akhauriyash/Code-Regression huggingface dataset:
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
const int nax=57;
const int dlu=10;
ll mod;

int n=50;

ll pot[nax][nax];

ll wyn;

int jeszkol[nax][nax];

void ff()
{
	fflush(stdout);
}

int pyt(int a, int b, int x, int y)
{
	printf("? %d %d %d %d\n", a, x, b, y);
	ff();
	int v;
	scanf("%d", &v);
	return v;
}

int los(int a, int b)
{
	return (rand()%(b-a+1))+a;
}

void szuk(int a, int b, int x, int y, int w)
{
	if (!w)
		return;
	if ((a/dlu)==(b/dlu) && !jeszkol[x][a/dlu])
	{
		szuk(a, b, x+1, y, w);
		return;
	}
	if ((a/dlu)==(b/dlu) && !jeszkol[y][a/dlu])
	{
		szuk(a, b, x, y-1, w);
		return;
	}
	if (w==(b-a+1)*(y-x+1))
	{
		for (int i=a; i<=b; i++)
		{
			for (int j=x; j<=y; j++)
			{
				wyn+=pot[i][j];
				jeszkol[j][i/dlu]--;
			}
		}
		return;
	}
	//~ if (x==y || (a!=b && (rand()&1)))
	if (a!=b)
	{
		int s=(a+b)>>1;
		//~ int s=los(a, b-1);
		int p=pyt(a, s, x, y);
		if (rand()&1)
		{
			szuk(a, s, x, y, p);
			szuk(s+1, b, x, y, w-p);
		}
		else
		{
			szuk(s+1, b, x, y, w-p);
			szuk(a, s, x, y, p);
		}
	}
	else
	{
		int s=(x+y)>>1;
		//~ int s=los(x, y-1);
		int p=pyt(a, b, x, s);
		if (rand()&1)
		{
			szuk(a, b, x, s, p);
			szuk(a, b, s+1, y, w-p);
		}
		else
		{
			szuk(a, b, s+1, y, w-p);
			szuk(a, b, x, s, p);
		}
	}
}

int main()
{
	int szit;
	scanf("%d%d%d%lld", &szit, &szit, &szit, &mod);
	ll trz=1;
	for (int i=0; i<n; i++)
	{
		for (int j=0; j<n; j++)
		{
			pot[i][j]=trz;
			trz=(trz*2)%mod;
		}
	}
	for (int i=0; i<n; i++)
		for (int j=0; j<nax; j++)
			if (dlu*j<n)
				jeszkol[i][j]=pyt(dlu*j, min(dlu*j+dlu-1, n-1), i, i);
	szuk(0, n-1, 0, n-1, 250);
	printf("! %lld\n", wyn%mod);
	ff();
	return 0;
}


Measured memory_bytes: 720
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
        int h, w, m;
        scanf("%d %d %d", &h, &w, &m);

        std::map<P, int> mp;
        ll rows[h] = {}, cols[w] = {};
        REP(i, 0, m){
                int x, y;
                scanf("%d %d", &x, &y);
                x--, y--;
                mp[P(x, y)]++;
                rows[x]++;
                cols[y]++;
        }

        ll rmax = 0, cmax = 0;
        REP(i, 0, h) rmax = std::max(rmax, rows[i]);
        REP(i, 0, w) cmax = std::max(cmax, cols[i]);

        V rm, cm;
        REP(i, 0, h) if(rows[i]==rmax) rm.push_back(i);
        REP(i, 0, w) if(cols[i]==cmax) cm.push_back(i);

        for(ll i: rm){
                for(ll j: cm){
                        if(mp[P(i, j)]) continue;
                        printf("%ld\n", rmax+cmax);
                        return 0;
                }
        }
        printf("%ld\n", rmax+cmax-1);
        return 0;
}

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

constexpr int mod = 1e9 + 7;

struct segment {
    int l, x;
    segment(int a, int b) : l(a), x(b) {}
};

int n, m;
vector<segment> seg[301];
int dp[301][301][301];

bool check(int r, int g, int b) {
    const int rp = max({r, g, b});
    for(auto const& s : seg[rp]) {
        const int cnt = (s.l <= r) + (s.l <= g) + (s.l <= b);
        if(cnt != s.x) return false;
    }
    return true;
}

int solve(int r, int g, int b) {
    if(g >= b) swap(g, b);
    if(r >= g) swap(r, g);
    if(g >= b) swap(g, b);

    int& res = dp[r][g][b];
    if(res != -1) return dp[r][g][b];
    if(!check(r, g, b)) return dp[r][g][b] = 0;
    if(b == n) return dp[r][g][b] = 1;
    res = solve(b + 1, g, b);
    (res += solve(r, b + 1, b)) %= mod;
    (res += solve(r, g, b + 1)) %= mod;
    return res;
}

