akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) (find(all(v),x)!=v.end())
#define incls(s,c) (s.find(c)!=string::npos)
#define lb(a,x) distance((a).begin(),lower_bound(all(a),(x)))
#define ub(a,x) distance((a).begin(),upper_bound(all(a),(x)))
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(all(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; cin >> x; return x;}
inline ll lin() { ll x; cin >> x; return x;}
inline char chin() { char x; cin >> x; return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; cin >> x; return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int a, b;
  cin >> a >> b;
  cout << a*b << endl;
  return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        Integer towns = Integer.parseInt(sc.nextLine());
        String[] Monsters = sc.nextLine().split(" ");
        String[] Braves = sc.nextLine().split(" ");

        long huntCount = 0;
        for (int i = 0; i < towns; i++) {
            int firstMonsters = Integer.parseInt(Monsters[i]);
            int bravePower = Integer.parseInt(Braves[i]);

            if (firstMonsters <= bravePower) {
                // 1つ目の町は全滅できる
                huntCount += firstMonsters;

                int secondMonsters = Integer.parseInt(Monsters[i + 1]);
                int remainBravePower = bravePower - firstMonsters;
                if (remainBravePower >= secondMonsters) {
                    // 2個目の町も全滅できる
                    huntCount += secondMonsters;
                    Monsters[i + 1] = String.valueOf(0);
                } else {

                    // ちょっと残る
                    huntCount += remainBravePower;
                    Monsters[i + 1] = String.valueOf(secondMonsters - remainBravePower);
                }
            } else {

                // 1個目の町も全滅できないが何匹かは倒せる
                huntCount += bravePower;
            }
            System.err.println(huntCount);
        }

        System.err.println();
        System.out.println(huntCount);
    }
}


Measured memory_bytes: 69212
import scala.io.StdIn

/**
  * AOJ
  */
object Main {

  def main(args: Array[String]): Unit = {
    val in = StdIn.readLine().split(" ").map(s => s.toInt)

    println(if(in(4) <= in(2) && in(2) <= (in(0) - in(4)) && in(4) <= in(3) && in(3) <= (in(1) - in(4))){"Yes"}else{"No"})
  }
}

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

int main(void){
  int gamenum;
  string taro,hanako;
  int taropoint,hanakopoint;
  taropoint = 0;
  hanakopoint = 0;

  cin >> gamenum;

  while ( gamenum > 0){
    cin >> taro >> hanako;

    for ( int i = 0 ; (taro[i] != '\0') && (hanako[i] != '\0') ; i++){
      if(taro[i] > hanako[i]){
        taropoint += 3;
        break;
      }else if(taro[i] < hanako[i]){
        hanakopoint += 3;
        break;
      }else if(taro[i] == hanako[i]){
        if((taro[i+1] == '\0') && (hanako[i+1] == '\0')){
          taropoint++;
          hanakopoint++;
          break;
        }else if((taro[i+1] == '\0') && hanako[i+1] != '\0'){
          hanakopoint += 3;
          break;
        }else if((taro[i+1] != '\0') && hanako[i+1] == '\0'){
          taropoint += 3;
          break;
        }
      }
    }

    gamenum--;
  }

  cout << taropoint << " " << hanakopoint << endl;
}

Measured memory_bytes: 3132
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,k = inm()
for i in range(40):
    if k**i>n:
        print(i)
        exit()


Measured memory_bytes: 38468
#include <iostream>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

