akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  vi a(n+1); rep(i,n+1) cin >> a[i];
  vector<ll> mx(n+1),mn(n+1);
  mx[n] = mn[n] = a[n];
  for(int i = n; 0 < i; i--){
    mx[i-1] = mx[i] + a[i-1];
    mn[i-1] = (mn[i]+1)/2 + a[i-1];
  }
  ll ans = 0, num = 1;
  rep(i,n+1){
    chmin(num,mx[i]);
    if(num < mn[i]){
      cout << -1;
      return 0;
    }
    ans += num;
    num -= a[i];
    num *= 2;
  }
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 5292
n = int(input())
s = input()

r = s.count('R')
g = s.count('G')
b = s.count('B')

cnt = 0
for i in range(n):
    j = 1
    while i + 2*j <= n-1:
        if s[i] != s[i+j] and s[i+j] != s[i+2*j] and s[i+2*j] != s[i]:
            cnt += 1
        j += 1

print(r*g*b-cnt)

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = min(b, d)-max(a, c);
    if (b < c || d < a) ans = 0;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A[3];
    rep(i,3) cin >> A[i];
    sort(A,A+3);
    cout << A[2]*10+A[1]+A[0] << endl;




}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[200005],ans[200005];
int main() {
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	scanf("%d",&a[i]);
	int in = 1;
	int m = n;
	while(1)
	{
	    ans[in++] = m;
	    m-=2;
	    if(m < 1)break;
	}
	if(n%2)m= 2;else m = 1;
	while(1)
	{
	    ans[in++] = m;
	    m+=2;
	    if(m > n)break;
	}
	for(i=1;i<=n;i++)
	printf("%d ",a[ans[i]]);
	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

ll f(ll a, ll b, ll x) {
    return (x * a) / b - a * (x / b);
}

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll a, b, n;
    cin >> a >> b >> n;
    if(n >= b) {
        cout << f(a, b, b - 1) << endl;
    } else {
        cout << f(a, b, n) << endl;
    }
    return 0;
}



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

int main(){
  ll h,w,n;
  ll x[100100],y[100100];
  ll wx[200100],wy[200100];

  scanf("%lld%lld%lld",&h,&w,&n);
  for(int i=0;i<n;i++){
    scanf("%lld%lld",&x[i],&y[i]);
    wx[2*i] = wx[2*i+1] = x[i];
    wy[2*i] = wy[2*i+1] = y[i];
  }

  sort(wx,wx+2*n); sort(wy,wy+2*n);
  ll sumx[2]={}, sumy[2]={};
  int med = n-1;

  for(int i=0;i<2*n;i++){
    sumx[0] += abs(wx[i]-wx[med]);
    sumy[0] += abs(wy[i]-wy[med]);
    sumx[1] += abs(wx[i]-wx[med+1]);
    sumy[1] += abs(wy[i]-wy[med+1]);
  }

  ll ans = 1e18;
  pair<ll,ll> cord(0,0);
  for(int i=0;i<n;i++){
    int dx = 0, dy = 0;
    if(x[i]<=wx[med])dx=1;
    if(y[i]<=wy[med])dy=1;

    ll X = wx[med+dx], Y = wy[med+dy];
    ll cur = sumx[dx] + sumy[dy] - abs(X-x[i]) - abs(Y-y[i]);
    if(ans > cur){
      ans = cur; cord = make_pair(X,Y);
    }else if(ans == cur){
      cord = min(cord, make_pair(X,Y));
    }
  }

  printf("%lld\n", ans);
  printf("%lld %lld\n",cord.first, cord.second);
}

Measured memory_bytes: 5896
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>

int main()
{
    int ans1 = 0, ans2 = 0, n, m, x, cell[100] = {0}, j, k, a;

    std::cin >> n >> m >> x;
    for (int i = 0;i < m;i++){
        std::cin >> a;
        cell[a] = 1;
    }
    n++;
    j = k = x;
    while(1){
        if(j == n)
            break;

        j++;
        if(cell[j] == 1){
            ans1++;
        }
    }
    while(1){
        if(k == 0)
            break;

        k--;
        if(cell[k] == 1){
            ans2++;
        }
    }


    std::cout << std::min(ans1, ans2);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
int p;
char s[22];
int cnt[100100][2];
int ac;
int pm;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i)
	{
		scanf("%d%s",&p,s);
		if(s[0]=='A')
		{
			cnt[p][1]++;
			if(cnt[p][1]==1)ac++,pm+=cnt[p][0];
		}
		else
			cnt[p][0]++;
	}
	printf("%d %d\n",ac,pm);
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#include <numeric>
#include <map>
#define rep(i,n) for (int i = 0; i < (n); ++i)
 
using namespace std;
 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

struct S
{
    ll m_n1;
    int m_n2;
    int m_n3;
	int m_n4;

