akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.StringTokenizer;
import java.util.Arrays;

class Point {
	int x,y;
	Point(int x,int y) {
		this.x = x;
		this.y = y;
	}
}

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;
		int w,h,xs,ys,xg,yg,n,c,d,x,y;

		try {
			while (!(buf = br.readLine()).equals("0 0")) {
				StringTokenizer st = new StringTokenizer(buf);
				w = Integer.parseInt(st.nextToken());
				h = Integer.parseInt(st.nextToken());
				int board[][] = new int[h][w];
				int check[][] = new int[h][w];
				for (int i=0;i<h;i++) {
					Arrays.fill(board[i],-1);
					Arrays.fill(check[i],0);
				}
				st = new StringTokenizer(br.readLine());
				xs = Integer.parseInt(st.nextToken())-1;
				ys = Integer.parseInt(st.nextToken())-1;
				st = new StringTokenizer(br.readLine());
				xg = Integer.parseInt(st.nextToken())-1;
				yg = Integer.parseInt(st.nextToken())-1;
				n = Integer.parseInt(br.readLine());
				for (int i=0;i<n;i++) {
					st = new StringTokenizer(br.readLine());
					c = Integer.parseInt(st.nextToken());
					d = Integer.parseInt(st.nextToken());
					x = Integer.parseInt(st.nextToken());
					y = Integer.parseInt(st.nextToken());
					PutBlock(board,x,y,c,d);
				}
				if (board[ys][xs]==-1) {
					System.out.println("NG");
					continue;
				}
				boolean OK = false;
				Point queue[] = new Point[h*w];
				int p = 0;
				queue[p++] = new Point(xs,ys);
				while (p>0) {
					Point dq = queue[--p];
					check[dq.y][dq.x] = 1;
					if (dq.x==xg&&dq.y==yg) {
						OK = true;
						break;
					}
					if (dq.x>0) {
						if (board[dq.y][dq.x-1]==board[dq.y][dq.x]&&check[dq.y][dq.x-1]==0) {
							queue[p++] = new Point(dq.x-1,dq.y);
						}
					}
					if (dq.x<w-1) {
						if (board[dq.y][dq.x+1]==board[dq.y][dq.x]&&check[dq.y][dq.x+1]==0) {
							queue[p++] = new Point(dq.x+1,dq.y);
						}
					}
					if (dq.y>0) {
						if (board[dq.y-1][dq.x]==board[dq.y][dq.x]&&check[dq.y-1][dq.x]==0) {
							queue[p++] = new Point(dq.x,dq.y-1);
						}
					}
					if (dq.y<h-1) {
						if (board[dq.y+1][dq.x]==board[dq.y][dq.x]&&check[dq.y+1][dq.x]==0) {
							queue[p++] = new Point(dq.x,dq.y+1);
						}
					}
				}
				if (OK) System.out.println("OK");
				else System.out.println("NG");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void PutBlock(int[][] b,int x,int y,int c,int target) {
		if (target==0) {
			for (int i=y-1;i<y+1;i++) {
				for (int j=x-1;j<x+3;j++) b[i][j] = c;
			}
		} else {
			for (int i=y-1;i<y+3;i++) {
				for (int j=x-1;j<x+1;j++) b[i][j] = c;
			}
		}
	}

	public static void PrintBoard(int[][] b,int h,int w) {
		for (int i=0;i<h;i++) {
			for (int j=0;j<w;j++) System.out.print(b[i][j]+" ");
			System.out.println();
		}
	}
}

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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;

typedef long long LL;
typedef vector <LL> VLL;

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

    int X, Y, Z;
    cin >> X >> Y >> Z;
    int K;
    cin >> K;


    VLL A(X), B(Y), C(Z);
    REP(i, X) {
        cin >> A[i];
    }

    REP(i, Y) {
        cin >> B[i];
    }

    REP(i, Z) {
        cin >> C[i];
    }

    sort(A.rbegin(), A.rend());
    sort(B.rbegin(), B.rend());
    sort(C.rbegin(), C.rend());

    using tp = tuple<LL, int, int, int>;
    priority_queue<tp> cand;
    set<tuple<int, int, int>> open;

    cand.push(tp(A.front() + B.front() + C.front(), 0, 0, 0));

    while(K) {
        LL v;
        int a, b, c;
        tie(v, a, b, c) = cand.top(); cand.pop();

        if (open.count(make_tuple(a, b, c))) continue;

        if (a + 1 < X) {
            cand.push(tp(A[a + 1] + B[b] + C[c], a + 1, b, c));
        }

        if (b + 1 < Y) {
            cand.push(tp(A[a] + B[b + 1] + C[c], a, b + 1, c));
        }

        if (c + 1 < Z) {
            cand.push(tp(A[a] + B[b] + C[c + 1], a, b, c + 1));
        }

        printf("%lld\n", v);
        --K;
        open.insert(make_tuple(a, b, c));

    }
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>
#include<bitset>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const double EPS = 0.000000000001;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================


	ll N, M;
	cin >> N;
	vector<ll> A(N);
	for (ll i = 0; i < N; i++) {
		cin >> A[i];
	}

	for (ll i = 1; i < N; i++) {
		A[i] += A[i - 1];
	}

	ll ans = LLINF;
	for (ll i = 0; i < N- 1; i++) {
		ans = min(ans, abs( 2 * A[i] - A[N - 1]));
	}

	cout << ans;

}