ll Conbi(ll a)
{
    return a * (a-1) / 2;
}

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

    map<int, ll> C;
    ll total = 0;
    RPT(i, N) {
        int tmp;
        cin >> tmp;
        total += tmp;
        C[total % M]++;
    }

    ll count = 0;
    for (auto it = C.begin(); it != C.end(); it++) {
        count += Conbi(it->second);
        if (it->first == 0) count += it->second;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
const int maxn = 123456;
int vis[maxn];
vector<int> e[maxn];
vector<pair<int,int> > res;
int dfs(int u, int p){
	vis[u] = 1;
	int s = 0;
	for(int v : e[u]){
		if(v == p) continue;
		if(vis[v] == 2) continue;
		if(vis[v] == 1) s ^= 1, res.push_back({u, v});
		else {
			int vs = dfs(v, u);
			if(vs) res.push_back({v, u});
			else res.push_back({u, v}), s ^= 1;
		}
	}
	vis[u] = 2;
	return s;
}
int main(){
	int n, m; cin >> n >> m;
	for(int i = 0; i < m; i++){
		int u, v; cin >> u >> v;
		e[u].push_back(v);
		e[v].push_back(u);
	}
	if(dfs(1, 0)) cout << -1 << endl;
	else {
		for(auto e : res) cout << e.first << " " << e.second << endl;
	}
	return 0;
}


Measured memory_bytes: 18036
d = [[[-1, -1], [0, -1], [1, -1], [1, 0], [0, 1], [-1, 0]],
     [[-1,  0], [0, -1], [1,  0], [1, 1], [0, 1], [-1, 1]]]

w, h = gets.split.map(&:to_i)
fld = (h+2).times.map{ [false]*(w+2) }
(1..h).each do |i|
  gets.split(" ").each_with_index{ |e, j| fld[i][j+1] = true if e == "1" }
end

tmp = (h+2).times.map{ [false]*(w+2) }
arr = []
arr << [0, 0]
tmp[0][0] = true
until arr.empty?
  y, x = arr.pop
  d[y%2].each do |dy, dx|
    u = y + dy; v = x + dx
    next if u < 0 || u > h+1 || v < 0 || v > w+1
    if !fld[u][v] && !tmp[u][v]
      tmp[u][v] = true
      arr << [u, v]
    end
  end
end
fld = fld.flatten.zip(tmp.flatten).map{|f,p| !(!f&p) }
p fld.each_with_index.each_with_object([]){ |(e, i), arr| arr << d[(i/(w+2))%2].count{ |y, x| !fld[i+y*(w+2)+x] } if e }.reduce(:+)

Measured memory_bytes: 9360
using System;
using System.Collections.Generic;

namespace abc139_d
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();

      Console.WriteLine((long)n * (n - 1) / 2);
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

Measured memory_bytes: 11220
// https://atcoder.jp/contests/agc011/tasks/agc011_b
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    vector<ll> S(N);
    S[0] = A[0];
    for (int i = 1; i < N; ++i)
    {
        S[i] = S[i - 1] + A[i];
    }
    int idx = -1;
    for (int i = N - 1; i >= 1; --i)
    {
        if (2 * S[i - 1] < A[i])
        {
            cout << N - i << endl;
            return 0;
        }
    }
    cout << N << endl;
    return 0;
}

Measured memory_bytes: 4764
#include<iostream>
using namespace std;
int H, W;
char maze[102][102];
int res = 0;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

void dfs(int x, int y, char s)
{
	maze[x][y] = '0';
	for (int i = 0; i < 4; i++)
	{
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (0 <= nx && nx < H && 0 <= ny && ny < W && maze[nx][ny] == s)
		{
			dfs(nx, ny, s);
		}
	}
}

int main()
{
	while (cin >> H >> W)
	{
		if (H == 0 && W == 0) break;
		res = 0;
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				cin >> maze[i][j];
			}
		}
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				if (maze[i][j] != '0')
				{
					res++;
					dfs(i, j, maze[i][j]);
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}


Measured memory_bytes: 3560
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    sc.nextLine();
    int[] m = new int[n];
    int minm = 100000;
    int s = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
      m[i] = Integer.parseInt(sc.nextLine());
      s += m[i];
      if(minm > m[i])
        minm = m[i];
    }
    ans = n + (x - s) / minm;
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    while(true) {
        int N = readln.chomp.to!int;
        if (N == 0) break;
        long[] t = new long[N];
        foreach(int i; 0..N) {
            t[i] = readln.chomp.to!long;
        }
        t.sort;
        long ans = 0;
        long sum = 0;
        foreach(int i; 0..N) {
            ans += sum;
            sum += t[i];
        }
        ans.writeln;
    }

}

Measured memory_bytes: 2900
//arc060_c.cpp
//Sat Jun 23 13:19:44 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;


int x[50];
ll dptable[51][51][2501];

int main(){
	int n,a;

	cin >> n >> a;


	for (int i=0;i<n;i++){
		cin >> x[i+1];
	}


	for (int j=0;j<=n;j++){
		for (int k=0;k<=n;k++){
			for (int s=0;s<=2500;s++){
				if (j==0 && k==0 && s==0){
					dptable[j][k][s] = 1;
				}else if (j>=1 && s<x[j]){
					dptable[j][k][s] = dptable[j-1][k][s];
				}else if (j>=1 && k>=1 && s>=x[j]){
					dptable[j][k][s] = dptable[j-1][k][s] + dptable[j-1][k-1][s-x[j]];
				}else {
					dptable[j][k][s] = 0;
				}
			}
		}
	}

	ll ans = 0;

	for (int k=1;k<=n;k++){
		ans += dptable[n][k][k*a];
	}

	cout << ans << endl;
}

