akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <complex>
#include <vector>
#include <cmath>

using namespace std;

typedef double ldb;
typedef complex<ldb> P;

const ldb eps = 1e-8;
// math.hのM_PIでもOK?
const ldb pi = acos(-1);
// 誤差を考慮した比較 sig(a-b) のように使う
// ret<0 なら a<b, ret>0 なら a>b, ret=0 なら a=b
int sig(ldb a) {return (a<-eps)?-1:(a>eps)?1:0;}
// 誤差を考慮した比較
bool eq(ldb a,ldb b){return abs(a-b)<eps;}
// 内積
ldb dot(P a, P b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}
// 外積
ldb cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}

// 直線,線分 (半直線は未確認だけど線分で無限に長いものを作れば良さそう)
struct L {
  P a,b;
  L(){}
  L(P a,P b):a(a),b(b){}
  ldb len(){return abs(a-b);}
  P vec(){return b-a;}
};

// 線分abに対する点xの位置
enum CCW{FRONT = 1, RIGHT = 2, BACK = 4, LEFT = 8, ON = 16};
int ccw(L s, P p) {
  P a = s.vec();
  p -= s.a;
  ldb cr = cross(a, p);
  if (eq(cr, 0)) {
    if (sig(dot(a, p)) < 0) return BACK;
    if (sig(norm(a) - norm(p)) < 0) return FRONT;
    return ON;
  }
  return (cr > 0) ? LEFT : RIGHT;
}

// "線分"a と 点b の距離
double dLP2(L a,P b) {
  if ( dot(a.b-a.a, b-a.a) < eps ) return abs(b-a.a);
  if ( dot(a.a-a.b, b-a.b) < eps ) return abs(b-a.b);
  return abs(cross(a.b-a.a, b-a.a)) / abs(a.b-a.a);
}

bool iI2_1(L a, L b) {
  return ((ccw(a, b.a) | ccw(a, b.b)) & (ccw(b, a.a) | ccw(b, a.b))) == (LEFT | RIGHT);
}

int main(void)
{
  int n,m;
  int x1[55],y1[55];
  int x2[55],y2[55];

  scanf("%d",&n);
  for( int i = 1; i <= n; i++ ) scanf("%d%d",x1+i,y1+i);
  x1[0] = 0;
  y1[0] = 0;
  x1[n+1] = 1000;
  y1[n+1] = 0;
  n += 2;
  scanf("%d",&m);
  for( int i = 1; i <= m; i++ ) scanf("%d%d",x2+i,y2+i);
  x2[0] = 0;
  y2[0] = 1000;
  x2[m+1] = 1000;
  y2[m+1] = 1000;
  m += 2;
  double res = 100000;
  for( int i = 0; i < n; i++ ) {
    for( int j = 0; j < m; j++ ) {
      bool ok = true;
      L a(P(x1[i],y1[i]),P(x2[j],y2[j]));
      for( int ii = 0; ii < n-1; ii++ ) {
        L b(P(x1[ii],y1[ii]),P(x1[ii+1],y1[ii+1]));
        if( iI2_1(a,b) ) {
          ok = false;
        }
      }
      for( int ii = 0; ii < m-1; ii++ ) {
        L b(P(x2[ii],y2[ii]),P(x2[ii+1],y2[ii+1]));
        if( iI2_1(a,b) ) {
          ok = false;
        }
      }
      if( ok ) {
        res = min(res,a.len());
      }
    }
  }
  for( int i = 0; i < m; i++ ) {
    P a(x2[i],y2[i]);
    for( int ii = 0; ii < n-1; ii++ ) {
      L b(P(x1[ii],y1[ii]),P(x1[ii+1],y1[ii+1]));
      res = min(res,dLP2(b,a));
    }
  }
  for( int i = 0; i < n; i++ ) {
    P a(x1[i],y1[i]);
    for( int ii = 0; ii < m-1; ii++ ) {
      L b(P(x2[ii],y2[ii]),P(x2[ii+1],y2[ii+1]));
      res = min(res,dLP2(b,a));
    }
  }
  printf("%.10f\n",res);
  return 0;
}

Measured memory_bytes: 1088
N = gets.to_i

A = Array.new(200 + 1){ [] }
ODD = (1 .. 200).select{|i| i.odd? }.to_a

ODD.each do |i|
  ODD.each do |j|
    break if i * j > N
    A[i * j] << i << j
  end
end
A.each{|cmp| cmp.uniq!}
puts ODD.count{|i| A[i].size == 8 && i <= N}



Measured memory_bytes: 1788
A, B, C, X, Y = map(int, input().split())

