akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
ll INF = 1000000007;
using Graph = vector<vector<ll>>;

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)


int main() {
    ll n, k;
    cin >> n >> k;
    ll r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;

    vector<string> vec;

    ll ans = 0;
    rep(i,t.size()){
        if(i < k){
            if(t.at(i) == 'r'){
                //cout << i << endl;
                ans += p;
                vec.pb("o");
            }else if(t.at(i) == 's'){
                //cout << i << endl;
                ans += r;
                vec.pb("o");
            }else if(t.at(i) == 'p'){
                //cout << i << endl;
                ans += s;
                vec.pb("o");
            }else{
                vec.pb("*");
            }
        }else{
            if(t.at(i) == 'r'){
                if(t.at(i-k) == 'r' && vec.at(i-k) == "o"){
                    vec.pb("*");
                }else{
                    //cout << i << endl;
                    ans += p;
                    vec.pb("o");
                }
            }else if(t.at(i) == 's'){
                if(t.at(i-k) == 's' && vec.at(i-k) == "o"){
                    vec.pb("*");
                }else{
                    //cout << i << endl;
                    ans += r;
                    vec.pb("o");
                }
            }else if(t.at(i) == 'p'){
                if(t.at(i-k) == 'p' && vec.at(i-k) == "o"){
                    vec.pb("*");
                }else{
                    //cout << i << endl;
                    ans += s;
                    vec.pb("o");
                }
            }else{
                vec.pb("*");
            }
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 5876
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>

using namespace std;

int main() {

	long long n;
	cin >> n;
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			ans += i;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3580
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	array<int, 8>merry{ 4, 1, 4, 1, 2, 1, 2, 1 }, p;
	while (cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7]) {
		array<int, 8>c{ 1, 2, 1, 2, 1, 4, 1, 4 };
		int foo_min = INF;
		REP(i, 8) {
			int foo = 0; REP(j, 8)foo += max(0, p[j] - merry[(j + i) % 8]);
			if (foo_min > foo) {
				foo_min = foo;
				REP(j, 8) c[j] = merry[(j + i) % 8];
			} else if (foo_min == foo) {
				int a = 0, b = 0;
				for (int j = 0, k = 10000000; j < 8; ++j, k /= 10)a += c[j] * k;
				for (int j = 0, k = 10000000; j < 8; ++j, k /= 10)b += merry[(j + i) % 8] * k;
				if (a > b)REP(j, 8)c[j] = merry[(j + i) % 8];
			}
		}
		cout << c[0] << ' ' << c[1] << ' ' << c[2] << ' ' << c[3] << ' ' << c[4] << ' ' << c[5] << ' ' << c[6] << ' ' << c[7] << endl;
	}
}


Measured memory_bytes: 3060
#include <iostream>
// #include <string>
// #include <cstdio>
// #include <algorithm>

using namespace std;

int main()
{
    int up[100] = {};
    int down[100] = {};
    long long up_cumulative[100] = {};
    long long down_cumulative[100] = {};
    int n;
    // width
    cin >> n;

    //read input
    for (int i = 0; i < n; ++i)
    {
        cin >> up[i];
    }
    for (int i = 0; i < n; ++i)
    {
        cin >> down[i];
    }

    //get cumulative sum
    long long sum_up = 0;
    long long sum_down = 0;
    for (int i = 0; i < n; ++i)
    {
        sum_up += up[i];
        sum_down += down[i];
        up_cumulative[i] = sum_up;
        down_cumulative[i] = sum_down;
        // cout << (i == 0 ? "" : " ") << sum_up;
    }

    long long max_num = -99999;
    for (int i = 0; i < n; ++i)
    {
        long long v;
        if (i == 0)
        {
            v = up_cumulative[i] + down_cumulative[n - 1];
        }
        else
        {
            v = up_cumulative[i] + down_cumulative[n - 1] - down_cumulative[i - 1];
        }
        // cout << v << endl;
        if (max_num < v)
        {
            max_num = v;
        }
    }
    cout << max_num << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long int lli;
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
int main(void)
{
	int i=0, flag =0;
	char s[101];
	scanf("%s", s);

	while(s[i] != '\0'){
		if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D'){
			flag = 1;
		}
		i++;
		if(s[i] == '\0') break;
		if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D'){
			flag = 1;
		}
		i++;
	}
	if(flag == 1) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;

    if (std::abs(c-a) <= d) {
        std::cout << "Yes" << std::endl;
    } else {
        if (std::abs(b-a) <= d && std::abs(c-b) <= d) {
            std::cout << "Yes" << std::endl;
        } else {
            std::cout << "No"  << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;

int main() {
	string s;
	cin >> s;
	REP(i,s.length()){
		if(i%2==0) cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
#define PI 3.14159265359
typedef long long ll;
using namespace std;
int main()
{
	ll N,M,tmp;
	vector<ll>vecx;
	vector<ll>vecy;
	vector<ll>veccx;
	vector<ll>veccy;
	cin>>N>>M;
	fore(i,0,N){
		ll x,y;
		cin>>x>>y;
		vecx.push_back(x);
		vecy.push_back(y);
	}
	fore(i,0,M){
		ll x,y;
		cin>>x>>y;
		veccx.push_back(x);
		veccy.push_back(y);
	}
	fore(i,0,N){
		ll min=0,minp=1000000000;
		fore(j,0,M){
			tmp=abs(vecx[i]-veccx[j])+abs(vecy[i]-veccy[j]);
			//cout<<tmp<<endl;
			if(minp>tmp){
				min=j+1;
				minp=tmp;
			}
		}
		cout<<min<<endl;
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>
#include <limits.h>
using namespace std;
typedef long long ll;
const int inf=1<<30;
const int INF=INT_MAX;
 
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int count = 0;
  list<int> b;
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int c;
    cin >> c;
    b.push_front(c);
  }
  list<int> ans;
  bool found;
  for(int i = n - 1; i >= 0; --i) {
    int j = i;
    found = false;
    for(auto itr = b.begin(); itr != b.end(); ++itr) {
      if((*itr) == j + 1) {
        ans.push_front(j + 1);
        b.erase(itr);
        found = true;
        break;
      }
      --j;
    }
    if(!found) {
      break;
    }
  }
  if(found) {
    for(auto&& e : ans) {
      cout << e << endl;
    }
  } else {
    cout << -1 << endl;
  }
  return 0;
}

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

//a->bまでangleの方向ではじめたときのルート
//angle: 1 -> right -1 -> left
std::vector<int> walk(int a, int b, int angle){
	std::vector<int> res;
	res.push_back(a);
	while(a != b){
		if(a == 9){
			a = 5;
			angle = -1;
		}else if(a == 0 && angle == -1){
			a = 1;
			angle = 1;
		}else{
			a += angle;
		}

		res.push_back(a);
	}
	
	return res;
}

int main(){
	int n, angle, a, b;
	std::cin >> n;
	for(;n--;){
		std::cin >> a >> b;

		std::vector<int> lv = walk(a, b, -1),
			rv = walk(a, b, 1), &shortest_v = lv;
		//a >= 6のとき左方向からはじめられない
		if(a >= 6 || lv.size() > rv.size()){
			shortest_v = rv;
		}

		std::cout << shortest_v[0];
		for(int i=1;i<shortest_v.size();i++){
			std::cout << " " << shortest_v[i];
		}
		std::cout << "\n";
	}
}

Measured memory_bytes: 1216
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace A_ABC152
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            if(s[0]==s[1]){
                WriteLine("Yes");
            }else{
                WriteLine("No");
            }
        }
    }
}


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

void input_array(int a[], int n){
    for(int i=0; i<n; i++){
        std::cin >> a[i];
    }
}

int search_number_of_prime_numbers(int a[], int n){
    int cnt = 0;
    for(int i=0; i<n; i++){
        int flag = 0;
        for(int j=1; j<=sqrt(a[i]); j++){
            if(a[i]==1){
                flag += 2;
            } 
            else if(a[i]%j==0){
                flag += 1;
            }
        }
        if(flag==1){
        cnt += 1;
        }
    }
    return cnt;
}

int main(){
    int N;
    std::cin >> N;
    int A[N];
    input_array(A,N);
    int num = search_number_of_prime_numbers(A,N);
    std::cout << num << '\n';

    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,t;
  cin>>a>>b>>t;
  int biscuitsum = 0;
  if(a<t){
    
    for(int i=1;;i++){
      int time = a*i;
      if(time>=t+0.5){
        break;
      }
      else{
        biscuitsum+=b;
      }
    }
    cout<<biscuitsum<<endl;
  }
  else if(a==t){
    cout<<1<<endl;
  }
  else{
    cout<<0<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int hp=sc.nextInt(),n=sc.nextInt();
		int sum = 0;
		for(int i=0;i<n;i++)
			sum+=sc.nextInt();
		String can = sum>=hp?"Yes":"No";
		System.out.print(can);
	}
}


Measured memory_bytes: 47404
n,m=map(int,input().split())
a=[]
ans=-1
for i in range(n):
    li = list(map(int,input().split()))
    li[0]=0
    a.append(li)

for i in range(len(a[0])):
    b=0
    for j in range(1,n):
        if a[j].count(a[0][i])>=1:
               b+=1
    if b==n-1:
        ans+=1
print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

const int kInf = 1 << 28;

struct edge { int to, cost; };

struct S {
  int v, p, cost;
  bool operator<(const S& other) const {
    return cost > other.cost;
  }
};
 
int N, M, L, K, A, H;
bool b[102];
vector<edge> es[102];

int d[102][102]; // d[i][j] -- 街i, 体力jにおける場合の最短時間

void solve() {
  priority_queue<S> q;
  
  rep(i,N+1) rep(j,M+1) d[i][j] = kInf;
  d[A][M] = 0;
  q.push((S){A, M, 0});

  while (!q.empty()) {
    S s = q.top(); q.pop();
    int v = s.v, p = s.p, cost = s.cost;
    if (d[v][p] < cost) continue;
    // printf(">> v:%d p:%d cost:%d\n", v, p, cost);
    
    rep(i,es[v].size()) {
      edge e = es[v][i];
      if (b[v]) {
        // 現在の街が冷凍施設がある
        // 体力を M まで回復して、移動することを試みる
        for (int j = 0; j + p <= M ; ++j) {
          if (p + j - e.cost < 0) continue;
          if (d[e.to][p + j - e.cost] > cost + e.cost + j) {
            d[e.to][p + j - e.cost] = cost + e.cost + j;
            q.push((S){e.to, p + j - e.cost, cost + e.cost + j});
          }
        }
      } else {
        // 冷凍施設がない場合は、移動可能ならば
        // 体力を減らして移動
        if (p - e.cost < 0) continue;
        if (d[e.to][p - e.cost] > cost + e.cost) {
          d[e.to][p - e.cost] = cost + e.cost;
          q.push((S){e.to, p - e.cost, cost + e.cost});
        }
      }
    }
  }

  int ans = kInf;
  rep(i,M+1) {
    // printf("d[H][%d] = %d\n", i, d[H][i]);
    ans = min(ans, d[H][i]);
  }
  if (ans == kInf) {
    puts("Help!");
  } else {
    printf("%d\n", ans);
  }
}

int main() {
  while (scanf("%d%d%d%d%d%d", &N, &M, &L, &K, &A, &H), N) {
    fill(b, b + N, false);
    
    int t;
    rep(i,L) {
      scanf("%d", &t);
      b[t] = true;
    }

    rep(i,N) es[i].clear();

    int x, y;
    rep(i,K) {
      scanf("%d%d%d", &x, &y, &t);
      es[x].push_back((edge){y, t});
      es[y].push_back((edge){x, t});
    }

    solve();
  }
  return 0;
}

Measured memory_bytes: 1312
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int N, K;

ll f(int n)
{
  if (n == 0) return 1;
  return n * f(n - 1);
}

ll nPr(int n, int r) { return f(n) / f(r); }

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

  ll ans = 0;
  if (K % 2 == 1) {
    ll cnt = 0;
    for (int i = 1; i <= N; i++)
      if (i % K == 0) cnt++;
    ans = cnt * cnt * cnt;
  }
  else {
    ll cnt = 0, half = 0, dup = 0;
    for (int i = 1; i <= N; i++) {
      ll r = i % K;
      if (i % K == 0) cnt++;
      if (i % K == K / 2) half++;
      if (i % K == 0 && i % K == K / 2) dup++;
    }
    ans += cnt * cnt * cnt;
    ll h = half - dup;
    ans += h * h * h;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int n,cou=0,pla[1111][3],ans[1111]={0};
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin >> pla[i][j];
    }
  }
  for(int i=0;i<3;i++){
    for(int j=0;j<n;j++){
      for(int z=0;z<n;z++){
	if(z != j && pla[j][i] == pla[z][i]) cou++;
      }
      if(cou==0) ans[j] += pla[j][i];
      cou=0;
    }
  }
  for(int i=0;i<n;i++){cout << ans[i] << endl;}
}

Measured memory_bytes: 1172
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T & a, const T & b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/



//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	int n, k;
	cin >> n >> k;

	double ans = 0;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	vector<double> E(n + 10, 0);

	for (int i = 0; i < n; i++)
	{
		E[i + 1] = a[i] * (a[i] + 1) / (double)2 / a[i];
	}

	for (int i = 0; i <= n; i++)
	{
		E[i + 1] += E[i];
	}

	double maxi = 0;
	for (int i = 0; i < n; i++)
	{
		if (i + k > n)continue;
		maxi = max(E[i + k] - E[i],maxi);
	}

	cout << maxi << endl;


	return 0;
}



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

