akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;
int y;

int main() {
	cin >> n >> y;
	rep(i, n + 1) {
		rep(j, n + 1) {
			int k = n - i - j;
			if (k >= 0) {
				if (10000 * i + 5000 * j + 1000 * k == y) {
					cout << i << " " << j << " " << k << endl;
					return 0;
				}
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define DEBUG2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << "\n"
#define DEBUG3(x, y, z)                                                        \
  cerr << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z  \
       << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair< int, int >
#define ld long double
using namespace std;
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;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
#define MAXQ 1000100
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int A, B;
  cin >> A >> B;

  vec< int > lp(MAXQ + 1, 0);
  vec< int > pr;
  lp[0] = 0, lp[1] = 1;
  FORS(i, 2, MAXQ) {
    if (!lp[i]) {
      lp[i] = -1;
      pr.pb(i);
      FORS(j, i, MAXQ / i) lp[i * j * 1ll] = i;
    }
  }
  //  DEBUG(count(lp.begin(), lp.begin() + 10001, -1));

  int res = gcd(A, B);
  vec< pint > lis;
  //  res==1の時lisは空！！
  FORA(val, pr) {
    int cnt = 0;
    while (res % val == 0) {
      res /= val;
      cnt++;
    }
    if (cnt)
      lis.pb(mp(val, cnt));
    if (res == 1)
      break;
  }
  if (res != 1)
    lis.pb(mp(res, 1));

  // FORA(e, lis) DEBUG2(e.fst, e.snd);
  print(lis.size() + 1);
}

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
# define ll  long long int
# define ld  long double
# define pb push_back
# define pp pop_back
# define ff first
# define ss second
# define mp make_pair
# define ac accumulate
# define mod 1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void solve(){
	int n,k;
	cin >> n >> k;
	int arr[n];
	for(int i = 0; i<n; i++)
		cin >> arr[i];
	sort(arr, arr + n);
	ll sum = 0;
	for(int i = 0; i <k; ++i)
		sum += arr[i];
	cout << sum;
}

int  main()
{
    #ifndef ONLINE_JUDGE
       freopen("input.txt", "r", stdin);
       freopen("output.txt", "w", stdout);
    #endif
     IOS;
     int t = 1;
     //cin >> t;
     while(t--){
     	solve();
     }
     return 0;
    
}

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

using namespace std;

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

  int cnt_b[200005] = {0};
  int cnt_w[200005] = {0};

  for (int i = 0; i < n; i++) {
    if (s[i] == '#') {
      cnt_b[i+1] = cnt_b[i] + 1;
      cnt_w[i+1] = cnt_w[i];
    } else {
      cnt_b[i+1] = cnt_b[i];
      cnt_w[i+1] = cnt_w[i] + 1;
    }
  }

  int ans = n;
  for (int i = 0; i <= n; i++) {
    int left_black = cnt_b[i]; // (0, i) に含まれる黒の個数
    int right_white = cnt_w[n]-cnt_w[i]; // [i, n+1) に含まれる黒の個数
    ans = min(ans, left_black + right_white);
  }
  cout << ans << endl;
  return 0;
}

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






#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   100007
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/




ll b[N];

int main()
{
    ll x,y,i,j,a,b;
    cin>>x>>y;
    if(x<10 && y<10)
        cout<<x*y<<endl;
    else
        cout<<-1<<endl;
    return 0;

}
































Measured memory_bytes: 256
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
// #define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()

int main(){
	int a,b; cin>>a>>b;
	ote(b%a? b-a: b+a);
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vii> vvii;

#define fastIO ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define forw(i,l,r) for(int i=(l);i<(r);i++)
#define forb(i,r,l) for(int i=(r);i>(l);i--)
#define log2i(x) 32 - __builtin_clz((x)) - 1
#define log2ll(x) 64 - __builtin_clzll((x)) - 1
#define Pi acos(-1.0)
#define sz(x) (int)x.size()
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

const int N = 407;
int n;
ll f[N]={0}, dp[N][N];

int main() {
#ifndef ONLINE_JUDGE
    //freopen("test.inp","r",stdin);
    //freopen("test.out","w",stdout);
#endif
    fastIO;
    cin >> n;
    forw(i,0,n) {
        int x;
        cin >> x;
        f[i+1]=f[i]+x;
        dp[i+1][i+1]=0;
    }
    forw(i,1,n+1) {
        forw(l,0,n-i) {
            int r=l+i+1;
            dp[l+1][r]=1e18;
            forw(j,l,r) dp[l+1][r]=min(dp[l+1][r],dp[l+1][j+1]+dp[j+2][r]);
            dp[l+1][r]+=f[r]-f[l];
        }
    }
    cout << dp[1][n];
    return 0;
}


Measured memory_bytes: 1536
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k;
    cin >> k;
    ll seven = 0;
    int ans = 1;
    while(ans <= 10000000){
        seven = (seven * 10 + 7) % k;
        if(seven == 0){
            cout << ans << endl;
            return 0;
        }
        ++ans;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
int main(void){
   int a = 0;
   int b = 0;
   scanf("%d %d",&a,&b);
   if(a > b){
    printf("a > b\n");
   }
   else if(a < b){
    printf("a < b\n");
   }
   else{
    printf("a == b\n");
   }
    return 0;
}

Measured memory_bytes: 580
#include <stdio.h>

#define NIL -1

struct Node{
  int parent;
  int left;
  int right;
};

struct Node L[100005];
int n;
int data[100005];


int dep( int o, int u)
{
  data[o] = u;
  if( L[o].right != NIL )dep(L[o].right, u);
  if( L[o].left != NIL )dep(L[o].left, u+1);
}

void print(int o)
{
  int i;
  int z;
  
    printf("node %d: parent = %d, depth = %d,",o,L[o].parent,data[o]);
    if( L[o].parent == NIL )printf(" root, ");
    else if( L[o].left == NIL )printf(" leaf, ");
    else printf(" internal node, ");
    printf("[");
    
for( i = 0 , z = L[o].left ; z != NIL ; i++, z = L[z].right){
  if(i) printf(", ");
  printf("%d",z);
 }
 
 printf("]");
 printf("\n");
}


int main()
{
int i,n,j,d,r,l,c,v;
  scanf("%d",&n);
  for( i = 0 ; i < n ; i++)
    L[i].parent = L[i].left = L[i].right = NIL;
  
  for( i = 0 ; i < n ; i++){
    scanf("%d%d",&v,&d);
    for( j = 0; j < d; j++){
      scanf("%d",&c);
      if( j == 0 )L[v].left = c;
      else L[l].right = c;
      l = c;
      L[c].parent = v;
    }
  }
  for( i = 0 ; i < n ; i++){
    if(L[i].parent == NIL) r=i;
  }

  dep(r,0);
  for( i = 0 ; i < n ; i++)print(i);

  return 0;
}



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

int main() {
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) cin >> X[i][j];
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
        int tmp = 0;
            for (int k = 0; k < D; k++) {
            tmp += abs(X[i][k] - X[j][k]) * abs(X[i][k] - X[j][k]);
        }
        for (int k = 1; k <= tmp; k++) {
            if (tmp == k * k) {
                ans++;
                break;
            }
        }
        }
    }

    cout << ans << endl;
}

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

