akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int gcd(int a,int b){
	if(a<b) swap(a,b);
	if(b==0) return a;
	gcd(b,a%b);
}

int main(){

	int n,m;
	int inp;
	int buse[500],ruse[500];
	vector<int> b,r;
	vector<int> gb[500],gr[500];
	bool f;
	int cnt;

	while(1){

		cin>>n>>m;
		if(n==0&&m==0) break;

		if(!b.empty()) b.clear();
		if(!r.empty()) r.clear();
		for(int i=0;i<500;i++) if(!gb[i].empty()) gb[i].clear();
		for(int i=0;i<500;i++) if(!gr[i].empty()) gr[i].clear(); 
		for(int i=0;i<500;i++) buse[i]=0,ruse[i]=0;

		for(int i=0;i<n;i++){
			cin>>inp;
			b.push_back(inp);
		}

		for(int i=0;i<m;i++){
			cin>>inp;
			r.push_back(inp);
		}

		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(gcd(b[i],r[j])!=1){
					gb[i].push_back(j);
					gr[j].push_back(i);
				}
			}
		}

		cnt=0;
		for(int i=1;i<500;){
			f=true;
			for(int j=0;j<n;j++){
				if(gb[j].size()==i&&buse[j]==0){
					for(int k=0;k<gb[j].size();k++){
						if(ruse[gb[j][k]]==0){
							buse[j]=1;
							ruse[gb[j][k]]=1;
							cnt++;
							f=false;
							break;
						}
					}
				}
			}
			for(int j=0;j<m;j++){
				if(gr[j].size()==i&&ruse[j]==0){
					for(int k=0;k<gr[j].size();k++){
						if(buse[gr[j][k]]==0){
							ruse[j]=1;
							buse[gr[j][k]]=1;
							cnt++;
							f=false;
							break;
						}
					}
				}
			}
			if(f) i++;
		}
		cout<<cnt<<endl;
	}

	return 0;
}

Measured memory_bytes: 3388
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}


const int MOD = 1000000007;
struct modint {
  long long val;
  modint(long long val=0) : val((val % MOD + MOD) % MOD){}
  modint operator-() const { return modint(-val); }
  modint& operator+=(const modint a) { if ((val += a.val)     >= MOD) val -= MOD; return *this; }
  modint& operator-=(const modint a) { if ((val += MOD-a.val) >= MOD) val -= MOD; return *this; }
  modint& operator*=(const modint a) { (val *= a.val) %= MOD; return *this; }
  modint operator+(const modint a) const { return (modint)*this += a; }
  modint operator-(const modint a) const { return (modint)*this -= a; }
  modint operator*(const modint a) const { return (modint)*this *= a; }
  modint pow(long long n) const { modint r(1), m(val); while (n > 0) { if (n & 1) {r *= m;} m *= m; n >>= 1; } return r; }
  modint inv() const { return pow(MOD-2); }
  modint& operator/=(const modint a) { return (*this) *= a.inv(); }
  modint operator/(const modint a) const { return (modint)*this /= a; }
  bool operator==(const modint &p) const { return val == p.val; }
  bool operator!=(const modint &p) const { return val != p.val; }
  friend ostream &operator<<(ostream &os, const modint &p) { return os << p.val; }
  friend istream &operator>>(istream &is, modint &a) { long long t; is >> t; a = modint(t); return (is); }
};


struct mod_combination {
  /* initialize: O(n log MOD) */
  /* choose    : O(1) */
  vector<modint> fact, fact_inv, inv;
  mod_combination(int n) : fact(n+1, 1), fact_inv(n+1, 1), inv(n+1, 1) {
    for (int i = 2; i <= n; i++) {
      fact[i] = fact[i - 1] * i;
      inv[i] = -inv[MOD % i] * (MOD / i);
      fact_inv[i] = fact_inv[i - 1] * inv[i];
    }
  }
  modint choose(int n, int k) { return fact[n] * fact_inv[k] * fact_inv[n - k]; }
};

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

  int max_length = s / 3;

  mod_combination mc(2000);

  modint ans;
  rep(l, 1, max_length+1) {
    int nokori = s - l * 3;
    int lll = l+nokori-1; /* allow duplicates */
    ans += mc.choose(lll, nokori);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 1e5 + 10;
int N;
LL a[MAX];
LL adif[MAX];

int main(void) {
    cin >> N;
    REP(i, N) cin >> a[i];
    int now = 0;
    REP(i, N + 1) {
        adif[i] =llabs(a[i] - now);
        now = a[i];
    }
    LL sum = 0;
    REP(i, N + 1) {
        sum += adif[i];
    }
    now = 0;
    DEBUG(sum)
    REP(i, N) {
        cout << sum - adif[i + 1] -  adif[i] + llabs(a[i + 1] - now) << endl;
        now = a[i];
    }
}


Measured memory_bytes: 2816
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <math.h>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <numeric>
#include <bits/stdc++.h>

#define int long long

struct edge {
    int to;
    int cost;
};

using namespace std;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vb = vector<bool>;
using qi = queue<int>;
using P = pair<int, int>;
using graph = vector<vector<edge>>;
// using graph = vector<vector<int>>;


#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define delim(i, n) cout << (i == n-1 ? "\n" : " ");

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

const int inf = 1LL << 60;
// const int inf = 100000000;
const int mod = 1000000007;

const int maxn = 300;
int n, m, k;

vi dx = {-1, 0, 0, 1};
vi dy = {0, -1, 1, 0};

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

    string s;
    cin >> s;
    int l = s.length();
    if (s[l-1] == 's') cout << std::fixed << std::setprecision(10) << s << "es" << "\n";
    else cout << std::fixed << std::setprecision(10) << s << "s" << "\n";
}

    

