akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  int ans = s * t;
  if(ans >= d){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3672
#include<stdio.h>
int main(){
	int n,a[55],ans=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			ans+=a[i]*a[j];
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip>
#include<map>
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
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()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll a,b,n;
    while (cin >> a>>b>>n)
    {
        ll maxn=-mod,k=0;
        /*for(ll i=1;i<=min(n,b);i++)
        {
            if(maxn<((a*i)/b-a*(i/b)))
            {
                maxn=((a*i)/b-a*(i/b));
                k=i;
            }
            
        }*/
        cout<<(a*min(n,b-1))/b-a*(min(n,b-1)/b)<<'\n';
    }
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
  int n, k;
  cin>>n>>k;
  Sieve sieve(k);
  mint ans;
  vector<mint> d(k+1);
  for (int i = 1; i <= k; ++i) {
    d[i] = mint(k/i).pow(n);
  }
  for (int p : sieve.primes) {
    for (int i = p; i <= k; i += p) {
      d[i/p] -= d[i];
    }
  }
  for (int i = 1; i <= k; ++i) ans += d[i]*i;
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(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...);
}

bool func(string s, int t){
	if(t==s.length()) return true;
	if (s.substr(t,7)=="dreamer") return func(s,t+5) || func(s,t+7);
	if (s.substr(t,6)=="eraser") return func(s,t+6);
	if (s.substr(t,5)=="dream" || s.substr(t,5)=="erase") return func(s,t+5);
	
	else return false;
}

int main(){
	string s;
	cin >> s;
	int i=0;

	
	//cout << i <<"\n";
	if(func(s,0)) cout << "YES";
	else cout << "NO";
	return 0;
}

Measured memory_bytes: 2332
import java.util.*;
public class Main{
  public static void main(String[] args){
  	Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    int[] A=new int[N];
    int[] B=new int[N];
    for(int i=0;i<N;i++){
      A[i]=sc.nextInt();
      B[i]=sc.nextInt();
    }
    
    Arrays.sort(A);
    Arrays.sort(B);
    
    int min=0;
    int max=0;
    if(N%2==0){
      min=A[N/2-1]+A[N/2];
      max=B[N/2-1]+B[N/2];
    }else{
      min=A[(N-1)/2];
      max=B[(N-1)/2];
    }
      
     
    System.out.println(max-min+1);
  }
}

Measured memory_bytes: 61792
import sys
sys.setrecursionlimit(10**9)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
'''
def check(A):
    num = A[1]
    for i in range(10):
        if A[i] >= num and i!=1:
            A[i] = INF
    print('check', A)
    for i in range(10):
        if A[i]!=INF and A[i]!=0 and i!=1:
                return True
    return False


def dfs(A):
    k = check(A)
    while k:
        for i in range(10):
            if i!= 1 and A[i] != INF:
                for j in range(10):
                    if A[j] != INF:
                        A[j] = min(A[i]+C[i][j], A[j])
                        if j == 1 and A[j]==A[i]+C[i][j]:
                            A[i] = INF
        print('dfs', A)
        k = check(A)
    print(A)
    return A[1]

    

H, W = mi()
C = li2(10)
a = li2(H)
ans = 0

INF = 10**9
memo = [INF]*10

for i in range(10):
    if i!= 1:
        A = []
        for j in range(10):
            A.append(C[i][j])
        print(A)
        memo[i] = dfs(A)
        print(i, memo[i])

for i in range(H):
    for j in range(W):
        if a[i][j] != -1 and a[i][j] != 1:
            ans += memo[a[i][j]]

print(memo)

print(ans)
'''
H, W = mi()
C = li2(10)
a = li2(H)
memo = [C[i][1] for i in range(10)]
flag = -1

def dfs(column, m):
    #print('a')
    if column == 1:
        global flag
        flag = max(m, flag)
    for i in range(10):
        if i!=column and C[column][i] < m:
            dfs(i, m-C[column][i])
    return False

for i in range(10):
    if i != 1:
        dfs(i, C[i][1])
        #print(flag)
        if flag != -1:
            memo[i] = C[i][1]-flag
            #print(i, flag)
        flag = -1
    #print(memo)

ans = 0

for i in range(H):
    for j in range(W):
        if abs(a[i][j]) != 1:
            ans += memo[a[i][j]]
#print(memo)
print(ans)

Measured memory_bytes: 3444
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;

//#define fi1 ifstream fin("input.txt")
//#define of1 ofstream fout("output.txt")
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m;
	cin>>n>>m;
	vector< vector<ll> >arr(11);
	for(ll i=1;i<=m;i++)
	{
		ll tmp;
		cin>>tmp;
		while(tmp--)
		{
			ll a;
			cin>>a;
			arr[i].eb(a);
		}
	}
	vector< ll >p(11);
	for(ll i=1;i<=m;i++)
	{
		cin>>p[i];
	}
	ll ans=0;
	vector<ll>swit(11,0);
	for(int i=0;i<(1<<n);i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i&(1<<j))
			{
			    swit[j+1]=1;
			}
		    else
		    {
		        swit[j+1]=0;
		    }
		}
		ll flag=1;
	    for(ll k=1;k<=m;k++)
	    {
	        ll c=0;
	        for(auto &noo:arr[k])
	        {
	            if(swit[noo])
	                c++;
	        }
	        if((c&1)!=p[k])
	        {
	            flag=0;
	            break;
	        }
	    }
	    ans+=flag;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>

