akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n, k;
  cin >> n >> k;

  int ans = n - k + 1;

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 888
import math
x=int(input())
x=180-x

ans=360//math.gcd(360,x)

ex=[60,120]

if(x in ex):
    x=180-x
    ans=360//math.gcd(360,x)
print(ans)
#for i in range(1,180):
#    if(360//math.gcd(360,i)==6):
#        print(i,360//math.gcd(360,i))
#    if(i==x):
        #print("問題の箇所",x,ans)

Measured memory_bytes: 62148
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

string d[7] = { "SUN","MON","TUE","WED","THU","FRI","SAT"};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    string S;
    cin >> S;
    for(int i = 0; i < 7; i++){
        if(S == d[i]){
            cout << 7-i << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


bool pairCompare(const Pi& firstElof, const Pi& secondElof)
{
	return firstElof.second > secondElof.second;
}

ll gcd(ll a, ll b) {
	ll temp;
	while (a % b != 0)
	{
		temp = b;
		b = a % b;
		a = temp;
	}
	return b;
}

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

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

	ll r, d, x;
	cin >> r >> d >> x;
	rep(i, 10) {
		x = r * x - d;
		cout << x<< endl;
	}




	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int n, m, r;
  cin >> n >> m >> r;
  VI rs(r);
  FOR(x,rs) {
    cin >> x;
    x--;
  }
  vector<VL> dist(n, VL(n, 1e18));
  REP(i,0,m) {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    dist[a-1][b-1] = c;
    dist[b-1][a-1] = c;
  }
  REP(k,0,n) {
    REP(i,0,n) {
      REP(j,0,n) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  sort(rs.begin(), rs.end());
  ll ans = 1e18;
  do {
    ll d = 0;
    REP(i,1,r) {
      d += dist[rs[i-1]][rs[i]];
    }
    ans = min(ans, d);
  } while (next_permutation(rs.begin(), rs.end()));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	std::int64_t T1, T2, A1, A2, B1, B2;
	std::cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
	auto first = T1 * (B1 - A1);
	auto second = T2 * (B2 - A2);
	auto oneloop = first + second;
	if (oneloop == 0)
	{
		std::cout << "infinity" << std::endl;
		return;
	}
	if (oneloop < 0)
	{
		first *= -1;
		second *= -1;
		oneloop *= -1;
	}
	auto c = std::abs(first) / oneloop;
	if (0 < first)
	{
		std::cout << 0 << std::endl;
	}
	else if (std::abs(first) % oneloop == 0)
	{
		std::cout << 2 * c << std::endl;
	}
	else
	{
		std::cout << 2 * c + 1 << std::endl;
	}
}

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

Measured memory_bytes: 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int n;
    int tn[50];
    int t=0;
    string s[50];
    string ss;
    cin >> n;
    rep(i,n){
        cin >> s[i];
        cin >> tn[i];
    }
    cin >> ss;
    rep(i,n){
        if(ss == s[i]){
            for(int j = i+1; j<n;j++){
                t += tn[j];
            }
        }
    }
    cout << t << endl; 
}

Measured memory_bytes: 888
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10**7)

ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

s = ns()
s = list(s)

ans = 0
i = 0
while i < len(s):
    if s[i] == '?':
        if i >= 1 and s[i - 1] == 'P':
            s[i] = 'D'
        elif i < len(s) - 1 and s[i + 1] == 'D':
            s[i] = 'P'
        else:
            s[i] = 'D'
    i += 1

print(*s, sep="")

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

class SegmentTree {
    vector<int> dat;
    public:
        int N;
        SegmentTree(int n);
        int query(int a, int b, int k, int l, int r);
        void update(int k, char a);
};

SegmentTree::SegmentTree(int n) {
    N = 1;
    while (N < n) N *= 2;
    dat.resize(2*N);
    rep(i, N) dat[i] = 0;
}

int SegmentTree::query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return 0;

    if (a <= l && r <= b) {
        return dat[k];
    } else {
        int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return vl | vr;
    }
}

void SegmentTree::update(int k, char a) {
    k += N - 1;
    a -= 'a';
    dat[k] = 1 << a;

    while (0 < k) {
        k = (k - 1) / 2;
        dat[k] = dat[2 * k + 1] | dat[2 * k + 2];
    }
}