Measured memory_bytes: 51072
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;

    bool can = false;
    for (int i = 1; i <= 9; i++)
    {
        for (int j = 1; j <= i; j++)
        {
            if(i*j == N) can = true;
        }
    }
    
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)


using namespace std;
using ll = long long;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char num(char a,int n){
    int k = a - 'A';
    k += n;
    if(k < 26){
        return a+n;
    }else return 'A'+k-26;
}

int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    rep(i,s.size()){
        s[i] = num(s[i],n);
    }

    cout << s << endl;


   

    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation

using namespace std;

int main() {
	char N, m;
	cin >> N;
	m = N + 1;
	cout << m << endl;
}

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

int main(){
    long long n, a, b;
    cin >> n >> a >> b;
    if(n == 1 && a != b){
        cout << 0;
    }else if(a > b){
        cout << 0;
    }else{
        cout << max((long long)1, (b-a)*(n-2)+1);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<long long> > vvll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define INF 1000000000LL
#define MOD 1000000007
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define p_q priority_queue
 
#define FOR(i, a, b) for (int i=(a); i<=(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)
 
#define MN 10005
int n;
string s[MN];

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

    int ae = 0, bs = 0, both = 0;
    ll cnt = 0;

    cin >> n;
    F0R(i, n){
        cin >> s[i];
        F0R(j, s[i].length()-1){
            if(s[i][j] == 'A' && s[i][j+1] == 'B') cnt++;
        }
        if(s[i][0] == 'B' && s[i][s[i].length()-1] == 'A') both++;
        else if(s[i][0] == 'B') bs++;
        else if(s[i][s[i].length()-1] == 'A') ae++;
    }
    
    if(bs == 0 && ae == 0){
        cnt += max(0, both-1);
    } else{
        cnt += min(n-1, min(bs, ae)+both);
    }
    cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define lol long long
#define inf 1000000000000000000
using namespace std;
int main(){
  int a,b,c=0;
  cin>>a>>b;
  for(int i=0;i<=a;i++){
    if((a-i)*4+2*i==b){
      c++;
      break;
    }
  }
  if(c==1) cout<<"Yes\n";
  else cout<<"No\n";
  return(0);
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main{
  static int a, b, c;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    a = sc.nextInt();
    b = sc.nextInt();
    c = sc.nextInt();

    if(c >= a && c <= b){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int a, b;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> a >> b;
  cout << ((a*10+b)%4 ? "NO" : "YES") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1.0)
#define pb push_back
#define vi vector<int>
#define mapii map<int , int>
#define mapci map<char, int>
#define mapsi map<string,int>
#define FOR(i,n) for(int i = 0;i<n;i++)
#define CP(n) printf("Case %d: \n",n);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdin)
#define MAX 1000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int p , q , r;
    cin>>p>>q>>r;
    cout<<min(p+r,min(q+r,p+q))<<endl;
    return 0;
}


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

vector<int> d[200010];

int main(){
  int n, m;
  cin >> n >> m;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    --a;
    d[a].push_back(b);
  }
  int ans = 0;
  priority_queue<int> q;
  rep(i, m) {
    if (d[i].size()) rep(j, d[i].size()) q.push(d[i][j]);
    if (!q.size()) continue; 
    ans += q.top();
    q.pop();
  }
  cout << ans << endl;
}



Measured memory_bytes: 7936
BIG_NUM = 2000000000

while True:

    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if i == 0 or i == H-1 or k == 0 or k == W-1:
                print("#",end = "")
            else:
                print(".",end = "")
        print()

    print() #データセットの区切り



Measured memory_bytes: 7008
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0); 
	int N; cin >> N; 
	int cnt = 0; 
	map<string, bool> M; 
	for(int i = 0; i < N; i++){
		string S; cin >> S; 
		if(!M[S]) cnt ++; 
		M[S] = true; 
	}
	cout << cnt << endl; 
}

