akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdlib.h>
#include <cmath>
using namespace std;
    char m[1000][1000];
    int d[1000][1000];
int main(){

    int H,W;
    cin>>H>>W;
    int dx[4]={1,0,-1,0};
    int dy[4]={0,1,0,-1};

    queue<pair<int,int>> Q;
    for(int i=0;i<1000;i++){
        if(i<H){
            string S;
            cin>>S;
            for(int j=0;j<1000;j++){
                if(j<W) {
                    m[i][j]=S.at(j);
                    if(S.at(j)=='#') {Q.push(make_pair(i,j)); d[i][j]=1;}
                }
                else m[i][j]='#';
            }
        }
        else {
            for(int j=0;j<1000;j++) m[i][j]='#';
        }
    }

    int max=0;

    while(Q.size()>0){
        int y=Q.front().first;
        int x=Q.front().second;
        int t=d[y][x];
        if(t>max) max=t;
        for(int i=0;i<4;i++){
            int Y=y+dy[i], X=x+dx[i];
            if(d[Y][X]==0 && m[Y][X]=='.' && 0<=Y && Y<1000 && 0<=X && X<1000){
                Q.push(make_pair(Y,X));
                d[Y][X]=t+1;
            }
        }
        Q.pop();
    }

    cout<<max-1<<endl;
    


}

Measured memory_bytes: 13328
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n, k := readInt(), readInt()

	count := 0
	for {
		if n == 0 {
			break
		}
		n = n / k
		count++
	}
	fmt.Println(count)
}


Measured memory_bytes: 640
fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(' ').map(String::toInt)
    val s = (1..h).map { readLine()!! }

    val d = listOf(-1 to 0, -1 to 1, 0 to 1, 1 to 1, 1 to 0, 1 to -1, 0 to -1, -1 to -1)

    for (y in (0..(h - 1))) {
        val sb = StringBuilder(w)

        for (x in (0..(w - 1))) {

            if (s[y][x] == '#') {
                sb.append('#')
                continue
            }

            var c = 0
            for ((dy, dx) in d) {
                if (y + dy !in (0..(h - 1))) {
                    continue
                }

                if (x + dx !in (0..(w - 1))) {
                    continue
                }

                if (s[y + dy][x + dx] == '#') {
                    c++
                }
            }
            sb.append(c)
        }

        println(sb)
    }

}

Measured memory_bytes: 38364
import fractions
# import math


N = int(input())

ARR = []

for i in range(N):
    ARR.append(int(input()))

def calculate(arr):
    arr = sorted(arr)
    s = arr[0]
    for i, ar in enumerate(arr):
        if i == 0:
            continue
        else:
            s = zuixiaogongbeishuAtcoder(s,ar)

    print(s)


def zuixiaogongbeishuAtcoder(a, b):
    f = fractions.gcd(a, b)
    res = a * b // f
    return res

#
# def zuixiaogongbeishu(a, b):
#     f = math.gcd(a, b)
#     res = (a * b) // f
#     return res


calculate(ARR)

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

int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    bool flag=false;
    for(int i=1; i<b; i++){
        if((a*i)%b==c) flag=true;
    }

    if(flag) cout << "YES" << endl;
    else cout << "NO " << endl;

    return 0;
}

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

