akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <assert.h>

using namespace std;

typedef long long ll;

const int MAXN = 100005;

struct Edge
{
	int to;
	int next;
}edge[MAXN << 1];

int n,id;
int first[MAXN];
int cnt[MAXN];
int ord[MAXN];
int f[MAXN];
int g[MAXN];

ll d[MAXN];
ll F[MAXN];
ll G[MAXN];

vector<pair<int,int> > e;

bool cmp(const int &a,const int &b)
{
	return d[a] < d[b];
}

void addE(int u,int v)
{
	edge[++id] = (Edge){v,first[u]};
	first[u] = id;
}

int search(ll v)
{
	int low = 1,high = n;
	while (low < high)
	{
		int mid = (low + high) >> 1;
		if (d[ord[mid]] >= v)
			high = mid;
		else
			low = mid + 1;
	}
	if (d[ord[low]] == v)
		return low;
	return -1;
}

void dfs1(int now,int fa)
{
	f[now] = 1;
	F[now] = 0;
	for (int i = first[now];i;i = edge[i].next)
		if (edge[i].to != fa)
		{
			dfs1(edge[i].to,now);
			F[now] += F[edge[i].to] + f[edge[i].to];
			f[now] += f[edge[i].to];
		}
}

void dfs2(int now,int fa)
{
	for (int i = first[now];i;i = edge[i].next)
		if (edge[i].to != fa)
		{
			G[edge[i].to] = G[now] + F[now] - F[edge[i].to] - f[edge[i].to] + g[now] + f[now] - f[edge[i].to];
			g[edge[i].to] = g[now] + f[now] - f[edge[i].to];
			dfs2(edge[i].to,now);
		}
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1;i <= n;i++)
	{
		cin >> d[i];
		cnt[i] = 1;
		ord[i] = i;
	}
	sort(ord + 1,ord + n + 1,cmp);
	for (int i = n;i >= 2;i--)
	{
		int pos = search(d[ord[i]] - (n - cnt[ord[i]]) + cnt[ord[i]]);
		if (pos == -1 || pos >= i)
		{
			cout << -1 << endl;
			return 0;
		}
		e.push_back(make_pair(ord[i],ord[pos]));
		addE(ord[i],ord[pos]);
		addE(ord[pos],ord[i]);
		cnt[ord[pos]] += cnt[ord[i]];
	}
	dfs1(1,0);
	dfs2(1,0);
	for (int i = 1;i <= n;i++)
		if (d[i] != F[i] + G[i])
		{
			cout << -1 << endl;
			return 0;
		}
	for (int i = 0;i < e.size();i++)
		cout << e[i].first << ' ' << e[i].second << endl;
	return 0;
}

Measured memory_bytes: 12788
#include<iostream>
#include<string>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int A,B;
	string result="Impossible";
	cin >> A;
    cin >> B;
    if(A%3==0 || B%3==0 || (A+B)%3==0){
        result="Possible";
    }
    
	cout << result << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  rep(i,ty-sy){
    cout<<'U';
  }
  rep(i,tx-sx){
    cout<<'R';
  }
  rep(i,ty-sy){
    cout<<'D';
  }
  rep(i,tx-sx+1){
    cout<<'L';
  }
  rep(i,ty-sy+1){
    cout<<'U';
  }
  rep(i,tx-sx+1){
    cout<<'R';
  }
  cout<<'D'<<'R';
  rep(i,ty-sy+1){
    cout<<'D';
  }
  rep(i,tx-sx+1){
    cout<<'L';
  }
  cout<<'U'<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

struct UnionFind {
	vector<int> par, siz;
	UnionFind(int n): par(n), siz(n, 1) {
		rep(i,n) par[i] = i;
	}
	int find(int x) {
		return (par[x] == x) ? x: par[x] = find(par[x]);
	}
	bool unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return false;
		else {
			if (siz[x] < siz[y]) swap(x, y);
			siz[x] += siz[y];
			par[y] = x;
			return true;
		}
	}
};

int main() {
	int n, k, l;
	cin >> n >> k >> l;
	UnionFind road(n), rail(n);
	rep(i,k) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		road.unite(a,b);
	}
	rep(i,l) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		rail.unite(a,b);
	}

	map<pii, int> mp;
	vector<pii> v(n);
	rep(i,n) {
		int x = road.find(i);
		int y = rail.find(i);
		mp[pii(x,y)]++;
		v[i] = pii(x,y);
	}
	rep(i,n) {
		if (i != 0) cout << " ";
		cout << mp[v[i]];
	}
	cout << endl;
}

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

