akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main () {
  int a, b, c;
  cin >> a >> b >> c;
  int e = a / b;
  if(a % b > 0) {
    cout << (e + 1) * c << endl;
  }
  else {
    cout << e * c << endl;
  }
}

Measured memory_bytes: 3588
import sys
input = sys.stdin.readline
#-------------------------------------
def gcd( x, y ):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

a,b,c,d = map(int,input().split())
cd = c*d
bcnt = b-(b//c+b//d-b//(cd//gcd(c,d)))
acnt = 0
if a>1:
        a -= 1
        acnt = a-(a//c+a//d-a//(cd//gcd(c,d)))

print(bcnt-acnt)

Measured memory_bytes: 38256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
vector<vector<int>>s(100030);
vector<vector<int>>sb(100030);
int tomodati[100030] = {};
int seen[100030] = {};
int namaes[100030] = {};
int main() {
	long long int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c) {
		cout << "No";
			return 0;
	}
	long long int k = (c - a - b) * (c - a - b);
	if (4*a*b < k) {
		cout << "Yes";
		return 0;
	}
	cout << "No";
}


Measured memory_bytes: 4992
n=gets.to_i
ls=gets.split.map(&:to_i).sort.tally
r=0
ls.keys.combination(3).to_a.each do |l|
  a,b,c=l[0],l[1],l[2]
  if c<b+a && b-a<c
    r+=ls[a]*ls[b]*ls[c]
  end
end
p r

Measured memory_bytes: 22716
#include <iostream>

using namespace std;

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

    long long count = 0;
    if (k == 0) {
        count = n * n;
    } else {
        for (long long b = 1; b <= n; b++) {
            if (b <= k)
                continue;
            count += (n / b) * (b - k);
            if (n % b >= k)
                count += n % b - k + 1;
        }
    }
    cout << count << endl;
}


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

using ll = unsigned long long;
using P = pair<int, int>;
#define rep1(i,n) for (int i=1; i<=n; i++)
#define rep0(i,n) for (int i=0; i<n; i++)
#define zarray(x,n) x[n+1]; rep1(i,n) {x[i]=0;} 

int main() {
    int n, q;
    cin >> n;
    ll zarray(a,100000);

    rep1(i,n) {
        int x;
        cin >> x;
        a[x]++;
    }

    ll sum = 0;
    rep1(j,100000) {
        sum += j * a[j];
    }
    //cerr << sum << endl;

    cin >> q;
    rep0(i,q) {
        ll b;
        ll c;
        cin >> b >> c;
        ll sub = b * a[b] + c * a[c];
        a[c] += a[b];
        a[b] = 0;
        sum += c * a[c] - sub;
        cout << sum << endl;
    }
}


Measured memory_bytes: 4400
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
#define yes(a) printf(a ? "yes\n" : "no\n")
#define Yes(a) printf(a ? "Yes\n" : "No\n")
#define YES(a) printf(a ? "YES\n" : "NO\n") 
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

ll n;
vector<ll> num;

void dfs(ll x){
  if(x > 1000000000) return;
  num.pb(x);
  dfs(x*10+3);
  dfs(x*10+5);
  dfs(x*10+7);

  return;
}

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

  cin >> n;
  ll ans = 0;
  dfs(3);
  dfs(5);
  dfs(7);
  sort(all(num));
  for(auto i : num){
    string s = to_string(i);
    if(i <= n){
      if(s.find('3') != string::npos && s.find('5') != string::npos && s.find('7') != string::npos){
        ans++;
      }
    }else break;
  }
  cout << ans << endl;
	return 0;
}

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

