akhauriyash/Code-Regression huggingface dataset:
class Dijkstra():
    """ ダイクストラ法
    重み付きグラフにおける単一始点最短路アルゴリズム

    * 使用条件
        - 負のコストがないこと
        - 有向グラフ、無向グラフともにOK

    * 計算量はO(E*log(V))

    * ベルマンフォード法より高速なので、負のコストがないならばこちらを使うとよい
    """
    class Edge():
        """ 重み付き有向辺 """
        def __init__(self, _to, _cost):
            self.to = _to
            self.cost = _cost

    def __init__(self, V):
        """ 重み付き有向辺
        無向辺を表現したいときは、_fromと_toを逆にした有向辺を加えればよい

        Args:
            V(int): 頂点の数
        """
        self.G = [[] for i in range(V)]  # 隣接リストG[u][i] := 頂点uのi個目の隣接辺
        self._E = 0  # 辺の数
        self._V = V  # 頂点の数

    @property
    def E(self):
        """ 辺数
        無向グラフのときは、辺数は有向グラフの倍になる
        """
        return self._E

    @property
    def V(self):
        """ 頂点数 """
        return self._V

    def add(self, _from, _to, _cost):
        """ 2頂点と、辺のコストを追加する """
        self.G[_from].append(self.Edge(_to, _cost))
        self._E += 1

    def shortest_path(self, s):
        """ 始点sから頂点iまでの最短路を格納したリストを返す
        Args:
            s(int): 始点s
        Returns:
            d(list): d[i] := 始点sから頂点iまでの最短コストを格納したリスト。
                     到達不可の場合、値はfloat("inf")
        """
        import heapq
        que = []  # プライオリティキュー（ヒープ木）
        d = [10**15] * self.V
        d[s] = 0
        heapq.heappush(que, (0, s))  # 始点の(最短距離, 頂点番号)をヒープに追加する

        while len(que) != 0:
            cost, v = heapq.heappop(que)
            # キューに格納されている最短経路の候補がdの距離よりも大きければ、他の経路で最短経路が存在するので、処理をスキップ
            if d[v] < cost: continue

            for i in range(len(self.G[v])):
                # 頂点vに隣接する各頂点に関して、頂点vを経由した場合の距離を計算し、今までの距離(d)よりも小さければ更新する
                e = self.G[v][i]  # vのi個目の隣接辺e
                if d[e.to] > d[v] + e.cost:
                    d[e.to] = d[v] + e.cost  # dの更新
                    heapq.heappush(que, (d[e.to], e.to))  # キューに新たな最短経路の候補(最短距離, 頂点番号)の情報をpush
        return d

def BellmanFord(edges,num_v,source):
  #グラフの初期化
  inf=float("inf")
  dist=[inf for i in range(num_v)]
  dist[source-1]=0

  #辺の緩和
  for i in range(num_v):
    for edge in edges:
      if edge[0] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
        dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
        if i==num_v-1: return -1

  return dist

N,M,P=map(int,input().split())
edges=[]
test=Dijkstra(N)
for i in range(0,M):
    a,b,c=map(int,input().split())
    edges.append([a,b,P-c])
    test.add(b-1,a-1,1)

use=set([N-1])
t=test.shortest_path(N-1)
for i in range(0,N-1):
    if t[i]!=10**15:
        use.add(i)

useedges=[]
for i in range(0,M):
    a,b,c=edges[i]
    if a-1 in use and b-1 in use:
        useedges.append(edges[i])

ans=BellmanFord(useedges,N,1)
if ans==-1:
    print(-1)
else:
    if -ans[N-1]>=0:
        print(-ans[N-1])
    else:
        print(0)


Measured memory_bytes: 58456
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
    int n;
    while(cin>>n){
    	cout<<a[n-1]<<endl;
    }
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
	ll n,x,m;
	cin>>n>>x>>m;
	ll sum = x,ind=-1;
	set<ll> s;
	s.insert(sum);
	ll psum=0,nsum=0;
	vector<ll> a,b;
	b.push_back(sum);
	for(auto i=2;i<=n;i++){
	    ll num = (x*x)%m;
	    ll sz = s.size();
	    s.insert(num);
	    if(s.size() > sz){
	        sum += num;
	        x = num;
	        b.push_back(num);
	    }
	    else{
	        ind = i;
	        int f=0;
	        for(auto it = b.begin();it != b.end();it++){
	            if(f == 1){
	                nsum += *it;
	                a.push_back(nsum);
	                continue;
	            }
	            if(*it == num){
	                f = 1;
	                nsum += *it;
	                a.push_back(nsum);
	            }
	            else{
	                psum += *it;
	            }
	        }
	        break;
	    }
	}
	    if(ind == -1){
	        cout<<sum;
	    }
	    else{
	       // cout<<psum<<" "<<nsum<<" ";
	        ll diff  = n-ind+1;
	        ll tot = diff/a.size();
	        ll rem = diff%a.size();
	        nsum += (nsum * tot);
	        if(rem > 0){
	        nsum += a[rem-1];
	        }
	        cout<<(psum+nsum);
	    }
	return 0;
}