ans = max(A, B) * (X + Y)
for i in range(2 * 10 ** 5 + 100):
    c = i // 2
    x = i * C + max(X - c, 0) * A + max(Y - c, 0) * B
    ans = min(ans, x)

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int md = 2019;
  int l, r; std::cin >> l >> r;
  if (r - l >= md - 1) {
    l = 0, r = md - 1;
  } else {
    l %= md, r %= md;
    if (l > r) l += md;
  }
  int ret = md * md;
  for (int i = l; i <= r; i++) {
    for (int j = i + 1; j <= r; j++) {
      ret = std::min(ret, i * j % md);
    }
  }
  std::cout << ret << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
#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 pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
#define S set<int>
#define itn int
bool dbg = false;
int X;
void solve() {
    if (X % 105 == 0) {
        cout << 1 << endl;
    } else if (X / 100 == X / 105) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> X;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<map>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////

int main(){

    ll n,m,k;
    L3(n,m,k);
    pair<ll,ll>ar[n+2];

    for(int i = 1;i<=n;i++)L2(ar[i].x,ar[i].y);
    sort(ar+1,ar+n+1);

    ll cum[n+2];
    SET(cum);
    ll res = 0;
    for(int i = 1;i<=n;i++){
        cum[i] += cum[i-1];
        if(cum[i] < ar[i].y){
            ll ko = ar[i].y - cum[i];
            ll koy = (ko+k-1)/k;
            res += koy;
            ll ind = upper_bound(ar+1,ar+n+1,mk(ar[i].x + 2 * m, 20000000000ll))-ar;
            cum[i]+=k *koy;
            cum[ind] -=k*koy;
        }
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int N){
        par.assign(N,0);
        rank.assign(N,0);
        REP(i,N) par[i]=i;
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    void unite(int x,int y){
        x=find(x),y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]) swap(x,y);
 
        //x becomes root
        par[y]=x;
        if(rank[x]==rank[y]) rank[x]++;
    }
};

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N,M; cin >> N >> M;
    VI a(M),b(M);
    REP(i,M)
    {
        int ta,tb;
        cin >> ta >> tb;
        ta--; tb--;
        a[i] = ta; b[i] = tb;
    }
    int ans = 0;
    REP(i,M)
    {
        UnionFind uf(N);
        REP(j,M)
        {
            if(i != j) uf.unite(a[j],b[j]);
        }
        if(!uf.same(a[i],b[i])) ans++;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include<map>
#include<stack>
#include<queue>
#include<cmath>
#include<string>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long int
#define lson rt<<1,l,m
#define rson rt<<1|1,m+1,r
const int inf = 0x3f3f3f3f;
long long a[222222];
long long pre[222222];
long long roo[222222];
int main()
{
	int n;
	while (cin >> n )
	{
		for (int i = 0; i < n; i++)
			cin >> a[i];
		long long ans = -1;
		pre[0] = a[0];
		roo[n - 1] = a[n - 1];
		for (int i = 1; i < n; i++)
			pre[i] = pre[i - 1] + a[i];
		for (int i = n - 2; i >= 0; i--)
			roo[i] = roo[i + 1] + a[i];
		for (int i = 1; i <= n - 3; i++)
		{
			long long ls = pre[i] ;
			long long rs = roo[i + 1];
			long long l1, l2, r1, r2;
			long long lz = lower_bound(pre, pre + i + 1, ls / 2)-pre;
			if (lz != 0)lz--;
			l1 = pre[lz];
			l2 = ls - l1;
			long long rz = lower_bound(pre, pre + n, ls + rs / 2) - pre;
			if (rz != i + 1)rz--;
			r1 = pre[rz] - pre[i];
			r2 = rs - r1;
			long long zs = max(l1, max(l2, max(r1, r2)));
			zs = abs(zs - min(l1, min(l2, min(r1, r2))));
			if (ans == -1 || ans > zs)
				ans=zs;
			l1 = pre[lz + 1];
			l2 = ls - l1;
			r1 = pre[rz] - pre[i];
			r2 = rs - r1;
			zs = max(l1, max(l2, max(r1, r2)));
			zs = abs(zs - min(l1, min(l2, min(r1, r2))));
			if (ans == -1 || ans > zs)
				ans = zs;
			l1 = pre[lz + 1];
			l2 = ls - l1;
			r1 = pre[rz+1] - pre[i];
			r2 = rs - r1;
			zs = max(l1, max(l2, max(r1, r2)));
			zs = abs(zs - min(l1, min(l2, min(r1, r2))));
			if (ans == -1 || ans > zs)
				ans = zs;
			l1 = pre[lz];
			l2 = ls - l1;
			r1 = pre[rz+1] - pre[i];
			r2 = rs - r1;
			zs = max(l1, max(l2, max(r1, r2)));
			zs = abs(zs - min(l1, min(l2, min(r1, r2))));
			if (ans == -1 || ans > zs)
				ans = zs;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

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

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int n; cin >> n;
  vector<lint> a(n);
  vector<lint> b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  priority_queue<pair<lint, lint>> pq;

  for (int i = 0; i < n; i++) {
    cin >> b[i];
    if (b[i] > a[i]) {
      pq.push({b[i], i});
    }
  }

  lint ans = 0;
  while (!pq.empty()) {
    lint val;
    lint i;
    tie(val, i) = pq.top();
    pq.pop();

    if (b[i] > a[i]) {
      int tmp = ans;
      ans += (b[i] - a[i]) / (b[(i - 1 + n) % n] + b[(i + 1) % n]);
      if (ans == tmp) break;
      b[i] = (b[i] - a[i]) % (b[(i - 1 + n) % n] + b[(i + 1) % n]) + a[i];
      pq.push({b[i], i});
    }

  }

  for (int i = 0; i < n; i++) {
    if (b[i] != a[i]) {
      ans = -1;
    }
  }

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


Measured memory_bytes: 9328
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
k_max = 10100
score = [-10**18-1] * N

for i in range(N):
  score_i = [-10**18-1] * k_max # iからスタートしてK回操作する場合の累積和
  score_i[0] = C[P[i]-1]
  index = P[i]-1
  for k in range(1, K):
    if index == i:
      # 既に進んだことがあるマスの場合
      
      loop_score = score_i[k-1] # 1ループで増えるスコア
      if loop_score > 0:
        loop_num = k # ループする要素数はk(indexが0 ~ k-1)
        
        tmp_score = [-10**18-1] * k_max
        tmp_score[0] = (K//k -1) * loop_score
#        print("loop_score", loop_score)
#        print("tmp_score", tmp_score)
        tmp_index = index
#        print("loop_num + K%k + 1", loop_num + K%k + 1)
        for j in range (1, loop_num + K%k + 1):
          tmp_score[j] = tmp_score[j-1] + C[P[tmp_index]-1]
          tmp_index = P[tmp_index]-1
#        print("max(tmp_score)", max(tmp_score))
        score_i[k] = max(tmp_score)
      break
    score_i[k] = score_i[k-1] + C[P[index]-1]
    index = P[index]-1
  score[i] = max(score_i)
print(max(score))

Measured memory_bytes: 84976
x, y = map(int,input().split())
ans = 0

if x == 1 and y == 1:
    print(1000000)
    exit()

if x == 1:
    ans += 300000
elif x == 2:
    ans += 200000
elif x == 3:
    ans += 100000

if y == 1:
    ans += 300000
elif y == 2:
    ans += 200000
elif y == 3:
    ans += 100000

print(ans)

Measured memory_bytes: 3064
S = input()

j = [0, 0]
a = int(S[:2])
b = int(S[2:])


def judge(num):
    if num > 0 and num < 13:
        return True
    else:
        return False


if judge(a) and judge(b):
    print('AMBIGUOUS')
elif not judge(a) and not judge(b):
    print('NA')
elif judge(a) and not judge(b):
    print('MMYY')
elif not judge(a) and judge(b):
    print('YYMM')


Measured memory_bytes: 3060
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "

using namespace std;
///check n=1;
///check corner case;

int main()
{
   ll n,a,b,cc=0,i;
   cin>>a>>b;
   for(i=1;i<=10000;i++){
     ll x=i*0.08;
     ll y=i*0.1;
     if(x==a && y==b){
        cout<<i<<endl;
        return 0;
     }
   }
   cout<<-1<<endl;
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int isprime(int n){
	int i;
	for(i=2;i*i<=n;i++){
		if(n%i==0){
			return 0;
			break;
		}
	}
	return 1;
}

int main(){
	int i,n,p1,q1;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		if(isprime(n)==0){
			while(1){
				n--;
				if(isprime(n)==1) break;
			}
		}
		if(isprime(n)==1){
			p1=n;
			q1=n;
			for(i=n-1;i>0;i--){
				if(isprime(i)==1) q1=i;
				if(p1-q1==2){
					printf("%d %d\n",q1,p1);
					break;
				}else{
					p1=q1;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 600
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        h: usize,
        w: usize
    }
    if h == 1 || w == 1 {
        println!("1");
        return;
    }
    let mut ans = h / 2 * w;
    if h % 2 == 1 {
        ans += (w + 1) / 2;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4476
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  char c[n][n];
  char t[m][m];
  bool b=false;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin>>c[i][j];
    }
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
      cin>>t[i][j];
    }
  }
  for(int i=0;i<=n-m;i++){
    for(int j=0;j<=n-m;j++){
      if(c[i][j]==t[0][0]){
        b=true;
        for(int k=0;k<m;k++){
          for(int l=0;l<m;l++){
            if(c[i+k][j+l]!=t[k][l]){
              b=false;
              break;
            }
          }
        }
        if(b){
          cout<<"Yes";
          return 0;
        }
      }
    }
  }
  cout<<"No";
}

Measured memory_bytes: 256
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		   Scanner sc = new Scanner(System.in);
		   PriorityQueue <Integer>pq = new PriorityQueue<Integer>(Collections.reverseOrder());
		   
		   int n = sc.nextInt();
		   int m = sc.nextInt();
		   
		   for(int i = 0; i < n ;i++) {
			   int a = sc.nextInt();
			   pq.offer(a);
		   }
		  
		   for(int i = 0 ; i < m; i++) {
				  int b = (int)Math.floor(pq.peek()/2);
				  pq.offer(b);
				  pq.poll();
			   }
		   long sum = 0;
		   for(int i = 0; i < n ;i++) {
			   sum += pq.poll();
		   }
		   System.out.println(sum);
		
			   
		   }

	}



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

using namespace std;

using ll = long long;

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

    ll ans = 0;
    
    ll x;
    for (ll i = 0; i < N; ++i) {
        cin >> x;
        while (x % 2 == 0) {
            ++ans;
            x /= 2;
        }
    }
    
    cout << ans << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> l(n + 1), r(n + 1);
  REP(i, n + 1) {
    if (i == 0) continue;
    if (s[i - 1] == '<') {
      l[i] = l[i - 1] + 1;
    }
  }
  RREP(i, n + 1) {
    if (i == n) continue;
    if (s[i] == '>') {
      r[i] = r[i + 1] + 1;
    }
  }
  ll ans = 0;
  REP(i, n + 1) ans += max(l[i], r[i]);
  cout << ans << endl;
}

Measured memory_bytes: 4740
# ABC117 C - Streamline
n,m = map(int,input().split())
x = list(map(int,input().split()))
l = []

x.sort()
for i in range(m-1):
    l.append(x[i+1]-x[i])

ans = x[m-1] - x[0]
l.sort(reverse=True)

for i in range(min(n-1,m-1)):
    ans -= l[i]
print(max(ans,0))

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

int main(){
  int n, t=0, c;
  cin >> n;
  int a[n];
  rep(i,0,n) cin >> a[i];
  rep(i,0,n-1){
    rep(j,i+1,n){
      c=a[i]*a[j];
      t+=c;
    }
  }
  cout << t << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define LL long long
#define MP make_pair
#define PB push_back
#define I insert

const LL mod=1000000007, N=200005;
using namespace std;

LL n, m, i, j, k, l, r, t, ans;
double d, e;

int main(){
	cin >> d;
	d /= 3;
	e = d*d*d;
	printf("%.12f\n",e);

	return 0;
}
//      IIIIIIIII      OOOOO             A          NN        N    EEEEEEEEEE
//          I         O     O           A A         N N       N    E
//          I        O       O         A   A        N  N      N    E
//          I        O       O        A     A       N   N     N    E
//          I        O       O       AAAAAAAAA      N    N    N    EEEEEEEE
//          I        O       O      A         A     N     N   N    E
//          I        O       O     A           A    N      N  N    E
//          I         O     O     A             A   N       N N    E
//      IIIIIIIII      OOOOO     A               A  N        NN    EEEEEEEEEE ___ KAPANADZE




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

int main(){
  string S;cin>>S;
  priority_queue<int> ans;
  int l=S.size();
  for(int i=2;i<l;i+=2){
    int j=i/2;
    string T1=S.substr(0,j);
    string T2=S.substr(j,j);
    if(T1==T2) ans.push(i);
  }
  cout<<ans.top()<<endl;
}
    

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

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

    vector<int> A(N+1);
    repd(i,1,N+1) cin >> A[i];
    vector<int> Ad(N+1,0);
    for(int i=N;i>0;i--){
        Ad[i]^=A[i];
        if(Ad[i]==1 && i!=1){
            //cout<<"e"<<i<<endl;
            Ad[1]^=1;
            for(int k=2;k*k<=i;k++){
                if(i%k==0){
                    Ad[k]^=1;
                    if(i/k!=k) Ad[i/k]^=1;
                }
            }
        }
    }
    //dbg_v1(i,Ad);
    vector<int> X;
    repd(i,1,N+1){
        if(Ad[i])X.push_back(i);
    }
    cout<<X.size()<<endl;
    rep(i,X.size()){
        if(i!=0) printf(" %d",X[i]);
        else printf("%d",X[i]);
    }
    cout<<endl;
    return (0);
}

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

int main() {
  int n,a,b;
  cin >> n >> a >> b;
  
  if(n>=a+b){
    cout << min(a,b) << " " << "0" << endl;
  }
  
  else{
    cout << min(a,b) << " " << a+b-n << endl;
  }
}

Measured memory_bytes: 256
#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);
    lint n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    vector<int> l(n), r(n), mini(n);
    for (int i = 0; i < n; ++i) {
        int ns = s[i].size();
        int rs = 0, ls = 0;
        int cnt = 0;
        for (int j = 0; j < ns; ++j) {
            if (s[i][j] == '(')
                cnt++;
            else
                cnt--;
            mini[i] = min(mini[i], cnt);
        }
        for (int j = 0; j < ns; ++j) {
            if (s[i][j] == ')') {
                if (rs == 0)
                    l[i]++;
                else
                    rs--;
            } else {
                rs++;
            }
        }
        for (int j = ns - 1; j >= 0; --j) {
            if (s[i][j] == '(') {
                if (ls == 0)
                    r[i]++;
                else
                    ls--;
            } else {
                ls++;
            }
        }
    }
    vector<pair<int, int>> left, right, midpos, midneg;
    for (int i = 0; i < n; ++i) {
        if (r[i] == 0 && l[i] == 0)
            continue;
        else if (r[i] == 0)
            left.emplace_back(0, l[i]);
        else if (l[i] == 0)
            right.emplace_back(0, r[i]);
        else if (r[i] - l[i] >= 0)
            midpos.emplace_back(-mini[i], r[i] - l[i]);
        else
            midneg.emplace_back(-mini[i], -r[i] + l[i]);
    }
    sort(midpos.begin(), midpos.end());
    sort(midneg.begin(), midneg.end());

    lint brar = 0;
    for (auto &rr : right) {
        brar += rr.second;
    }
    for (auto &mm : midpos) {
        if (brar - mm.first < 0) {
            cout << "No"
                 << "\n";
            return 0;
        }
        brar += mm.second;
    }
    lint bral = 0;
    for (auto &ll : left) {
        bral += ll.second;
    }
    for (auto &mm : midneg) {
        if (bral - mm.first < 0) {
            cout << "No"
                 << "\n";
            return 0;
        }
        bral += mm.second;
    }
    if (bral == brar) {
        cout << "Yes"
             << "\n";
    } else {
        cout << "No"
             << "\n";
    }
    return 0;
}

Measured memory_bytes: 54228
Sa = gets.chomp.chars.reverse
Sb = gets.chomp.chars.reverse
Sc = gets.chomp.chars.reverse

card = 'a'
loop do
  case card
  when 'a'
    if Sa.size == 0
      puts 'A'
      exit
    end
    card = Sa.pop
  when 'b'
    if Sb.size == 0
      puts 'B'
      exit
    end
    card = Sb.pop
  when 'c'
    if Sc.size == 0
      puts 'C'
      exit
    end
    card = Sc.pop
  end
end

Measured memory_bytes: 1788
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  int n,d;cin>>n>>d;
  int a[n][d];
  for(int i = 0; n > i; i++){
    for(int j = 0; d > j; j++){
      cin>>a[i][j];
    }
  }
  int ans = 0;
  for(int i = 0; n > i; i++){
    for(int j = i; n > j; j++){
      if(i==j)continue;
      int tmp = 0;
      for(int k = 0; d > k; k++){
        tmp += abs(a[i][k]-a[j][k])*abs(a[i][k]-a[j][k]);
      }
      if(floor(sqrt(tmp))*floor(sqrt(tmp))==tmp)ans++;
    }
  }
  cout << ans << endl;
}
      

Measured memory_bytes: 256
//============================================================================
// Name        : MergeSort.cpp
// Author      : Ken
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int n_comparison = 0;
long long int n_inversion = 0;

void writeVector(const vector<int>& A){
	for(int i=0; i<A.size()-1; i++){
		cout << A.at(i) << " ";
	}
	cout << A.at(A.size()-1);
	//cout << "\n";
}

void Merge(vector<int>& A, int left, int mid, int right){
	//cout << "Merge([";
	//writeVector(A);
	//cout << "], " << left << ", " << mid << ", " << right << ")\n";
	int n1 = mid - left;
	int n2 = right - mid;

	vector<int> L(n1+1);
	vector<int> R(n2+1);

	for(int i=0; i<n1; i++){
		L.at(i) = A.at(left + i);
	}
	L.at(n1) = pow(10, 9) + 1;
	//cout << "L: ";
	//writeVector(L);

	for(int i=0; i<n2; i++){
		R.at(i) = A.at(mid + i);
	}
	R.at(n2) = pow(10, 9) + 1;
	//cout << "R: ";
	//writeVector(R);

	int i = 0, j = 0;
	for(int k=left; k<right; k++){
		if(L.at(i) <= R.at(j)){
			//cout << "i: " << i << "\n";
			A.at(k) = L.at(i);
			i++;
			//n_comparison ++;
		}else{
			//cout << "j: " << j << "\n";
			//n_comparison ++;
			n_inversion += (n1 - i);
			A.at(k) = R.at(j);
			j++;

		}
	}
	//writeVector(A);
}

void MergeSort(vector<int>& A, int left, int right){
	//cout << "MergeSort([";
	//writeVector(A);
	//cout << "], " << left << ", " << right << ")\n";
	if(left+1 < right){
		int mid = (left + right)/2;
		MergeSort(A, left, mid);
		MergeSort(A, mid, right);
		Merge(A, left, mid, right);
	}
}

int main() {
	int n, input;
	cin >> n;
	vector<int> A;
	for(int i=0; i<n; i++){
		cin >> input;
		A.push_back(input);
	}

	MergeSort(A, 0, n);
	//writeVector(A);
	//cout << "\n";
	//cout << n_comparison << "\n";
	cout << n_inversion << "\n";

	return 0;
}



Measured memory_bytes: 4368
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<numeric>

int main(){
    int a = 0;
    int b = 0;
    int c = 0;
    int k = 0;

    std::cin >> a >> b >> c >> k;

    int sum = 0;
    if(k <= a){
        std::cout << k;
    }
    else if((a < k) && (k <= a + b)){
        std::cout << a;
    }
    else
    {
        std::cout << a * 2 - k + b;
    }
}

Measured memory_bytes: 3580
n, m = map(int, input().split())

k = []
s = []
for _ in range(m):
    ks = list(map(int, input().split()))
    k.append(ks[0])
    s.append(ks[1:])
p = list(map(int, input().split()))

ans = 0
for bits in range(2**n):
    flag = True
    for i in range(m):
        on_sum = 0
        for switch in s[i]:
            on_sum += ((bits >> (switch - 1)) & 1)
        flag = flag and ((on_sum % 2) == p[i])
    if flag:
        ans += 1

print(ans)




Measured memory_bytes: 40432
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int ans = a*x + b*y;
    ans = min(ans, c*x*2 + b*max(0,(y-x)));
    ans = min(ans, c*y*2 + a*max(0,(x-y)));

    cout << ans << endl;
}

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