using namespace std;

int main () {
  double x1, x2, y1, y2;
  double d;
  cin >> x1 >> y1 >> x2 >> y2;
  d = hypot(x1-x2, y1-y2);
  cout.precision(8);
  cout << fixed <<  d << endl;
  return 0;
}

Measured memory_bytes: 1292
#include <iostream>
#include <iomanip>

int main(void) {
	using namespace std;
	int a, b;
	cin >> a >> b;
	int d = int(a / b);
	int r = a % b;
	double f = (double)a / b;
	cout << d << ' ' << r << ' ' << fixed << setprecision(7) << f << endl;
	return 0;
}

Measured memory_bytes: 3232
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
char s[201010]={0};
int main()
{
    int num1=0,num2=0;
    int flag=1;
    long long cnt=0;
    long long cntBC=0;
    long long cntA=0;
    scanf("%s",s);
    int n = strlen(s);
    for(int i=n-1;i>=1;--i){
        if(s[i]=='C'&&s[i-1]=='B'){
            cnt+=cntBC*cntA;
            cntBC++,i--,cntA=0;
        }
        else if(s[i]=='A'){
            cntA++;
        }
        else{
            cnt+=cntBC*cntA;
            cntBC=0;
            cntA=0;
        }
    }
    if(s[0]=='A'){
        cntA++;
        //cnt+=cntA*cntBC;
    }
        cnt+=cntA*cntBC;

    printf("%lld\n",cnt);
    return 0;
}


Measured memory_bytes: 384
import java.util.*;

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();
      	int d = sc.nextInt();
      	
      	int x = (a-c) * b;  
        int y = (d * a) - (c * d);
      	
      	System.out.println(x-y);
    }
    

}

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

#define X first
#define Y second
typedef long long ll;
typedef pair<ll,ll> pll;

int main(int argc, char const *argv[])
{
    //ios::sync_with_stdio(false);
    //cin.tie(NULL);
    ll p, q, r;
    cin >> p >> q >> r;
    if (p<=q && p<=r) cout << p + min(r,q) << endl;
    else if (q<=p && q<=r) cout << q + min(r,p) << endl;
    else if (r<=q && r<=p) cout << r + min(p,q) << endl;
    return 0;
}

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