unsigned long long valorMaximo = 0;

string palavraUm, palavraDois;
int v[5000][5000];

void lcs(int i, int j)
{
    if (i != 0 && j != 0)
    {
        if (palavraUm[i - 1] == palavraDois[j - 1])
        {
            lcs(i - 1, j - 1);
            cout<<palavraUm[i - 1];
        }
        else if (v[i - 1][j] > v[i][j - 1])
        {
            lcs(i - 1, j);
        }
        else
        {
            lcs(i, j - 1);
        }
    }

}

int main()
{
    cin >> palavraUm >> palavraDois;

    memset(v, 0, sizeof(v));

    for (int i = 1; i <= palavraUm.length(); i++)
    {
        for (int j = 1; j <= palavraDois.length(); j++)
        {
            if (palavraUm[i - 1] == palavraDois[j - 1])
                v[i][j] = v[i - 1][j - 1] + 1;
            else
                v[i][j] = max(v[i - 1][j], v[i][j - 1]);
        }
    }
/*
    for (int i = 1; i <= palavraUm.length(); i++)
    {
        for (int j = 1; j <= palavraDois.length(); j++)
            cout << v[i][j] << " ";
        cout << endl;
    }
    */

    int a = palavraUm.length();
    int b = palavraDois.length();
    lcs(a, b);
    cout<<endl;
}