#define llint long long int
#define pb push_back

using namespace std;


int main(){
  int x[4], y[4];
  cin >> x[0] >> y[0] >> x[1] >> y[1];
  if(x[0] <= x[1]){
    if(y[0] <= y[1]){
      x[2] = x[1] - abs(y[1] - y[0]);
      y[2] = y[1] + abs(x[1] - x[0]);
      
      x[3] = x[0] - abs(y[1] - y[0]);
      y[3] = y[0] + abs(x[1] - x[0]);
    }
    else{
      x[2] = x[1] + abs(y[1] - y[0]);
      y[2] = y[1] + abs(x[1] - x[0]);
      
      x[3] = x[0] + abs(y[1] - y[0]);
      y[3] = y[0] + abs(x[1] - x[0]);
    }
  }
  else{
    if(y[0] <= y[1]){
      x[2] = x[1] - abs(y[1] - y[0]);
      y[2] = y[1] - abs(x[1] - x[0]);
      
      x[3] = x[0] - abs(y[1] - y[0]);
      y[3] = y[0] - abs(x[1] - x[0]);
    }
    else{
      x[2] = x[1] + abs(y[1] - y[0]);
      y[2] = y[1] - abs(x[1] - x[0]);
      
      x[3] = x[0] + abs(y[1] - y[0]);
      y[3] = y[0] - abs(x[1] - x[0]);
    }
  }
  cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3];
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int k = sc.nextInt();
    while(k > 0){
      if(a >= b){
        b *= 2;
      } else {
        c *= 2;
      }
      k--;
    }
    if(a < b && b < c){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35592
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        for(;;){
            int n = in.nextInt(), p = in.nextInt();
            if(n==0 && p==0) return ;
            int cup = p, pos = 0;
            int ns[] = new int[n];
            for(;;){
                if(cup>0){
                    ns[pos]++;
                    if(ns[pos]==p) break;
                    cup--;
                }
                else{
                    cup += ns[pos];
                    ns[pos] = 0;
                }
                pos = (pos+1)%n;
            }
            System.out.println(pos);
        }
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> ordered_mset;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
/*.....................................................................................................................*/

    const ll mod=(ll)1e9+7;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;}
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const ll man=(ll)1e5+5;
/*........................................................................................................................*/

