akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  ll N, M;
  cin >> N >> M;
  if(M % 2 == 0) {
    if(N * 2 <= M && M <= N * 4) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3536
N = int(input())
b = list(map(int, input().split()))
a = []
for i in range(N):
    k = N - i
    for j in range(k):
        l = k - j
        if b[l-1] == l:
            a.append(l)
            del b[l-1]
            break
    if len(b) == k:
        break
if len(b) == 0:
    for i in reversed(range(N)):
        print(a[i])
else:
    print(-1)

Measured memory_bytes: 3064
#include <cstdio>
#include <queue>

int testcase_ends() {
  size_t n, k, m;
  scanf("%zu %zu %zu", &n, &k, &m);

  if (n == 0 && k == 0 && m == 0) return 1;

  std::queue<int> q;
  for (size_t i=0; i<n; ++i) q.push((m+i+n-1)%n+1);

  while (q.size() > 1) {
    q.pop();
    for (size_t i=1; i<k; ++i) {
      int tmp = q.front();
      q.pop();
      q.push(tmp);
    }
  }

  printf("%d\n", q.front());
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    vector<int> C = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    for (int i = 0; i < M; i++) {
        cin >> A[i];
    }
    vector<int> dp(N + 1, -1);
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        if (dp[i] == -1) continue;
        for (int j = 0; j < M; j++) {
            if (i + C[A[j]] <= N) {
                dp[i + C[A[j]]] = max(dp[i + C[A[j]]], dp[i] + 1);
            }
        }
    }

    int now = N;
    string ans = "";
    while(now != 0) {
        int ma = 0, ma_j = 0;
        for(int j = 0; j < M; j++) {
            if (now - C[A[j]] >= 0 && dp[now] - dp[now - C[A[j]]] == 1) {
                if (ma < A[j]) {
                    ma = A[j];
                    ma_j = j;
                }
            }
        }
        if (ma == 0) break;
        now -= C[ma];
        ans += '0' + A[ma_j];
    }
    cout << ans << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 256
n = int(input())
w = list(map(int, input().split()))
ans = 100000000000000000


for i in range(n):
  anslist1 = (w[0:i])
  anslist2 = (w[i:n])
  #print(anslist1)
  #print(anslist2)
  
  sum1 = sum(anslist1)
  sum2 = sum(anslist2)
  if abs(sum1 - sum2) < ans:
    ans = abs(sum1 - sum2)
print(ans)

Measured memory_bytes: 3060
/*
             much pretests
        ▄              ▄
        ▌▒█           ▄▀▒▌   wow vectors
        ▌▒▒█        ▄▀▒▒▒▐
       ▐▄█▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐        heckin_TLE
     ▄▄▀▒▒▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐
   ▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌
  ▐▒▒▒▄▄▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀▄▒▌      beautiful graphs
  ▌░░▌█▀▒▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐
 ▐░░░▒▒▒▒▒▒▒▒▌██▀▒▒░░░▒▒▒▀▄▌
 ▌░▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░▒▒▒▒▌  wow cp
▌▒▒▒▄██▄▒▒▒▒▒▒▒▒░░░░░░░░▒▒▒▐
▐▒▒▐▄█▄█▌▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▒▒▒▌        much time
▐▒▒▐▀▐▀▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▒▐
 ▌▒▒▀▄▄▄▄▄▄▀▒▒▒▒▒▒▒░▒░▒░▒▒▒▌     very memory
 ▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒▒▄▒▒▐
  ▀▄▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒▄▒▒▒▒▌
    ▀▄▒▒▒▒▒▒▒▒▒▒▄▄▄▀▒▒▒▒▄▀   much loops
      ▀▄▄▄▄▄▄▀▀▀▒▒▒▒▒▄▄▀
         ▀▀▀▀▀▀▀▀▀▀▀▀
         bugs do me a bamboozle
*/

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#ifdef on_linux
	#include <sys/resource.h>
#endif

#ifdef dobby_is_a_free_elf
	#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
	#define trace(...) 0;
#endif

using namespace std;
using namespace __gnu_pbds;


#define all(x)                  (x).begin(), (x).end()
#define between(i,x,y)          ((i) >= (x) && (i) <= (y))
#define DECIMAL(n)              cout << fixed << setprecision(n)
#define fi                      first
#define lbd                     lower_bound
#define mem0(x)                 memset(x, 0, sizeof (x))
#define mem1(x)                 memset(x, -1, sizeof (x))
#define mp                      make_pair
#define pb                      push_back
#define pf                      push_front
#define ppb                     pop_back
#define ppf                     pop_front
#define sc                      second
#define sqr(a)                  ((a) * (a))
#define sz(x)                   (int)((x).size())
#define ubd                     upper_bound

#define int                     long long

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <typename T>
using ordered_set = tree<T, null_type,
      less<T>,
      rb_tree_tag,
      tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0
// order_of_key(k) returns count of elements strictly smaller than k


const long double PI = 3.14159265358979323846264338;
const double eps = 1e-10;
#ifdef int
	const long long INF = 1e18;
#else
	const long long INF = 1e9;
#endif
const int32_t fftmod = 998244353;
const int32_t MOD = 1000000007;
const int32_t N = 1e5 + 10;
const int32_t NN = 1e6 + 10;



inline void elf_magic(int testcase)
{
	int a;
	cin >> a;
	double b;
	cin >> b;

	cout << (int)(a * (int)(100 * b + 0.5)) / 100;

	return;
}

int32_t main()
{
	#ifdef on_linux
	rlimit cpu_time {.rlim_cur = 2, .rlim_max = RLIM_INFINITY};
	setrlimit(RLIMIT_CPU, &cpu_time);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int TESTS = 1;
	//cin >> TESTS;
	for (int i = 1; i <= TESTS; ++i) {
		// cout << "Case #" << i << ": ";
		elf_magic(i);
		if (i != TESTS)	{ cout << '\n'; }
	}
	return 0;
}

Measured memory_bytes: 3684
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int L,A,B,C,D,cnt1=0,cnt2=0;
	cin>>L>>A>>B>>C>>D;
	while(A>0){
		A-=C;
		cnt1++;
	}
	while(B>0){
		B-=D;
		cnt2++;
	}
	cout<<min(L-cnt1,L-cnt2)<<endl;
}

