akhauriyash/Code-Regression huggingface dataset:
// 拡張ダイクストラ
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)

int main()
{
	fast();

	using P = pair<ll, ll>;

	// d[0] : うえ, d[1] : みぎ, d[2] : した, d[3] : ひだり
	int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
	ll H, W, K;
	cin >> H >> W >> K;
	vector<string> grid(H);
	vector<vector<vector<P>>> d(H);

	int sx, sy, gx, gy;

	cin >> sx >> sy >> gx >> gy;
	sx--, sy--, gx--, gy--;

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

	for (int i = 0; i < H; i++) // init
	{
		d[i] = vector<vector<P>>(W, vector<P>(4, P(infll, infll)));
	}

	// (最短距離, その方向に進んだ回数), (x, y), dir
	priority_queue<pair<P, pair<P, ll>>, vector<pair<P, pair<P, ll>>>, greater<pair<P, pair<P, ll>>>> pq;

	for (int i = 0; i < 4; i++)
	{
		d[sx][sy][i] = P(1, 0);
		pq.push({d[sx][sy][i], {{sx, sy}, i}});
	}

	while (!pq.empty())
	{
		auto v = pq.top();
		pq.pop();
		ll vx = v.second.first.first, vy = v.second.first.second, dir = v.second.second;

		for (int i = 0; i < 4; i++) // 向きを変える
		{
			P ncost = make_pair(d[vx][vy][dir].first + 1, 0);
			if (d[vx][vy][i] <= ncost)
				continue;
			d[vx][vy][i] = ncost;
			pq.push({ncost, {{vx, vy}, i}});
		}

		// 直進する
		int nx = vx + dx[dir], ny = vy + dy[dir];
		if (nx < 0 || nx >= H || ny < 0 || ny >= W) // grid の外
			continue;
		if (grid[nx][ny] == '@') // 行き止まり
			continue;
		ll df = d[vx][vy][dir].first, ds = d[vx][vy][dir].second;
		P ncost = make_pair(df + (ds + 1) / (K + 1), ds % K + 1);
		if (d[nx][ny][dir] <= ncost)
			continue;
		d[nx][ny][dir] = ncost;
		pq.push({ncost, {{nx, ny}, dir}});
	}

	ll min_cost = (*min_element(d[gx][gy].begin(), d[gx][gy].end())).first;

	cout << (min_cost == infll ? -1 : min_cost) << "\n";
}


Measured memory_bytes: 126772
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#define PB push_back
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=3e5+10;
vector<int> s;
ll xi[N],ti[N];
int li[N],ri[N],n;
int vis[N];
int stk[N],top;
ll ans,L;
int main() {
	rd(n),rd(L);
	ans=n;
	for(int i=1;i<=n;++i) rd(xi[i]);
	for(int i=1;i<=n;++i) rd(ti[i]);
	for(int i=1;i<=n;++i) {
		ans+=ti[i]/(2*L);
		ti[i]%=2*L;
		if(ti[i]==0) ans--,vis[i]=1;
		else {
			li[i]=2*xi[i]>=ti[i];
			ri[i]=2*(L-xi[i])>=ti[i];
			if(!li[i]&&!ri[i]) ti[i]=0,vis[i]=1;
		}
//		printf("%d:(%d,%d) %d\n",i,li[i],ri[i],vis[i]);
	}
//	cout<<ans<<endl;
	int px=1; //py=n;
	while(px<n&&!(li[px]==1&&ri[px]==0)) px++;
	
//	while(py>=1&&!(ri[py]==1&&li[py]==0)) py--;
//	cout<<py<<' '<<px<<endl;
//	for(int i=py+1;i<px;++i) if(!vis[i]) {
//		if(top) vis[stk[top--]]=vis[i]=1,ans++;
//		else stk[++top]=i;
//	}
//	int p=stk[top]; top=0;
	
	int tot=0;
	
	int cnt1=0,cnt2=0;
	for(int i=1;i<px;++i) if(!vis[i]) {
		if(!li[i]) {
			if(top) {
//				cout<<stk[top]<<' '<<i<<endl;
				vis[stk[top--]]=vis[i]=1,tot++,ans--;
			}
			else cnt1++;
		}
		else stk[++top]=i;
	}
	
	for(int i=1;i<=top;++i) s.PB(stk[i]);
	top=0;
	
	for(int i=n-1;i>=px;--i) if(!vis[i]) {
		if(!ri[i]) {
			if(top) {
//				cout<<stk[top]<<' '<<i<<endl;
				vis[stk[top--]]=vis[i]=1,tot++,ans--;
			}
			else cnt2++;
		}
		else stk[++top]=i;
	}
//	cout<<"s.size()="<<s.size()<<endl;
//	for(int i=0;i<s.size();++i) printf("%d ",s[i]); puts("");

	for(int i=top;i>=1;--i) s.PB(stk[i]);
	
//	ans+=(s.size()+1)/2;
//	for(int i=0;i+1<s.size();i+=2) vis[s[i]]=vis[s[i+1]]=1;
	
	tot+=s.size()>>1;
	ans-=s.size()>>1;
//	cout<<"TOT="<<tot<<endl;
	
//	if(p) stk[++top]=p;
//	while(top>1) vis[stk[top]]=vis[stk[top-1]]=1,top-=2,ans++;
//	ans+=top;

//	cout<<cnt1<<' '<<cnt2<<' '<<ans<<' '<<vis[n]<<endl;
	
	if(ri[n]==0||vis[n]) ans++;
	
//	cout<<ans<<endl;
//	if(cnt2||vis[n]) ans++,cout<<"ER"<<endl;
	
//	if(ri[n]==0||ti[n]==0) ans++;
	
//	if(ans1==ans&&!tot) ans+=vis[n];
//	else {
//		int tmp=(vis[n]&&(!flg2))+(!flg1);
//		if(tmp==1) ans+=tmp-(tot&1);
//		else ans++;
//	}

	printf("%lld",ans*2*L);
	return 0;
}

