akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using ll = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (ll)1e9 //10^9:∞
#define LLINF (ll)1e12
#define MOD (ll)(1e9+7) //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)
#define endl "\n"

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__


	ll a, b, x;
	cin >> a >> b >> x;

	if (a != 0)cout << b / x - (a - 1) / x << endl;
	else cout << b / x  + 1 << endl;



	return 0;
}


Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
#include <tuple>
#include <utility>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long int64;
typedef pair<int, int> pii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  double total = 1;
  for (auto &i : a) total *= i;
  double sum = 0;
  for (auto &i : a) sum += (total / i);
  cout << total / sum << '\n';
  return 0;
}



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

using namespace std;


int main(){
  int h, n;
  cin >> h >> n;
  
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  
  int sum = accumulate(a.begin(),a.end(), 0);
 
  if(sum>=h) cout << "Yes" << endl;
  else  cout << "No" << endl;
  
  return 0;
}

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

int main(){

    int N, K;
    cin >> N;
    cin >> K;

    int ans = 1;
    for(int i = 0; i < N; i++){
        if(ans * 2 < ans + K) ans *= 2;
        else ans += K;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

void YES() {cout << "YES" << endl; exit(0);}
void NO() {cout << "NO" << endl; exit(0);}
void Yes() {cout << "Yes" << endl; exit(0);}
void No() {cout << "No" << endl; exit(0);}


int main() {
  int n, m, c;
  cin >> n >> m >> c;
  vl b(m);
  rep (i, m) {
    cin >> b[i];
  }

  int ans = 0;
  rep (aaa, n) {
    vi a(m);
    rep (i, m) {
      cin >> a[i];
    }
    ll sum = 0;
    rep (i, m) {
      sum += a[i] * b[i];
    }
    sum += c;
    if (sum > 0) ans++;
  }
  cout << ans << endl;
}


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

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

  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> ws(n);
  vector<int> es(n);
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'W')
      ++ws[i];
    else
      ++es[i];
  }
  for (int i = 1; i < n; ++i) {
    ws[i] += ws[i - 1];
  }
  for (int i = n - 1; 0 < i; --i) {
    es[i - 1] += es[i];
  }

  int ans = n;
  for (int i = 0; i < n; ++i) {
    ans = min(ans, ws[i] + es[i]);
  }
  cout << (ans - 1) << "\n";
}