Measured memory_bytes: 1792
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val Array(n, m) = in.readLine.split(" ").map(_.toInt)
  val ki = Iterator.continually(in.readLine)
    .take(m)
    .map(_.split(" ").map(_.toInt))
    .toArray
  val p = in.readLine.split(" ").map(_.toInt)

  val ans = dfsEnum(2, n)
  println(ans)

  def dfsEnum(d:Int, n:Int):Int = {
    // d進 n個列挙
    val graph = Array.fill(m)(mu.ListBuffer.empty[Int])
    val enum = Array.ofDim[Boolean](n)
    var ret = 0

    // initialize
    for {
      i <- 0 until m
      j <- ki(i)(0) to 1 by -1
    } (ki(i)(j) - 1) +=: graph(i)
  
    def evalute():Unit = {
      val res = (0 until m)
        .map(i => graph(i).count(enum(_) == true) % 2 == p(i))
        .forall(_ == true)

      if(res) ret += 1
    }
  
    def dfs(cnt:Int):Unit = {
      if(cnt == n) evalute
      else {
        for(b <- List(false, true)) {
          enum(cnt) = b
          dfs(cnt+1)
        }
      }
    }
  
    dfs(0)
    ret
  }

}

Measured memory_bytes: 28496
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int N;
  cin >> N;
  cout << (N*(N-1)/2) << endl;
}

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


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.Collectors;

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

        int n = sc.nextInt();

        System.out.println(solve(n));

        sc.close();
    }

    static String solve(int n) {
        return String.valueOf(n).chars().mapToObj(ch -> String.valueOf((char) ('1' + '9' - ch)))
                .collect(Collectors.joining());
    }
}

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