Measured memory_bytes: 19248
class PotUnionFind:
    def __init__(self, size):
        self.parent = [-1 for i in range(size)]#非負なら親ノード，負ならグループの要素数
        self.diff_p = [0 for i in range(size)]#親ノードを基準としたポテンシャル

    def root(self, x): #root(x): xの根ノードを返す
        if self.parent[x] < 0:
            return x
        else:
            rx = self.root(self.parent[x]) #xをxの根rxに直接つなぎたい
            self.diff_p[x] += self.diff_p[self.parent[x]] #そのために，diff(rx,x)を計算
            self.parent[x] = rx #xをrxに直接つなげる
            return rx

    def merge(self, x, y, dxy): #ポテンシャル差の条件p(y)-p(x)=dxyでxとyのグループをまとめる
        dxy = self.diff_p[x] + dxy - self.diff_p[y] #dxyをdiff(rx,ry)で置き換え
        x = self.root(x) #rxを新たにxと名づける
        y = self.root(y) #ryを新たにyと名づける
        if x == y:
            return False
        if self.parent[x] > self.parent[y]: #xの要素数がyの要素数より「小さい」とき入れ替える
            x,y=y,x
            dxy = -dxy
        self.parent[x] += self.parent[y] #xの要素数を更新
        self.parent[y] = x #yをxにつなぐ
        self.diff_p[y] = dxy #yの相対ポテンシャルを更新
        return True

    def issame(self, x, y): #issame(x,y): xとyが同じグループにあるならTrue
        return self.root(x) == self.root(y)
        
    def diff(self,x,y): #diff(x,y): xを基準としたyのポテンシャルを返す 
        if self.root(x) == self.root(y): #この時点でxの親はroot(x)
            return self.diff_p[y] - self.diff_p[x]
        else:
            return None

    def size(self,x): #size(x): xのいるグループの要素数を返す
        return -self.parent[self.root(x)]
#>>>>>>>>>>>>>>EhdCutHere>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

n,m = list(map(int,input().split()))

uf = PotUnionFind(n)
ans = True
for i in range(m):
    l,r,d=list(map(int,input().split()))
    l-=1;r-=1;
    if uf.issame(l,r):
        ans = d==uf.diff(l,r)
    else:
        uf.merge(l,r,d)
    if ans == False:
        break

if ans == False:
    print('No')
else:
    print('Yes')
#print([uf.root(i) for i in range(n)])
#print([uf.parent[i] for i in range(n)])
#print([uf.size(i) for i in range(n)])



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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