Measured memory_bytes: 6652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll N;
  cin >> N;
  vector<ll> X(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> X.at(i);
  }

  ll ans = INF;
  for (ll p = 1; p <= 100; p++)
  {
    ll tmp = 0;
    for (ll i = 0; i < N; i++)
    {
      tmp += (X.at(i) - p) * (X.at(i) - p);
    }
    chmin(ans, tmp);
  }
  cout << ans << endl;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int H,W;
    cin >> H >> W;
    i64 c[10][10];
    rep(i,0,10) rep(j,0,10) cin >> c[i][j];

    rep(k,0,10) rep(i,0,10) rep(j,0,10) c[i][j]=min(c[i][j],c[i][k]+c[k][j]);

    i64 ans=0;
    rep(i,0,H) rep(j,0,W){
        int Aij;
        cin >> Aij;
        if(Aij==-1) continue;
        ans+=c[Aij][1];
    }

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define int long long
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  itn n,k;
  int sum=1,mx,mn;
  cin>>n>>k;
  mx=n;
  mn=0;
  for(int i=1;i<k;i++){
    mn+=i;
    mx+=n-i;
    if(mx>n*(n+1)/2) mx=n*(n+1)/2;
  }
  for(int i=k;i<n+1;i++){
    sum+=mx-mn+1;
    mn+=i;
    mx+=n-i;
    if(mx>n*(n+1)/2) mx=n*(n+1)/2;
    sum%=1000000007;
  }
  cout<<sum%1000000007<<"\n";
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int Arr[n];
    for(int i=0;i<n;i++)
        cin >> Arr[i];
    int Brr[n];
    if(n>2)
        {
            Brr[0]=0;
            Brr[1]=abs(Arr[1]-Arr[0]);
            for(int i=2;i<n;i++)
                {
                    Brr[i]=min(abs(Arr[i]-Arr[i-1])+Brr[i-1],abs(Arr[i]-Arr[i-2])+Brr[i-2]);
                }
               cout << Brr[n-1];
        }
        else
            cout << abs(Arr[n-1]-Arr[n-2]);

    return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  int n = a*b;
    
  if (n % 2 == 0 ) {
    cout << "Even" <<endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
 
int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}
 
#define MAX 200005
 
signed main(void) {
    int i,j;
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    bool b = true;
    rep(i,n-1)if(a[i] >= a[i+1])b = false;
    if(b){
        cout << 1 << endl;
        return 0;
    }
    int ok = MAX, ng = 1;
    while(ok-ng > 1){
 
        int mid = (ok+ng)/2;
        bool c = true;
        vector<pii> ans;
        ans.push_back(pii(a[0],0));
        rep(i,n-1){
            if(ans.empty()){
                c = false;
                break;
            }
            if(a[i] < a[i+1]){
                if(ans.back().second){
                    ans.push_back(pii(a[i+1]-a[i],0));
                }else{
                    ans.back().first += a[i+1]-a[i];
                }
            }else{
 
                int num = a[i] - a[i+1];//超過数
                while(num > 0 && ans.back().first <= num){
                    num -= ans.back().first;
                    ans.pop_back();
                }
                if(num)ans.back().first -= num;
                int t = ans.back().second;
                int add = 0;
                if(t+1 == mid){
                    //繰り上げ発生時
                    if(ans.size() == 1){
                        c = false;
                        break;
                    }
                    add += ans.back().first;
                    ans.pop_back();
                }
 
                //if(mid == 2)rep(j,ans.size())cout << " " << ans[j].first << " " << ans[j].second << endl;
                //一番最後の文字をインクリメントする
                if(ans.back().first == 1){
                    ans.back().second++;
                    t = ans.size()-1;
                    if(ans.size() >= 2 && ans[t].second == ans[t-1].second){
                        ans[t-1].first += ans[t].first;
                        ans.pop_back();
                    }
                }else{
                    t = ans.back().second;
                    ans.back().first--;
                    ans.push_back(pii(1,t+1));
                }
                if(add)ans.push_back(pii(add, 0));
            }
        }
 
        if(c)ok = mid;
        else ng = mid;
    }
 
    cout << ok << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int gcd( int x, int y ){ return y ? gcd(y, x%y) : x; }
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >>x>>y;
if(x>8||y>8)std::cout << ":(" << '\n';
else std::cout << "Yay!" << '\n';

}