Measured memory_bytes: 98432
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        boolean[] backet = new boolean[26];

        for (int i = 0; i < s.length; i++) {
            backet[s[i] - 'a'] = true;
        }

        String res = "None";
        for (int i = 0; i < backet.length; i++) {
            if (backet[i]) {
                continue;
            } else {
                char ans = (char)(i+'a');
                res = String.valueOf(ans);
                break;
            }
        }

        System.out.println(res);
    }
}


Measured memory_bytes: 25940
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

string S;

signed main(void) {
    cin >> S;
    int cnt=0;
    int k = S.size();
    rep(i,k) {
        if (S[i] == 'x') cnt++;
    }
    if (cnt >= 8) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }


    return 0;
}

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

int main(){
  int A, B; cin >> A >> B;
  int C = A -2*B;
  if(C <= 0) cout << 0;
  else cout << C;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){

  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    string a,b,s;
    int how=0;
    cin>>a>>b;
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    for(int j=0;j<a.size()||j<b.size();j++){
      if(j<a.size()) how+=a[j]-'0';
      if(j<b.size()) how+=b[j]-'0';
      s.push_back(how%10+'0');
      how/=10;
    }
    if(how!=0) s.push_back(how+'0');
    reverse(s.begin(),s.end());
    if(s.size()>80) cout<<"overflow"<<endl;
    else cout<<s<<endl;
  }
  return 0;

}