void LOG(const int& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

i64 ceil(i64 a, i64 b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }
i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

const i64 INF = inf<i64>;
signed main() {
  i64 N;
  cin >> N;
  i64 ans = INF;
  for (i64 i = 1; i * i <= N; i++) {
    if (N % i == 0) {
      ans = min(ans, i + N / i - 2);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import bisect

N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0
for j in B:
    ans += bisect.bisect_left(A, j) * (N - bisect.bisect_right(C, j))

print(ans)

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define Task ""

using namespace std;
typedef long long ll;

const int maxn = 1e5 + 5;

pair<ll, ll> p[maxn];
int N;
ll C;
ll g[maxn], f[maxn];

signed main(void)
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (fopen("A.INP", "r")){
        freopen("A.INP", "r", stdin);
        freopen("A.OUT", "w", stdout);
    }
    if (fopen(Task".INP", "r")){
        freopen(Task".INP", "r", stdin);
        freopen(Task".OUT", "w", stdout);
    }
    cin >> N >> C;
    for (int i=1; i<=N; ++i){
        cin >> p[i].fi >> p[i].se;
    }
    p[N+1].fi = C;
    ll res = 0, now = 0, dist = 0;
    for (int i=1; i<=N; ++i){
        dist -= p[i].fi - p[i-1].fi;
        now += p[i].se;
        f[i] = max(f[i-1], now + dist);
    }
    now = 0, dist = 0;
    for (int i=N; i>=1; --i){
        dist -= p[i+1].fi - p[i].fi;
        now += p[i].se;
        g[i] = max(g[i+1], now + dist);
        res = max(res, now + dist);
        res = max(res, f[i-1] + now + dist * 2);
    }
    now = 0, dist = 0;
    for (int i=1; i<=N; ++i){
        dist -= p[i].fi - p[i-1].fi;
        now += p[i].se;
        res = max(res, now + dist);
        res = max(res, g[i+1] + now + dist * 2);
    }
    cout << res << '\n';
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a * b % 2 == 0) {
			System.out.println("Even");
		}else {
			System.out.println("Odd");
		}
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
const int N=1e6+5,mo=1e9+7;
int vf[N],fac[N],inv[N];
inline int P(int n,int m){return 1ll*fac[n]*vf[n-m]%mo;}
inline int C(int n,int m){return 1ll*vf[m]*P(n,m)%mo;}
int n,i,ans;
int main(){
	for(int i=*vf=*fac=1;i<N;++i)
		inv[i]=i==1?1:1ll*(mo-mo/i)*inv[mo%i]%mo,
		vf[i]=1ll*vf[i-1]*inv[i]%mo,
		fac[i]=1ll*fac[i-1]*i%mo;
	scanf("%d",&n);
	for(i=n+1>>1;i<n;++i)
		ans=(ans+1ll*fac[n-1-i]*(P(n-1,i)+mo-1ll*C(i-1,n-1-i)*fac[i]%mo))%mo;
	ans=(ans+1ll*(n+1>>1)*fac[n-1])%mo;
	printf("%d\n",ans);
}

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

int main() {
	long long K, A, B;
	cin >> K >> A >> B;
	K++;
	if (A  + 2 >= B) {
		cout << K << endl;
		return 0;
	}


	K -= A;

	if (K <= 1) {
		cout << K + A << endl;	
		return 0;	
	}

	cout << A + (B - A) * (K  / 2) + K % 2 << endl;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
using namespace std;
int a,b,c,len;
int main()
{
    scanf("%d%d",&a,&b);
    c=b;
    while(c>0)
    {
        c/=10;
        len++;
}
    a=a*pow(10,len)+b; 
    if(sqrt(a)==floor(sqrt(a)))printf("Yes");
    else printf("No");
}


Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  int N, D;
  cin >> N >> D;
  int ans = (N + D * 2) / (D * 2 + 1);
  cout << ans << endl;
  return 0;
}

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

int a[100005];
int ans[100005];

bool cmp(int a, int b) {
    return a > b;
}

int main() {
    int n;
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }
    sort(a, a+n, cmp);
    int tmp=a[0], cnt=1, j=0;
    for(int i=1; i<n; i++) {
        if(a[i] == tmp) {
            cnt ++;
        }
        else {
            if(cnt >= 4) {
                ans[j] = tmp;
                j++;
                ans[j] = tmp;
                j++;
            }
            else if(cnt >= 2) {
                ans[j] = tmp;
                j++;
            }
            tmp = a[i];
            cnt = 1;
        }
    }
    if(cnt >= 2) {
        ans[j] = tmp;
        j++;
    }
    /*for(int i=0; i<j; i++) {
        cout << ans[i] << " \n"[i == j-1];
    }*/
    cout << (long long int)ans[0] * ans[1] << endl;
    return 0;
}



Measured memory_bytes: 768
def solve():
    sx, sy, tx, ty = map(int, input().split())
    ans = ''
    ans += (ty - sy) * 'U'
    ans += (tx - sx) * 'R'
    ans += (ty - sy) * 'D'
    ans += (tx - sx) * 'L'
    ans += 'L'
    ans += (ty - sy + 1) * 'U'
    ans += (tx - sx + 1) * 'R'
    ans += 'D'
    ans += 'R'
    ans += (ty - sy + 1) * 'D'
    ans += (tx - sx + 1) * 'L'
    ans += 'U'
    return ans

print(solve())

Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ull unsigned long long 
#define ll long long 
#define pre(a,b) cout<<fixed<<setprecision(a)<<b<<"\n";//a for precision b for answer
#define mp make_pair
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define pb push_back 
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b) 
#define forn(n) for(ll i=0;i<n;i++) 
#define ff first
#define ss second
#define MAX 1e18;
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound
#define vmin *min_element
#define vmax *max_element
const int MOD = 1e9 + 7;
const int v1=1e5+5;
#define pi 3.141592653589793238
const int N=2e5+5;
 
 
//cout<<"Case #"<<p<<": "<<;
//f ile input  freopen("input.txt","r",stdin); 
//file output freopen("output.txt","w",stdout);
 
using namespace std;

int32_t main()
{
  IOS;
  ll n;ll k=0;
  cin>>n>>k;
  vector <ll> a(n);
  forn(n)
  cin>>a[i];
  vector <ll> dp(n);
  dp[0]=0;
 for(ll i=1;i<min(k,n);i++)
  dp[i]=abs(a[0]-a[i]);
  for(ll i=k;i<n;i++)
  {
    dp[i]=MAX;
    for(ll j=i-k;j<i;j++)
      dp[i]=min(dp[i],abs(a[i]-a[j])+dp[j]);
  }
 cout<<dp[n-1]<<"\n";
}

Measured memory_bytes: 1792
#include <stdio.h>
int main (void){
  int X=0;
  scanf("%d",&X);
  int happy500=0;
  happy500=(X/500)*1000;
  int happy5=0;
  happy5=((X-((X/500)*500))/5)*5;
  printf("%d\n",happy500+happy5);
  return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
 
import numpy as np
 
N, K = map(int, input().split())
S = np.array(list(input()), dtype='U1')
 
S_slide = S[1:]
S_2 = S[:-1]
 
happiness = np.count_nonzero(S_slide == S_2)
happiness += 2*K
 
happiness = min(happiness, N-1)
 
print(happiness)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
    int A, B; cin >> A >> B;
    string S; cin >> S;
    int pos = 0, cnt = 0;
    rep(i, S.size()) if (S[i] == '-') pos = i, cnt++;
    if (pos == A && cnt == 1) cout << "Yes" << endl;
    else cout << "No" << endl;
}



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

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

  int n; cin >> n;
  int q = n % 10;

  if (q == 3)
  {
    cout << "bon" << endl;
    return 0;
  }
  if (q == 0 || q == 1 || q == 6 || q == 8)
  {
    cout << "pon" << endl;
    return 0;
  }
  
  cout << "hon" << endl;
  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int len, ans = 0;
  string str, str9;
  cin>> str;
  len = str.size();

  for(int i = 0; i < len - 1; i++) str9 += '9';

  if(len == 1) {

    ans = str[0] - '0';

  } else {
    
    int keta1 = str[0] - '0';
    str.erase(str.begin() + 0);
    if(str == str9) ans += keta1;
    else            ans += keta1 - 1;

    ans += 9 * (len - 1);
    
  }

  cout<< ans <<endl;

  return 0;
}


