akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long A, long long B){
	if (A <= 9 && B <= 9) cout << A*B << endl; else cout << "-1" << endl;
}

int main(){	
	long long A;
	long long B;
	scanf("%lld",&A);
	scanf("%lld",&B);
	solve(A, B);
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int a[300];
int n,tot;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+2*n+1);
	for(int i=1;i<=2*n;i+=2)
		tot+=a[i];
	printf("%d\n",tot);
	return 0;
}


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

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

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

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N;

  cin >> N;
  cout << (1000 - N % 1000) % 1000 << endl;

  return 0;
}

Measured memory_bytes: 3648
# solution

data=int(input())

abc=[list(map(int,input().split())) for _ in [0]*(data-1)]

q,k=map(int,input().split())

array1=[list(map(int,input().split())) for _ in [0]*q]

k-=1

tree=[[] for _ in [0]*data]

dist=[-1]*data

dist[k]=0

[tree[a-1].append([b-1,c]) for a,b,c in abc]

[tree[b-1].append([a-1,c]) for a,b,c in abc]

q=[k]

while(q):
	qq=[]
	for i in q:
		for j,k in tree[i]:
			if dist[j]<0:
				dist[j]=dist[i]+k
				qq.append(j)
	q=qq

for x,y in array1:
	print(dist[x-1]+dist[y-1])


Measured memory_bytes: 91044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1000000007;
struct UnionFind{
    vector<long long> par,height,size;
    UnionFind(ll N): par(N),height(N),size(N){
        for(ll i=0;i<N;i++){
            par.at(i)=i;
            height.at(i)=1;
            size.at(i)=1;
        }
    }

    ll root(ll x){
        if(par.at(x)==x)return x;
        return root(par.at(x));
    }

    void unite(ll x,ll y){
        ll rx=root(x);
        ll ry=root(y);
        if(rx!=ry){
            if(height.at(rx)<height.at(ry)) swap(rx,ry);
            size.at(rx)+=size.at(ry);
            height.at(rx)=max(height.at(ry)+1,height.at(rx));
            par.at(ry)=rx;
        }
    }