Measured memory_bytes: 1160
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	for i := 0; i < 1<<3; i++ {
		v := int(s[0] - '0')
		for j := 0; j < 3; j++ {
			n := int(s[j+1] - '0')
			if i>>j&1 == 1 {
				n *= -1
			}
			v += n
		}
		if v == 7 {
			for j := 0; j < 3; j++ {
				fmt.Printf("%c", s[j])
				if i>>j&1 == 1 {
					fmt.Printf("-")
				} else {
					fmt.Printf("+")
				}

			}
			fmt.Printf("%c=7\n", s[3])
			return
		}
	}
}


Measured memory_bytes: 1832
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;

int check[1000001];
int arr[200000];

int main(void)
{
	int n, ans;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &arr[i]);
	for(int i = 0; i < n; i++)
		if (check[arr[i]] == 0)
		{
			for (int j = arr[i] * 2; j <= 1000000; j += arr[i])
				check[j] = 1;
			check[arr[i]] = 2;
		}
		else if (check[arr[i]] == 2)
			check[arr[i]] = 1;
			
	ans = 0;
	for (int i = 0; i < n; i++)
		if (check[arr[i]] != 1)
			ans++;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 6416
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=101000;
int n;
ll a[N],b[N],x;
int main() {
	scanf("%d",&n);
	rep(i,0,n) scanf("%lld%lld",a+i,b+i);
	per(i,0,n) {
		a[i]+=x;
		a[i]%=b[i];
		if (a[i]!=0) x+=b[i]-a[i];
	}
	printf("%lld\n",x);
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;
using Q = std::tuple<int,int,int>;

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

template <int n>
struct UnionFind{
    UnionFind(){
        for(int i=0;i<n;i++){
            par[i] = i;
            rank[i] = 0;
        }
    }
    int find(int x){
        if(x == par[x])return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y){return;}
        
        if(rank[x] > rank[y]){
            par[y] = x;
        }else{
            par[x] = y;
            if(rank[x] == rank[y]){rank[y]++;}
        }
    }
    int rank[n], par[n];
};

vector<Q> edges;
UnionFind<1000> uf;

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

    int N, M;
    while(true){
        std::cin >> N >> M;

        if(N == 0 && M == 0){return 0;}

        edges.clear();
        uf = UnionFind<1000>();
    
        int sum = 0;
    
        for(int i=0;i<M;++i){
            int u, v, cost;
            std::cin >> u >> v >> cost;

            edges.emplace_back(cost, u, v);
        }
    
        sort(edges.begin(), edges.end());

        for(Q &q : edges){
            int u, v, cost;
            tie(cost, u, v) = q;

            if(uf.same(u, v)){
                continue;
            }

            uf.unite(u, v);
            sum += cost;
        }

        std::cout << sum << std::endl;
    }
}

Measured memory_bytes: 3088
import sys
input = sys.stdin.readline
dish = []
min = 10
ans = 0
for _ in range(5):
	tmp = int(input())
	if tmp % 10 < min and tmp % 10 != 0:
		min = tmp % 10
	if tmp % 10 != 0:
		tmp += 10 - (tmp % 10)
	dish.append(tmp)
print(sum(dish)-(10-min))

Measured memory_bytes: 38384
// Problem : B - Between a and b ...
// Contest : AtCoder - AtCoder Beginner Contest 048
// URL : https://atcoder.jp/contests/abc048/tasks/abc048_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a) for (int i=0; i<(a); i++)
#define rep1(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rep(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define imax INT_MAX
#define imin INT_MIN
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

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

 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