Measured memory_bytes: 3012
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,q,k;
char s[1000005];
int main(){
	scanf("%lld%s%lld",&n,s,&q);
	while(q--){
		scanf("%lld",&k);
		ll D=0,M=0,DM=0,DMC=0;
		for(ll i=0;i<n;i++){
			if(i>=k){
				if(s[i-k]=='D'){
					DM-=M;
					D--;
				}
				if(s[i-k]=='M')
					M--;
			}
			if(s[i]=='D')
				D++;
			if(s[i]=='M'){
				M++;
				DM+=D;
			}
			if(s[i]=='C')
				DMC+=DM;
		}
		printf("%lld\n",DMC);
	}
}

Measured memory_bytes: 1280
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
T[] readArray(T)(size_t n){auto a=new T[](n),r=readln.splitter;foreach(ref v;a){v=r.front.to!T;r.popFront;}return a;}
T[] readArrayM(T)(size_t n){auto a=new T[](n);foreach(ref v;a)v=readln.chomp.to!T;return a;}

void main()
{
  int a; readV(a);
  int b; readV(b);
  int c; readV(c);
  int d; readV(d);
  writeln(min(a, b) + min(c, d));
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount


#define INF INT_MAX/3
#define mod 1000000007

typedef vector<int> vi;

int n,m;
vi a;
map<vi,int> mem;

int dfs(vi state){
  if(state.size()<=1)return 0;
  if(mem.find(state)!=mem.end())return mem[state];
  int res=INF;
  rep(i,m){
    vi l,r;
    rep(j,state.size()){
      if((a[state[j]]>>i)&1)l.push_back(state[j]);
      else r.push_back(state[j]);
    }
    if(l.size()==0||r.size()==0)continue;
    minch(res,max(dfs(l),dfs(r))+1);
  }
  return mem[state]=res;
}

bool solve(){
  cin>>m>>n;
  if(m==0||n==0)return false;
  a.resize(n);
  vector<int> idx;
  rep(i,n){
    string s;
    cin>>s;
    a[i]=0;
    rep(j,m){
      if(s[j]=='1')a[i]|=1<<j;
    }
    idx.push_back(i);
  }
  mem.clear();
  cout<<dfs(idx)<<endl;
  return true;;
}

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



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

int main() {
  int n, x; scanf("%d %d",&n, &x);
  int d = 2*n-1;
  if (x==1 || x==d) {
    puts("No");
  } else {
    puts("Yes");
    for (int i = 0; i < d; i++) {
      printf("%d\n", (x-n+i+d)%d+1);
    }
  }
  return 0;
}


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

typedef long long ll;
int main()
{
    ll x,a,b;
    cin>>x>>a>>b;
    if((b-a)<=0)
    {
        cout<<"delicious"<<endl;
    }
    else if((b-a)<=x)
    {
        cout<<"safe"<<endl;
    }
    else
    {
        cout<<"dangerous"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	int x = s.length();
	vector<vector<int>> sim(26, vector<int>(x));
	for (int i = 0; i < 26; i++) {
		char y = 'a' + i;
		for (int j = 0; j < x; j++) {
			if (y == s.at(j))sim.at(i).at(j)++;
		}
	}
	int ans = 10000;
	for (int i = 0; i < 26; i++) {
		int res = 0;
		for (int j = 0; j < x; j++) {
			bool flag = true;
			for (int k = 0; k < x - j; k++) {
				if (sim.at(i).at(k) == 0)flag = false;
			}
			if (flag)break;
			for (int k = 0; k < x-1; k++) {
				sim.at(i).at(k) = max(sim.at(i).at(k), sim.at(i).at(k + 1));
			}
			res++;
		}
		ans = min(res, ans);
	}
	cout << ans << endl;
}

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

namespace ConsoleApp14
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Calc();
        }
    }

    public class Solver
    {

        public void Calc()
        {
            var N = int.Parse(Console.ReadLine());
            var As = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

            Console.WriteLine(As.Count(x => x % 2 == 0) == As.Count(x => x % (2 * 3) == 0 || x % (2 * 5) == 0) ? "APPROVED" : "DENIED");

        }
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    VP p(n);
    rep(i,n){
        ll x,l;
        cin>>x>>l;
        p[i] = mp(x-l,x+l-1);
    }
    sort(ALL(p),[&](P a, P b){
        if(a.second==b.second) {
            return a.first<b.first;
        } else {
            return a.second<b.second;
        }
    });
    ll ans = 0;
    ll prev = -1*INF;
   // dbg(p);
    rep(i,n){
        if(p[i].fi>prev){
            ans++;
            prev = p[i].se;
        }
    }
    cout<<ans<<endl;
    return  0;
}


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