int main(){
  int x,n;
  cin >> x >> n;
  if(n == 0){
    cout << x << endl;
    return 0;
  }
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  vector<int> q(200);
  rep(i,200){
    q[i] = 101-i;
    rep(j,n){
      if(101-i == p[j]){
        q[i] = 500;
      }
    }
  }
  int ans = 200;
  int count;
  rep(i,200){
    if(ans >= abs(x-q[i])){
      count = 101-i;
      ans = abs(x-q[i]);
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3628
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val fs = Array(n, { readLine()!!.replace(" ", "").let { Integer.parseInt(it, 2) } })
    val pMat = Array(n, { readLine()!!.split(" ").map(String::toInt) })
    val ans = (1 until 1024).map { x -> (0 until n).map { pMat[it][bitCount(x.and(fs[it]))] }.sum() }.max()
    println(ans)
}

fun bitCount(x: Int): Int {
    return Integer.toString(x, 2).filter { it == '1' }.length
}


Measured memory_bytes: 49204
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,b)  for(int i=0;i<(int)(b);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;

using namespace std;

int main(){
    cs
    ll x,a=100,t=0;
    cin>>x;
    while(a<x){
        t++;
        a=a+floor(a*0.01);
    }
    cout<<t;
}

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






int main() {
  string x,t;
  cin>>x>>t;
  
  int sizex=int(x.size());
  int sizet=int (t.size());
  
  string answer="UNRESTORABLE";
  

  
  for (int i=0;i<sizex-sizet+1;i++){
    int flag=1;
    for (int j=0;j<sizet;j++){
      if (x.at(sizex-sizet-i+j)!='?' and x.at(sizex-sizet-i+j)!=t.at(j)){
      flag=0;
      }
    }
    
    if (flag==1){
      string answertext=x;
      for (int k=sizex-sizet-i;k<sizex-i;k++){
        answertext.at(k)=t.at(k-sizex+sizet+i);
      }
      
      for (int k=0;k<sizex;k++){
        if (answertext.at(k)=='?'){
          answertext.at(k)='a';
        }
      }
      
      answer=answertext;
      break;
    }
  }
  
  cout<<answer<<endl;
        
      
      
      
  



  
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

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


void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

#define ll long long
#define ld long double
#define ull unsigned long long
#define ull unsigned long long
#define mod 1000000007
#define pi (3.1415926)

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

#define scd(a)  scanf("%lld",&a)
#define scdd(a,b)	scanf("%lld%lld",&a,&b)
#define scddd(a,b,c)	scanf("%lld%lld%lld",&a,&b,&c)
#define ptab(a)	printf("%lld ",a)
#define pdn(a)	printf("%lld\n",a)
#define pddn(a,b)	printf("%lld %lld\n",a,b)
#define pdddn(a,b,c)	printf("%lld %lld %lld\n",a,b,c)

#define forr(n) for(ll i=0;i<n;i++)
#define rev(n) for(ll i=n-1;i>=0;i--)
#define forp(x, y) for(ll i=x;i<y;i++)
#define loop( j, k, in) for (ll i=j ; i<k ; i+=in)

#define in  cin>>
#define out cout<<
#define en "\n"
#define sp " "
#define eps 1.0E-14
#define l length()

int N;
char ans[111];

void DFS(int cur,int mx){
//    printf("cur = %d\n",cur);
    if(cur==N){
        ans[N]='\0';
        printf("%s\n",ans);
        return;
    }
    for(int i=0;i<=cur;i++){
        ans[cur]='a'+i;
        DFS(cur+1,max(mx,i));
        if(i>mx) break;
    }
}

void work(){
    scanf("%d",&N);
    DFS(0,0);
}

ll sum (int n ){return ((n*(n+1)) / 2) ;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main()
{
    init();

    string s , d=""; cin>>s; short k= s.l / 2;

    for (short i=0 ; i<k ;++i)
     d+="hi";

    if (d == s) cout << "Yes";
    else cout << "No";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int n; cin >> n;
    int w = 0;
    int a = 0;
    int t = 0;
    int c = 0;
    rep(i,n){
        string s; cin >> s;
        if (s == "WA") w++;
        if (s == "AC") a++;
        if (s == "TLE") t++;
        if (s == "RE") c++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << w << endl;
    cout << "TLE x " << t << endl;
    cout << "RE x " << c << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9,mod=1e9+7;
typedef long long ll;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
using namespace std;
int val[1000001],f[1000001],cnt[20],vis[1000001],js,x,y,z,ans,n,len=(1<<15);
int main() {
	n=read(),len=(1<<15);
	for(int i=1; i<n; i++)
		x=read(),y=read(),z=read(),val[x]^=z,val[y]^=z;
	for(int i=0; i<n; i++)
		cnt[val[i]]++;
	for(int i=1; i<=15; i++)
		ans+=cnt[i]/2,js|=(cnt[i]&1)<<(i-1);
	for(int i=1; i<len; i++)
		f[i]=f[i>>1]+(i&1);
	for(int i=1; i<len; i++)
		f[i]--;
	for(int i=1; i<len; i++)
		for(int j=0; j<15; j++)
			if((i>>j)&1)
				vis[i]^=(j+1);
	for(int i=1; i<len; i++) {
		if(vis[i]) continue;
		for(int k=(i-1)&i; k; k=(k-1)&i)
			if(!vis[k])
				f[i]=min(f[i],f[k]+f[i^k]);
	}
	printf("%d",ans+f[js]);
	return 0;
}

Measured memory_bytes: 6528
/* Press F to pay respects */
#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds; 
using namespace std;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
//typedef tree<int, null_type, less<int>, rb_tree_tag, 
//             tree_order_statistics_node_update> 
//    data_set;
#define rep(i,l,r)   for(int i=(l);i<(r);i++)
#define deb(x)     cout << (#x) << " is " << (x) << endl
#define dbg(x)     cout << x << ' '
#define here cout << " Hey baitch!!\n";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
const int MOD = 1e9+7;
const int MOD1 = 998244353;
const int N = 2e5+5;
const int INF = 1000111000111000111LL;
const ld PI = 3.1415926535898;
void add(int &a, int b) {
	a += b;
	if(a >= MOD)	
		a -= MOD;
	if(a < 0)
		a += MOD;
}
int32_t main()
{
	SYNC
	int n; string s; cin >> n >> s;
	int dp[n+6][n+6];
	memset(dp,0,sizeof dp);
	dp[1][1] = 1;
	for(int i = 2; i <= n; i++) 
	{
		int sign = (s[i-2]=='<');
		for(int j = 1; j <= i; j++) 
		{
			if(sign && j > 1)
				add(dp[i][j],dp[i-1][j-1]);
			if(!sign)
				add(dp[i][j],dp[i-1][i-1]-dp[i-1][j-1]);
		}
		for(int j = 2; j <= i; j++) add(dp[i][j],dp[i][j-1]);
	}
	// rep(i,1,5) {
	// 	rep(j,1,5) {
	// 		cout << dp[i][j] << ' ';
	// 	}cout << endl;
	// }
	cout << dp[n][n];
    return 0;
}

Measured memory_bytes: 70912
/* Be your own light */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

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

    ll n,m,i;
    cin>>n;
    vector<ll> a(n);
    for(i=0;i<n-1;i++) cin>>a[i];
    map<ll,ll> mp;
    for(i=0;i<n-1;i++)
    {
        mp[a[i]]++;
    }
    for(i=1;i<=n;i++) cout<<mp[i]<<"\n";
}

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

using namespace std;

const long long MOD = 1000000007;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}

long long digits(long long n){
    return log10(n) + 1;
}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

    string s;
    int a = 0, b = 0, c = 0;

    cin >> s;

    for(char i : s){
        if(i == 'a')
            ++a;
        if(i == 'b')
            ++b;
        if(i == 'c')
            ++c;
    }

    if(max(max(a, b), c) - min(min(a, b), c) > 1)
        cout << "NO";
    else
        cout << "YES";

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
ll factorial(ll a){return a < 2 ? 1 : factorial(a - 1) * a;}
ll summation(ll a){return a < 1 ? 0 : (a * a + a) / 2;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ll N = 300005;
const string ALPHABETS = "abcdefghijklmnopqrstuvwxyz";
ll dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
//ll dx[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
ll n, m, x, y, z, w, h;
string s, t;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n){
        ll ans = 0, tmp = 0, cnt = 0, mx = -INF, mn = INF;
        ll a[N] = {}, b[N] = {}, c[N] = {};
        vll v;
        rep(i, n){
            cin >> x;
            if(x % 2){
                cnt++;
            }
        }
        print(cnt % 2 ? "NO" : "YES");
    }
}


Measured memory_bytes: 256
h,w = map(int, input().split())
# print(h,w)
row = []
for x in range(h):
    col = list(input())
    row.append(col)

out = "Yes"

for x in range(h):
    for y in range (w):
        if row[x][y] == "#":
           #print(x,y)
            if  x > 0 and row[x-1][y] == "#":
                pass
            elif x < h-1 and row[x+1][y] == "#":
                pass
            elif y > 0 and row[x][y-1] == "#" :
                pass
            elif y < w-1  and row [x][y+1] == "#" :
                pass
            else:
                out = "No"
                break
        pass

print(out)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#include <unordered_set>

//#define _USE_MATH_DEFINES
//#include <math.h>


#include <vector>
#include <list>

#include <set>
#include <map>

#include <unordered_map>

#include <queue>

#include <string>

#include <vector>

#define sqr(x) (x) * (x)

#include <algorithm>
#include <functional>

#include <bitset>

#include <functional>

#include <chrono>

typedef unsigned int u32;
typedef int i32;

typedef unsigned long long int u64;
typedef long long int i64;

typedef uint16_t u16;
typedef int16_t i16;

typedef uint8_t u8;
typedef int8_t i8;


using namespace std;
using namespace std::chrono;

struct less_key
{
    bool operator() (pair<i64, i64> p1, pair<i64, i64> p2)
    {
        return (p1.first < p2.first || (p1.first == p2.first && p1.second < p2.second));
    }
};

struct pair_hash
{
    std::size_t operator()(const pair<i64, i64>& k) const
    {
        return static_cast<size_t>(k.first ^ k.second);
    }
};


#include <random>

const i64 mod = 1000000007ll;
const i64 inf = 10000000000000007ll;

const i64 mod2 = 998244353ll;

const double eps = 0.00000001;

const int maxn = 100;
i64 C[maxn + 1][maxn + 1];

void fill_cnk() {
    for (i64 n = 0; n <= maxn; ++n) {
        C[n][0] = 1;
        C[n][n] = 1;
        for (i64 k = 1; k < n; ++k) {
            C[n][k] = (C[n - 1][k - 1] + C[n - 1][k]) % mod;
        }
    }
}

i64 tdp[10][2];

i64 dp[102][10];


void fill_tdp(i64 w) {
    tdp[0][0] = 1;
    tdp[1][0] = 1;
    tdp[1][1] = 1;

    for (i64 i = 2; i <= w; i++) {
        tdp[i][0] = tdp[i - 1][0] + tdp[i - 1][1];
        tdp[i][1] = tdp[i - 1][0];
    }
}

i64 f(i64 x) {
    return tdp[x][0] + tdp[x][1];
}

i64 L[10];
i64 R[10];
i64 E[10];

void fill_pre(i64 w) {
    for (i64 i = 1; i <= w; i++) {
        i64 l = max(0ll, i - 3);
        i64 r = max(0ll, w - (i + 1));

        L[i] = f(l) * f(r);
    }

    for (i64 i = 1; i <= w; i++) {
        i64 l = max(0ll, i - 2);
        i64 r = max(0ll, w - (i + 2));

        R[i] = f(l) * f(r);
    }

    for (i64 i = 1; i <= w; i++) {
        i64 l = max(0ll, i - 2);
        i64 r = max(0ll, w - (i + 1));

        E[i] = f(l) * f(r);
    }
}

int main() {
    i64 h, w, k;
    cin >> h >> w >> k;

    fill_cnk();
    //cerr << C[100][50] << endl;

    fill_tdp(w);
    //for (i64 i = 0; i <= 8; i++) {
    //    cerr << i << ": " << f(i) << endl;
    //}

    fill_pre(w);

    dp[0][1] = 1;

    for (i64 y = 1; y <= h; y++) {
        for (i64 x = 1; x <= w; x++) {
            if (x > 1) {
                dp[y][x - 1] += (dp[y - 1][x] * L[x]) % mod;
                dp[y][x - 1] %= mod;
            }

            if (x < w) {
                dp[y][x + 1] += (dp[y - 1][x] * R[x]) % mod;
                dp[y][x + 1] %= mod;
            }

            dp[y][x] += (dp[y - 1][x] * E[x]) % mod;
            dp[y][x] %= mod;
        }
    }

    cout << dp[h][k];

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD1 1000000007
#define MOD2 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ll t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<ll,ll> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m,ll MOD){if(m==0)return 1;ll t=mpowe(n,m/2,MOD);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;if(n==0) return -1;return logtwo(n/2)+1;}
ll dig(ll n)
{
	ll c=0;
	while(n>0)
	{
		n=n/10;
		c++;
	}
	return c-1;
}
int main()
{
    fastio();
   
    ll n;
    cin>>n;
    ll a[n];
    ll p=1,l=1000000000000000000;
    cn(a,n);
    for(int i=0;i<n;i++)
    {
    	if(a[i]==0)
    	{
    		cout<<0<<endl;
    		return 0;
    	}
    }
    for(int i=0;i<n;i++)
    {
    	ll d = p*a[i];
    	///cout<<d<<" "<<p<<" "<<l/a[i]<<" "<<endl;
    	if(l/a[i]<p || d>1000000000000000000)
    	{
    		cout<<-1<<endl;
    		return 0;
    	}
    	p=d;
    }
    cout<<p<<endl;
}


Measured memory_bytes: 4392
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FL          freopen("in", "r", stdin),freopen("out", "w", stdout);
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
//int dx[] = {1, 0}, dy[] = {0, 1};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int main(){
    //FL;
    FIN;
    int n, k;
    cin >> n >> k;
    int v[n + 1];
    fore(i, 0, n)cin >> v[i];
    sort(v, v + n);
    int ans = 0;
    fore(i, 0, k)
        ans += v[i];
    cout << ans<< '\n';
    EjecuteTime;
    return 0;
}       


Measured memory_bytes: 3792
import java.util.Scanner;

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 sum1 = A + B ;
    int sum2 = B + C ;
    int sum3 = C + A ;

    if (sum1 == sum2 && sum2 == sum3){
      System.out.println(sum1);
    }

    if (sum1 < sum2 && sum1 < sum3){
    System.out.println(sum1);
    }
    if (sum2 < sum1 && sum2 < sum3){
    System.out.println(sum2);
    }
    if (sum3 < sum2 && sum3 < sum1){
    System.out.println(sum3) ;
    }

  }
}


Measured memory_bytes: 21844
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	ll n, d, a; cin >> n >> d >> a;
    vector<ll> x(n), h(n);
    vector<P> m(n);
    rep(i, n) {
        cin >> x[i] >> h[i];
        m[i] = make_pair(x[i], h[i]);
    }
    priority_queue<P, vector<P>, greater<P>> pque;
    sort(all(m));
    ll cnt = 0;
    ll now = 0;
    rep(i, n) {
        ll X = m[i].fr, H = m[i].sc;
        while(pque.size() > 0 && X > pque.top().fr) {
            ll Z = pque.top().sc;
            now -= Z;
            pque.pop();
        }
        H -= now * a;
        if(H <= 0) continue;
        ll co = (H + a - 1) / a;
        cnt += co;
        pque.push(make_pair(X + 2 * d, co));
        now += co;
    }
    cout << cnt << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}