Measured memory_bytes: 256
W, H, N = map(int, input().split())
x1, x2, y1, y2 = 0, W, 0, H

for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        x1 = max(x1, x)
    elif a == 2:
        x2 = min(x2, x)
    elif a == 3:
        y1 = max(y1, y)
    else:
        y2 = min(y2, y)

ans = max(y2 - y1, 0) * max(x2 - x1, 0)
print(ans)

Measured memory_bytes: 3064
N, K = map(int, input().split())
ans = 0
if K == 0:
  print(N**2)
  exit()
for b in range(K+1, N+1):
  #print(b)
  #print(N // b * (b - K), max((N%b)-(K-1), 0))
  ans += N // b * (b - K)
  ans += max((N%b)-(K-1), 0)
print(ans)

Measured memory_bytes: 9064
n = int(input())
b = [int(i) for i in input().split()]

res = []
while True:
    if len(b) == 0:
        break
    flg = True

    for i in range(len(b)):
        k = len(b)-i-1
        if k == b[k]-1:
            a = b.pop(k)
            res.append(a)
            flg = False
            break

    if flg:
        print(-1)
        exit()

for x in res[::-1]:
    print(x)

Measured memory_bytes: 38896
import java.util.Scanner;

public class Main {


	static Scanner scan = new Scanner(System.in);
	public static void main(String[] args){
		String now_script = scan.next();

		char[] swap=null;							//対象の文字列を格納する変数
		int i = 0;
		for(int num= scan.nextInt();i <= num;i++){
			if(!(isInteger(now_script))){			//文字列である場合
				swap = now_script.toCharArray();
				now_script = scan.next();
			}else{									//数字の場合
				int getcard_num = Integer.parseInt(now_script);	//シャッフルするのに取り出す枚数

				swap = shuffle(swap , getcard_num);
				if(scan.hasNext("-")){				//最後の読み込み
					System.out.print(swap);
					break;
				}else if(!scan.hasNextInt()){		//次が数字じゃなかったら新しい文字列が入る準備をする
					i = -1;
					System.out.println(swap);
					swap = null;
					now_script = scan.next();
					num= scan.nextInt();
				}else{

					now_script = scan.next();		//それ以外は次の数字を読み込む
				}
			}

		}

		System.out.println();		//おまじない
	}

	/**
	 * 入力されたStringが文字列か数字かを判定
	 * @param num	判定する入力文字列
	 * @return	true:数字、false:文字列（数字以外の文字を含んでいる）
	 */
	static boolean isInteger(String num){

		try{
			int n = Integer.parseInt(num);
			return true;
		}catch(NumberFormatException e){
			return false;
		}

	}