int main(){
    string s;
    bool flag = false;
    cin >> s;

    for(int i=1;i<4;i++){
        if(s[i-1] == s[i]) flag = true;
    }
    if(flag){
        cout << "Bad" << "\n";
    }
    else{
        cout << "Good" << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>


using namespace std;


int main(){

  while(1){

long int d = 0;

long int n = 0;

int m = 0;

long int ans = 0;




  vector<long> dat;
  vector<long>::iterator it;


 dat.push_back(0);

 scanf("%ld",&d);

 if(d == 0) break;

  scanf("%ld%d",&n,&m);

  dat.push_back(d);

  for(long i = 1;i < n;i++){
    long tmp = 0;
    scanf("%ld",&tmp);
    dat.push_back(tmp);
  }

  sort(dat.begin(),dat.end());


  for(int i = 0;i < m;i++){
    long tmp = 0;

    scanf("%ld",&tmp);

    it = lower_bound(dat.begin(),dat.end(),tmp);

    long s1 = 0,s2 = 0;


    s1= *it;

    --it;

    s2 = *it;

    ans += min(abs(tmp-s1),abs(tmp-s2));

  }

  printf("%ld\n",ans);

}

  return 0;

}


Measured memory_bytes: 1960
"""
~~ Author : Bhaskar
~~ Dated : 10~06~2020
"""

import sys
from bisect import *
from math import floor,sqrt,ceil,factorial as F,gcd,pi
from itertools import chain,combinations,permutations,accumulate
from collections import Counter,defaultdict,OrderedDict,deque
from array import array
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
mod = 1000000007
ch = "abcdefghijklmnopqrstuvwxyz"
lcm = lambda a,b : (a*b)//gcd(a,b)
setbit = lambda x : bin(x)[2:].count("1")
input = lambda : sys.stdin.readline()

def solve():
    n = int(sys.stdin.readline())
    a = list(map(int, sys.stdin.readline().split()))
    s = 0
    for i in a:
        s ^= i
    for i in a:
        print(s^i,end = " ")
    print()



if __name__ == "__main__":
    try:
        sys.stdin = open('input.txt','r')
        sys.stdout = open('output.txt','w')
    except:
       pass
    solve()



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

ll S;

int main()
{
	cin >> S;
	cout << 0 << " " << 0 << endl;
	ll X=1e9;
	ll d2=(X-1ll+S)/X;
	ll d3=d2*X-S;
	cout << X << " " << 1 << endl;
	cout << d3 << " " << d2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int32_t N, K;
	cin >> N >> K;

	vector<bool> available(10);
	std::fill(std::begin(available), std::end(available), true);
	for (int32_t i = 0; i < K; i++) {
		int32_t value;
		cin >> value;
		available[value] = false;
	}

	while (true) {
		bool valid = true;
		int32_t temp = N;
		while (temp > 0) {
			int32_t last = temp % 10;
			if (!available[last]) {
				valid = false;
				break;
			}
			temp /= 10;
		}
		if (valid)
			break;
		N++;
	}
	cout << N << endl;

	return 0;
}

Measured memory_bytes: 256
while True:
    (a, op, b) = input().split()
    a = int(a)
    b = int(b)

    if op == '?':
        break
    elif op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)

Measured memory_bytes: 6724
using System;
using System.Collections.Generic;

namespace ALDS1_3_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var poland = new Stack<int>();
            string[] str = Console.ReadLine().Split();
            for (int i = 0; i < str.Length; i++)
            {
                if (str[i] == "+")
                {
                    poland.Push(poland.Pop() + poland.Pop());
                }
                else if (str[i] == "-")
                {
                    poland.Push(-1 * (poland.Pop() - poland.Pop()));
                }
                else if (str[i] == "*")
                {
                    poland.Push(poland.Pop() * poland.Pop());
                }
                else
                {
                    poland.Push(int.Parse(str[i]));
                }
            }
            Console.WriteLine(poland.Pop());
        }
    }
}