// youtube 
int dist[100005][3];//(node, step), total distance
const int INF = 1001001001;//10^5の間違えづらい書き方
int main() {
    string S;
    cin >> S;
    if(!S.compare("Sunny")){
        cout << "Cloudy" << endl;
    }else if(!S.compare("Cloudy")){
        cout << "Rainy" << endl;
    }else if(!S.compare("Rainy")){
        cout << "Sunny" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <tuple>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <complex>
#include <bitset>
#include <numeric>
#include <random>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define SE second
#define FI first
#define DBG(a) cerr<<(a)<<endl;
#define dump(a) cerr<<#a <<' '<< a <<endl;
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;  typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
typedef pair<int,int>PI; typedef vector<int> VI;
const LL LINF=334ll<<53; const int INF=15<<26; const LL MOD=1E9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    VI a(n);
    REP(i,n) cin >> a[i];
    LL ans=0,up=0;
    REP(i,n){
        if(a[i]!=0){
            a[i]+=up;
            ans+=a[i]/2;
            up=a[i]%2;
        }else{
            up=0;
        }
    }
    cout << ans <<endl;

    return 0;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, const T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, const T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }
int N, D, Q;
V ds, qs;

void calc() {
	cin >> N >> D;
	ds.resize(N); input(ds);
	cin >> Q;
	map<int, int> qex;
	vector<int> qs(N); input(qs);
	rep(i, Q) {
		int x = qs[i];
		qex[x - 1] = i;
	}
	int m = N + 1;
	int now = D;
	V memo(N);
	rep(i, N) {
		memo[i] = now;
		if (now >= ds[i]) now -= ds[i];
		else if (2 * now > ds[i]) now = ds[i] - now;
		if (now == 0) m = i;
	}
	if (m == N + 1) {
		rep(i, Q) cout << "YES" << endl;
	} else {
		V anses(Q);
		int S = 1;
		for (int i = N - 1; i >= 0; i--) {
			if (qex.count(i)) {
				anses[qex[i]] = (memo[i] >= S);
			}
			if (S > ds[i] / 2) S += ds[i];
		}
		rep(i, Q) {
			cout << (anses[i] ? "YES" : "NO") << endl;
		}
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	calc();
#ifdef _MSC_VER
	system("pause");
#endif
}

Measured memory_bytes: 48896
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std; 
#define pb push_back 
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define sc(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
 
int main(int argc, char** argv) {
	int s,f;
	cin>>s>>f;
	if(f>=s)
	{
		printf("unsafe")
;	}
else puts("safe");
	return 0;
}

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

int main(){
    int n, t, ans = 1e9;
    cin >> n >> t;
    int c[n], time[n];
    for (int i = 0; i < n; i++){
        cin >> c[i] >> time[i];
    }

    for (int i = 0; i < n; i++){
        if(time[i] <= t && c[i] < ans){
            ans = c[i];
        }
    }
    if(ans == 1e9){
        cout << "TLE" << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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


int main() {
  ll n; cin >> n;

	vector<int> a(n+1), b(n);
	rep(i,n+1) cin >> a[i];
	rep(i,n) cin >> b[i];
	ll ans = 0;

	rep(i, n+1) {
		if (i - 1 >= 0) {
			ans += min(a[i], b[i - 1]);
		  a[i] -= b[i-1]; chmax(a[i], 0);
		}

		if (i < n) {
			ans += min(a[i], b[i]);
			b[i] -= a[i]; chmax(b[i], 0);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1024
import math

list=input().split(" ")
n=int(list[0])
k=int(list[1])
s=input()

list2=[]
renzoku=0

if s[0]=='0':
    list2.append(0)

for x in range(n-1):
    renzoku+=1
    if int(s[x])!=int(s[x+1]):
        list2.append(renzoku)
        renzoku=0

list2.append(renzoku+1)
if len(list2)%2==0:
    list2.append(0)

#print(list2)

kaisu=math.ceil(len(list2)/2)-k
max=0
if kaisu<=0:
    max=len(s)

for y in range(kaisu):
    #print(list2[y*2:y*2+(2*k+1)])
    if y==0:
        gokei=sum(list2[y*2:y*2+(2*k+1)])
    else:
        gokei-=(list2[y*2-2]+list2[y*2-1])
        gokei+=(list2[y*2+k*2-1]+list2[y*2+k*2])
    if gokei>max:
        max=gokei
print(max)

Measured memory_bytes: 4596
#include <iostream>
#include <string>
#include <cstring>

int main()
{
	std::string s, t;
	std::cin >> s >> t;
	
	std::cout << (std::strncmp(s.c_str(), t.c_str(), s.size()) == 0 ? "Yes" : "No") << std::endl;
	
	return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
int main(){
	int i,p=0,k=0,n;
	string s;
	cin>>n;
	cin>>s;
	for(i=n-1;i>=0;i--){
	if(s[i]=='D')n--;
	else break;
	}
	for(i=0;i<n;i++){
		if(s[i]=='I')k++;
		if(s[i]=='D')k--;
		if(p<k)p=k;
	}
	cout<<p;
}

Measured memory_bytes: 256
#include <stdio.h>

void swap( int* a, int* b ){
    
    int tmp = *a;
    *a = *b;
    *b = tmp;
    
}

int main(void){
    
    int input1, input2;
    
    while( 1 ){
        
     scanf( "%d %d", &input1, &input2 );
     
     if( input1 == 0 && input2 == 0 )
        break;   
    
     if( input1 > input2 )
        swap( &input1, &input2 );
        
     printf( "%d %d\n", input1, input2 );    
    
    }
    
}


Measured memory_bytes: 2036
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define REP(i, start, end) for (ll i = start, i##Len = (end); i < i##Len; ++i)
#define REPR(i, start, end) for (ll i = start, i##Len = (end); i > i##Len; --i)
using ll = long long;
using namespace std;

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    ll n, x, m;
    cin >> n >> x >> m;

    vector<ll> used(m, -1), dp(m);
    used[x] = n;
    dp[x] = x;
    n -= 1;
    bool flag = 1;
    ll ans = x;

    while (n > 0 && x)
    {
        x = x * x % m;
        ans += x;

        if (flag && used[x] != -1)
        {
            flag = 0;
            ll per = (used[x] - n);
            ll div = n / (used[x] - n);
            ll mod = n % (used[x] - n);
            if (per > n || div == 0)
                break;
            else if (mod == 0)
            {
                div -= 1;
                mod = per;
            }
            ans += (ans - dp[x]) * div;
            n = mod;
        }
        else
        {
            used[x] = n;
            dp[x] = ans;
        }
        --n;
    }

    cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  int n, m;
  cin >> n >> m;
  priority_queue<int>pq;
  vector<int>ar(n);
  for (int i = 0; i < n; i++){
    cin >> ar[i];
    pq.push(ar[i]);
  }
  if (n == 1){
    while (m != 0){
      ar[0] /= 2;
      m--;
    }
    cout << ar[0] << "\n";
    return 0;
  }
  for (int i = 0; i < m; i++){
    int x = pq.top();
    pq.pop();
    x /= 2;
    pq.push(x);
  }
  ll sum = 0;
  while (!pq.empty()){
    sum += pq.top();
    pq.pop();
  }
  cout << sum << "\n";
  return 0;
}


Measured memory_bytes: 1276
n, m = map(int, input().split())

MOD = 10 ** 9 + 7

if abs(n - m) > 1:
    print(0)
elif abs(n - m) == 1:
    if n < m:
        n, m = m, n
    temp = 1
    for i in range(1, n + 1):
        b = temp
        temp = temp * i % MOD
    print((temp * b) % MOD)
else:
    temp = 1
    for i in range(1, n + 1):
        temp = (temp * i) % MOD
    print((temp * temp * 2) % MOD)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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

	string N, M;
	cin >> N >> M;

	N += M;

	int X = stoi(N);
	int rX = sqrt(X);
	if (rX*rX == X) co("Yes");
	else co("No");


	Would you please return 0;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7
n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))
dp = [[0] * (m + 3) for _ in range(n + 3)]
for i in range(n + 3):
    dp[i][0] = 1
for i in range(m + 3):
    dp[0][i] = 1
for i in range(1, n + 1):
    for j in range(1, m + 1):
        if s[i - 1] == t[j - 1]:
            dp[i][j] += dp[i - 1][j] + dp[i][j - 1]
        else:
            dp[i][j] += dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1]
        dp[i][j] %= MOD
print(dp[n][m] % MOD)

Measured memory_bytes: 72796
// ------- PBDS ------ //
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
// ------- PBDS ------ //

#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define testcase ll tt; cin>>tt; while(tt--)
#define pb push_back
#define nn cout<<"\n"
#define MOD 1000000007
#define pi 3.1415926535
#define endl "\n"
#define vll vector<ll>
#define MULTI int T; cin >> T; while(T--)
#define all(a)      (a).begin(),(a).end()
#define here cout<<"I'm here\n";
void vout(vector<ll> ans){
    for(auto ele:ans) cout<<ele<<" "; cout<<endl;
}
vector<ll> adj[200001];
bool vis[200001];

// ------- PBDS ------ //
typedef tree<
// change this for any data-type
string,
null_type,
// change this for any data-type
less<string>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

/*
    to get the position of an element in set , do
    s.order_of_key(ele);
    this returns the number of elements strictly lesser than ele in set s
    Let us assume we have a set s : {1, 5, 6, 17, 88}, then :
    s.order_of_key(6) : Count of elements strictly smaller than 6 is 2.
    s.order_of_key(25) : Count of elements strictly smaller than 25 is 4.

    to get the element at position k
    s.find_by_order(k);
    returns an iterator to the ele counting from 0
    Let us assume we have a set s : {1, 5, 6, 17, 88}, then :
    *(s.find_by_order(2)) : 3rd element in the set i.e. 6
    *(s.find_by_order(4)) : 5th element in the set i.e. 88
*/

// ------- PBDS ------ //

clock_t time_p=clock();
void purvansh11()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

//BINARY EXPONENTIATION  -- O(log2(b))
ll power(ll a, ll b) {
    /*
        for 3^11 :
        as 11 -> 1011, we mean 3^8 * 3^2 * 3^1
        so multiply for all ones in binary rep of b
    */

    ll ans = 1;
    ll num = a;
    while (b > 0) {
        if (b & 1) ans = ((ans % MOD) * (num % MOD)) % MOD;
        num = ((num % MOD) * (num % MOD)) % MOD;
        b /= 2;
    }
    return ans;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    SPEED;
    cout.precision(8);
    cout << fixed;
    ll n;
    cin>>n;
    vector<ll> v(n);
    for(auto &itr:v) cin>>itr;
    ll cnt=0;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            for(ll k=j+1;k<n;k++){
                set<ll> s;
                s.insert(v[i]);
                s.insert(v[j]);
                s.insert(v[k]);
                if(s.size()!=3) continue;
                auto itr=s.begin();
                ll a=*itr;
                itr++;
                ll b=*itr;
                itr++;
                ll c=*itr;
                if((a+b)>c) cnt++;
            }
        }
    }   
    cout<<cnt;
    
    purvansh11();
    return 0;
}

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

using namespace std;

int N, ans;
int a[100000][3];
int dp[100000][3];

int main(){
	cin >> N;
	for(int i = 0; i < N; ++i) cin >> a[i][0] >> a[i][1] >> a[i][2];
	dp[0][0] = a[0][0]; dp[0][1] = a[0][1]; dp[0][2] = a[0][2];

	for(int i = 1; i < N; ++i){
		dp[i][0] = max(dp[i-1][1], dp[i-1][2])+a[i][0];
		dp[i][1] = max(dp[i-1][0], dp[i-1][2])+a[i][1];
		dp[i][2] = max(dp[i-1][0], dp[i-1][1])+a[i][2];
	}
	for(int j = 0; j < 3; ++j) ans = max(ans, dp[N-1][j]);

	cout << ans << endl;
}

Measured memory_bytes: 2560
def main():
    N = int(input())
    S = list(map(int, input().split()))
    ans = 0
    for C in range(1, N//2+1):
        cs = 0
        for k in range(1, (N-1)//C+1):
            a = C*k
            b = N - a - 1
            if a >= b and (N-1) % C == 0:
                break
            if b <= C:
                break
            cs += S[a] + S[b]
            ans = max(cs, ans)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 63340
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){
int N;
cin>>N;
int  exist[N]={};
rep(i,N){
    int t;
    cin>>t;
    exist[t]++;
}
int t;
if(N%2==0)t=1;
else    t=2;
for(int i=t;i<N;i+=2){
    if(exist[i]!=2){
        cout<<"0";
        return 0;
    }
}

int  cul=N/2;
long long ans=1;
rep(i,cul){
    ans*=2;
    if(ans>mod)ans%=mod;
}
cout<<ans<<endl;
 return 0;
}
/*
5
2 4 4 0 2

4

7
6 4 0 2 4 0 2

0

8
7 5 1 1 7 3 5 3

16
*/

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

using namespace std;

long long f_(long long a) {
  if (a < 0) return 0;
  long long res[] = {a, 1, a+1, 0};
  return res[a%4];
}

long long f(long long a, long long b) {
  return f_(b)^f_(a-1);
}

int main() {
  long long A, B;
  cin >> A >> B;
  cout << f(A, B) << endl;
  return 0;
}



Measured memory_bytes: 256
sub f{my$p=$h[my$c=$c[$_]-1];my$r=$s=$v[++$_]=1;$v[$_--]or$a[$c]-=-$s*(-$s+($s=($r+=&f)-$h[$c]+$p))for@$_;$a[$c]+=($p+$r-$h[$c])*(@a-($h[$c]=$p+$r))+1;$r}@a=(0)x<>;@c=glob<>;map{push@$_,$u-$_+$;for($u,$;)=split}<>;f;print"@a"

Measured memory_bytes: 545684
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define INF INT_MAX/2

typedef vector<int> vi;

typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;

int main()
{
	int N, K, T, U, V, L;
	cin >> N >> K >> T >> U >> V >> L;
	//vi D(N); rep(i, 0, N) cin >> D[i];
	vi D(L + 1, 0);
	rep(i, 0, N) { int d; cin >> d; D[d]++; }

	double ans = 0;
	int have = 0;
	int speedup = -1;
	rep(i, 1, L+1)
	{
		if (i < speedup)
			ans += 1.0 / V;
		else if (i == speedup)
		{
			speedup = -1;
			ans += 1.0 / V;
		}
		else
			ans += 1.0 / U;

		if (D[i] == 1)
		{
			if (have == K)
			{
				speedup = i + T*V;
			}
			else
			{
				have++;
			}
		}

		if (speedup < 0 && 0 < have)
		{
			have--;
			speedup = i + T*V;
		}
	}

	printf("%.10f\n", ans);
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

template<typename T, typename U, bool PROP = true> struct segment_tree_lazy {
    int S;
    vector<T> table;
    vb has; vector<U> ops;

    segment_tree_lazy(int _S) : S(_S) {
        table.resize(2 * S), has.resize(S), ops.resize(S);
    }

    segment_tree_lazy(auto begin, auto end) : segment_tree_lazy(distance(begin, end)) {
        copy(begin, end, table.begin() + S);
        for (int i = S - 1; i > 0; i--)
            table[i] = table[2 * i] + table[2 * i + 1];
    }

    void apply(int i, const U &op) {
        table[i] = op(table[i]);
        if (i < S) has[i] = true, ops[i] = op(ops[i]);
    }

    void rebuild(int i) {
        for (i /= 2; i; i /= 2)
            table[i] = ops[i](table[2 * i] + table[2 * i + 1]);
    }

    void propagate(int i) {
        for (int j = 31 - __builtin_clz(i); j > 0; j--) {
            int k = i >> j;
            if (has[k]) {
                apply(2 * k, ops[k]);
                apply(2 * k + 1, ops[k]);
                has[k] = false, ops[k] = U{};
            }
        }
    }

    void replace(int i, T v) {
        if (PROP) propagate(i + S);
        table[i + S] = v;
        rebuild(i + S);
    }

    void operator()(int i, int j, U op) {
        i += S, j += S;
        if (PROP) propagate(i), propagate(j - 1);
        for (int l = i, r = j; l < r; l /= 2, r /= 2) {
            if (l&1) apply(l++, op);
            if (r&1) apply(--r, op);
        }
        rebuild(i), rebuild(j - 1);
    }

    T operator()(int i, int j) {
        i += S, j += S;
        if (PROP) propagate(i), propagate(j - 1);
        T left{}, right{};
        for (; i < j; i /= 2, j /= 2) {
            if (i&1) left = left + table[i++];
            if (j&1) right = table[--j] + right;
        }
        return left + right;
    }
    T operator()(int i) { return (*this)(i, i+1); }
};

struct max_ll {
    ll val;

    max_ll() : val(0) {}
    max_ll(ll val) : val(val) {}

    max_ll operator+(const max_ll& other) const {
        return max_ll(max(val, other.val));
    }
};

struct add_op {
    ll val;

    add_op() : val(0) {}
    add_op(ll val) : val(val) {}

    max_ll operator()(const max_ll& x) const {
        return max_ll(val + x.val);
    }

    add_op operator()(const add_op& other) const {
        return add_op(val + other.val);
    }
};

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

    int N;
    ll M;
    cin >> N >> M;

    vll A(M);
    vi L(M);
    vi R(M);
    vvi Rs(N+1);

    for(int i=0;i<M;i++) {
        cin >> L[i] >> R[i] >> A[i];
        Rs[R[i]].push_back(i);
    }

    segment_tree_lazy<max_ll, add_op> segdp(N+1);

    for(int i=1;i<=N;i++) {
        max_ll cur = segdp(0, i);
        segdp.replace(i, cur);

        for (int j : Rs[i]) {
            segdp(L[j], R[j]+1, add_op(A[j]));
        }
    }

    cout << segdp(1, N+1).val << endl;

    return 0;
}

Measured memory_bytes: 19072
<?php
  fscanf(STDIN,"%d%d",$N,$L);
  $R=$L+$N-1;
  $sum=$L*$N+$N*($N-1)/2;
  $m=$L;
  if($L<=0&&$R>=0)$m=0;
  else if($R<0)$m=$R;
  echo $sum-$m;

Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[100005] = {}, b[3] = {};
    ll z = 1;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
        int c = 0, d = -1;
        if (b[0] == a[i]) c++, d = 0;
        if (b[1] == a[i]) c++, d = 1;
        if (b[2] == a[i]) c++, d = 2;
        if (d != -1) b[d]++;
        z = z * c % mod;
        sort(b, b + 3);
    }
    cout << z;
}


Measured memory_bytes: 640
import java.util.*;

public class Main{
  public static void main(String[] args) throws Exception{
	Scanner sc = new Scanner(System.in);
    List<Integer> numList = new ArrayList<>();
    while(sc.hasNextInt()){
        numList.add(sc.nextInt());
    }
    int total = numList.stream().reduce(0,(s1,s2) -> s1 + s2);
    double result = Math.ceil(total / 2.0);
    System.out.println((int)result);
  }
}

Measured memory_bytes: 28756
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,M=get_i
H=get_i
ans=array(N,-1)
M.times do|i|
    a,b=get_i
    a-=1
    b-=1
    ans[a]=H[b] if ans[a]<H[b]
    ans[b]=H[a] if ans[b]<H[a]
end
res=0
H.each_with_index do|h,i|
    if h>ans[i]
        res+=1
    end
end
puts res

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

map <int,int> Mapita;

int main(){
	int A,B,C;
	scanf ("%d %d %d",&A,&B,&C);
	Mapita[A]++;
	Mapita[B]++;
	Mapita[C]++;
	if (Mapita[5]>=2 && Mapita[7]>=1){
		cout << "YES";
	}else{
		cout << "NO";
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

int main(){
  ll n;cin>>n;
  vll a(n),dp(n,MOD);//長さがi+1であるような増加部分列における最終要素の最小値
  rep(i,0,n){
    cin>>a[i];
  }
  ll ans=0;
  rep(i,0,n){
    *lower_bound(dp.begin(),dp.end(),a[i])=a[i];
  }
  ll it=lower_bound(dp.begin(),dp.end(),MOD)-dp.begin();
  cout<<it<<endl;
}






Measured memory_bytes: 4316
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int n,m,sum=0;
	cin>>n;
	vector<int>a(n),b(n-1);
	rep(i,n-1)cin>>b[i];
	rep(i,n-1){
	    a[b[i]-1]++;
	}
	rep(i,n)cout<<a[i]<<endl;
	return 0;
}


Measured memory_bytes: 4788
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

lint sumrank(string s) {
	//各位の和を返す
	lint ret = 0;
	for (int i = 0; i < s.size(); i++)ret += (s[i] - '0');
	return ret;
}

int main() {
	string N;
	cin >> N;
	lint A = sumrank(N);
	if (A % 9 == 0) {
		cout << "Yes" << enld;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3856
#include<iostream>
using namespace std;
int main(){
	int n,m,c,count=0;
	cin>>n>>m>>c;
	int b[m];
	for(int i=0;i<m;i++)cin>>b[i];
	for(int i=0;i<n;i++){
		int num,total=c;
		for(int j=0;j<m;j++){
			cin>>num;
			total+=num*b[j];
		}
		if(total>0)count++;
	}
	cout<<count<<endl;
}

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

#define MAXN 101
int cmp(const void *a,const void *b)
{
	return *(int*)a-*(int*)b;
	
}
int main(void)
{
	int N,i,a[MAXN],Alice=0,Bob=0,r=1;
	scanf("%d",&N);
	i=0;

	for(i=0;i<N;i++)
		scanf("%d",a+i);
	
	qsort(a,N,sizeof(a[0]),cmp);
	for(i=N-1;i>=0;i--)
	{
		if(r==1)
			Alice+=a[i];
		else
			Bob+=a[i];
		r=-r;
	
	}

	printf("%d\n",Alice-Bob);

	return 0;

	
}


Measured memory_bytes: 128
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for i in range(n):
    for j in range(i):
        for k in range(j):
            if l[i] == l[j] or l[k] == l[j] or l[k] == l[i]:
                continue
            if l[i] + l[j] > l[k] and l[i] + l[k] > l[j] and l[j] + l[k] > l[i]:
                cnt += 1
print(cnt)

Measured memory_bytes: 9196
# -*- coding: utf-8 -*-
"""
Created on Fri May 15 00:52:33 2020

@author: Kanaru Sato
"""

import fractions

def divnum(x,y,n):
    if x%n == 0:
        return y//n - x//n + 1
    else:
        return y//n - x//n

a,b,c,d = list(map(int,input().split()))
cd = (c*d)//fractions.gcd(c,d)
ans = divnum(a,b,c) + divnum(a,b,d) - divnum(a,b,cd)
print(b-a+1-ans)

Measured memory_bytes: 5048
import java.util.Scanner;
import java.lang.Math;

public class Main{

	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
		double r;
		double l,s;

		r = sc.nextDouble();

		l = 2*r*Math.PI;
		s = r*r*Math.PI;

		System.out.println(String.format("%.6f", s)+" "+String.format("%.6f", l));

		sc.close();
	}

}


Measured memory_bytes: 28204
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
using str=string;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int main(){
    ios::sync_with_stdio(false);
    int n; cin >> n;
    if(n%2==0) cout << n/2 << endl;
    else cout << (n+1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long h = in.nextLong(), w = in.nextLong();
        int n = in.nextInt();
        Map<Long, Integer> map = new HashMap<>();
        int[] dx = {0, 0, 1, 1, 1, 0, -1, -1, -1};
        int[] dy = {0, -1, -1, 0, 1, 1, 1, 0, -1};
        for(int i = 0; i < n; i++) {
            int a = in.nextInt() - 1, b = in.nextInt() - 1;
            for(int k = 0; k < 9; k++) {
                int y = a + dy[k], x = b + dx[k];
                if(x < 1 || w-1 <= x || y < 1 || h-1 <= y) {
                    continue;
                }
                long key = (long)y<<32|x;
                Integer val = map.get(key);
                map.put(key, val == null ? 1 : val + 1);
            }
        }
        System.out.println((h-2) * (w-2) - map.size());
        long[] cnt = new long[10];
        for(long key: map.keySet()) {
            cnt[map.get(key)]++;
        }
        for(int i = 1; i < 10; i++) {
            System.out.println(cnt[i]);
        }
    }
}

Measured memory_bytes: 224096
// Problem : E - Red Scarf
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define Sort(a)	sort(a.begin(),a.end())
#define rev(a)	reverse(a.begin(),a.end())
#define all(a)	(a).begin(),(a).end()
#define vll vector<long long int>
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 1e18

#define MAX 200005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}
lli Ceil(lli a,lli b){lli res=a/b;if(a%b!=0)	res++;return res;}

template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

lli dxx[]={1,1,0,-1,-1,-1,0,1};
lli dyy[]={0,1,1,1,0,-1,-1,-1};
lli dx[]={1,0,-1,0};
lli dy[]={0,1,0,-1};

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void solve(lli the)
{
	char ch;
	db aa,bb,cc,dd,xx;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,d,n,m,l,r,x,y,z,low,high,mid,sum=0,ans=0,temp,t;
    cin >> n;
    vll v(n);
    cin >> v;
    x=0;
    for(i=0;i<n;i++){
    	x=(x^v[i]);
    }
    for(i=0;i<n;i++){
    	cout<<(x^v[i])<<" ";
    }
    // cout<<
    
    
}













int main()
{
	long long int t=1,c=1;
	// scanf("%lld",&t);
	while(t--){
		solve(c);
		c++;
	}
	return 0;
}
/* UJJWAL KESHRI */

Measured memory_bytes: 4756
#include <stdio.h>
#include <string.h>
int main(void) {
  char a[11],b[11],c[11];
  scanf("%s %s %s",a,b,c);
  printf("%s\n",(a[strlen(a)-1]==b[0] && b[strlen(b)-1]==c[0])?"YES":"NO");
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
int main()
{
	double x[2],y[2];
	double length,z;
	scanf("%lf %lf %lf %lf",&x[0],&y[0],&x[1],&y[1]);
	z=pow(x[0]-x[1],2)+pow(y[0]-y[1],2);
	length=sqrt(z);
	printf("%f",length);
	return 0;
}



Measured memory_bytes: 2040
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, m;
    cin >> n >> m;    
 
    vvl G(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
    }
 
    ll sv, tv;
    cin >> sv >> tv;
    sv--;  tv--;
 
    vvl dist(n, vl(3, -1));  // dist[i][j] : 移動距離がmod3でjとなる頂点svから頂点iまでの最短距離
    queue<pair<ll, ll>> Q;
 
    dist[sv][0] = 0;
    Q.push(make_pair(sv, 0));
    while(!Q.empty()) {
        ll v = Q.front().first;
        ll c = Q.front().second;
        Q.pop();
        for(auto u : G[v]) {
            ll nc = (c + 1)%3;
            if(dist[u][nc] != -1) {
                continue;
            }
            dist[u][nc] = dist[v][c] + 1;
            Q.push(make_pair(u, nc));
        }
    }
 
    ll ans = dist[tv][0];
    if(ans != -1) {
        ans /= 3;
    }
 
    out(ans);
    re0;
}

Measured memory_bytes: 11136
#include <cstdio>

using namespace std;
int n,i,x,y,m[104],t[104],v[104];
double d;
int main()
{
    scanf ("%d", &n);
    for (i=1;i<=n;i++)
        scanf ("%d", &t[i]);
    for (i=1;i<=n;i++)
        scanf ("%d", &v[i]);
    m[n+1]=0;
    for (i=n;i>=2;i--)
    {
        if ((m[i+1]+t[i])<=v[i])
            m[i]=m[i+1]+t[i];
        else
            m[i]=v[i];
    }
    x=0;
    d=0.0;
    for (i=1;i<=n;i++)
    {
        if (m[i+1]<=v[i])
            y=m[i+1];
        else
            y=v[i];
        if ((x+t[i])<=y)
        {
            d=(0.0)+d+(1.0)*(2*x+t[i])*t[i]/2;
            x=x+t[i];
        }
        else if ((v[i]-x+v[i]-y)>=t[i])
        {
            d=(0.0)+d+(1.0)*(x+y+(1.0)*(t[i]-y+x)/2)*(y-x+(1.0)*(t[i]-y+x)/2)/2+(1.0)*(y+(1.0)*(t[i]-y+x)/2+y)*(t[i]-y+x)/4;
            x=y;
        }
        else
        {
            d=(0.0)+d+(1.0)*(x+v[i])*(v[i]-x)/2;
            d=(0.0)+d+(1.0)*(v[i]+y)*(v[i]-y)/2;
            d=(0.0)+d+(1.0)*v[i]*(t[i]-2*v[i]+x+y);
            x=y;
        }
    }
    printf ("%10f", d);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>

int main(void) {
    int x, t;
    scanf("%d %d", &x, &t);
    int ans = x - t;
    if (ans < 0) ans = 0;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256