	/**
	 * 下からとったカードを順番を変えずにそのまま上におく
	 * @param swap	カードの順番（文字列）
	 * @param b	取得する枚数
	 * @return
	 */
	public static char[] shuffle(char[] swap, int getcard_num){
		char[] tmp = new char[swap.length];
		//first
		for(int i = getcard_num ;i < swap.length; i++){

			tmp[i -getcard_num] = swap[i];	//h枚のカードをシャッフル後（tmp)の一番上にもってくる

		}

		//second
		for(int j = 0;j< getcard_num; j++){	//山札ーシャッフルで取り出した枚数（ｂ）
			tmp[j + swap.length - getcard_num] = swap[j];					//残った枚数をシャッフル後の後ろの方にもってくる
		}



		return tmp;
	}

}


Measured memory_bytes: 26400
# -*- coding: utf-8 -*-

#116_c
counter = 0

def mizu(h):
    global counter
    if len(h) == 0:
        return
    elif len(h) == 1:
        counter += h[0]
        return
    else:
        m = min(h)
        counter += m
        h = [i-m for i in h]
        while 0 in h:
            mizu(h[:h.index(0)])
            h = h[h.index(0)+1:]
        mizu(h)

if __name__ == "__main__":
    N = int(input())
    h = [int(i) for i in input().split()]
    mizu(h)
    print(counter)


Measured memory_bytes: 3064
from numpy import array, int64, minimum

def main():
    N, K, *I = open(0).read().split()
    N, K = map(int, (N, K))

    A, F = array(I[:N], int64), array(I[N:], int64)
    A.sort()
    F.sort()
    F = F[::-1]

    sum_A = A.sum()

    ng, ok = -1, 10 ** 12
    while ng + 1 < ok:
        mid = (ok + ng) // 2
        if (sum_A - minimum(A, mid // F).sum()) <= K:
            ok = mid
        else:
            ng = mid

    print(ok)


if __name__ == '__main__':
    main()


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

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

int main(void)
{
    ll n,d;
    cin >> n >> d;
    ll x,y,count=0;
    ld value=0.0;
    for(int i=0;i<n;i++)
    {
        cin >> x >> y;
        value=(ld)(sqrt(pow(x,2)+pow(y,2)));
        if(value<=d)
        {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3680
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        string s = Console.ReadLine();
        int[] res = new int[s.Length];
        int streak = 0;
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] != 'R')
            {
                res[i] += streak / 2;
                res[i - 1] += streak - streak / 2;
                streak = 0;
            }
            else streak++;
        }

        for (int i = s.Length - 1; i >= 0; i--)
        {
            if (s[i] != 'L')
            {
                res[i] += streak / 2;
                res[i + 1] += streak - streak / 2;
                streak = 0;
            }
            else streak++;
        }


        Console.WriteLine(string.Join(" ", res));
    }
}