Measured memory_bytes: 10040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int lp = 0; lp < k; lp++) {
        vector<ll> b(n);
        for (int i = 0; i < n; i++) {
            ll s = i - a[i];
            ll t = i + a[i] + 1;
            s = max(0LL, s);
            b[s]++;
            if (t < n) {
                b[t]--;
            }
        }
        for (int i = 1; i < n; i++) {
            b[i] += b[i - 1];
        }
        if (b == a) {
            break;
        }
        swap(a, b);
    }
    for (ll i : a) {
        cout << i << " ";
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 6352
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
       while(true){
        int n = sc.nextInt();
        if(n==0)break;
        int []array=new int [n];
        double sum=0,S=0;
        for(int i=0;i<n;i++){
            array[i]=sc.nextInt();
            sum+=array[i];
        }
        double ave=(double)sum/n;
        for(int i=0;i<n;i++){
            S+=(double)Math.pow(array[i]-ave,2);
        }
        S=(double)S/n;
        S=(double)Math.sqrt(S);
        System.out.println(S);
       }
    }
}


Measured memory_bytes: 31284
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

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

    string ans = "No";
    while(true) {
        C -= B;
        if(C <= 0) {
            ans = "Yes";
            break;
        }
        A -= D;
        if(A <= 0) break;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
b = a[::-1] #小さい順

upper = 200001
lower = 1
while upper-lower > 1:
	mid = (upper+lower)//2
	cnt = 0
	ma = 0
	for mi in range(n):
		while ma < n and b[mi] + a[ma] >= mid:
			ma += 1
		cnt += ma
		#print(ma, mi)
	#print(lower, mid, upper, cnt)
	if cnt > m:
		lower = mid
	else:
		upper = mid

uppercnt = []
cnt = 0
for i in range(n):
	while (cnt < n-1) & (a[i] + b[cnt] < upper):
		cnt += 1
	if a[i] + b[cnt] >= upper:
		uppercnt.append(cnt)
	else:
		uppercnt.append(-1)
c = [a[0]]

uppernum = 0
for i in range(n-1):
	d = c[i] + a[i+1]
	c.append(d)
for i in range(n):
	if uppercnt[i] == -1:
		continue
	else:
		#print(a[i], (n-uppercnt[i]))
		#print(c[n-uppercnt[i]-1])
		uppernum += a[i] * (n-uppercnt[i])
		uppernum += c[n-uppercnt[i]-1]
uppercnter = 0
for i in uppercnt:
	if i != -1:
		uppercnter += n-i

print(lower*(m-uppercnter)+uppernum)

Measured memory_bytes: 64520
#include<stdio.h>
int main()
{
	int h, d, o, x;
	scanf("%d\n%d\n%d\n%d", &h, &d, &o, &x);
	//	h=\500, d=\100, o=50
	int count = 0;
	for (int i = 0; i <= h && i * 500 <= x; i++)
	{
		for (int j = 0; j <= d && i * 500 + j * 100 <= x; j++)
		{
			if ((x-(i * 500 + j * 100)) / 50 <= o)
			{
				count++;
			}
		}
	}
	printf("%d", count);
	return 0;
}

Measured memory_bytes: 128
/**
  Queen Chess
*/

/* include */
#include <stdio.h>
#include <stdlib.h>

/* define */
#define MAX 8
#define BLACK 1 //queen exist
#define WHITE 0 //queen non-exist
#define TRUE 1
#define FALSE -1

/* prototype */
int search(int);
void printing();

/* global */
//X????????????Y????¨???????JUDGE????????????ULLR(Upper Left, Lower Right)???URLL(Upper Right, Lower Left)
int X[MAX], Y[MAX], JUDGE[MAX][MAX], URLL[2*MAX-1], ULLR[2*MAX-1];
int top=1;


int main() {
  int i,j, k, r,c;
  /*?????????????????????*/
  //?????????????¨?????¨??????????
  for(i=0;i<MAX;i++){
    X[i] = WHITE;
    Y[i] = WHITE;
  }
  //?¬??????????????¨??????????
  for(i=0;i<2*MAX-1;i++){
    URLL[i] = WHITE;
    ULLR[i] = WHITE;
  }
  //??????????????????
  for(i=0;i<MAX;i++){
    for(j=0;j<MAX;j++){
      JUDGE[i][j] = FALSE;
    }
  }

  //input
  scanf("%d", &k); //????????????????????¨??????????????°
  for(i=0;i<k;i++){
    scanf("%d %d",&r,&c); //r??????,c????¨?
    JUDGE[r][c] = TRUE; //?????¨
  }
  
  //0???????????????????????????????????????????§£?????¢?´¢
  search(0);
  
  return 0;
}

/** ?????????????????????????????????????????????????????¢?´¢
  * x?????????????????????????????????????????´??????x?????????????????????????????§????????¨????????????
  * ?????????????????£??????????????????????????????????????????
  * ?????°????????¨???????????¨??§????????£???????????¶?????????????????????????????¨?????§??????
  */
int search(int x){
  int y;
  if(x==MAX) { //?????????????????§?????????????????°???????????¶?????°????????§???..????¶???????
    printing(); //?????????????????????????±??????£?????????????????¶????????????
    return 0;
  }
  for(y=0;y<MAX;y++){ 
    if(Y[y]==BLACK || URLL[x+y]==BLACK || ULLR[x-y+MAX-1]==BLACK){
      continue; //??¨???????????????????????????????¬????for()???
    }
    //x???????????????????????????????????????????????????????????\??¨?????¢????????????BLACK?????????
    X[x] = y; //<?\????>???????????¨??????...
    Y[y] = BLACK; //????????????
    URLL[x+y] = BLACK; //?????´????????????
    ULLR[x-y+MAX-1] = BLACK; //??????????????????
    
    //?¬????????????¢?´¢
    search(x+1); //<?\????>??????????¬?????????\???????§???????????????????...
    
    //???????????????????????????????????????
    X[x] = WHITE; //<?\????>??????????????\??§????????????????????§??????...????????????????????????
    Y[y] = WHITE; //??????...
    URLL[x+y] = WHITE; //??????...
    ULLR[x-y+MAX-1] = WHITE; //????????????...
  }
  return 0;
}

/*??????*/
void printing(){
  int i,j;
  for(i=0;i<MAX;i++){
    for(j=0;j<MAX;j++){
      if(JUDGE[i][j] == TRUE) { //?????????????????????????????°
        if(X[i]!=j){
          return;
        }
      }
    }
  }
  for(i=0;i<MAX;i++) {
    for(j=0;j<MAX;j++) {
      if(X[i]==j) {
        printf("Q");
      }else{
        printf(".");
      }
    }
    printf("\n");
  }
}

Measured memory_bytes: 572
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <iterator>

using namespace std;

int main() {
	set<int> A, B;
	set<int> V;
	int n, m;
	int x;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x;
		A.insert(x);
	}

	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> x;
		B.insert(x);
	}
	
	set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(V, V.end()));
	   
	for (auto it = V.begin(); it != V.end(); it++) 
		cout << *it << endl;
}


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