int main() {
    memset(dp, -1, sizeof(dp));

    cin >> n >> m;
    for(int i = 0; i < m; ++i) {
        int l, r, x; cin >> l >> r >> x;
        seg[r].emplace_back(l, x);
    }

    cout << solve(0, 0, 0) << endl;
}


Measured memory_bytes: 106880
n = int(input())
a = [int(i) for i in input().split()]
for i in range (n):
    if a[i]%2==0:
        if not(a[i] % 3 == 0 or a[i] % 5 == 0):
            print("DENIED")
            break
else:
    print("APPROVED")

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
	int key;
	Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
	Node *cur = nil->next;
	while (cur != nil && cur ->key != key ) {
		cur = cur->next;
	}
	return cur;
}

void init() {
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList() {
	Node *cur = nil->next;
	int isf = 0;
	while ( 1 ) {
		if( cur == nil ) break;
		if( isf++ > 0 ) printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}

void deleteNode(Node *t) {
	if (t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst() {
	deleteNode(nil->next);
}

void deleteLast() {
	deleteNode(nil->prev);
}

void deleteKey(int key) {
	deleteNode(listSearch(key));
}

void insert(int key) {
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}



int main(){
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for (i=0; i < n; i++) {
		scanf("%s%d", com, &key);
		if( com[0] == 'i' ) {insert(key); np++; size++;}
		else if (com[0] == 'd') {
			if (strlen(com) > 6) {
				if (com[6] == 'F') deleteFirst();
				else if (com[6] == 'L') deleteLast();
			} else {
				deleteKey(key); nd++;
			}
			size--;
		}
	}
	printList();

	return 0;
}



Measured memory_bytes: 33836
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  n += 2;
  vector<ii> seg(n);
  vector<double> v(n);
  int sum = 0;
  vector<double> A;
  for (int i = 1; i < n - 1; ++i) {
    int x;
    scanf("%d", &x);
    seg[i].first = sum;
    sum += x;
    seg[i].second = sum;
    A.push_back(seg[i].first);
    A.push_back(seg[i].second);
  }
  for (int i = 1; i < n - 1; ++i) {
    scanf("%lf", &v[i]);
  }
  v[0] = v[n - 1] = 0;
  seg[0] = {-1, 0};
  seg[n - 1] = {sum, sum + 1};
  for (int i = 1; i < n - 1; ++i) {
    for (int j = 0; j < i; ++j) {
      if (v[j] >= v[i]) continue;
      int cur = v[i] - v[j] + seg[j].second;
      if (cur > seg[i].first && cur < seg[i].second) {
        A.push_back(cur);
      }
    }
    for (int j = i + 1; j < n; ++j) {
      if (v[j] >= v[i]) continue;
      int cur = seg[j].first - (v[i] - v[j]);
      if (cur > seg[i].first && cur < seg[i].second) {
        A.push_back(cur);
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      double cur = (seg[j].first + v[j] + seg[i].second - v[i]) * 0.5;
      if (cur > seg[i].first && cur < seg[j].second) {
        A.push_back(cur);
      }
    }
  }
  sort(A.begin(), A.end());
  A.erase(unique(A.begin(), A.end()), A.end());
  double ret = 0.0;
  for (int i = 1; i < A.size(); ++i) {
    double L = A[i - 1], R = A[i];
    double x = min(L, sum - L), y = min(R, sum - R);
    for (int j = 0; j < n; ++j) {
      if (L >= seg[j].first && R <= seg[j].second) {
        x = min(x, v[j]);
        y = min(y, v[j]);
      } else if (L >= seg[j].second) {
        x = min(x, v[j] + L - seg[j].second);
        y = min(y, v[j] + R - seg[j].second);
      } else {
        x = min(x, v[j] + seg[j].first - L);
        y = min(y, v[j] + seg[j].first - R);
      }
    }
    // trace(L, R, x, y);
    ret += 0.5 * (R - L) * (x + y);
  }
  printf("%.10f\n", ret);
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,l,r,s=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>l>>r;
		s+=r-l+1;
	}
	cout<<s<<endl;
	return 0;	
}

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define pb push_back
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1e5+5;
int a[N],q[N],c,k,h,t,n,res;
inline int min(R int x,R int y){return x<y?x:y;}
int main(){
	scanf("%d%d%d",&n,&c,&k);
	fp(i,1,n)scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	h=1,t=0;
	fp(i,1,n){
		while(h<=t&&a[q[h]]<a[i]-k)++res,h=min(t+1,h+c);
		q[++t]=i;
	}
	while(h<=t)++res,h=min(t+1,h+c);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 1024
//no convex hull ans=0.
//S:convex polygon counted:2^(n-|S|)
//number of subsets.
//U:inside S(\S) 
//S union U: convex hull is S
//number of pair:(S,U),where the convex hull of S union U is S
//S union U corresponds to a unique S,thus a unique U
//bijection (S,U)<->S union U
//for each subset of set,it is valid if the convex hull exists.(has postive area)
//the only case is colinear!
//ans=2^n-1-C(n,1)-C(n,2)-sigma(2^ai-ai-C(ai,2)-1)(ai>=3)
#include<cstdio>
#include<algorithm>
using namespace std;
bool vis[210][210];
struct kk
{
	int id;
	double num;
}c[210];
int n,i,j,k,l,x[210],y[210];
long long pow2[210],ans;
const long long P=998244353;
bool cmp(kk A,kk B)
{
	return A.num<B.num;
}
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d%d",&x[i],&y[i]);
	pow2[0]=1;
	for (i=1;i<=n;i++) pow2[i]=pow2[i-1]*2%P;
	ans=pow2[n];
	ans-=1+n+n*(n-1)/2;
	ans=(ans%P+P)%P;
	for (i=1;i<n;i++)
	{
		int tot=0;
		for (j=i+1;j<=n;j++)
		{
			if (vis[i][j]) continue;
			int dx=x[j]-x[i],dy=y[j]-y[i];
			if (dx==0) 
			{
				c[++tot].id=j;
				c[tot].num=100000;
			}
			else
			{
				c[++tot].id=j;
				c[tot].num=(double)dy/(double)dx;
			}
		}
		if (tot==0) continue;
		sort(c+1,c+tot+1,cmp);
		c[0].num=c[1].num-1;
		long long now=0;
		for (int j=1;j<=tot;j++)
		{
			if (c[j].num-c[j-1].num<1e-8) now++;
			else
			{
				for (k=j-now;k<j;k++)
				  for (l=k+1;l<j;l++)
				  {
				  	vis[c[k].id][c[l].id]=1;
				  	vis[c[l].id][c[k].id]=1;
				  }
				now++;//itself;
				if (now>=3) ans-=pow2[now]-now-now*(now-1)/2-1;
				now=1;
				ans=(ans%P+P)%P;
			}
		}
		for (k=tot-now+1;k<=tot;k++)
			for (l=k+1;l<=tot;l++)
				{
				  	vis[c[k].id][c[l].id]=1;
				  	vis[c[l].id][c[k].id]=1;
				}
		now++;
		if (now>=3) ans-=pow2[now]-now-now*(now-1)/2-1;
		ans=(ans%P+P)%P;
	}
	printf("%lld\n",ans);
}
//O(n^2 logn)

Measured memory_bytes: 256
import math

n = int(input())

ans = [0] * n

r = math.floor(math.sqrt(n))
for x in range(1,r+1):
  for y in range(x,r+1):
    for z in range(y,r+1):
      sum = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if sum <= n:
        if x == y and y == z:
          ans[sum-1] += 1
        elif x == y or y == z or z == x:
          ans[sum-1] += 3
        else:
          ans[sum-1] += 6

for p in ans:
  print(p)

Measured memory_bytes: 69568
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var array = cin.ReadIntArray(N);
            int resultInt = 0;
            int beforeInt = 0;
            int baseIndex = 0;

            Array.Sort(array);
            Console.WriteLine(Math.Abs(array[0] - array[N - 1]));
            //do
            //{
            //    for (int i = 0; i < N; i++)
            //    {
            //        if (baseIndex == i) { continue; }
            //        beforeInt = array[baseIndex] - array[i];
            //        beforeInt = Math.Abs(beforeInt);
            //        if (resultInt == 0 || beforeInt > resultInt)
            //        {
            //            resultInt = beforeInt;
            //        }
            //    }
            //    baseIndex++;
            //}
            //while (baseIndex < N);
            //Console.WriteLine(resultInt);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

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

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; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;

int main(){
    string s;
    int a;
    cin >> a >> s;

    if(a >= 3200){
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }

}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

void solve(long long N, long long M, std::vector<long long> H,
           std::vector<long long> A, std::vector<long long> B) {
  vector<pair<ll, ll>> path(M);
  REP(i, M) { path[i] = {min(A[i] - 1, B[i] - 1), max(A[i] - 1, B[i] - 1)}; }
  sort(ALL(path));
  vector<bool> good(N, true);
  REP(i, M) {
    ll a = path[i].first;
    ll b = path[i].second;
    if (H[a] <= H[b]) {
      good[a] = false;
    }
    if (H[a] >= H[b]) {
      good[b] = false;
    }
  }
  int count = 0;
  REP(i, N) {
    if (good[i]) {
      count++;
    }
  }
  cout << count << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> H(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &H[i]);
  }
  std::vector<long long> A(M);
  std::vector<long long> B(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
  }
  solve(N, M, std::move(H), std::move(A), std::move(B));
  return 0;
}


Measured memory_bytes: 6704
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  const int inf = 1000000000;
  int h, n;
  cin >> h >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a.at(i) >> b.at(i);
  vector<int> dp(h + 1, inf);
  dp.at(h) = 0;
  for (int i = 0; i < n; i++) {
    for (int j = h; j >= 0; j--) {
      int k = min(j + a.at(i), h);
      dp.at(j) = min(dp.at(j), dp.at(k) + b.at(i));
    }
  }
  cout << dp.at(0) << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int dig = n%10;
  if(dig==3)
    cout<<"bon";
  else if(dig==0 || dig==1 || dig==6 || dig==8)
    cout<<"pon";
  else
    cout<<"hon";
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
    int v[3][3];
    cin>>v[0][0]>>v[0][1]>>v[1][1];
    range(i,0,101){
        int t=v[0][0]+v[0][1]+i;
        v[0][2]=i;
        v[2][2]=t-v[0][0]-v[1][1];
        v[1][2]=t-v[0][2]-v[2][2];
        v[2][1]=t-v[0][1]-v[1][1];
        v[1][0]=t-v[1][1]-v[1][2];
        v[2][0]=t-v[2][1]-v[2][2];
        bool ans=(t==v[2][0]+v[1][1]+v[0][2] && t==v[0][0]+v[1][0]+v[2][0]);
        if(ans){
            rep(j,3)rep(k,3){cout<<v[j][k];if(k==2)cout<<endl;else cout<<" ";}
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, K;
        cin >> N >> K;
        vll H(N);
        rep(i, 0, N) cin >> H[i];

        sort(all(H));

        ll ans = 0;
        rep(i, 0, N-K) {
                ans += H[i];
        }
        cout << ans << endl;
}


Measured memory_bytes: 4760
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cmath>
using namespace std;
const int maxn=2000+10;
int a[maxn],max_start[maxn],max_over[maxn];
int z,w,n;
int main()
{
    int i,j;
    scanf("%d%d%d",&n,&z,&w);
    for(i=1; i<=n; i++)
        scanf("%d",&a[i]);
	if(n!=1)
    printf("%d\n",max(abs(a[n]-w),abs(a[n-1]-a[n])));
    else
	printf("%d\n",abs(a[1]-w));
    return  0;
}


Measured memory_bytes: 256
//「全て0ならa_i点」と言い換えると見通しが良い。（重複カウントに気を使わなくて良いため）
//1の場所を決めていく。貰うDPを考えると見通しが良い。便宜上、0文字目, N+1文字目に1を置くことにすると見通しが良い。
//a[i][j] = dp[j] + cost(j, i)をメモリ節約で持つ形式。(for i -> for j)
//a[i][j] -> a[i+1][j]の更新は, r = iの区間[l, r]について処理する感じ。一様加算クエリになる。
//dp[i] = min(a[i][0],a[i][1],…,a[i][i-1])なので、これは区間minクエリになる。
//よって、a([i])[j]をセグメント木（StarrySky木）で持てば良い。

#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

const int DEPTH = 18;
const int INF = 1e+15;
struct StarrySky {
	int addVal[1 << (DEPTH + 1)];
	int minVal[1 << (DEPTH + 1)];
	
	StarrySky() {
		int i;
		for (i = 0; i < (1 << (DEPTH + 1)); i++) {
			addVal[i] = 0;
			minVal[i] = 0;
		}
	}
	
	//[l, r)
	void add(int l, int r, int v, int a = 0, int b = (1 << DEPTH), int id = 0) {
		if (a >= r || b <= l) return;
		if (l <= a && b <= r) { addVal[id] += v; minVal[id] += v; return; }
		add(l, r, v, a, a + (b - a) / 2, id * 2 + 1);
		add(l, r, v, a + (b - a) / 2, b, id * 2 + 2);
		minVal[id] = min(minVal[id * 2 + 1], minVal[id * 2 + 2]) + addVal[id];
	}
	
	//[l, r)
	int getMin(int l, int r, int a = 0, int b = (1 << DEPTH), int id = 0) {
		if (a >= r || b <= l) return INF;
		if (l <= a && b <= r) return minVal[id];
		int res1 = getMin(l, r, a, a + (b - a) / 2, id * 2 + 1);
		int res2 = getMin(l, r, a + (b - a) / 2, b, id * 2 + 2);
		return min(res1, res2) + addVal[id];
	}
	
	int get(int pos) {
		pos += (1 << DEPTH) - 1;
		int ret = addVal[pos];
		while (pos > 0) {
			pos = (pos - 1) / 2;
			ret += addVal[pos];
		}
		return ret;
	}
	
	void update(int pos, int x) {
		int res = get(pos);
		add(pos, pos + 1, x - res);
	}
};

int n, m;
vector<int> lefts[200001];	//lefts[i][j] = 「右端 = iになっている区間の左端」, 閉区間で考える
vector<int> scores[200001];
StarrySky dp;

signed main() {
	int i, j;
	int sumA = 0;
	
	cin >> n >> m;
	rep(i, m) {
		int l, r, a;
		cin >> l >> r >> a;
		sumA += a;
		lefts[r].push_back(l);
		scores[r].push_back(a);
	}
	
	//dp[0] = 0;
	REP(i, 1, n + 1) {
		int res = dp.getMin(0, i);
		dp.update(i, res);
		rep(j, lefts[i].size()) {
			int l = lefts[i][j];
			int a = scores[i][j];
			dp.add(0, l, a);
		}
	}
	
	int ans1 = dp.getMin(0, n + 1);
	cout << sumA - ans1 << endl;
	return 0;
}

Measured memory_bytes: 30336
#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define int          long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define pi           pair<int,int>
#define sz(x)       (int)x.size()
#define pq           priority_queue<int>
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define FIO         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}


void solve()
{
     int h,w,m;
     cin>>h>>w>>m;
     set<pi>s;
     map<int,int>m1,m2,c1,c2;
     while(m--)
     {
     	int x,y;
     	cin>>x>>y;
     	m1[x]++;
     	m2[y]++;
     	c1[x]++;
     	c2[y]++;
     	s.in({x,y});


     }

     int sum=0;
     int mi=-1;
      int ax;
      for(auto x:m1)
      {
      	if(x.ss>mi)
      	{
      		ax=x.ff;
      		mi=x.ss;
      	}
      }
      sum=mi;
      for(auto x:s)
      {
      	if(x.ff==ax)
      		{m2[x.ss]--;}
      }
     mi=0;
     for(auto x:m2)
     {
     	mi=max(mi,x.ss);
     }
     sum+=mi;

     int sum1=0;
     mi=0;
     int ay;
     for(auto x:c2)
      {
      	if(x.ss>mi)
      	{
      		ay=x.ff;
      		mi=x.ss;
      	}
      }
     // cout<<ay<<endl;
      sum1=mi;
      for(auto x:s)
      {
      	if(x.ss==ay)
      		{c1[x.ff]--;}
      }
      mi=0;
      for(auto x:c1)
     {
     	mi=max(mi,x.ss);
     }
     sum1+=mi;
     cout<<max(sum1,sum);


}

signed main()
{
        FIO
        
        
        int t=1;
        //cin>>t;
        while(t--)
        solve();
        cerr<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;

        return 0;
}

Measured memory_bytes: 97536
from sys import exit
import math
import collections
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,k = mi()
h = li()
h.sort()
h.reverse()
sum = 0
for i in range(k,n,1):
    sum += h[i]
print(sum)


Measured memory_bytes: 32388
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7

H,W = map(int,input().split())
a = []
for i in range(H):
    a.append(str(input()))

# print(a)
print("#"*(W+2))
for i in range(H):
    print("#"+a[i]+"#")
print("#"*(W+2))


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X1,X2,X3,X4,X5;
  cin >> X1 >> X2 >> X3 >> X4 >> X5;
 
  if(X1 == 0){
  cout << "1" << endl;
  }
  else if(X2 == 0){
    cout << "2" << endl;
  }
  else if(X3 == 0){
        cout << "3" << endl;
  }
  else if(X4 == 0){
        cout << "4" << endl;
  }
  else{
        cout << "5" << endl;
  }
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
double PHI = 1.6180339;
#define endl "\n"    
typedef long long ll;
#define int long long
//#define int unsigned long long

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

    int x;
    cin>>x;
    int val=pow(x,3);
    cout<<val<<endl;
    
}
 

Measured memory_bytes: 512
#include <stdio.h>

int main(){
  int n;
  char s[101] = {};
  int count = 0;
  int max = 0;

  scanf("%d", &n);
  scanf("%s", s);

  for(int i = 0; i < n; i++){
    if(s[i] == 'I') count++;
    if(s[i] == 'D') count--;
    if(count > max) max = count;
  }

  printf("%d", max);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MAXN 3009
string x,y;
int dp[MAXN][MAXN];

int lcs(int i, int j){
    if (dp[i][j] != -1) return dp[i][j];
    if (i == 0 || j == 0)   return dp[i][j] = 0;
    if (x[i - 1] == y[j - 1])   
        return dp[i][j] = 1 + lcs(i - 1, j - 1);
    return dp[i][j] = max (lcs(i-1, j), lcs(i, j-1));
}

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    memset(dp, -1, sizeof dp);
    cin >> x >> y;
    stack<char> res;
    lcs(sz(x), sz(y));
    int i = sz(x), j = sz(y);
    while (i > 0 && j > 0){
        if (x[i - 1] == y[j - 1])
            res.push(x[i - 1]), i--,j--;
        else if (dp[i - 1][j] > dp[i][j-1])
            i--;
        else
            j--;
    }
    while (res.size()){
        cout << res.top();
        res.pop();
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 36096
# 最小公倍数を求める
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
  
a, b, c, d = map(int, input().split())

# cで割り切れるものの数
a_c = a // c if a % c == 0 else a // c + 1
b_c = b // c

ab_c = b_c - a_c + 1

# dで割り切れるものの数
a_d = a // d if a % d == 0 else a // d + 1
b_d = b // d

ab_d = b_d - a_d + 1

# c*dで割り切れるものの数
cd = c * d // gcd(c, d)
a_cd = a // cd if a % cd == 0 else a // cd + 1
b_cd = b // cd

ab_cd = b_cd - a_cd + 1

print(b - a + 1 - ab_c - ab_d + ab_cd)




Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
const int N=3005;
const int MOD=998244353;
int n,X;
long long ksm(long long a,long long b)
{
	long long res=1;
	while(b)
	{
		if(b&1) res=res*a%MOD;
		a=a*a%MOD,b>>=1;
	}
	return res;
}
long long fac[N],inv[N];
void init(int n=3000)
{
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=fac[i-1]*i%MOD;
	inv[n]=ksm(fac[n],MOD-2);
	for(int i=n;i>=1;i--)
		inv[i-1]=inv[i]*i%MOD;
	return;
}
long long C(int n,int m)
{
	if(m>n) return 0;
	return fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}
long long f(int n)
{
	long long res=0;
	if(2*n<X||(2*n-X)%2==1) res++;
	for(int S=0;S<2*n;S++)
	{
		if(S<X)
		{
			if(S>=n) res=(res+C(n,S-n))%MOD;
		}
		else
		{
			if((S-X)%2==0) continue;
			int num=(S-X+1)/2;
			int reb=n-2*num,ret=S-2*num*2;
			if(reb<=0||ret<=0) continue;
			if(ret>=reb&&ret<=2*reb) res=(res+C(reb,ret-reb))%MOD;
		}
	}
	return res;
}
int main()
{
	init();
	scanf("%d%d",&n,&X);
	long long ans=0;
	for(int i=0;i<=n;i++)
		ans=(ans+C(n,i)*f(n-i)%MOD)%MOD;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 3868
#include <iostream>

using namespace std;

const int UNIONFIND_MAX = 1e5 + 1;

long long par[UNIONFIND_MAX];
long long num[UNIONFIND_MAX];

void unionfind_init(int n){
	for (int i = 0; i < n; i++){
		par[i] = i;
		num[i] = 1;
	}
}

// return the root
int unionfind_root(int x){
	if(par[x] == x){
		// x is root
		return x;
	} else {
		// compress the path
		return par[x] = unionfind_root(par[x]);
	}
}

// check two set is the same
bool unionfind_same(int x, int y){
	return unionfind_root(x) == unionfind_root(y);
}

// unite two set
void unionfind_unite(int x, int y){
	x = unionfind_root(x);
	y = unionfind_root(y);
	if(x == y){
		return;
	}
	par[x] = y;
	num[y] += num[x];
	num[x] = num[y];
}

long long unionfind_size(int x){
	return num[unionfind_root(x)];
}

int main(){
	long long N, M;
	cin >> N >> M;
	long long A[M], B[M];
	for (long long i = 0; i < M; i++){
		cin >> A[i] >> B[i];
	}

	unionfind_init(N + 1);

	long long ans[M+1] = {0};
	ans[M] = N * (N - 1) / 2;

	for (long long i = M - 1; i >= 0; i--){
		if (unionfind_same(A[i], B[i])){
			ans[i] = ans[i + 1];
		} else {
			ans[i] = ans[i + 1] - unionfind_size(A[i]) * unionfind_size(B[i]);
			unionfind_unite(A[i], B[i]);
		}
	}

	for (long long i = 1; i <= M; i++){
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 5248
def main():
    N = int(input())
    a = list(map(int,input().split()))
    Alice = 0
    Alice_j = True
    Bob = 0
    Bob_j = False
    a.sort(reverse = True )
    for i in range(N):
        if Alice_j == True:
            Alice += a[i]
            Alice_j = False
            Bob_j = True
        elif Bob_j == True:
            Bob += a[i]
            Bob_j = False
            Alice_j = True
    return Alice - Bob

print(main())


Measured memory_bytes: 9108
#include<stdio.h>
#define NUM 10000

int main(){
  int i,j,n1,n2,count=0,temp;
  int a[NUM];

  scanf("%d",&n1);
  for(i=0;i<n1;i++){
    scanf("%d",&a[i]);
  }


  scanf("%d",&n2);
  for(j=0;j<n2;j++){
    scanf("%d",&temp);
    for(i=0;i<n1;i++){
      if(a[i]==temp){
	count++;
	break;
      }
    }
	
  }

  

  printf("%d\n",count);

return 0;
}



Measured memory_bytes: 2144
#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;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll w[111111];
ll d[111111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll n,k; cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>w[i]>>d[i];
	}
	ll lo = 1; ll hi = ll(4e18);
	ll ans=0;
	while(lo<=hi)
	{
		ll mid=(lo+hi)>>1;
		ll cnt=0;
		for(int i=0;i<n;i++)
		{
			if(w[i]<=mid)
			{
				cnt+=1+(mid-w[i])/d[i];
				cnt=min(cnt,k);
			}
		}
		if(cnt>=k)
		{
			ans=mid;
			hi=mid-1;
		}
		else
		{
			lo=mid+1;
		}
	}
	cout<<ans<<'\n';
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)

using namespace std;
using ll = long long;
using ii = pair<int,int>;

constexpr int MAXN = 5 + 1e5;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int k,a,b,c;
  cin >> a >> b >> c >> k;
  int ans = -1;
  if (k <= a) ans = k;
  else if (k <= a + b) ans = a;
  else ans = a - (k-a-b);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3524
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

bool dp[80][80][159 * 80];

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

    int h, w;
    cin >> h >> w;

    vector< vector<int> > a(h, vector<int>(w));
    rep(i, h){
        rep(j, w){
            cin >> a[i][j];
        }
    }

    vector< vector<int> > v(h, vector<int>(w));
    rep(i, h){
        rep(j, w){
            int b;
            cin >> b;
            v[i][j] = abs(a[i][j] - b);
        }
    }

    dp[0][0][abs(v[0][0])] = true;

    rep(i, h){
        rep(j, w){
            rep(k, 159 * 80){
                if(i + 1 < h){
                    dp[i + 1][j][abs(k + v[i + 1][j])] |= dp[i][j][k];
                    dp[i + 1][j][abs(k - v[i + 1][j])] |= dp[i][j][k];
                }
                if(j + 1 < w){
                    dp[i][j + 1][abs(k + v[i][j + 1])] |= dp[i][j][k];
                    dp[i][j + 1][abs(k - v[i][j + 1])] |= dp[i][j][k];
                }
            }
        }
    }

    int ans = IINF;
    rep(k, 159 * 80){
        if(dp[h - 1][w - 1][k]){
            chmin(ans, k);
        }
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 79872
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#else
#define gc() 1
#define max3(a,b,c) max(a,b,c)
#define min3(a,b,c) min(a,b,c)
#endif

typedef long long lint;

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

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



#define MAXIN 100

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

	string s, t; cin >> s >> t;
	if (s.length() != t.length()) {
		co("No");
		return 0;
	}
	if (s == t) {
		co("Yes");
		return 0;
	}
	string in;
	rep(i, s.length()) {
		in = s.back();
		s.insert(0, in); s.pop_back();
		if (s == t) {
			co("Yes");
			return 0;
		}
	}
	co("No");

	gc();
}

Measured memory_bytes: 256
from collections import defaultdict


def c():
    n, m = map(int, input().split())
    graph = defaultdict(list)
    for i in range(m):
        a, b = map(int, input().split())
        graph[a].append(b)
        graph[b].append(a)
    stack = []
    count = 0

    stack.append((1, set()))

    while stack:
        val, visited = stack.pop()
        visited.add(val)
        if len(visited) == n:
            count += 1
            continue

        for g in graph[val]:
            if g not in visited:
                stack.append((g, set(visited)))

    print(count)


if __name__ == '__main__':
    c()


Measured memory_bytes: 40048
#include <iostream>
using namespace std;
int main(void){
    int N;
    int min;
    int max;
    long sum=0;
    cin>>N;
    
    int A[N];
    for(int i=0;i<N;i++)cin>>A[i];
    
    min=A[0];
    max=A[0];
    
    for(int i=0;i<N;i++){
        sum+=A[i];
        if(min>A[i])min=A[i];
        if(max<A[i])max=A[i];
    }
    
    cout<<min<<" "<<max<<" "<<sum<<"\n";
}



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

int main() {
  string s;
  cin >> s;
  int order = 700;
  
  if(s[0] == 'o') order += 100;
  if(s[1] == 'o') order += 100;
  if(s[2] == 'o') order += 100;
  
  cout << order;
  
  return 0;
}


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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<30)
#define INFLL (1L<<62)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  ll a, b, c;

  cin >> a >> b >> c;

  ll mini = INFLL;

  mini = min(abs(a/2*b*c - (a+1)/2*b*c), mini);
  mini = min(abs(b/2*a*c - (b+1)/2*a*c), mini);
  mini = min(abs(c/2*a*b - (c+1)/2*a*b), mini);

  cout << mini << endl;
  return 0; 
}


Measured memory_bytes: 256
#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 pair<ll, ll> pll;

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

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

static const uint64_t MOD = 1000000007LL;

int main() {
    string s;
    cin >> s;

    int n = s.size();
    vector< vector<uint64_t> > dp(n+1,vector<u_int64_t>(13,0));

    dp[0][0]=1;

    for(int i=0;i<n;i++){
        int c;
        if(s[i]!='?') c = s[i]-'0';
        else c = -1;

        for(int j=0;j<=9;j++){
            if(c!=-1&&c!=j)continue;
            for(int k=0;k<13;k++)dp[i+1][(k*10+j)%13] = (dp[i+1][(k*10+j)%13]+dp[i][k])%MOD;
        }
       
    }

    cout << dp[n][5] << endl;

}



Measured memory_bytes: 13696
N = int(input())
ans = 10**13
for i in range(1,int(N**0.5)+1) :
    if N % i == 0 :
        if i == 1 :
            ans = min(ans, i+(N//i)-2)
        else :
            ans = min(ans, i+(N//i)-2)
print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
const long long int mod=1e9+7;
typedef long long ll;
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
double reabs(double in){
    if(in<0){
        return (-1)*in;
    }else{
        return in;
    }
}

int main(){
    int N;
    cin>>N;
    long long A[N+1],B[N];

    FOR(i,N+1){
        cin>>A[i];
    }
    FOR(i,N){
        cin>>B[i];
    }
    
    long long ans=0;

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

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




Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    loop {
        let n: u32 = sc.next();
        if n == 0 {
            break;
        }

        let mut s1: f64 = 0.;
        let mut s2: f64 = 0.;

        for _ in 0..n {
            let a: f64 = sc.next();
            s1 += a;
            s2 += a.powi(2);
        }

        let n = n as f64;
        let v = (s2 / n) - (s1 / n).powi(2);
        println!("{:.8}", v.sqrt());
    }
}

/* ========== Scanner ========== */

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }

    fn char(&mut self) -> char {
        self.next::<String>().chars().next().unwrap()
    }
}



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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V)                                                           \
    for (auto v : (V))                                                         \
        cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

template <typename T> T gcd(T a, T b) {
    return ((a % b == 0) ? b : gcd(b, a % b));
}

int main() {
    /* code */
    int K;
    cin >> K;
    ll res = 0;
    FOR(a, 1, K + 1) {
        FOR(b, 1, K + 1) {
            FOR(c, 1, K + 1) { res += gcd(gcd(a, b), c); }
        }
    }
    cout << res << endl;
    return 0;
}

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

typedef long long ll;

int main(){
  ll n;
  cin>>n;
  vector<vector<ll>> d = vector<vector<ll>>(n, vector<ll>(n,0));
  for(ll i=0;i<n;++i){
    for(ll j=0;j<n;++j){
      cin>>d[i][j];
    }
  }
  for(ll k=0;k<n;++k){
    for(ll i=0;i<n;++i){
      for(ll j=0;j<n;++j){
        if (d[i][j]>d[i][k]+d[k][j]){
          cout<<-1<<endl;
          return 0;
        }
      }
    }
  }
  ll res = 0;
  for(ll i=0;i<n;++i){
    for(ll j=i+1;j<n;++j){
      bool flag = true;
      for(ll k=0;k<n;++k){
        if(i==k || j==k){
          continue;
        }
        if(d[i][j]==d[i][k]+d[k][j]){
          flag = false;
          break;
        }
      }
      if(flag){
        res += d[i][j];
      }
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 1024
data = [input() for x in range(0, 4, 1)]

x = int(data[0])
y = int(data[1])
z = int(data[2])
p = int(data[3])

cnt = 0

for i in range(0, x + 1, 1):
  for j in range(0, y + 1, 1):
    for k in range(0, z + 1, 1):
      tmp_total = 500 * i + 100 * j + 50 * k
      if tmp_total == p:
        #print("{0} {1} {2}".format(i, j, k))
        cnt += 1
      else:
        pass
      
print(cnt)
  
      

Measured memory_bytes: 3064