Measured memory_bytes: 10868
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long D = long.Parse(str[0]);
		long G = long.Parse(str[1]);
		long[]A = new long[D];
		long[]B = new long[D];
		for(var i=0;i<D;i++){
			string[] str2 = Console.ReadLine().Split();
			A[i] = long.Parse(str2[0]);
			B[i] = long.Parse(str2[1]);
		}
		long ans = 99999999999;
		for(var i=0;i<(long)(Math.Pow(2,D));i++){
			long ct = 0;
			long cta = 0;
			for(var j=0;j<D;j++){
				if(i/(long)(Math.Pow(2,j))%2==1){
					ct += A[j];
					cta += A[j]*(100*(j+1))+B[j];
				}
			}
			if(cta < G){
				for(var j=D-1;j>=0;j--){
					if(i/(long)(Math.Pow(2,j))%2==0){
						long ct2 = (G - cta - 1) / (100*(j+1)) + 1;
						if(ct2 < A[j]){
							ct += ct2;
							ans = Math.Min(ans,ct);
						}
						break;
					}
				}
			} else {
				ans = Math.Min(ans,ct);
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
(let ((s (sort (remove-duplicates (concatenate 'list (read-line))
                                  :test #'char=)
               #'char-lessp))
      (alp (concatenate 'list "abcdefghijklmnopqrstuvwxyz")))

  (defun f (lst1 lst2)
    (if (null lst2)
      "None"
      (if (null lst1)
        (car lst2)
        (if (not (char= (car lst1) (car lst2)))
          (car lst2)
          (f (cdr lst1) (cdr lst2))))))

  (format t "~A~%"
          (f s alp)))



Measured memory_bytes: 27296
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include"math.h"
using namespace std;
#define MOD 1000000007
class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

int main() {
	int a, b, q;
	cin >> a >> b >> q;
	vector<long long> s(a);
	for (int i = 0; i < a; i++) {
		cin >> s[i];
	}
	vector<long long> t(b);
	for (int i = 0; i < b; i++) {
		cin >> t[i];
	}
	vector<long long> x(q);
	for (int i = 0; i < q; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < q; i++) {
		int ss, xs;
		long long min = 9223372036854775807; 
		ss = find(s, x[i]);
		xs = find(t, x[i]);
		if (ss != -1 && xs != -1) {
			if (s[ss] < t[xs]) {
				min = x[i] - s[ss];
			}
			else {
				min = x[i] - t[xs];
			}
		}
		if (ss != s.size()-1 && xs != t.size()-1) {
			if (s[ss+1] < t[xs+1]) {
				if (min > t[xs+1] - x[i]) {
					min = t[xs+1] - x[i];
				}
				
			}
			else {
				if (min > s[ss+1] - x[i]) {
					min = s[ss+1] - x[i];
				}
			}
		}
		if (ss != s.size()-1 && xs != -1) {
			long long temp = s[ss+1] - x[i] + s[ss+1] - t[xs];
			long long temp2 = x[i] - t[xs] + s[ss + 1] - t[xs];
			if (temp > temp2)temp = temp2;
			if (min > temp)min = temp;
		}
		if (ss != -1 && xs != t.size()-1) {
			long long temp = t[xs + 1] - x[i] + t[xs + 1] - s[ss];
			long long temp2 = x[i] - s[ss] + t[xs + 1] - s[ss];
			if (temp > temp2)temp = temp2;
			if (min > temp)min = temp;
		}

		cout << min << endl;


	}



	return 0;
}


Measured memory_bytes: 3712
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#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(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	string s;
	while(cin >> s){
		bool f = ((s[0]==s.back())+SZ(s))%2;
		if(f) {
			cout << "First" << endl;
			continue;
		}else{
			cout << "Second" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int a,b;
  char op;
  //cin >> a >> op >> b;
  while(1){
    cin >> a >> op >> b;
    //cout << a << " " << op <<" " << b<< endl;
    if(op == '+'){
      cout << a + b << endl;
    }else if(op == '-'){
      cout << a - b << endl;
    }else if(op == '*'){
      cout << a * b << endl;
    }else if(op == '/'){
      cout << a / b << endl;
    }else{
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
bool IsP(const string& str)
{
    if (str.empty())
        return false;
 
    int i = 0;                // first characters
    int j = str.length() - 1; // last character
 
    while (i < j)
    {
        if (str[i] != str[j])
        {
            return false;
        }
        i++;
        j--;
    }
    return true;
}
int main() {
  string s;
  cin >> s;
  int n1,n2;
  n1 = (s.length()-1)/2;
  n2 = (s.length()+3)/2;
  bool b1;
  b1= IsP(s);
  bool b2;
  b2= IsP(s.substr(0,n1));
  bool b3;
  b3= IsP(s.substr(n2-1,s.length()-1));
  if (b1 && b2 && b3) {
    cout << "Yes";
  }else {
    cout << "No"; }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {//Risolto in =(1)
    public static long sum(long n) {
        return n * (n + 1) / 2;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();

        long res = sum(n) - sum(n/3) * 3 - sum(n / 5) * 5 + sum(n / 15) * 15;

        System.out.print(res);
    }
}


Measured memory_bytes: 27068
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

class RMQ {
private:
    vector<ll> val;
    int N;
public:
    RMQ(int n, ll init);
    void update(int i, ll x);
    ll find(int r, int l, int fn, int fr, int fl);
    ~RMQ();
};

RMQ::RMQ(int n, ll init) {
    N = n;
    val.resize(2*N-1, init);
}

void RMQ::update(int i, ll x) {
    i += N-1;
    val[i] = x;
    while (i > 0) {
        i = (i-1)/2;
        val[i] = min(val[i*2+1], val[i*2+2]);
    }
}

ll RMQ::find(int a, int b, int k, int l, int r) {
    // [a, b)のクエリ
    // ノードk(区間[a, b)担当)が答える
    if (b <= l || r <= a) return LINF; // 区間がかぶらなければLINF
    if (a <= l && r <= b) return val[k]; // 区間が完全にかぶっていればval[k]
    else {
        // 一部だけかぶる場合は左右の子に委託する
        ll c1 = find(a, b, 2*k+1, l, (l+r)/2);
        ll c2 = find(a, b, 2*k+2, (l+r)/2, r);
        return min(c1, c2);
    }
}

RMQ::~RMQ() {
}

int main(int argc, char const *argv[]) {
    ll n,x;
    cin >> n >> x;
    vector<ll> a(n);
    int N = 1;
    while (N < n) {N*=2;}
    RMQ segtree(N, LINF);
    REP(i,n) {
        cin >> a[i];
        segtree.update(i,a[i]);
    }

    ll ans = LINF;

    REP(k,n) {
        ll tmp = 0;
        // cout << "k = " << k << endl;
        REP(i,n) {
            // cout << "i = " << i << endl;
            // i-k ~ i までの最小値を足していく
            if (i-k >= 0) {
                tmp += segtree.find(i-k, i+1, 0, 0, N);
                // cout << "p = " << segtree.find(i-k,i+1,0,0,N) << endl;
            }
            else {
                ll pl = segtree.find(0,i+1,0,0,N);
                int l = n+(i-k);
                // cout << "l = " << l << endl;
                ll mi = segtree.find(l,n,0,0,N);
                tmp += min(pl,mi);
                // cout << "m = " << min(pl,mi) << endl;
            }
        }
        tmp += x*k;
        // cout << "tmp = " << tmp << endl;
        ans = min(ans,tmp);
    }

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

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll ,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;

bool iskaibun(string sub){
    // cout << sub << endl;
    int n = sub.size();
    bool ret = true;
    for(int i = 0; i < n; i++){
        if(sub[i] != sub[n-1-i])ret = false;
    }
    return ret;
}

string s;
int main(){
    cin >> s;
    int n = s.size();
    string ans = "Yes";
    if(!iskaibun(s.substr(0,n)))ans = "No";
    // cout << ans << endl;
    if(!iskaibun(s.substr(0,(n-1)/2)))ans = "No";
    // cout << ans << endl;
    // cout << n-(n+3)/2 << endl;
    if(!iskaibun(s.substr((n+3)/2-1,n-(n+3)/2+1)))ans = "No";
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN 2*100005
#define fim '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << fim
#define debug2(x, y) cout << "DEBUG " << x << " " << y << fim
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< fim
#define max3(x, y, z) max(x, max(y, z))
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<unsigned ll, pair<int, int> > piii;
typedef pair<pair<int, int>, int> piii2;
typedef tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
    ll k, n;
    cin >> k >> n;
    vector<ll> vet(n);
    for(int i = 0; i < n; i++)
        cin >> vet[i];
    sort(vet.begin(), vet.end());
    ll ans = INF;
    for(int i = 0; i < n; i++) {
        if(i == 0)
            ans = min(ans, vet[n-1]-vet[0]);
        else {
            ans = min(ans, (k-vet[i])+vet[i-1]);
        }
    }
    cout << ans << endl;
}


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

bool f(int x){
    string s = to_string(x);
    string t = s.substr(3,2);
    reverse(t.begin(), t.end());
    if(s.substr(0,2) == t){
        return true;
    }else{
        return false;
    }
}

int main(){
    int cnt = 0;
    int a, b; cin >> a >> b;

    for(int i = a; i <= b; i++){
        if(f(i)){ cnt++;}
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

template <class InputIterator, class T>
bool contains(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// =========ここまでテンプレ============

int main()
{
    ll thp;
    ll tatk;
    ll ahp;
    ll aatk;
    cin >> thp;
    cin >> tatk;
    cin >> ahp;
    cin >> aatk;

    while (true)
    {
        ahp -= tatk;
        if (ahp <= 0)
        {
            cout << "Yes";
            break;
        }
        else
        {
            thp -= aatk;
            if (thp <= 0)
            {
                cout << "No";
                break;
            }
        }
    }
}

// "NO" ではない！！

Measured memory_bytes: 3128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int 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 vvi 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 MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    set<int> s;
    rep(i,n){
        int x;
        cin>>x;
        s.insert(x);
    }
    cout<<s.size()<<endl;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s; cin>>s;
	for(auto&&i:s){
		if(i=='?')cout<<'D';
		else cout<<i;
	}
	cout<<"\n"s;
}

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

	return 0;
}


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

using namespace std;

long long a, b, c, d;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> a >> b >> c >> d;
	cout << max(max(a*c, a*d), max(b*c, b*d)) << "\n";
	
	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int lazy[200005];
int ans[200005];
vector<int> *adj;
void dfs(int idx, int p){
    
    ans[idx]=lazy[idx];
    for(auto itr:adj[idx]){
        if(itr!=p){
            lazy[itr]+=lazy[idx];
            dfs(itr,idx);
        }
    }
    return ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,q,a,b;
    cin>>n>>q;
    adj=new vector<int>[n];
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        a--;
        b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    
    for(int i=0;i<q;i++){
        cin>>a>>b;
        a--;
        lazy[a]+=b;
    }
    dfs(0,-1);
    for(int i=0;i<n;i++){
        cout<<ans[i]<<" ";
    }
    cout<<"\n";
}


Measured memory_bytes: 24320
#include <string>
#include <sstream>
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <queue>

using namespace std;


class Main {
public:
	int minNum(int k, int t, vector<int>& as) {

		int maxNum = 0;
		int sum = 0;
		for (int i = 0;i < as.size();i++) {
			maxNum = max(as[i], maxNum);
			sum += as[i];
		}
		vector<int> buf(sum);

		int count = maxNum;
		for (int i = 0;count >= 1 && i < sum;i+=2) {
			buf[i] = 1;
			count--;
		}

		bool lastPut = false;
		int dir = -1;
		int j = sum - 1;
		while(count >= 1) {
			if (buf[j] == 0) {
				if (!lastPut) {
					buf[j] = 1;
					count--;
				}
				lastPut = !lastPut;
			}
			
			j += dir;
			if (j < 0) {
				j = 0;
				dir *= -1;
				lastPut = false;
			}
			else if (sum <= j) {
				j = sum - 1;
				dir *= -1;
				lastPut = false;
			}
		}

		int sameCount = 0;
		for (int i = 1;i < sum;i++) {
			if (buf[i - 1] == 1 && buf[i] == 1) {
				sameCount++;
			}
		}

		return sameCount;
	}
};


int main()
{
	Main m;
	int k, t;
	vector<int> as;

	cin >> k >> t;
	for (int i = 0;i < t;i++) {
		int inp;
		cin >> inp;
		as.push_back(inp);
	}

	cout << m.minNum(k,t,as) << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	
	A := ScanInt(scanner)
	B := ScanInt(scanner)
	X := ScanInt(scanner)
	
	if A <= X && X <= A + B {
	    fmt.Println("YES")
	} else {
	    fmt.Println("NO")
	}
}

func ScanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func ScanFloat64(scanner *bufio.Scanner) float64 {
	scanner.Scan()
	f, e := strconv.ParseFloat(scanner.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func ScanText(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}
 

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#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--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int A,B,C,D;






int main()
{

	cin >> A>>B>>C>>D;

	if(B < C || A > D)
		cout << 0 << endl;
	else
		cout << min(B,D) - max(A,C) << endl;



}




Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    h = [int(input()) for _ in range(N)]

    sort_h = sorted(h, reverse=True)

    ans = float('inf')
    for i in range(N-K+1):
        tmp = sort_h[i] - sort_h[i + K - 1]
        if ans > tmp:
            ans = tmp

    print(ans)

main()

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

int main(){
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;

	int x1,x2,y1,y2;
	x1 = x+r;
	x2 = x-r;
	y1 = y+r;
	y2 = y-r;

	if (x1<=W && x2 >=0 && y1<=H && y2 >= 0){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
		
	return 0;
}



Measured memory_bytes: 3116
d,g = map(int,input().split())
p,c = [0]*d,[0]*d
import math

for i in range(d):
    p[i],c[i] = map(int,input().split())

ans = 10**9
for i in range(2**d):
    ls = ""
    for j in range(d):
        if (i>>j)&1:
            ls = "1"+ls
        else:
            ls = "0"+ls
    score = 0
    cnt = 0
    ls = list(ls)
    for i in range(d):
        if ls[(d-1)-i] == "1":
            score += 100*(i+1)*p[i] + c[i]
            cnt += p[i]
    if score>=g:
        ans = min(ans,cnt)
    else:
        index = d-1 - ls.index("0")
        maximum = p[index]
        score = g - score
        if maximum>=math.ceil(score/((index+1)*100)):
            cnt +=math.ceil(score/((index+1)*100))
            ans = min(ans,cnt)
        else:
            pass


print(ans)
        



Measured memory_bytes: 42736
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;

int n;
int a[MAXN];


void run() {
	scanf("%d",&n); REP(i,n) scanf("%d",&a[i]),--a[i];
	int ret=0; REP(i,n) if(a[i]>i&&a[a[i]]==i) ++ret; printf("%d\n",ret);
}

int main() {
	run();
	return 0;
}


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

#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll MOD = 1000000007;
const long long INF = 1LL << 60;
//cout<<fixed<<setprecision(10);

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;}

signed main()
{   
    gearup;
    vector<int> a(3);
    rep(i,3) cin>>a[i];
    map<int,int> mp;
    rep(i,3)mp[a[i]]++;
    for(auto m:mp){
        if(m.second == 1)cout << m.first << endl;
    }
}


Measured memory_bytes: 256
n,x = map(int, input().split())
a = list(map(int, input().split()))
cost = a[:]
use = [i for i in range(n)]
ans = sum(a)
for k in range(1,n):
  for i in range(n):
    j = (i-k)%n
    if cost[i] > a[j]:
      cost[i] = a[j]
      use[i] = j
  cur = k*x + sum(cost)
  if ans > cur:
    ans = cur
print(ans)

Measured memory_bytes: 3188
#include<stdio.h>
#include<iostream>
#include<cmath>
using namespace std;

struct Line{
    bool isRightX, isRightY;
    double x, y, a, b;
};

Line getBisector(double x1, double y1, double x2, double y2){
    Line bisector;
    bisector.isRightX = bisector.isRightY = false;
    if ( y1 == y2 ){   
	bisector.isRightY = true;
	bisector.x = ( x1 + x2 ) / 2;
    } else if ( x1 == x2 ){    
	bisector.isRightX = true;
	bisector.y = ( y1 + y2 ) / 2;
    } else {
	bisector.a = ( x2 - x1 ) / ( y1 - y2 );
	bisector.b = ( y1 + y2 ) / 2 - bisector.a * (( x1 + x2 ) / 2);
    }

    return bisector;
}

void compute(){
    double x1, y1, x2, y2, x3, y3, x, y, r;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    Line AB = getBisector(x1, y1, x2, y2);
    Line AC = getBisector(x1, y1, x3, y3);
    if ( AB.isRightX ){
	if ( AC.isRightY ){
	    x = AC.x; y = AB.y;
	} else {
	    y = AB.y; x = (y - AC.b) / AC.a;
	}
    } else if ( AB.isRightY ){ //y ツ篠イツづ可閉スツ行
	if ( AC.isRightX ){
	    x = AB.x; y = AC.y;
	} else {
	    x = AB.x; y = AC.a * x + AC.b;
	}
    } else {
	if ( AC.isRightX ) {
	    y = AC.y; x = (y - AB.b) / AB.a;
	} else if ( AC.isRightY ) {
	    x = AC.x; y = AB.a * x + AB.b;			
	} else {
	    x = (AC.b - AB.b) / (AB.a - AC.a); 
	    y = AB.a * x + AB.b;
	}	
    }
    r = sqrt( (x - x1)*(x - x1) + (y - y1)*(y - y1) );

    printf("%.3lf %.3lf %.3lf\n", x, y, r);
}

int main(){
    int tcase; cin >> tcase;
    for ( int i = 0; i < tcase; i++ ){
	compute();
    }
    return 0;
}

Measured memory_bytes: 0
N, K, S = map(int, input().split())
INF = 10**9

if K == 0:
    if S == INF:
        print(' '.join([str(INF-1) for _ in range(N)]))
    else:
        print(' '.join([str(INF) for _ in range(N)]))
    exit()

if S == INF:
    ans = [INF] * K
    ans.extend([INF-1] * (N-K))
else:
    ans = [S] * K
    ans.extend([INF] * (N-K))
print(' '.join([str(x) for x in ans]))

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

int H;
int W;
char orchard[100][100];

void dfs(int x, int y, char type){
	orchard [x][y] = 'f';
	
	int der[][2] = { {0, 1}, {1, 0}, {0, -1}, {-1, 0} };
	
	for(int i = 0; i <= 3; i++){
		int nx = x + der[i][0];
		int ny = y + der[i][1];
		
		if(0 <= nx && nx < H && 0 <= ny && ny < W && orchard[nx][ny] == type)
			dfs(nx, ny, type);
	}
	
	return ;
} 

int main(){
	while(cin >> H >> W){
		
		if(H == 0 && W == 0)
			return 0;
			
		int i,j;
		char type;
		int num = 0;
		
		for(i = 0; i < H ; i++){
			for(j = 0; j < W; j++){
				cin >> orchard[i][j];
			} 
		}
		
		for(i = 0; i < H; i++){
			for(j = 0; j < W; j++){
				type = orchard[i][j];
				if(type != 'f'){
					num++;
					dfs(i, j, type);
				}
			}
		}
		cout << num << endl;
	}
	
}


Measured memory_bytes: 4032
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include <map>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()


int main() {
	int n;
	cin >> n;
	ll a[n];
	ll ans = 0;
	ll max=0;
	rep(i, n) {
		cin >> a[i];
		if (i > 0) {
			if (a[i]<max) {
				ans += max - a[i];
			}
			if (a[i] > max) {
				max = a[i];
			}
		}
		else {
			max = a[i];
		}
		//cout << ans << endl;
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 4752
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        for(int i=0; i<n; ++i){
            int pm, pe, pj;
            cin >> pm >> pe >> pj;
            if(pm == 100 || pe == 100 || pj == 100)
                cout << 'A' << endl;
            else if((pm + pe) / 2 >= 90)
                cout << 'A' << endl;
            else if((pm + pe + pj) / 3 >= 80)
                cout << 'A' << endl;
            else if((pm + pe + pj) / 3 >= 70)
                cout << 'B' << endl;
            else if((pm + pe + pj) / 3 >= 50 && (pm >= 80 || pe >= 80))
                cout << 'B' << endl;
            else
                cout << 'C' << endl;
        }
    }
}

Measured memory_bytes: 0
# dpA - Frog 1
def main():
    n = int(input())
    A = tuple(map(int, input().rstrip().split()))
    x, y = 0, abs(A[1] - A[0])
    for i in range(2, n):
        dif1 = x + abs(A[i] - A[i - 2])
        dif2 = y + abs(A[i] - A[i - 1])
        x, y = y, min(dif1, dif2)
    print(y)


if __name__ == "__main__":
    main()

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

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

    vector<int> l(m); vector<int> r(m);

    int lmax=1,rmin=1e5;

    for(int i=0; i<m; i++){
        cin>>l[i]>>r[i];

        lmax = max(lmax,l[i]);

        rmin = min(rmin,r[i]);
    }

    if(rmin > n) cout<<n -lmax +1<<endl;

    else cout<<max( rmin -lmax + 1,0)<<endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

int main()
{
  std::string s;
  std::cin >> s;
  int p = 700;
  for ( int i = 0; i < 3; i++ ) {
    if ( s[i] == 'o' ) p += 100;
  }
  std::cout << p << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define SZ(X) ((int64_t)((X).size()))
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
#define doublemax (std::numeric_limits<double>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);

//sort(ALL(v),greater<int>());


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

	int N;
	cin >> N;
	vector<int>A(N), B(N);
	rep(i, N) {
		cin >> A[i] >> B[i];
	}

	int ans = 0;
	for (int i = N - 1; 0 <= i; i--) {
		A[i] += ans;
		if (A[i] == 0)continue;
		if (A[i] <= B[i]) {
			ans += B[i] - A[i];
			continue;
		}
		if (A[i] % B[i] == 0)continue;

		A[i] %= B[i];
		ans += B[i] - A[i];
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<vector>
#define R register
#define next kkksc03
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
inline ll read();
inline void write(ll x);
inline void writesp(ll x);
inline void writeln(ll x);
char s1[1000000],s2[1000000];
ll ans,n;

int main(){	
	n=read();
	if(n%2){
		writeln(0);
		return 0;
	}
	for(R ll i=10;i<=n;i*=5){
		ans+=n/i;
	}
	writeln(ans);
	//1000000000000000000
	//124999999999999995
}
inline ll read(){
	ll x=0,t=1;char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') t=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*t;
}
inline void write(ll x){
	if(x<0){putchar('-');x=-x;}
	if(x<=9){putchar(x+'0');return;}
	write(x/10);putchar(x%10+'0');
}
inline void writesp(ll x){
	write(x);putchar(' ');
}
inline void writeln(ll x){
	write(x);putchar('\n');
}
/**
*¡¡¡¡©³©·¡¡¡¡¡¡©³©·+ +
*¡¡©³©¿©ß©¥©¥©¥©¿©ß©· + +
*¡¡©§¡¡¡¡¡¡¡¡¡¡¡¡¡¡©§
*¡¡©§¡¡¡¡¡¡©¥¡¡¡¡¡¡©§ ++ + + +
*  ¨€¨€¨€¨€©¥¨€¨€¨€¨€+
*  ¨¨€¨€¨¡¡¨¨€¨€¨ +
*¡¡©§¡¡¡¡¡¡©ß¡¡¡¡¡¡©§
*¡¡©§¡¡¡¡¡¡¡¡¡¡¡¡¡¡©§ + +
*¡¡©»©¥©·¡¡¡¡¡¡©³©¥©¿
*¡¡¡¡¡¡©§¡¡¡¡¡¡©§ + + + +Code is far away from ¡¡
*¡¡¡¡¡¡©§¡¡¡¡¡¡©§ + bug with the animal protecting
*¡¡¡¡¡¡©§¡¡ ¡¡ ©»©¥©¥©¥©· ÉñÊÞ±£ÓÓ,´úÂëÎÞbug¡¡
*¡¡¡¡¡¡©§ ¡¡¡¡¡¡¡¡¡¡¡¡ ©Ç©·
*¡¡¡¡  ©§ ¡¡¡¡¡¡¡¡¡¡ ¡¡©³©¿
*¡¡    ©»©·©·©³©¥©×©·©³©¿ + + + +
*¡¡¡¡¡¡¡¡©§©Ï©Ï¡¡©§©Ï©Ï
*¡¡¡¡¡¡¡¡©»©ß©¿¡¡©»©ß©¿+ + + +
*/

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

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

  if (N > M)
    swap(N, M);

  ll ans;

  if (N == 1) {
    if (M == 1)
      ans = 1;
    else
      ans = M - 2;
  } else if (N == 2) {
    ans = 0;
  } else {
    ans = ll(N - 2) * (M - 2);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<string.h>
#include<stdio.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
    if(ch=='A'){return 1;}
    else if(ch=='C'){return 2;}
    else if(ch=='G'){return 3;}
    else if(ch=='T'){return 4;}
    else{return 0;}
    
}

long long getkey(char str[]){
    long long sum=0,p=1,i;
    for(i=0;i<strlen(str);i++){
        sum+=p*(getChar(str[i]));
        p*=5;
    }
    return sum;
}

int h1(int key){return key%M;}
int h2(int key){return 1+(key%(M-1));}

int find(char str[]){
    long long key,i,h;
    key=getkey(str);
    for(i=0;;i++){
        h = (h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0){return 1;}
        else if(strlen(H[h])==0){return 0;}
        
    }
    return 0;
}

int insert(char str[]){
    long long key,i,h;
    key=getkey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0){return 1;}
        else if(strlen(H[h])==0){
            strcpy(H[h],str);
            return 0;
            
        }
    }
    return 0;
}

int main(void){
    int i,n,h;
    char str[L],com[9];
    for(i=0;i<M;i++){
        H[i][0]='\0';
    }
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s %s",com,str);
        
        if(com[0]=='i'){
            insert(str);
        }
        else{
            if(find(str)){
                printf("yes\n");
            }
            else{
                printf("no\n");
            }
        }
    }
    return 0;
}




Measured memory_bytes: 16100
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  var A = input[1].split(" ").map(i => parseInt(i));
  A.sort((a,b) => b-a);
  var ans =0;
  var P = new Array(1).fill(A[0]);
  for(var i = 0;i<N-1;i++){
    ans += P[i];
    P.push(A[i+1]);
    P.push(A[i+1]);
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
 string a,b;
  cin >> a >> b;
  int n,m,cnt=0;
  n=a.size();
  m=b.size();
  if(n>m){
    cout << "GREATER" << endl;
   return 0;
  }
  else if(n<m){
    cout << "LESS" << endl;
   return 0;
  }
  else{
   for(int i=0;i<n;i++){
    if(a[i]>b[i]){
      cout << "GREATER" << endl;
      return 0;
    }
    else if(a[i]<b[i]){
      cout << "LESS" << endl;
      return 0;
    }
    else cnt++;
   }
  }

  if(cnt==n)cout << "EQUAL" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
using namespace std; 
using ll = long long;



int main(int argc, char const *argv[])
{
    ll n, a, b;
    cin >> n >> a >> b;
    ll c = a + b;
    ll ans = a * (n/c);
    ans += min(n%c, a);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
can = [0]
gets
a = gets.split.map(&:to_i)
n = gets.to_i
m = gets.split.map(&:to_i)
a.each_with_index {|e,i|
  if i == 0
    can << e
  else
    can = Marshal.load(Marshal.dump(can + can.map {|ele| ele + e}))
  end
  can.uniq!
}
n.times{|i|
  if can.include?m[i]
    puts 'yes'
  else
    puts 'no'
  end
}

Measured memory_bytes: 6424
#include<iostream>

using namespace std;

int main(){
  int N,a[103],x=0;

  cin>>N;

  for(int i = 1;i<=N;i++){
    cin>>a[i];
  }

  a[0]=0;
  a[N+1]=0;

  while(1) {
    for(int i = 0;i<=N+1;i++) {
      if(a[i] != 0) {
        for(int j = i;j<=N+1;j++) {
          if(a[j]>0) {
            a[j] = a[j] - 1;
          } else {
            x = x + 1;
            i = j;
            break;
          }
        }
      }
    }
    bool is_all_zero = true;
    for(int i = 0;i<=N+1;i++) {
      if(a[i] != 0) {
        is_all_zero = false;
      }
    }
    if(is_all_zero) {
      break;
    }
  }
  cout<<x<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  static boolean palin(String s)
  {char c[]=s.toCharArray();
   int n=c.length;
   if(n==1)
     return true;
   for(int i=0;i<n;i++)
   {
     if(c[i]!=c[n-1-i])
       return false;
   }
   return true;
  }
 public static void main(String args[])
   { Scanner sc=new Scanner(System.in);
     String s=sc.next();
    int n=s.length();
     boolean palindrome=palin(s);
     if(palindrome)
     { String x=s.substring(0,(n-1)/2);
       String y=s.substring(((n+3)/2)-1,n);
       if(palin(x) && palin(y))
         System.out.println("Yes");
       else
      System.out.println("No");
     }
    else
      System.out.println("No");
   }
}


Measured memory_bytes: 23124
#include<stdlib.h>
#include<cstdio>
#include<unordered_map>
#include<unordered_set>
#include<algorithm>
#include<vector>
#include<string>
#include<stack>
#include<map>
#include<string.h>
#include<iostream>
#include<queue>
#pragma warning(disable:4996)
using namespace std;

bool d[2005][2005];
int K[2005][2005];
int n[2005][2005];//横
int m[2005][2005];//縦
char S[2005];
signed main() {
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	for (int e = 0; e < a; e++) {
		scanf("%s", S);
		for (int f = 0; f < b; f++) {
			if (S[f] == '1') {
				d[e][f] = true;
			}
		}
	}
	for (int i = 1; i <= a; i++) {
		for (int j = 1; j <= b; j++) {
			K[i][j] = K[i - 1][j] + K[i][j - 1] - K[i - 1][j - 1] + d[i - 1][j - 1];
		}
	}
	for (int i = 1; i < a; i++) {
		for (int j = 1; j <= b; j++) {
			n[i][j] = n[i - 1][j] + n[i][j - 1] - n[i - 1][j - 1] + (d[i - 1][j - 1] && d[i][j - 1]);
		}
	}
	for (int i = 1; i <= a; i++) {
		for (int j = 1; j < b; j++) {
			m[i][j] = m[i - 1][j] + m[i][j - 1] - m[i - 1][j - 1] + (d[i - 1][j - 1] && d[i - 1][j]);
		}
	}
	for (int i = 0; i < c; i++) {
		int dx, dy, ex, ey;
		scanf("%d%d%d%d", &dx, &dy, &ex, &ey);
		dx--; dy--;
		int ans = K[ex][ey] - K[ex][dy] - K[dx][ey] + K[dx][dy];
		ans -= n[ex - 1][ey] - n[ex - 1][dy] - n[dx][ey] + n[dx][dy];
		ans -= m[ex][ey - 1] - m[ex][dy] - m[dx][ey - 1] + m[dx][dy];
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 52864
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int n;
int t[10002];
int dp[2][5002][2];

int minCost(const int &a, const int &b){
  if(a == -1) return b;
  if(b == -1) return a;
  return a > b ? b : a;
}

int solve(){
  memset(dp, -1, sizeof(dp));
  dp[1][1][0] = dp[1][0][1] = 0;

  for(int i = 1; i < n; i++){
    int to = min(i, n / 2);

    for(int j = 0; j <= to; j++){
      for(int pre = 0; pre < 2; pre++){
        if(dp[i % 2][j][pre] == -1) continue;

        int ni = (i + 1) % 2;

        for(int next = 0; next < 2; next++){
          if(pre == next){
            if(next == 0) dp[ni][j + 1][next] = minCost(dp[ni][j + 1][next], dp[i % 2][j][pre]);
            else          dp[ni][j][next] = minCost(dp[ni][j][next], dp[i % 2][j][pre]);
          }
          else{
            if(next == 0) dp[ni][j + 1][next] = minCost(dp[ni][j + 1][next], dp[i % 2][j][pre] + t[i - 1]);
            else          dp[ni][j][next] = minCost(dp[ni][j][next], dp[i % 2][j][pre] + t[i - 1]);
          }
        }

        dp[i % 2][j][pre] = -1;
      }
    }
  }

  return minCost(dp[0][n / 2][0], dp[0][n / 2][1]);
}

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n - 1; i++){
    scanf("%d", &t[i]);
  }
  printf("%d\n", solve());
}

Measured memory_bytes: 952
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define mod 1000000007 //1e9+7
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 1001

void calc(int n,int r){
  stack<int> card;

  for(int i=0;i<n;i++){
    card.push(i+1);
  }

  for(int i=0;i<r;i++){
    int p,c;
    stack<int> s1,s2;

    scanf("%d%d",&p,&c);

    for(int i=0;i<p-1;i++){
      s1.push(card.top());
      card.pop();
    }

    for(int i=0;i<c;i++){
      s2.push(card.top());
      card.pop();
    }

    for(int i=0;i<p-1;i++){
      card.push(s1.top());
      s1.pop();
    }

    for(int i=0;i<c;i++){
      card.push(s2.top());
      s2.pop();
    }

    
    
  }
  
  printf("%d\n",card.top());

}

int main(){
  int n,r;

  while(1){
    scanf("%d%d",&n,&r);
    if(n==0) break;
    calc(n,r);
  }
  
  return 0;
}

Measured memory_bytes: 3116
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long m = in.nextLong();
        long n = in.nextLong();
        System.out.println(lcm(m,n));
    }
    private static long gcd(long m, long n) {
    if(m < n) return gcd(n, m);
    if(n == 0) return m;
    return gcd(n, m % n);
    }
    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }
}

Measured memory_bytes: 23892
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　RedcoderになるためAtCoderを巡る旅をしてます。

　　　 　＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　   ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

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

#define COUT(x) cout << (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;
}

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

    int A, B, C; cin >> A >> B >> C;
    if((A == B && B == C) || (A != B && B != C && C != A)) COUT("No");
    else COUT("Yes");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n; cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    ll dp[n][2];
    dp[0][0]=a[0];
    dp[0][1]=-a[0];
    for(int i=1;i<n;i++){
        dp[i][0]=max(dp[i-1][0]+a[i],dp[i-1][1]-a[i]);
        dp[i][1]=max(dp[i-1][0]-a[i],dp[i-1][1]+a[i]);
    }
    cout<<dp[n-1][0]<<endl;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) std::begin(x), std::end(x)
using namespace std;
template <class T, class U> inline void chmin(T & a, U const & b) { a = min<T>(a, b); }
template <typename T> T gcd(T a, T b) { while (a) { b %= a; std::swap(a, b); } return b; }
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

int solve2(int n, int m, const vector<int> & a) {
    int cnt = 0;
    REP3 (x, 1, m + 1) {
        bool found = true;
        for (int a_i : a) {
            if (2 * x % a_i == 0 and (2 * x / a_i) % 2 == 1) {
                // nop
            } else {
                found = false;
            }
        }
        cnt += found;
    }
    return cnt;
}

int solve1(int n, int m, const vector<int> & a) {
    set<int> even;
    int64_t odd = 1;
    for (int a_i : a) {
        int k = __builtin_ctz(a_i);
        even.insert(k);
        if (even.size() >= 2) return 0;
        odd = lcm<int64_t>(odd, a_i >> k);
        if (2 * m < (odd << k)) return 0;
    }
    int k = *even.begin();
    if (k == 0) {
        return (count(ALL(a), a[0]) == n);
    } else {
        int64_t z = odd << (k - 1);
        return (m - z) / (2 * z) + (z <= m);
    }
}

int main() {
    int n, m; scanf("%d%d", &n, &m);
    vector<int> a(n);
    REP (i, n) {
        scanf("%d", &a[i]);
    }
    int cnt = solve1(n, m, a);
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 640
#include<iostream>

using namespace std;

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

Measured memory_bytes: 1188