signed main()
{
    fast;
    ll n,m;
    cin>>n>>m;
    if(m<n)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}   


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

using namespace std;

int main() {
  int n, d;
  cin >> n >> d;
  int x = d * 2 + 1;
  if (n % x == 0) {
    cout << n / x << endl;
  } else {
    cout << n / x + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main(int argc, char** argv) {
    int A, B;
    cin >> A >> B;
    int lower_1 = A / 0.08;
    int upper_1 = (A+1) / 0.08;
    int lower_2 = B / 0.1;
    int upper_2 = (B+1) / 0.1;

    int lower = max(lower_1, lower_2);
    int upper = min(upper_1, upper_2);

    int res = -1;
    for (int i = lower; i <= upper; i++) {
        if (int(i * 0.08) == A && int(i * 0.1) == B) {
            res = i;
            break;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define lli long long int
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}
ll a[200001];
ll pre[200001];
int main()
{
   ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
ll n;
cin>>n;
for(ll i=0;i<n;i++)
{
	cin>>a[i];
}
ll ans=0;
 pre[n-1]=a[n-1];
for(ll i=n-2;i>=0;i--)
{
	pre[i]=pre[i+1]+a[i];
	pre[i]=pre[i]%mod;
}
for(int i=0;i<n-1;i++)
{
	ll value=a[i]*pre[i+1];
	value=value%mod;
	ans=ans+value;
	ans=ans%mod;
	
}
cout<<ans%mod<<endl;
}
 
 

Measured memory_bytes: 6788
import collections
def main():
    N = int(input())
    s = [input() for i in range(N)]
    ss = collections.Counter(s).most_common()
    #maxcount = ss[0][1]
    sss = sorted([ss[i][0] for i in range(len(ss)) if ss[i][1] == ss[0][1]])
    for i in range(len(sss)):
        print(sss[i])
main()

Measured memory_bytes: 45032
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	uint64_t N, A, B;
	if (scanf("%" SCNu64 "%" SCNu64 "%" SCNu64, &N, &A, &B) != 3) return 1;
	if (A > B || (N == 1 && A != B)) {
		puts("0");
	} else {
		printf("%" PRIu64 "\n", (B * (N - 1) + A) - (A * (N - 1) + B) + 1);
	}
	return 0;
}

/*
「1個だけB、残りA」から「1個だけA、残りB」まで、1ずつ増やすことで全部作れる
*/


Measured memory_bytes: 1700
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 2;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregion

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

  int h, w, n, sr, sc;
  string s, t;
  cin >> h >> w >> n;
  cin >> sr >> sc >> s >> t;
  int L = sc, R = sc;
  int L_cnt = 0, R_cnt = 0;
  rep(i, n)
  {
    if (s[i] == 'R')
    {
      R++;
    }
    else if (s[i] == 'L')
    {
      L--;
    }

    if (L <= 0)
    {
      if (R_cnt > 0)
      {
        R_cnt--;
        L++, R++;
      }
      else
      {
        YES(false);
        return 0;
      }
    }
    else if (R > w)
    {
      if (L_cnt > 0)
      {
        L_cnt--;
        L--, R--;
      }
      else
      {
        YES(false);
        return 0;
      }
    }

    if (t[i] == 'L')
    {
      if (L == R)
      {
        if (L - L_cnt > 1)
          L_cnt++;
      }
      else
      {
        R--;
      }
    }
    else if (t[i] == 'R')
    {
      if (L == R)
      {
        if (R + R_cnt < w)
          R_cnt++;
      }
      else
      {
        L++;
      }
    }
  }
  L = R = sr;
  L_cnt = R_cnt = 0;
  rep(i, n)
  {
    if (s[i] == 'D')
    {
      R++;
    }
    else if (s[i] == 'U')
    {
      L--;
    }
    if (L <= 0)
    {
      if (R_cnt > 0)
      {
        R_cnt--;
        L++, R++;
      }
      else
      {
        YES(false);
        return 0;
      }
    }
    else if (R > h)
    {
      if (L_cnt > 0)
      {
        L_cnt--;
        L--, R--;
      }
      else
      {
        YES(false);
        return 0;
      }
    }

    if (t[i] == 'U')
    {
      if (L == R)
      {
        if (L - L_cnt > 1)
          L_cnt++;
      }
      else
      {
        R--;
      }
    }
    else if (t[i] == 'D')
    {
      if (L == R)
      {
        if (R + R_cnt < h)
          R_cnt++;
      }
      else
      {
        L++;
      }
    }
  }
  YES(true);
  return 0;
}


Measured memory_bytes: 920
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 2e5+10;
int n,m,ans,a[N],l,r,L[N],R[N];
map<pa,int>f;
set<int>s;

int main(){
	n=read(),m=read();
	For(i,1,n) a[i]=read();
	For(i,1,m) s.insert(a[i]);
	r=m;
	set<int>::iterator it=--s.end();
	while (a[r]==*it&&r>1) --r,--it;
	R[m]=r;
	For(i,m+1,n){
		s.insert(a[i]);
		if (*(--s.end())!=a[i]) r=i;
		s.erase(a[i-m]);
		R[i]=r;
	}
	s.clear();
	For(i,n-m+1,n) s.insert(a[i]);
	l=n-m+1;
	it=s.begin();
	while (a[l]==*it&&l<n) ++l,++it;
	L[n-m+1]=l;
	Dow(i,n-m,1){
		s.insert(a[i]);
		if (*s.begin()!=a[i]) l=i;
		s.erase(a[i+m]);
		L[i]=l;
	}
	For(i,1,n-m+1){
		auto tmp=L[i]>R[i+m-1]?mp(0,0):mp(L[i],R[i+m-1]);
		if (!f[tmp]) f[tmp]=1,++ans;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 18520
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	ar<int,2> a[n],b[m];
	for(int i = 0;i<n;i++)
		cin>>a[i][0]>>a[i][1];
	for(int i = 0;i<m; i++)
		cin>>b[i][0]>>b[i][1];
	for(int i = 0; i<n;i++)
	{
		ll ans = INT_MAX,k=-1;
		ar<int,2>w;
		for(int  j =0;j <m; j++)
		{
			int y = abs(a[i][0]-b[j][0])+abs(a[i][1]-b[j][1]);
			if(ans>y)
			{
				ans = y;
				w=b[j];
				k = j+1;
			}
			else if(ans==y)
			{
				if(w>b[j])
				{
					k = j+1;
					w = b[j];
				}
			}
		}
		cout<<k<<endl;
	}
	return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS(N) resize(N)
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

vector<int> v;
int N;

void init()
{
	cin >> N;
	CINV(v, N);
}

void solve()
{
	int res = 0;
	rep(i, N) rep(j, N) {
		res = max(res, abs(v[i]-v[j]));
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    char a;
    cin >> a;
    if(a=='A')
        cout << 'T';
    else if(a=='T')
    cout << 'A';
    else if(a=='C')
        cout << 'G';
    else
        cout << 'C';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define REP(i,n) for(int i=0;i<n;++i)
#define INF (2<<30)
using namespace std;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int y, m, d;
  bool f = true;
  cin >> s;
  y = atoi(s.substr(0, 4).c_str());
  m = atoi(s.substr(5, 2).c_str());
  d = atoi(s.substr(8, 2).c_str());
  if(y > 2019) {
    f = false;
  } else if(y == 2019) {
    if(m > 4) {
      f = false;
    }
  }
  cout << (f ? "Heisei" : "TBD") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007


int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> S(3000, vector<char>(3000));
  rep(i, H) {
    rep(j, W) {
      cin >> S[i][j];
    }
  }

  vvi a(3000, vi(3000, 0)), hashx(3000, vi(3000, 0));
  rep(i, H) {
    int res = 0;
    rep(j, W) {
      if (S[i][j] == '#') {
        res++;
      }
      else if (S[i][j] == '.') {
        a[i][j] = res;
        hashx[i][res]++;
      }
    }
  }

  vvi b(3000, vi(3000, 0)), hashy(3000, vi(3000, 0));
  rep(j, W) {
    int res = 0;
    rep(i, H) {
      if (S[i][j] == '#') {
        res++;
      }
      else if (S[i][j] == '.') {
        b[i][j] = res;
        hashy[res][j]++;
      }
    }
  }
  int ans = 1;
  rep(i, H) {
    rep(j, W) {
      if (S[i][j] == '.') {
        int tmp = hashx[i][a[i][j]] + hashy[b[i][j]][j] - 1;
        ans = max(tmp, ans);
      }
    }
  }
  cout << ans << endl;

}





Measured memory_bytes: 150272
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int x = Integer.parseInt(br.readLine());
		String line = br.readLine();
		String[] str = line.split(" ");
		int a = 0;
		for (int i = 0; i < x; i++) {
			a = a + Integer.parseInt(str[i]);
		}
		if (a % 2 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 37588
a, b = map(int, input().split())
s = input()

if s[a] != "-":
    print("No")
elif len(s.split("-")) != 2:
    print("No")
else:
    h = s.split("-")
    if len(h[0]) == a and len(h[1]) == b:
        print("Yes")
    else:
        print("No")





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

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

    vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    sort(p.begin(), p.end());

    int sum = 0;
    for (int i = 0; i < k; i++)
    {
        sum += p[i];
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3624