Measured memory_bytes: 3664
#include<stdio.h>
#include<string.h>

int main(){
	int len;
	int flag = 0;
	int loop;
	char s[101];

	scanf("%s", s);
	len = strlen(s);

	for (loop = 0; loop < len; loop++){
		if (flag == 0 && s[loop] == 'C')flag++;
		else if (flag == 1 && s[loop] == 'F'){
			flag++;
			break;
		}
	}
	if (flag == 2)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {

	//A
	/*int n;
	cin >> n;
	char s[100];
	char t[100];

	cin >> s;
	cin >> t;

	int i, j;
	int flag;
	for (i = 0; i < n; i++) {
		flag = 0;
		for (j = 0; j <= n-i-1; j++) {
			if (t[j] == s[j + i]) {

			}
			else {
				flag = 1;
				break;
			}
		}
		if (flag == 0) {
			cout << n + i;
			return 0;
		}
	}
	cout << 2 * n;
	return 0;
	*/

	//B改
	int n,x;
	cin >> n >> x;
	int i;
	if (x == 1) {
		if (n == 1) {
			cout << "Yes\n";
			cout << 1;

		}
		else {
			cout << "No";
		}
		
	}
	else if (x == 2 * n - 1) {
		cout << "No";
	}
	else if (x == 2) {
		if (n == 2) {
			cout << "Yes\n";
			cout << 1;
			cout << '\n';
			cout << 2;
			cout << '\n';
			cout << 3;
		}
		else {
			cout << "Yes\n";
			for (i = 0; i < n - 2; i++) {
				cout << i + n + 2;
				cout << '\n';
			}
			cout << 3;
			cout << '\n';
			cout << 2;
			cout << '\n';
			cout << 1;
			cout << '\n';
			cout << 4;
			cout << '\n';
			for (i = n + 2; i < 2 * n - 1; i++) {
				cout << i - n + 3;
				cout << '\n';
			}
		}
	}
	else {
		cout << "Yes\n";
		for (i = 0; i < n-2; i++) {
			cout << ((i + n+1) + (x - 3)) % (2 * n - 1) + 1;
			cout << '\n';
		}
		cout << x - 1;
		cout << '\n';
		cout << x;
		cout << '\n';
		cout << x + 1;
		cout << '\n';
		cout << x - 2;
		cout << '\n';
		for (i = n + 2; i < 2 * n - 1; i++) {
			cout << ((i - n + 2) + (x - 3)) % (2 * n - 1) + 1;
			cout << '\n';
		}
	}
	return 0;

	/*int n, x, i;
	
	std::cin >> n;
	std::cin >> x;

	
	if (n == 1) {
		if (x == 1) {
			std::cout << "Yes\n";
			std::cout << 1;
		}
		else {
			std::cout << "No";
		}
	}
	else if (n == 2) {
		if (x == 2) {
			std::cout << "Yes\n";
			std::cout << 1; std::cout << "\n"; std::cout << 2; std::cout << "\n"; std::cout << 3;
		}
		else {
			std::cout << "No";
		}
	}
	else {
		if (x == 1) {
			std::cout << "No";
		}
		else if (x == 2 * n - 1) {
			std::cout << "No";
		}
		else if (x == 2) {
			std::cout << "Yes\n";
			for (i = 1; i <= 2 * n - 1; i++) {
				if (i < n - 1) {
					std::cout << i + 4;
				}
				else if (i < n + 2) {
					std::cout << n + 2 - i;
				}
				else if (i == n + 2) {
					std::cout << 4;
				}
				else {
					std::cout << i;
				}
			}
			std::cout << "\n";
		}
		else {
			std::cout << "Yes\n";
			for (i = 1; i <= 2 * n - 1; i++) {
				if (i == n - 1) {
					std::cout << x - 1;
				}
				else if (i == n) {
					std::cout << x;
				}
				else if (i == n + 1) {
					std::cout << x + 1;
				}
				else if (i == n + 2) {
					std::cout << x - 2;
				}
				//else if (i == x - 1) {
				//	std::cout << n - 1;
				//}
				//else if (i == x) {
				//	std::cout << n;
				//}
				//else if (i == x + 1) {
				//	std::cout << n + 1;
				//}
				//else if (i == x - 2) {
				//	std::cout << n + 2;
				//}
				else {
					std::cout << i;
				}
				std::cout << "\n";
			}
		}
	}
	return 0;
	*/

}

Measured memory_bytes: 1536
n = int(input())
k = 0
while n > k:
  if k*(k+1)//2 < n <= (k+1)*(k+2)//2:
    break
  k += 1
s = (k+1)*(k+2)//2 - n
for i in range(1,k+2):
  if i == s:
    continue
  print(i)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    string s;
    cin >> s;

    if (s.size() == 2) {
        if (s[0] == s[1]) {
            put("1 2");
        }
        else {
            put("-1 -1")
        }
        return;
    }

    rep(i, s.size() - 3) {
        char a = s[i];
        char b = s[i+1];
        char c = s[i+2];
        if (a == b || b == c || c == a) {
            std::cout << i + 1 << " " << i + 3 << endl;
            return;
        }
    }

    put("-1 -1")
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3716
#include <cstdio>
#include <cstdlib>

using namespace std;

bool is_rectangle(int a, int b, int d) { return a * a + b * b == d * d; }

bool is_rhombus(int a, int b, int d) { return a == b; }

int main() {
  char *line = NULL;
  size_t buffer_size = 0;
  int num_rectangles = 0, num_rhombus = 0;
  while (getline(&line, &buffer_size, stdin) > 0) {
    int a, b, d;
    sscanf(line, "%d,%d,%d", &a, &b, &d);
    if (is_rectangle(a, b, d)) { ++num_rectangles; }
    if (is_rhombus(a, b, d)) { ++num_rhombus; }
  }
  free(line);

  printf("%d\n%d\n", num_rectangles, num_rhombus);

  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<limits.h>
  
#define N 101
#define WHITE 0
#define GRAY 1
#define BLACK 2
  
int Q[N], M[N][N], color[N], d[N], n, f=1, c=1;
  
void Enqueue(int n){
  Q[f] = n;
  f++;
  if(f == N) f=1;
}
  
int Dequeue(){
  int x = c;
  c++;
  if(c == N) c=1;
  return Q[x];
}
  
void BFS(int s){
  int i, u;
  for(i = 1; i <= n; i++){
    color[i] = WHITE;
    d[i] = -1;
  }
  color[s] = GRAY;
  d[s] = 0;
  Enqueue(s);
  while(f != c){
    u = Dequeue();
    for(i = 1; i <= n; i++){
      if(color[i] == WHITE && M[u][i] == 1){
    color[i] = GRAY;
    d[i] = d[u] + 1;
    Enqueue(i);
      }
    }
    color[u] = BLACK;
  }
}
  
int main(){
  int i, j, k, x, s, m;
  for(i=1; i < n; i++){
    for(j=1; j < n; j++) M[i][j] = 0;
  }
  scanf("%d",&n);
  for(i=1; i <= n; i++){
    scanf("%d%d", &m, &k);
    if(i == 1) s = 1;
    for(j=0; j < k; j++){
      scanf("%d",&x);
      M[m][x] = 1;
    }
  }
  BFS(s);
  for(i=1; i <= n; i++){
    printf("%d %d\n", i, d[i]);
  }
  return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <string>

using namespace std;

void solve()
{
	string Red;
	while(cin >> Red, Red != "-")
	{
		string Green, Bottom;
		cin >> Green >> Bottom;
		int R_pos = 0;
		int G_pos = 0;
		int pos = 0;
		char Center = Green[0];
		G_pos++;
		int size = Red.size() + Green.size();
		for(int i = 0; i < size; ++i)
		{
			if(Center == Bottom[pos])
			{
				Center = Red[R_pos];
				R_pos++;
				pos++;
			}
			else
			{
				cout << Center;
				Center = Green[G_pos];
				G_pos++;
			}
		}
		cout << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000

void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,M,K,i,j;
  cin>>N>>M>>K;
  if(K%N==0||K%M==0) {
    cout<<"Yes"<<endl;
    return ;
  }
  repl(i,1,M){
    repl(j,1,N){
    if(N * i + M * j - i*j*2 == K) {
      cout<<"Yes"<<endl;
      // cout<<i<<" "<<j<<endl;
      return ;
    }
  }
  }

  cout<<"No"<<endl;

}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main (void){
	int n,k;
	while(cin>>n>>k){
		int i,sum=0,num[n];
		for(i=0;i<n;i++){
			cin>>num[i];
		}
		sort(num,num+n);
		for(i=k;i>0;i--){
			sum+=num[n-i];
		}
		cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

struct point {
	double x, y;
}A, B, C, P;

double crossProd(point A, point B, point C) {
	return (B.x - A.x) * (C.y - A.y) - (B.y - A.y) * (C.x - A.x);
}

int main() {
	while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &A.x, &A.y, &B.x, &B.y, &C.x, &C.y, &P.x, &P.y) != EOF) {
		if (crossProd(A, B, P) > 0 && crossProd(B, C, P) > 0 && crossProd(C, A, P) > 0   //点在三角形内 
		 || crossProd(A, P, B) > 0 && crossProd(B, P, C) > 0 && crossProd(C, P, A) > 0) puts("YES");
		else puts("NO"); //点在三角形外 
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<set>
#include<vector>
#include<cmath>
#include<list>
#include<algorithm>

#define ll long long

using namespace std;

int main() {
	string s;
	cin >> s;
	cout << (s == "ABC" ? "ARC" : "ABC" )<< endl;
	return 0; 
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef double D;
const ll inf=(1ll<<61);
const ll mod=1e9+7;
const int MX=302;
ll n;
int main(){
    cin>>n;
    ll ret=0,m=n;
    while(m){
        ret+=(m%10);
        m/=10;
    }
    if(n<=9){
        cout<<n<<endl;
        return 0;
    }
    ll x=0,y=0;
    while(x*10+9<=n){
        x*=10;
        x+=9;
        y++;
    }
    if(x==n){
        cout<<y*9<<endl;
        return 0;
    }
    ll h=0;
    m=n;
    while(m){
        h=(m%10);
        m/=10;
    }
    ll u=h-1;
    ll o=y;
    while(o--)u*=10,u+=9;
    if(u>n)h=0;
    cout<<max(y*9+h-1,ret)<<endl;
}


Measured memory_bytes: 256
S = list(input())
temp = ""
list = []
ans = 0
for n in range(len(S)):
  if S[n]=="A" or S[n]=="C" or S[n]=="G" or S[n]=="T":
    temp += S[n]
  else:
    list.append(temp)
    temp = ""
list.append(temp)
temp = 0
for n in range(len(list)):
  if temp < len(list[n]):
    temp = len(list[n])
print(temp)

Measured memory_bytes: 3064
import Data.List
import Data.Ord

main = interact $ unlines . map (show . princess_marriage) . read' . lines
 where
  read' ("0 0":_) = []
  read' (nm:xs) = (m, map ((\[d,p]->(d,p)). map read . words) dps) : read' xs'
   where
    [n,m] = map read (words nm)
    (dps,xs') = splitAt (fromInteger n) xs

princess_marriage (m,dps) = sum . map (uncurry (*)) . hire m . reverse . sortBy (comparing snd) $ dps
 where
  hire _ [] = []
  hire m' ((d,p):dps') = if m' <= d then (d-m',p):dps' else hire (m'-d) dps'

Measured memory_bytes: 14356
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int inputSecond = Integer.parseInt(br.readLine());
		int hour = inputSecond/3600;
		int minute = (inputSecond/60)%60;
		int second = inputSecond%60;

		System.out.println(hour + ":" + minute + ":" + second);

	}

}

Measured memory_bytes: 17052
N, M = map(int, input().split())
ab = [list(map(int,input().split())) for i in range(N)]
cd = [list(map(int,input().split())) for i in range(M)]

for i in range(N):
    min_ = 10**10
    index = 0
    for j in range(M):
        if abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]) < min_:
            index = j+1
            min_ = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
    print(index)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; 
typedef string str;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
typedef vector<int> vi; 
typedef vector<bool> vb; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
 
#define sz(x) (int)(x).size()
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define sor(x) sort(all(x))
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define endl '\n'
 
const ll MOD = 998244353;
const ll INF = 1e18;
const int n = 5e5;

int pow(ll a, int b, int m) {
   a = a % m;
   ll ret = 1;
   while (b > 0) {
      if (b & 1) ret = ret * a % m;
      a = a * a % m;
      b /= 2;
   }
   return ret;
}

int inv (int a, int p) {
   return pow(a, p - 2, p);
}

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   int n, m, k; cin >> n >> m >> k;
   vl pre(k + 1);
   pre[0] = 1;
   for (int i = 1; i <= k; i++)
      pre[i] = (pre[i - 1] * (n - i) % MOD) * inv(i, MOD) % MOD;
   ll ans = 0;
   for (int i = 0; i <= k; i++)
      ans = (ans + pre[i] * pow(m - 1, n - 1 - i, MOD)) % MOD;
   cout << ans * m % MOD;
   return 0;
}

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