Measured memory_bytes: 384
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int div(int n){
    int cnt=0;
    for(int i=1;i<=n;++++i){
        if(n%i==0){
            cnt++;
        }
    }
    return cnt;
}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int cnt=0;
    for(int i=3;i<=n;++++i){
        if(div(i)==8){
            cnt++;
        }   
    }
    cout << cnt << endl;

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<pair<ll,ll>> v(n);
    for(int i = 0;i < n;i++){
        cin >> v[i].second >> v[i].first; //締め切り、かかる時間
    }
    sort(v.begin(),v.end());
    bool j = true;

    ll time = 0;
    for(int i = 0;i < n;i++){
        time += v[i].second;
        if(time > v[i].first){
            j = false;
            break;
        }
    }

    if(j){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3328
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
ll x;
cin >>x;
ll ans;
ans=x/11;
ans*=2;
ll memo=x%11;
if(memo<=6&&0<memo)
ans++;
else if(memo==0){
}

else 
ans+=2;
cout<<ans;
return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
//    val mod = 1000000007L
    val mod = 2019
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map(String::toLong).toList()

    val S = A.sum()
    val X1 = S - 2 * (A.filterIndexed { id, l -> id % 2 == 1 }.sum())

    val list = mutableListOf(X1)
    var pre = X1
    for (n in 0 until N-1) {
        val tmp = 2*A[n] - pre
        pre = tmp
        list.add(tmp)
    }
        println(list.joinToString(" "))
}

Measured memory_bytes: 80724
import java.util.*;

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

        int N = sc.nextInt();
        int[] A = new int[N + 1];
        int[] B = new int[N];
        long cnt = 0;

        for (int i = 0; i < N + 1; i++) A[i] = sc.nextInt();
        for (int i = 0; i < N; i++) B[i] = sc.nextInt();
        int[] BC = B.clone();

        for (int i = 0; i < N; i++) {
            if (A[i] >= B[i]) {
                A[i] -= B[i];
                B[i] = 0;
            } else {
                B[i] -=  A[i];
                A[i] = 0;
            }
            if (A[i + 1] >= B[i]) {
                A[i + 1] = A[i + 1] - B[i];
                B[i] = 0;
            } else {
                B[i] = B[i] - A[i + 1];
                A[i + 1] = 0;
            }

        }

        for (int i = 0; i < N; i++)
            cnt += BC[i] - B[i];

        System.out.println(cnt);

    }
}


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