Measured memory_bytes: 2964
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main {

	Scanner sc = new Scanner(in); 
	
	void run() {
		int[] t = new int[30];
		int[] time = new int[101];
		int[] c = new int[101];
		int[][] cost = new int[101][101];
		int[] dis = new int[101];
		boolean[] used = new boolean[101];
		int INF = Integer.MAX_VALUE/2;
		while (true) {
			int T = sc.nextInt();
			if (T == 0) break;
			for (int i = 0; i < T; i++)
				t[i] = sc.nextInt();
			int N = sc.nextInt();
			Arrays.fill(time, INF);
			int max = -1;
			for (int i = 0; i < N; i++) {
				int d = sc.nextInt(), m = sc.nextInt();
				time[d] = min(time[d],m);
				max = max(max, d);
			}
			
			I:for (int i = 1; i <= max; i++) {
				for (int j = i; j < i+T && j <= max; j++) {
					if (time[j] < t[j-i]) {
						c[i] = j-1;
						continue I;
					}
				}
				c[i] = (max <= i+T-1) ? max : i+T-1;
			}
			
			
			for (int i = 0; i < 101; i++)
				Arrays.fill(cost[i], INF);
			
			for (int i = 1; i < max; i++) {
				for (int j = i+1; j <= c[i]; j++) {
					cost[i][j] = 1;
				}
				if (c[i] != max) {
					if (c[i]-i == T-1) {
						cost[i][c[i]+1] = 0;
					} else {
						cost[i][c[i]+1] = 1;
					}
				}
			}
			
			Arrays.fill(dis, INF);
			Arrays.fill(used, false);
			dis[1] = 0;
			while (true) {
				int v = -1;
				for (int i = 1; i <= max; i++) {
					if (!used[i] && (v == -1 || dis[i] < dis[v])) v = i;
				}
				if (v == -1) break;
				used[v] = true;
				for (int i = 1; i <= max; i++) {
					dis[i] = min(dis[i], dis[v]+cost[v][i]);
				}
			}
			int res = INF;
			for (int i = 1; i <= max; i++) {
				if (c[i] == max)
					res = min(res, dis[i]);
			}
			out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 28928
from fractions import gcd
a,b,c,d = map(int, input().split())

def div(A,B,X):
    return B//X - (A-1)//X

N = b - a + 1
LCM = int(c * d / gcd(c, d))
print(N - div(a,b,c) - div(a,b,d) + div(a,b,LCM))


Measured memory_bytes: 5048
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define tms(x) ___ = x; while(___--)
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; rep(i, 0, l) cout<<' '<<i<<':'<<*(x+i)<<endl;
#define pb push_back
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int ___;
int w[10000];
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
inline int max(int cnt, ...);
inline int min(int cnt, ...);
signed main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, sum = 0, cnt = 0;
	cin>>n>>m;
	rep(i, 0, n) cin>>w[i], sum += w[i];
	double ps = sum/4.0/m;
	rep(i, 0, n)
		if (w[i] >= ps) cnt++;
	if (cnt >= m) puts("Yes");
	else puts("No");
	return ~~(0-0);
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}
inline int max(int cnt, ...)
{
	int mx = -1e18;
	va_list l;
	va_start(l, cnt);
	tms(cnt) mx = max(mx, va_arg(l, int));
	va_end(l);
	return mx;
}
inline int min(int cnt, ...)
{
	int mn = 1e18;
	va_list l;
	va_start(l, cnt);
	tms(cnt) mn = min(mn, va_arg(l, int));
	va_end(l);
	return mn;
}


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

void print(vector<int> a) {
    for (int x : a) printf("%d\n", x);
}

vector<int> fastsolve(vector<int> a, vector<int> x, vector<int> y) {
    int n = a.size();
    int m = x.size();
    vector<int> ans(m, -1);

    vector<int> cnt(n);
    vector<int> b(n);
    int notCovered = n;
    auto add = [&](int x, int y) {
        if (y == +1) {
            if (x - cnt[x] >= 0) {
                if (b[x - cnt[x]] == 0) {
                    notCovered--;
                }
                b[x - cnt[x]]++;
            }
            cnt[x]++;
        } else {
            if (x - cnt[x] >= -1) {
                if (b[x - cnt[x] + 1] == 1) {
                    notCovered++;
                }
                b[x - cnt[x] + 1]--;
            }
            cnt[x]--;
        }
    };
    for (int i = 0; i < n; i++) add(a[i], 1);

    for (int i = 0; i < m; i++) {
        add(a[x[i]], -1);
        a[x[i]] = y[i];
        add(a[x[i]], +1);
        ans[i] = notCovered;
    }
    return ans;
}

int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif

    int n, m;
    bool first = 1;
    while (scanf("%d%d", &n, &m) == 2) {
        if (first) first = 0;
        else printf("\n");

        vector<int> a(n);
        for (int i = 0; i < n; i++) {
            scanf("%d", &a[i]);
            a[i]--;
        }
        vector<int> x(m), y(m);
        for (int i = 0; i < m; i++) {
            scanf("%d%d", &x[i], &y[i]);
            x[i]--; y[i]--;
        }

        print(fastsolve(a, x, y));
    }

#ifdef HOME
    cerr << clock() / (double)CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int main(){
  long a,b,x;
  cin>>a>>b>>x;
  
  long ans=0;
  if(a%x==0){ans=(b/x)-(a/x)+1;} // 答えはb/x+a/xでも出せるが、
  else{ans=(b/x)-(a/x);} // a%x==0の場合はaもxで割り切れるから、 
                         // その分を＋1した式で計算する。
  cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
bool v[N], c[N], isbit = 1;
vector<int> G[N];
int dfs(int x, int c = 0) {
	if (v[x]) {
		if (::c[x] != c) isbit = 0;
		return 0;
	}
	v[x] = 1;
	::c[x] = c;
	int res = 1;
	for (int u : G[x]) {
		res += dfs(u, c ^ 1);
	}
	return res;
}
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++ i) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	long long cnt1 = 0, cnt2 = 0, cnt3 = 0;
	for (int i = 1; i <= n; ++ i) {
		if (v[i]) continue;
		isbit = 1;
		int cnt = dfs(i);
		if (isbit) {
			if (cnt == 1) cnt3 ++; else cnt2 ++;
		}
		else {
			cnt1 ++;
		}
	}
	//printf("%I64d %I64d %I64d\n", cnt1, cnt2, cnt3);
	long long ans = cnt1 * cnt1 + 2 * cnt2 * cnt2 + 2 * cnt1 * cnt2 + 2 * cnt3 * n - cnt3 * cnt3;
	cout << ans << endl;
}



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


int main(){

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

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

  sort(a,a+n);
int ans=0;
for(int i =0;i<k;i++)
{ans += a[i];}

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

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

using namespace std;

int MAX_N = 100;

int main()
{
    // スペース区切りの整数の入力
    long long N,sum;
    cin >> N;

    sum = 0;

    for (int i = 1; i <= N; i++)
    {
        if (i%3!=0 && i%5!=0)
        {
            sum += i;
        }
    }
    
    cout << sum << endl;
    return 0;
}

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

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  D(x)         cout << #x << " - " << x << endl;
  #define  D2(x)        cout << "[" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]" << endl;
  #define  all(x)       (x).begin(), (x).end()
  #define  D2p(x)       cout << #x << " ~ [ "; for(auto n: x) cout << n.first << "-" << n.second << " / "; cout << "]" << endl;
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 1e6 + 4;


  void solve(){
	map<pair<int,int>,int> mp;
	ll ans=0;
	int n;
	cin >> n;
	for(int i=1;i<=n;i++){
		int f = i%10;
		int l = f;
		int k = i;
		while(k>0){
			l = k%10;
			k/=10;
		}
		mp[{l,f}]++;
		ans += 2*(mp[{f,l}])-(l==f && f==l);
	}
	cout << ans;
  }

  int main(){
    IOS
    solve();
    cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


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

int t, a, b, c, d;
long long n;
map<long long, long long> mp;

long long f(long long x) {
	if (x == 0) {
		return 0;
	}
	if (x == 1) return d;
	if (mp.count(x)) return mp[x];
	long long aa = 1ll * (x % 2) * d + a + f(x / 2);
	if (x % 2) {
		aa = min(aa, 1ll * (2 - x % 2) * d + a + f(x / 2 + 1));
	}
	long long bb = 1ll * (x % 3) * d + b + f(x / 3);
	if (x % 3) {
		bb = min(bb, 1ll * (3 - x % 3) * d + b + f(x / 3 + 1));
	}
	long long cc = 1ll * (x % 5) * d + c + f(x / 5);
	if (x % 5) {
		cc = min(cc, 1ll * (5 - x % 5) * d + c + f(x / 5 + 1));
	}
	mp[x] = min(aa, min(bb, cc));
	if (LLONG_MAX / x >= d) {
		mp[x] = min(mp[x], x * d);
	}
	return mp[x];
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> t;
	while (t--) {
		mp.clear();
		cin >> n >> a >> b >> c >> d;
		cout << f(n) << "\n";
	}
}


Measured memory_bytes: 4404
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC061A
{
    class Program
    {
        static void Main(string[] args)
        {
            int A, B, C;
            var word = Console.ReadLine().Split(' ');
            A = int.Parse(word[0]);
            B = int.Parse(word[1]);
            C = int.Parse(word[2]);
            if (A <= C && C <= B)
            {
                Console.WriteLine("Yes");
            }
            else Console.WriteLine("No");
            {
                Console.ReadKey();
            }

        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;
int n, A[MAX], s;
int B[MAX], T[VMAX+1];
int solve(){
int ans = 0;
bool V[MAX];
for(int i = 0; i < n; i++){
B[i] = A[i];
V[i] = false;
}
sort(B, B+n);
for(int i = 0; i < n; i++) T[B[i]] = i;
for(int i = 0; i < n; i++){ 
if(V[i]) continue;
int cur = i;
int S = 0;
int m = VMAX;
int an = 0;
while(1){
V[cur] = true;
an++;
int v = A[cur];
m = min(m, v);
S += v;
cur = T[v];
if(V[cur]) break;
}
ans += min(S + (an - 2) * m, m + S + (an + 1) * s);
}
return ans;
}
int main(){
cin >> n;
s = VMAX;
for(int i = 0; i < n; i++){
cin >> A[i];
s = min(s, A[i]);
}
int ans = solve();
cout << ans << endl;
return 0;
}


Measured memory_bytes: 3180
#include <stdio.h>
int main()
{
	int h, w, i, j;
	scanf("%d%d", &h, &w);
	char s[h][w];
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			scanf("%c", &s[i][j]);
			if(s[i][j]=='.')s[i][j]='0';
			if(s[i][j]=='\n')j--;
		}
	}
	for(i=0;i<h;i++)
		for(j=0;j<w;j++)
			if(s[i][j]=='#')
				for(int k=-1;k<2;k++)
					for(int l=-1;l<2;l++){
						if(i+k<0 || i+k>=h || j+l<0 || j+l>=w || s[i+k][j+l]=='#')continue;
						s[i+k][j+l]++;
					}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++)printf("%c", s[i][j]);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

const ll MOD = 1e9+7;
// a^b % MOD;
ll powmod(ll a,ll b) {ll res=1;a%=MOD; for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
// 逆元 1/a % MOD
ll inversemod(ll a) { return powmod(a,MOD - 2);}

inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

map<ll,ll> lcms;
void PrimeFact(ll n){
    map<ll,ll> mp;
    while(n!=1){
        if(n == 2 || n == 3){
            mp[n]++; n/=n;
            continue;
        }
        bool prime_flag = false;
        for(ll i = 2;i*i <= n;i++){
            if(n%i==0){
                mp[i]++; n/=i;
                prime_flag = true;
                break;
            }
        }
        if(!prime_flag){mp[n]++; n/= n;}
    }
    for(auto p:mp){
        lcms[p.first] = max(lcms[p.first],p.second);
    }
}
template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    
    ll _gcd = 0;
    for(auto a:A){
        PrimeFact(a);
    }
    ll _lcm = 1;
    for(auto p:lcms){
        for(int i = 0; i < p.second; i++){
            _lcm *= p.first;
            _lcm %= MOD;
        }
    }
    
    for(int i = 0; i < N;i++){
        res += _lcm*inversemod(A[i])%MOD;
        res %= MOD;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cassert>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

typedef long long i64;

struct BIT {

	vector<int> data;
	int size;

	void init(int n)
	{
		size = n;
		data.resize(size + 1);
		fill(data.begin(), data.end(), 0);
	}

	void add(int pos, int x)
	{
		pos += 1;
		while(pos < size + 1) {
			data[pos] += x;
			pos += pos & -pos;
		}
	}

	int sum(int pos)
	{
		pos += 1;
		int s = 0;
		while(pos > 0) {
			s += data[pos];
			pos -= pos & -pos;
		}
		return s;
	}
};

const i64 mod = 998244353;

int main()
{
	int n;
	vector<pair<int, int>> ps;
	vector<int> xs, ys;

	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		ps.push_back({x, y});
		xs.push_back(x);
		ys.push_back(y);
	}

	sort(xs.begin(), xs.end());
	sort(ys.begin(), ys.end());

	for(int i = 0; i < n; i++) {
		int ox = ps[i].first, oy = ps[i].second;
		int x = lower_bound(xs.begin(), xs.end(), ox) - xs.begin();
		int y = lower_bound(ys.begin(), ys.end(), oy) - ys.begin();
		ps[i] = {x, y};
	}

	i64 ans = 0;
	BIT bit;

	sort(ps.begin(), ps.end());
	bit.init(n);

	vector<i64> modpow2(n + 1, 0);

	modpow2[0] = 1;
	for(int i = 1; i < n + 1; i++) {
		modpow2[i] = modpow2[i - 1] * 2;
		while(modpow2[i] >= mod) {
			modpow2[i] -= mod;
		}
	}

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

		int x = ps[i].first;
		int y = ps[i].second;

		int xl = x, xr = n - 1 - x;
		int yl = y, yr = n - 1 - y;
		int xlyl = bit.sum(y);
		int xlyr = i - xlyl;
		int xryl = yl - xlyl;
		int xryr = yr - xlyr;

		assert(xlyl + xlyr == xl);
		assert(xryl + xryr == xr);

		bit.add(y, 1);

		i64 a = 0;

		a += modpow2[n] - 1;
		a -= modpow2[xl] - 1;
		a -= modpow2[xr] - 1;
		a -= modpow2[yl] - 1;
		a -= modpow2[yr] - 1;
		a += modpow2[xlyl] - 1;
		a += modpow2[xlyr] - 1;
		a += modpow2[xryl] - 1;
		a += modpow2[xryr] - 1;

		ans += a;

		while(ans < 0) {
			ans += mod;
		}
		while(ans >= mod) {
			ans -= mod;
		}

		//printf("%d (%d,%d) -> %d + %d + %d + %d, %lld\n", i, x, y, xlyl, xlyr, xryl, xryr, a);
	}

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

	return 0;
}


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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

int main() {
    lli n;
    cin1(n);
    lli a1[n];
    lli a2[n];
    ncin1(n, a1);
    ncin1(n, a2);

    lli total[n] = {0};

    REP(i, 0, n) {
        // i 列目を足す
        REP(j, 0, n) {
            // j 列目で下に落ちているやつ
            if (i < j) {
                total[j] += a1[i];
            }
            else if (i == j) {
                total[j] += a1[i] + a2[i];
            }
            else {
                total[j] += a2[i];
            }
        }
    }

    lli ans = 0;
    REP(i,0,n) {
        ans = max(ans, total[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;

void main(){
    while(true){
	auto s = readln();
	if(stdin.eof()) break;
	int n = to!int(chomp(s));
	if(n==-1)break;
	real x,y;
	real vecx,vecy;
	real angle;
	x = 1.0;
	y = 0.0;
	real r = sqrt(x * x + y * y);
	vecy =  x / r;
	vecx = 1 * y / r;
	for(int i=0;i<n-1;i++){
	    x += vecx;
	    y += vecy;
	    r = sqrt(x * x + y * y);
	    vecy =  x / r;
	    vecx = -1 * y / r;
	}
	writeln(x);
	writeln(y);
    }
}

Measured memory_bytes: 2504
import math
a,b,h,m = map(int, input().split())

rb = h*(360/12) + m*1/2
ra = m*(360/60)

ang = abs(rb - ra)
if 360-ang<=180:
      ang = 360 - ang
      ang = math.radians(ang)
else:
      ang = math.radians(ang)
#print(math.cos(ang))
ans =  a**2 + b**2 - 2*a*b*(math.cos(ang))
print(math.sqrt(ans))

Measured memory_bytes: 9516
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

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

	cin >> n >> m;

	time = 1900 * m + 100 * (n - m);

	for (i = 0, j = 1; i < m; i++) {
		j *= 2;
	}

	cout << time * j;

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import numpy as np

N,X,Y,Z = map(int,input().split())

MOD = 10 ** 9 + 7

# ダメなやつを数える
L = max(10,X + Y + Z)
dp = np.zeros(1 << L+1, dtype = np.int64) # 右から見て部分和として踏む場所
rng = np.arange(1 << L+1, dtype=np.int64)
x575 = (1 << Z) + (1 << (Y+Z)) + (1 << (X+Y+Z))
bad = ((x575 & rng) == x575)
dp[1] = 1

for n in range(N):
    prev = dp
    dp = np.zeros_like(prev)
    for i in range(1, 11):
        dp[1::1<<i] += prev.reshape(1<<i, 1<<(L+1-i)).sum(axis = 0)
    dp[bad] = 0
    dp %= MOD

answer = pow(10,N,MOD) - dp.sum()
answer %= MOD
print(answer)

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

int main(){
    ll a,b,k;
    cin >>a>>b>>k;
    if(a>k){
        a -=k;
    }else if((a+b)>k){
        b = a+b-k;
        a = 0;
        //cout << 11 << endl;
    }else{
        a=0;
        b=0;
        //cout << 10 << endl;
    }
    cout << a <<  " "<< b << endl;
}

Measured memory_bytes: 3616
#include<stdio.h>
int main()
{
	int n,m,t=0,cnt=0;
	while(~scanf("%d%d",&n,&m)){
		while(t<n){
			t+=m+m+1;
			cnt++;
		}printf("%d\n",cnt);
		cnt=0;t=0;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define absl(v) labs((v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,tmp;
  int a[LIMIT2]={0},b[LIMIT1]={0};
  char s[LIMIT1];
  
  scanf("%lld",&n);
  rep(i,n){
    scanf("%d",&a[i]);
    b[i] = a[i];
  }
  qsort(b,n,sizeof(int),upint);
  tmp = (ll)b[n/2-1];
  rep(i,n){
    if(a[i]<=tmp) printf("%d\n",b[n/2]);
    else printf("%lld\n",tmp);
  }
  return 0;
}



Measured memory_bytes: 4856
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define f first
#define s second
#define va vector<long long int> a
#define vb vector<long long int> b
#define M 1000000007
using namespace std;
ll t;
void fast(){cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);}
ll power(ll x,ul y,ll p){ll res = 1;x = x % p;if(x == 0)return 0;while (y > 0){if (y & 1)res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;}

int main(){
fast();
ll k,a,b,flag=0;
  cin>>k>>a>>b;
  for(ll i=a;i<=b;i++)
  {
    if(i%k==0){
      flag=1;
      break;}
  }
  if(flag==1)
    cout<<"OK"<<endl;
  else
    cout<<"NG"<<endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;
    vector<ll> a(n-1), b(n-1);
    vector<vector<PII>> g(n);
    REP(i, n-1) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        g[a[i]].push_back({b[i], i});
        g[b[i]].push_back({a[i], i});
    }

    vector<ll> ans(n-1);
    function<void(ll,ll,ll)> dfs = [&](ll v, ll p, ll c) {
        ll now = c==1 ? 2 : 1;
        for(auto to: g[v]) {
            if(to.first == p) continue;
            dfs(to.first, v, now);
            ans[to.second] = now;
            now++;
            if(now == c) now++;
        }
    };
    dfs(0, -1, 0);

    ll ma = 0;
    REP(i, n-1) chmax(ma, ans[i]);
    cout << ma << endl;
    REP(i, n-1) cout << ans[i] << endl;

    return 0;
}

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

// GCD, LCM
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;}

int main()
{
    ll N,m=INT64_MAX;
    cin>>N;

    ll x=sqrt(N)/1;

    for(int i=1;i<=x;i++){
        if(N%i==0){
            ll x,y;
            x=i;
            y=N/i;
            ll d= abs(x-1)+abs(y-1);
            if(d<m)m=d;
        }
    }

    cout<<m<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
typedef struct{
  long a;
  long b;
}setab;

int compare(void const *p,void const *q){
  return ((setab*)p) -> a - ((setab*)q) -> a;
}

int main(){
  setab abset[100000] = {};
  long n = 0;
  long k = 0;
  long i = 0;
  long result = 0;
  long sum = 0;
  scanf("%ld %ld",&n,&k);
  for(i=0;i<n;i++){
    scanf("%ld %ld",&abset[i].a,&abset[i].b);
  }
  
  qsort(abset,n,sizeof(setab),compare);
  /*for(i=0;i<n;i++){
    printf("%ld %ld#",abset[i].a,abset[i].b);
  }*/
  for(i=0;i<n;i++){
    if(sum <= k-1 && k-1 < sum + abset[i].b){
      result = abset[i].a;
      break;
    }else{
      sum += abset[i].b;
    }
  }
  
  printf("%ld",result);
    
  return 0;
}
 
  

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long[] sum = new long[N+1];
		var di = new Dictionary<long,long>();
		for(int i=0;i<N;i++){
			sum[i + 1] = sum[i] + A[i];
			if(!di.ContainsKey(sum[i + 1])) di.Add(sum[i + 1], 0);
			di[sum[i + 1]]++;
		}
		
		long cnt = 0;
		long tot = 0;
		for(int i=0;i<N;i++){
			if(di.ContainsKey(tot)){
				cnt += di[tot];
			}
			tot += A[i];
			di[tot]--;
			if(di[tot] == 0) di.Remove(tot);
		}
		
		Console.WriteLine(cnt);
		
		
	}
	int N;
	long[] A;
	public Sol(){
		N = ri();
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 41428
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;

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

    ll a = 2, b = 1;
    for (int j = 0; j < N; ++j) {
        ll t = a+b;
        a = b;
        b = t;
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void output(int A[], int n);
void insertionSort(int A[], int n);

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

    return 0;
}

void output(int A[], int n){
    int i;
    for(i = 0; i < n; i++){
        printf("%d", A[i]);
	if(i != n-1)printf(" ");
    }
    printf("\n");
}

void insertionSort(int A[],int n){
    int i, j, key;
    output(A, n);
for(i = 1; i <= n-1; i++) {
        key = A[i];
        j = i-1;
        while(j >= 0 && A[j] > key){
            A[j+1] = A[j];
            j --;
        }
	 A[j+1] = key;
        
        output(A, n);
    }
}


Measured memory_bytes: 2128
from collections import deque
H,W=map(int,input().split())

l=[input() for _ in range(H)]


def bfs(H,W,l):
  ans=0
  que=deque()
  count=[[-1]*W for _ in range(H)]
  num=H*W
  dx=[1,-1,0,0]
  dy=[0,0,1,-1]
  for i in range(H):
    for j in range(W):
      if l[i][j]=='#':
        count[i][j]=0
        que.append([i,j])
        num-=1
  while num>0:
    x,y=que.popleft()
    for k in range(4):
      a, b=x+dx[k], y+dy[k]
      if a<0 or a>=H or b<0 or b>=W or count[a][b]!=-1:
        continue
      else:
        count[a][b]=count[x][y]+1
        que.append([a,b])
        num-=1
  for i in range(H):
    ans=max(ans,max(count[i]))
  return ans
print(bfs(H,W,l))
    


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

using namespace std;

typedef long long ll;

const int N = 2e5 + 5;
const ll MOD = 1e9 + 7;

ll get(ll x) {
  if(x <= 0) return 0;
  return (x * (x + 1)) / 2ll;
}

int main() {
  ll n; cin >> n;
  ll k; cin >> k;
  ll p = 0;
  ll ans = 0;
  for(ll i = k; i <= n; i++) {
    ll L = get(i - 1);
    ll R = (get(n) - get(n - i) + MOD) % MOD;
    if(R < 0) R += MOD;
    //cout << L << ' ' << R << '\n';
    ll cur = (R - L + 1 + MOD) % MOD;
    if(cur < 0) cur += MOD;
    ans = (ans + cur) % MOD;
  }
  ans = (ans + 1) % MOD;
  cout << ans << '\n';
  
}

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

bool f(int n){
    if(n/10000 != n%10) return false;
    if((n%10000)/1000 != (n%100)/10) return false;
    return true;
}

int main(){
    int a,b;
    cin>>a>>b;
    int ans = 0;
    for(int i=a;i<=b;i++){
        if(f(i)) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const string YES = "YES";
const string NO = "NO";

void solve(long long A, long long V, long long B, long long W, long long T){
  string ans;
  if(V<=W||abs(A-B)>(V-W)*T)cout<<NO<<endl;
  else cout<<YES<<endl;
}

int main(){
  cout<<setprecision(1000);
    long long A;
    scanf("%lld",&A);
    long long V;
    scanf("%lld",&V);
    long long B;
    scanf("%lld",&B);
    long long W;
    scanf("%lld",&W);
    long long T;
    scanf("%lld",&T);
    solve(A, V, B, W, T);
    return 0;
}


Measured memory_bytes: 3692
#include<cstdio>

using ll=long long;

ll gcd(ll a, ll b)
{
	ll c;

	while((c=a%b))
	{
		a=b;
		b=c;
	}
	return b;
}

int main(void)
{
	int t;

	while(scanf("%d", &t)==1)
	{
		ll a, b, c, d, e;

		for(int i=0;i<t;i++)
		{
			int ans=1;

			scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
			e=gcd(b, d);
			do
			{
				if(b>a)
				{
					ans=0;
//					printf("b>a\n");
					break;
				}
				if(b>d)
				{
					ans=0;
//					printf("b>d\n");
					break;
				}
				if(b>c)
				{
					ll x=(a-c)%e;
					if(x==0) x+=e;
					if(a<c)
					{
						a+=(c-a+d-1)/d*d;
					}
					if(x+c<b)
					{
						ans=0;
						break;
					}
				}
			}
			while(0);
			printf("%s\n", ans?"Yes":"No");
		}
	}

	return 0;
}


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

int main()
{
    int n, u, k, v;

    cin >> n;

    bool a[n][n];
    for( int i = 0; i < n; i++ )
        for( int j = 0; j < n; j++ )
            a[i][j] = 0;

    for( int i = 0; i < n; i++ )
    {
        cin >> u >> k;
        for( int j = 0; j < k; j++ )
        {
            cin >> v;
            a[u-1][v-1] = 1;
        }
    }

    for( int i = 0; i < n; i++ )
    {
        cout << a[i][0];
        for( int j = 1; j < n; j++ )
            cout << " " << a[i][j];
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define Fast_cin ios::sync_with_stdio(false), cin.tie(0);
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
using namespace std;
 
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;
 
template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') fu = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}
 
template <typename T>
void print(T x) {
    if(x < 0) putchar('-'), x = -x;
    if(x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}
 
template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}
 
template <typename T>
struct hash_map_t {
    vector <T> v, val, nxt;
    vector <int> head;
    int mod, tot, lastv;
    T lastans;
    bool have_ans;
 
    hash_map_t (int md = 0) {
        head.clear(); v.clear(); val.clear(); nxt.clear(); tot = 0; mod = md;
        nxt.resize(1); v.resize(1); val.resize(1); head.resize(mod);
        have_ans = 0;
    }
 
    void clear() { *this = hash_map_t(mod); }
 
    bool count(int x) {
        int u = x % mod;
        for(register int i = head[u]; i; i = nxt[i]) {
            if(v[i] == x) {
                have_ans = 1;
                lastv = x;
                lastans = val[i];
                return 1;
            }
        }
        return 0;
    }
 
    void ins(int x, int y) {
        int u = x % mod;
        nxt.push_back(head[u]); head[u] = ++tot;
        v.push_back(x); val.push_back(y);
    }
 
    int qry(int x) {
        if(have_ans && lastv == x) return lastans;
        count(x);
        return lastans;
    }
};

ll s;

int calc(ll x) {
    for(register int i = floor(sqrt(x + 0.5)); i >= 1; i--) {
        if(x % i == 0) {
            return i;
        }
    }
    return 1;
}

bool check(int now) {
    ll ad = 1ll * now * now - s;
    if(ad / calc(ad) <= now) return 1;
    return 0;
}

int main() {
    cin >> s;
    int now = ceil(sqrt(s));
    if(1ll * now * now == s) {
        cout << 0 << " " << 0 << " " << now << " " << 0 << " " << 0 << " " << now << endl;
        return 0;
    }
    while(!check(now)) ++now;
    ll ad = 1ll * now * now - s;
    int a = calc(ad), b = ad / a;
    cout << 0 << " " << 0 << " " << a << " " << now << " " << now << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		List<Integer> list = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);

		 while(sc.hasNext()) {
			int inputNum = sc.nextInt();
			if(inputNum != 0) {
				list.add(inputNum);
			}
			if(inputNum == 0) {
				break;
			}
		 }
		int index =1;
		for(int i : list) {
			System.out.println("Case "+index+": "+i);
			index++;
		}
	}
}

Measured memory_bytes: 47088
from collections import deque
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())

graph = [[] for _ in range(n)]
graph2 = [[] for _ in range(n)]
in_degree = [0] * n
out_degree = [0] * n
for _ in range(n - 1 + m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph2[b].append(a)
    in_degree[b] += 1
    out_degree[a] += 1

v_root = in_degree.index(0)

depth = [-1] * n
ans = [0] * n
depth[v_root] = 0


def dfs(v):
    if depth[v] == -1:
        for v_par in graph2[v]:
            d = dfs(v_par)
            if depth[v] < d + 1:
                depth[v] = d + 1
                ans[v] = v_par + 1
    return depth[v]


for i in range(n):
    if out_degree[i] == 0:
        # print(i)
        _ = dfs(i)

print(*ans, sep='\n')


Measured memory_bytes: 211216
(defun f (a b c n)
  (if (or (oddp a)
	  (oddp b)
	  (oddp c))
      n
      (f (ash (+ b c) -1)
	 (ash (+ a c) -1)
	 (ash (+ a b) -1)
	 (+ n 1))))
 
(defun ff (a b c)
  (if (and (= a b) (= b c))
      (if (evenp a)
	  -1
	  0)
      (f a b c 0)))
 
(let ((a (read))
      (b (read))
      (c (read)))
  (format t "~a~%" (ff a b c)))


Measured memory_bytes: 4448
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;

fn main() {
    let s = str2vec(&input_line_str());
    for z in 0..s.len() - 1 {
        if s[z] == s[z + 1] {
            if s[z]==s[z+1] {
                println!("{} {}", z+1, z + 2);
                return;
            }
        }
        if z + 3 <= s.len() {
            if s[z] == s[z + 2] && s[z] != s[z + 1] {
                println!("{} {}", z + 1, z + 3);
                return;
            }
        }
    }
    p("-1 -1");
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<iostream>

using namespace std;

int gcd(int big, int small){
    if(big<0 || small<0)
        return -1;
    if(small==0)
        return big;
    if((big%small)==0)
        return small;
    return gcd(small, big%small);
}

int main(){
    int a, b;
    scanf("%d%d", &a, &b);
    if(a<b){
        swap(a,b);
    }
    int res = gcd(a,b);
    printf("%d\n", res);
    return 0;
}



Measured memory_bytes: 3228
#include <iostream>

using namespace std;

int main(){
  
  int64_t a,b,c,d;
  
  cin >> a >> b >> c >> d ;
  
  if(a>0 && b>=0){
    if(d>=0){
    cout << b * d << endl;
    }else{
    cout << a * d << endl;
    }
  }else if(a<=0 && b>=0){
    if(c>0 && d>=0){
      cout << b * d << endl;
    }else if(c<0 && d>=0){
      if((a * c) >= (b * d)){
        cout << (a * c) << endl;
      }else if((a*c) < (b*d)){
        cout << (b * d) << endl;
      }
    }else{
      cout << a * c << endl;
    }
  }else if(a<0 && b<=0){
    if(c>0){
    cout << b * c << endl;
    }else{
    cout << a * c << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3572