Measured memory_bytes: 8820
while True:
  try:
    n=input()
    count=0
    for i in range(len(n)):
      if i==int(len(n))-1:
        if n[i]=="I":
          count+=1
        elif n[i]=="V":
          count+=5
        elif n[i]=="X":
          count+=10
        elif n[i]=="L":
          count+=50
        elif n[i]=="C":
          count+=100
        elif n[i]=="D":
          count+=500
        elif n[i]=="M":
          count+=1000
      elif n[i]=="I":
        if n[i+1]!="I":
          count-=1
        else:
          count+=1
      elif n[i]=="V":
        if n[i+1]!="I" and n[i+1]!="V":
          count-=5
        else:
          count+=5
      elif n[i]=="X":
        if n[i+1]=="L" or n[i+1]=="C" or n[i+1]=="D" or n[i+1]=="M":
          count-=10
        else:
          count+=10
      elif n[i]=="L":
        if n[i+1]=="C" or n[i+1]=="D" or n[i+1]=="M":
          count-=50
        else:
          count+=50
      elif n[i]=="C":
        if n[i+1]=="D" or n[i+1]=="M":
          count-=100
        else:
          count+=100
      elif n[i]=="D":
        if n[i+1]=="M":
          count-=500
        else:
          count+=500
      elif n[i]=="M":
        count+=1000
    print(count)
  except EOFError:
    break