int main()
{
	long long int n;
	char a[105];
	while (scanf("%lld", &n) != EOF)
	{
		cin >> a;
		if (n % 2 == 1)
			cout << "No" << endl;
		else
		{
			int flag = 0;
			for (int i = 0; i < n / 2; i++)
				if (a[i] != a[n / 2 + i])
				{
					flag = 1;
					break;
				}
			if (flag == 0)
				cout << "Yes" << endl;
			else
				cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

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

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

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

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int a = sc.nextInt();
        int p = sc.nextInt();
        int g = sc.nextInt();
        a = a - g;
        System.out.println(a / (p+g));
    }
}


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

using namespace std;

int main()
{
    int n, k, x, c=0;
    cin>>n>>k;
    vector <int> A;
    for(int i=0; i<n; i++)
    {
        cin>>x;
        A.push_back(x);
    }
    int cnt=0;
    if(n==k)
    {
        cout<<1<<endl;
        return 0;
    }
    while(!A.empty())
    {
        cnt++;
        if(c==0)
        {
            c=1;
            for(int i=1; i<=k; i++)
            {
                A.pop_back();
                if(A.empty())
                {
                    break;
                }
            }
        }
        else
        {
            for(int i=1; i<k; i++)
            {
                A.pop_back();
                if(A.empty())
                {
                    break;
                }
            }
        }

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




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

using namespace std;

int main(){

	map<char,int>m;

	m.insert(make_pair('A',10));
	m.insert(make_pair('B',11));
	m.insert(make_pair('C',12));
	m.insert(make_pair('D',13));
	m.insert(make_pair('E',14));
	m.insert(make_pair('F',15));

	char X;
	char Y;

	cin >> X >> Y;

	int x = m.at(X);
	int y = m.at(Y);

	if(x < y){
		cout << "<";
	}else if(x > y){
		cout << ">";
	}else if(x == y){
		cout << "=";
	}

	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#include<bitset>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
struct S{
    int u, v, w;
};

signed  main(){
    int l;
    cin >> l;
    int r = 0;
    for(int i = 19; i >= 0; i--){
        if(l & (1 << i)){
            r = i; break;
        }
    }
    vector<S> G;
    for(int i = 0; i < r; i++){
        G.push_back({i, i + 1, 1 << i});
        G.push_back({i, i + 1, 0});
    }
    int rest = l - (1 << r);
    int tmp = 1 << r;
    for(int i = r - 1; i >= 0; i--){
        if(rest & (1 << i)){
            rest -= 1 << i;
            G.push_back({i, r, tmp});
            tmp += 1 << i;
        }
    }
    cout << r + 1 << ' ' << G.size() << endl;
    for(int i = 0; i < G.size(); i++){
        cout << G[i].u + 1 << ' ' << G[i].v + 1 << ' ' << G[i].w << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    ll l,r;
    cin >> l >> r;
    r = min(r, l+2019);
    ll ans = 2018;
    for(ll i=l; i<r; i++){
        for(ll j=i+1; j<=r; j++){
            ll x = i*j%2019;
            ans = min(ans, x);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  if(n == 1){
    cout << "Yes" << endl;
    return 0;
  }
  vector<long long> vec;
  for(int i=0; i<n; i++){
    long long num;
    cin >> num;
    vec.push_back(num);
  }
  long long checking = vec[n-1];
  for(int i=n-2; i>=0; i--){
    long long currentNum = vec[i];
    if(currentNum <= checking){
      checking = vec[i];
      continue;
    }else{
      if(currentNum - checking >= 2){
        cout << "No" << endl;
        return 0;
      }else{
        checking = vec[i]-1;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
    
    
    

Measured memory_bytes: 1400
#pragma comment(linker, "/STACK:66777216")
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<cmath>
#include<unordered_set>
#include<unordered_map>
#include<cassert>
#include<bitset>
#include<ctime>
using namespace std;
using ll = long long;

vector<vector<int>> g;

int DFS(int v, int level, int p = -1) {
	int cnt = 1;
	if (level) {
		for (int u : g[v]) {
			if (u != p)
				cnt += DFS(u, level - 1, v);
		}
	}
	return cnt;
}

void Solve() {
	int n;
	scanf("%d", &n);
	int s = 0;
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		s ^= a;
	}
	if (s & 1)
		printf("NO");
	else
		printf("YES");
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	Solve();

#ifdef LOCAL
	cerr << double(clock()) / CLOCKS_PER_SEC << endl;
#endif

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    if(n>0 && n<=100 && m>=0 && m<=n)
    {
        if(n==m)
            cout<<"Yes"<<endl;
        else if(n>m)
            cout<<"No"<<endl;
    }

    return 0;

}


Measured memory_bytes: 256
def main():
    import math
    a, b, c = map(int, input().split())
    # a = math.sqrt(a)
    # b = math.sqrt(b)
    # c = math.sqrt(c)
    # n = math.sqrt(a*b)

    if 4 * a*b < (c-a-b)**2 and c-a-b > 0:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


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

int main() {
    int n;
    cin >> n;

    vector<int> A;
    for (int i = 0; i < n; i++){
        int a;
        cin >> a;
        A.push_back(a);
    }

    vector<int> A2(A.size());
    copy(A.begin(), A.end(), A2.begin());

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

    for (int i = 0; i < n; i++){
        if (A[i] == A2[0]) {
            cout << A2[1] << endl;
        } else {
            cout << A2[0] << endl;
        }
    }
}

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;
bool solve(ll n) 
{ 
    if (n == 0 || n == 9) 
        return true; 
    if (n < 9) 
        return false; 
  
    // (n/9) - n%8]
    return solve((ll)(n >> 3) - (ll)(n & 7)); 
} 
int main(){
    // int t = 1;
    // cin >> t;
    // for(int i = 0; i < t;++i){
        // ll a;
        // cin >> a;
        string s;
        cin >> s;
        ll ans = 0;
        for(int i = 0; i < s.length(); ++i){
            ans += (s[i] -'0');
            ans %= 9;
        }
        if(ans == 0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
        // if(solve(a)){
        //     cout << "Yes" << endl;
        // }else{
        //     cout << "No" << endl;
        // }
    // }
    return 0;
}

Measured memory_bytes: 3716
n,m=map(int,input().split())
v=[]
for i in range(m):
    a,b=map(int,input().split())
    v.append((a-1,b-1))
def dfs(x):
    check[x]=True
    for i in graph[x]:
        if not check[i]:
            dfs(i)
ans=0
for i in range(m):
    graph=[[] for i in range(n)]
    for j in range(m):
        if j!=i:
            graph[v[j][0]].append(v[j][1])
            graph[v[j][1]].append(v[j][0])
    check=[False]*n
    dfs(0)
    for j in check:
        if not j:
            ans+=1
            break
print(ans)


Measured memory_bytes: 44912
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<numeric>
#include<stack>
#include<queue>
#include<unordered_map>
#include<cmath>
#include<utility>

using ULL = unsigned long long;
using LL = long long;
using String = std::string;
using Ints = std::vector<int>;
using Doubles = std::vector<double>;
using Bools = std::vector<bool>;
using Strings = std::vector<std::string>;
using ULLs = std::vector<ULL>;
using LLs = std::vector<LL>;

// pythonのdictionary相当
template <typename T1, typename T2>
using Dict = std::unordered_map<T1,T2>;



int main(void) {
    int n, k;
    std::cin >> n >> k;
    Ints A(n);
    for(int i=0;i<n;i++){
        int _a;
        std::cin >> _a;
        A[i] = _a;
    }

    for(int i=0;i<std::min(50, k);i++){
        Ints B(n+1, 0);
        for(int j=0;j<n;j++){
            B[std::max(0, j-A[j])]++;
            B[std::min(n, j+A[j]+1)]--;
        }
        for(int j=0;j<n;j++){
            B[j+1]+=B[j];
        }
        A=B;
    }

    for(int i=0;i<n;i++){
        std::cout << A[i] << " ";
    }
    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 5596
#define _CRT_SECURE_NO_WARNINGS
#define MOD 998244353
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <functional>
#include <algorithm>
#include <iterator>
#include <cstdio>
#include <utility>
#include <unordered_map>
#include <cmath>
#include <chrono>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

typedef pair<ll, ll> P;
struct edge { ll to, cost; };

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>(b);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,-1)

inline ll madd(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a + b) % MOD;
}
inline ll msub(ll a, ll b) {
	a %= MOD;b %= MOD;
	a += MOD;
	return (a - b) % MOD;
}
inline ll mmul(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a*b) % MOD;
}
inline ll mpow(ll a, ll r) {
	long long res = 1;
	while (r > 0) {
		if (r & 1) res = res * a % MOD;
		a = a * a % MOD;
		r >>= 1;
	}
	return res;
}
inline ll minv(ll a) {
	a %= MOD;
	ll b = MOD, u = 0, v = 1;
	while (a) {
		ll t = b / a;
		b -= t * a; swap(a, b);
		u -= t * v; swap(u, v);
	}
	if (u < 0) u += MOD;
	return u;
}
inline ll mdiv(ll a, ll b) {
	a %= MOD;
	a *= minv(b);
	return a%MOD;
}



struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

/*int V;
vector<edge> G[MAX_V];
int d[MAX_V]:
void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P>> q;
	fill(d, d + V, INF);


}*/
int main(void) {
	int n, q;
	cin >> n >> q;
	vector<ll> s, t, x;
	ll ss, tt, xx;
	REP(i, n) {
		cin >> ss >> tt >> xx;
		s.push_back(ss);
		t.push_back(tt);
		x.push_back(xx);
	}
	vector<ll> d;
	ll dd;
	REP(i, q) {
		cin >> dd;
		d.push_back(dd);
	}
	vector<vector<int>> vv;
	REP(i, q + 1) vv.push_back(vector<int>());
	REP(i, n) {
		auto lb = lower_bound(d.begin(), d.end(), s[i] - x[i]);
		vv[lb - d.begin()].push_back(x[i]);
		auto ub = upper_bound(d.begin(), d.end(), t[i] - x[i]-1);
		vv[ub - d.begin()].push_back(-x[i]);
	}
	multiset<int> se;
	REP(i, q) {
		for (int j : vv[i]) {
			if (j < 0) {
				int cn=se.erase(-j);
				REP(ii, cn - 1) {
					se.insert(-j);
				}
			}
			else {
				se.insert(j);
			}
		}
		if (se.empty()) cout << "-1" << endl;
		else cout << *se.begin() << endl;
	}
	return 0;
}

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

int main(){
  int n;

  while(cin >> n ,n){
    int MAX_POINT = 0,MIN_POINT = 1<<28,sum,a[5];
    for(int i = 0 ; i < n ; i++){
      sum = 0;
      for(int j = 0 ; j < 5 ; j++){
	cin >> a[j];
	sum += a[j];
      }
      MAX_POINT = max(MAX_POINT,sum);
      MIN_POINT = min(MIN_POINT,sum);
    }
    cout << MAX_POINT << ' ' << MIN_POINT << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,A,B = map(int,input().split())

if (B-A)%2==0:
    ans = (B-A)//2
elif B-A == 1:
    ans = min(N-A,B-1)
else:
    ans = min(A-1,N-B)
    ans = (B-A-1)//2 + ans +1

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    int h[300]={},k[300]={},g[300];
    for(int i=0;i<300;i++){
        g[i]=100000;
    }
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>h[i]>>k[i];
    }
    cin>>m;
    for(int i=n;i<n+m;i++){
        cin>>h[i]>>k[i];
    }
    for(int i=0;i<n+m;i++){
        g[i]=h[i]*60+k[i];
        sort(g,g+n+m);
    }

    for(int i=0;i<n+m;i++){
        if(g[i]==g[i+1]) continue;
        cout<<g[i]/60<<":";
        if(g[i]%60<10) cout<<"0"<<g[i]%60;
        else cout<<g[i]%60;
        if(i!=n+m-1) cout<<" ";
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 3144
/* ***********************************************
Author        :pkwv
Created Time  :2017年10月22日 星期日 20时09分08秒
File Name     :B.cc
************************************************ */

#include <algorithm>
#include <bitset>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <unordered_map>
#include <vector>

using namespace std;

int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
  int n;
	while (std::cin >> n) {
		int odd{1}, even{0};
		for (int i = 1; i <= n; ++ i) {
			int a;
			std::cin >> a;
			if (a & 1) {
				even = even * 3 + odd * 2;
				odd = odd;
			} else {
				even = even * 3 + odd;
				odd = odd * 2;
			}
		}
		std::cout << even << std::endl;
	}
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

template<class T> vi compress( vector<T> a ){
  vector<T> ord = a;
  vi res(0);
  SORT( ord );
  UNIQUE( ord );
  YYS( w , a ) res.pb( lower_bound( ALL(ord) , w ) - ord.begin() );
  return res;
}

int n;
int a[200010];

int cnt[200010];

int main(){

  n = in();
  vl s(n+1, 0);
  REP(i, n){
    a[i] = in();
    s[i+1] = s[i] + a[i];
  }

  vi c = compress(s);

  ll ans = 0;
  for(int i = n; i >= 0; i--){
    ans += cnt[c[i]];
    cnt[c[i]]++;
  }

  cout << ans << endl;

  return 0;
}


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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    int a,b;
    cin >> a >> b;
    if(a == b){
        cout << "Draw" << endl;
    }else if( (a>b && b != 1) || a == 1 ){
        cout << "Alice" << endl;
    }else{
        cout << "Bob" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
	int N; cin >> N;
	vector<int>v(N);
	for (int i = 0; i < N; ++i)cin >> v[i];
	sort(v.begin(), v.end());
	double ans = v[0];
	for (int i = 1; i < N; ++i) {
		ans = (ans + v[i]) / 2;
	}
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}

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

int N,M;
int A[100000], B[10000];

signed main() {
  cin >> N >> M;
  vector<vector<int>> work(100000);
  for(int i=0; i<N; i++) {
    int a, b; cin >> a >> b;
    work[a].push_back(b);
  }

  priority_queue<int> q;
  int ans = 0;
  for(int day=1; day<=M; day++) {
    for(int w : work[day]) q.push(w);
    if(q.empty()) continue;
    ans += q.top(); q.pop();
  }
  cout << ans << endl;
}


Measured memory_bytes: 5632
# Frog1
N = int(input())
h = list(map(int, input().split()))
inf = float("inf")
dp = [inf for _ in range(N)]
dp[0] = 0
for i in range(N):
    for j in (1, 2):
        if i + j >= N:
            continue
        dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i+j]))
print(dp[-1])

Measured memory_bytes: 83644
#include <iostream>
#include <vector>
#include <algorithm> //sort,二分探査など
//#include<bitset>
//#include<cmath>//pow,logなど
//#include<deque>
//#include<functional>
//#include<iterator>
//#include<map>
//#include<numeric>//gcd,lcm
//#include<queue>
//#include<set>
//#include<stack>
//#include<string>
//#include<utility>//pair

//QCFium法
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

//浮動小数点処理高速化
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using i64 = int64_t;
using f80 = __float80;
using u64 = uint_fast64_t;

constexpr i64 INF = 1010000000000000017LL;
constexpr u64 MOD = 1000000007LL;
constexpr f80 PI = 3.14159265358979323846;

#define _overload3(_1, _2, _3, name, ...) name
#define repi(i, start, end) for (int i = (int)(start); i < (int)(end); ++i)
#define _rep(i, n) repi(i, 0, n)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(i, start, end) for (int i = (int)(start); i > (int)(end); --i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()

#define v(T) vector<T>
#define vv(T) v(v(T))
#define vvv(T) v(v(v(T)))
typedef v(int) vi;

#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
  rep(i, v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
  for (T &in : v)
    is >> in;
  return is;
}

//sort(rng(P),[](const vi &a, const vi &b){return a[1]<b[1];});

void Main()
{
  i64 N;
  cin >> N;
  vv(i64) xy(N, v(i64)(2));
  cin >> xy;

  i64 ans = -1 * INF;

  i64 l = INF;
  i64 r = -1 * INF;
  rep(i, N)
  {
    chmax(r, xy[i][0] + xy[i][1]);
    chmin(l, xy[i][0] + xy[i][1]);
  }
  chmax(ans, r - l);

  l = INF;
  r = -1 * INF;
  rep(i, N)
  {
    chmax(r, xy[i][0] - xy[i][1]);
    chmin(l, xy[i][0] - xy[i][1]);
  }
  chmax(ans, r - l);

  cout << ans << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //  cout << fixed << setprecision(15);
  Main();
}

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

int main()
{
	int n;
	cin >> n;
	vector<int64_t> l(87);
	l[0] = 2LL;
	l[1] = 1LL;

	for (int i = 2; i <= n; i++)
	{
		l.at(i) = l.at(i - 1) + l.at(i - 2);
	}

	cout << l.at(n) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a, b, c;
int main(void){
    scanf("%d%d%d", &a, &b, &c);
    cout << a <<" "<< b << " "<< 3 * c - a - b <<" \n";
    cout << 4 * c - 2 * a - b << " " << c << " " << 2 * a + b - 2 * c << " \n";
    cout << a + b - c << " " << 2 * c - b << " " << 2 * c - a << " \n";
    return 0;
}

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

long long int gcd(long long int a, long long int b);
long long int lcm(long long int a, long long int b);

int main(){
  int n;
  while(cin >> n , n){
    long long int d[11],v[11];
    for(int i=0;i<n;i++){
      cin >> d[i] >> v[i];
      long long int G = gcd(d[i],v[i]);
      d[i] /= G;
      v[i] /= G;
    }
    long long int L = lcm(d[0],d[1]);
    for(int i=2;i<n;i++){
      L = lcm(L,d[i]);
    }
    long long int ans[11];
    for(int i=0;i<n;i++){
      ans[i] = v[i]*(L/d[i]);
    }
    long long int G = gcd(ans[0],ans[1]);
    for(int i=2;i<n;i++){
      G = gcd(G,ans[i]);
    }
    for(int i=0;i<n;i++){
      cout << ans[i] / G << endl;
    }
  }
}

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

long long int  lcm(long long int a, long long int b){
  if(b > a) swap(a,b);
  return a * b / gcd(a,b);
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int ans,n;

void dfs(ll now,bool a,bool b,bool c){
	if(now > n)return;
	if(a && b && c)ans++;
	dfs(now * 10 + 3,true,b,c);
	dfs(now * 10 + 5,a,true,c);
	dfs(now * 10 + 7,a,b,true);
}

int main(){
	
	cin >> n;
	dfs(0,false,false,false);
	
	cout << ans << endl;
	
	
	return 0;
}


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


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c >= 22)
        cout << "bust";
    
    else
    {
        cout << "win";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n;
  cin >>n;
  ll e[n],o[n],l=0,p=0;
  for(ll i=0;i<n;i++) {
    if(i%2==0) {
      cin >>o[l];l++;
    }
    else {
      cin >>e[p];p++;
    }
  }
  ll k=n/2;
  vector <pair<ll,ll>> ee;//firstに何個か、secondにその数字
 sort(e,e+k);ll c=1;
 for(ll i=0;i<k;i++){//配列の中身がそれぞれ何個あるかのカウント
  if(e[i]==e[i+1]){
    c++;
    if(i==k-2){//122333みたいなときは3のところがansに入らないので
      ee.push_back(make_pair(c,e[i]));
      break;
    }
  }
  else{
    ee.push_back(make_pair(c,e[i]));
    if(i==k-2) {
        ee.push_back(make_pair(1,e[i+1]));//112223とかのときにansに3の分を足すため
        break;
    }
    c=1;
  }
}
vector <pair<ll,ll>> oo;//firstに何個か、secondにその数字
sort(o,o+k);c=1;
for(ll i=0;i<k;i++){//配列の中身がそれぞれ何個あるかのカウント
if(o[i]==o[i+1]){
  c++;
  if(i==k-2){//122333みたいなときは3のところがansに入らないので
    oo.push_back(make_pair(c,o[i]));
    break;
  }
}
else{
  oo.push_back(make_pair(c,o[i]));
  if(i==k-2) {
      oo.push_back(make_pair(1,o[i+1]));//112223とかのときにansに3の分を足すため
      break;
  }
  c=1;
}
}
sort(oo.begin(),oo.end());
sort(ee.begin(),ee.end());
reverse(oo.begin(),oo.end());
reverse(ee.begin(),ee.end());
ll os=oo.size(),es=ee.size();
if(es==1||os==1){
  if(oo[0].second!=ee[0].second){
    cout <<k-oo[0].first+k-ee[0].first<<endl;
    return 0;
  }
  else{
    cout <<k<<endl;
    return 0;
  }
}
else{
  if(oo[0].second!=ee[0].second){
  cout <<k-oo[0].first+k-ee[0].first<<endl;
  return 0;
}
else {
  cout <<min(2*k-oo[1].first-ee[0].first,2*k-oo[0].first-ee[1].first)<<endl;
  return 0;
}
}
}


Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) throws IOException {
		final String[] expression = getExpression();
		
		final String answer = calclate(expression);
		System.out.println(answer);
	}
	
	public static String calclate(final String[] expression) {
		final Stack<String> stack = new Stack<String>();
		
		for (String term : expression) {
			
			if (isNumber(term)) {
				stack.push(term);
				
			} else {
				final int operand2 = Integer.parseInt(stack.pop());
				final int operand1 = Integer.parseInt(stack.pop());
				
				String result;
				if ("+".equals(term)) {
					result = String.valueOf(operand1 + operand2);
					
				} else if ("-".equals(term)) {
					result = String.valueOf(operand1 - operand2);
					
				} else {
					result = String.valueOf(operand1 * operand2);
				}
				stack.push(result);
			}
		}
		
		return stack.pop();
	}
	
	public static boolean isNumber(String term) {
		Pattern patternNum = Pattern.compile("-*[0-9]+");
		Matcher matcherNum = patternNum.matcher(term);
		
		return matcherNum.matches();
	}
	
	public static String[] getExpression() throws IOException {
		final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		final String[] expression = reader.readLine().split(" ");
		reader.close();
		
		return expression;
	}
}

Measured memory_bytes: 17104
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
    ll a;
    ll b;
    cin>>a>>b;
    cout<<seinomi(a-b*2)<<endl;
}









Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int n;cin>>n;
    vector<ll> v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    ll ans=0;
    for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)ans+=1ll*v[i]*v[j];
    cout<<ans;
}

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

   int main() {
     int N,A;
     int MAX=1;
     int MIN=1000000000;
     cin>>N;
     while(N--){
      cin>>A;
      MAX= max(A,MAX);
      MIN=min(A,MIN);}
     cout<<MAX-MIN<<endl;
   return 0;
   }

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String s = sc.next();
      if(s.charAt(2)==s.charAt(3)&&s.charAt(4)==s.charAt(5)){
          System.out.println("Yes");
          }else{
          System.out.println("No") ;        
      }
	}
}

Measured memory_bytes: 35832
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(n)]
ab.sort()
ans = 0
for a, b in ab:
    buy = [m, b][0 <= m-b]
    m -= buy
    ans += a*buy
print(ans)


Measured memory_bytes: 16896
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  pr((n+m)*(n+m-1)/2-n*m);


}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256