using ll = long long int;

const int MAX_N = (int)(1e3 + 5);
const int MAX_M = (int)(4e1 + 5);

int n;

ll x[MAX_N];
ll y[MAX_N];

ll length[MAX_M];
ll acc_length[MAX_M];

stack<char> ans;

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%lld %lld", &(x[i]), &(y[i]));
  }

  int parity = (abs(x[0]) + abs(y[0])) % 2;
  for (int i = 1; i < n; ++i) {
    if ((abs(x[i]) + abs(y[i])) % 2 != parity) {
      printf("%d\n", -1);
      return 0;
    }
  }

  if (parity == 0) {
    for (int i = 0; i < n; ++i) x[i] += 1;
  }

  int m = 32;
  for (int i = 0; i < m; ++i) {
    length[i + 1] = pow(2, i);
  }

  acc_length[0] = 0;
  acc_length[1] = length[1];
  for (int i = 2; i <= m; ++i) {
    acc_length[i] = acc_length[i - 1] + length[i];
  }

  printf("%d\n", (parity == 0) ? m + 1 : m);

  if (parity == 0) printf("%lld ", 1);
  for (int i = 1; i <= m; ++i) {
    printf("%lld ", length[i]);
  }

  printf("\n");

  for (int j = 0; j < n; ++j) {
    ll cur_x = x[j];
    ll cur_y = y[j];

    // cout << cur_x << "+" << cur_y << endl;

    for (int i = m; i >= 1; --i) {

      // cout << i << ":" << cur_x << "_" << cur_y << endl;

      ll left_mv = abs(cur_x - length[i]) + abs(cur_y);
      ll right_mv = abs(cur_x + length[i]) + abs(cur_y);
      ll down_mv = abs(cur_x) + abs(cur_y - length[i]);
      ll up_mv = abs(cur_x) + abs(cur_y + length[i]);

      if (left_mv <= acc_length[i - 1]) {
        cur_x -= length[i];
        ans.push('R');
      }
      else if (right_mv <= acc_length[i - 1]) {
        cur_x += length[i];
        ans.push('L');
      }
      else if (down_mv <= acc_length[i - 1]) {
        cur_y -= length[i];
        ans.push('U');
      }
      else if (up_mv <= acc_length[i - 1]) {
        cur_y += length[i];
        ans.push('D');
      }
    }

    if (parity == 0) ans.push('L');

    while (!ans.empty()) {
      printf("%c", ans.top());
      ans.pop();
    }

    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 256
'use strict';

function Main(input) {
    const tmp = input.split("\n")[0].split(" ");
    const A = parseInt(tmp[0], 10);
    const B = parseInt(tmp[1], 10);
    let time = A + B;

    if (time >= 24) {
        time -= 24;
    }

    console.log(time);
}

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


Measured memory_bytes: 7372
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
	int x1, y1, x2, y2;
	int x3, y3, x4, y4;
	int x_diff, y_diff;
	cin >> x1 >> y1 >> x2 >> y2;

	x_diff = x2 - x1;
	y_diff = y2 - y1;

	x3 = x2 - y_diff;
    x4 = x1 - y_diff;
	y3 = y2 + x_diff;
	y4 = y1 + x_diff;

	cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const ll MOD = 1000000007;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }
template<int mod>
struct ModInt {
    using ll = long long; ll x;
    ModInt() : x(0) {}
    ModInt(int y) : x(y >= 0 ? ll(y % mod) : (ll)((mod - (-y) % mod))) {}
    ModInt(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
    ModInt &operator+=(const ModInt &rhs) { if((x += rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &rhs) { if((x += mod - rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &rhs) { x = x * rhs.x % mod; return *this; }
    ModInt &operator/=(const ModInt &rhs) { *this *= rhs.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(const ModInt &rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(const ModInt &rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(const ModInt &rhs) const { return ModInt(*this) /= rhs; }
    ModInt operator==(const ModInt &rhs) const { return x == rhs.x; }
    ModInt operator!=(const ModInt &rhs) const { return x != rhs.x; }
    friend ostream &operator<<(ostream &os, const ModInt &rhs) { return os << rhs.x; }
    friend istream &operator>>(istream &is, ModInt &rhs) { ll t; is >> t; rhs = ModInt<mod> (t); return (is); }
private:
    ModInt inverse() const { ll a = x, u = 1LL, v = 0LL, t, b = (ll)mod; while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return  ModInt(u); }
};
using mint = ModInt<MOD>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    int s=0, t=0, sum=0;
    ll ans = 0;
    while(s < N){
        while(t < N && (sum ^ A[t]) == (sum + A[t])){
            sum ^= A[t++];
            ans++;
        }
        sum ^= A[s++];
        ans += t - s;

    }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+9;
int main()
{
    ll n,k,a[N],ans=0,ans1=0;
    vector<ll>v;
    cin>>k>>n;
    for(int i=1;i<=n;i++){ 
        cin>>a[i];
    }
    for(int i=1;i<=n-1;i++){ 
        ans=abs(a[i+1]-a[i]);
        v.push_back(ans);
    }
    v.push_back(k-a[n]+a[1]);
    sort(v.begin(),v.end());
    for(int i=0;i<v.size()-1;i++){ 
        ans1+=v[i];
    }
    cout<<ans1<<'\n';
   

  
  

    return 0;
}


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

constexpr int MAX = 1e7;

int main() {
    long long n, k;
    cin >> n >> k;
    long long ans = n;
    for (int i = 0; i < MAX; i++) {
        chmin(ans, n % k);
        n = abs((n % k) - k);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    SSSS = 10 ** 9 + 7
    [A, B] = string_to_int(inputs[0])
    max_len = max([A, B])
    min_len = min([A, B])
    diff_len = abs(A-B)
    if diff_len >= 2:
        return 0

    pattern = 0
    for i in reversed(range(1, min_len + 1)):
        if i == min_len:
            if diff_len == 1:
                pattern = max_len * min_len
                pattern *= min_len
            else:
                pattern = min_len + min_len
                pattern *= min_len
        else:
            pattern *= i * i
        pattern = pattern % SSSS

    return pattern % SSSS


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 40172