    S(ll n1, int n2, int n3, int n4) : m_n1(n1), m_n2(n2), m_n3(n3), m_n4(n4)
    {
    }

    bool operator<(const struct S& other) const
    {
        return m_n1 < other.m_n1;
    }
};

bool visited[1005][1005][1005];
 
int main () {
	int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
	vector<ll> vx(X), vy(Y), vz(Z);
	rep(i,X) {
		cin >> vx[i]; 
	}
	rep(i,Y) {
		cin >> vy[i]; 
	}
	rep(i,Z) {
		cin >> vz[i]; 
	}
	sort(vx.rbegin(), vx.rend());
	sort(vy.rbegin(), vy.rend());
	sort(vz.rbegin(), vz.rend());
	priority_queue< S > pq;
	int x, y, z;
	ll del;
	pq.push(S(vx[0] + vy[0] + vz[0], 0, 0, 0));
	visited[0][0][0] = true;
	rep(i,K) {
		auto cur = pq.top();
		pq.pop();
		del = cur.m_n1;
		x = cur.m_n2;
		y = cur.m_n3;
		z = cur.m_n4;
		cout << del << endl;
		int nx = min(X-1, x+1);
		int ny = min(Y-1, y+1);
		int nz = min(Z-1, z+1);
		if (!visited[nx][y][z]) {
			pq.push(S(vx[nx] + vy[y] + vz[z], nx, y, z));
			visited[nx][y][z] = true;
		}
		if (!visited[x][ny][z]) {
			pq.push(S(vx[x] + vy[ny] + vz[z], x, ny, z));
			visited[x][ny][z] = true;
		}
		if (!visited[x][y][nz]) {
			pq.push(S(vx[x] + vy[y] + vz[nz], x, y, nz));
			visited[x][y][nz] = true;
		}
	}
    return 0;
}

Measured memory_bytes: 985600
n = gets.to_i
h = gets.split(" ").map(&:to_i)
i = 0
a = 0 
until i == n do
	s = 0 
	if i + s == n - 1
		break
	end
	if h[i + s] < h[i + s + 1]
     s += 1
		 i += s
  else
		while h[i + s] >= h[i + s + 1] do
			s += 1
			if i + s == n - 1
				break
			end
		end
		if s > a
			a = s
		end
		i += s + 1
	end
end

puts a


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll a,b,c,d,e,k;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  cin >> e;
  cin >> k;
  if(e-a>k) cout << ":(" << endl;
  else cout << "Yay!" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
  int a,b,c;

  cin >> a >> b >> c;
  b = -b;
  if( b + c <= 0){
    cout << "delicious" <<endl;
  }else if( b + c <= a){
    cout << "safe" <<endl;
  }else{
    cout << "dangerous" <<endl;
  }

  return 0;

}


Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]

cnt = [0 for _ in range(10**5 * 5)]
for a in A:
    cnt[a] += 1

ans = sum(A)

Q = int(input())
for _ in range(Q):
    B, C = map(int, input().split())

    ans -= B * cnt[B]
    ans += C * cnt[B]

    cnt[C] += cnt[B]
    cnt[B] = 0

    print(ans)

Measured memory_bytes: 20448
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

int main(int argc, char *argv[]) {
	int n;
	vector<pair<int, int>> vp;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x, l;
		cin >> x >> l;
		vp.push_back(make_pair(x + l, x - l));
	}

	sort(vp.begin(), vp.end());
	int res = 0;
	int last = -0x3f3f3f3f;
	for (int i = 0; i < n; i++) {
		if (vp[i].second >= last) {
			res++;
			last = vp[i].first;
		}
	}
	cout << res << endl;
}









Measured memory_bytes: 1400
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    SCIN(str);
    str.insert(4," ");
    COUT(str);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll H,W;