int main()
{
   int a,b;
   cin>>a>>b;
   double d=a,r=b;
   cout<<fixed;

   cout<<setprecision(5)<<(a/b)<<" "<<(a%b)<<" "<<(d/r)<<endl;
}



Measured memory_bytes: 3288
#include <iostream>

using namespace std;

int main() {
  int n, m, l;
  cin >> n >> m >> l;
  int A[n][m], B[m][l];
  long long C[n][l];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      cin >> A[i][j];
  for (int j = 0; j < m; j++)
    for (int k = 0; k < l; k++)
      cin >> B[j][k];
  for (int i = 0; i < n; i++) {
    for (int k = 0; k < l; k++) {
      long long tmp = 0;
      for (int j = 0; j < m; j++) {
        tmp += A[i][j] * B[j][k];
      }
      C[i][k] = tmp;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int k = 0; k < l-1; k++) {
      cout << C[i][k] << " ";
    }
    cout << C[i][l-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1312
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	[ w, a, b ] <- readInts
	print $ maximum [ 0, b - ( a + w ), a - ( b + w ) ]

Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
long long n,i,a,b;

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


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

int main()
{
    cin>>a>>b;
    if(gcd(a,b)==1)
        cout<<a*b<<endl;
    else
    cout<<lcm(a,b);
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,l; cin>>n>>l;
  ll sum=l*n+n*(n-1)/2;
  
  ll diff=LINF;
  ll ans;
  rep(i,n){
    ll d=l+i;
    if(chmin(diff,abs(d))){
      ans=sum-d;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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


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

  vector<int> cand;
  cand.pb(1);
  for(int i = 6; i <= n; i *= 6) {
    cand.pb(i);
  }
  for(int i = 9; i <= n; i *= 9) {
    cand.pb(i);
  }
  sort(all(cand));

  vector<int> memo; // k円ちょうど引き出す最小回数
  memo.assign(n+1, INF<int>);
  memo[0] = 0;
  rep1(i, n+1) {
    rep(j, cand.size()) {
      if(i - cand[j] < 0) break; // 昇順ソートしたので、breakでいい
      memo[i] = min(memo[i], memo[i - cand[j]] + 1);
    }
  }

  cout << memo[n] << endl;

  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#ifdef sahdsg
#define DBG(...) printf(__VA_ARGS__)
#else
#define DBG(...) (void)0
#endif // sahdsg

using namespace std;
typedef long long LL;
int main()
{
    int i=0;
    LL ans=0,cnt=0;
    while(1) {
        char x=getchar();
        i++;
        if(x=='B') break;
        cnt++;
        if(x==EOF) {puts("0");return 0;}
    }

    for(;;i++) {
        char x=getchar();
        if(x=='W') {ans+=i-cnt;cnt++;}
        if(x==EOF) break;
    }
    printf("%lld\n", ans);
    return 0;
}


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

int main()
{
	int n;
	cin >> n;
	for(int i=0; i<n; ++i)
	{
		int a,b,c;
		cin >> a >> b >> c;
		int a2=a*a, b2=b*b, c2=c*c;
		if(a2+b2==c2 || a2+c2==b2 || b2+c2==a2)
		{
			cout << "YES\n";
		}
		else
		{
			cout << "NO\n";
		}
	}
}

Measured memory_bytes: 1120
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N;
  cin >> N;

  vector<int> A(N+1);
  REP(i, N+1) cin >> A[i];

  if(N == 0){
    if(A[0] == 1) cout << 1 << "\n";
    else cout << -1 << "\n";
    return 0;
  }

  vector<int> MIN(N+1);
  vector<int> MAX(N+2);
  MIN[N] = A[N];

  RREP(i, N){
    MIN[i] = A[i]+(MIN[i+1]+1)/2;
    if(i <= 62){
      if(MIN[i] > (1ll << i)){
        cout << -1 << "\n";
        return 0;
      }
    }
  }

  RREP(i, N+1){
    MAX[i] += MAX[i+1]+A[i];
  }

  vector<int> v(N+1);
  v[0] = 1;

  int ans = min(v[0], MAX[0]);
  REP(i, N){
    v[i+1] = (v[i]-A[i])*2;
    ans += min(v[i+1], MAX[i+1]);

    if(v[i+1] >= INF) v[i+1] = INF;
  }

  cout << ans << "\n";

  return 0;
}

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

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

int r , c , n , r1 , c1  , r2 , c2;

vector< pii > b[4];
bool isInBorder(int x , int y) {
	return x == 0 || x == r || y == 0 || y == c;
}
void push(int x , int y, int id) {
	if (x == 0)
		b[0].push_back(make_pair(y, id));
	else if (y == c)
		b[1].push_back(make_pair(x, id));
	else if (x == r)
		b[2].push_back(make_pair(y, id));
	else
		b[3].push_back(make_pair(x, id));
}
int main() {
	scanf("%d%d%d", &r, &c, &n);
	for (int i = 1 ; i <= n ; ++i) {
		scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
		if (isInBorder(r1, c1) && isInBorder(r2, c2)) {
			push(r1, c1, i);
			push(r2, c2, i);
		}
	}
	vector< int > all;
	for (int i = 0 ; i <= 3 ; ++i) {
		sort(b[i].begin(), b[i].end());
		if (i >= 2)
			reverse(b[i].begin(), b[i].end());
		for (int j = 0 ; j < b[i].size(); ++j)all.push_back(b[i][j].second);
	}
	stack<int> st;
	for (int i = 0; i < all.size(); ++i){
		if(st.size() && all[i] == st.top()){
			st.pop();
			continue;
		}
		st.push(all[i]);
	}
	if(st.size()){
		puts("NO");
	}else{
		puts("YES");
	}
	return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll MOD = 1e9+7;

typedef vector<int> vi;

ll modpow(ll n, int m){
	ll ret=1;
	if( m < 0 ) m = MOD-1 + m;
	for(int i=1; i<=m; i<<=1){
		if( m&i ) ret = ret * n % MOD;
		n = n*n % MOD;
	}
	return ret;
}


ll dp[50][40000]={};
int main(){
	int N, X[3];

	cin >> N;
	rep(i,3) cin >> X[i];

	int sX[5]={};
	rep(i,3) sX[i+1] = sX[i] + X[i];

	typedef pair<pii,pii> pip;
	priority_queue<pip, vector<pip>, greater<pip>> que;
	vector<vi> tree;
	tree.push_back(vi());
	reps(i,1,11){
		tree[0].push_back(i);
		tree.push_back(vi());
		que.emplace(pii(i, (i == sX[1])), pii(i, -1));
	}
	set<int> ban;
	while( !que.empty() ){
		int s = que.top().X.X;
		int c = que.top().X.Y;
		int n = que.top().Y.X;
		int m = que.top().Y.Y;
		//cout << s << " " << n << " " << m << endl;
		que.pop();
		if( c == 3 ){
			ban.insert(n);
			continue;
		}
		//if( tree[n].size() >= 10 ) continue;
		rep(i,10){
			int ns = s+i+1;
			int mx = i+1;
			if( m > 0 ) mx = tree[m][i];
			if( ns <= sX[c+1] ){
				int nx = tree.size();
				int nc = c + (ns == sX[c+1]);
				tree[n].push_back( nx );
				tree.push_back( vi() );
				//rep(j,3) if( ns == sX[j+1] ) ns += 10;
				que.emplace(pii(ns, nc), pii(nx, mx));
			}else{
				tree[n].push_back( mx );
			}
		}
	}

	//cout << "tree.size() = " << tree.size() << " " << ban.size() << endl;

	// int a[3];
	// rep(i,3) cin >> a[i];
	// int cur = 0;
	// cout << cur;
	// rep(i,3) cout << " -> " << (cur = tree[cur][a[i]-1]); cout << endl;

	dp[0][0] = 1;
	rep(i,N) rep(j, tree.size()) for(auto t: tree[j]){
		dp[i+1][t] += dp[i][j];
		dp[i+1][t] %= MOD;
	}

	ll sum = 0;
	rep(j, tree.size()) if( !ban.count(j) ){
		sum = (sum + dp[N][j]) % MOD;
	}
	//cout << "sum = " << sum << endl;
	ll ans = (modpow(10, N) + MOD - sum) % MOD;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 17204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int x, n;
    cin >> x >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int now1 = x, now2 = x;
    while(1) {
        if(find(a.begin(), a.end(), now1) != a.end()) {
            now1++;
            continue;
        }
        else {
            break;
        }
    }
    while(1){
        if(find(a.begin(), a.end(), now2) != a.end()) {
            now2--;
            continue;
        }
        else {
            break;
        }
    }
    if(now1 - x >= x - now2) {
        cout << now2 << endl;
    }else{
        cout << now1 << endl;
    }
    
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;

namespace cola2
{
    class Program
    {
        static void Main()
        {
            string[] s_data = Console.ReadLine().Trim().Split(' ');

            //????????¢????????????
            int box_left = 0;
            int box_right = int.Parse(s_data[0]);
            int box_bottom = 0;
            int box_upper = int.Parse(s_data[1]);

            //???????????????
            int circle_left = int.Parse(s_data[2]) - int.Parse(s_data[4]);
            int circle_right = int.Parse(s_data[2]) + int.Parse(s_data[4]);
            int circle_bottom = int.Parse(s_data[3]) - int.Parse(s_data[4]);
            int circle_upper = int.Parse(s_data[3]) + int.Parse(s_data[4]);

            if (box_left <= circle_left && box_right >= circle_right && box_bottom <= circle_bottom && box_upper >= circle_upper)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 8908
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

long long gcd(long long a, long long b)
{
	long long tmp, r;
	if (a < b)
	{
		tmp = a;
		a = b;
		b = tmp;
	}
	r = a % b;
	while (r != 0)
	{
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n;
	cin >> n;
	vector<ll> leftGcd(n), rightGcd(n),a(n);
	rep(i, n)
	{
		cin >> a[i];
	}

	leftGcd[0] = a[0];
	rightGcd[n - 1] = a[n - 1];
	rep(i, n)
	{
		if (0 < i)
			leftGcd[i] = gcd(leftGcd[i - 1], a[i]);

		if (0<i)
			rightGcd[n-1-i] = gcd(rightGcd[n-i], a[n-1-i]);
	}
	ll gcdMax = 0;
	gcdMax = max(gcdMax, rightGcd[1]);
	gcdMax = max(gcdMax, leftGcd[n - 2]);
	for(ll i=1;i<n-1;i++)
	{
		gcdMax = max(gcdMax, gcd(leftGcd[i-1], rightGcd[i + 1]));
	}
	cout << gcdMax << endl;

	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  lint sum=0;
  int a[N];
  REP(i,N){
    cin>>a[i];
    sum+=a[i];
  }
  lint ans=99999999999999;
  lint left=0;
  lint right=sum;
  FOR(i,0,N-1){
    left+=a[i];
    right-=a[i];
    if(ans>lint(abs(left-right)))ans=abs(left-right);
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

char S[100005];

int multiplier[100005];

long long memo[100005][14];
const long long MOD = 1e9+7;

long long dp(int i, int j){
	if(i == 0){
		return j == 5;
	}else if(memo[i][j] != -1){
		return memo[i][j];
	}else if(S[i-1] == '?'){
		long long ans = 0;
		for(int k = 0; k < 10; k ++){
			ans += dp(i-1, (j+k*multiplier[i-1])%13);
		}
		return memo[i][j] = ans%MOD;
	}else{
		int k = S[i-1] - '0';
		return memo[i][j] = dp(i-1, (j+k*multiplier[i-1])%13);
	}
}

int main(){
	scanf(" %s", S);
	int N = strlen(S);
	reverse(S, S+N);
	
	multiplier[0] = 1;
	for(int i = 1; i <= N; i ++){
		multiplier[i] = (multiplier[i-1]*10)%13;
	}
	
	memset(memo, -1, sizeof(memo));
	printf("%lld", dp(N, 0));
	return 0;
}


Measured memory_bytes: 19456
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: u32,
        b: u32,
        c: u32,
    }
    println!("{}", std::cmp::min(b/a, c));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;

struct UF{
    int N;
    vector<int> par, siz, ecnt;
    void init(int _n){
        N = _n;
        par.resize(N);
        siz.resize(N, 1);
        ecnt.resize(N, 0);
        for(int i=0;i<N;i++){
            par[i] = i;
        }
    }
    int root(int x){
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        ecnt[x]++;
        if(x == y) return;
        if(siz[x] < siz[y]) swap(x,y);
        par[y] = x;
        siz[x] += siz[y];
        ecnt[x] += ecnt[y];
    }
    bool check(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y){
            return siz[x] > ecnt[x];
        }
        else{
            return siz[x]+siz[y] > ecnt[x]+ecnt[y];
        }
    }
};

UF uf;

int main() {
    int N, H, W;
    vector<P3> es;
    cin >> N >> H >> W;
    uf.init(H+W);
    for(int i=0;i<N;i++){
        ll r, c, a;
        cin >> r >> c >> a;
        r--; c--;
        es.push_back({a,{r,c}});
    }
    sort(es.rbegin(), es.rend());
    ll ans = 0;
    for(int i=0;i<N;i++){
        ll r, c, a;
        r = es[i].second.first;
        c = es[i].second.second;
        a = es[i].first;
        if(uf.check(r, c+H)){
            uf.unite(r, c+H);
            ans += a;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<bool> >;//ll or Edge
using Edge=pair<int,ll>;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++17
int main(){
    ll x,y,a,b,c;cin>>x>>y>>a>>b>>c;
    vector<P>S;
    rep(i,a){
        ll t;cin>>t;
        S.push_back(P(t,0));
    }
    rep(i,b){
        ll t;cin>>t;
        S.push_back(P(t,1));
    }
    rep(i,c){
        ll t;cin>>t;
        S.push_back(P(t,2));
    }
    sort(ALL(S));
    reverse(ALL(S));
    ll sum=0;
    ll ans=0;
    ll lim=x+y;
    for(auto v:S){
        if(v.se==0 && x>0){x--;sum++;ans+=v.fi;}
        else if(v.se==1 && y>0){y--;sum++;ans+=v.fi;}
        else if(v.se==2 && sum<lim){sum++;ans+=v.fi;}
        if(sum==lim)break;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 11648
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MAX = 1e5+5;
LL level[MAX];
LL MOD = 998244353;

LL getPow(LL x , LL y)
{
        LL res = 1;
        if(x == 0) return 0;
        while(y > 0)
        {
                if(y&1)
                        res = (res%MOD * x%MOD)%MOD;
                x = (x%MOD * x%MOD)%MOD;
                y /= 2;
        }
        return res;
}

int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        LL n;
        cin >> n;
        LL a[n+2];
        LL mx = -1;
        memset(level , 0 , sizeof(level));
        for(int i = 1 ; i <= n ; i++)
        {
                cin >> a[i];
                mx = max(mx , a[i]);
                level[a[i]]++;
        }
        if(level[0] != 1 || a[1] != 0)
        {
                cout << 0 << endl;
                return 0;
        }
        LL ans = 1;
        for(int i = 1 ; i <= mx ; i++)
        {
                ans = ans%MOD *(getPow(level[i-1] , level[i])%MOD)%MOD;
        }
        if(ans < 0) ans += MOD;
        cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

vector<int> parent(100010);
vector<int> si(100010);

void init(int n) {
	for (int i = 0; i < n; i++) {
		parent[i] = i;
		si[i] = 1;
	}
}

int find(int x) {
	if (parent[x] == x) return x;
	else return parent[x] = find(parent[x]);
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) return;
	if (si[x] < si[y]) {
		parent[x] = y;
		si[y] += si[x];
	}
	else {
		parent[y] = x;
		si[x] += si[y];
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n, m, k;
	cin >> n >> m >> k;
	init(n);
	vector<int> a(m), b(m);
	vector<int> ans(n, -1);
	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		unite(a[i], b[i]);
		ans[a[i]]--; ans[b[i]]--;
	}
	rep(i, n) {
		ans[i] += si[find(i)];
	}
	rep(i, k) {
		int c, d;
		cin >> c >> d;
		c--; d--;
		if (find(c) == find(d)) {
			ans[c]--; ans[d]--;
		}
	}
	rep(i, n) cout << ans[i] << ' ';
	cout << endl;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  if(n==2) {
    cout << -1 << endl;
    return 0;
  }
  int a[n];
  for(int i=0; i<n; i++) a[i]=i+1;
  for(int i=0; i<n; i++) {
    rotate(a,a+1,a+n);
    if(n%2==0&&i>=n/2) swap(a[n/2-1],a[n/2]);
    for(int j=0; j<n-1; j++) {
      if(j) cout << " ";
      cout << a[j];
    }
    cout << endl;
    if(n%2==0&&i>=n/2) swap(a[n/2-1],a[n/2]);
  }
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct Dice{
private:
	static const int _roll[4][6], _turn[2][6];
public:
	vector<int> value;
	// 1-6 : top, near, right, left, far, bottom 

	Dice(){
		value.resize(6);
		for (int i = 0; i < 6; ++i) value[i] = i;
	}

	void roll(int dir){ // N, E, W, S
		vector<int> nxt(6);
		for (int i = 0; i < 6; ++i){
			nxt[i] = value[_roll[dir][i]];
		}
		value = nxt;
	}

	void turn(int dir){ // L, R
		vector<int> nxt(6);
		for (int i = 0; i < 6; ++i){
			nxt[i] = value[_turn[dir][i]];
		}
		value = nxt;
	}

	int &operator[](int i){
		return value[i];
	}
};

const int Dice::_roll[4][6] = {
	{ 1, 5, 2, 3, 0, 4 }, // North
	{ 3, 1, 0, 5, 4, 2 }, // East
	{ 2, 1, 5, 0, 4, 3 }, // West
	{ 4, 0, 2, 3, 5, 1 }, // South
};

const int Dice::_turn[2][6] = {
	{ 0, 3, 1, 4, 2, 5 }, // Left
	{ 0, 2, 4, 1, 3, 5 }, // Right
};

typedef pair<int, int> P;

int main(){	
	int n;

	int rdir[] = { 0, 3, 1, 2, 0 };
	int dx[] = { 0, 1, -1, 0};
	int dy[] = { 1, 0, 0, -1};
	while (cin >> n, n){
		P field[200][200];

		while (n--){
			int t, f;
			cin >> t >> f;
			Dice d;
			for (int i = 0; i < 6; ++i) d[i] = i + 1;
			if (d[2] == t || d[3] == t) d.turn(0);
			while (d[0] != t) d.roll(0);
			while (d[1] != f) d.turn(0);

			P pos = make_pair(100, 100);
			while (1){
				P dir = make_pair(-1, -1);
				for (int i = 1; i <= 4; ++i){
					int nx = pos.first + dx[rdir[i]], ny = pos.second + dy[rdir[i]];
					if(d[i] >= 4 && field[pos.second][pos.first].first > field[ny][nx].first) dir = max(dir, make_pair(d[i], rdir[i]));
				}
				if (dir.second < 0) break;
				d.roll(dir.second);
				pos.first += dx[dir.second];
				pos.second += dy[dir.second];
			}
			++field[pos.second][pos.first].first;
			field[pos.second][pos.first].second = d[0];
		}
		int cnt[7] = {};
		for (int i = 0; i < 200; ++i)for (int j = 0; j < 200; ++j){
			++cnt[field[i][j].second];
		}
		for (int i = 0; i < 6; i++) cout << (i ? " " : "") << cnt[i + 1];
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1524
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>

using namespace std;

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

  map<string, int> a;
  int max_num = 1;
  for (int i = 0; i < N; ++i)
  {
    string S;
    cin >> S;

    if (a.count(S) == 0)
    {
      a.insert(make_pair(S, 1));
    }
    else
    {
      ++a[S];
      if (a[S] > max_num) max_num = a[S];
    }
  }

  for (auto itr = a.begin(); itr != a.end(); ++itr)
  {
    if (itr->second == max_num) cout << itr->first << endl;
  }
}

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

using namespace std;

int main(void) {
	int n, x;
	vector<int> v;

	while (cin >> n >> x) {
		if (n == 0 && x == 0) {
			break;
		}

		int cnt = 0;
		for (int a = 1; a < n - 1; a++) {
			for (int b = a + 1; b < n; b++) {
				for (int c = b + 1; c <= n; c++) {
					if ((a + b + c) == x) {
						cnt++;
					}
				}
			}
		}
		v.push_back(cnt);
	}

	for (int i = 0; i < v.size(); i++) {
		cout << v[i] << endl;
	}

	return 0;
}

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

int main()
{
    long long h, w;
    scanf("%lld%lld", &h, &w);
    if (h % 3 == 0 || w % 3 == 0)
    {
        printf("0\n");
        return 0;
    }
    long long min{std::min(h, w)};
    for (int i = 1; i < h; i++)
    {
        long long min_table[3]{i * w, (h - i) * (w / 2), (h - i) * ((w + 1) / 2)};
        long long tmp_min = *std::max_element(min_table, min_table + 3) - *std::min_element(min_table, min_table + 3);
        min = std::min(min, tmp_min);
    }
    for (int i = 1; i < w; i++)
    {
        long long min_table[3]{i * h, (w - i) * (h / 2), (w - i) * ((h + 1) / 2)};
        long long tmp_min = *std::max_element(min_table, min_table + 3) - *std::min_element(min_table, min_table + 3);
        min = std::min(min, tmp_min);
    }
    printf("%lld\n", min);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
	int n;cin>>n;vector<int> a(n),b(n),c(n);
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++) cin>>b[i];
	for(int i=0;i<n;i++) cin>>c[i];
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	ll ans=0;

	for(int i=0;i<n;i++){
		ll al,cl;
		auto itera=lower_bound(a.begin(),a.end(),b[i]);
		if(itera==a.end()) al=n;
		else al=distance(a.begin(),itera);

		auto iterc=upper_bound(c.begin(),c.end(),b[i]);
		if(iterc==c.end()) cl=0;
		else cl=n-distance(c.begin(),iterc);

		ans+=al*cl;
	}
	cout<<ans<<endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string s;
    cin >> s;
    if (s[0] == s[2])
        OP("Yes");
    else
        OP("No");
        
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	int n; cin >> n;
	vector<ll> A(101010, 0);
	ll S = 0;
	for (int i=0; i<n; i++) {
		ll a; cin >> a;
		S += a;
		A[a]++;
	}
	int q; cin >> q;
	for (int i=0; i<q; i++) {
		ll b, c; cin >> b >> c;
		S = S - b * A[b] + c * A[b];
		A[c] += A[b];
		A[b] = 0;
		cout << S << endl;
	}

	return 0;
}

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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000001)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  int H,W,N,sy,sx;
  string S,T;
  cin >> H >> W >> N >> sy >> sx >> S >> T;
  int dpx[200010];
  int dpy[200010];
  int X=sx;
  int Y=sy;
  rep(i,N){//right,down

    //takahashi
    if(S[i]=='R')X++;
    if(S[i]=='D')Y++;

    //hantei
    if(X>W || Y>H){
      cout << "NO" << endl;
      return 0;
    }

    //aoki
    if(T[i]=='L' && X>1)X--;
    if(T[i]=='U' && Y>1)Y--;
  }

  X=sx;
  Y=sy;
  
  rep(i,N){//up,left

    //takahashi
    if(S[i]=='L')X--;
    if(S[i]=='U')Y--;

    //hantei
    if(X<1 || Y<1){
      cout << "NO" << endl;
      return 0;
    }

    //aoki
    if(T[i]=='R' && X<W)X++;
    if(T[i]=='D' && Y<H)Y++;
  }
  

  cout << "YES" << endl;
}

Measured memory_bytes: 776
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static string ReadLine() { return Console.ReadLine(); }
    static int ReadInt() { return int.Parse(ReadLine()); }
    static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return ReadLine().Split(); }


    static float Scala(float a, float b, float c, float d) {
        return a * d - b * c;
    }

    // ax + by = c
    // dx + ey = f
    static void Calc(float a, float b, float c, float d, float e, float f) {
        var nume = Scala(a, b, d, e);

        var xd = Scala(c, b, f, e);
        var yd = Scala(a, c, d, f);

        var x = xd / nume;
        var y = yd / nume;
        Console.WriteLine("{0:f3} {1:f3}", x, y);
    }

    static void Main() {
        string s;
        while ((s = ReadLine()) != null) {
            var xs = s.Split().Select(int.Parse).ToArray();
            Calc(xs[0], xs[1], xs[2], xs[3], xs[4], xs[5]);
        }
    }
}

Measured memory_bytes: 9568
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD =  1000000007;
const int INF = 1e11;
using Graph = vector<vector<int>>;

signed main(){
  string S;
  cin >> S;
  if( S.back() == 's' ) cout << S << "es" << endl;
  else cout << S << "s" << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define W while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007
#define mp make_pair

  int main()
  {
     string s,t;
     cin>>s;
     cin>>t;
     ll len1,len2,count=0,i;
     len1=s.size();
     len2=t.size();
     for(i=0;i<len1;i++)
     {
         if(s[i]==t[i])
         count++;
     }
     if(count==len1)
     cout<<"Yes";
     else
     cout<<"No";
        }

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define BITSEARCH(i,n) for(int i=0;i<(1<<(n));++i)
#define BITCHK(i,j) (i) & (1<<(j))

/* BITSEARCH 使い方
 
BITSEARCH(i,n){
  vector<int> h;
  REP(j,n){
    if (BITCHK(i,j)){
      h.push_back(j+1);
    }
  }
}

*/

using namespace std;

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
  int64_t n,d;
  cin >> n >> d;
  vector<vector<int>> vec(n, vector<int>(d));
  REP(i,n){
    REP(j,d){
      cin >> vec.at(i).at(j);
    }
  }
  int t=0;
  REP(i,n){
    REP(j,n){
      if (i!=j){
        double js = 0;
        REP(k,d){
          js += pow(abs(vec.at(i).at(k) - vec.at(j).at(k)),2);
        }
        js = sqrt(js);
        if (ceil(js) == floor(js)){
          t++;
        }
      }
    }
  }
  cout << t/2 << endl;
  return 0;
}



Measured memory_bytes: 256
n = int(input())
list_A = list(map(int, input().split()))
list_B = list(map(int, input().split()))

ans = 0
re = 0

for i in range(n):
    if list_A[i] - list_B[i] - re >= 0:
        ans += list_B[i] + re
        re = 0
    else:
        ans += list_A[i]
        if list_A[i]-re >= 0:
            re = re + list_B[i] - list_A[i]
        elif list_A[i]-re < 0:
            re = list_B[i]


if list_A[n]-re >= 0:
    ans += re
else:
    ans += list_A[n]

print(ans)

Measured memory_bytes: 18476
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,p[256],d=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  sort(p,p+n,greater<int>());
  p[0]=p[0]/2;
  for(int i=0;i<n;i++){
    d+=p[i];
  }
  cout<<d<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define ll long long 
#define f(i, a, b) for(ll i=a;i<b;i++)
#define fi(i, a, b) for(ll i=b-1;i>=a;i--)
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define ml map<ll,ll> 

void solve()
{
   ll n;
   cin>>n;
   ll a[n];
   f(i,0,n)cin>>a[i];
   ll dp[n+1][n+1];
   f(i,0,n+1)
   dp[i][0]=0,dp[0][i]=0;

   f(i,1,n+1)
   {
      dp[i][i] = a[i-1];
   }
   f(i,1,n)
   dp[i][i+1] = abs(a[i-1]-a[i]);
   fi(i,1,n-1)
   {
         f(j,i+2,n+1)
      {
         dp[i][j] = max(min(dp[i+2][j]+a[i-1]-a[i],dp[i+1][j-1]+a[i-1]-a[j-1]),min(dp[i+1][j-1]+a[j-1]-a[i-1],dp[i][j-2]+a[j-1]-a[j-2]));
      }
   }
   cout<<dp[1][n];
}

int main()
{
   ll t;
   t=1;
//    cin>>t;
   while (t--)
   {
       solve();
   }  
}

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

int main() {
  int N, H, W;
  cin >> N >> H >> W;
  
  int a[1000], b[1000];
  
  for (int i=0; i<N; i++) {
    cin >> a[i] >> b[i];
  }
  
  int count=0;
  
  for(int i=0; i<N; i++) {
    if (a[i] >= H && b[i] >= W) {
      count++;
    }
  }
  
  cout << count << endl;
  
  
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        // 主処理
        int result = (a - 1) * (b - 1);

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	static  long A, B, C, D;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a, b, c, d;
		a = sc.nextLong();
		b = sc.nextLong();
		c = sc.nextLong();
		d = sc.nextLong();

		long ans = f(b, c, d) - f(a - 1, c, d);
		System.out.println(ans);
	}

	static long f(long x, long c, long d) {
		long res = x;
		res -= x / c;
		res -= x / d;
		res += x / lcm(c, d);
		return res;
	}

	static long lcm(long a, long b) { return a / gcd(a, b) * b; }
	static long gcd(long m, long n) {
		if (m < n) return gcd(n, m);
		if (n == 0) return m;
		return gcd(n, m % n);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1e9+7;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

int main(){
    int N,K;
    cin>>N>>K;
    int count=0;
    while(N>0){
        N/=K;
        count++;
    }
    cout<<count<<endl;
    return 0;
}


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

main() {
    int N,T; cin >> N >> T;
    int ans=9999;
    rep(i,N){
        int a,b; cin >> a >> b;
        if(T>=b){ans=min(ans,a);}
    }
    if(ans==9999) cout << "TLE" << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <locale>

using namespace std;

int main() {
    string s;
    cin >> s;
    int q;
    cin >> q;
    string order;
    int left;
    int right;
    string replace_word;
    for(int i = 0; i < q; i++) {
        cin >> order >> left >> right;
        if(order == "replace") {
            cin >> replace_word;
            // cout << "repword: " << replace_word << endl;
            s.replace(left, right-left+1, replace_word);
            // cout << s << endl;
        } else if(order == "reverse") {
            string reverse_word = s.substr(left, right-left+1);
            // string left_character = s.substr(left, 1);
            // string right_character = s.substr(right, 1);
            // s.replace(left, 1, right_character);
            // s.replace(right, 1, left_character);
            reverse(reverse_word.begin(), reverse_word.end());
            // cout << "rev_word: " << reverse_word << endl;
            s.replace(left, right-left+1, reverse_word);
            // cout << s << endl;
        } else if(order == "print") {
            // cout << s << endl;
            cout << s.substr(left, right - left + 1) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3196
a, b, x = gets.chomp.split.map{|i| i.to_i }

na = 0; nb = 0
cost = 20000 * 1000  # cost_max

while na <= (x / 1000.0).ceil
    nb = ((x - 1000 * na) / 500.0).ceil
    if nb < 0 then nb = 0 end
    cost_tmp = a * na + b * nb
    cost = [cost_tmp, cost].min
    na += 1
end

puts cost


Measured memory_bytes: 6876