Measured memory_bytes: 5576
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin>>N;
    int even=0, odd=0;
    for(int i=0; i<N; i++) {
        int A;
        cin>>A;
        if(A%2==1) odd++;
    }
    cout<<((odd%2==0)?"YES":"NO")<<endl;

    return 0;
}

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

int main()
{
  ll n;
  cin >> n;
  map<char, ll> s;
  s['M'] = s['A'] = s['R'] = s['C'] = s['H'] = 0;
  for (ll i = 0; i < n; i++)
  {
    string tmp;
    cin >> tmp;
    s[tmp[0]]++;
  }
  ll ans =
      (s['M'] * s['A'] * s['R']) +
      (s['M'] * s['A'] * s['C']) +
      (s['M'] * s['A'] * s['H']) +
      (s['M'] * s['R'] * s['C']) +
      (s['M'] * s['R'] * s['H']) +
      (s['M'] * s['C'] * s['H']) +
      (s['A'] * s['R'] * s['C']) +
      (s['A'] * s['R'] * s['H']) +
      (s['A'] * s['C'] * s['H']) +
      (s['R'] * s['C'] * s['H']);
  cout << ans << endl;
}


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

int main(){
	int example=0;
	int top3[3]={0};

	for(int i=0; i<10 ; i++){
	cin>>example;
	for(int ia=0 ; ia<3 ; ia++){
		if(top3[ia]<=example){
			for(int ib=0 ; ib<(2-ia) ; ib++){
				top3[2-ib] = top3[1-ib];
			}
			top3[ia] = example;
			break;
		}
	}
	}
	
	for(int i=0 ; i<3 ; i++){
	cout << top3[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
int main(void)
{
  int N=IN(),A,B,C,Q,count[100000]={0};
  static long long sum=0;
  while(N--){A=IN();count[A-1]++;sum+=A;}
  Q=IN();
  while(Q--)
  {
    B=IN(),C=IN();
    sum+=1ll*count[B-1]*(C-B);
    count[C-1]+=count[B-1];
    count[B-1]=0;
    printf("%lld\n",sum);
  }
  return 0;
}

Measured memory_bytes: 1972
def main():
    from sys import stdin, setrecursionlimit
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #n = int(stdin.readline()[:-1])   
    #r = stdin.readline()[:-1]
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #n = int(r)
    #a = r.split()
    #a,b,c = r.split()
    #a = list(map(int, r.split()))
    #a,b,c,d = map(int, r.split())
    #a = list(map(int, r.split()))
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    #a = [list(map(int, input().split())) for i in range(1,n+1)]
    #res = 0

    s,t = input().split()
    a,b = map(int,input().split())
    u = input()

    if u == s:
        a-=1
    else:
        b-=1
    print(a,b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
var a:array[-1..100005]of longint;
    n,i,max,min,l:longint;
begin
    readln(n);min:=-1;max:=maxlongint;
    for i:=1 to n do begin
        read(l);
        inc(a[l]);inc(a[l-1]);inc(a[l+1]);
        if (l+1)>max then max:=l+1;
        if (l-1)<min then min:=l-1;
        if min<0 then min:=0;
        if max>100000then max:=100000;
    end;l:=0;
    for i:=min to max do
    if a[i]>l then l:=a[i];
    writeln(l);
end.

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define LLINF LLONG_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < n; i++)

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

#define MAX_S 3100
#define MAX_T 3100

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input values
    string s, t;
    cin >> s >> t;

    // dp table
    vector<vector<int>> dp(MAX_S, vector<int>(MAX_T, 0));

    // init dp table

    // init condition

    // loop
    rep (i, s.size()) {
        rep (j, t.size()) {
            if (s[i] == t[j]) {
                chmax(dp[i+1][j+1], dp[i][j]+1);
            }
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }

    string ans = "";
    int i = (int)s.size(), j = (int)t.size();
    while (i > 0 && j > 0) {
        if (dp[i][j] == dp[i-1][j]) {
            i--;
        } else if (dp[i][j] == dp[i][j-1]) {
            j--;
        } else {
            ans = s[i-1] + ans;
            i--;
            j--;
        }
    }

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

Measured memory_bytes: 37888
#include <iostream>
#include <cmath>

using namespace std;

const double pi = 4*atan(1);

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.setf(ios::fixed);
	cout.precision(5);
	double r;
	cin>>r;
	cout<<r*r*pi<<' '<<2*r*pi<<'\n';
	return 0;
}



Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
int read() {
	char c=getchar(); int x=0,f=1;
	while (c<'0' || c>'9') {
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int main() {
	long long w=read(),h=read(),x=read(),y=read();
	printf("%.10f ", w*h*0.5);
	if (x*2==w && y*2==h) printf("1\n");
	else printf("0\n");
	return 0;
}

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

int main(){
  string s;
  long long ans;
  ans=0;
  cin >> s;
  for (int i=0 ; i<(1<<(s.size()-1)); i++){
    bitset<10> p(i);
    string t="";
    for (int j=0; j<s.size(); j++){
      t+=s.at(j);
      if(p[j]==1){
        ans += stoll(t);
        t="";
      }
    }
    if(t.size()>0){
      ans += stoll(t);
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3652
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def foo(n):
    h = {0:'0', 1:'1', -2:'10', -1:'11'}
    if n in h:
        ret = h[n]
        #ddprint(f"foo {n} ret {ret}")
        return ret
    r = n%4
    if r==0:
        s = '00'
        v = 0
    elif r==1:
        s = '01'
        v = 1
    elif r==2:
        s = '10'
        v = -2
    else:
        s = '11'
        v = -1
    ret = foo((n-v)//4) + s
    #ddprint(f"foo {n} ret {ret}")
    return ret

n = inn()
if n==0:
    print(0)
else:
    s = foo(n)
    for i in range(len(s)):
        if s[i]=='1':
            break
    print(s[i:])


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> count(4);
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        if(s == "AC"){
            count.at(0)++;
        }else if(s == "WA"){
            count.at(1)++;
        }else if(s == "TLE"){
            count.at(2)++;
        }else if(s == "RE"){
            count.at(3)++;
        }
    }
    cout << "AC x " << count.at(0) << endl;
    cout << "WA x " << count.at(1) << endl;
    cout << "TLE x " << count.at(2) << endl;
    cout << "RE x " << count.at(3) << endl;
}


Measured memory_bytes: 3624
//A smoothe sea never made a skilled sailor.
//KEEP IT SIMPLE STUPID
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define print(o) for(auto it=(o).begin();it!=(o).end();it++) cout<<*it<<" ";
#define vll vector<ll>
#define pb push_back
#define FOR(n) for(ll i=0;i<n;i++)
#define FORr(a,b) for(ll i=a;i<=b;i++)
#define all(x) (x).begin(),(x).end()

bool palin(string s)
{
    string t=s;
    reverse(all(t));
    return t==s;
}

int main()
{
    float l;
    cin>>l;
    float ans=(l/3)*(l/3)*(l/3);
    printf("%0.6f",ans);
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int am[5], pm[5];
	int max, m;
	int i;
	
	while (1){
		scanf("%d%d", &*am, &*pm);
		
		if (*am + *pm == 0){
			break;
		}
		else {
			max = *am + *pm;
			m = 0;
		}
		for (i = 1; i < 5; i++){
			scanf("%d%d", &am[i], &pm[i]);
			if (max < am[i] + pm[i]){
				max = am[i] + pm[i];
				m = i;
			}
		}
		
		printf("%c %d\n",m + 'A', max);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	string s,t,t2,x,x2,s2;
	cin>>s;

	rrep(i,s.size())s2+=s[i];
	rep(i,(s.size()-1)/2)t+=s[i];
	rrep(i,(s.size()-1)/2)t2+=s[i];
	for(int i=(s.size()+3)/2-1; i<s.size(); i++)x+=s[i];
	for(int i=s.size()-1; i>=(s.size()+3)/2-1; i--)x2+=s[i];

	if(t==t2&&x==x2&&s==s2)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(void){
	int a[6]={0};
  
  	for(int i=0; i<6; ++i){
      scanf("%d",&a[i]);
    }
  
  	for(int i=0; i<5; ++i){
      for(int j=i+1; j<5; ++j){
        if(abs(a[j]-a[i]) > a[5]){
          printf(":(");
          return 0;
        }
      }
    }
  printf("Yay!");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N, M;
  int ans = 0;

  cin >> N;

  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N);
  vector<pair<int,int>> AB(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  for(int i = 0; i < N; i++){
    cin >> B[i];
  }
  for(int i = 0; i < (N-1); i++){
    cin >> C[i];
  }

  int bf = -2;
  for(int i = 0; i < N; i++){
    ans += B[A[i]-1];
      // cout << " A[" << i << "] = " << A[i] << ", (B)ans += " << B[A[i]-1] << endl;
    if(bf == (A[i]-1)){
      ans += C[A[i] -2];
      // cout << " A[" << i << "] = " << A[i] << ", (C)ans += " << C[A[i]-2] << endl;
    }
    bf = A[i];
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

const int N = 105;
int a[N];

int main()
{
    int k, t;
    while(cin >> k >> t) {
        for(int i = 0; i < t; ++ i) cin >> a[i];
        int maximum = 0;
        for(int i = 0; i < t; ++ i) maximum = max(maximum, a[i]);
        if(maximum <= k / 2) cout << 0 << endl;
        else {
            cout << k - 2 * (k - maximum) - 1 << endl;
        }
    }


    return 0;
}


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

#define ll long long 
using namespace std;

void solve(){
    int n;
    cin>>n;
    if(n>=30){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return;
}

int main(){
    ll t;
   // cin>>t;
    t=1;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = INT_MAX;
const ll LLINF = INT64_MAX;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> s(n);
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    int q;
    cin >> q;
    int ans = 0;
    for(int i=0;i<q;i++){
        int t;
        cin>>t;
        auto flg = binary_search(ALL(s),t);
        if(flg){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3276
MOD = 10 ** 9 + 7
N,M = map(int,input().split())
ans1 = 1
for i in range(N):
    ans1 *= M - i
    ans1 %= MOD
ans2 = [1,M-N]
for i in range(2,N+1):
    ans2.append((ans2[-2] * (i -1) + ans2[-1] * (M - N + i - 1))% MOD)
print(ans1 * ans2[N] % MOD)

Measured memory_bytes: 102740
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

const ll MOD = 998244353;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

ll dp[301][300 * 300 + 1];
ll dp2[301][300 * 300 + 1];

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

  int n;
  cin >> n;
  ll a[n];
  for(int i = 0; i < n; i++) cin >> a[i];

  for(int i = 0; i <= n; i++){
    fill(dp[i], dp[i] + n * 300 + 1, 0);
    fill(dp2[i], dp2[i] + n * 300 + 1, 0);
  }

  dp[0][0] = 1;
  for(int i = 1; i <= n; i++){
    for(int j = 0; j <= n * 300; j++){
      if(j - a[i - 1] >= 0){
        dp[i][j] = (dp[i][j] + dp[i - 1][j - a[i - 1]]) % MOD;
      }
      ll tmp = (dp[i - 1][j] * 2) % MOD;
      dp[i][j] = (dp[i][j] + tmp) % MOD;
    }
  }

  dp2[0][0] = 1;
  for(int i = 1; i <= n; i++){
    for(int j = 0; j <= n * 300; j++){
      if(j - a[i - 1] >= 0){
        dp2[i][j] = (dp2[i][j] + dp2[i - 1][j - a[i - 1]]) % MOD;
      }
      dp2[i][j] = (dp2[i][j] + dp2[i - 1][j]) % MOD;
    }
  }

  ll sum = 0;
  for(int i = 0; i < n; i++){
    sum += a[i];
  }

  ll ans = 1;
  for(int i = 0; i < n; i++){
    ans = (((ans + ans) % MOD) + ans) % MOD;
  }

  for(int i = ceil(sum, 2); i <= sum; i++){
    ll tmp = (((dp[n][i] + dp[n][i]) % MOD) + dp[n][i]) % MOD;
    ans = (ans - tmp + MOD) % MOD;
  }


  if(sum % 2 == 0){
    ll tmp = (((dp2[n][sum / 2] + dp2[n][sum / 2]) % MOD) + dp2[n][sum / 2]) % MOD;
    ans = (ans + tmp) % MOD;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 423552
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

#define INF 99999999
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;

int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    
    if( a <= c && c <= b )
        cout << "Yes"  << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
'use strict'
function main (input) {
  input = input.split('\n')
  const troops = input[1].split('')
  const n = Number(input[0])
  let countsW = [0]
  for (let i = 1; i <= n; i++) {
    countsW[i] = (troops[i - 1] == 'W') ? countsW[i - 1] + 1 : countsW[i - 1]
  }
  let min, cnt = 0
  for (let i = 0; i < n; i++) {
      cnt = n - (i + 1) - (countsW[n] - countsW[i + 1]) + countsW[i]
    min = (min < cnt) ? min : cnt
  }
  console.log(min)
}

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


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

const int INF = 1012345678;

int main()
{
	int n, k = 0;
	cin >> n >> k;
	vector<int> list(n);
	for (int i = 0; i < n; i++)
	{
		cin >> list[i];
	}
	sort(list.begin(), list.end(), greater<int>());
	int ans = 0;
	for (int i = 0; i < k; i++)
	{
		ans += list[i];
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
//به نامش
//how we code is who we are :))
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
const ll MAXN = 2e6 + 10, inf = 1e18, mod = 1e9 + 7;

struct pair_hash {
	template <class T1, class T2>
		std::size_t operator () (const std::pair<T1,T2> &p) const {
			auto h1 = std::hash<T1>{}(p.first);
			auto h2 = std::hash<T2>{}(p.second);

			return h1 ^ h2;  
		}
};

ll pw(ll te, ll tee) {
	if (tee == 0)	return 1;
	ll res = pw(te, tee / 2);
	return (tee % 2 ? te * res * res : res * res);
}

string s;

void Read_input() {
	cin >> s;
}

void Solve() {
	string t = s.substr(0, 4);
	ll tmp = stol(t);
	if (tmp < 2019)	{
		cout << "Heisei";
		exit(0);
	}
	if (tmp > 2019) {
		cout << "TBD";
		exit(0);
	}
	t = s.substr(5, 2);
	tmp = stol(t);
	if (tmp > 4) {
		cout << "TBD";
		exit(0);
	}
	if (tmp < 4) {
		cout << "Heisei";
		exit(0);
	}
	t = s.substr(8, 2);
	tmp = stol(t);
	if (tmp <= 30) {
		cout << "Heisei";
		exit(0);
	}
	else
		cout << "TBD";
}


int main() {

	ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	//freopen("input.txt", "r", stdin),	freopen("output.txt", "w", stdout);

	Read_input(),	Solve();
	return 0;
}


Measured memory_bytes: 256
with open(0) as f:
    N, *a = map(int, f.read().split())
F = [x for x in a[:N]] #Fの要素は加えるか取り除くかの2択
C = [x for x in a[N:2*N]] 
B = [-x for x in a[2*N:]] #Bの要素は引くか取り除くかの二択
import heapq as hq
#ヒープにして常に最小値を追跡
hq.heapify(F)
hq.heapify(B)

#Cを二分し、前半はFと、後半はBとで演算を行う
#演算方法(c in C)
#前半：cがF[0]より大きければF[0]を取り除くN個の一つとし、cをスコアに加える
#後半：-cがB[0]より大きければB[0]を取り除くN個の一つとし、cをスコアから引く
#どちらも場合も条件を満たさない場合はそのｃを取り除くN個の一つとする
#計算量：O(N*N*logN)
#途中計算をメモして計算量軽減
from copy import deepcopy
memoF = [0] * (N+1) #C[:i]を前半としたときのFとの演算結果の要素和
memoF[0] = sum(F)
memoB = [0] * (N+1) #C[i:]を後半としたときのBとの演算結果の要素和
memoB[N] = sum(B)
for i in range(N):
    if C[i] > F[0]:
        memoF[i+1] = memoF[i] + C[i] - hq.heapreplace(F, C[i])
    else:
        memoF[i+1] = memoF[i]

    if -C[N-1-i] > B[0]:
        memoB[N-1-i] = memoB[N-i] - C[N-1-i] - hq.heapreplace(B, -C[N-1-i])
    else:
        memoB[N-1-i] = memoB[N-i]

Scores = [memoF[i]+memoB[i] for i in range(N+1)]
ans = max(Scores)
print(ans)

Measured memory_bytes: 42336