    bool same(ll x,ll y){
        if(root(x)==root(y))return true;
        else return false;
    }
    
};
int main(){
    ll N,M;
    cin>>N>>M;
    vector<ll> p(N);
    for(ll i=0;i<N;i++)cin>>p.at(i);
    vector<ll> x(M),y(M);
    for(ll i=0;i<M;i++)cin>>x.at(i)>>y.at(i);

    UnionFind tree(N);
    for(ll i=0;i<M;i++){
        tree.unite(x.at(i)-1,y.at(i)-1);
    }

    ll ans=0;

    for(ll i=0;i<N;i++){
        if(tree.same(i,p.at(i)-1))ans++;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int dp[1000100][2];

int main(){
  string s;
  cin >> s;

  reverse(s.begin(), s.end());
  s += '0';
  int n = s.size();
  fill((int*)dp, (int*)dp + sizeof(dp) / sizeof(int), INF);
  dp[0][0] = 0;
  for(int i = 0; i < n; ++i){
  	for(int j = 0; j < 2; ++j){
  		int d = s[i] - '0';
  		d += j;
  		if(d <= 9)dp[i + 1][0] = min(dp[i + 1][0], dp[i][j] + d);
  		if(d)dp[i + 1][1] = min(dp[i + 1][1], dp[i][j] + 10 - d);
  	}
  }

  cout << dp[n][0] << endl;
  return 0;
}


Measured memory_bytes: 9220
/* 
	Name: Mohit Khare
	CSE - MNNIT Allahabad
	never give up!!
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define ALL(x) x.begin(), x.end()
#define fastandfurious ios_base::sync_with_stdio(false);
#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define mp make_pair
#define X first
#define Y second

#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b) for(int i=a;i<b;i++)
#define revr(i,a,b) for(int i=a;i>b;i--)
#define pr1(a) cout<<a<<endl;
#define pr2(a,b) cout<<a<<" "<<b<<endl;

const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
#define linf 99999999999999999ll	
#define PI 3.1415926535897932384626
#define mod 1000000007
const int maxn=1e5+1;

ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

deque<char> st;
int main()
{
	//freopen("input.in","r",stdin);
    //freopen("output.txt","w",stdout);
	fastandfurious
	int n;
	cin>>n;
	string s;
	cin>>s;
	int l = s.length(),cnt = 0,ans = -1,cnt2=0,r=0;
	for(int i = 0 ;i < l;i++)
	{
		if(s[i]=='(')
		{
			if(r<0)
			{
				while(r!=0)
				{
					st.push_back(')');
					r++;
				}
				st.push_back('(');
				cnt++;
				r++;
			}
			else
			{
				st.push_back('(');
				cnt++;
				r++;
			}
		}
		else
		{
			if(r<=0 && cnt==0)
			{
				st.push_front('(');
				r--;
			}
			else
			{
				st.push_back(')');
				cnt--;
				r--;
			}
		}
	}
	cnt2 = 0;
	string res;
	int f = 0;
	while(!st.empty())
	{
		if(st.back() == '(' && f==0)
			cnt2++;
		if(st.back() == ')')
			f=1;
		res+=st.back();
		st.pop_back();
	}
	int l2 = res.length();
	for(int i = l2-1; i >= 0;i--)
		cout<<res[i];
	for(int i = 0 ; i < abs(r);i++)
		cout<<")";
	cout<<endl;
	return 0;	
}

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

signed main()
{
	int r;
	cin>>r;
	double ans=1.0*r*2*3.14159265358979323846;
	
	cout<<fixed<<setprecision(20)<<ans<< endl;
	return 0;
}

Measured memory_bytes: 3788
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     
     ll a,b,c,d;
     cin>>a>>b>>c>>d;
     ll i,j,k;
     ll f=0;
     while(1)
     {
       if(f==0)
       {
         c-=b;
         if(c<=0) return cout<<"Yes",0;
       }
       else 
       {
          a-=d;
          if(a<=0) return cout<<"No",0;
       }
       f=1-f;
     }
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 3628
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	string s;
	cin >> s;
	s = "0" + s;
	int dp[s.size()][2] = {};
	dp[0][0] = 0;
	dp[0][1] = 1;
	REP1(i, s.size()-1){
		int num = s[i] - '0';
		dp[i][0] = min(dp[i-1][0] + num, dp[i-1][1] + 10 - num);
		dp[i][1] = min(dp[i-1][0] + num + 1, dp[i-1][1] + 10 - (num + 1));
	}
	cout << dp[s.size()-1][0] << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i < n + 1; ++i) cin >> a[i];
    vector<int> ans(n + 1, 0);
    for (int j = n; j > 0; --j) {
        if (j * 2 > n) ans[j] = a[j];
        else {
            int cnt = 0;
            for (int i = j * 2; i <= n; i += j) cnt += ans[i];
            cnt %= 2;
            ans[j] = a[j] - cnt;
            if (ans[j] < 0) ans[j] += 2;
            ans[j] %= 2;
        }
    }
    int cnt = 0;
    for (int k = 1; k < n + 1; ++k) if (ans[k] == 1) cnt++;
    cout << cnt << endl;
    for (int k = 1; k < n + 1; ++k) if (ans[k] == 1) cout << k << " ";
    cout << endl;
}


Measured memory_bytes: 2432
#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;
const int INF=-2000000000;
int main() {
  ll n,W;
  cin >> n >> W;
  vector<ll> w(n),v(n);
  rep(i,n) cin >> w[i] >> v[i];
  vector<vector<ll>> dp(n+1,vector<ll>(W+1,0));
  for(int i=0; i<n; i++){
    for(int sum_w=0; sum_w<=W; sum_w++){
      if(sum_w-w[i]>=0){
        dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w-w[i]]+v[i]);
      }
      dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w]);
    }
  }
  cout << dp[n][W] << endl;
}

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


int main()
{
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a);
  vector<int> q(b);
  vector<int> r(c);
  rep(i, a)
    cin >> p[i];
  rep(i, b)
    cin >> q[i];
  rep(i, c)
    cin >> r[i];
  sort(p.begin(), p.end());
  sort(q.begin(), q.end());
  sort(r.begin(), r.end());
  int idp, idq, idr;
  idp = a - x;
  idq = b - y;
  idr = c - 1;
  ll ans = 0;
  while (idr >= 0)
  {
    if (idp < a && idq < b)
      if (p[idp] <= q[idq])
        if (p[idp] < r[idr])
        {
          ans += r[idr];
          idp++; idr--;
        }
        else
          break;
      else
        if (q[idq] < r[idr])
        {
          ans += r[idr];
          idq++; idr--;
        }
        else
          break;
    else if (idp == a && idq == b)
      break;
    else if (idp == a)
      if (q[idq] < r[idr])
      {
        ans += r[idr];
        idq++; idr--;
      }
      else
        break;
    else if (idq == b)
      if (p[idp] < r[idr])
      {
        ans += r[idr];
        idp++; idr--;
      }
      else
        break;
  }
  while (idp < a)
  {
    ans += p[idp];
    idp++;
  }
  while (idq < b)
  {
    ans += q[idq];
    idq++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <utility>
#define FR first
#define SE second
#define y1 yy

using namespace std;

typedef pair<int,int> pr;

namespace SGT {

int maxn[800000];

void update(int l,int r,int o,int p,int q) {
  if (l==r) maxn[o]=max(maxn[o],q);
  else {
  	int m=((l+r)>>1);
  	if (m>=p) update(l,m,o*2,p,q);
  	else update(m+1,r,o*2+1,p,q);
  	maxn[o]=max(maxn[o*2],maxn[o*2+1]);
  }
}

int query(int l,int r,int o,int lx,int rx) {
  if (l>=lx&&r<=rx) return maxn[o];
  else {
  	int m=((l+r)>>1);
  	if (m>=rx) return query(l,m,o*2,lx,rx);
  	if (m<lx) return query(m+1,r,o*2+1,lx,rx);
  	return max(query(l,m,o*2,lx,rx),query(m+1,r,o*2+1,lx,rx));
  }
}

}

int r,c;

inline int id(int x,int y) {
  if (x==0) return y;
  if (y==c) return c+x;
  if (x==r) return c+r+c-y;
  if (y==0) return c+r+c+r-x;
  return -1;
}

int num[200005];
pr a[100005];

int main() {
  int n;
  scanf("%d%d%d",&r,&c,&n);
  int m=0;
  for(int i=1;i<=n;i++) {
  	int x1,y1,x2,y2;
  	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
  	int p=id(x1,y1),q=id(x2,y2);
  	if (p!=-1&&q!=-1) {
  		if (p>q) swap(p,q);
  		a[++m]=pr(p,q);
  		num[2*m-1]=p;
  		num[2*m]=q;
	  }
  }
  sort(num+1,num+2*m+1);
  for(int i=1;i<=m;i++) {
  	a[i].FR=lower_bound(num+1,num+2*m+1,a[i].FR)-num;
  	a[i].SE=lower_bound(num+1,num+2*m+1,a[i].SE)-num;
  }
  sort(a+1,a+m+1);
  for(int i=m;i>0;i--) {
  	if (a[i].FR+1<a[i].SE&&SGT::query(1,2*m,1,a[i].FR+1,a[i].SE-1)>a[i].SE) {
  		puts("NO");
  		return 0;
	  }
	SGT::update(1,2*m,1,a[i].FR,a[i].SE);
  }
  puts("YES");
  return 0;
}

Measured memory_bytes: 4224
# 参考:https://atcoder.jp/contests/abc112/submissions/14491766
import sys
input = lambda: sys.stdin.readline().rstrip()
 
l = []
for _ in range(int(input())):
    t = list(map(int,input().split()))
    l.append(t)
    if t[2]: 
        x,y,h = t[0], t[1], t[2]
        
for X in range(101):
    for Y in range(101):
        H = h + abs(x - X) + abs(y - Y)
        if all(h==max(H - abs(x-X) - abs(y-Y), 0) for x,y,h in l): print(X, Y, H)

Measured memory_bytes: 75212
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define inf 0x3f3f3f3f
#define MM (1<<20)
#define MN 200005
using namespace std;
inline int in(){
    int x=0;bool f=0; char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
vector<int> v[MN];
int mn[MM],f[MN],b[MN],sum[MN];
int n,l,r,M,q;
inline void update(int x,int v){
	for (x+=M;x;x>>=1) mn[x]=min(mn[x],v);
}
inline int query (int l,int r){
	int res=inf;
	for (l+=M-1,r+=M+1;l^r^1;l>>=1,r>>=1){
		if (~l&1) res=min(res,mn[l^1]);
		if ( r&1) res=min(res,mn[r^1]);
	}return res;
}
int main()
{
	n=in();memset(f,0x3f,sizeof(f));f[0]=0;
	for (int i=1;i<=n;++i) b[i]=in(),sum[i]=sum[i-1]+1-b[i];
	memset(mn,0x3f,sizeof(mn));
	for (M=1;M<n+2;M<<=1);q=in();
	for (int i=1;i<=q;++i){
		l=in();r=in();v[l-1].push_back(r);
	}
	for (int i=0;i<n;++i){
		f[i+1]=min(f[i+1],f[i]+b[i+1]);
		int siz=v[i].size();
		for (int j=0;j<siz;++j){
			int dis=min(f[i]+sum[v[i][j]]-sum[i],sum[v[i][j]]+query(i+1,v[i][j]));
			f[v[i][j]]=min(f[v[i][j]],dis);
			update(v[i][j]+1,dis-sum[v[i][j]]);		
		}
	}printf("%d",f[n]);return 0;
}

Measured memory_bytes: 15360
N = input()
s = []
flaga = 0
flagbs = 0
flagba = 0
Aend = 0
Bstart = 0
AB = 0
flaginit = 0
for i in range(N):
	s.append(raw_input())
for s2 in s:
	flaginit = 1
	flaga = 0
	flagbs = 0
	for c in s2:
		if flaginit == 1:
			if c =='A':
				flaga = 1
			elif c =='B':
				Bstart += 1
				flagbs = 1
			flaginit = 0
		else:
			if c == 'A':
				flaga = 1
			elif c =='B':
				if flaga == 1:
					AB += 1
				flaga = 0
			else:
				flaga = 0
	if flaga == 1:
		Aend += 1
		if flagbs == 0:
			flagba = 1
	else:
		if flagbs == 1:
			flagba = 1
if(flagba == 0 and Aend > 0):
	Aend -= 1
AB += min(Aend,Bstart,N-1)
print(AB)

Measured memory_bytes: 3452
#include <iostream>
#include <algorithm>

#define REP(i,n) for(int i = 1; i <= n; i++)
#define ll long long
#define PI 3.141592653589

using namespace std;

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

    bool flag = false;
    REP(i,9){
        if(N % i == 0 && N / i <= 9) flag = true;
    }
    
    if(flag == true) cout << "Yes";
    else cout << "No";
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;

double EPS=1e-9;
int INF=1000000005;
long long INFF=1000000000000000005ll;
double PI=acos(-1);
int dirx[8]={ -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8]={ 0, 1, -1, 0, -1, 1, -1, 1 };
const ll MOD = 1000000007;

#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define OUT(x) cout << x << endl
#define OUTH(x) cout << x << " "
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define READ(x) for(auto &(z):x) cin >> z;
#define FOR(a, b, c) for (int(a)=(b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a)=(b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a)=(b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a)=(b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a)=(b); (a) <= (c); ++(a))
#define EACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define MAX(a, b) a=max(a, b)
#define MIN(a, b) a=min(a, b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define TC(t) while (t--)
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)


//ll roundDown(ll n, ll m) {
//    return n>=0?(n/m)*m:((n-m+1)/m)*m;
//}
//
//ll roundUp(ll n, ll m) {
//    return n>=0?((n+m-1)/m)*m:(n/m)*m;
//}

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

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

//    int tc; cin >> tc;
//    TC(tc) solve();
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	// last + first - both + neither
//	ll x1 = b-a+1;
//	ll x2 = ((roundDown(b,c)-roundUp(a,c))/c)*(roundDown(b,c)==0?0:1)*(roundUp(a,c)==0?0:1)+1;
//	ll x3 = ((roundDown(b,d)-roundUp(a,d))/d)*(roundDown(b,d)==0?0:1)*(roundUp(a,d)==0?0:1)+1;
//	ll x4 = ((roundDown(b,c*d)-roundUp(a,c*d))/c*d)*(roundDown(b,c*d)==0?0:1)*(roundUp(a,c*d)==0?0:1)+1;
//	cout << roundDown(b,c) << " " <<roundUp(a,c) << endl;
//	cout << roundDown(b,d) << " " <<roundUp(a,d) << endl;
//	cout << roundDown(b,c*d) << " " <<roundUp(a,c*d) << endl;
//	cout << x1 << " " << x2 << " " << x3 << " " << x4 << endl;
	ll e = lcm(c,d);
	ll x1 = b-a+1;
	ll x2 = b/c-(a-1)/c;
	ll x3 = b/d-(a-1)/d;
	ll x4 = b/e-(a-1)/e;
	OUT(x1-x2-x3+x4);
    return 0;
}

Measured memory_bytes: 3640
#include <string>
#include <iostream>
#include <vector>
#include <sstream>

using namespace::std;

void inputNums(vector<int> &nums){
  string input;


  getline(cin, input);

  stringstream ss(input);

  string buf;

  while(!ss.eof()){
    ss >> buf;
    nums.push_back(stoi(buf));
  }

}

int main(void){
  int num;
  cin >> num;

  int tmp = num;
  auto res = "Yes";

  int cnt=0;
  while(true){
    tmp=num;
    tmp-=7*cnt;
    if(tmp<0) break;
    if(tmp%4==0) {res = "Yes";break;}
    else res = "No";
    cnt++;
  }

  cout << res << endl;
  return 0;
}



Measured memory_bytes: 256
def solve():
  n= int(input())
  a = list(int(i) for i in input().split())
  
  odd = 0
  even = 0
  for i in a:
    if i%2 == 0: even += 1
    else: odd+= 1
  if odd %2 == 1 :
    return('NO')
  else:  
    return('YES')
  
  
  
if __name__ == '__main__':
  print(solve())

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

using namespace std;
int main(){
  int n,y;
  cin >> n >> y;
  for(int mai_1k=0; mai_1k<=n; mai_1k++){
    for(int mai_5k=0; mai_5k<=n-mai_1k; mai_5k++){
      int mai_10k = n-mai_1k-mai_5k;
      int sum = 1000*mai_1k + 5000*mai_5k + 10000*mai_10k;
      if(sum == y){
        cout << mai_10k << " " << mai_5k << " " << mai_1k << endl;
        return 0;
        }
    }
  }

  cout << -1 << " " << -1 << " " << -1 << endl; 

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MX = 1e5+2;
vector<int> adj[MX];
int dist[MX][3];
struct info {
	int u, dep;
};
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n, m;
	cin >> n >> m;
	while(m--) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
	}
	int s, t;
	cin >> s >> t;
	memset(dist, 0x3f, sizeof dist);
	dist[s][0] = 0;
	queue<int> que;
	que.push(s);
	int d = 0, nxtd;
	while(que.size()) {
		int sz = que.size();
		nxtd = d == 2 ? 0 : d+1;
		while(sz--) {
			int q = que.front();
			que.pop();
			for(int a: adj[q]) {
				if(dist[q][d]+1 < dist[a][nxtd]) {
					dist[a][nxtd] = dist[q][d]+1;
					que.push(a);
				}
			}
		}
		d = nxtd;
	}
	cout << (dist[t][0] == 0x3f3f3f3f ? -1 : dist[t][0]/3);
}

Measured memory_bytes: 6912
/*
***************************************************************************
 name  : ITP1_09_B.cpp
 title : Shuffle
 make  : 2018/09/05 tanabe
***************************************************************************
*/

// Library
#include <iostream>  // standard input output object
#include <cstring>   // character functions

main(void){
  std::string str;  // string
  std::string temp; // temporary
  int m;            // shuffle count
  int h;            // shuffle number
  int len;          // length
  int i,j;          // index

  // initialized input "str"
  // continue str != -
  // input "str" at loop update
  for(std::cin >> str;str != "-";std::cin >> str){
    len = str.length(); //
    std::cin >> m;      // input "m"
    // initialized i = 0
    // continue i < m
    // increment i at loop update
    for(i = 0;i < m;i++){
      std::cin >> h; // input "h"
      temp = str;
      // initialized j = 0
      // continue j < h
      // increment j at loop update
      for(j = 0;j < h;j++){
        temp += str[j];
      }
      // initialized j = 0
      // continue j < len
      // increment j at loop update
      for(j = 0;j < len;j++){
        str[j] = temp[j+h];
      }
    }
    std::cout <<  str << std::endl; // output "str"
  }

}



Measured memory_bytes: 3176
from collections import defaultdict

n = int(input())
a = [int(x) for x in input().split()]

cnt = defaultdict(int)
for v in a:
  cnt[v] += 1

ans = 0
for v in cnt:
  ans += cnt[v]*(cnt[v]-1)//2

for v in a:
  print(ans + (cnt[v]-1)*(cnt[v]-2)//2 - cnt[v]*(cnt[v]-1)//2)

Measured memory_bytes: 110040
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
string s;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  int n = sz(s), c = 0;
  ll ans = 0;
  FOR(i, 0, n){
    if(s[i]-'0'){
      ans += modPow(2, c, MOD)*modPow(3, n-i-1, MOD) % MOD;
      c++;
    }
  }
  ans += modPow(2, c, MOD);
  cout << ans%MOD << endl;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
//#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

const int N=1e5+100;
int g[N];


void smain() {

    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        g[a]++;
        g[b]++;
    }
    for(int i=1;i<=n;i++){
        if(g[i]%2==1){
            cout<<"NO";
            return;
        }
    }
    cout<<"YES";

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str;
//legendary n000b
#define endl "\n"

const int MOD = 1000000007;


int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
	int a, b;
  cin >> a >> b;
  cout << a * b << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}

int main() {
	// D , D , 앳코더 1회 ㄱ? 
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n; cin >> n;
	if (n >= 1000) {
		cout << "ABD" << '\n';
	}
	else {
		cout << "ABC" << '\n';
	}
	

}

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

int N;
ll A[20][20],dp[1<<16] = {},value[1<<16] = {};

int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			cin >> A[i][j];
		}
	}
	for(int S=1;S<(1<<N);S++){
		for(int i=0;i<N;i++){
			if(S & (1<<i)){
				int T = S & ~(1<<i);
				value[S] = value[T];
				for(int j=0;j<N;j++){
					if(T & (1<<j)) value[S] += A[i][j];
				}
				break;
			}
		}
	}
	for(int S=1;S<(1<<N);S++){
		for(int T=S;T>0;T=((T-1)&S)){
			dp[S] = max(dp[S],dp[S^T]+value[T]);
		}	
	}
	cout << dp[(1<<N)-1] << endl;
}