const static double pi = acos(-1);

int main() {
  int a, b, x;
  scanf("%d %d %d", &a, &b, &x);

  double t = 2.0 * x / (a * a) - b, ans = 0;
  if (t >= 0) {
    ans = atan((b - t) / a) / pi * 180;
  }
  else {
    t = 2.0 * x / (a * b);
    ans = atan(b / t) / pi * 180;
  }
  
  printf("%lf\n", ans);

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
const int maxn = 300005;
const int mod = 998244353;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    s[1] = 'B' + 'R' - s[1];
    cout << s << endl;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>

#define SIZE 1000000007
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 
using namespace std;


int main()
{	
	ll N;
	scanf("%lld", &N);
	ll x[N];
	
	for(ll i=0;i<N;i++){
		scanf("%lld", &x[i]);
	}
	ll kai[N];
	kai[0]=1;
	for(ll i=1;i<N;i++){
		kai[i]=kai[i-1]*i;
		kai[i]=kai[i] % SIZE;
	}
	
	ll answer=0;
	ll np=1;
	for(ll i=1;i<N;i++){
		answer=answer+kai[i-1]*(x[N-1]-x[i-1]);
		answer=answer % SIZE;
		if(i!=N-1)
		{answer=answer*(i+1);
		 answer=answer % SIZE;
		}
	
	}
	
	printf("%lld", answer);
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
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;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

int main() {
  LL N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;

  N--;
  LL target = B - A;
  LL diff = D - C;
  bool ok = false;
  for (LL i = 0; i <= N; i++) {
    LL j = N - i;

    LL minim = -D * i + C * (N - i);
    LL maxim = minim + diff * N;
    if (minim <= target && target <= maxim) ok = true;
  }
  cout << (ok ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

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

ordered_set<ll> ors;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

void solve(ll tt) {
    ll h,w,k;
    cin>>h>>w>>k;
    string s[h];
    repf(i,0,h) cin>>s[i];
    ll ans=0;
    repf(i,0,(1<<h)) {
        repf(j,0,(1<<w)) {
            ll c=0;
            repf(i1,0,h) {
                if(!(i&(1<<i1))) continue;
                repf(j1,0,w) {
                    if(!(j&(1<<j1))) continue;
                    if(s[i1][j1]=='#') c++; 
                }
            }
            if(c==k) ans++;
        }
    }
    cout<<ans<<endl;
}

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    repf(tt,1,t+1) {
        solve(tt);
    }
}     

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

namespace A {
    class Program {
        static void Main(string[] args) {
            int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).OrderBy(x => x).ToArray();

            int score = Math.Abs(A[0] - A[1]) + Math.Abs(A[1] - A[2]);

            Console.WriteLine(score);
        }
    }
}


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

namespace ABC110
{
    class C
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            int[] start = new int[26].Select(x => -1).ToArray();
            int[] goal = new int[26].Select(x => -1).ToArray();

            for (int i = 0; i < S.Length; i++)
            {
                int a = S[i] - 'a';
                int b = T[i] - 'a';

                if (start[a] != -1 || goal[b] != -1)
                {
                    if (start[a] != b || goal[b] != a)
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
                start[a] = b;
                goal[b] = a;
            }
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 14688
import sys
X,N =  map(int,input().split())
if N == 0:
  print(X)
  sys.exit()
p = list( map(int,input().split()))
gans = X
gx = X
lans = X
lx = X
for i in range(100+1):
  if gx not in p:
    gans = gx
    break
  else:
    gx += 1
for i in range(100+1):
  if lx not in p:
    lans = lx
    break
  else:
    lx -= 1

if abs(X-gans) < abs(X-lans):
  print(gans)
else:  
  print(lans)  

Measured memory_bytes: 9212
#include <iostream>
#include <fstream>
#include <ctime>
#include <climits>
#include <functional>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cassert>
using namespace std;
struct UnionFind {
    vector<int> par, sz;
    int n_tree;

    explicit UnionFind(int n) : par(n), sz(n, 1), n_tree(n) { //0-indexed
        iota(par.begin(), par.end(), 0);
    }

    int n_cluster() const {
        return n_tree;
    }

    int size(int x) {
        return sz[root(x)];
    }

    int root(int x) {
        return x == par[x] ? x : par[x] = root(par[x]);
    }

    bool unite(int x, int y) {
        int rx = root(x), ry = root(y);
        if (rx != ry) {
            par[rx] = ry;
            --n_tree;
            sz[ry] += sz[rx];
            return true;
        }
        return false;
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    bool is_root(int x) const {
        return par[x] == x;
    }
};
int main() {
#ifdef LOCAL
    ifstream in("in.txt");
    cin.rdbuf(in.rdbuf());
#endif
    //仿tourist的做法
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    vector<vector<int>> g(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u;
        --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<int> c(n);
    iota(c.begin(), c.end(), 0);
    sort(c.begin(), c.end(), [&](int x, int y) {return a[x] - b[x] < a[y] - b[y]; });
    vector<long long> sum_b(n);
    // ans[i]：子树i的最优解
    vector<bool> done(n, false);
    vector<long long> ans(n);
    for (int i = 0; i < n; ++i) {
        ans[i] = max(a[i], b[i]);
        sum_b[i] = b[i];
    }
    vector<bool> added(n, false);
    UnionFind uf(n);
    for (auto v : c) {
        vector<int> s;
        for (auto u : g[v]) {
            if (done[u]) {
                //并查集用来查找子树的根
                u = uf.root(u);
                if (!added[u]) {
                    sum_b[v] += sum_b[u];
                    added[u] = true;
                    //s里存的是子树的根
                    s.push_back(u);
                }
            }
        }
        //cout << v << ' ' << sum_b[v] << endl;
        if (!s.empty()) {
            long long best = LLONG_MAX;
            for (auto u : s) {
                long long sum_b_without = sum_b[v] - sum_b[u];
                long long cur = max(sum_b_without + ans[u], sum_b_without + a[v] - b[v]);
                best = min(best, cur);
                uf.unite(u, v);
            }
            ans[v] = best;
        }
        done[v] = true;
        //assert(uf.root(v) == v);
    }
    //for (int i = 0; i < n; ++i) {
    //    cout << c[i] << ' ' << sum_b[c[i]] << ' ' << ans[c[i]] << endl;
    //}
    cout << ans[c[n - 1]] << '\n';
#ifdef LOCAL
    cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}

Measured memory_bytes: 9852
'use strict';
function main(input) {
  const arr = input.trim().split(' ');
  const a = Number(arr[0]);
  const b = Number(arr[1]);
  const c = Number(arr[2]);

  if (a + b < c) {
    console.log('0','0');
  } else if (a < c) {
    console.log(`${0} ${a + b - c}`);
  } else {
    console.log(`${a - c} ${b}`);
  }
  
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
/*
AizuOnline A2501
Title grid mori
*/
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
//
int n,a,b,c,d;

main()
{
  int i,i2;
  int minval,sum;

  while(EOF!=scanf("%d ",&n))
    {
      scanf("%d %d ",&a,&b);
      scanf("%d %d ",&c,&d);
      a--;b--;c--;d--;        //caution convert 1base=> zero base
      minval=INT_MAX;
      for(i=1;i<=n;i++)
	{
	  sum = abs((a % i)-(b % i));
	  sum += abs((a / i)-(b / i));
	  sum += abs((c % i)-(d % i));
	  sum += abs((c / i)-(d / i));
	  if(sum < minval)
	    {
	      minval = sum;
	      i2=i;
	    }
	}
      printf("%d\n",minval);
      //printf("(%d) \n",i2);
    }
return(0);
}

Measured memory_bytes: 600
// ABC_167_D

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

int main()
{
	ll n, k;
	cin >> n >> k;

	vector<ll> v(n, 0);
	for(ll i = 0; i < n; ++i) {
	cin >> v.at(i);
	--v[i];
	}

	set<int> s_used;
	vector<int> v_path;

	int now = 0;

	while(s_used.count(now) == 0) {
		v_path.push_back(now);
		s_used.insert(now);
		now = v[now];
	}

	// ???
	int s = find(v_path.begin(), v_path.end(), now) - v_path.begin();
	int r = (int)v_path.size() - s;

	//cout << s << " " << r << "\n";

	if(s >= k) cout << v_path[k] + 1 << "\n";
	else {
		cout << v_path[(k - s) % r + s] + 1 << "\n";
	}

	return 0;
}

Measured memory_bytes: 14684
import java.util.*;class Main{public static void main(String[]z){for(Scanner s=new Scanner(System.in);s.hasNext();){String t=s.nextLine();z=" :101:':000000:,:000011:-:10010001:\\.:010001:\\?:000001:A:100101:B:10011010:C:0101:D:0001:E:110:F:01001:G:10011011:H:010000:I:0111:J:10011000:K:0110:L:00100:M:10011001:N:10011110:O:00101:P:111:Q:10011111:R:1000:S:00110:T:00111:U:10011100:V:10011101:W:000010:X:10010010:Y:10010011:Z:10010000".split(":");int i,j;for(i=0;i<z.length;)t=t.replaceAll(z[i++],z[i++]);t+="0000";for(i=0;i+4<t.length();System.out.print((char)j)){j=Integer.parseInt(t.substring(i,i+=5),2)+65;if(j>90)j=new int[]{32,46,44,45,39,63}[j-91];}System.out.println();}}}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
string a,b;
main(){
cin>>a>>b;
for(int k=0;k<a.size();k++){
    if(a[k]!=b[k]){
    cout<<"No";
    return 0;
    }
}
cout<<"Yes";
return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

int main(){
  string S;
  cin >> S;
  ll count = 0;
  ll N;
  N = S.length();
  
  rep(i,N){
    if(i%2==0 && (S[i]=='R' || S[i]=='U' || S[i]=='D')) count++;
    else if(i%2==1 && (S[i]=='L' || S[i]=='U' || S[i]=='D')) count++;
  }
  if(count==N) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 int ans(unordered_map<int,vector<int>>& graph,int s,vector<int>& dp){
     if(graph.find(s)==graph.end()){
         return 0;
     }
     if(dp[s]!=-1){
         return dp[s];
     }
     int x = 0;
     for(int i=0;i<graph[s].size();i++){
         x = max(x,ans(graph,graph[s][i],dp));
     }
     return dp[s] = x+1;
 }
int main() {
	int n,m;
	cin>>n>>m;
	unordered_map<int,vector<int>> graph;
	for(int i=0;i<m;i++){
	    int a,b;
	    cin>>a>>b;
	    graph[a].push_back(b);
	}
	vector<int> dp(n+1,-1);
	int mx = 0;
	for(int i=1;i<=n;i++){
	    if(dp[i]!=-1){
	        mx = max(mx,dp[i]);
	    }
	    else{
	        mx = max(mx,ans(graph,i,dp));
	    }
	}
	cout<<mx<<'\n';
 
}

Measured memory_bytes: 12196
#include<bits/stdc++.h>
using namespace std;
int main(){
string S;
  cin>>S;
  int N=S.size();
  string ans="Yes";
  for(int i=0;i<=(N-3)/2;i++){
    if(S.at(i)!=S.at(N-i-1)||S.at(i)!=S.at((N-3)/2-i)){
      ans="No"; break;
  
    }
  } cout<<ans<<endl;


 return 0;
}

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4 5 3");
            WillReturn.Add("8");
            WillReturn.Add("7");
            WillReturn.Add("4");
            WillReturn.Add("2");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("2 10 4");
            WillReturn.Add("20");
            WillReturn.Add("20");
            //4
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("5 2 1");
            WillReturn.Add("900000000");
            WillReturn.Add("900000000");
            WillReturn.Add("1000000000");
            WillReturn.Add("1000000000");
            WillReturn.Add("1000000000");
            //800000000
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static long mA;
    static long mB;
    static long[] mHArr;

    static void Main()
    {
        List<string> InputList = GetInputList();
        long[] wkArr = InputList[0].Split(' ').Select(X => long.Parse(X)).ToArray();

        mA = wkArr[1];
        mB = wkArr[2];

        mHArr = InputList.Skip(1).Select(X => long.Parse(X)).ToArray();
        //降順にソートしておく
        Array.Sort(mHArr, (A, B) => B.CompareTo(A));

        Console.WriteLine(ExecNibunHou());
    }

    //2分法で何回の爆発が必要かを調べる
    static long ExecNibunHou()
    {
        long L = 0;
        long R = mHArr.Sum(X => X / mA + 1);

        while (L + 1 < R) {
            long Mid = (L + R) / 2;

            bool IsOK = DeriveIsOK(Mid);
            if (IsOK) R = Mid;
            else L = Mid;
        }
        return R;
    }

    //K回の爆発でOKかを返す
    static bool DeriveIsOK(long pK)
    {
        //爆発回数
        long BakuhatuCnt = 0;

        //余波の合計
        long YohaSum = pK * mB;

        foreach (long EachH in mHArr) {
            long RestH = EachH - YohaSum;
            if (RestH <= 0) break;

            long wkDiff = mA - mB;
            long CurrBakuhatuCnt = RestH / wkDiff;
            if (EachH % wkDiff > 0) CurrBakuhatuCnt++;

            BakuhatuCnt += CurrBakuhatuCnt;
            if (BakuhatuCnt > pK) return false;
        }
        return true;
    }
}


Measured memory_bytes: 27740
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
int main() {
	ll k;
	cin>>k;
	if(k%2==0) {
		cout<<-1;
		return 0;
	} else {
		bool flag=1;
		int count=0;
		ll temp = k;
		while(temp) {
			int rem = temp%10;
			if(rem!=7) {
				flag=0;
				break;
			} else {
				count++;
			}
			temp/=10;
		}
		if(flag) {
			cout<<count;
			return 0;
		}
	}
	ll num = 7, mul = 10,len = 1;
	while(num<=k) {
		num+=(7*mul);
		mul*=10;
		len++;
	}
	debug()<<imie(num);
	set<int> used;
	while(true) {
		ll rem = num%k;
		if(rem==0) {
			debug()<<imie(num);
			cout<<len;
			return 0;
		}
		if(used.find(rem)==used.end()) {
			used.insert(rem);
		} else {
			cout<<-1;
			return 0;
		}
		
		num = (rem*10)+7;
		len++;
	}
}


Measured memory_bytes: 50460
fun main(args: Array<String>) {

    val (a, b) = readLine()!!.split(" ").map { it.toInt() }

    // 差込口の数
    var plugs = 1
    
    // 電源タップの個数
    var taps = 0

    // 差込口がb個以上になるまで電源タップを増やす
    while(plugs < b){
        taps++
        plugs = plugs - 1 + a
    }

    println(taps)
}

Measured memory_bytes: 38000
#include <iostream>
#include <stdint.h>
#include <vector>
#include <limits.h>
#include <utility>

using namespace std;
const int mod = 1000000007;

typedef struct LEGE {
  int64_t le;
  int64_t ge;
} LEGE;

LEGE find_nearest(int64_t x, vector<int64_t>& ST)
{
  LEGE ans;
  auto it = lower_bound(ST.begin(), ST.end(), x);
  ans.ge = (it!=ST.end()) ? *it : 0;
  if (ans.ge == x)
    ans.le = x;
  else
    ans.le = (it!=ST.begin()) ? *(it-1) : 0;
  return ans;
}

int main()
{
  int A,B,Q;
  cin >> A >> B >> Q;

  vector<int64_t> S, T;
  for (int a=0; a<A; ++a) {
    int64_t s;
    cin >> s;
    S.push_back(s);
  }

  for (int b=0; b<B; ++b) {
    int64_t t;
    cin >> t;
    T.push_back(t);
  }

  for (int q=0; q<Q; ++q) {
    int64_t x;
    cin >> x;

    //cerr << x << endl;
    
    auto s_lege = find_nearest(x,S);
    auto t_lege = find_nearest(x,T);
    int64_t s_le = s_lege.le, s_ge = s_lege.ge;
    int64_t t_le = t_lege.le, t_ge = t_lege.ge;

    //cerr << "s_le:" << s_le << " s_ge:" << s_ge << " t_le:" << t_le << " t_ge:" << t_ge << endl;

    int64_t cost_min = INT64_MAX;

    // s_le and t_le
    if (s_le > 0 && t_le > 0) {
      cost_min = min(cost_min,(s_le > t_le) ? x - t_le : x - s_le);
    }
    // s_le and t_ge
    if (t_ge > 0 && s_le > 0) {
      cost_min = min(cost_min,t_ge - s_le + min(t_ge-x,x-s_le));
    }
    // t_le and s_ge
    if (s_ge > 0 && t_le > 0) {
      cost_min = min(cost_min,s_ge - t_le + min(s_ge-x,x-t_le));
    }
    // s_ge and t_ge
    if (s_ge > 0 && t_ge > 0) {
      cost_min = min(cost_min,(s_ge > t_ge) ? s_ge - x : t_ge - x);
    }

    cout << cost_min << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3060
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll num=1e9+7;
ll mod(ll n)
{
    return (n%num+num)%num;
}
ll add(ll x,ll y)
{
    return mod(mod(x)+mod(y));
}
ll mult(ll x,ll y)
{
    return mod(mod(x)*mod(y));
}
ll sub(ll x,ll y)
 {
     return mod(mod(x)-mod(y));
 }
 ll pt(ll n,ll p)
 {
      if(p==0)
       return 1;
       if(p==1)
        return n%num;
        ll t=pt(n,p/2);
        if(p%2==0)
         return mult(t,t);
         else
          return mult(n,mult(t,t));
 }
 void solve()
 {
    bool ok=false;
    ll n;
    ll ct=0;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        if(x==y)
        {
            ct++;
            if(ct==3)
             ok=true;
        }
        else
         ct=0;
    }
    if(ok)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
      
 }
int main(){
   ll t;
   t=1;
   while(t--)
   {
       solve();
   }
    
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if (s < t) {
        cout << "Yes"
             << "\n";
    } else {
        cout << "No"
             << "\n";
    }
    return 0;
}

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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e18+9
#define N 100010
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll result(ll a, ll b, ll p){
    ll ans=1;
    if(b==(-1))
        b=p-2;
    while(b){
        if(b&1){
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}

ll T,n,m;

int main(){
	if(fopen("input.txt", "r"))
	freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n , k;
    cin >> n >> k;
    ll p = inf;
    map<ll,ll>m;
    n %= k;
    ll d = 1000000;
    while(d--){
    	m[n]++;
    	p = min(p,n);
    	n = (abs(n-k))%k;
    }
    cout << p ;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

int main(void) {

  string s;
  cin >> s;

  int n = s.size();

  bool f = true;
  for (int i = 1; i <= n; i++) {
    if (s[i - 1] != s[n + 1 - i - 1]) {
      cout << "No\n";
      return 0;
    }
  }
  for (int i = 1; i <= (n - 1)/2; i++) {
    if (s[i - 1] != s[(n + 1)/2 - i - 1]) {
      cout << "No\n";
      return 0;
    }
  }
  for (int i = (n + 3)/ 2; i <= n; i++) {
    if (s[i - 1] != s[(3 * n + 3)/2 - i - 1]) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";



  

  return 0;

}


Measured memory_bytes: 256
import sys

def main():
    line = sys.stdin.readline()
    lst = line.split(' ')
    a = int(lst[0])
    b = int(lst[1])
    n = min(a,b)
    m = max(a,b)

    if (m == n+1):
    #n! * m!

        ans = 1
        for i in range(1,n+1):
            ans = (ans * i) % 1000000007

        for i in range(1,m+1):
            ans = (ans * i) % 1000000007

        print(ans)
    elif (m == n):
        ans = 2
        for i in range(1,n+1):
            ans = (ans * i) % 1000000007

        for i in range(1,m+1):
            ans = (ans * i) % 1000000007
        print(ans)
    else:
        print(0)
    return 0

if __name__ == '__main__':
    sys.exit(main())


Measured memory_bytes: 3064
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll h,w,s,t;
    cin>>h>>w>>s>>t;
    if(h==1){
        cout<<((t==1 || t==w)?"Yes":"No")<<endl;
        return 0;
    }
    if(w==1){
        cout<<((s==1 || s==h)?"Yes":"No")<<endl;
        return 0;
    }
    if(h%2==0 || w%2==0){
        cout<<"Yes"<<endl;
        return 0;
    }
    if((s&1)==(t&1)){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    
    
    
    
    
    
    return 0;
}



Measured memory_bytes: 3068
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.text.DecimalFormat;

public class Main{
    public static void main(String[] args) throws Exception {
        //入力されたマス目を用意する
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = 0;
   
        String strn = br.readLine();//キャンバスの数入力
        //入力された文字を分解
        int w = 0;
        int j = 0;

        if(strn.length() == 3){
        w = Character.getNumericValue(strn.charAt(0));
        j = Character.getNumericValue(strn.charAt(2));
        }else{
        w = Integer.parseInt(strn.substring(0,strn.length()/2));
        j = Integer.parseInt(strn.substring(strn.length()/2+1,strn.length()));
        }

        String canvas[][] = new String[w][j];
        //wの数だけキャンバス入力
        for(int i = 0;i < w;i++){

        String strCanvasLine = br.readLine();//キャンバスの数入力
            //配列に格納
            for(int x = 0;x<j;x++){
                canvas[i][x] = String.valueOf(strCanvasLine.charAt(x));
            }
        }

       
        
        //上下左右に１つでも＃があるのか網羅
        for(int wline = 0 ; wline < w ; wline++){
            for(int jline=0 ; jline < j ; jline++){
                if(canvas[wline][jline].equals("#")){//黒に塗りたい場所
                        boolean near = true;
                       //上下左右に場所があるかを確認
                        if(!(wline == 0)){//上がある
                            if(!(canvas[wline-1][jline].equals("#"))){
                                //上に黒がない
                                near = false;
                            }else{//上に黒がある
                                continue;
                            }
                        }

                        if(!(wline == w-1)){//下がある
                            if(!(canvas[wline+1][jline].equals("#"))){
                                //下に黒がない
                                near = false;
                            }else{//上に黒がある
                                continue;
                            }
                        }

                        if(!(jline == 0)){//左がある
                            if(!(canvas[wline][jline-1].equals("#"))){
                                //左に黒がない
                                near = false;
                            }else{//上に黒がある
                                continue;
                            }
                        }

                        if(!(jline == j-1)){//右がある
                            if(!(canvas[wline][jline+1].equals("#"))){
                                //右に黒がない
                                near = false;
                            }else{//上に黒がある
                                continue;
                            }
                        }

                        if(!(near)){
                            System.out.println("No");
                            System.exit(0);
                        }
                }
            }

        }

        System.out.println("Yes");
    }

}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    long long cnt=0;
    string S;
    cin >> N >> S;
    vector<int> r;
    vector<int> g;
    vector<int> b;
    for(int i = 0; i < N; i++){
        if(S.at(i)=='R'){
            r.push_back(i);
        }
        if(S.at(i)=='G'){
            g.push_back(i);
        }
        if(S.at(i)=='B'){
            b.push_back(i);
        }
    }
    for(int i = 1; i < N; i++){
        for(int j = 0; j < N; j++){
            if(j+i+i >= N){
                break;
            }
            if(S[j]!=S[j+i] && S[j]!=S[j+i+i] && S[j+i]!=S[j+i+i]){
                cnt++;
            }
        }
    }
    long long ans = r.size() * g.size() * b.size() - cnt;
    cout << ans << endl;
}

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

int main(){
  int n;  cin >> n;
  map<string, int> key;
  for(int i=0; i<n; i++){
    string s; cin >> s;
    key[s] += 1;
  }
  cin >> n;
  for(int i=0; i<n; i++){
    string s; cin >> s;
    key[s] -= 1;
  }
  int ans=0;
  for(auto x: key) ans = max(ans, x.second);
  cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define REP(i, start, end) for (int i = start, i##Len = (end); i < i##Len; ++i)
#define REPR(i, start, end) for (int i = start, i##Len = (end); i > i##Len; --i)
using ll = long long;
using namespace std;

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

    int N;
    cin >> N;
    map<int, vector<pair<int, int>>> RL, UD, UR, RD, DL, LU;
    int X, Y;
    char U;
    REP(i, 0, N)
    {
        cin >> X >> Y >> U;
        if (U == 'R' || U == 'L')
            RL[Y].emplace_back(X, U == 'R' ? 0 : 1);
        else
            UD[X].emplace_back(Y, U == 'U' ? 0 : 1);
        if (U == 'U' || U == 'R')
            UR[X + Y].emplace_back(Y, U == 'U' ? 0 : 1);
        if (U == 'R' || U == 'D')
            RD[Y - X].emplace_back(X, U == 'R' ? 0 : 1);
        if (U == 'D' || U == 'L')
            DL[X + Y].emplace_back(-Y, U == 'D' ? 0 : 1);
        if (U == 'L' || U == 'U')
            LU[X - Y].emplace_back(-X, U == 'L' ? 0 : 1);
    }

    int inf = 1e9, ans = 1e9;

    auto solve = [&](map<int, vector<pair<int, int>>> &mp, int mul) {
        for (auto &[key, vec] : mp)
        {
            sort(vec.begin(), vec.end());
            REP(i, 0, vec.size() - 1)
            if (vec[i].second == 0 && vec[i + 1].second == 1)
            {
                ans = min(ans, abs(vec[i].first - vec[i + 1].first) * mul);
            }
        }
    };

    solve(RL, 5);
    solve(UD, 5);
    solve(UR, 10);
    solve(RD, 10);
    solve(DL, 10);
    solve(LU, 10);

    if (ans == inf)
        cout << "SAFE" << endl;
    else
        cout << ans << endl;
}

Measured memory_bytes: 68428
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (typeof((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(typeof(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}


int high[150];

int main() {
    //freopen( "/Users/macuser/Documents/Programming/Contest/input.in", "r", stdin );
    
    int t, n;
    cin >> t;
    for (int i = 0; i < t; ++i) {
        cin >> n;
        memset(high, 0, sizeof(high));
        for (int j = 0; j < n; ++j) {
            cin >> high[j];
        }
        
        int inc = 0, dec = 0;
        for (int j = 0; j < n-1; ++j) {
            if (high[j] > high[j+1]) dec = max(dec, high[j] - high[j+1]);
            else inc = max(inc, high[j+1] - high[j]);
        }
        
        cout << inc << " " << dec << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
#define P pair<int,int>
typedef long long ll;
using namespace std;

int main(){
    int n,m; cin >> n >> m;
    vector<P> key(m);
    rep(i,m){
        int a,b; cin >> a >> b;
        key[i].second=a;
        int next=0;
        rep(j,b){
            int c; cin >> c;
            next+=(int)pow(2,c-1);
        }
        key[i].first=next;
    }

    int li=(int)pow(2,n);
    vector<int> dp(li,INF);
    dp[0]=0;
    rep(i,li){
        if(dp[i]==-1) continue;
        rep(j,m){
            int go=i|key[j].first;
            dp[go]=min(dp[go],dp[i]+key[j].second);
        }
    }
    int ans=(dp[li-1]==INF) ? -1 : dp[li-1];
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 256