int main() {
  int n,m,a,b,v[50]={0};
  cin >> n >> m;
  for(int i=0; i<m; i++) {
    cin >> a >> b;
    v[a-1]++;
    v[b-1]++;
  }
  for(int i=0; i<n; i++) {
    cout << v[i] << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int A, B;
    int K;

    cin >> A >> B >> K;
    int ans=max(A,B);

    while(K>0) {
        while(ans>0) {
            if(A%ans==0 && B%ans==0) {
                --K;
                --ans;
                break;
            }
            --ans;
        }
    }
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
for h in range(max(1, int(n / 4)), min(3500, int(3*n / 4)) + 1):
    for w in range(max(1, int(3*n / 4)), 3501):
        num = n * h * w
        den = 4 * h * w - n * (h + w)
        if den != 0 and num % den == 0 and h <= num // den <= w:
            print(h, num // den, w)
            exit()

Measured memory_bytes: 9112
#include <iostream>
#include <string>
using namespace std;
int main(void){
   string s;
   bool f;
   cin >> s;
   if(s.length()%2==1){
       s.erase(s.end()-1,s.end());
   }else{
       s.erase(s.end()-2,s.end());
   }
   while(true){
       int start = s.length()/2;
       f = true;
       for(int i=0;i<start;i++){
           if(s[i]!=s[i+start]){
               f=false;
               break;
           }
       }
       if(f==true){
           cout << s.length()<<endl;
           break;
       }else{
           s.erase(s.end()-2,s.end());
       }
   }
}


Measured memory_bytes: 256
N=int(input())
X=input()
c=X.count('1')
r1=int(X,2)%(c-1) if c>1 else 0
r2=int(X,2)%(c+1)
d=[0]*(N+1)
for i in range(N):
    d[i+1]=d[(i+1)%bin(i+1).count('1')]+1
for i in range(N):
    if X[i]=='0':
        n=(r2+pow(2,N-i-1,c+1))%(c+1)
    else:
        if c==1:
            print(0)
            continue
        n=(r1-pow(2,N-i-1,c-1))%(c-1)
    print(d[n]+1)

Measured memory_bytes: 11100
import java.util.*;

public class Main { 
	public static void main(String argsp[]) 
    {	
      	Scanner sc = new Scanner(System.in);
      	String input = sc.nextLine();
      	String[] inputs = input.split(" ");
      	int a = Integer.valueOf(inputs[0]);
      	int b = Integer.valueOf(inputs[1]);
      	if(b%a==0)
        {
           System.out.println(b+a);
        }
      	else {
          System.out.println(b-a);
        }
      	
      	
    }
}

Measured memory_bytes: 23252
import heapq
class Graph:
    def __init__(self,w_v,w_e):
        super().__init__()
        self.size = len(w_v)
        self.w_v = [v_i for v_i in w_v]#value of vartex
        self.w_e = [{} for _ in [0]*self.size]

        self.maxw = 0

        self.neighbor = [[] for _ in [0]*self.size]
        for a_i,b_i,w_i in w_e:
            self.w_e[a_i][b_i] = w_i#weight of edge
            self.w_e[b_i][a_i] = w_i#weight of edge

            self.neighbor[a_i].append(b_i)
            self.neighbor[b_i].append(a_i)
            self.maxw+=w_i

    def dijkstra(self,v_n):
        d = [self.maxw]*self.size
        d[v_n] = 0
        prev = [-1]*self.size

        queue = []
        for i,d_i in enumerate(d): heapq.heappush(queue,(d_i,i))
        
        while len(queue)>0:
            d_u,u = queue.pop()
            if d[u]<d_u :continue
            for v in self.neighbor[u]:
                alt = d[u]+self.w_e[u][v]
                if d[v]>alt:
                    d[v] = alt
                    prev[v] = u
                    heapq.heappush(queue,(alt,v))

        return d,prev

def main():
    n,x,y = tuple([int(t)for t in input().split()])

    w_v = [0]*n
    w_e = [(i,i+1,1) for i in range(n-1)]
    w_e.append((x-1,y-1,1))

    g = Graph(w_v,w_e)

    distance = [g.dijkstra(i)[0] for i in range(n)]

    res = [0]*n
    for dmin_ in distance:
        for d in dmin_:
            res[d] += 1

    for r in res[1:n]:
        print(r//2)

if __name__ == "__main__":
    main()

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


namespace ConsoleApplication2
{
    class Program
    {
        static void Main()
        {
            int j=0,i;
            int []b={500,100,50,10,5,1};
            int []e=new int [10000];
            while(true)
            {
                int p = 0, all = 0,
                a = int.Parse(Console.ReadLine());
                if (a == 0) break;
                a = 1000 - a;
                for (i = 0; i < 6; i++)
                {
                    p = (a / b[i]);
                    a = a - (p * b[i]);
                    all += p;
                }
                e[j] = all;
                j++;
            }
            for (i = 0; i < j; i++)
                Console.WriteLine(e[i]);
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

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;
}
template<class T>
void DEBUG_DP(T* viewdp, int ilen, int jlen){
    REP(i,ilen){
        REP(j,jlen){
            if(viewdp[i][j] != -1)
                printf("[% 4d]", viewdp[i][j]);
            else
                printf("[    ]");
        }
        puts("");
    }
}
int h,w;
char mz[102][102];
int cnt[102][102];
bool visited[102][102];
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>h>>w;
    FOR(i,0,h)FOR(j,0,w) cin>>mz[i][j];
    ll ans = 0;

    REP(i,102){
        fill(cnt[i],cnt[i]+102, INT_MAX-1);
    }

    cnt[0][0] =  (mz[0][0]=='#') ? 1 : 0;

    int nx=0, ny=0;
    int gx=w-1, gy=h-1;

    REP(i,h)REP(j,w){
        char c = mz[i][j];
        if(c=='.' && mz[i+1][j]=='#'){
            chmin(cnt[i+1][j], cnt[i][j]+1);
        }else{
            chmin(cnt[i+1][j], cnt[i][j]);
        }
        if(c=='.' && mz[i][j+1]=='#'){
            chmin(cnt[i][j+1], cnt[i][j]+1);
        }else{
            chmin(cnt[i][j+1], cnt[i][j]);
        }
    }
    
    cout << cnt[gy][gx] << endl;
    return 0;
}

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

int main(){
  long long N,a,b,c,d;
  cin>>N;
  d=0;
  for(a=1;a<=N;a++){
for(b=1;b<=N;b++){
  for(c=1;c<=N;c++){
    d+=gcd(gcd(a,b),c);
  }
}
  }
  cout<<d<<endl;
}
  

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int H, W;
  cin >> H >> W;
  VEC<string> s(H);
  REP(i, 0, H) { cin >> s[i]; }
  REP(i, 0, H) {
    REP(j, 0, W) {
      if (s[i][j] == '#') {
        VEC<pair<int, int>> a = {
            {i + 1, j}, {i - 1, j}, {i, j + 1}, {i, j - 1}};
        bool ok = false;
        for (auto v : a) {
          int ni = v.first;
          int nj = v.second;
          if (0 <= ni && ni < H && 0 <= nj < W) {
            if (s[ni][nj] == '#') ok = 1;
          }
        }
        if (!ok) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout<<"Yes"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <chrono>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using llong = long long;
using ullong = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()
#define loop(i, times) for(llong i = 0; i < times; i++)
#define rloop(i, times) for(llong i = times -1; 0 <= i; i--)

std::chrono::system_clock::time_point  start;

void TimeStart(void)
{
	start = std::chrono::system_clock::now();
}

void TimeEnd(void)
{
	auto time = std::chrono::system_clock::now() - start;
	auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(time).count();
	cerr << endl <<msec << " msec" << endl;
}

#endif

class AGC029A
{
public:
	AGC029A()
	{
		cin >> s_;
		ans_ = 0;
	}
	void Run(void)
	{
		llong move_index = s_.size() - 1;
		rloop (i, s_.size())
		{
			if (s_[i] == 'B')
			{
				ans_ += move_index - i;
				move_index--;
			}
		}

		cout << ans_;
	}
private:
	string s_;
	llong ans_;
};

int main()
{
	AGC029A agc029a;

	TimeStart();
	agc029a.Run();
	TimeEnd();

	return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    int k;
    cin>>k;
    vector<int> v(t);
    for (int i = 0; i < t; i++)
    {
        cin>>v[i];
    }
    sort(v.begin(), v.end());
    long long sum = 0;
    for (int i = 0; i < k; i++)
    {
        sum+=v[i];
    }
    cout<<sum<<"\n";
}

Measured memory_bytes: 3620
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));


struct edge {
	int to;
	int w;
};
void dfs(vector<list<edge>>&g, vector<bool>&checked, vector<int> &value, int node) {
	if (checked[node] == true)return;
	else {
		checked[node] = true;
		for (auto v : g[node]) {
			value[v.to] = value[node] + v.w;
			dfs(g, checked, value, v.to);
		}
	}
}
int main() {
	int n, m;
	cin >> n >> m;
	vector<list<edge>>g(n);
	vector<int> l(m), r(m), d(m);
	rep(i, m) {
		cin >> l[i] >> r[i] >> d[i];
		l[i]--;
		r[i]--;
		g[l[i]].push_back(edge({ r[i], d[i] }));
		g[r[i]].push_back(edge({ l[i],-d[i] }));
	}
	vector<bool>checked(n, false);
	vector<int> value(n, -1);
	value[0] = 0;
	rep(i, n) {
		if (checked[i] == false) dfs(g, checked, value, i);
	}
	bool all = true;
	rep(i, m) {
		if (value[r[i]] - value[l[i]] != d[i]) {
			all = false;
			break;
		}
	}
	cout << (all ? "Yes" : "No");




	return 0;
}





Measured memory_bytes: 20736
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

res = 0
last = [0 for _ in range(26)]

for d in range(D):
    maxtmp = -10**18
    contest = None
    for i in range(26):
        tmp = res
        lasttmp = last[:]
        tmp += S[d][i]
        lasttmp[i] = d + 1
        for j in range(26):
            tmp -= C[j] * ((d + 1) - lasttmp[j])
        if maxtmp <= tmp:
            maxtmp = tmp
            contest = i
    res += S[d][contest]
    last[contest] = d + 1
    for j in range(26):
        res -= C[j] * ((d + 1) - last[j])
    print(contest + 1)

Measured memory_bytes: 9392
import sys
input = sys.stdin.readline
n, m = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)

import bisect
S = [0] * n
S[0]=A[0]
for i in range(1,n):
    S[i] = S[i-1]+A[i]


l = -1
r = A[0]*2+1
mi = (l+r)//2
while r-l > 1:
    t = n-1
    kai = 0
    for i in range(n):
        while t >= 0 and A[t] + A[i] < mi:
            t -= 1
        # print(i,t)
        kai += t+1
    # print(mi,kai)
    if kai < m:
        r = mi
    else:
        l = mi
    mi = (l+r)//2
# print(l)
# print(A)
t = n-1
ans = 0
kai = 0
for i in range(n):
    while t >= 0 and A[t] + A[i] < l:
        t -= 1
    kai += t+1
    # print(t)
    if t >= 0:
        ans += S[t] + (t+1)*A[i]
# print(ans)
# print(kai,m)
if kai > m:
    ans -= (kai-m)*l
print(ans)
# s = l+1
# for i in range(n):
#     ll=i
#     rr=n
#     mm=(ll+rr)//2
#     while rr-ll>1:
#         if A[mm] + A[i] < mi:
#             rr = mm
#         else:
#             ll = mm

#         mm = (ll+rr)//2
#     ans0 += S[ll]

Measured memory_bytes: 55204
import java.util.*;


public class Main {
    static class Plan{
        int t, x, y;

        Plan(int t, int x, int y){
            this.t = t;
            this.x = x;
            this.y = y;
        }

        int getT() {
            return t;
        }

        int getY() {
            return y;
        }

        int getX() {
            return x;
        }

        static int getTimeDifference(Plan p1, Plan p2){
            return Math.abs(p1.getT() - p2.getT());
        }

        static int getDistance(Plan p1, Plan p2){
            return Math.abs(p1.getX() - p2.getX()) + Math.abs(p1.getY() - p2.getY());
        }
    }

    static void solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        ArrayList<Plan> plans = new ArrayList<Plan>();
        plans.add(new Plan(0, 0, 0));
        for (int i = 0; i < n; i++){
            int t = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();
            plans.add(new Plan(t, x, y));
        }

        String ans = "Yes";
        for (int i = 0; i < plans.size()-1; i++){
            int dt = Plan.getTimeDifference(plans.get(i), plans.get(i+1));
            int dist = Plan.getDistance(plans.get(i), plans.get(i+1));
            boolean possible = (dt >= dist) && ((dt - dist) % 2 == 0);
            if(!possible){
                ans = "No";
                break;
            }
        }
        System.out.println(ans);
    }

    public static void main(String[] args){
        solve();
    }
}

Measured memory_bytes: 90212
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

signed main() {
    string A;
    cin >> A;
    int len = A.length();
    int ans = len * (len - 1) / 2 + 1;
    map<int, int> count;
    for (int i = 0; i < len; i++) {
        ans -= count[A[i]];
        count[A[i]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
function Main(input){
    input = input.split("\n");
 
 
    var p = 1,prime = [],c = 1;

    prime[0] = 2;
 
    while(p <= 123456 * 2){
        while(1){
            p += 2;
            var fl = true;
 
            for(var i = 3;i <= Math.sqrt(p);i += 2){
                if(p % i == 0){
                    fl = false;
                    break;
                }
            }
 
            if(fl){
                prime[c++] = p;
                break;
            }
        }
    }
 
 
    for(var i = 0;1;i++){
        var n = parseInt(input[i],10);
 
        if(n == 0)
            break;
 
        var start = -1,end;
 
        for(var j = 0;1;j++){
            if(start == -1 && prime[j] > n)
                start = j;
            if(start != -1 && prime[j] > 2 * n){
                end = j;
                break;
            }
        }
        console.log(end - start);
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 18088
#include <bits/stdc++.h>
#define N 200005
using namespace std;
typedef long long ll;
int n,a[N],b[N],ok[N];
ll ans=1e15,sum[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
	ok[0]=1;
	for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i],ok[i]=ok[i-1]&(a[i]==b[i]);
	if(ok[n]) return puts("0"),0;
	for(int i=n;i;i--){
		if(a[i]>b[i]) ans=min(ll(b[i]),ans);
	}
	printf("%lld",sum[n]-ans);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int v = 3;

  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
	if (S == "Y") {
      v = 4;
      break;
    }
  }
  if (v == 3) {
    cout << "Three" << endl;
  } else {
    cout << "Four" <<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a, b, c, t;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if(a > b){
        t = a;
        a = b;
        b = t;
    }
    
    if(b > c){
        t = b;
        b = c;
        c = t;
    }
    
    if(a > b){
        t = a;
        a = b;
        b = t;
    }
    
    printf("%d %d %d\n", a, b, c);
    
    return 0;
}


Measured memory_bytes: 2052
N,M,Q = map(int,input().rstrip().split(" "))
i = 0
K = []

A = [1] * N
A.append(M)
E = [M] * (N + 1)

q = []

karians = 0
ans = 0
for _ in range(Q):
    q.append(list(map(int,input().split(" "))))

while True:
    karians = 0
    for qq in q:
        if A[qq[1] -1] - A[qq[0] -1] == qq[2]:
            karians += qq[3]
    if karians > ans:
        ans = karians
    if A == E:
        break
    i = 0
    A[0] += 1
    while A[i] == A[i + 1] + 1:
        A[i] = 1
        A[i + 1] += 1
        i += 1
        if i == N - 1:
            break
print(ans)

Measured memory_bytes: 9244
import java.util.Scanner;

public class Main {

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

		final int a = sc.nextInt();
		final int b = sc.nextInt();

		final int num = Integer.valueOf(String.valueOf(a) + String.valueOf(b));

		String result = "No";
		for (int i = 1; i <= num; i++) {
			if (num % i > 0) {
				continue;
			} else if (i == num / i) {
				result = "Yes";
				break;
			}
		}

		System.out.print(result);

	}

}


Measured memory_bytes: 20820
N=int(input())
*p,=map(float,input().split())
dp=[[0]*(N+1) for _ in range(N+1)]
dp[0][0]=1

for i in range(1,N+1):
    for j in range(N+1):
        dp[i][j]=dp[i-1][j]*(1-p[i-1])
        if j:dp[i][j]+=dp[i-1][j-1]*p[i-1]

print(sum(dp[N][i] for i in range(N+1) if 2*i>=N))

Measured memory_bytes: 252168
#include<bits/stdc++.h>
#define ll unsigned long long
using namespace std;
int main(){
   ll a,b,c,d,l,r,t,g,p;
   cin>>a>>b>>c>>d;
   p=(c*d)/__gcd(c,d);
   l=b/c-(a-1)/c;
   r=b/d-(a-1)/d;
   g=b/p-(a-1)/p;
   t=b-a+1;
   cout<<t-(l+r-g);
   
    return 0;
    
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        int a = sc.nextInt();
        out.println(a + a * a + a * a * a);
        out.flush();
        out.close();
    }

    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        Scanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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


Measured memory_bytes: 32792
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
using namespace std;


ll lis[10][10];
int main() {
    
    ll n;
    cin >> n;
    for(ll i=1;i<=n;i++){
        string s = to_string(i);
        ll p,q;
        p = s[0] - '0';
        q = s[s.length()-1] - '0';
        lis[p][q]++;
    }
    ll ans = 0;
    for(ll i=1;i<=9;i++){
        for(ll j=1;j<=9;j++){
            ans += lis[i][j] * lis[j][i];
        }
    }
    cout << ans << endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int mod_pow(long long x,int n){
	long long res=1;
	while(n>0){
		if(n&1)
			res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
int main(){
	int n,a[100000];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	bool ok=true;
	for(int i=0;i<n;i++)
		ok&=a[i]==(i+n%2)/2*2+(n+1)%2;
	cout<<(ok?mod_pow(2,n/2):0)<<endl;
}


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



int main() {
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
typedef pair<ll,ll> P;

int main() {
  ll T,n;
  cin >> T >> n;
  P a[n];
  ll d[n+1];
  d[0]=0;
  for(int i=0; i<n; i++) {
    cin >> a[i].F >> a[i].S;
    d[i+1]=d[i]+a[i].S-a[i].F;
  }
  ll ans=0;
  for(int i=0; i<n; i++) {
    ll l=i,r=n;
    while(l+1<r) {
      ll m=(l+r)/2;
      if(a[m].S-a[i].F>T) r=m;
      else l=m;
    }
    ll cnt=d[l]-d[i];
    ll t=T-(a[l].F-a[i].F);
    cnt+=min(t,a[l].S-a[l].F);
    ans=max(ans,cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5436
n,m,x = map(int,input().split())
book = [list(map(int, input().split())) for _ in range(n)]
cos_min=10**10*n
for i in range(1,2**n):
    s_c= [0]*(m+1)
    choose = bin(i)[2:].zfill(n)

    for j in range(n):
        if choose[n-j-1]=="1":  
            s_c = [a+b for (a,b)in zip(s_c,book[j])]

    for j in s_c[1:]:
        if j<x:
            break
    else:
        cos_min=min(cos_min,s_c[0])

if cos_min!=10**10*n :
    print(cos_min)
else:
    print(-1)    


Measured memory_bytes: 9168
class UnionFind:
    # parent：親の番号を格納する
    # 親だった場合は-(その集合のサイズ)
    # すべてのノードが独立した状態でスタート
    def __init__(self, N):
        self.parent = [-1]*N
    
    # aがどのグループに属しているか再帰的に調べる
    def root(self, a):
        if(self.parent[a] < 0):
            return a
        else:
            # returnする前に親をメモしてしまう
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    
    # aのいるグループの頂点数を調べる
    def size(self, a):
        return -self.parent[self.root(a)]
        
    # aとbをくっつける
    def connect(self, a, b):
        # aとbを直接つなぐのではなくroot(a)にroot(b)をくっつける
        a = self.root(a)
        b = self.root(b)
        if(a==b):
            # 既にくっついているのでくっつけない
            return False
        else:
            # 大きいほうaに小さいほうbをくっつけたい
            # 大小逆ならひっくり返す
            if(self.size(a) < self.size(b)):
                a,b=b,a
            # aのサイズを更新する
            self.parent[a] += self.parent[b]
            # bの親をaに変更する
            self.parent[b] = a
            return True
          
N,M=list(map(int,input().split()))
A,B=[],[]
ans=[0]*M
Uni=UnionFind(N)
for i in range(M):
    a,b=list(map(int,input().split()))
    A.append(a-1)
    B.append(b-1)
 
ans[M-1] = int(N*(N-1)/2)
 
for i in range(M-1,0,-1):
    # 繋がってなかったのが繋がったとき
    if(Uni.root(A[i])!=Uni.root(B[i])):
        ans[i-1] = ans[i] - Uni.size(A[i])*Uni.size(B[i])
    else:
        ans[i-1] = ans[i]
    Uni.connect(A[i],B[i])
for i in range(M):
    print(ans[i])


Measured memory_bytes: 16928
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>

using namespace std;
typedef long long ll;

char S[10] = {};
ll letter[30] = {}, counter = 0;

int main() {
	cin >> S;
	for (int i = 0; i < 4; i++)letter[S[i]-'A']++;
	for (int i = 0; i < 30; i++) {
		if (letter[i] == 2)counter++;
		if ((letter[i] != 0 && letter[i] != 2) || counter >= 3) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
    #include <cstdio>
    #include <bitset>
    #define M 8005
    using namespace std;
     
    int x, y, z, c;
    string s;
    bitset<M * 2> bs[2];
    int main() {
    	int i;
    	cin >> s >> x >> y;
    	for (i = 0; s[i] == 'F'; i++);
    	bs[0][i + M] = bs[1][M] = 1;
    	for (; i <= s.size(); i++) {
    		if (s[i] == 'F') c++;
    		else bs[z] = (bs[z] << c) | (bs[z] >> c), z = !z, c = 0;
    	}
    	cout << (bs[0][x + M] & bs[1][y + M] ? "Yes" : "No");
    	return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int status[4];

int main(){
    int N; cin >> N;
    vector<string> s(N);

    for(int i=0; i<N; ++i){
        cin >> s[i];
    }

    for(int i=0; i<N; ++i){
        if(s[i] == "AC"){
            status[0]++;
        }else if(s[i] == "WA"){
            status[1]++;
        }else if(s[i] == "TLE"){
            status[2]++;
        }else if(s[i] == "RE"){
            status[3]++;
        }
    }

    for(int i=0; i<4; ++i){
        if(i == 0){
            cout << "AC x " << status[i] << endl;
        }else if(i == 1){
            cout << "WA x " << status[i] << endl;
        }else if(i == 2){
            cout << "TLE x "<< status[i] << endl;
        }else if(i == 3){
            cout << "RE x " << status[i] << endl;

        }
    }
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const int mod = 1e9+7;
const int N = 1e5+345;

int x[N], y[N];

void solve() {
	int n, m; scanf("%d%d", &n, &m);
	for (int i = 0; i < n; ++i) scanf("%d", x+i);
	for (int i = 0; i < m; ++i) scanf("%d", y+i);
	long long xs = 0;
	for (long long i = 0; i < n; ++i) {
		(xs += x[i] * (2*i - n + 1) % mod) %= mod;
	}
	debug(xs);
	long long ys = 0;
	for (long long i = 0; i < m; ++i) {
		(ys += y[i] * (2*i - m + 1) % mod) %= mod;
	}
	printf("%lld", xs*ys%mod);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

int main(void){
    int n = 0; 
    int w[101];
    int ans = 0;
    int s1 = 0, s2 = 0;

    scanf("%d", &n);

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

    for(int i = 1; i < n; i++){
        s1 = 0;
        s2 = 0;

        for(int j = 0; j < i; j++){
            s1 += w[j];
        }        
        for(int k = i; k < n; k++){
            s2 += w[k];
        }
//        printf("i = %d abs(s1-s2) = %d\n", i, abs(s1-s2));
        if(i == 1){
            ans = abs(s1 - s2);
        }
        if(ans > abs(s1 - s2)){
            ans = abs(s1 - s2);
        }
    }
    printf("%d\n", ans);

    return 0;

} 


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc127/tasks/abc127_c

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

int main()
{
    int n;
    long k;
    int q;
    cin >> n >> k >> q;
    vector<int> s(n, k - q);

    for (int i = 0; i < q; i++)
    {
        int a;
        cin >> a;
        s[--a]++;
    }

    for (int i = 0; i < n; i++)
    {
        if (s[i] > 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3776
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

X = I()

a = 100
for i in range(INF):
    if a >= X:
        print(i)
        break

    a = int(a * 1.01)

Measured memory_bytes: 68240
n,k = map(int,input().split())
L = list(map(int,input().split()))
 
aaa = sum(L[0:k])
ans = aaa
for i in range(k,n):
    aaa += L[i]
    aaa -= L[i-k]
    if ans <= aaa:
        ans = aaa
    i += 1    
     
print((ans+k)/2)  


Measured memory_bytes: 24812
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;

public class Main {

	static final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

	public static void main(String[] args) throws Exception {

		// --- input ---
		int[] l1 = getNums(in.readLine().split(" "), 2);
		int[] vals = getNums(in.readLine().split(" "), l1[0]);
		in.close();

		// --- resolv ---
		HashMap<Integer, Integer> map = new HashMap<>();
		for(int v : vals) {
			if(map.containsKey(v)) {
				map.put(v, map.get(v) + 1);
			} else {
				map.put(v, 1);
			}
		}

		List<Integer> ary = map.values().parallelStream().sorted((a,b)->b-a).collect(Collectors.toList());

		int ans = 0;
		for(int i=0; i < ary.size(); i++) {
			if(i < l1[1]) {
				continue;
			}
			ans += (int)ary.get(i);
		}

		System.out.println(ans);
	}

	public static int[] getNums(String[] vals, int num) {
		int[] vAry = new int[num];
		for(int i=0; i < num; i++) {
			vAry[i] = Integer.parseInt(vals[i]);
		}
		return vAry;
	}
}

Measured memory_bytes: 57972
#include <bits/stdc++.h>
     
    using namespace std;
     
    int main() {
      string s;
      cin >> s;
      for (int i = 1; i < s.size(); ++i) {
        if (s[i] == s[i - 1]) {
          cout << "Bad" << endl;
          return 0;
        }
      }
      cout << "Good" << endl;
    }

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int gcd(int a,int b){
    if(b>a){
        int temp=a;
        a=b;
        b=temp;
    }
    int r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    int g=a[0];
    for(int i=1;i<n;i++){
        g=gcd(g,a[i]);
    }
    cout<<g;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<int, int> P;
priority_queue<P, vector<P>, greater<P>> pque;

int N,M;
bool visited[100100];
int dp[100100]={0};
vector<int> G[100100],v;

void dfs(int s){
  visited[s]=1;
  for(int i=0;i<G[s].size();i++){
    if(!visited[G[s][i]]){
      dfs(G[s][i]);
    }
  }
  v.push_back(s);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N >> M;
  int x,y;
  for(int i=0;i<M;i++){
    cin >> x >> y;
    x--;
    y--;
    G[x].push_back(y);
  }

  for(int i=0;i<N;i++){
    if(!visited[i]){
      dfs(i);
    }
  }
  reverse(v.begin(),v.end());

  int ans=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<G[v[i]].size();j++){
      dp[G[v[i]][j]]=max(dp[G[v[i]][j]],dp[v[i]]+1);
    }
    ans=max(ans,dp[v[i]]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8056
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	double ave=0;
	rep(i,0,n){
		cin >> a[i];
		ave += a[i];
	}
	
	ave = ave/n;
	int num = ave;
	if(ave > 0 ){
		if(ave - num >= 0.5)
			ave += 0.99999999999;
	}
	else{
		if( ave - num >= 0.5)
			ave -= 0.99999999999;
	}
	
	//P(ave);
	
	num = ave;
	long ans = 0;
	rep(i,0,n){
		ans += (num - a[i] ) * (num - a[i] );
	}

	P(ans);
	
	ret 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define speedX ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout<< name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_time() cout << "\n\nTime of execution: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define end_time()
#endif


#define int long long 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
inline bool equals(ld a, ld b) {return fabs(a - b) < 1e-9;}
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define mod 1000000007


void solve(){
	int n;
	string s;
	cin>>n>>s;
	int ans =0;
	for(int i = 0; i<n-2; i++){
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ans++;
	}
	cout<<ans<<"\n";
}
signed main(){
	speedX;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	end_time();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
using namespace std; 
 
int main(void)
{
 
  long long a, b, q;
  q=1;
  cin >> a >>b;

  if (a>=b){
      for (int i=1;i<=b;i++){
          if (a%i==0 && b%i==0){
              q=i;
          }
      }
  }
  else{
      for (int i=1;i<=a;i++){
          if (a%i==0 && b%i==0){
              q=i;
          }
      }
  }
  a=a/q;
  b=b/q;
  
  cout << q*a*b << "\n";
  


 
  
  
}




Measured memory_bytes: 256
N, X, Y = map(int, input().split())
X, Y = X - 1, Y - 1

ans = [0] * (N - 1)
for i in range(N - 1):
    for j in range(i + 1, N):
        d = min(j - i, abs(X - i) + 1 + abs(Y - j),
                abs(Y - i) + 1 + abs(X - j))
        ans[d - 1] += 1

for k in range(N - 1):
    print(ans[k])


Measured memory_bytes: 3444
#include <cstdio>
int main(){double n,a,d,s=0;scanf("%lf%lf%lf",&n,&a,&d);for(a-=d;n;--n){s+=a+(n+0.5)*d;a+=(2*a+3*d)/n/2;d+=2/n*d;}printf("%.9lf",s);}

Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
import heapq

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(H: int, N: int, A: "List[int]"):
    damage = sum(A)
    if H > damage:
        print(NO)
    else:
        print(YES)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(H, N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14112
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl
#define first(v) get<0>(v)
#define second(v) get<1>(v)
#define third(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;



int main(){
    ll N;
    cin >> N;
    string S;
    cin >> S;
    vector<ll> wuntil(N,0);
    vector<ll> eikou(N,0);
    for(ll i=0;i<N;i++){
        if(i!=0)wuntil[i]=wuntil[i-1];
        if(S[i]=='W')wuntil[i]++;
    ;}
    for(ll i=N-1;i>=0;i--){
        if(i!=N-1)eikou[i]=eikou[i+1];
        if(S[i]=='E')eikou[i]++;
    ;}
    ll ans=INF;
    chmin(ans,eikou[1]);
    chmin(ans,wuntil[N-2]);
    for(ll i=1;i<=N-2;i++){
        chmin(ans,eikou[i+1]+wuntil[i-1])
    ;}
    print(ans);

    
    return 0;
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

signed main() {
	int a, b;
	cin >> a >> b;
	if (a > b) swap(a, b);

	rep (i, b) {
		cout << a;
	}
	cout << endl;

	return 0;
}

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

int main(void){
    
    int a,b,c;
    
    cin >> a >> b >> c;
    
    if(a==b)cout<<c;
    else if(a==c)cout<<b;
    else cout<<a;
    
    
    
    
    
    return 0;
    
}


Measured memory_bytes: 256
yn = lambda b: print('Yes') if b else print('No')
#-------------------------------------------------------------------

N, K, Q = map(int, input().split())		# 5 7 2

A=[K-Q]*N

for _ in range(Q):
	a=int(input())-1
	A[a]+=1

for a in A:
	yn( a>0 )
	

Measured memory_bytes: 6584
N, *AB = map(int, open(0).read().split())
AB = [(B, -A) for A, B in zip(AB[::2], AB[1::2])]
AB.sort()
t = 0
for b, a in AB:
    a = -a
    t += a
    if t > b:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 49116
#include <iostream>
#include <vector>

using namespace std;

long long n;
vector <int> c;
vector < vector <int> > mv;
vector <long long> res;

int sol(int ac, int fa,vector <int> &el){
	long long gu = el[c[ac]];
	long long so = 1;
	long long re;
	for(int i=0;i<mv[ac].size();i++)if(mv[ac][i]!=fa){
		el[c[ac]]=0;
		re = sol(mv[ac][i],ac,el);
		so += re;
		re-=el[c[ac]];
		re = re * (re-1)/2 + re;
		res[c[ac]] -= re;
	}
	el[c[ac]] = gu +so;
	return so;
}
int main(){
	
	cin>>n;
	c.resize(n);
	for(int i=0;i<n;i++)cin>>c[i],c[i]--;
	mv.resize(n);
	res.resize(n,n*(n-1)/2+n);
	vector <int> el(n,0);
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		mv[v].push_back(u);
		mv[u].push_back(v);
	}
	sol(0,0,el);
	for(int i=0;i<n;i++){
		long long re = n - el[i];
		re = re * (re-1)/2 + re;
		res[i] -= re;
		cout<<res[i]<<endl;
	}
	
	return 0;
}

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

double dp[301][301][301];
double solve(int x,int y,int z,int n)
{
    if(x<0 || y<0 || z<0){return 0;}
    if(x==0 && y==0 && z==0){return 0;}
    if(dp[x][y][z] > -0.9){return dp[x][y][z];}
    double exp = n+x*solve(x-1,y,z,n)+y*solve(x+1,y-1,z,n)+z*solve(x,y+1,z-1,n);
    return dp[x][y][z] = exp/(x+y+z);
}

int32_t main()
{
    int n,x;cin>>n;
    memset(dp,-1,sizeof dp);
    int one = 0,two = 0,three = 0;
    for(int i=1;i<=n;i++){
        cin>>x;
        if(x==1){one++;}
        else if(x==2){two++;}
        else three++;
       
    }
     cout<<fixed<<setprecision(9)<<solve(one,two,three,n);
    
    
}




Measured memory_bytes: 216888
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 300;
const int INF = 1e9;
const double pi=acos(-1);

int main(){
  string s,t;
  cin >> s >> t;
  bool ok =true;
  map<char,char>a,b;
  rep(i,s.size()){
    if(a.count(s[i])){
      if(a[s[i]] != t[i]) ok=false;
    }
    if(b.count(t[i])){
      if(b[t[i]] != s[i]) ok=false;
    }
    a[s[i]]=t[i];b[t[i]]=s[i];
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 776