Measured memory_bytes: 1280
n, l = map(int, input().split())

# 味リスト
tastes = []
for i in range(n):
    tastes += [l+i]

# 全部
all_tastes = sum(tastes)

# 食ったあとの味リスト
ptn = []
for x in tastes:
    ptn += [all_tastes - x]

# 元との差(abs)
di = []
for i in range(n):
    di += [abs(all_tastes - ptn[i])]

min_value = min(di)
print(ptn[di.index(min_value)])

Measured memory_bytes: 3064
N = int(input())
S = input()

lset = [0]
for c in S:
    lset.append(lset[-1] | (1<<int(c)))

rset = [0]
for c in S[::-1]:
    rset.append(rset[-1] | (1<<int(c)))
rset.reverse()

ptns = [set() for i in range(10)]
for i,c in enumerate(S):
    for j in range(10):
        if lset[i] & (1<<j) == 0: continue
        for k in range(10):
            if rset[i+1] & (1<<k) == 0: continue
            ptns[int(c)].add(j*10 + k)

print(sum(len(p) for p in ptns))

Measured memory_bytes: 43372
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	string S; cin >> S;
	rep(i, 0, S.size()) {
		if (i == 4)cout << " ";
		cout << S[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int res=0;
    int a[100],b[100];
    for(int i=1;i<=n;i++)
        {
            cin>>a[i];
        }
    for(int i=1;i<=n;i++)
        {
            cin>>b[i];
        }
    for(int i=1;i<=n;i++)
        {
            if(a[i]>b[i])
                res+=a[i]-b[i];
        }
        cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
line = input()
V = [int(n) for n in line.split()]
line = input()
C = [int(n) for n in line.split()]
X=0
Y=0
for i in range(N):
    if V[i] > C[i]:
        X+=V[i]
        Y+=C[i]
print(X-Y)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    float cp,cf;
    int n;
    cin>>n;
    cp=n*1.0;
    if(n%2==1){
        cf=n/2+1;
    }
    else{
        cf=n/2;
    }
    cout<<cf/cp;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
char field[51][51];
int W, H;

void dfs(int x, int y) {
  //cout << "field[x][y] = " << field[x][y] << endl;
  field[x][y] = '0';
  
  for(int dx = -1 ; dx <= 1 ; dx++) {
    for(int dy = -1 ; dy <= 1 ; dy++) {
      int nx = x + dx, ny = y + dy;
      if(0 <= nx && nx < H && 0 <= ny && ny < W && field[nx][ny] == '1') dfs(nx, ny);
    }
  }
}

int main(void) {
  while(cin >> W >> H, W != 0 && H != 0) {
    int res = 0;
    for(int i = 0 ; i < H ; i++)
      for(int j = 0 ; j < W ; j++) cin >> field[i][j];
    
    for(int i = 0 ; i < H ; i++) {
      for(int j = 0 ; j < W ; j++) {
	if(field[i][j] == '1') {
	  dfs(i, j);
	  res++;
	  /*cout << endl;
	  for(int b = 0 ; b < H ; b++) {
	    for(int a = 0 ; a < W ; a++) {
	      cout << field[b][a] << ' ';
	    }
	    cout << endl;
	  }
	  cout << endl;*/
	}
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

int K;
const int MAX = 1100000;

int check(vector<int> &A, int x){
	vector<int> div, sum1, sum2;
	int res = INF;
	
	for(int i = 0; i < A.size(); i++){
		if(A[i]%x) div.push_back(A[i]%x);
	}
	
	if(!div.size()) return false;
	
	sort(div.begin(), div.end());
	
	sum1.resize(div.size()+2,0);
	sum2.resize(div.size()+2,0);
	
	for(int i = 0; i < div.size(); i++){
		sum1[i+1] += div[i];
		sum1[i+1] += sum1[i];
	}
	for(int i = div.size(); i >= 1; i--){
		sum2 [i-1] += x-div[i-1];
		sum2[i-1] += sum2[i];
	}
	// cout<<"x = "<<x<<" ------- "<<endl;
	// for(int i = 0; i < div.size(); i++) cout<<div[i]<<" ";cout<<endl;
	// for(int i = 0; i <= div.size(); i++) cout<<sum1[i]<<" ";cout<<endl;
	// for(int i = 0; i <= div.size(); i++) cout<<sum2[i]<<" ";cout<<endl;
	
	for(int i = 0; i <= div.size(); i++){
		// if(sum2[i]-sum1[i] == 0)
			res = min(res, max(sum1[i],sum2[i]));
		
	}
	
	return res <= K;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int ans = 1;
	int sum = 0;
	
	int N;
	vector<int> A;
	
	cin>>N>>K;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		sum += A[i];
	}
	
	for(int i = 1; i*i <= MAX*N; i++){
		if(sum%i) continue;
		if(check(A,i)) ans = max(i, ans);
		if(check(A,sum/i)) ans = max(sum/i, ans);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
n,m=gets.split.map &:to_i
A=n.times.map{gets.split.map &:to_i}
B=m.times.map{gets.split.map &:to_i}
puts A.map{|x,y|
	1+(0...m).min_by{|i|[(B[i][0]-x).abs+(B[i][1]-y).abs,i]}
}

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

int main() {
  int A, V, B, W, T;
  cin >> A >> V >> B >> W >> T;
  if (W >= V) return cout << "NO" << "\n", 0;
  cout << (((abs(A - B) + (V - W) - 1) / (V - W) <= T) ? "YES" : "NO") << "\n";
}

Measured memory_bytes: 3552
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsm = lambda: map(str, sys.stdin.readline().split())
nsl = lambda: list(nsm())

mod = 1000000007

n, m = nm()
dp = [0] * (n + 2)
for i in range(m):
    tmp = ni()
    dp[tmp] = -1
dp[0] = 1
for i in range(n):
    if i + 1 <= n:
        if dp[i + 1] != -1 and dp[i] != -1:
            dp[i + 1] += dp[i] % mod
            dp[i + 1] %= mod
    if i + 2 <= n:
        if dp[i + 2] != -1 and dp[i] != -1:
            dp[i + 2] += dp[i] % mod
            dp[i + 2] %= mod
print(dp[n] % mod)


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



int main(){
  int N,K;
  cin>>N>>K;
  
  double sum;
  for(int i=1;i<=N;i++){
    int a=i;
    double tmp=1.0/N;
    while(a<K){
      a*=2;
      tmp/=2;
    }
    sum+=tmp;
  }
  cout<<fixed<<setprecision(12)<<sum<<endl;
}

Measured memory_bytes: 3748
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
 
#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}
 
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mk(arr,n,type)  type *arr=new type[n];
 
clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}
int main(){
	int A,B;
	cin >> A >> B;
	cout << A*B << "\n";
	return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
int search(int *A,int n,int key);

  int main(){
  int n,q,A[10000],i,j,key,goukei=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(search(A,n,key))goukei++;
  }
  printf("%d\n",goukei);

  return 0;
}

int search(int A[],int n,int key){
  int k=0;
  A[n]=key;
  while(A[k]!=key)k++;
  return k!=n;
}


Measured memory_bytes: 2064
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
const int N=2e5+8;
const int mod=2019;
ll sum[N];
ll ten[N];
map<int,int> mp;
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	ll ans=0;
	string s; cin>>s;
	reverse(s.begin(),s.end());
	int n=(int)s.length();
	ten[0]=1;
	for(int i=1; i<=n; i++) {
		ten[i]=10*ten[i-1];
		ten[i]%=2019;
	}
	sum[0]=(s[0]-'0');
	mp[sum[0]]++;
	for(int i=1; i<n; i++) {
		int d=(s[i]-'0');
		sum[i]=d*ten[i]+sum[i-1];
		sum[i]%=2019;
		ans+=mp[sum[i]];
		mp[sum[i]]++;
	}
	ans+=mp[0];
	cout<<ans<<endl;
	return 0;
}


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

int main(){
	int n,t,a;
	cin >> n >> t >> a;
	int h[1100];
	int ans = 0;
	int oppai = 1e9;
	for(int i = 1; i<=n;++i){
		cin >> h[i];
		int K = abs((1000*t-h[i]*6)-1000*a);
		if(oppai > K){
			oppai = K;
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// 287644PV
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(6)<<(x)
const int mod = 1000000007;

void addSelf(int&x, int y)
{
    x+= y;
    if(x >= mod)
        x-=mod;
}
void subSelf(int&x, int y)
{
    x -= y;
    if(x < 0)
        x += mod;
}

int gcd(int a, int b)
{
    if(b == 0)
        return a;
    else
        return gcd(b,a%b);
}

int64_t power(int base, int expo)
{
    int64_t sol = 1;
    for (int i = 0; i <expo ; ++i) {
        sol *= base;
    }
    return sol;
}

bool compare1(pair<int,int> i,pair<int,int> j) // 1 < i < n
{
    return i.second < j.second;
}

bool compare2(pair<int,int> i, pair<int,int> j) //n > n-i > 1
{
    return i.first > j.first;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    int out = 0;
    for (auto x: s) {
        if(x == '+')
            out++;
        else
            out--;
    }
    cout << out;
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int count=0;
		int num;
		while(scan.hasNext()) {
			num=scan.nextInt();
			if(num==0) {
				break;
			}
			count+=1;
			System.out.printf("Case %d: %d\r\n",count, num);
		}
		scan.close();

	}

}


Measured memory_bytes: 67356
#include<queue>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
inline void read(int &x)
{
	x=0;
	int p=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c^'0');c=getchar();}
	x*=p;
}
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n,a,b;
	read(n);read(a);read(b);
	int minn=a*n;
	int ans=min(minn,b);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <queue>
#include <vector>
#include <iostream>
using namespace std;
const int inf = 1012345678;
int main() {
	int N, S, G;
	cin >> N;
	vector<int> D(6), A(N);
	for (int i = 0; i < 6; ++i) cin >> D[i];
	cin >> S >> G; --S, --G;
	for (int i = 0; i < N; ++i) cin >> A[i];
	vector<vector<int> > g(N);
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 6; ++j) {
			for (int k = -1; k <= 1; k += 2) {
				int nxt = i + D[j] * k;
				if (0 <= nxt && nxt < N) {
					g[nxt + A[nxt]].push_back(i);
				}
			}
		}
	}
	queue<int> que; que.push(G);
	vector<int> dist(N, inf); dist[G] = 0;
	while (!que.empty()) {
		int u = que.front(); que.pop();
		for (int i : g[u]) {
			if (dist[i] == inf) {
				dist[i] = dist[u] + 1;
				que.push(i);
			}
		}
	}
	int cur = S;
	while (cur != G) {
		int dice;
		cin >> dice; --dice;
		int res = 0;
		for (int j = -1; j <= 1; j += 2) {
			int nxt = cur + D[dice] * j;
			if (0 <= nxt && nxt < N && dist[nxt + A[nxt]] < dist[cur]) {
				res = j;
			}
		}
		cout << res << endl;
		if (res != 0) {
			cur += D[dice] * res;
			cur += A[cur];
		}
	}
	return 0;
}


Measured memory_bytes: 3312
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  string s;
  cin >> s;
  ll ans = 0;
  int cnt = 0;
  rep(i, s.size()-1) {
    if (s[i] == 'A')
      cnt++;
    else if (s[i] == 'B' && s[i+1] == 'C') {
      ans += cnt;
      i++;
    }
    else
      cnt = 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
def abc063_d():
    n, a, b = map(int, input().split())
    H = [int(input()) for _ in range(n)]
    lower, upper = 0, 10**16
    d = a - b
    while upper - lower > 1:
        x = (upper + lower) // 2
        v = 0
        for hi in H:
            v += (max(0, hi - x*b) + d - 1) // d
            if v > x: break
        if v <= x: upper = x
        else: lower = x
    print(upper)

if __name__ == '__main__':
    abc063_d()

Measured memory_bytes: 80796
#include <iostream>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define INF 1000000007

int main() {

  int N, T;
  cin >> N >> T;

  vector<ll> a(N);
  REP(i, N) cin >> a[i];

  vector<ll> mina(N), maxa(N);
  mina[0] = 0;
  maxa[N-1] = N-1;
  for (int i = 1; i < N; i++) {
    if (a[i] < a[mina[i-1]]) mina[i] = i;
    else mina[i] = mina[i-1];

    int j = N-i-1;
    if (a[j] > a[maxa[j+1]]) maxa[j] = j;
    else maxa[j] = maxa[j+1];
  }

  ll maxprof = 0;
  REP(i, N) {
    ll prof = (a[maxa[i]] - a[mina[i]]) * (T/2);
    if (maxprof < prof) {
      maxprof = prof;
    }
  }

  set<ll> s;
  REP(i, N) {
    ll prof = (a[maxa[i]] - a[mina[i]]) * (ll)(T/2);
    if (maxprof == prof) {
      s.insert(maxa[i]);
    }
  }

  cout << s.size() << endl;

  return 0;

}


Measured memory_bytes: 4992
/// 1行の文字を空白で分割してVec<T>にする。
fn read_split<T : std::str::FromStr>() -> Vec<T> {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}

fn read_one<T : std::str::FromStr>() -> T {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.trim().parse().ok().unwrap()
}

fn main() {
    let n : i32 = read_one();
    let mut h : Vec<i64> = read_split();
    h.reverse();
    if n == 1 {
        println!("Yes");
        return;
    }
    let mut ans = true;
    for i in 0..(n - 1) {
        let p = i as usize;
        if h[p] < h[p + 1] { h[p+1] -= 1 };
        if h[p] < h[p + 1] {
            ans = false;
            break;
        }
    }
    print!("{}", if ans {"Yes"} else {"No"});
}



Measured memory_bytes: 8444
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <cassert>
// using namespace std;
// #define int long long
#define REP(i,s,n) for (int i = (s); i < (n); ++i)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) for (int i = n; i >= 0; i--)
#define INF (int)(1e9+7)
#define space " "
#define ENDL "\n"
#define MAXL 100

int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};

inline void init() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
}
// アドレスを渡すのを間違えないように!!
inline void nextInt(int *a) { scanf("%d", a); }
inline void nextInt(int *a, int *b) { scanf("%d %d", a, b); }
inline void nextInt(int *a, int *b, int *c) { scanf("%d %d %d", a, b, c); }
inline void nextDouble(double *a) { scanf("%lf", a); }
inline void nextDouble(double *a, double *b) { scanf("%lf %lf", a, b); }
inline void nextDouble(double *a, double *b, double *c) { scanf("%lf %lf %lf", a, b, c); }
inline void nextLine(char *c) { scanf("%s", c); getchar();/*改行の読み捨て*/ }
inline std::string nextLine() {
    std::string s = ""; char str[MAXL+1];
    scanf("%s", str); getchar(); /*改行の読み捨て*/
    return s += str;
}
inline void print(double *a, int n = 0) {
    std::cout << std::fixed << std::setprecision(n) << *a << ENDL;
}
inline void print(long long a) {
    printf("%Ld\n", a);
}

long long ans, a, b, n, x[100005];

int main() {

    std::cin >> n >> a >> b;
    rep(i,n) std::cin >> x[i];

    for(int i = 0; i < n-1; ++i) {
        ans += std::min((x[i+1]-x[i]) * a, b);
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 1024
def Main(N):
    ans = 0
    for i in range(1,N+1):
        if i%15 == 0 or i%5 == 0 or i%3 == 0:
            continue
        else:
            ans += i
    return ans
    

def main():
    N = int(input())
    print(Main(N))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9176