signed main() { 
	ll a,b,x;
	cin>>a>>b>>x;
	cout<<b/x-a/x+(a%x==0)?1:0;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3636
from scipy.special import comb

n, k = map(int, input().split())
cnt1 = 0
cnt2 = 0

if k%2 == 1:
    for i in range(1, n+1):
        if i%k == 0:
            cnt1 += 1
    print(cnt1**3)
else :
    for i in range(1, n+1):
        if i%k == 0:
            cnt1 += 1
        elif i%k == k//2:
            cnt2 += 1
    print(cnt1**3+cnt2**3)

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

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

using namespace std;
typedef pair<int, int> Weight;

pair<int,int> operator+(const pair<int,int>& lhs, const pair<int,int>& rhs) {
  return make_pair(lhs.first + rhs.first, rhs.second);
}

Weight INF = make_pair(1000000000,1000000000);
struct Edge{
  int src, dest; Weight weight;
  bool operator < (const Edge &rhs) const {return weight > rhs.weight;}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void dijkstra(Graph &g, Array &d, int s) {
  d.assign(g.size(), INF);
  d[s] = make_pair(0,0);
  typedef pair<Weight,int> P;
  priority_queue<P, vector<P>, greater<P> > que;
  que.push(P(make_pair(0,0), s));
  while (!que.empty()) {
    Weight dist = que.top().first;
    int v = que.top().second;
    que.pop();
    if (d[v] < dist) continue;
    REP(i, g[v].size()) {
      Edge e = g[v][i];
      if (d[e.dest] > d[v] + e.weight) {
        d[e.dest] = d[v] + e.weight;
        que.push(P(d[e.dest], e.dest));
      }
    }
  }
}

int main() {
  while(1){
    int n,m;
    cin>>n>>m;
    if(!n) break;
    Graph g(n);
    REP(i,m) {
      int a,b,d,c;
      cin>>a>>b>>d>>c;
      --a;--b;
      g[a].push_back((Edge){a,b,make_pair(d,c)});
      g[b].push_back((Edge){b,a,make_pair(d,c)});
    }
    Array dist(n);
    dijkstra(g, dist, 0);
    int cost = 0;
    REP(i,n) {
      if(!i) continue;
      cost += dist[i].second;
    }
    cout << cost << endl;
  }
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
 
int main() {
     
    int n,a[200][3]={},count[3][102]={},score[201]={};
     
    cin>>n;
 
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>a[i][j];
            count[j][a[i][j]]++;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            if(count[j][a[i][j]] == 1) score[i]+=a[i][j];
        }
    cout<<score[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1164
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let k: usize = iterator.next().unwrap().parse().unwrap();
    let o: usize = (k + 1) / 2;
    let e: usize = k / 2;
    return (o * e).to_string();
}


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

int main(void) {
	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	string t[4] = {"dream", "dreamer", "erase", "eraser"};
	for (int i = 0; i < 4; i++) {
		reverse(t[i].begin(), t[i].end());		
	}
	bool flag1 = true;
	for (int i = 0; i < s.size();) {
		bool flag2 = false;
		for (int j = 0; j < 4; j++) {
			if (s.substr(i, t[j].size()) == t[j]) {
				flag2 = true;
				i += t[j].size();
			}
		}
		if (!flag2) {
			flag1 = false;
			break;
		}
	}
	(flag1)? puts("YES"):puts("NO");

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n; cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int ans = 0;
    int nowMin = p[0];
    rep(i,n) {
        if (i != 0 && nowMin == 1) break;
        if (p[i] > nowMin) {
            continue;
        }
        ans++;
        nowMin = min(nowMin, p[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
//B - NarrowRectanglesEasy: 
//Assunto: 
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int w, a, b, ans;
    cin >> w >> a >> b;
    if(b + w < a) ans = a - (b + w);
    else if(a + w < b) ans = b - (a + w);
    else ans = 0;
    cout << ans <<'\n';
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;

fn solve(ss: &Vec<(i32, i32)>) -> bool {
  let sum: i32 = ss.iter().map(|&(_, l)| l).sum();
  if sum != 0 {
    return false;
  }
  let mut gain: i32 = ss
    .iter()
    .filter_map(|&(b, l)| if b >= 0 { Some(l) } else { None })
    .sum();
  let (mut up, mut down): (Vec<(i32, i32)>, Vec<(i32, i32)>) = ss
    .iter()
    .filter(|&&(b, _)| b < 0)
    .partition(|&&(_, l)| l >= 0);
  up.sort_by_key(|&(b, _)| -b);
  down.sort_by_key(|&(b, l)| b - l);
  for &(b, l) in &up {
    if gain + b < 0 {
      return false;
    }
    gain += l;
  }
  for &(b, l) in &down {
    if gain + b < 0 {
      return false;
    }
    gain += l;
  }
  gain == 0
}

#[fastout]
fn main() {
  input! {
    n: usize,
    ss: [Chars; n],
  }
  let ss: Vec<_> = ss
    .into_iter()
    .map(|s| {
      let mut current = 0;
      let mut bottom = 0;
      for c in s.into_iter() {
        if c == '(' {
          current += 1;
        } else {
          current -= 1;
        }
        bottom = cmp::min(bottom, current);
      }
      (bottom, current)
    })
    .collect();

  println!("{}", if solve(&ss) { "Yes" } else { "No" });
}


Measured memory_bytes: 66272
#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<stack>
#include<queue>
#include<string>
#include<set>
#define ll long long
using namespace std;
int main()
{
int a,b,c,d,e;
scanf("%d",&e);

//scanf("%d%d%d%d",&a,&b,&c,&d);
d=e%10;
c=(e/10)%10;
b=(e/100)%10;
a=(e/1000)%10;
int flag=0;
while(a+b+c+d==7&&flag==0)
{
	printf("%d+%d+%d+%d=7\n",a,b,c,d);
	flag=1;
	break;
}
while(a+b+c-d==7&&flag==0)
{
	printf("%d+%d+%d-%d=7\n",a,b,c,d);
	flag=1;
		break;
}
while(a+b-c+d==7&&flag==0)
{
	printf("%d+%d-%d+%d=7\n",a,b,c,d);
	flag=1;
	break;
}
while(a+b-c-d==7&&flag==0)
{
	printf("%d+%d-%d-%d=7\n",a,b,c,d);
	flag=1;
	break;
}
while(a-b+c+d==7&&flag==0)
{
	printf("%d-%d+%d+%d=7\n",a,b,c,d);
	flag=1;
	break;
}
while(a-b+c-d==7&&flag==0)
{
	printf("%d-%d+%d-%d=7\n",a,b,c,d);
	flag=1;
	break;
}
while(a-b-c+d==7&&flag==0)
{
	printf("%d-%d-%d+%d=7\n",a,b,c,d);
	flag=1;
	break;
}
while(a-b-c-d==7&&flag==0)
{
	printf("%d-%d-%d-%d=7\n",a,b,c,d);
	flag=1;
	break;
}
 
 return 0;
 }
 
//printf("%d%c",mp[i][j],j==n?'\n':' ');


Measured memory_bytes: 256
n, m = map(int, input().split())


A = [[1, 1]] + [[0, 1] for _ in range(n-1)]

for _ in range(m):
    x, y = map(lambda x: int(x) - 1, input().split())
    A[x][1] -= 1
    A[y][1] += 1
    if A[x][0]:
        A[y][0] = 1

    if A[x][1] == 0:
        A[x][0] = 0

print(sum(a[0] for a in A))

Measured memory_bytes: 15204
#!/usr/bin/env python
import sys
from math import modf

class Bigint:
    def __init__(self,n,mod=10**9+7):
        self.n = n % mod
        self.mod = mod
        return
    #
    def __str__(self):
        return str(self.n)
    #
    def __add__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        return Bigint(self.n+other.n,self.mod)
    #
    def __iadd__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        self.n = (self.n + other.n) % self.mod
        return self
    #
    def __sub__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        return Bigint(self.n-other.n,self.mod)
    #
    def __isub__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        self.n = (self.n - other.n) % self.mod
    #
    def __mul__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        return Bigint(self.n*other.n,self.mod)
    #
    def __imul__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        self.n = ( self.n * other.n ) % self.mod
        return self
    #
    def __pow__(self,other):
        assert type(other)==int, "power should be integer"
        #
        if other<0: return self ** ( other % ( self.mod-1 ) )
        ret = Bigint(1,self.mod)
        now = Bigint(self.n,self.mod)
        while other>0:
            if other%2==0: pass
            else: ret *= now
            other//=2
            now*=now
        return ret
    #
    def __truediv__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        return self * ( other ** (other.mod-2) )
    #
    def __itruediv__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        self*= ( other ** (other.mod-2) )
        return self


def _ia(): return [ int(x) for x in sys.stdin.readline().strip().split() ]

def main():
    x,y = _ia()

    b = (2*x - y)/3
    if b.is_integer():
        b = int("{:.0f}".format(b))
        if b<0: return 0
    else:
        return 0

    a = x - 2*b
    if a<0: return 0
    n = a + b
    m = min(a,b)
    ans = Bigint(1)
    for i in range(m,0,-1):
        ans *= Bigint(n)
        ans /= Bigint(i)
        n -= 1
    #
    return ans
#
if __name__=="__main__":
    print(main())


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

int main() {
  int n;
  cin>>n;
  string s;
  cin>>s;
  int cnt = 0;
  char open = '(';
  char close = ')';
  deque<char> dq;
  for (int i=0; i<n; i++) {
    char c = s[i];
    if (c == open) {
      ++cnt;
    } else {
      if (cnt > 0) {
        --cnt;
      } else {
        dq.push_front(open);
      }
    }
    dq.push_back(c);
  }
  for (int i=0; i<cnt; i++) {
    dq.push_back(close);
  }
  for (char c: dq) {
    cout<<c;
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;

int main()
{
	string C1, C2;
	cin >> C1 >> C2;
	if (C1[0]==C2[2] && C1[1] == C2[1] && C1[2] == C2[0])
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << 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() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<vector<int>> x(N), y(N);
    rep(i, N) {
        cin >> A[i];
        rep(j, A[i]) {
            x[i].push_back(0);
            y[i].push_back(0);
            cin >> x[i].back() >> y[i].back();
            x[i].back()--;
        }
    }
    int ans = 0;
    rep(k, 1 << N) {
        bool f = true;
        rep(i, N) {
            rep(j, A[i]) {
                if (y[i][j] == 1 && ((k >> i) & 1) == 1 && ((k >> x[i][j]) & 1) == 0) f = false;
                if (y[i][j] == 0 && ((k >> i) & 1) == 1 && ((k >> x[i][j]) & 1) == 1) f = false;
            }
        }
        if (f) {
            int s = 0;
            rep(i, N) {
                s += (k >> i) & 1;
            }
            ans = max(ans, s);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <iterator>
#include <array>
#include <cmath>

#define int long long

using namespace std;

const int inf = 1e12 + 57;

signed main()
{   
    int n, m;
    cin >> n >> m;
    if (n == 1 && m == 0)
    {
        cout << 0;
        return 0;
    }
    vector<int> a(n, -1);
    for(int i = 0;i < m; ++i)
    {
        int x, y;
        cin >> x >> y;
        --x;
        if (a[x] != y && a[x] != -1)
        {
            cout << -1;
            return 0;
        }
        a[x] = y;
    }
    if (a[0] == -1)
        a[0] = 1;
    else if (a[0] == 0 && a.size() != 1)
    {
        cout << -1;
        return 0;
    }
    for(int i : a)
    {
        if (i == -1)
        {
            cout << 0;
        }
        else
        {
            cout << i;
        }
    }
}

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

using namespace std;

int K, T;
int a[1 << 20];

int main() {
  scanf("%d%d", &K, &T);
  for (int i = 0; i < T; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < T; i++) {
    if (a[i] > (K + 1) / 2) {
      if (K % 2 == 0) {
        int ans = a[i] - (K + 1) / 2;
        ans*=2;
        ans--;
        printf("%d\n", ans);
      } else {
        int ans = (a[i] - (K + 1) / 2)*2;
        printf("%d\n", ans);
      }
      return 0;
    }
  }
  puts("0");
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
	string s,t;
	cin>>s;
	cin>>t;
	vector<vector<ll> > vv(26,vector<ll>());
	rep(i,0,s.sz){
		vv[s[i]-'a'].pb(i);
	}
	rep(i,0,t.sz){
		if(vv[t[i]-'a'].sz==0){
			cout << -1 << endl;
			return 0;
		}
	}
	ll ans = 0;
	ll p = 0;
	rep(i,0,t.sz){
		ll a = t[i]-'a';
		long long low = 0;
		long long high = vv[a].sz-1;
		
		while(low < high){
		  long long mid = (high + low) >> 1;
		
		  if(p<=vv[a][mid]){
		    high = mid;
		  }
		  else{
		    low = mid + 1;
		  }
		}
		if(!(p<=vv[a][low])){
			p = 0;
			ans += s.sz;
			i--;
			continue;
		}
		p = vv[a][low]+1;
		if(p==s.sz){
			ans += s.sz;
			p = 0;
		}
	}
	cout << ans + p << endl;
	return 0;
}

Measured memory_bytes: 1724
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int imos[1010][1010];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  FOR(i,0,N) {
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    imos[y1][x1]++;
    imos[y1][x2]--;
    imos[y2][x1]--;
    imos[y2][x2]++;
  }
  FOR(x,0,1010) {
    FOR(y,1,1010) {
      imos[y][x] += imos[y-1][x];
    }
  }
  int ans = imos[0][0];
  FOR(y,0,1010) {
    FOR(x,1,1010) {
      imos[y][x] += imos[y][x-1];
    }
  }
  FOR(y,0,1010) {
    FOR(x,0,1010) {
      ans = max(ans, imos[y][x]);
    }
  }
  cout << ans << endl;
}


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

int main(){
    int n,s;
    cin >> n;
    for (int i=0; i < n; i++){
        int a=0, b=0, flg=0;
        for (int j = 0; j < 10; j++){
            cin >> s;
            if (s > a) a=s;
            else if (s > b) b=s;
            else flg = 1;
        }
        printf("%s\n", flg==0? "YES": "NO");
    }
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {     
	int n;
	cin >> n;
	vector<int> a(n);
	int x = 0;
	for (int i = 0; i < n; ++i) cin >> a[i], x ^= a[i];
	for (int i = 0; i < n; ++i) cout << (a[i] ^ x) << ' ';  
}                                                    


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  ll l,r; cin>>l>>r;
  if (r-l<=1e4) {
    ll res = 0;
    for (ll x=l; x<=r; x++) {
      res = res ^ x;
    }
    out(res);
  }
  
  ll res = 0;
  while (l%4!=0) {
    res = res ^ l; l++;
  }
  while (r%4!=0) {
    res = res ^ r; r--;
  }
  res = res ^ r;
  out(res);
  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)

class UnionFind{
public:
	vector<int> par;
	//0-indexed
	UnionFind(int n){init(n);}
	void init(int n = 1) {
		par.resize(n);
		for(int i=0;i<n;++i)par[i]=i;
	}
	int root(int x = 1){
		if(par[x]==x)return x;
		return par[x]=root(par[x]);
	}
	void unite(int x = 1,int y = 1){
		x = root(x);
		y = root(y);
		if(x==y)return;
		par[x] = y;
	}
};

int main(){
	ll N,xi,yi,ans=0;
	cin >> N;
	UnionFind uf(N);
	vector<ll> x(100001,-1),y(100001,-1),nx(N,0),ny(N,0);
	FOR(i,0,N){
		cin >> xi >> yi;
		if((x[xi]==-1)&&(y[yi]==-1)){
			x[xi] = y[yi] = i;
		}else if((x[xi]!=-1)&&(y[yi]==-1)){
			y[yi] = x[xi];
		}else if((x[xi]==-1)&&(y[yi]!=-1)){
			x[xi] = y[yi];
		}else{
			uf.unite(x[xi],y[yi]);
		}
	}
	FOR(i,0,100001){
		if(x[i]!=-1)nx[uf.root(x[i])]++;
		if(y[i]!=-1)ny[uf.root(y[i])]++;
	}
	FOR(i,0,N){
		ans += nx[i]*ny[i]-1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3712
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String[] line = sc.nextLine().split(" ");
			ArrayList<Integer> list = new ArrayList<Integer>(Arrays.asList(1,2,3,4,5,6,7,8,9,10));
			int a = Integer.parseInt(line[0]);
			int b = Integer.parseInt(line[1]);
			int c = Integer.parseInt(line[2]);
			list.remove(list.indexOf(a));
			list.remove(list.indexOf(b));
			list.remove(list.indexOf(c));
			int count =0;
			for(int i = 0; i < list.size();i++){
				if(a+b+list.get(i) <= 20){
					count++;
				}
			}
			double rate = (double) count/7;
			System.out.println(rate < 0.5 ? "NO":"YES");
		}
	}

}

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

int main(void){
	string s1,s2;
	cin>>s1>>s2;
	for(int L=min(s1.size(),s2.size());L>=1;L--){
		vector<int> a(26),b(26);
		set<vector<int>>st;
		rep(i,L)a[s1[i]-'a']++;
		rep(i,4000){
			st.insert(a);
			if(i+L==(int)s1.size())break;
			a[s1[i]-'a']--;
			a[s1[i+L]-'a']++;
		}

		rep(i,L)b[s2[i]-'a']++;
		rep(i,4000){
			if(st.find(b)!=st.end()){
				cout<<L<<endl;
				return 0;
			}
			if(i+L==(int)s2.size())break;
			b[s2[i]-'a']--;
			b[s2[i+L]-'a']++;			
		}
	}
	cout<<0<<endl;

	return 0;
}

Measured memory_bytes: 3868
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;文字列 -> 整数
(defn Int [s] (Integer/parseInt s))
;文字列 -> 文字列
(defn Str [s] s)

;scanf的なノリで1行をいい感じに読み取る
;定数が重いので注意
(defn input [varTypes]
    (mapv 
        (fn [f s] (f s)) ;文字列sに関数fを適用する
        varTypes         ;適用する関数
        (clojure.string/split 
            (read-line)  ;1行を読み込み
            #" "         ;区切り文字
        )
    )
)

;スペース区切りの整数を受け取る
;速い
(defn inputFast [varType]
    (map
        varType
        (clojure.string/split 
            (read-line)  ;1行を読み込み
            #" "         ;区切り文字
        )
    )
)

(defn floor [a b] (quot a b))
(defn ceil [a b] (floor (- (+ a b) 1) b))
(defn abs [a] (if (>= a 0) a (- 0 a)))

;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
(defn f[x]
    (if (= 0 (mod x 2))
        (+ 1 (f (floor x 2)))
        0
    )
)
(dosync
(read-line)
(let [a (inputFast Int)]
    (println 
        (reduce (fn [x y] (min x (f y))) 100 a)
    )
)
)

Measured memory_bytes: 65388
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int i,j;
  string s="No";
  for(i=0;i<26;i++){
    for(j=0;j<15;j++){
      if(4*i+7*j==n){
        s="Yes";
      }
    }
  }
  cout << s;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main() {
    int64_t n, s;
    cin >> n >> s;

    if (n < s) {
        cout << -1 << endl;
        quick_exit(0);
    }

    if (n == s) {
        cout << n + 1 << endl;
        quick_exit(0);
    }

    int64_t x = 4e+5, y = n / x;

    for (int64_t b = 2; b < x; b++) {
        int64_t t = 0;
        for (int64_t m = n; m > 0;) {
            t += m % b; m /= b;
        }
        if (t == s) {
            cout << b << endl;
            quick_exit(0);
        }
    }

    int64_t b = -1;
    for (int64_t i = 1; i <= y; i++) {
        int64_t j = s - i;
        if (j < 0) break;
        int64_t r = (n - j) % i;
        int64_t t = (n - j) / i;
        if (r != 0 || j >= t) continue;
        b = t;
    }

    cout << b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007

int main(void)
{
    int N,M;
    cin >> N >> M;

    vector<int> H(N);
    REP (i,N) {
        cin >> H[i];
    }

    vector<bool> T(N,true);
    int A,B;
    REP (i,M) {
        cin >> A >> B;
        if (H[A-1] > H[B-1]) {
            T[B-1] = false;
        }
        else if (H[A-1] < H[B-1]) {
            T[A-1] = false;
        }
        else {
            T[A-1] = false;
            T[B-1] = false;
        }
    }

    ll ans = 0;
    REP (i,N) {
        if (T[i]) {
            ans++;
        }
    }
 
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3796
#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
n,m=map(int,input().split())
b=[list(map(int,input().split())) for _ in range(n)]
res=0
ans=0
b.sort(key=lambda x: x[0])
for i in range(n):
    if res+b[i][1]<=m:
        ans+=b[i][0]*b[i][1]
        res+=b[i][1]
    else:
        ans+=b[i][0]*(m-res)
        break
print(ans)

Measured memory_bytes: 29372
/*
                    Author: Ankit Kaul
    **********************Code Belongs to Respective Author Only************************************
    */
    /*#pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
    #include <bits/stdc++.h>
    #define endl       '\n'
    #define PI          3.141592653589
    #define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #define M           1000000007
    #define int         long long int
    #define inf         INT_MAX
    #define pb          emplace_back
    #define pf          emplace_front
    #define pii         pair<int,int>
    #define vi          vector<int>
    #define vii         vector<pii>
    #define mi          map<int,int>
    #define mii         map<pii,int>
    #define all(a)      (a).begin(),(a).end()
    #define rall(a)     (a).rbegin(),(a).rend()
    using namespace std;
    int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
    int power(int x,int n){
        int result=1;
        while(n>0)
        {   if(n % 2 ==1)
            result=(result * x) % M;
            x=(x*x)% M;
            n=n/2;
        }
    return result % M;
    }      
    bool isPrime(int n) 
    { 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
    } 
    signed main()
    {   jaldi
        int i,n,count=0;
        cin>>n;
        map<string,int> mp;
        string str[n];
        for(i=0;i<n;i++)
        {   cin>>str[i];
            mp[str[i]]++;
        }
        for(i=0;i<n;i++)
        count=max(mp[str[i]],count);
        for(i=0;i<n;i++)
        {   if(mp[str[i]]!=count)
            mp[str[i]]=0;
        }
        sort(str,str+n);
        for(i=0;i<n;i++)
        {   if(mp[str[i]]==0)
            continue;   
            else
            {   cout<<str[i]<<endl;
                mp[str[i]]=0;
            }
        }
    }   


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

int main() {
    using namespace std;
    string s;
    cin >> s;
    vector<unsigned long> tapi(300);
    for(const auto c : s)++tapi[c];
    unsigned long ans{1 + s.size() * (s.size() + 1) / 2};
    for(const auto i : tapi)ans -= i * (i + 1) / 2;
    cout << ans << endl;
    return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)


int32_t main()
{

	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		ans += (n - 1) / i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
A=get_i.sort{|x,y| y<=>x}
if N==2
    puts A[0]
    exit
end
k=0
ans=0
1.upto(N-1) do|i|
    if i.even?
      ans+=A[k+1]
      k+=1
    else
        ans+=A[k]
    end
end
puts ans

Measured memory_bytes: 33316
#include <stdio.h>
int main() {
	int n, q, l, r, cnt[100000];
	char s[100000];
	scanf("%d%d%s", &n, &q, s);
	cnt[0] = 0;
	for (int i = 1; i < n; i++) {
		cnt[i] = cnt[i - 1];
		if (s[i - 1] == 'A' && s[i] == 'C') {
			cnt[i]++;
		}
	}
	for (int i = 0; i < q; i++) {
		scanf("%d%d", &l, &r);
		printf("%d\n", cnt[r - 1] - cnt[l - 1]);
	}
	return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    
	    double N=sc.nextLong();
	    
	    double time[]=new double[5];
	    time[0]=sc.nextLong();
	    time[1]=sc.nextLong();
	    time[2]=sc.nextLong();
	    time[3]=sc.nextLong();
	    time[4]=sc.nextLong();
	    
	    
	    double neck=0;
	    
	    for(int i=0;i<5;i++) {
	    	if(neck<Math.ceil(N/time[i])) {
	    		neck=Math.ceil(N/time[i]);
	    	}
	    }
	    
	    System.out.println(String.format("%.0f", neck+4));
	}

}


Measured memory_bytes: 22740
from math import factorial
def com(n,r):
  if n<r:
    return 0
  return int(factorial(n) // factorial(r) // factorial(n-r))

n=int(input())
l_list=[]

for _ in range(n):
  l=sorted(input())
  l_list.append(l)

l_list = sorted(l_list)

count=0

ans = 0
i = 0
j = 1
while i < n:
  tmp = 0
  while i + j < n and l_list[i] == l_list[i + j]:
    tmp += 1
    j += 1
  if tmp != 0:
    ans += com(tmp+1, 2)
  i += j
  j = 1

print(ans)

Measured memory_bytes: 25472
import java.util.Scanner
import scala.util.control.Breaks

object Main {
  def Yenof(money_unit: String)(money: Double): Double = {
    if (money_unit.equals("BTC")) {
      money * 380000
    } else {
      money
    }
  }

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val N = sc.nextInt()
    var x = Seq[Double]()
    var u = Seq[String]()
    0.until (N).foreach (_ => {
      x :+= sc.nextDouble()
      u :+= sc.next()
    })

    val otoshidama_yen: Seq[Double] = u.zip(x).map(unit_money => {
      val unit = unit_money._1
      val money = unit_money._2
      Yenof(unit)(money)
    })

    print(otoshidama_yen.sum)
  }
}

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

int main(){
 int N, M;
 cin >> N >> M;
  
 int NMMAX = 50;
 int A[NMMAX],B[NMMAX]; 
  
 for (int i = 0;i < M;i++) {
   cin >> A[i] >> B[i];
 }
  
 int road[NMMAX];
 for (int i = 0;i < N; i++) {
   road[i] = 0;
 }
  
 for (int i = 0; i < M; i++) {
   road[A[i] - 1] += 1;
   road[B[i] - 1] += 1;
 }
  
 for (int i = 0; i < N; i++) {
   cout << road[i] << endl;
 }
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
LL n;
bool check (LL x)
{
	if (x==0) return false;
	return (n/x)==(n%x);
}
int main()
{
	scanf("%lld",&n);
	LL ans=0;
	for (LL u=1;u*u<=n;u++)
	{
		if (check(u-1)) ans=ans+u-1;
		if (u*u!=n&&check(n/u-1)) ans=ans+n/u-1;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int s[1000001];
bool b[1000001], ono;
int gcd(int x, int y){
	while (y) y ^= x ^= y ^= x %= y;
	return x;
}
int main(){
	for (int i = 2; i <= 1000000; i++){
		if (s[i] == 0){
			for (int j = i * 2; j <= 1000000; j += i){
				s[j] = i;
			}
		}
	}
	int n, a, g;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &a);
		if (i == 0) g = a;
		else g = gcd(g, a);
		set<int> se;
		while (s[a] != 0){
			se.emplace(s[a]);
			a /= s[a];
		}
		if (a != 1) se.emplace(a);
		for (int e : se){
			if (b[e]) ono = true;
			b[e] = true;
		}
	}
	if (!ono){
		printf("pairwise coprime\n");
	}else if (g == 1){
		printf("setwise coprime\n");
	}else{
		printf("not coprime\n");
	}
}

Measured memory_bytes: 8580
import java.util.*;
     
    public class Main {
      public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n= sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        int cnt = 0;
        for (int i = 0; i < k; i++) {
          int d = sc.nextInt();
          for (int j = 0; j < d; j++) {
              int p = sc.nextInt();
              a[p-1]++;
          }
        }
        
        for (int j = 0; j < n; j++) {
          if (a[j] == 0) {
            cnt++;
          }
        }
        System.out.println(cnt);
      }
    }  

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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)


template <typename T>
void debug_out(T t) {
  cerr << t;
}

template <typename A, typename B>
void debug_out(pair<A, B> u) {
  cerr << "(" << u.first << " " << u.second << ")";
}

template <typename T>
void debug_out(vector<T> t) {
  int sz = t.size();
  for(int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if(i != sz - 1) cerr << ", ";
  }
}

template <typename T>
void debug_out(vector<vector<T>> t) {
  int sz = t.size();
  for(int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if(i != sz - 1) cerr << endl;
  }
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__), cerr << endl;

int n;
string s;

int main() {
  cin >> n >> s;
  vector<int> a, b;
  range(i, 0, 2 * n) {
    if(s[i] == 'a') a.push_back(i);
    else b.push_back(i);
  }
  vector<string> dp(n + 1);
  husk(i, n - 1, -1) {
    dp[i] = dp[i + 1];
    if(b[i] < a[i]) {
      int pos = i;
      string c;
      vector<int> id;
      while(pos < n && b[pos] < a[pos] && (pos == i || b[pos] < a[pos - 1])) {
        id.push_back(b[pos]);
        id.push_back(a[pos]);
        pos++;
      }
      sort(id.begin(), id.end());
      for(int j : id) c += s[j];
      dp[i] = max(dp[i], c + dp[pos]);
    } else {
      int pos = i;
      while(pos < n && a[pos] < b[i]) pos++;
      dp[i] = max(dp[i], "ab" + dp[pos]);
    }
  }
  cout << dp[0] << endl;;
  return 0;
}


Measured memory_bytes: 15616
#include <stdio.h>

int main(void)
{
	double max;
	double min;
	double height;
	max=0;
	min=100000;
	int i;
	for(i=0;i<=50;i++){
		scanf("%lf",&height);
		if(height > max) max = height;
		if(height < min) min = height;
	}
	printf("%.1f\n",max-min);
	return 0;
}

Measured memory_bytes: 652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

    	Scanner scan = new Scanner(System.in);

        int    A = scan.nextInt();
      	String S = scan.next();

      	S = A >= 3200 ? S : "red";
        
        System.out.print(S);

      	scan.close();

	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s,t,u;
  int a,b;
  cin>>s>>t>>a>>b>>u;
  if (s==u) cout<<a-1<<' '<<b<<endl;
  else if (t==u) cout<<a<<' '<<b-1<<endl;
}

Measured memory_bytes: 256
// ========================================================================================================
// Library
// ========================================================================================================
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
using namespace std;

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ========================================================================================================
// ========================================================================================================

int main()
{
	fastIOS();

	int a,b; cin >> a >> b;
    
    int res = INT_MAX;
    int tmp1 = 25*a/4 + 5*b;
    int tmp2 = ceil(25.0*(a+1)/4.0 + 5*(b+1));
    for(int i = tmp1 ; i <= tmp2 ; i++)
    {
        if(i*2/25 == a && i/10 == b && res > i)
        {
            res = i;
        }
    }
    
    if(res != INT_MAX){
        cout << res << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char *argv[])
{
  using namespace std;
  int a, b, c;
  cin >> a >> b >> c;
  if (a < b && b < c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1156