int main(){
    int N, Q;
    string S;
    cin >> N >> S >> Q;

    SegmentTree st = SegmentTree(N);

    rep(i, N) st.update(i, S[i]);

    rep(_, Q) {
        int t;
        cin >> t;
        if (t == 1) {
            int a;
            char c;
            cin >> a >> c;
            st.update(--a, c);
        } else {
            int l, r;
            cin >> l >> r;
            int s = st.query(--l, r, 0, 0, st.N);
            int ans = __builtin_popcount(s);
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 4996
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int H, W; cin >> H >> W;
    vector<string> s(H + 2); for (int i = 1; i <= H; i++) cin >> s[i];

    s[0] = ""; s[H + 1] = "";
    for (int i = 0; i <= W + 1; i++) {
        s[0] += '.'; s[H + 1] += '.';
    }

    for (int i = 1; i <= H; i++) {
        s[i] = '.' + s[i] + '.';
    }

    bool ans_flag = 1;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (s[i][j] == '#' && s[i][j - 1] == '.' && s[i][j + 1] == '.' && s[i - 1][j] == '.' && s[i + 1][j] == '.') {
                ans_flag = 0;
                break;
            }
        }
    }

    if (ans_flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
inf = 10**17
mod = 10**9+7

# グリッドBFS
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]

dy_dx = [[1,0],[0,1],[-1,0],[0,-1]]

ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == '#': continue
        dis = [[-1 for k in range(w)] for k in range(h)]
        dis[i][j] = 0
        d = deque()
        d.append([i, j])
        while len(d):
            now = d.popleft()
            y = now[0]
            x = now[1]
            for k in range(4):
                ny = y + dy_dx[k][0]
                nx = x + dy_dx[k][1]
                if 0 <= ny < h and 0 <= nx < w:
                    if s[ny][nx] != '#' and dis[ny][nx] == -1:
                        dis[ny][nx] = dis[y][x] + 1
                        ans = max([ans, dis[ny][nx]])
                        d.append([ny, nx])

print(ans)


Measured memory_bytes: 9432
N = int(input())
card = list(map(int,input().split(' ')))

sum_card = sum(card)
min_value = 10000000000
sunuke = 0
for i in range(0,N-1,1):
  sunuke += card[i]
  if abs(sum_card - 2*sunuke) < min_value:
    min_value = abs(sum_card - 2*sunuke)
  
print(int(min_value))

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

int main()
{
  int n;
  cin>>n;
  
  vector<string> str(n);
  map<string,int> maps;
  for(int i=0;i<n;i++)
  {
    cin>>str.at(i);
    if(maps.count(str.at(i)))
      maps.at(str.at(i))++;
    else
      maps[str.at(i)]=1;
  }
  
  int hindo=0;
  for(string x:str)
  {
    if(maps.at(x)>hindo)
      hindo=maps.at(x);
  }
  
  for(auto i=maps.begin();i!=maps.end();i++)
  {
    if(i->second==hindo)
      cout<<i->first<<endl;
  } 
}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define debug(x) cerr << #x << " = " << x << endl

int main(int qtd, char* nome[])
{
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	int n, k;
	cin >> n >> k;
	int d[k];
	for(int i=0; i<k; i++)
		cin >> d[i];
	int ans;
	function<bool(int)> f = [&d, &k](int n){
		while(n){
			int digit = n%10;
			for(int i=0; i<k; i++)
				if(digit == d[i])
					return false;
			n/=10;
		}
		return true;
	};
	for(ans=n; ans<1000000; ans++)
		if(f(ans))
			break;
	
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int a[100];
	rep(i, n) cin >> a[i];
	int ans = INF;
	for (int i = -100; i <= 100; i++) {
		int tmp = 0;
		rep(j, n) {
			tmp += (int)pow(a[j] - i, 2);
		}
		ans = min(ans, tmp);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
 ll N;
  ll M;
  cin >>N>>M;
  vvl vec(M);
  rep(i,M) {
ll aa;
    cin >>aa;
    rep(j,aa) {
      ll bb;
      cin >>bb;
      
      vec.at(i).push_back(bb);
    }
  }
  
  
  
  vl p(M);
  rep(i,M) {
cin >>p.at(i);
  }

  ll cou=0;
  for (int bit = 0; bit < (1<<N); ++bit) { 
 
    vl ps(M);
    rep(i,M) {
      ps.at(i)=0;
    }
    
 rep(i,N) {
if (bit & (1 << i)) {
  rep(j,M) {
    rep(k,vec.at(j).size()) {
      if(vec.at(j).at(k)==N-i) {
        ps.at(j)++;
      }
    }
  }
  
  
  
}
 }
    
    
    
    
    
    rep(i,M) {
     ps.at(i)=ps.at(i)%2;
    }
    bool ans=true;
    rep(i,M) {
      if(p.at(i)!=ps.at(i)) {
        ans=false;
        break;
      }
    }
    if(ans) {
      cou++;
    }
    
    
  }
  
  
  
  cout<<cou<<endl;
}
    
    
    

 

Measured memory_bytes: 256
#include <cstdio>
#define MAX 10000
#define NIL -1
 
struct Node{
    int parent,left,right;
};
 
Node T[MAX];
int n,D[MAX],H[MAX];
 
void setDepth(int u,int d){
    if(u==NIL) return;
    D[u] = d;
    setDepth(T[u].left,d+1);
    setDepth(T[u].right,d+1);
}
 
int setHeight(int u){
    int h1=0,h2=0;
    if(T[u].left!=NIL)
        h1=setHeight(T[u].left)+1;
    if(T[u].right!=NIL)
        h2=setHeight(T[u].right)+1;
    return H[u]=(h1>h2?h1:h2); 
}
 
int getSibling(int u){
    if(T[u].parent == NIL) return NIL;
    if(T[T[u].parent].left!=u&&T[T[u].parent].left!=NIL)
        return T[T[u].parent].left;
    if(T[T[u].parent].right!=u&&T[T[u].parent].right!=NIL)
        return T[T[u].parent].right;
    return NIL;     
}
 
void print(int u){
    printf("node %d: ",u);
    printf("parent = %d, ",T[u].parent);
    printf("sibling = %d, ",getSibling(u));
    int deg = 0;
    if(T[u].left !=NIL) deg++;
    if(T[u].right !=NIL) deg++; 
    printf("degree = %d, ",deg);
    printf("depth = %d, ",D[u]);
    printf("height = %d, ",H[u]);
     
    if(T[u].parent == NIL){
        printf("root\n");
    }else if(T[u].left==NIL && T[u].right==NIL){
        printf("leaf\n");
    }else{
        printf("internal node\n");
    }
}
 
int main() {
     
    int v,l,r,root = 0;
    scanf("%d",&n);
    for(int i=0;i<n;i++) T[i].parent = NIL;
     
    for(int i=0;i<n;i++){
        scanf("%d %d %d",&v,&l,&r);
        T[v].left=l;
        T[v].right=r;
        if(l != NIL) T[l].parent = v;
        if(r!=NIL) T[r].parent = v;
    }
     
    for(int i=0;i<n;i++) 
        if(T[i].parent == NIL) 
            root = i;
     
    setDepth(root,0);
    setHeight(root);
     
    for(int i=0;i<n;i++) print(i);
     
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    int H[N];
    for(int i=0; i<N; i++){
        cin >> H[i];
    }
    int max_h=1;
    int res=0;
    for(int i=0; i<N; i++){
        if(H[i] >= max_h){
            res ++;
            max_h = H[i];
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  ll N,A,B;
  cin >> N >> A >> B;
  vector<ll> X(N);
  for(int i=0; i<N; i++){
    cin >> X[i];
  }
  ll sum = 0;
  for(int i=1; i<N; i++){
    if((X[i]-X[i-1])*A <= B){
      sum += (X[i]-X[i-1])*A;
    }else{
      sum += B;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <queue>
#include <cmath>
#include <map>
#define Pr pair <int, int>
#define mp make_pair
#define fi first
#define se second
using namespace std;
const int P = 998244353;
const int maxn = 1003;
const int INF = 1000000000;
vector <int> G[maxn];
int n, col[maxn];
int bfs(int s){
    queue <int> q;
    memset(col, 0, sizeof(col));
    q.push(s);
    col[s] = 1;
    while (! q.empty()){
        int u = q.front(); q.pop();
        for (int i = 0; i < G[u].size(); ++ i){
            int v = G[u][i];
            if (! col[v]){
                col[v] = col[u] + 1;
                q.push(v);
            }
            else if (col[v] != col[u] + 1 && col[v] != col[u] - 1)
                return -1;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; ++ i)
        ans = max(ans, col[i]);
    return ans;
}
int read(){
	int c = 0, f = 1; char ch = getchar();
	while (ch != '-' && (ch < '0' || '9' < ch)) ch = getchar();
	if (ch == '-') f = -1, ch = getchar();
	while ('0' <= ch && ch <= '9') c = c * 10 + ch - '0', ch = getchar();
	return c * f;
}
int main(){
    n = read();
    for (int i = 1; i <= n; ++ i){
        string s;
        cin >> s;
        for (int j = i + 1; j <= n; ++ j)
            if (s[j - 1] == '1'){
                G[i].push_back(j);
                G[j].push_back(i);
            }
    }
    int ans = -1;
    for (int i = 1; i <= n; ++ i)
        ans = max(ans, bfs(i));
    cout << ans << endl;
}


Measured memory_bytes: 512
import math
n,m = map(int,input().split())
n_f = math.factorial(n);m_f = math.factorial(m)
if abs(n-m) == 1:print((n_f*m_f)%(10**9+7))
elif n == m:print((n_f*m_f*2)%(10**9+7))
else:print(0)

Measured memory_bytes: 5180
var i,j,a:integer;
	s:array[1..10] of char;

begin
	readln(a);
  for i:=1 to 10 do begin
    read(s[i]);
    if eoln then break
  end;
  readln;
  if a>=3200 then begin
    for j:=1 to i do write(s[j]);
      writeln;
    end
      else writeln('red')
end.

Measured memory_bytes: 128
if __name__ == '__main__':
    n = int(input())
    prices = []
    # get price
    for i in range(n):
        prices.append(int(input()))
    maxp = prices[1] - prices[0]
    minp = prices[0]
    for i in range(1, n):
        maxp = max(maxp, prices[i] - minp)
        minp = min(minp, prices[i])
    print(maxp)


Measured memory_bytes: 13592
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
ans = 0
s = 0
uppers = []
(0...N).each{ |i|
  if A[i] < B[i]
    s += B[i] - A[i]
    ans += 1
  end
  if A[i] > B[i]
    uppers << (A[i] - B[i])
  end
}
uppers.sort.reverse_each{ |d|
  break if s <= 0
  s -= d
  ans += 1
}
p s > 0 ? -1 : ans


Measured memory_bytes: 16528
#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, B, C;
    cin >> A >> B >> C;

    if (A == B) {
        if(B == C) cout << "No" << endl;
        else cout << "Yes" << endl;
    } else {
        if(B == C) cout << "Yes" << endl;
        else if(A == C) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

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

int main(){
    int N, M, ans = 0;
    cin >> N >> M;
    int food[M] = {};
    
    for(int i = 0; i < N; i++){
        int K;
        cin >> K;
        for(int j = 0; j < K; j++){
            int like;
            cin >> like;
            food[like - 1]++;
        }
    }

    for(int i = 0; i < M; i++){
        if(food[i] == N){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD = 1000000007;
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin >> A[i];

    ll sum1 = 0,sum2 = 0;
    vector<ll> csum(N+1);
    for(int i=0;i<N;i++){
        csum[i+1] = csum[i]+A[i];
        if(i%2 == 0){
            if(csum[i+1] > 0) continue;
            sum1 += abs(csum[i+1])+1;
            csum[i+1] += abs(csum[i+1])+1;
             
        }
        else{
            if(csum[i+1] < 0) continue;
            sum1 += abs(csum[i+1])+1;
            csum[i+1] -= abs(csum[i+1])+1;
        }
    }
    for(int i=0;i<N;i++){
        csum[i+1] = csum[i]+A[i];
        if(i%2 == 0){
            if(csum[i+1] < 0) continue;
            sum2 += abs(csum[i+1])+1;
            csum[i+1] -= abs(csum[i+1])+1;
             
        }
        else{
            if(csum[i+1] > 0) continue;
            sum2 += abs(csum[i+1])+1;
            csum[i+1] += abs(csum[i+1])+1;
        }
    }

    cout << min(sum1,sum2) << endl;
}


Measured memory_bytes: 1792
#include <stdio.h> 

int main(){
	int x;
	int a;
	int b;

	char buf[256];
	fgets(buf,256,stdin);
	sscanf(buf,"%d %d %d" ,&x,&a,&b);

	if(a-b>=0){
	   printf("delicious\n");
	}else if(x>=b-a){
	   printf("safe\n");
	}else if(x<b-a){
	   printf("dangerous\n");
	}
	return 0;
}

Measured memory_bytes: 128
n = int(input())
for i in range(n):
  now = []
  I = '0' * (11-len(bin(i))) + bin(i)[2:]
  for j in range(i+1,n):
    J = '0' * (11-len(bin(j))) + bin(j)[2:]
    #print(I,J)
    for k in range(9):
      if I[k] != J[k]:
        now.append(9-k)
        break
  print(' '.join(list(map(str,now))))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  long long n,a,b,c,d,e;
  cin>>n>>a>>b>>c>>d>>e;
  long  long x=min(a,min(b,min(c,min(d,e))));
  cout<<4+(n+x-1)/x<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Linq;
class Program
{
    static ArrayList s = new ArrayList();
    public static ArrayList DepthFirstSearch(Node root)
    {
        s.Add(root.x);
        root.Visited = true;
        if (root.Children != null)
        {
            for (int i = 0; i < root.Children.Count; i++)
            {
                if (!((Node)(root.Children[i])).Visited)
                {
                    DepthFirstSearch(((Node)root.Children[i]));
                }
            }
        }
        return s;
    }
    static void Main()
    {
        //入力を受け取る
        int[] nm = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int n = nm[0], m = nm[1];
        int[] p = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int[][] xy = new int[m][];
        for (int i = 0; i < m; i++)
            xy[i] = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        //処理内容
        Node[] v = new Node[n];
        for (int i = 0; i < n; i++)
            v[i] = new Node(i + 1);
        for (int i = 0; i < m; i++)
        {
            v[xy[i][0] - 1].Children.Add(v[xy[i][1] - 1]);
            v[xy[i][1] - 1].Children.Add(v[xy[i][0] - 1]);
        }
        ArrayList t = new ArrayList();
        for (int i = 0; i < n; i++)
        {
            if (!v[i].Visited)
            {
                t.Add(DepthFirstSearch(v[i]));
                s = new ArrayList();
            }
        }
        int ans = 0;
        for (int i = 0; i < t.Count; i++)
        {
            int[] nums = (int[])((ArrayList)t[i]).ToArray(typeof(int));
            int[] nums2 = new int[nums.Length];
            for (int j = 0; j < nums.Length; j++)
                nums2[j] = p[nums[j] - 1];
            Array.Sort(nums);
            Array.Sort(nums2);
            int a = 0, b = 0;
            for (; ; )
            {
                if (nums[a] == nums2[b])
                {
                    ans++;
                    a++;
                    b++;
                }
                else if (nums[a] > nums2[b])
                    b++;
                else
                    a++;
                if (a == nums.Length || b == nums.Length)
                    break;
            }
        }
        Console.WriteLine(ans);
    }
}
class Node //ノード
{
    public bool Visited { get; set; }
    public ArrayList Children = new ArrayList();
    public int x;
    public Node(int x) { this.x = x; }
}

Measured memory_bytes: 47156
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v:Vec<Vec<char>> = Vec::new();
	for i in iter {
		v.push(i.chars().collect::<Vec<char>>());
	}
	let a = v[0].clone();
	let b = v[1].clone();
	let c = v[2].clone();
	if a[a.len() - 1] == b[0] && b[b.len() - 1] == c[0] {
		println!("YES");
	}else{
		println!("NO");
	}
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  string s, t; std::cin >> s >> t;
  int ssz = s.size(), tsz = t.size();
  int pos = -1;
  rep(i, ssz-tsz+1) {
    string str(s, i, tsz);
    bool ok = true;
    rep(j, tsz) {
      if (str[j] != t[j] && str[j] != '?')
        ok = false;
    }
    if (ok) pos = i;
  }
  if (pos == -1)
    std::cout << "UNRESTORABLE" << "\n";
  else {
    rep(i, tsz) s[i+pos] = t[i];
    rep(i, ssz) if (s[i] == '?') s[i] = 'a';
    std::cout << s << "\n";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vi64 = vector<int64_t>;
using vvi64 = vector<vi64>;
#define rep(i, n) for (int64_t i = 0; i < (n); ++i)
#define repe(i, n) for (int64_t i = 0; i <= (n); ++i)
#define reps(i, s, n) for (int64_t i = (s); i < (n); ++i)
#define repse(i, s, n) for (int64_t i = (s); i <= (n); ++i)
#define repr(i, n) for (int64_t i = (n); i >= 0; --i)
#define all(xs) (xs).begin(), (xs).end()
const int64_t inf = (int64_t)1e18;
const int64_t mod = (int64_t)1e9 + 7;


int N, M;
vvi ss;
vi ps;

int solve(int i, vector<bool> lights) {
  if (i == N) {
    int res = 0;
    rep (j, M) {
      int cnt = 0;
      rep (k, ss[j].size()) {
        cnt += lights[ss[j][k]] ? 1 : 0;
      }
      if (cnt % 2 == ps[j]) res++;
    }
    return res == M ? 1 : 0;
  }

  int res = 0;
  res += solve(i + 1, lights);
  lights[i] = true;
  res += solve(i + 1, lights);
  return res;
}

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

  cin >> N >> M;
  ss.assign(M, vi());
  rep (i, M) {
    int k; cin >> k;
    rep (j, k) {
      int s; cin >> s; s--;
      ss[i].push_back(s);
    }
  }
  ps.assign(M, 0);
  rep (i, M) cin >> ps[i];

  cout << solve(0, vector<bool>(N, false)) << endl;

  return 0;
}

Measured memory_bytes: 256
/*input
3
1
4
3
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb emplace_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=200005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int arr[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	set<int> s;
	map<int,int> mp;
	REP(i,n){
		cin>>arr[i];
		s.insert(arr[i]);
		mp[arr[i]]++;
	}
	int mx1=*prev(s.end());
	int mx2=*prev(prev(s.end()));
	REP(i,n){
		if(arr[i]==mx1 and mp[mx1]==1) cout<<mx2;
		else cout<<mx1;
		cout<<'\n';
	}
}

Measured memory_bytes: 13440
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1005;

int main()
{
    int tem;
    int a, b;
    a = b = 0;
    int t = 3;
    while(t--)
    {
        cin >> tem;
        if(tem == 5) a++;
        if(tem == 7) b++;
    }
    if(a == 2 && b == 1)
        puts("YES");
    else
        puts("NO");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll q,a,b,c;
    cin>>q;
    fr(i,q){
        cin>>a>>b;
        if(b>a) swap(a,b);
        if(a==b) cout<<2*a-2<<endl;
        else cout<<(int)ceil(2*sqrt(a*b))-3<<endl;
    }
}

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


int main() {
    ll n;
    cin >> n;
    ll five_count = 0;
    if(n%2 == 0){
        ll t = 10;
        while(t <= n){
            five_count += n/t;
            t *= 5;
        }
    }
    cout <<five_count << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>

//エイリアス
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int N;
    io.read(N);
    auto H = io.read_vec<int>(N);
    string ans = "Yes";
    for(int i = N - 1; i > 0; i--){
        if(H[i - 1] > H[i]){
            if(H[i - 1] - H[i] == 1){
                H[i - 1]--;
            }
            else{
                ans = "No";
                break;
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll maxn = 1e5 + 10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//head
int main(){
	set<string> st;
	ll t;
	scanf("%lld", &t);
		getchar();
	while(t--){
		string str;
		getline(cin, str);
		st.insert(str);
	}
	printf("%lld", st.size());
	return 0;
}


Measured memory_bytes: 19400
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[12][12];
char ret[100];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
char dir[10]="DRUL";
int rem;
int H,W;
int dfs(int a,int b,int c,int d){
	if(c==rem)return 1;
	char ch=str[a][b];
	str[a][b]='.';
	for(int i=0;i<4;i++){
		if((i^2)==d)continue;
		int row=a;int col=b;
		while(1){
			row+=dx[i];
			col+=dy[i];
			if(row<0||col<0||row>=H||col>=W)break;
			if(str[row][col]=='o'){
				ret[c]=dir[i];
				int tmp=dfs(row,col,c+1,i);
				if(tmp){
					str[a][b]=ch;return 1;
				}
				break;
			}
		}
	}
	str[a][b]=ch;
	return 0;
}
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	H=a;W=b;
	for(int i=0;i<a;i++)scanf("%s",str[i]);
	int sx,sy;
	int dir;
	for(int i=0;i<a;i++)for(int j=0;j<b;j++){
		if(str[i][j]=='o')rem++;
		else if(str[i][j]!='.'){
			sx=i;
			sy=j;
			if(str[i][j]=='U')dir=2;
			if(str[i][j]=='D')dir=0;
			if(str[i][j]=='L')dir=3;
			if(str[i][j]=='R')dir=1;
		}
	}
	dfs(sx,sy,0,dir);
	printf("%s\n",ret);
}

Measured memory_bytes: 1016
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<iomanip>
#include<cstring>
#define reg register
#define EN std::puts("")
#define LL long long
inline LL read(){
	register LL x=0;register int y=1;
	register char c=std::getchar();
	while(c<'0'||c>'9'){if(c=='-') y=0;c=std::getchar();}
	while(c>='0'&&c<='9'){x=x*10+(c^48);c=std::getchar();}
	return y?x:-x;
}
int main(){
	LL n=read(),k=read();
	n%=k;
	std::printf("%lld",std::min(n,k-n));
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;
int main() {
	long long N, M;
	cin >> N >> M;
	int A[100010];
	priority_queue<int> b;
	for (long long i = 0; i < N; i++) {
		cin >> A[i];
		b.push(A[i]);
	}

	while(M > 0){
		int a = b.top();
		b.pop();
		a /= 2;
		b.push(a);
		M--;
	}

	long long ans = 0;
	for (long long i = 0; i < N; i++) {
		ans += b.top();
		b.pop();
	}
	cout << ans;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF ll(1e18)+1
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  ll N,K;
  cin>>N>>K;
  vector<ll>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  sort(rng(A));
  vector<ll>M,P;
  ll mm=0,p=0,z=0;
  for(int i=0;i<N;i++){
    if(A[i]>0)P.push_back(A[i]),p++;
    else if(A[i]<0)M.push_back(A[i]),mm++;
    else z++;
  }
  //負の総数
  ll msum=mm*p;
  //0の総数
  ll zsum=z*mm+z*p+z*(z-1)/2;
  //正の総数
  ll psum=p*(p-1)/2+mm*(mm-1)/2;

  //cout<<msum<<" "<<zsum<<" "<<psum<<endl;
  
  //解が正のとき
  if(msum+zsum<K){
    K-=msum+zsum;
    for(int i=0;i<M.size();i++)M[i]*=-1;
    sort(rng(M));
    ll l=-1,r=INF,m;
    //l(<K)
    while(r-l>1){
      m=(l+r)/2;
      ll res=0;
      for(int i=0;i<P.size();i++){
        int l1=i,r1=P.size(),m1;
        //l1(<m)
        while(r1-l1>1){
          m1=(r1+l1)/2;
          if(P[m1]*P[i]<m)l1=m1;
          else r1=m1;
        }
        res+=r1-(i+1);
      }
      for(int i=0;i<M.size();i++){
        int l1=i,r1=M.size(),m1;
        //l1(<m)
        while(r1-l1>1){
          m1=(r1+l1)/2;
          if(M[m1]*M[i]<m)l1=m1;
          else r1=m1;
        }
        res+=r1-(i+1);
      }
      if(res<K)l=m;
      else r=m;
    }
    cout<<l<<endl;
  }
  //解が0のとき
  else if(msum<K){
    cout<<0<<endl;
  }
  //解が負のとき
  else{
    ll l=-INF,r=1,m;
    //l(<K)
    while(r-l>1){
      m=(l+r)/2;
      ll res=0;
      for(int i=0;i<P.size();i++){
        int l1=-1,r1=M.size(),m1;
        //l1(<m)
        while(r1-l1>1){
          m1=(r1+l1)/2;
          if(P[i]*M[m1]<m)l1=m1;
          else r1=m1;
        }
        res+=r1;
      }
      if(res<K)l=m;
      else r=m;
    }
    cout<<l<<endl;
  }
  return 0;
}


Measured memory_bytes: 4084
#逆元

from fractions import gcd

n=int(input())

a=list(map(int,input().split()))
mod=10**9+7

b=0
for i in a:
    b+=pow(i,mod-2,mod)


L=a[0]
def lcm(x,y):
    return x//gcd(x,y)*y

for i in a:
    L=lcm(L,i)


print(L*b%mod)

Measured memory_bytes: 6200
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define int long long int
#define double long double
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value)
#define ff first          // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}, dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t) \
    int(t);          \
    cin >> (t);      \
    while ((t)--)
signed main()
{

    int n, k, ans = 0;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    reverse(h.begin(), h.end());
    for (int i = k; i < n; i++)
    {
        ans += h[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {
	
	static int h;
	static int w;
	
	static char [][]grid;
	
	static int [][]left;
	static int [][]right;
	static int [][]up;
	static int [][]down;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		 h = Integer.parseInt(sc.next());
		 w = Integer.parseInt(sc.next());
		
		grid = new char [h][w];
		
		left = new int [h][w];
		right = new int [h][w];
		up = new int [h][w];
		down = new int [h][w];
		
		for(int i = 0 ;i < h ;i++) {
			String s = sc.next();
			for(int j = 0 ; j < w ;j++) {
				grid[i][j] = s.charAt(j);
			}
		}
		
		lcnt();
		rcnt();
		ucnt();
		dcnt();
		
		int ans = 0;
		
		for(int i = 0 ;i < h ;i++) {
			for(int j = 0; j < w ;j++) {
				if(grid[i][j] == '#') {
					continue;
				}
				int temp = left[i][j] + right[i][j] + up[i][j] + down[i][j] -3;
				
				ans = Math.max(ans,temp);
			}
		}
		
		System.out.println(ans);
	

	}
	
	static void lcnt() {
		int temp = 0;
		for(int i = 0 ;i < h ;i++) {
			temp = 0;
			for(int j = 0 ;j < w ;j++) {
				if(grid[i][j] == '#') {
					temp = 0;
				}
				else {
					temp++;
					left[i][j] = temp;
				}
			}
		}
		
	}
	static void rcnt() {
		int temp = 0;
		for(int i = 0 ;i < h ;i++) {
			temp = 0;
			for(int j = w-1 ;j >= 0 ;j--) {
				if(grid[i][j] == '#') {
					temp = 0;
				}
				else {
					temp++;
					right[i][j] = temp;
				}
			}
		}
	}
	static void ucnt() {
		int temp = 0;
		for(int j = 0 ; j < w ; j++) {
			temp = 0;
			for(int i = 0 ;i < h ;i++) {
				if(grid[i][j] == '#') {
					temp = 0;
				}
				else {
					temp++;
					up[i][j] = temp;
				}
			}
		}
		
	}
	static void dcnt() {
		int temp = 0;
		for(int j = 0 ; j < w ; j++) {
			temp = 0;
			for(int i = h-1 ; i >= 0 ;i--) {
				if(grid[i][j] == '#') {
					temp = 0;
				}
				else {
					temp++;
					down[i][j] = temp;
				}
			}
		}
		
	}

}


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

int main() {
  int a,b;
  cin>>a>>b;
  vector<string> vec(a);
  for(int i=0;i<a;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for(int i=0;i<a;i++){
    cout<<vec.at(i);
  }
}

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

int main()
{
	int s[7];
	char x[100];
	int a;
	int i = 0;
	for (int i = 1; i <= 6; i++)
	{
		cin >> s[i];
	}
	cin >> x;
	while (x[i] != 0)
	{
		if (x[i] == 'N')
		{
			a = s[5];
			s[5] = s[1];
			s[1] = s[2];
			s[2] = s[6];
			s[6] = a;
		}
		if (x[i] == 'S')
		{
			a = s[2];
			s[2] = s[1];
			s[1] = s[5];
			s[5] = s[6];
			s[6] = a;
		}
		if (x[i] == 'W')
		{
			a = s[4];
			s[4] = s[1];
			s[1] = s[3];
			s[3] = s[6];
			s[6] = a;
		}
		if (x[i] == 'E')
		{
			a = s[3];
			s[3] = s[1];
			s[1] = s[4];
			s[4] = s[6];
			s[6] = a;
		}
		i++;
	}
	cout << s[1] << endl;
	return 0;
}


Measured memory_bytes: 3072
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}
#define int ll
signed main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	string s;
	cin>>n>>s;
	int r=count(ALL(s),'R');
	int g=count(ALL(s),'G');
	int b=count(ALL(s),'B');
	ll ans=r*g*b;
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<i;j++)
		{
			int k=2*i-j;
			if(k<n&&s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k])
				ans--;				
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 4000000000; //4*10^9;
constexpr auto MOD = 1000000007; //10^9+7;

int main()
{
	ll a, b, k;
	cin >> a >> b >> k;

	if (a >= k)cout << a - k << " " << b;
	else if(a+b>=k) cout << 0 << " " << b-k+a ;
	else cout << 0 << " " << 0;

}

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

vector<int> adj[2001];
int visited[2001];
int ans[2000];

void bfs(int s)
{
	memset(visited, 0, sizeof(visited));
	queue<int> q;
	q.push(s);
	visited[s]++;
	int reach = 1;
	while(!q.empty())
	{
		int qsz = q.size();
		for(int i=0; i<qsz; i++)
		{
			int curr = q.front();
			q.pop();
			for(const int &next: adj[curr])
			{
				if(!visited[next])
				{
					q.push(next);
					visited[next]++;
					if(s < next)
						ans[reach]++;
				}
			}
		}
		reach++;
	}
}

int main(void)
{
	cin.tie(0);	ios_base::sync_with_stdio(0);
	int N, x, y;	cin >> N >> x >> y;
	for(int i=1; i<=N; i++)
	{
		if(i==1)
			adj[i].push_back(i+1);
		else if(i==N)
			adj[i].push_back(i-1);
		else
		{
			adj[i].push_back(i+1);
			adj[i].push_back(i-1);
		}
	}
	adj[x].push_back(y);
	adj[y].push_back(x);

	for(int i=1; i<=N; i++)
		bfs(i);
	for(int i=1; i<=N-1; i++)
		cout << ans[i] << "\n";
  return 0;
}

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

string S;

int main() {

    cin >> S;

    bool beg = (S.length() % 2);
    bool res = (S[0] == S[S.length() - 1]);

    if (beg ^ res) {
        cout << "First";
    } else {
        cout << "Second";
    }

    return 0;
}

Measured memory_bytes: 512
/*
Problem : https://atcoder.jp/contests/abc145/tasks/abc145_f
Algorithm : dp
Status :
*/
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const ll INF = 1e18;
const int MAXN = 305;

int n,k;
ll a[MAXN],f[MAXN][MAXN];

int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
	scanf("%d%d",&n,&k);
	memset(f,0x3f,sizeof(f));
	for(int i = 1;i <= n;i++){
		scanf("%lld",&a[i]);
		f[i][0] = 0;
		f[i][1] = a[i];
	}
	for(int j = 2;j <= n - k;j++){
		for(int i = j;i <= n;i++){
			for(int l = 1;l <= i - 1;l++)
			    f[i][j] = min(f[i][j],f[l][j - 1] + max(0ll,a[i] - a[l]));
		}
	}
	ll ans = INF;
	for(int i = 1;i <= n;i++)
	    ans = min(ans,f[i][n - k]);
	printf("%lld\n",ans);
	return 0;
}


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



int main(){
  int64_t N,M;
  cin>>N>>M;
  
  if(N*2>=M){
    cout<<M/2<<endl;
  }
  else{
    int64_t a=M-N*2;
    int64_t k=a/2;
    int64_t l=k/2;
    cout<<N+l<<endl;
  }
}

Measured memory_bytes: 3600
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

constexpr ll INF = 1e16;

#define rep(i, N) for(ll i=0; i<N; ++i)

ll max(ll a, ll b) {return a < b ? b : a; }
ll min(ll a, ll b) {return a > b ? b : a; }
double maxf(double a, double b) { return a < b ? b : a; }

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

  cout<<r*r<<endl;

  return 0;
}

Measured memory_bytes: 256