int main(){
  int a, b;
  cin>>a>>b;
  //string のコンストラクタは第一引数で文字列の長さ、第二引数で埋める文字を示すので
  string s(b,'0'+a);
  string t(a, '0'+b);
  cout<<min(s,t)<<endl;
  
}


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

using namespace std;

#define BIG 998244353

long long pow(long long a, long long b) {
    if(b == 0)
        return 1;
    return a*pow(a,b-1)%BIG;
}

int main() {
    long long n; cin >> n;
    vector<long long> v(n);
    vector<long long> num(n,0);
    long long max = 0;
    for(long long i = 0; i< n; i++){
        cin >> v[i];
        if(i == 0 && v[i] != 0) {
            cout << 0 << endl;
            return 0;
        }
        if(i != 0 && v[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
        if(max < v[i])
            max = v[i];
        num[v[i]]++;
    }
    long long ans = 1;
    for(long long i = 2; i<n;i++) {
        if(num[i] == 0) {
            if(max+1 == i)
                break;
            else {
                cout << 0 << endl;
                return 0;
            }
        }
        long long tmp = pow(num[i-1],num[i]);
        ans *= tmp;
        ans %= BIG;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2304
# 解説ACくやしい！
n,k = map(int,input().split())
mod = 10**9+7
n = n
ans = 0
temp_min = 0
temp_max = 0
for i in range(n+1):
    temp_min += i
    temp_min %= mod
    temp_max += n-i
    temp_max %= mod
    if i>=k-1:
        ans += temp_max-temp_min+1
        ans %= mod
print(ans)


Measured memory_bytes: 9128
def check(f):
        for k in range (n):
                if j[k]==g:
                        j[k]=[-1,-1]
                        f+=1
        return f

while 1:
        n=input()
        if n==0:
                break
        j=[0 for i in range(n)]
        for i in range(n):
                j[i]=map(int,raw_input().split())

        m=input()
        g=[10,10]
        o=[0,0]
        f=0
        for i in range(m):
                o=map(str,raw_input().split())
                for l in range(int(o[1])):
                        if o[0]=="N":
                                g[1]+=1
                                f=check(f)
                        elif o[0]=="S":
                                g[1]-=1
                                f=check(f)
                        elif o[0]=="E":
                                g[0]+=1
                                f=check(f)
                        elif o[0]=="W":
                                g[0]-=1
                                f=check(f)
        if n<=f:
                print("Yes")
        else:
                print("No")

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

int main(void){
    string s,ans;
    cin>>s;

    for(int i=0;i<s.size();i++){
        switch(s[i]){
            case '0':ans.push_back(s[i]);break;
            case '1':ans.push_back(s[i]);break;
            case 'B':if(ans.size()==0)
                         continue;
                     else
                         ans.pop_back();break;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

ll div(ll s) {
  if (s < 0) return 0;
  return 1;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll s;
  cin >> s;
  ll t = sqrt(s);
  if (t * t == s) {
    cout << "0 0 " << t << " 0 0 " << t << endl;
    return 0;
  }
  if (t * t > s) t--;

  ll x1, y1, x2, y2;
  ll LIM = 1000000000LL;

  ll d = div(t * (t + 1) - s);

  if (d != 0) {
    cerr << "a" << endl;
    cout << "0 0 " << t << " " << d << " " << (t * (t + 1) - s) / d << " " << t + 1 << endl;
    return 0;
  }

  d = div((t + 1) * (t + 1) - s);

  if (d != 0) {
    cout << "0 0 " << t + 1 << " " << d << " " << ((t + 1) * (t + 1) - s) / d << " " << t + 1 << endl;
    return 0;
  }

  return 0;
}


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

using namespace std;

int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  long len=s.length();
  char arr[len+1];
  strcpy(arr, s.c_str()); 
  
  for(long i=0;i<len;i++)
  {
    int tot=(int)arr[i]+n;
    
    if(tot>90)
    {
      int diff=(tot-90)+64;
      arr[i]=(char)diff;
    }
    else
    {
      arr[i]=(char)tot;
    }
    cout<<arr[i];
  }
  return 0;
}

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

#define in cin
#define out cout

#define REP(i,n) for(int i=0; i<n; i++)
#define REP2(i,s,e) for(int i=s; i<e; i++)
#define REPE(i,s,e) for(int i=s; i<=e; i++)
#define REPR(i,s,e) for(int i=s; i>=e; i--)

#define all(v) v.begin(), v.end()
#define pb push_back

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define rd(n) scanf("%d", &n)

#define x first
#define y second
#define intINF 2147483647
#define llINF 9223372036854775807LL
#define MOD 1000000007

#define mx 4444

ll n, x;
ll cost[mx];

ll getmin[mx][mx];

ll shift(int s)
{
    ll ret = 0;
    REP(i, n)
    {
        ret += getmin[i][i+s];
    }
    return ret;
}

int main()
{
    in >> n >> x;

    REP(i, n) in >> cost[i];
    REP(i, n) cost[i+n] = cost[i];

    REP(i, 2*n)
    {
        ll t = cost[i];
        REP2(j, i, 2*n)
        {
            t = min(t, cost[j]);
            getmin[i][j] = t;
        }
    }

    ll res = llINF;
    REP(i, n)
    {
        ll t = x*i + shift(i);
        res = min(res, t);
    }

    out << res << "\n";

    return 0;
}


Measured memory_bytes: 78720
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define INF 1000000007
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define CLR(a) memset((a), 0, sizeof(a))

using ll = long long;
using ull = unsigned long long;
using namespace std;

ll gcd(ll a, ll b){
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

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

bool cmp_second(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}




int main(void){

    int n, d;
    cin >> n >> d;

    if(n%(d*2+1)==0)cout << n/(d*2+1) << endl;
    else cout << n/(d*2+1)+1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority queue
#include<deque>//double_ended queue
using namespace std;
int main()
{ 
    int n=0;
    cin>>n;
    string s;
    cin>>s;
    string t;
    t=s.substr(0,n/2);
    if(s==t+t){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

Comb = []
for i in range(X):
    for j in range(Y):
        if (i + 1) * (j + 1) > K:
            break
        for k in range(Z):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break
            Comb.append(A[i] + B[j] + C[k])

Comb.sort(reverse=True)
for i in range(K):
    print(Comb[i])


Measured memory_bytes: 8728
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

vector < ll > pos, neg;
const ll mod = (1e9) + 7;

ll mul(ll x, ll y)
{
	return ((x % mod) * (y % mod)) % mod;
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> n >> k)
    {
		pos.clear();
		neg.clear();

		for(ll i = 0; i < n; i++)
		{
			slld(input);

			if(input < 0) neg.push_back(input);
			else pos.push_back(input);
		}

		ll res = 1;

		sort(neg.begin(),neg.end());
		sort(pos.rbegin(),pos.rend());

		if(pos.empty() && (k & 1))
		{
			sort(neg.rbegin(),neg.rend());
			for(j = 0; j < k; j++) res = mul(res,neg[j]);

			res += mod;
		}
		else if(k == n)
		{
			for(auto it: pos) res = mul(res,it);
			for(auto it: neg) res = mul(res,it);
			
			res = (res + mod) % mod;
		}
		else
		{
			ll idxp = 0, idxn = 0;

			if(k & 1) res = mul(res, pos[idxp]), idxp++, k--;

			for(ll i = 1; i <= k; i += 2)
			{
				if(idxp + 1 < pos.size() && idxn + 1 < neg.size())
				{
					if(pos[idxp] * pos[idxp + 1] >= neg[idxn] * neg[idxn + 1])
					{
						res = mul(res, pos[idxp] * pos[idxp + 1]);
						idxp += 2;
					}
					else
					{
						res = mul(res, neg[idxn] * neg[idxn + 1]);
						idxn += 2;
					}
				}
				else if(idxp + 1 < pos.size())
				{
					res = mul(res, pos[idxp] * pos[idxp + 1]);
					idxp += 2;
				}
				else if(idxn + 1 < neg.size())
				{
					res = mul(res, neg[idxn] * neg[idxn + 1]);
					idxn += 2;
				}
				else assert(0);
			}
		}

		printf("%lld\n", res);
    }


}





Measured memory_bytes: 5612
#include <stdio.h>

int a, b;
int n;
int x, y;

int dp[32][32];
int i, j;

int main()
{
	while (scanf("%d %d", &a, &b)){
		
		// a, b???0??????while?????????
		if (a == 0 && b == 0) break;

		// ??????????????????
		for (i = 0; i <= 16; i++){
			for (j = 0; j <= 16; j++){
				dp[i][j] = 0;
			}
		}

		scanf("%d", &n);
		for (i = 0; i < n; i++){
			scanf("%d %d", &x, &y);
			// ????????§???????????´?????? -1 ?????£??\???????????¢
			dp[y][x] = -1;
		}

		dp[1][1] = 1;
		for (i = 1; i <= b; i++){
			for (j = 1; j <= a; j++){
				// ????????§???????????´?????????????????????0????????§0?????£??\
				if (dp[i][j] == -1) {
					dp[i][j] = 0;
					continue;
				}

				// ??????????????§??????????????????????????´???????????¨?¨?????????\????????¨?????§???????????§
				// ??????????????????????????¨?????§?????????????????°?????????????????´????????§??????????????????
				dp[i][j] += dp[i - 1][j] + dp[i][j - 1];
			}
		}

		// (a, b)?????§?????????(???????????§?????????)?????????
		printf("%d\n", dp[b][a]);
	}

	return (0);
}

Measured memory_bytes: 604
import sys


class AlgSegmentTreeMin:
    def __init__(self, n, default_value):
        self.Nelem = n
        self.default_value = default_value
        self.size = 1 << (n.bit_length())
        self.data = [default_value] * (2 * self.size)

    def update(self, i, x):
        i += self.size
        self.data[i] = x
        i >>= 1
        while i:
            x = self.data[i + i]
            y = self.data[i + i + 1]
            self.data[i] = min(x, y)
            i >>= 1

    def get_value(self, left, right):
        left += self.size
        right += self.size + 1
        x = self.default_value
        while left < right:
            if left & 1:
                y = self.data[left]
                x = min(x, y)
                left += 1
            if right & 1:
                right -= 1
                y = self.data[right]
                x = min(x, y)
            left >>= 1
            right >>= 1
        return x


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    stree = AlgSegmentTreeMin(n, 10 ** 15)
    lrc = [list(map(int, readline().split())) for _ in range(m)]
    lrc.sort()
    stree.update(0, 0)
    for l, r, c in lrc:
        l -= 1
        r -= 1
        tm = stree.get_value(l, r)
        now = stree.get_value(r, r)
        tm = tm + c if tm + c < now else now
        stree.update(r, tm)
    mt = stree.get_value(n-1, n)
    print(mt if mt != stree.default_value else -1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 96476
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())

if m1 == 2:
  if d1 == 28:
    print("1")
  else:
    print("0")
elif m1 == 1 or m1 == 3 or m1 == 5 or m1 == 7 or m1 == 8 or m1 == 10 or m1 == 12:
  if d1 == 31:
    print("1")
  else:
    print("0")
elif m1 == 4 or m1 == 6 or m1 == 9 or m1 == 11:
  if d1 == 30:
    print("1")
  else:
    print("0")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    // Your code here!
    int n,k;
    cin >> n >> k;
    int ans(0);
    
    for(int i=0;i<n;i++){
        int x;  cin >> x;
        ans += min(x,abs(k-x))*2;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N; cin >> N;
    int minv = 10000, maxv = -10000;

    vector<int> a(N);
    for(int i=0; i<N; i++) { cin >> a[i]; minv = min(minv, a[i]); maxv = max(maxv, a[i]); }

    int ans = 1000000000;
    
    for(int i=minv; i<=maxv; i++){
        int tmp = 0;
        for(int j=0; j<N; j++) tmp += (a[j]-i)*(a[j]-i);
        ans = min(ans, tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	char cards[201] = {0};
	char tmp[201] = {0};
	char *cp;
	char *tp;
	cp = cards;
	tp = tmp;
	int m,h,i;
	int cnt;
	int len = 0;

	while(1){
		len = 0;
		cnt = 0;
		scanf("%s", cards);

		if(cards[0] == '-'){
			break;
		}

		while(cards[len] != '\0'){
			len++;
		}

		scanf("%d", &m);

		while(cnt != m){
			scanf("%d", &h);

			for(i = 0;i < h;i++){
				*(tp + i) = *(cp + i);
			}

			for(i = h;i < len;i++){
				*(cp + i - h) = *(cp + i);
			}

			for(i = 0;i < h;i++){
				*(cp + len - h + i) = *(tp + i);
			}

			cnt++;
		}
		puts(cards);
	}
	return 0;
}

Measured memory_bytes: 584
s = list(input())
t = list(input())

s.sort()
t.sort()

if s[0]<t[-1]:
    print('Yes')
elif s[0]>t[-1]:
    print('No')
elif s[0]==s[-1] and t[0]==t[-1] and len(s)<len(t):
    print('Yes')
else:
    print('No')

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

int gcd(int b, int a){
    while(a>0){
        b %=a;
        swap(b,a);
    }
    return b;
}
int main() {
	int n;
	cin>>n;
	int temp;
	cin>>temp;
	int hcf= temp;

	for(int i=2;i<=n;i++){
        cin>>temp;
	    hcf = gcd(hcf,temp );
	}
	cout<<hcf<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    int w, idx = 0, sl;
    cin >> s >> w;
    sl = s.length();
    
    while(idx < sl) {
        cout << s[idx];
        idx += w;
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length(), p = 2019;
		sc.close();
		long ans = 0;
		Map<Integer, Long> modlist = new HashMap<Integer, Long>();
		long val = 0;
		int m = 1, mode10 = 10 % p;
		for (int i = n - 1; i >= 0; --i) {
			int tmp = (int) (s.charAt(i) - '0');
			tmp %= p;
			tmp *= m;
			tmp %= p;
			val += (long)tmp;
			val %= (long)p;
			int key = (int)val;
			long value = 1;
			if (modlist.containsKey(key))
				value += modlist.get(key);
			modlist.put(key, value);
			ans += (key == 0 ? value : value - 1);
			m *= mode10;
			m %= p;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 52576
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Set;
import java.util.HashSet;

class Main {

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

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String[] inputNumbers = br.readLine().split(" ");
            Set<String> numbersSet = new HashSet<>();
            numbersSet.add(inputNumbers[0]); numbersSet.add(inputNumbers[1]);

            Set<String> firstGroup = new HashSet<>();
            Set<String> secondGroup = new HashSet<>();
            Set<String> thirdGroup = new HashSet<>();

            firstGroup.add("1"); firstGroup.add("3"); firstGroup.add("3"); firstGroup.add("5");
            firstGroup.add("7"); firstGroup.add("8"); firstGroup.add("10"); firstGroup.add("12");
            secondGroup.add("4"); secondGroup.add("6"); secondGroup.add("9"); secondGroup.add("11");
            thirdGroup.add("2");
            
            String result = "No";

            if (firstGroup.containsAll(numbersSet)
                || secondGroup.containsAll(numbersSet)
                || thirdGroup.containsAll(numbersSet)) {
                result = "Yes";
            }

            System.out.println(result);

        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}


Measured memory_bytes: 21076
import java.util.Scanner;
import java.util.Arrays;

public class Main{

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

        // input
        int a = scan.nextInt();
        int b = scan.nextInt();

        // answer
        if(a == b){
            System.out.println(a + b);
        } else {
            System.out.println(Math.max(a, b) * 2 - 1);
        }


    }
}

Measured memory_bytes: 21716
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

	using i8 = std::int_fast8_t;
	using i32 = std::int_fast32_t;
	using i64 = std::int_fast64_t;
	using u8 = std::uint_fast8_t;
	using u32 = std::uint_fast32_t;
	using u64 = std::uint_fast64_t;
	using isize = std::ptrdiff_t;
	using usize = std::size_t;

	class rep {
		const usize f, l;

	public:
		class itr {
			friend rep;
			usize i;
			constexpr itr(const usize x) noexcept : i(x) {}

		public:
			void operator++() noexcept { ++i; }
			constexpr usize operator*() const noexcept { return i; }
			constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
		};
		constexpr rep(const usize first, const usize last) noexcept
			: f(first), l(last) {}
		constexpr itr begin() const noexcept { return itr(f); }
		constexpr itr end() const noexcept { return itr(l); }
	};
	class revrep {
		const usize f, l;

	public:
		class itr {
			friend revrep;
			usize i;
			constexpr itr(usize x) noexcept : i(x) {}

		public:
			void operator++() noexcept { --i; }
			constexpr usize operator*() const noexcept { return i; }
			constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
		};
		constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
		constexpr itr begin() const noexcept { return itr(l); }
		constexpr itr end() const noexcept { return itr(f); }
	};
	template <class T> using vec_alias = std::vector<T>;
	template <class T> auto md_vec(const usize n, const T &value) {
		return std::vector<T>(n, value);
	}
	template <class... Args> auto md_vec(const usize n, Args... args) {
		return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
	}
	template <class T> constexpr T difference(const T &a, const T &b) {
		return a < b ? b - a : a - b;
	}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <utility>

namespace n91 {

	void main_() {
		usize h, w;
		std::cin >> h >> w;
		std::vector<std::string> a(h);
		for (auto &s : a) {
			std::cin >> s;
		}
		struct p {
			usize x, y, d;
		};
		std::queue<p> que;
		auto dist = md_vec(h, w, h * w);
		for (const auto i : rep(0, h)) {
			for (const auto j : rep(0, w)) {
				if (a[i][j] == '#') {
					que.push({ i, j, 0 });
				}
			}
		}
		while (!que.empty()) {
			const auto e = que.front();
			que.pop();
			if (dist[e.x][e.y] <= e.d) {
				continue;
			}
			dist[e.x][e.y] = e.d;
			if (e.x != 0) {
				que.push({ e.x - 1, e.y, e.d + 1 });
			}
			if (e.x + 1 != h) {
				que.push({ e.x + 1, e.y, e.d + 1 });
			}
			if (e.y != 0) {
				que.push({ e.x, e.y - 1, e.d + 1 });
			}
			if (e.y + 1 != w) {
				que.push({ e.x, e.y + 1, e.d + 1 });
			}
		}
		usize max = 0;
		for (const auto &v : dist) {
			for (const auto e : v) {
				max = std::max(max, e);
			}
		}
		std::cout << max << std::endl;
	}

} // namespace n91

int main() {
	n91::main_();
	return 0;
}


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

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

	int i = 0, x;
	while (++i <= n)
	{
		x = i;
		if (x % 3 == 0) 
		{
			cout << " " << i;
			continue;
		}
		while (x)
		{
			if (x % 10 == 3) 
			{
				cout << " " << i;
				x = 0;
			}
			x /= 10;
		}
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main(){
	char a[1002];
	int i;
	
	for(int i=0;i<1002;i++){
		a[i]=0;
	}
	cin >> a;
	for(i=0;i<1002;i++){
		if(a[i]=='T'){
			cout << "a";
		}
		if(a[i]=='L'){
			cout << "i";
		}
		if(a[i]=='U'){
			cout << "u";
		}
		if(a[i]=='R'){
			cout << "e";
		}
		if(a[i]=='D'){
			cout << "o";
		}
		if(a[i]==0){
cout << "\n";
			return 0;
		}
		if(a[i]=='2'){
			cout << "k";
		}
		if(a[i]=='3'){
			cout << "s";
		}
		if(a[i]=='4'){
			cout << "t";
		}
		if(a[i]=='5'){
			cout << "n";
		}
		if(a[i]=='6'){
			cout << "h";
		}
		if(a[i]=='7'){
			cout << "m";
		}
		if(a[i]=='8'){
			cout << "y";
		}
		if(a[i]=='9'){
			cout << "r";
		}
		if(a[i]=='0'){
			i++;
			if(a[i]=='T'){
				cout << "wa";
			}
			if(a[i]=='U'){
				cout << "nn";
			}
			if(a[i]=='D'){
				cout << "wo";
			}
		}

	}
return 0;
}

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

long long int m=1e9 + 7;
long long int fact[1000001],infact[1000001];

long long int power(long long int x,long long int y)
{
    long long int res=1LL;
    x=x%m;
    while(y>0)
    {
        if(y&1)
        res=(res*x)%m;
        x=(x*x)%m;
        y/=2;
    }
    return res;
}

long long int ncr(long long int n,long long int r)
{
    long long int res=( ((fact[n] * infact[n-r])%m) * infact[r])%m;
    return res;
}
 
int main()
{
    fact[1]=1;
    fact[0]=1;
    infact[1]=1;
    infact[0]=1;
    for(long long int i=2;i<1000001;i++)
    {
        fact[i]=( (fact[i-1]%m) * (i%m) )%m;
        infact[i] = ( ( infact[i-1]%m ) * (power(i,m-2)) )%m;
    }
    long long int n,ans=0LL;
    cin>>n;
    if(n==1)
    {
        cout<<"0";
        return 0;
    }
    for(long long int i=2;i<=n;i++)
    {
        long long int temp= (ncr(n,i));
        temp = (temp * (power(2,i)-2LL))%m;
        temp = (temp * power(8,n-i))%m;
        ans=(ans+temp)%m;
    }
    cout<<ans;
}
    

Measured memory_bytes: 19256
x1, y1, x2, y2 = map(int, input().split())

vx = x2 - x1
vy = y2 - y1

x3 = x2 - vy
y3 = y2 + vx

x4 = x3 - vx
y4 = y3 - vy

print(x3, y3, x4, y4)

Measured memory_bytes: 2940
#pragma GCC optimize("O3")

#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 long long ll;
typedef pair<int, int> pi;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n,d,a;
    cin >> n >> d >> a;
    vector<pair<ll,ll>> arr(n);
    F0R(i,n)
    {
        ll first,second;
        cin >> first >> second;
        arr[i]={first,second};
    }
    set<pair<ll,ll>> se;
    sort(arr.begin(),arr.end());
    se.insert(arr[0]);
    int ind=n;
    FOR(i,1,n)
    {
        if(arr[i].first<=arr[0].first+2*d)
            se.insert(arr[i]);
        else
        {
            ind=i;
            break;
        }
    }
    ll cnt=0;
    while(!se.empty())
    {
        pair<ll,ll> curr=*se.begin();
        se.erase(se.begin());
        while(!se.empty() && curr.second<=cnt*a)
        {
            curr=*se.begin();
            se.erase(se.begin());
        }
        while(ind!=n && arr[ind].first<=curr.first+2*d)
        {
            arr[ind].second+=cnt*a;
            se.insert(arr[ind]);
            ind++;
        } 
        if(curr.second%a)
            cnt=max(cnt,curr.second/a+1);
        else
            cnt=max(cnt,curr.second/a);
        if(ind!=n && se.empty())
        {
            arr[ind].second+=cnt*a;
            se.insert(arr[ind]);
            ind++;
        }
    }
    cout << cnt;

    return 0;
}


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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline void chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
}
template <class T1, class T2>
inline void chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    char A;
    cin >> A;
    if (A <= 90) {
        cout << 'A' << endl;
    } else {
        cout << 'a' << endl;
    }
}

Measured memory_bytes: 3584