int main() {
    int n, p;
    cin >> n >> p;
    string s;
    cin >> s;
    
    ll res = 0;
    if (p == 2 || p == 5) {
        for (int i = 0; i < n; i++) {
            if ((s[i] - '0') % p == 0) res += i + 1;
        }
    } else {
        int m = 1;
        vector<int> mod(n);
        int val = 0;
        for (int i = n - 1; i >= 0; i--) {
            val += m * (s[i] - '0');
            val %= p;
            mod[i] = val;
            m = 10 * m % p;
        }
        vector<int> cnt(p, 0);
        for (int i = 0; i < n; i++) {
            ++cnt[mod[i]];
            res += (mod[i] == 0 ? cnt[mod[i]] : cnt[mod[i]] - 1);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 1284
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

int N;
int main(void){
    cin >> N;
    if(N%2==0) cout << N/2 - 1 << endl;
    else cout << N/2 << endl;
    return 0;
}



Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;

int main()
{
	FAST;
	int arr[101][101] = {0};

	int w,h,n;
	cin >> w >> h >> n;
	
	while(n--)
	{
		int x,y,a;
		cin >> x >> y >> a;

		if(a == 1)
		{
			for(int i=0 ; i<x ; i++)
				for(int j=0  ; j<h ; j++)	arr[i][j] = 1;
		}
		else if(a == 2)
		{
			for(int i=x ; i<w ; i++)
				for(int j=0 ; j<h ; j++)	arr[i][j] = 1;
		}
		else if(a == 3)
		{
			for(int i=0 ; i<w ; i++)
				for(int j=0 ; j<y ; j++)	arr[i][j] = 1;
		}
		else
		{
			for(int i=0 ; i<w ; i++)
				for(int j=y ; j<h ; j++)	arr[i][j] = 1;
		}
	}

	int count = 0;
	for(int i=0 ; i<w ; i++)
	{
		for(int j=0 ; j<h ; j++)
		{
			if(!arr[i][j])	count++;
		}
	}
	cout << count;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int num = 2019;
  string s;
  cin >> s;
  int n = s.size();
  vector<int> d(n+1);
  int ten = 1;
  for (int i = n-1; i >= 0; --i) {
    int a = (s[i]-'0') * ten % num;
    d[i] = (d[i+1]+a) % num;
    ten *= 10; ten %= num;
  }
  vector<int> cnt(num);
  long long ans = 0;
  for (int i = n; i >= 0; --i) {
    ans += cnt[d[i]];
    cnt[d[i]]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4336
import java.util.Random;
import java.util.Scanner;

public class Main {
    static int d = 365;
    static int[] c = new int[26];
    static int[][] s = new int[d][26];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Random random = new Random();
        sc.nextInt();
        for (int i=0;i<26;i++){
            c[i]=sc.nextInt();
        }
        for (int i=0;i<d;i++){
            for (int j=0;j<26;j++){
                s[i][j]=sc.nextInt();
            }
        }
        int[] contest = new int[d];
        int count = 100000;
        for (int i=0;i<d;i++)contest[i]=random.nextInt(26);
        for (int i=0;i<count;i++){
            int[] instance = contest.clone();
            int times = 1;
            int[] choose = new int[times];
            for (int j=0;j<times;j++)choose[j]=random.nextInt(d);
            for (int j=0;j<times;j++)instance[choose[j]]=random.nextInt(26);
            if (function(contest)<function(instance))contest=instance;
        }
        for (int i=0;i<d;i++)System.out.println(contest[i]+1);
    }
    static long function(int[] contest){
        long satisfaction = 0;
        int[] interval = new int[26];
        for (int i=0;i<d;i++){
            satisfaction+=s[i][contest[i]];
            for (int j=0;j<26;j++)interval[j]++;
            interval[contest[i]]=0;
            for (int j=0;j<26;j++)satisfaction-=c[j]*interval[j];
        }
        return  satisfaction;
    }
}


Measured memory_bytes: 57296
#include<cstdio>
#include<cstring>
using namespace std;
char ch[105];
int len;
inline int read(){
	int ret=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return ret*f;
}
int main(){
	scanf("%s",ch+1);
	len=strlen(ch+1);
	for (int i=1;i<=len;i++){
		if ((i&1)){
			if (ch[i]=='L'){printf("No");return 0;}
		}else{
			if (ch[i]=='R'){printf("No");return 0;}
		}
	}
	printf("Yes");
	return 0;
}

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

struct Node
{
	int parent;
	int child_left;
	int child_right;
};

int get_sibling(int id, const vector<Node>& t)
{
	if (t[id].parent == -1) return -1;
	if (t[t[id].parent].child_left == -1 || t[t[id].parent].child_right == -1) return -1;
	else {
		if (t[t[id].parent].child_left == id) return t[t[id].parent].child_right;
		else return t[t[id].parent].child_left;
	}
}

int get_degree(int id, const vector<Node>& t)
{
	if (t[id].child_left == -1 && t[id].child_right == -1) return 0;
	else if (t[id].child_left == -1 || t[id].child_right == -1) return 1;
	else return 2;
}

void set_depth(int id, int d, const vector<Node>& t, vector<int>& depth)
{
	if (id == -1) return;
	depth[id] = d;
	set_depth(t[id].child_left, d + 1, t, depth);
	set_depth(t[id].child_right, d + 1, t, depth);
}

int set_height(int id, const vector<Node>& t, vector<int>& height)
{
	int h_left = 0, h_right = 0;
	if (t[id].child_left != -1) h_left = set_height(t[id].child_left, t, height) + 1;
	if (t[id].child_right != -1) h_right = set_height(t[id].child_right, t, height) + 1;
	return height[id] = max(h_left, h_right);
}

string get_type(int id, const vector<Node>& t)
{
	if (t[id].parent == -1) return "root";
	else if (t[id].child_left == -1 && t[id].child_right == -1) return "leaf";
	else return "internal node";
}

void print(int id, const vector<Node>& t, const vector<int>& depth, const vector<int>& height)
{
	printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s",
		id, t[id].parent, get_sibling(id, t), get_degree(id, t), depth[id], height[id], get_type(id, t).c_str());
	cout << endl;
}

int main()
{
	int n;
	cin >> n;
	vector<Node> t(n);
	int root = 0;
	for (int i = 0; i < n; i++) {
		t[i].parent = -1;
		t[i].child_left = -1;
		t[i].child_right = -1;
	}

	for (int i = 0; i < n; i++) {
		int id, left, right;
		cin >> id >> left >> right;
		t[id].child_left = left;
		t[id].child_right = right;
		if (left != -1) t[left].parent = id;
		if (right != -1) t[right].parent = id;
	}

	for (int i = 0; i < n; i++) {
		if (t[i].parent == -1) root = i;
	}

	vector<int> height(n);
	set_height(root, t, height);

	vector<int> depth(n);
	set_depth(root, 0, t, depth);
	for (int i = 0; i < n; i++) print(i, t, depth, height);
}


Measured memory_bytes: 3288
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pt;
const int N=1e6+5;
const int M=2e3+5;
const int INF=0x7fffffff;
const int mod=1e9+7;
const int bb=18;
const double eps=1e-10;
const double pi=acos(-1);
LL n,m;
char str[N];
LL f[N];
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    r(n); r(m);
    LL cnt0=0,cnt1=0,cnt2=0;
    FOR(i,1,n){
        r(f[i]);
        if(f[i]>0) cnt1++;//+
        else if(f[i]<0) cnt2++;//-
        else cnt0++;//0
    }
    sort(f+1,f+n+1);
    if(cnt1*cnt2>=m){//-
        LL l=-1e18,r=-1;
        LL ans;
        while(l<=r){
            LL mid=(l+r)>>1;
            LL sum=0;

            FOR(j,1,cnt2){
                LL ll=cnt2+cnt0+1,rr=n;
                LL res=cnt2+cnt0;
                while(ll<=rr){//最大的乘积大于mid的pos
                    LL midd=(ll+rr)>>1;
                    if(f[j]*f[midd]>mid){
                        res=midd;
                        ll=midd+1;
                    }
                    else rr=midd-1;
                }
                //cout<<res<<endl;
                sum+=res-(cnt2+cnt0);
            }
            //cout<<mid<<' '<<sum<<endl;
            if(sum<=cnt1*cnt2-m){
                ans=mid;
                r=mid-1;
            }
            else l=mid+1;

        }
        cout<<ans<<endl;
        return 0;
    }
    m-=cnt1*cnt2;
    if(m<=cnt0*(cnt1+cnt2)+cnt0*(cnt0-1)/2){
        cout<<0<<endl;
        return 0;
    }
    m-=cnt0*(cnt1+cnt2)+cnt0*(cnt0-1)/2;
    LL l=1,r=1e18;
    LL ans;
    //cout<<m<<endl;
    while(l<=r){
        LL mid=(l+r)>>1;
        LL sum=0;
        FOR(j,1,cnt2){
            LL ll=j+1,rr=cnt2;
            LL res=j;
            while(ll<=rr){//最大的乘积大于mid的pos
                int midd=(ll+rr)>>1;
                if(f[j]*f[midd]>mid){
                    res=midd;
                    ll=midd+1;
                }
                else rr=midd-1;
            }
            sum+=res-j;
        }
        FOR(j,cnt0+cnt2+1,n){
            LL ll=j+1,rr=n;
            LL res=n+1;
            while(ll<=rr){
                LL midd=(ll+rr)>>1;
                if(f[j]*f[midd]>mid){
                    res=midd;
                    rr=midd-1;
                }
                else ll=midd+1;
            }
            sum+=n-ll+1;
        }
        if(sum<=cnt1*(cnt1-1)/2+cnt2*(cnt2-1)/2-m){
            ans=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1920
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<stack>

using namespace std;

int main()
{
	int n, m, k;
	vector<string> arr;
	vector<vector<int>> sol;
	vector<int> base;
	bool occ[301] = { 0, };
	int lastelem[301], lastocc = 0;

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

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

	for (int i = 0; i < m; i++)
	{
		base.push_back(0);
	}

	for (int i = 0; i < n; i++)
	{
		char input[301];

		scanf("%s", input);

		string str;

		str = input;

		arr.push_back(str);
		sol.push_back(base);

		for (int j = 0; j < m; j++)
		{
			if (str[j] == '#')
			{
				occ[i] = true;

				lastelem[i] = j;

				lastocc = i;
			}
		}
	}

	int lastrow = -1;
	int cnt = 1;

	for (int i = 0; i < n; i++)
	{
		int lastcol = -1;

		if (occ[i])
		{
			for (int j = 0; j < m; j++)
			{
				if (arr[i][j] == '#')
				{
					int ub;

					if (i == lastocc)
					{
						ub = n - 1;
					}

					else
					{
						ub = i;
					}

					for (int k = lastrow + 1; k <= ub; k++)
					{
						if (j == lastelem[i])
						{
							for (int l = lastcol + 1; l < m; l++)
							{
								sol[k][l] = cnt;
							}
						}

						else
						{
							for (int l = lastcol + 1; l <= j; l++)
							{
								sol[k][l] = cnt;
							}
						}
					}

					lastcol = j;

					cnt++;
				}
			}

			lastrow = i;
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			printf("%d ", sol[i][j]);
		}

		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <numeric>
#include <utility>
#include <cmath>
#include <algorithm>
#include <queue>

using ll = long long;

template <class T>
using vec = std::vector<T>;

template <class T>
constexpr T nil = static_cast<T>(-1);

template <class T>
constexpr T inf = std::numeric_limits<T>::max() / 2;


struct Edge
{
    int from, to;
    ll d;
};

std::pair<bool,vec<ll>> BellmanFord(const vec<vec<Edge>>& edges, int begin)
{
    using namespace std;

    const int n = edges.size();

    vec<ll> dist(n, inf<ll>);
    dist[begin] = 0;

    auto pass = [&edges, &dist]()
    {
        for (const auto& edge : edges)
            for (const auto& e : edge)
            {
                if (dist[e.from] == inf<ll>) continue;
                dist[e.to] = min(dist[e.to], dist[e.from] + e.d);
            }
    };

    for (int i = 0; i < n - 1; ++i)
        pass();

    auto checkDist = dist;
    pass();

    bool positive = equal(checkDist.cbegin(), checkDist.cend(), dist.cbegin());

    return make_pair<bool, vec<ll>>(move(positive), move(dist));
}


void solve()
{
    using namespace std;

    int n, m, r;
    cin >> n >> m >> r;

    vec<vec<Edge>> edges(n);

    for (int i = 0, from, to, d; i < m; ++i)
    {
        cin >> from >> to >> d;
        edges[from].push_back({from, to, d});
    }

    auto dist = BellmanFord(edges, r);

    if (dist.first)
        for (auto d : dist.second)
        {
            if (d == inf<ll>)
                cout << "INF" << endl;
            else
                cout << d << endl;
        }
    else
        cout << "NEGATIVE CYCLE" << endl;
}

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


Measured memory_bytes: 3236
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		char[] N =nextString().toCharArray();
		String ans ="No";
		if(N[0]==N[1]&&N[1]==N[2]||N[1]==N[2]&&N[2]==N[3])
			ans="Yes";

		System.out.println(ans);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

int main() {
	int x;
	int y;
	int z;
	
	cin >> x;
	cin >> y;
	cin >> z;
	
	if(x<y && y<z) {
		cout << "Yes" << endl;
	}
	else if(x>y || x>z || y>z ){
		cout << "No" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(t) (t).begin(),(t).end()
typedef long long ll;

int main() {
	ll Ans=0;
	ll A; cin >> A;
	ll B; cin >> B;
	ll C; cin >> C;
	ll D; cin >> D;

	std::vector<ll> v{A*C,A*D,B*C,B*D};
	Ans=*max_element(ALL(v));
	cout << Ans << '\n';
	return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
	long long n;
	int s =0,x;
	scanf("%lld",&n);
	long long m;
	m = n;
	while(n!=0){
		x = n%10;
		n/=10;
		s+=x;
	}
	//printf("%d",s);
	if(m%s){
		printf("No\n");
	}
	else printf("Yes\n");
	return 0;

}

Measured memory_bytes: 256
import heapq

n = int(input())
a = list(map(int, input().split()))
dp = [0] * (pow(10, 6) + 5)
heapq.heapify(a)
heapq.heappush(a, 1000003)
ans = -1
y = 0
for _ in range(n + 1):
    x = heapq.heappop(a)
    if x == y and dp[x] == 2:
        dp[x] = 1
        ans -= 1
        continue
    elif dp[x] == 0:
        ans += 1
        dp[x] = 2
        i = 2
        while i * x <= 1000000:
            dp[i * x] = 1
            i += 1
    y = x
print(ans)

Measured memory_bytes: 113956
n = int(input())

def zorome(n):
	l = []
	while n > 0:
		l.append(n%10)
		n = n//10
	return l

for i in range(n, 1000):
	ll = zorome(n)
	if ll[0] == ll[1] and ll[1] == ll[2]:
		break
	n += 1
print(n)

Measured memory_bytes: 3064
#include <iostream>

int main() {
  uint32_t N = 0;
  std::cin >> N;

  uint32_t ans = 0;
  for (size_t i = 0; i < N; i++) {
    uint32_t a = 0;
    std::cin >> a;

    if (a != 2 && a % 2 == 0) continue;

    ans++;
    for (size_t p = 3; p * p <= a; p += 2) {
      if (a % p == 0) {
        ans--;
        break;
      }
    }
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 3116
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto tmp = readln.split.to!(int[]);
    auto H = tmp[0], W = tmp[1];
    alias Coord = Tuple!(int, int);
    alias Record = Tuple!(Coord, Coord);
    Record[] rec;
    int inc;
    Coord before;
    foreach (y; 0..H) {
        auto as = readln.split.to!(int[]);
        auto proc = (int x) {
            if (inc > 0) {
                as[x] += inc;
                rec ~= Record(before, Coord(y+1,x+1));
                inc = 0;
            }
            if (as[x] > 0 && as[x] % 2 == 1) {
                as[x]--;
                inc = 1;
                before = Coord(y+1,x+1);
            }
        };
        if (y % 2 == 0) {
            foreach(x; 0..W) proc(x);
        } else {
            foreach_reverse(x; 0..W) proc(x);
        }
    }
    writeln(rec.length);
    foreach (r; rec) {
        writefln("%d %d %d %d", r[0].expand, r[1].expand);
    }
}



Measured memory_bytes: 6908
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
#define sz(a) ((ll)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define eps 1e-9
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define y1 y32432
#define y0 y435346

#define maxn 500005

string s;
int n, a[maxn];

bool cal(int x){
	int run = x * 10 + a[n - 1];
	for(int i = n - 2; i >= 0; i--){
		int d = x % 10;
		int u = (a[i] - d);
		if(u < 0) u += 10;
		int A = (run / 10) * 10 + u;
		if(A > run) A -= 10;
		if(A < 0) return false;
		x = (A + x) / 10;
		run = A;
	}
	return true;
}

int main()
{
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);

	cin >> s;
	n = sz(s);
	Rep(i, n) a[i] = s[i] - '0';
	int l = 0, r = 100000000, mid;
	while(l < r){
		mid = (l + r) / 2;
		if(cal(mid)){
			r = mid;
		} else l = mid + 1;
	}

	int A = l * 10 + a[n - 1];
	int res = (A + 8) / 9;
	if(res == 0) res++;
	cout << res << endl;

    return 0;
}


Measured memory_bytes: 2820
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
#define all(v) v.begin(),v.end()

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main(){
    string s,t;
    cin >> s >> t;
    sort(all(s));
    sort(all(t));
    reverse(all(t));
    if(s<t) cout << "Yes" <<endl;
    else cout << "No" <<endl;
    return 0;
}


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

const int N = 604, MOD = 1e9 + 7;

namespace {
  int Mul(int x, int y) { return 1LL * x * y % MOD; }
  int Dec(int x, int y) { return (x -= y) < 0 ? x + MOD : x; }
  int Add(int x, int y) { return (x += y) >= MOD ? x - MOD : x; }
  int Kissme(int x, int y) {
    int c = 1;
    while(y) {
      if(y & 1) c = Mul(c, x);
      x = Mul(x, x);
      y >>= 1;
    }
    return c;
  }
}

struct Segment {
  int u, v;

  bool Intersect(const Segment &rhs) const {
    return ((rhs.u > u) & (rhs.u < v)) ^ ((rhs.v > u) & (rhs.v < v));
  }
}seg[N];

int fa[N], n, K, mi[N], mx[N], G[N], f[N][N], vis[N], Ans, IG[N];

int Find(int x) {
  return fa[x] == x ? x : fa[x] = Find(fa[x]);
}

void Merge(int x, int y) {
  int fx = Find(x), fy = Find(y);
  if(fx != fy) {
    fa[fx] = fy;
    mx[fy] = max(mx[fy], mx[fx]);
    mi[fy] = min(mi[fy], mi[fx]);
  }
}

int main(void) {
  scanf("%d%d", &n, &K);
  for(int i = 1; i <= 2 * n; i++)
    fa[i] = mx[i] = mi[i] = i;
  for(int i = 1; i <= K; i++) {
    scanf("%d%d", &seg[i].u, &seg[i].v);
    vis[seg[i].u] = vis[seg[i].v] = 1;
    
    if(seg[i].u > seg[i].v)
      swap(seg[i].u, seg[i].v);
    Merge(seg[i].u, seg[i].v);
    for(int j = 1; j < i; j++)
      if(seg[i].Intersect(seg[j]))
	Merge(seg[i].u, seg[j].u);
  }

  G[0] = 1;
  IG[0] = 1;
  for(int i = 2; i <= 2 * n; i += 2) {
    G[i] = Mul(G[i - 2], i - 1);
    IG[i] = Kissme(G[i], MOD - 2);
  }
  
  for(int l = 0; l < 2 * n; l++)
    for(int i = 1, j = 1 + l; j <= 2 * n; i++, j++) {
      if(mx[Find(i)] > j || mi[Find(i)] < i ||
	 mx[Find(j)] > j || mi[Find(j)] < i) continue;
      bool flg = 0;
      for(int k = 1; k <= K; k++)
	if(seg[k].Intersect({i, j}))
	  flg = 1;
      if(flg) continue;
      
      int X = 0, Y = 0;
      for(int k = 1; k < i; k++)
	X += !vis[k];
      for(int k = j + 1; k <= 2 * n; k++)
	X += !vis[k];
      for(int k = i; k <= j; k++)
	Y += !vis[k];

      f[i][j] = Mul(G[X], G[Y]);
      //      printf("f[%d][%d] = %d\n", i, j, f[i][j]);
      
      for(int k = j - 1, Z = !vis[j]; k > i; Z += !vis[k--])
	if(f[i][k]) {
	  assert(~(X + Z) & 1);
	  f[i][j] = Dec(f[i][j], Mul(f[i][k], Mul(IG[X + Z], Mul(G[Z], G[X]))));
	}

      //      printf("f[%d][%d] = %d\n", i, j, f[i][j]);
      Ans = Add(Ans, f[i][j]);
    }
  cout << Ans << endl;
  return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
#include <limits.h>


int S[500000];
int R[250001];
int L[250001];

int count;


void merge(int A[], int left, int mid,int right){
  int i,j,k;
  int n1,n2;
  
  n1 = mid - left;
  n2 = right - mid;
  
  /*L[0...n1], R[0...n2] �𐶐�*/
    
  for( i = 0 ;i<= n1-1;i++){
    L[i] = A[left + i];
  }
  for (i = 0 ;i<= n2-1;i++){
    R[i] = A[mid + i];
  }
  
  L[n1] = INT_MAX;
  R[n2] = INT_MAX;
  
  i = 0;
  j = 0;
  for( k = left;k<= right-1;k++){
    ++count;
    if( L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else {
      A[k] = R[j];
      j = j + 1;
    }
  }
}

void mergeSort(int A[],int left,int right){
  int mid;
  
  if (left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);

  }
}


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

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  mergeSort(S,0,n);

  for(j=0;j<n;j++){

    if(j!=n-1){
      printf("%d ",S[j]);

    }

    else{
      printf("%d\n",S[j]);
    }
  }

  printf("%d\n",count);

  return 0;
}



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

int main() {
    int n,m;cin>>n>>m;
    int tmp,sum=0,ans;
    for(int i=0;i<m;++i){
        cin>>tmp;
        sum+=tmp;
    }
    if(n-sum>=0)ans=n-sum;
    else ans=-1;
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
s = int(input())

a = 0
b = 0
c = 0
d = 0

for i in range(s):
  ans = input()
  if ans == "AC":
    a += 1
  elif ans == "WA":
    b += 1
  elif ans == "TLE":
    c += 1
  elif ans == "RE":
    d += 1

print("AC x",a)
print("WA x",b)
print("TLE x",c)
print("RE x",d)

Measured memory_bytes: 9196
#![allow(unused_mut, non_snake_case,unused_imports)]
use std::iter;
use std::cmp::{max, min, Ordering};
use std::mem::{swap};
use std::collections::{HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap,VecDeque};
use std::iter::FromIterator;

//　高速 EOF要
//macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};}
//macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};}
//macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};}
// 低速 EOF不要
macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

/*
 <url:https://beta.atcoder.jp/contests/agc027/tasks/agc027_a>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
fn main(){
    input!(N:usize,x:i64,A:[i64;N]);
    let mut A:Vec<i64> = A;
    A.sort();
    let mut x:i64 = x;
    let mut ans = 0;
    for i in 0..N{
        if A[i] <= x{
            if i == N-1 && A[i] != x{
                continue;
            }
            ans += 1;
            x -= A[i];
        }else {
            break;
        }
    }
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <unordered_map>
using namespace std;

class Solver
{
public:
	long n;
	long m;


	Solver() {
		cin >> n;
		cin >> m;
	}

	void exec() {
		if(n == m ) {
			cout << "Yes" << endl;
		} else {
			cout << "No"  << endl;
		}
	}
};
int main(){
	Solver co = Solver();
	co.exec(); 
}


Measured memory_bytes: 256
# coding : UTF-8

from sys import stdin

N = stdin.readline().rstrip()

def main():
    if int(N) <= int(N[0]*len(N)):
        print(N[0]*len(N))
    else:
        print((str(int(N[0])+1))*len(N))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <tuple>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<tuple<int, int, char, long long, string> >vec(n);
	for (int i = 0; i < n; i++) {
		int a, b;
		char c;
		long long d;
		string e;
		cin >> a >> b >> c >> d >> e;
		vec[i] = forward_as_tuple(a,b,c,d,e);
	}
	sort(begin(vec), end(vec));
	for (int i = 0; i < n; i++) {
		int a, b;
		char c;
		long long d;
		string e;
		tie(a, b, c, d, e) = vec[i];
		cout << a << " " << b << " " << c << " " << d << " " << e << endl;
	}
}


Measured memory_bytes: 12184
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
 
int main(){
	fast;
	int a, b, ans=-1;
	cin>>a>>b;
	b*=10;
	int n=b+10;
	for(int i=b; i<n; i++){
	    int f=floor(0.08*i);
	    if(f==a){ ans=i; break;}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    cout << ((stoi(a + b + c) % 4 == 0) ? "YES\n" : "NO\n");

    return 0;
}


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

bool input( int a[], int b[], int n ) {
	for( int i = 0; i < n; ++i ) {
		if( !(cin >> a[i]) ) { return false; }
	}

	for( int i = 0; i < n; ++i ) {
		if( !(cin >> b[i]) ) { return false; }
	}

	return true;
}

int main() {
	ios_base::sync_with_stdio( false );

	constexpr int N = 4;
	int a[N];
	int b[N];

	while( input( a, b, N ) ) {
		int hit = 0;
		int blow = 0;

		for( int i = 0; i < N; ++i ) {
			for( int j = 0; j < N; ++j ) {
				if( b[i] == a[j] ) {
					if( i == j ) {
						hit += 1;
					}
					else {
						blow += 1;
					}
				}
			}
		}

		cout << hit << ' ' << blow << '\n';
	}
}



Measured memory_bytes: 3108
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		if(A + B == A + C) {
			System.out.println(A);
		} else {
			if(B + A == B + C) {
				System.out.println(B);
			} else {
				System.out.println(C);
			}
		}
		
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, d;
  cin >> n >> d;
  
  vector<vector<int>> x(n, vector<int>(d));
  for(int i=0; i<n; i++){
    for(int j=0; j<d; j++){
      cin >> x[i][j];
    }
  }
 
  int num=0; 
  
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      int dissqr = 0;
      for(int k=0; k<d; k++){
    dissqr += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }
      for(int l=1; l<130; l++){
        if(l*l == dissqr){
          num++;
        }
      }
    }
  }
  
  cout << num << endl;
  
}

Measured memory_bytes: 3544
typedef long long ll; using namespace std;
int m = 1e9+7;
#include <iostream>

int main(){
  int n; cin >> n;
  string s; cin >> s;
  if (s[0] == 'W' || s[2*n-1] == 'W') return 0*puts("0");
  ll a[2] = {1,0}, al[2] = {1,0}, ls=0; bool ok = true; ll an=1;
  for(int i=1; i<2*n && ok; i++) {
    //cout << (s[i] != s[i-1]) << endl;
    if (s[i] != s[i-1]) {
      a[ls]++; al[ls]++;
      if (ls == 1) {
        if (a[0] == 0) ok=0;
        else {an = an * a[0] % m; a[0]--;}
      }
    } else {
      ls^=1;
      a[ls]++; al[ls]++;
      if (ls == 1) {
        if (a[0] == 0) ok=0;
        else {an = an * a[0] % m; a[0]--;}
      }
    }
  }
  //cout << al[0] << " " << al[1] << endl;
  if (al[0]!=al[1]) return 0*puts("0");
  for(int i=1; i<=n; i++) {
    an = an * i % m;
  }
  cout << an << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <vector>
#include<iostream>
#include<queue>
using namespace std;

int main() {


	int n , a , b;

	scanf ("%d%d%d" , &n , &a , &b);

	if ( abs ( n - a) < abs( n - b) )
		puts ("A");
	else
		puts("B");

  return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
s = [input() for i in range(h)]
cost = [[2500] * w for i in range(h)]
cost[0][0] = 1
wall = 0
for i in range(h):
  for j in range(w):
    if s[i][j] == '#':
      wall += 1
for k in range(h*w):
  for i in range(h):
    for j in range(w):
      if s[i][j] != '#':
        u = cost[i-1][j] + 1 if i > 0 and s[i-1][j] != '#' else 2500
        d = cost[i+1][j] + 1 if i < h-1 and s[i+1][j] != '#' else 2500
        l = cost[i][j-1] + 1 if j > 0 and s[i][j-1] != '#' else 2500
        r = cost[i][j+1] + 1 if j < w-1 and s[i][j+1] != '#' else 2500
        cost[i][j] = min(cost[i][j], u, d, l, r)

if cost[h-1][w-1] == 2500:
  print(-1)
else:
  print(h*w - cost[h-1][w-1] - wall)

Measured memory_bytes: 66008
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
const int MAXL = 1000000001;
typedef pair<int, int> SEG;
typedef pair<SEG, int> S;
//int data[MAXL];
int main(){
  int N;
  while(cin>>N && N){
    //memset(data, -1, sizeof(data));
    vector<S> data;
    data.push_back(S(SEG(-1, 0), -1));
    REP(time, N){
      string cmd; cin>>cmd;
      if(cmd == "W"){
        int l, s; cin>>l>>s;
        vector<S> add;
        REP(i, data.size()-1){
          if(s == 0) break;
          if(data[i].first.second < data[i+1].first.first){
            int fst = data[i].first.second;
            int len = min(s, data[i+1].first.first - fst);
            add.push_back(S(SEG(fst, fst + len), l));
            s -= len;
          }
        }
        if(s > 0){
          int fst = data.back().first.second;
          int len = s;
          add.push_back(S(SEG(fst, fst + len), l));
        }
        REP(i, add.size()) data.push_back(add[i]);
        sort(data.begin(), data.end());
        /*
        REP(i, MAXL){
          if(S == 0) break;
          if(data[i] == -1){
            data[i] = l;
            S --;
          }
        }
        */
      }else if(cmd == "D"){
        int l; cin>>l;
        //REP(i, MAXL)if(data[i] == l)data[i] = -1;
        vector<S>::iterator it = data.begin();
        while(it != data.end()){
          if(it->second == l){
            it = data.erase(it);
          }else{
            it++;
          }
        }
      }else if(cmd == "R"){
        int P; cin>>P;
        int res = -1;
        REP(i, data.size())if(data[i].first.first <= P && P < data[i].first.second){
          res = data[i].second;
          break;
        }
        cout<< res << endl;
        //cout<<data[P]<<endl;
      }else{
        assert(false);
      }
      //REP(i, data.size())printf("%d:(%d, %d) ", data[i].second, data[i].first.first, data[i].first.second); cout<<endl;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1012
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9;
int n,a[200010],id[200010],b[200010],fa[200010],p[200010];
bool used[200010];
bool cmp(int x,int y)
{
	if (a[x]==a[y])
	{
		return x<y;
	}
	else
	{
		return a[x]>a[y];
	}
}
int find(int x)
{
	if (x!=fa[x])
	{
		fa[x]=find(fa[x]);
	}
	return fa[x];
}
bool check(int v)
{
	//cerr<<v<<endl;
	if (v==1)
	{
		for (int i=2;i<=n;i++)
		{
			if (a[i]<=a[i-1])
			{
				return false;
			}
		}
		return true;
	}
	p[0]=1;
	for (int i=1;i<=n;i++)
	{
		fa[i]=i;
		used[i]=false;
		b[i]=0;
		if (1LL*p[i-1]*v>inf)
		{
			p[i]=inf;
		}
		else
		{
			p[i]=p[i-1]*v;
		}
	}
	for (int i=1;i<=n;i++)
	{
		int x=id[i];
		used[x]=true;
		if (!used[x-1] && !used[x+1])
		{
			continue;
		}
		if (used[x-1])
		{
			int y=find(x-1);
			if (a[x]==a[y])
			{
				b[x]=b[y]+1;
			}
			else
			{
				int tmp;
				if (a[y]-a[x]>30 || p[a[y]-a[x]]>=inf)
				{
					tmp=0;
				}
				else
				{
					tmp=b[y]/p[a[y]-a[x]];
				}
				b[x]=tmp+1;
			}
			fa[y]=x;
		}
		if (used[x+1])
		{
			int y=find(x+1);
			int tmp;
			if (a[y]-a[x]>30 || p[a[y]-a[x]]>=inf)
			{
				tmp=0;
			}
			else
			{
				tmp=b[y]/p[a[y]-a[x]];
			}
			b[x]+=tmp;
			fa[y]=x;
		}
		//cerr<<x<<" "<<b[x]<<endl;
	}
	int tmp;
	if (a[id[n]]-1>30 || p[a[id[n]]-1]>=inf)
	{
		tmp=0;
	}
	else
	{
		tmp=b[id[n]]/p[a[id[n]]-1];
	}
	return tmp<v;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		id[i]=i;
	}
	sort(id+1,id+n+1,cmp);
	int l=1,r=n,mid;
	while (l<=r)
	{
		mid=(l+r)>>1;
		if (check(mid))
		{
			r=mid-1;
		}
		else
		{
			l=mid+1;
		}
	}
	cout<<l<<endl;
	return 0;
}


Measured memory_bytes: 5504
//Har Har Mahadev
using namespace std;
#include <bits/stdc++.h>
#define booga cout << "booga" << endl
#define ll long long int
#define pb push_back
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " -> " << a << endl;
	err(++it, args...);
}
ll lcm(ll a, ll b){
	return a*b / __gcd(a,b);
}
int solve(ll x){
	int ans = 0;
	while(x % 2 == 0){
		ans++;
		x /= 2;
	}
	return ans;
}
void testcase(){
	unordered_set<int> s;
	ll n,m,a[100005],l = 1;
	cin >> n >> m;
	for(int i{0};i < n;i++){
		cin >> a[i];
		a[i] /= 2;
		l = lcm(l,a[i]);
		s.insert(solve(a[i]));
	}
	if(s.size() > 1){
		cout << 0;
	}
	else{
		cout << (1 + m/l) / 2;
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	while(t--){
		testcase();
	}
	return 0;
}


Measured memory_bytes: 4380
#include <cmath>
#include <iostream>
#include <string>
using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  int ans = -1;
  for (int i = 1; i <= 1000; ++i) {
    if (floor(i * 0.08) == A && floor(i * 0.1) == B)
      ans = i;
    if (ans != -1)
      break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

vector<vector<int>> ansvec;
int a[501][501], y[100001],ballNum[100001];
bool can[100001];
signed main() {
	int H,W;
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> a[i][j];
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (a[i][j] % 2 == 1) {
				if (j < W-1) {
					a[i][j]--;
					a[i][j + 1]++;
					ansvec.push_back({ i + 1,j+1 ,i+1,j + 2 });
				}
				else {
					a[i][j]--;
					a[i + 1][j]++;
					if(!(j == W-1 && i == H-1))ansvec.push_back({ i+1,j+1,i + 2,j+1 });
				}
			}
		}
	}

	std::cout << (int)ansvec.size() << "\n";
	for (vector<int> v : ansvec) {
		for (int i = 0; i < v.size(); i++) {
			if (i == v.size() - 1) {
				std::cout << v[i] << "\n";
			}
			else {
				std::cout << v[i] << " ";
			}
		}
	}
	return 0;
}

Measured memory_bytes: 13744
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int x,i;
    i=1;
    while (1) {
        scanf("%d",&x);
        if (x == 0) break;
        printf("Case %d: %d\n",i,x);
        i=i+1;
    }
    
    return 0;
}

Measured memory_bytes: 2560
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static final int INF=9999999;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		
		
		List<Integer> money = new ArrayList<>();
		money.add(1);
		{
			int x=6;
			while(x<=100000){
				money.add(x);
				x*=6;
			}
			x=9;
			while(x<=100000){
				money.add(x);
				x*=9;
			}
			Collections.sort(money);
		}

		int[] a=new int[100001];
		Arrays.fill(a, INF);
		
		int step=0;
		List<Integer> stepList = new ArrayList<>();
		List<Integer> nextStepList = new ArrayList<>();
		stepList.add(0);
		
		while(a[N]==INF){
			for(int x:stepList){
				for(int m:money){
					if(x+m>N) break;
					if(a[x+m]>step+1){
						a[x+m]=step+1;
						nextStepList.add(x+m);
					}
				}
			}
			step++;
			stepList=new ArrayList<>(nextStepList);
			nextStepList.clear();
		}
		
		System.out.println(a[N]);
		
	}
}


Measured memory_bytes: 27568
#include<stdio.h>

int main(){
  int x,y,n;
  int tmp;
  scanf("%d %d",&x,&y);
  if(x<y){
    tmp = x;
    x = y;
    y = tmp;
  }
    n=x%y;
 while(n!=0){
   x=y;
   y=n;
   n=x%y;
  }
  printf("%d\n",y);
  return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007ll
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define db(x) cout << #x << " = " << x << '\n'
#define sep cout << "********************************************\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL)
int main(int argc, char const *argv[])
{
	fast;
	ll n, ans = 0;
	set<ll> st;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		ll num;
		cin >> num;
		if (st.empty() || *st.begin() > num)
			ans ++;
		st.insert(num);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 9600