int main(){
    cin>>H>>W;
    ll ans=INF;
    for(ll i=1;i<H;i++){
        ll a=W*i;
        ll b,c;
        if( (H-i)%2==1 && W%2==1){
            b=(H-i)*(W/2);
            c=(H-i)*((W+1)/2);
            ans=min(ans,max({a,b,c})-min({a,b,c}));
            b=W*((H-i)/2);
            c=W*((H-i+1)/2);
            ans=min(ans,max({a,b,c})-min({a,b,c}));
        }else{
            b=(H-i)*W/2;
            ans=min(ans,abs(a-b));
        }
    }
    for(ll i=1;i<W;i++){
        ll a=H*i;
        ll b,c;
        if( (W-i)%2==1 && H%2==1){
            b=(W-i)*(H/2);
            c=(W-i)*((H+1)/2);
            ans=min(ans,max({a,b,c})-min({a,b,c}));
            
            b=H*((W-i)/2);
            c=H*((W-i+1)/2);
            ans=min(ans,max({a,b,c})-min({a,b,c}));
        }else{
            b=(W-i)*H/2;
            ans=min(ans,abs(a-b));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define print(x) (cout << x << endl)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

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

  int n, p;
  string s;
  cin >> n;
  vector<pair<int, pair<string, int> > > v(n);
  for (int i = 1; i <= n; i++) {
    cin >> s >> p;
    v[i - 1] = {i, {s, p}};
  }
  sort(v.begin(), v.end(), [](auto& p1, auto& p2){
    if (p1.second.first.compare(p2.second.first) == 0) 
      return p1.second.second > p2.second.second;
    else 
      return p1.second.first.compare(p2.second.first) < 0;
  });

  for (auto i : v) {
    cout << i.first << endl;
  }
  
  
  
  // cout << "Case #" << C++ << ": " << cur_max << endl;  


}



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

int ara[100005];
int main()
{

        int n;cin>>n;
        for(int i=1;i<=n;i++)cin>>ara[i];
        int f=0;
        int ans=0,last;
        for(int i=1;i<=n;i++)
        {
            if(ara[i]==i)
            {
                if(f==0)
                {
                    f=1;
                    ans++;
                }
                else
                {
                    if(ara[i-1]==i-1)
                    {
                        f=0;
                    }
                    else
                        ans++;
                }
            }
        }
        cout<<ans<<endl;

}
/*
5
3 2 1 4 5

*/


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

int main(){
  int N;
  cin >> N;
  int Ans=0;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  for(int i=1; i<N; i++){
    if(A.at(i)==A.at(i-1)){
      Ans++;
      A.at(i)=-1;
    }
  }
  cout << Ans << endl;
}

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

using namespace std;

int main(void) {
  int H, N; cin >> H >> N;
  int dp[H+1];
  memset(dp, 0x7F, sizeof(dp));
  dp[0] = 0;
  
  for (int i = 0; i < N; i++) {
    int a, b; cin >> a >> b;
    for (int i = 1; i < min(a, H+1); i++){
      dp[i] = min(dp[i], b);
    }
    
    for (int i = a; i <= H; i++) {
      dp[i] = min(dp[i], dp[i-a] + b);
    }
  }

  cout << dp[H] << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define N 8
#define FREE -1
#define NOT_FREE 9999
#define PUT 1
#define NOT_PUT 0

int p[N+1][N+1];
int dpos[2*N+1] = {FREE};
int dneg[2*N+1] = {FREE};
int col[N+1] = {FREE};
int row[N+1] = {FREE};

//最後の行で出力できるかどうか確認
void backTracking()
{
  int i,j;
  
  for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      if(p[i][j] == PUT){
	if(row[i] != j) return;
      }
    }
  }
  //printf("Tracking ended\n");

  for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      if(row[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void putQueen(int i)
{
  if(i == N){
    backTracking();
    return;
  }
  
  int j;
  for(j = 0;j < N;j++){
    if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE) continue;

    //put a queen at (i, j)
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;

    //try the next row
    putQueen(i+1);
    
    //remove the queen at (i, j) for backtracking
    col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}

int main()
{
  int i,j,k;
  int n;

  scanf("%d", &n);

  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++) p[i][j] = NOT_PUT;
  }
  
  for(k = 0;k < n;k++){
    scanf("%d%d", &i, &j);
    p[i][j] = PUT;
  }

  putQueen(0);
  
  return 0;
}


Measured memory_bytes: 2696
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 2e5+5;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;

int n, f[N], c[N], mx[N], mn[N], ans = 0;

struct line{ int x, v, L, R; }a[N];

int lowbit(int x){ return x & (-x); }

void update(int x, int val){
	for(; x <= n; x += lowbit(x)) (c[x] += val) %= mod;
}

int query(int x){
	int res = 0;
	for(; x; x -= lowbit(x)) (res += c[x]) %= mod;
	return res;
}

bool cmp1(line a, line b){ return a.v < b.v; }
bool cmp2(line a, line b){ return a.R != b.R ? a.R < b.R : a.L < b.L; }

int main(){
//	freopen("river.in", "r", stdin);
//	freopen("river.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i].x >> a[i].v;
	sort(a+1, a+n+1, cmp1);
	for(int i = 1; i <= n; i++){
		int l = 1, r = i-1; mx[i] = max(mx[i-1], a[i].x);
		while(l <= r){
			int mid = (l+r>>1);
			if(mx[mid] > a[i].x) a[i].L = mid, r = mid-1;
			else l = mid+1;
		}
	}
	mn[n+1] = inf;
	for(int i = n; i >= 1; i--){
		int l = i+1, r = n; mn[i] = min(mn[i+1], a[i].x);
		while(l <= r){
			int mid = (l+r>>1);
			if(mn[mid] < a[i].x) a[i].R = mid, l = mid+1;
			else r = mid-1;
		}
	}
	for(int i = 1; i <= n; i++) a[i].L ? 0 : a[i].L = i, a[i].R ? 0 : a[i].R = i;
	sort(a+1, a+n+1, cmp2);
	for(int i = 1; i <= n; i++){
		if(a[i].L == 1) f[i] = (f[i]+1)%mod;
		f[i] += (query(a[i].R)-query(max(a[i].L-2, 0))+mod)%mod;
		if(a[i].R == n) (ans += f[i]) %= mod;
		update(a[i].R, f[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
vector<int> m;
int main(void){
    int n;
    cin>>n;
    n*=2;
    int i=1;
    for(;i*(i+1)<n;i++);
    if(i*(i+1)==n){
        cout<<"Yes"<<endl;
        cout<<i+1<<endl;
        n/=2;
        int ans[i+1][i];
        for(int j=0;j<i+1;j++)for(int k=0;k<i;k++)ans[j][k]=0;
        int t=0;
        for(int j=0;j<i;j++){
            for(int k=1;k<=i-j;k++){
                ans[k-1][k+j-1]=k+t;
                ans[k+j][k-1]=k+t;
            }
            t+=i-j;
        }
        for(int j=0;j<i+1;j++){
            cout<<i;
            for(int k=0;k<i;k++){
                cout<<" "<<ans[j][k];
            }
            cout<<endl;
        }
    }
    else cout<<"No"<<endl;
}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
	private Scanner sc;

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

		String[] nico = sc.nextLine().split(",");
		double fx = Double.parseDouble(nico[0]);
		double fy = Double.parseDouble(nico[1]);

		nico = sc.nextLine().split(",");
		double ox = Double.parseDouble(nico[0]);
		double oy = Double.parseDouble(nico[1]);
		
		double s = 0.0;
		while (sc.hasNextLine()) {
			nico = sc.nextLine().split(",");
			double tx = Double.parseDouble(nico[0]);
			double ty = Double.parseDouble(nico[1]);

			double a = Math.sqrt((fx - ox) * (fx - ox) + (fy - oy) * (fy - oy));
			double b = Math.sqrt((fx - tx) * (fx - tx) + (fy - ty) * (fy - ty));
			double c = Math.sqrt((ox - tx) * (ox - tx) + (oy - ty) * (oy - ty));
			double z = (a + b + c) / 2;
			
			s = s + Math.sqrt(z * (z - a) * (z - b) * (z - c));
			
			ox = tx;
			oy = ty;
		}
		
		System.out.println(s);
	}
}

Measured memory_bytes: 25944
#include <bits/stdc++.h>
#define MOD 1000000007
// #define MOD 998244353
#define ll long long
#define db double
#define endl "\n"
#define INF 1000000000000000000
#define INF1 1000000000
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define RAND mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define pb push_back
#define mp make_pair
#define debx cout<<" X "<<endl;
#define deby cout<<" Y "<<endl;
#define debz cout<<" Z "<<endl;
#define deb(x) cout << '>' << #x << ':' << x << endl;
using namespace std;
 
ll mpow(ll a, ll b){
    if(!b)
        return 1;
    ll temp=mpow(a,b/2);
    temp=(temp*temp)%MOD;
    if(b%2)
        return (a*temp)%MOD;
    return temp;
}
ll _pow(ll a, ll b){
    if(!b)
        return 1;
    ll temp=mpow(a,b/2);
    temp=(temp*temp);
    if(b%2)
        return (a*temp);
    return temp;
}
ll mod_in(ll n){
    return mpow(n,MOD-2);
}
ll cl(ll a, ll b){
    if(a%b)
        return 1+a/b;
    return a/b;
}
ll dig(ll n){
    if(!n)
        return 0;
    return 1 + dig(n/10);
}
int main(){
    fastio
    ll n, k, s ;
    cin>>n>>k>>s ;
    while(k--){
        cout<<s<<" ";
        n-- ;
    }
    ll v = INF1 ;
    if(s == INF1)
        v-- ;
    while(n){
        cout<<v<<" ";
        n--;
    }
}

Measured memory_bytes: 1280
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>

using namespace std;

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || c > '9') break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

int main()
{
    const char *Yes = "Yes";
    const char *No = "No";

    int N;

    gc(N);

    int a;

    int cntFour = 0;
    int cntTwo = 0;

    for (int i = 0; i < N; i++)
    {
        gc(a);
        if (a % 4 == 0) {cntFour++;}
        else if (a % 2 == 0) {cntTwo++;}
    }

    printf("%s", N / 2 <= cntFour ? Yes
     : N - cntFour * 2 <= cntTwo ? Yes
     : No);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cerr << #v << " = "; array_out(v , __VA_ARGS__ );} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
 
using P = pair<ll,ll>; using vp = vector<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
/////////////////

int dp[110][10200];

void solve(){
  ini(N);
  vi v(N); in(v);
  dp[0][0] = 1;
  rep(i , N) rep(j , 10000){
    dp[i+1][j] |= dp[i][j];
    dp[i+1][j + v[i]] |= dp[i][j]; 
  }
  repr1(i , 10000){
    if(dp[N][i] && (i % 10)) die(i);
  }
  out(0);
}



Measured memory_bytes: 4352
(defun app ()
    (let ((n (read-line))
        (ans "No"))

        (if (or (equal "7" (subseq n 0 1)) (equal "7" (subseq n 1 2)) (equal "7" (subseq n 2 3)))
        (setq ans "Yes"))

    (format t "~A~%" ans)
    )
)

(app)

Measured memory_bytes: 23528
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##_len=(int)(n);i<i##_len;++i)
#define REP(i,n) REPF(i,0,n)
#define RREP(i,n) for(int i=(int)(n);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int N,A,B;
    cin>>N>>A>>B;
    map<int,int> nums_n,nums_a;
    vi v(N);
    cin>>v;

    sort(RALL(v));
    long double max_avr=0;
    REP(i,N) {
        if(EXIST(nums_n,v[i])) {
            nums_n[v[i]]++;
        }
        else {
            nums_n[v[i]]=1;
        }
        if(i<A) {
            max_avr+=v[i];
            if(EXIST(nums_a,v[i])) {
                nums_a[v[i]]++;
            }
            else {
                nums_a[v[i]]=1;
            }
        }
    }

    vector<vector<int>> C(100,vi(100,-1));
    REP(i,100) C[i][0]=1; REP(i,100) C[i][i]=1;
    REP(i,100) REP(j,100) {
        if(i==j) break;
        if(C[i][j]==-1) C[i][j]=C[i-1][j-1]+C[i-1][j];
    }

    int ans=0;
    if(v[0]==v[A-1]) {
        REPF(j,A,B+1) {
            if(nums_n[v[A-1]]<j) break;
            ans+=C[nums_n[v[A-1]]][j];
        }
    }
    else {
        ans=C[nums_n[v[A-1]]][nums_a[v[A-1]]];
    }

    cout<<max_avr/A<<endl;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
var s:string;
procedure dfs(dep,sum:int64;t:string);
begin
  if dep=4 then
  begin
    if sum=7 then
    begin
      writeln(t,'=7');
      halt;
    end;
    exit;
  end;
  dfs(dep+1,sum+ord(s[dep+1])-48,t+'+'+s[dep+1]);
  dfs(dep+1,sum-ord(s[dep+1])+48,t+'-'+s[dep+1]);
end;
begin
  readln(s);
  dfs(1,ord(s[1])-48,s[1]);
end.

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>

using namespace std;

int main(){
    long double a, b;
    cin >> a;
    cin >> b;
    
    int d = int(a)/ int(b);
    int r = int(a)% int(b);
    long double f = a / b;
    printf("%d %d %Lf\n",d, r, f);

    return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int main()
{
    int r;cin>>r;
    cout<<3*r*r<<endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <climits>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

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

void solve(void){
    string S;
    cin >> S;
    cout << 700 + count(all(S), 'o')*100 << '\n';
}

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


Measured memory_bytes: 256
open Printf
open Scanf

let id x = x

type state = {mv : int; sp : int; bd : int array}

let () =
  let goal = [|1;2;3;4;5;6;7;8;0|] in
  let isp = ref 0 in
  let bd = Array.init 9 (fun i -> let v = scanf "%d " id in if v = 0 then isp := i; v) in
  let que = Queue.create () in
  let ht = Hashtbl.create 100 in
  let rec loop () =
    if Queue.is_empty que then failwith "8 puzzle"
    else
      let st = Queue.pop que in
      if st.bd = goal then st.mv
      else begin
          List.iter (fun (dx, dy) ->
                     let x, y = (st.sp/3, st.sp mod 3) in
                     let nx, ny = (dx + x, dy + y) in
                     if 0 <= nx && nx <= 2 && 0 <= ny && ny <= 2 then
                       let nsp = 3 * nx + ny in
                       let nbd = Array.copy st.bd in
                       begin
                         nbd.(st.sp) <- st.bd.(nsp);
                         nbd.(nsp) <- 0;
                         if Hashtbl.mem ht nbd then ()
                         else
                           let nst = {mv = st.mv + 1; sp = nsp; bd = nbd} in Queue.push nst que;
                                                                             Hashtbl.add ht nbd true
                       end
                    ) [(1,0);(0,1);(-1,0);(0,-1)];
          loop ()
        end                  
  in
  Queue.push {mv = 0; sp = !isp; bd = bd} que;
  Hashtbl.add ht bd true;
  loop () |> printf "%d\n"

Measured memory_bytes: 36024
//#pragma GCC optimize ('O3')
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 50 + 5;
const int M = 1e5 + 5;
const ll OO = 1e18;
const int mod = 1e9 + 7;

int n,k,v[N],ans;

int solve(int a, int b) {

    if(a+1+n-b>k) return 0;

    int rem = k - (a+1+n-b);

    vector<int> x,y;

    int sum = 0;

    for (int i = 0; i <= a; ++i) {
        x.pb(v[i]);
        sum += x.back();
    }

    for (int i = n-1; i >= b; --i) {
        y.pb(v[i]);
        sum += y.back();
    }

    int ret = sum;

    sort(x.begin(),x.end());
    sort(y.begin(),y.end());

    for (int i = 0; i <= a+1; ++i) {
        for (int j = 0; j <= n-b; ++j) {

            if(rem<i+j) continue;

            int newRet = sum;

            for (int l = 0; l < i; ++l) {
                newRet -= x[l];
            }
            for (int k = 0; k < j; ++k) {
                newRet -= y[k];
            }

            ret = max(ret, newRet);

        }
    }

    return ret;

}

void init() {

}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k;

    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }

    for (int i = -1; i < n; ++i) {
        for (int j = i+1; j <= n; ++j) {
            ans = max(ans, solve(i,j));
        }
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3616
/* In the name of God */
     
#include <bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pii pair <int, int>
using namespace std;
const ll mod = 1e9 + 7;
const int N = 2e5 + 5;

void solve() {
    int a, b, c;
    int k;
    cin >> a >> b >> c >> k;
    while(a >= b) {
        b *= 2;
        k--;
    }
    while(c <= b) {
        c *= 2;
        k--;
    }
    // cout << k;
    cout << (k >= 0 ? "Yes\n" : "No\n");
}
 
int main()  {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        // cout << "Case #" << tc << ": ";
        solve();
    } 
}                        

Measured memory_bytes: 3648
package main

import (
	"fmt"
)

func main() {
	var x int
	var res int
	fmt.Scan(&x)
	if x < 600 {
		res = 8
	} else if x < 800 {
		res = 7
	} else if x < 1000 {
		res = 6
	} else if x < 1200 {
		res = 5
	} else if x < 1400 {
		res = 4
	} else if x < 1600 {
		res = 3
	} else if x < 1800 {
		res = 2
	} else {
		res = 1
	}
	fmt.Println(res)
}


Measured memory_bytes: 1768
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int A = sc.nextInt();

		int B = sc.nextInt();

		int C = sc.nextInt();

		int D = sc.nextInt();

		int a = 0;

		int b = 0;

		if(N%A==0) {

			a = B * N/A;

		}else {

			a = B * (N/A+1);

		}

		if(N%C==0) {

			b = D * N/C;

		}else {

			b = D * (N/C + 1);

		}

		System.out.println(Math.min(a, b));

	}

}



Measured memory_bytes: 26276
#!/usr/bin/env python3
import sys
from itertools import accumulate
INF = float("inf")


def solve(N: int, M: int, V: int, P: int, A: "List[int]"):

    ans = 0

    # 降順
    A.sort(reverse=True)
    acc = [0]+list(accumulate(A))

    left = P-1
    right = len(A)
    while right - left > 1:
        mid = (right + left)//2
        if A[mid]+M < A[P-1]:
            right = mid
            continue

        cap = M*N+(mid-P+1)*(A[mid]) - acc[mid] + acc[P-1]
        if cap >= M*V:
            left = mid
        else:
            right = mid
    print(left+1)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    V = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, V, P, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 64672
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for (int i=(a); i>=(b); --i)
#define REP(i,b) for (int i=0; i<(b); ++i)
#define endl '\n'
#define sz(x) (int) x.size()
#define mod %
#define fillchar(x,y,z) memset(x,z,y)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define sqr(x) ((x)*(x))
typedef long long int64;
typedef unsigned long long qword;
using namespace std;
const int maxn=1e5+5;
vector<int> adj[maxn];
int f[maxn];
int tp[maxn],vs[maxn];
int cnt,n,m;
void Input()
{
    cin >> n >> m;
    FOR(i,1,m) {
        int x,y;
        cin >> x >> y;
        adj[x].push_back(y);
    }
}
void DFS(int u)
{
    vs[u]=1;
    for (int v:adj[u])
        if (!vs[v]) DFS(v);
    tp[++cnt]=u;
}
void Solve()
{
    FOR(i,1,n) if (!vs[i]) DFS(i);
    FORR(i,n,1) {
        int u=tp[i];
        for (int v:adj[u])
            f[v]=max(f[v],f[u]+1);
    }
    cout << *max_element(f+1,f+1+n);
}
int main()
{
    #ifdef meomeomeooooo
        freopen("input.txt","r",stdin);
        //freopen(".out","w",stdout);
    #endif // meomeomeooooo
    iostream::sync_with_stdio(false);
    cin.tie(0);
    Input();
    Solve();
    return 0;
}



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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

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

int main() {
  int n, k;
  string s;

  cin >> n >> k >> s;

  int score = 0;
  rep(i, n - 1) if (s[i] == s[i + 1]) score++;
  int ans = min(score + 2 * k, n - 1);

  cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String...args){
        Scanner scanner=new Scanner(System.in);
        int K =scanner.nextInt();
        int X =scanner.nextInt();

        if(K*500>=X){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }
}






Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>


using namespace std;

int main() {
  int n;
  cin>>n;
  int a[n], b[n];
  for(int i=0; i<n; i++) {
    cin>>a[i];
    b[i] = a[i];
  }
  sort(b, b+n);
  int t=0;
  for(int i=0; i<n; i++) {
    if(b[i] - a[i] != 0) {
      t++;
    }
  }
  if (t>2) {
    cout<<"NO"<<endl;
  } else {
    cout<<"YES"<<endl;
  }
  return 0;
}


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

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

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int h,w,n;
int sr, sc;
char s[252521], t[252521];

vector<pii> ords;
int x;
int low, high;

bool solve(){
    int rl = low, rh = high;
    FORR(i,0,ords.size()){
        pii P = ords[i];
        if(P.first == 0){
            // takahashi
            if(P.second == +1){
                rh--;
            }else{
                rl++;
            }
            if(rl >= rh)return false;
        }else{
            // aoki
            if(P.second == +1){
                rl = max(low,rl-1);
            }else{
                rh = min(high,rh+1);
            }
        }
    }
    return rl<=x && x<rh;
}

int main(){
    scanf("%d%d%d",&h,&w,&n);
    scanf("%d%d",&sr,&sc); --sr; --sc;
    scanf("%s%s",s,t);
    {
        x = sc;
        low = 0;
        high = w;
        ords.clear();
        REP(i,n){
            if(s[i]=='L')ords.push_back(pii(0,-1));
            if(s[i]=='R')ords.push_back(pii(0,+1));
            if(t[i]=='L')ords.push_back(pii(1,-1));
            if(t[i]=='R')ords.push_back(pii(1,+1));
        }
        if(!solve()){
            puts("NO");
            return 0;
        }
    }
    {
        x = sr;
        low = 0;
        high = h;
        ords.clear();
        REP(i,n){
            if(s[i]=='U')ords.push_back(pii(0,-1));
            if(s[i]=='D')ords.push_back(pii(0,+1));
            if(t[i]=='U')ords.push_back(pii(1,-1));
            if(t[i]=='D')ords.push_back(pii(1,+1));
        }
        if(!solve()){
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    return 0;
}


Measured memory_bytes: 2804
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
S = input()

tmp = 0
ans = 0

for i in range(len(S)):
    if S[i] == "R":
        if tmp == 1:
            ans += 1
        else:
            tmp = 1
            ans = 1
    else:
        tmp = 0

print(ans)

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

#define ll long long
#define all(x) x.begin(), x.end()

const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;

ll knapSack(int W, vector<int> &wt, vector<int> &val){ 
    int n = wt.size();
    int V = accumulate(all(val), 0);
    ll K[n+1][V+1];

    for(int i=0; i<=n; i++)
        for(int v=0; v<=V; v++){
            K[i][v] = INFLL;
            if(v==0)
                K[i][v] = 0;
            else if(i==0)
                continue;
            else if(val[i-1]<=v)
                K[i][v] = min(wt[i-1]+K[i-1][v-val[i-1]], K[i-1][v]);
            else
                K[i][v] = K[i-1][v];
        }

    int res = INT_MIN;
    for(int v=0; v<=V; v++)
        if(K[n][v]<=W)
            res = max(v, res);

    return res; 
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, w;
    cin >> n >> w;
    vector<int> wt(n), val(n);
    for(int i=0; i<n; i++)
        cin >> wt[i] >> val[i];
    cout << knapSack(w, wt, val) << endl;
    
    return 0;
}

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

using namespace std;

int main(){
    int N; cin>>N;
    int M; cin>>M;
    vector<int> K(M+1);
    vector<vector<int>> S(M+1,vector<int>(N+1));
    vector<int> P(M+1);
    int via;
    int gokei;
    int swicount=0;
    int light=0;
    int ans=0;

    for(int i=1;i<=M;i++){
        cin>>K[i];
        via=K[i];
        for(int j=1;j<=via;j++){
            cin>>S.at(i).at(j);
        }
    }
    for(int i=1;i<=M;i++){
        cin>>P[i];
    }
    //
  
    vector<int> SWI(N+1);//スイッチ状態
    for(int i=0;i<pow(2,N);i++){
        gokei=i;
        for(int j=N-1;j>=0;j--){//2^jの位をSWI[j+1]
            SWI[j+1]=gokei/(int)pow(2,j);
            gokei=gokei%(int)pow(2,j);
        }//1つのスイッチの状態完成
        for(int k=1;k<=M;k++){//電球がつくか
            for(int l=1;l<=K[k];l++){
                via=S.at(k).at(l);
                if(SWI[via]==1) swicount++;
            }
            if(swicount%2==P[k]){//電気つく
                light++;
            }
            swicount=0;
        }
        if(light==M){//全部電気ついた
        ans++;
        }
        light=0;
    }

    printf("%d",ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int INF = 1LL << 60;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    map<string,int> cnt;
    int N;
    cin >> N;
    string s;
    REP(i,N){
        cin >> s;
        cnt[s]++;
    }
    cin >> N;
    REP(i,N){
        cin >> s;
        cnt[s]--;
    }
    int ans = 0;
    for(auto x:cnt){
        ans = max(ans, x.second);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define MOD 1000000007
#define MAXN 200005
#define LL long long
LL inv[MAXN],s[MAXN];
int N;
int n,m,x,y;
LL Pow(LL a,int b)
{
    LL ans=1;
    while(b)
    {
        if(b&1) ans=ans*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return ans;
}
void Pre()
{
    s[0]=1;
    for(int i=1; i<=N; i++)
        s[i]=s[i-1]*i%MOD;
    inv[0]=1;
    inv[N]=Pow(s[N],MOD-2);
    for(int i=N-1; i>0; i--)
        inv[i]=inv[i+1]*(i+1)%MOD;
}
LL C(int a,int b)
{
    if(a<0||b<0) return 1;
    return s[a]*inv[b]%MOD*inv[a-b]%MOD;
}
int main()
{

    scanf("%d%d",&n,&m);
    scanf("%d%d",&x,&y);
    N=n+m-2;
    Pre();
    LL ans=0;
    for(int i=y+1;i<=m;i++)
    {
        ans+=C(n-x+i-2,i-1)*C(x+m-i-1,x-1)%MOD;
        ans%=MOD;
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
using namespace std;
long int x[10000],n,sum;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x[i];
		sum=sum+x[i];
	}
	sort(x,x+n);
	cout<<x[0]<<" "<<x[n-1]<<" "<<sum<<endl;
	return 0;
}

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

vector<vector<int>> G;
int ans;

void dfs(int v, vector<int> V) {
  V.at(v) = 1;
  if (accumulate(V.begin(), V.end(), 0) == V.size()) {
    ans++;
    return;
  }
  for (auto g : G.at(v)) {
    if (V.at(g)) continue;
    dfs(g, V);
  }
  V.at(v) = 0;
}

int main() {
  int N, M;
  cin >> N >> M;
  G.resize(N);
  for (int i = 0, a, b; cin >> a >> b; i++) {
    G.at(--a).push_back(--b), G.at(b).push_back(a);
  }
  vector<int> V(N);
  dfs(0, V);
  cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long n = scanner.nextLong();
		long min = Integer.MAX_VALUE;
		for(long i=1;i<=Math.sqrt(n);i++){
			if(n % i == 0){
				long x = n / i;
				String y = String.valueOf(i);
				String z = String.valueOf(x);
				long max = Math.max(y.length(), z.length());
				min = Math.min(min, max);
			}
		}
		System.out.println(min);
	}

}


Measured memory_bytes: 21204
#include<stdio.h>//与えられた数列を逆順に出力するプログラム
#include<stdlib.h>

int main(void){
 
	int *a,n,i;

	scanf("%d",&n);
	a=(malloc(sizeof(int) * n));

	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=n-1;i>-1;i--){
		printf("%d",a[i]);
		if(i!=0)
			printf(" ");
	}
	printf("\n");
	free(a);
	return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string[] sn = new string[n];
        for (int i = 0; i < n; i++)
            sn[i] = Console.ReadLine();
        
        int[][] cnt = new int[30][];
        for (int i = 0; i < 30; i++)
            cnt[i] = new int[n];
        
        for (int i = 0; i < n; i++)
            foreach(char c in sn[i])
                cnt[c - 'a'][i]++;
        
        for (int i = 0; i <= 'z' - 'a'; i++)
            Console.Write(new string((char)(i + 'a'), cnt[i].Min()));
        Console.WriteLine();
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	unsigned long long a;
	double b;
	cin>> a >>b;
	unsigned long long c = 1000*b;
	unsigned long long d = a*c;
	unsigned long long e = d/1000;
	cout<< e <<endl;
}

Measured memory_bytes: 3728