Measured memory_bytes: 27600
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int m, d, count = 0;
  cin >> m >> d;
  for (int i = 4; i <= m; i++){
    for (int j = 22; j <= d; j++){
      int d1 = j % 10;
      int d10 = j / 10;
      if(d1 < 2){
        continue;
      }
      if (d1 * d10 == i){
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
S = str(input())
ans = count = 0
for i in range(len(S)):
    for j in range(i,len(S),1):
        if S[j] == "A" or S[j] == "C" or S[j] == "G" or S[j] == "T":
            count += 1
        else:
            break
    if count > ans:
        ans = count
    count = 0
print(ans)


Measured memory_bytes: 2940
#include<vector>
#include<iostream>
#include<queue>
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;

//constexpr int INF = 1e9;

struct edge
{
	int from, to, cost;
	bool operator>(const edge& other) const{
		return cost > other.cost;
	}
};

using edges = vector<edge>;
using graph = vector<edges>;

void add_edge(graph& g, int from, int to, int cost)
{
	g[from].push_back(edge{ from,to,cost });
	g[to].push_back(edge{ to,from,cost });
}

edges prim(const graph& g)
{
	const int N = g.size();
	vector<bool> used(N);
	used[0] = true;
	priority_queue < edge, vector<edge>, greater<edge >>que;
	for (auto e : g[0])
	{
		que.push(e);
	}
	edges mst;
	while (!que.empty())
	{
		auto e = que.top();
		que.pop();
		if (used[e.to])
		{
			continue;
		}
		mst.push_back(e);

		used[e.to] = true;
		for (auto new_e : g[e.to])
		{
			que.push(new_e);
		}
	}
	return mst;
}

int main()
{
	int V, E;
	cin >> V >> E;
	graph g(V);
	for (int i = 0; i < E; i++)
	{
		int s, t, w;
		cin >> s >> t >> w;
		add_edge(g, s, t, w);
	}
	const auto mst = prim(g);
	int ans = 0;
	for (auto& e : mst)
	{
		ans += e.cost;
	}
	cout << ans << endl;
}




Measured memory_bytes: 10216
import sys
import numpy as np
 
h, n = map(int, input().split())
ab = np.array(sys.stdin.read().split(), dtype=np.int64)
aaa = ab[0::2]
bbb = ab[1::2]
 
dp = np.zeros(10001, dtype=np.int64)

#k番目の魔法を最後に使って合計iのダメージを与える時の魔力消費量は、
#min(i-Akダメージの魔力消費量)+Bk
#iダメージ与える最小消費量を、上記計算式を全ての1<=k<=nで探索
#1<=i<=hでforを繰り返して、hダメージ与える最小魔力消費量を算出

for i in range(1, h + 1):
    dp[i] = (dp[i - aaa] + bbb).min()
print(dp[h])

Measured memory_bytes: 12512
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    ll a, b, v, w, t;
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;

    if(v <= w) {
        cout << "NO" << endl;
        return 0;
    }
    if(abs(a - b) <= t * (v - w)) {
        cout << "YES" << endl;
        return 0;
    }
    cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 3616
data = gets.to_i
ary = []

4.times do
    ary << Array.new(3){Array.new(10, 0)}
end
data.times do
    b, f, r, v = gets.split(" ").map(&:to_i)
    ary[b - 1][f - 1][r - 1] += v
end
4.times do |i|
    3.times do |j|
        print " "
        puts ary[i][j].join(" ")
        puts "#" * 20 if (j == 2) && (i < 3)
    end
end

Measured memory_bytes: 8796
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String s = a.toUpperCase();
    if(a.equals(s)) {
      System.out.println("A");
    } else {
      System.out.println("a");
    }
  }
}

Measured memory_bytes: 35684
N = int(input())
arr = sorted(list(map(int, input().split())))
count_arr = [0]*arr[-1]

ans = 0
for i in arr:
    for j in range(1,(arr[-1]//i)+1):
        count_arr[(i*j)-1] += 1
for i in arr:
    if count_arr[i-1] == 1:
        ans +=1

print(ans)

Measured memory_bytes: 132852
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=150;
//ここまでテンプレ
int main(){
	int A,B,C;
	cin>>A>>B>>C;
	cout<<A+B+C+max({A,B,C})*9<<endl;
}

Measured memory_bytes: 256
double x[99],y[99],X,Y;
n,i;main(){
	for(gets(x);~scanf("%lf %lf",x+n,y+n);n++);
	if(!(n&1))for(X=(x[0]+x[n/2])/2,Y=(y[0]+y[n/2])/2,i=1;
		i<n/2&&fabs((x[i]+x[n/2+i])/2-X)<1e-7&&fabs((y[i]+y[n/2+i])/2-Y)<1e-7;
	i++);
	printf(i==n/2?"%f %f\n":"NA\n",X,Y);exit(0);
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#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--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n;
    cin >> n;
    vector<ll> w(n);
    REP(i, n) cin >> w[i];
    ll sum = 0, sum2 = 0, ans = MAXR;
    REP(i, n) sum += w[i];
    REP(i, n){
        sum -= w[i];
        sum2 += w[i];
        ans = min(ans, abs(sum - sum2));
    }
    cout << ans;
    return 0;
}

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

long case1(long K, long A, long B) {
  if (K < A + 1) return 0;
  long ans = B; K -= A + 1;
  long q = K / (A + 2);
  ans += q * B;
  long r = K % (A + 2);
  ans += r;
  return ans;
}

long case2(long K, long A, long B) {
  if (K < A + 1) return 0;
  long ans = B; K -= A + 1;
  long q = K / 2;
  ans += (B - A) * q;
  if (K % 2) ans++;
  return ans;
}

int main() {
  long K, A, B;
  cin >> K >> A >> B;
  if (B <= A + 1) {
    cout << K+1 << endl;
    return 0;
  }
  long c1 = case1(K, A, B), c2 = case2(K, A, B);
  cout << max({K+1, c1, c2}) << endl;
}


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

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

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        for (int j = i + 1; j < s.size(); ++j) {
            if (s[i] == s[j]) {
                cout << "no" << endl;
                return 0;
            }
        }
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 3592
/*
sonu_verma1
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(a) push_back(a)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
int a,b,c;
cin>>a>>b>>c;
cout<<c<<" "<<a<<" "<<b;

    return 0;
}

Measured memory_bytes: 256