akhauriyash/Code-Regression huggingface dataset:
//AUTHOR - NAVEEN KUMAR(@naveen19991124)
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#inlcude<boost/multiprecision/cpp_dec_float.hpp>
#define ll long long
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define v vector<ll>
#define mp make_pair
#define fir first
#define sec second
#define _fast_ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
//using boost :: multiprecision :: cpp_int;
//using boost :: multiprecision :: cpp_dec_float_50;
//using boost :: multiprecision :: cpp_dec_float_100;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1;
a *= a; a %= mod;} return p % mod;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int main()
{
    _fast_
    ll t = 1;
 //   cin>>t;
    while(t--){
    ll x;
    cin>>x;
    ll val = x/500;
    ll ans = 0;
    ans += val*1000;
    val = x-500*(val);
    val = val/5;
    ans = ans+val*5;
    cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, k, x, y, ans;
		
		n = sc.nextInt();
		k = sc.nextInt();
		x = sc.nextInt();
		y = sc.nextInt();
		
		if(n > k) ans = k * x + (n - k) * y;
		else ans = n * x;
		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}
/*ここから*/
long long search1(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 2;
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1%1000000007+f2%1000000007;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

int main() {
    int N,M;
    cin >> N >> M;
    long long ans = 1;
    if(M==0){
        ans = search1(N)%1000000007;
        cout << ans << endl;
        exit(0);
    }
    vector<long long> a(M);
    for(int i=0;i<M;i++){
        cin >> a[i];
        if(i>0&&a[i-1]+1==a[i]){
            cout << 0 << endl;
            exit(0);
        }
    }
    long long temp = 0;
    for(int i=0;i<M;i++){
        temp = a[i]-temp-1;
        //cout << temp << endl;
        if(temp != 0){
            ans *=search1(temp);
        }
        //cout << search(temp) << endl;
        temp = a[i]+1;
        ans %= (long long)1000000007;
    }
    ans *= search1(N-a[M-1]-1);
    //cout << search(N-a[M-1]-1) << endl;
    ans%=(long long)1000000007;
    cout << ans << endl;
}

Measured memory_bytes: 4308
class Dice:
    def __init__(self, nums):
        self.top    = nums[0]
        self.front  = nums[1]
        self.right  = nums[2]
        self.left   = nums[3]
        self.back   = nums[4]
        self.bottom = nums[5]

    def toN(self):
        tmp = self.top
        self.top = self.front
        self.front = self.bottom
        self.bottom = self.back
        self.back = tmp

    def toS(self):
        tmp = self.top
        self.top = self.back
        self.back = self.bottom
        self.bottom = self.front
        self.front = tmp

    def toE(self):
        tmp = self.top
        self.top = self.left
        self.left = self.bottom
        self.bottom = self.right
        self.right = tmp

    def toW(self):
        tmp = self.top
        self.top = self.right
        self.right = self.bottom
        self.bottom = self.left
        self.left = tmp

    def moveTo(self, ds):
        for d in ds:
            if   d == 'N':
                self.toN()
            if d == 'S':
                self.toS()
            if d == 'E':
                self.toE()
            if d == 'W':
                self.toW()

    def getTop(self):
        return self.top

    def getBottom(self):
        return self.bottom

    def getFront(self):
        return self.front

    def getBack(self):
        return self.back

    def getLeft(self):
        return self.left

    def getRight(self):
        return self.right

    def __eq__(self, other):
        if self.top != other.top:
            return False
        if self.bottom != other.bottom:
            return False
        if self.front != other.front:
            return False
        if self.back != other.back:
            return False
        if self.left != other.left:
            return False
        if self.right != other.right:
            return False

        return True

def moveTo(dice, top, front):
    if dice.getFront() != front:
        if   dice.getTop()    == front:
            dice.moveTo("S")
        elif dice.getBottom() == front:
            dice.moveTo("N")
        elif dice.getBack()   == front:
            dice.moveTo("NN")
        elif dice.getLeft()   == front:
            dice.moveTo("ES")
        elif dice.getRight()  == front:
            dice.moveTo("WS")

    if dice.getTop() != top:
        if   dice.getBottom() == top:
            dice.moveTo("EE")
        elif dice.getLeft()   == top:
            dice.moveTo("E")
        elif dice.getRight()  == top:
            dice.moveTo("W")

    return dice

def equalDice(dice1, dice2):
    dice2 = moveTo(dice2, dice1.getTop(), dice1.getFront())
    return dice1 == dice2

def main():
    dice1 = Dice(input().split())
    dice2 = Dice(input().split())

    if equalDice(dice1, dice2):
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()



Measured memory_bytes: 5580
import heapq

N, M = map(int, input().split())
a = list(map(int, input().split()))

q = []
for i in range(N):
    # 最も大きい値を取り出して1/2したいので、ここで反転させておき、最終的に足す時に戻す
    heapq.heappush(q, -a[i])
for i in range(M):
    l = heapq.heappop(q)
    heapq.heappush(q, -(-l//2))
print(-sum(q))

Measured memory_bytes: 14180
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=4e5+10;
const int mod=1e9+7;
ll fac[maxn],inv[maxn];
void gcd(ll a,ll b,ll &d,ll &x, ll &y){
	if(b){
		gcd(b,a%b,d,y,x); y-=x*(a/b);
	}
	else {
		d=a,x=1,y=0;
	}
}
void init(){
	fac[0]=fac[1]=1;
	for(int i=2;i<maxn;i++)
		fac[i]=fac[i-1]*i%mod;
}
ll c(ll n,ll k){
	ll x,y,d;
	ll tmp=(fac[k]*fac[n-k])%mod;
	gcd(tmp,mod,d,x,y);
	y=fac[n]*(x%mod)%mod;
	if(y<0) y+=mod;
	return y;
}
int main(){
	ll n,k;
	init();
	cin>>n>>k;
	ll ans=c(2*n-1,n);
	if(k>=n-1){
		//cout<<0;
		cout<<ans; return 0; 
	}
	else {
		for(int i=1;i<n-k;i++){
			ans-=c(n,i)*c(n-1,i-1)%mod;
			ans+=mod;
			ans%=mod;
		}
		cout<<ans;
	}
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=1001001001001001;
const int Inf=1001001001;
const int mod=1000000007;
int main(){
    ll n,k,ans=0;cin>>n>>k;
    ans=n/k;
    ans=ans*ans*ans;
    if(k%2==0){
        ll res=(n/(k/2));
        res=(res+1)/2;
        ans+=res*res*res;
    }
    cout<<ans<<endl;
}


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

int main(){
  int n,i;
  char s[10];
  int a[10];
    
  /*fgets(s,sizeof(s),stdin);
  a[0] = strtok(s, " ");
  
  for(i=1;i<10;i++){
    //printf("a\n");
    a[i] = strtok(NULL, " ");
    }*/
  scanf("%d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4]);
  
  for(i=0;i<5;i++){
    //printf("%s",a[i]);
    if(a[i]==0){
      printf("%d\n",i+1);
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 1676
import math

# 場合分けあり

a, b, x = map(int, input().split())

h = x/(a**2)
men = a*h
m = men * 2/b

if men <= a*b/2:
    rad = math.atan(b/m)
    print(math.degrees(rad))
else:
    y = 2*men/a-b
    rad = math.atan((b-y)/a)
    print(math.degrees(rad))


Measured memory_bytes: 3068
#include <stdio.h>

int main(void){

  long a,b,x;
  scanf("%ld %ld %ld", &a, &b, &x);
  long answer = b/x;
  if (a != 0) {
    answer -= (a-1)/x;
  } else {
    answer++;
  }
  printf("%ld\n", answer);

  return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int N = fs.nextInt();

        int ans = 0;
        for (int i = 1; i <= N; ++i) {
            int cnt = 0;
            for (int j = 1; j <= i; ++j) {
                if (i % j == 0) ++cnt;
            }
            if (cnt == 8 && i % 2 == 1) ++ans;
        }

        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() { return Double.parseDouble(next());}
}




Measured memory_bytes: 32588
/**
 *    author:  tourist
 *    created: 20.11.2019 08:41:43       
**/
#include <bits/stdc++.h>

using namespace std;

template <typename T, class F = function<T(const T&, const T&)>>
class SparseTable {
 public:
  int n;
  vector<vector<T>> mat;
  F func;

  SparseTable(const vector<T>& a, const F& f) : func(f) {
    n = static_cast<int>(a.size());
    int max_log = 32 - __builtin_clz(n);
    mat.resize(max_log);
    mat[0] = a;
    for (int j = 1; j < max_log; j++) {
      mat[j].resize(n - (1 << j) + 1);
      for (int i = 0; i <= n - (1 << j); i++) {
        mat[j][i] = func(mat[j - 1][i], mat[j - 1][i + (1 << (j - 1))]);
      }
    }
  }

  T get(int from, int to) const {
    assert(0 <= from && from <= to && to <= n - 1);
    int lg = 32 - __builtin_clz(to - from + 1) - 1;
    return func(mat[lg][from], mat[lg][to - (1 << lg) + 1]);
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> pos(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    --p[i];
    pos[p[i]] = i;
  }
  vector<int> x0 = p, x1 = p;
  for (int i = 0; i < n; i++) if (i % 2 == 0) x1[i] = n; else x0[i] = n;
  SparseTable<int> s0(x0, [&](int i, int j) { return min(i, j); });
  SparseTable<int> s1(x1, [&](int i, int j) { return min(i, j); });
  SparseTable<int> st(p, [&](int i, int j) { return min(i, j); });
  set<tuple<int, int, int>> s;
  s.emplace(s0.get(0, n - 1), 0, n - 1);
  while (!s.empty()) {
    auto pp = *s.begin();
    s.erase(s.begin());
    int x = get<0>(pp);
    int y = (pos[x] % 2 == 0 ? s1.get(pos[x], get<2>(pp)) : s0.get(pos[x], get<2>(pp)));
    cout << x + 1 << " " << y + 1 << " ";
    if (get<1>(pp) <= pos[x] - 1)
      s.emplace(get<1>(pp) % 2 == 0 ? s0.get(get<1>(pp), pos[x] - 1) : s1.get(get<1>(pp), pos[x] - 1), get<1>(pp), pos[x] - 1);
    if (pos[x] + 1 <= pos[y] - 1)
      s.emplace(pos[x] % 2 == 1 ? s0.get(pos[x] + 1, pos[y] - 1) : s1.get(pos[x] + 1, pos[y] - 1), pos[x] + 1, pos[y] - 1);
    if (pos[y] + 1 <= get<2>(pp))
      s.emplace(pos[y] % 2 == 1 ? s0.get(pos[y] + 1, get<2>(pp)) : s1.get(pos[y] + 1, get<2>(pp)), pos[y] + 1, get<2>(pp));
  }
  return 0;
}


Measured memory_bytes: 46464
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int N;
  vector<int> v;
  cin >> N;
  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  double ans = v[0];
  for(int i=1; i<N; i++){
    ans = (v[i] + ans) / 2;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main(void)
{
  char S[10];
  char T[10];
  int A, B;
  char U[10];

  cin >> S >> T;
  cin >> A >> B;
  cin >> U;

  if (strcmp(S, U) == 0) {
    cout << A - 1 << " " << B;
  } else if (strcmp(T, U) == 0) {
    cout << A << " " << B - 1;
  } else {
    cout << A << " " << B;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second

using namespace std;

const int maxN = 1e5 + 10;
const int inf = 3e18 + 10;

typedef pair<int, int> ii;

int k;
int dist[maxN];
vector<ii> adj[maxN];

void dijkstra(int src){
    priority_queue<ii , vector<ii> , greater<ii> > pq ;

    for(int i = 0; i < maxN; ++i)
        dist[i] = inf;

    pq.push({0,src});
    dist[src] = 0 ;

    while(!pq.empty()){
        int u = pq.top().se;
        pq.pop();

        for(auto &t : adj[u]){
            int v = t.fi;
            int w = t.se;
            if(dist[v] > dist[u] + w){
                dist[v] = dist[u] + w ;
                pq.push({dist[v], v});
            }
        }
    }

    cout << dist[0] + 1 << endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(); cout.tie();

    cin >> k;

    for(int i = 1; i <= k; ++i){
        int u = i % k;
        int v = (i + 1) % k;
        adj[u].push_back({v,1});
    }

    for(int i = 1; i <= k; ++i){
        int u = i % k;
        int v = (10 * i) % k;
        adj[u].push_back({v,0});
    }

    dijkstra(1);
}


Measured memory_bytes: 12168
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <locale>
using namespace std;
#define FORN(i,m,n) for(int i=m; i<(n); i++)
#define PRINTVEC(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PRINTMAT(m) FORN(j,0,m.size()) {PRINTVEC(m[j]);}
#define p_b(x) push_back(x)
#define m_p(a,b) make_pair(a,b)
typedef long long ll;

vector<vector<ll> > dp;
vector<ll> dig;
string s; int N;
const ll M = 1e9 + 7;

ll solve(ll pos, ll mod){
  if(pos==N){
    if(mod == 5) return 1;
    else return 0;
  }
  if(dp[pos][mod]!=-1) return dp[pos][mod];
  ll ans = 0;
  if(s[pos]!='?') {
    ans += solve(pos+1, (mod + ((s[pos]-'0') * dig[pos])) % 13);
  }
  else{
    FORN(i,0,10){
      ll newmod = (mod + (i * dig[pos])) % 13;
      ans += solve(pos+1, newmod);
      ans %= M;
    }
  }
  ans %= M;
  dp[pos][mod] = ans;
  return ans;
}

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  cin>>s; N = s.size();
  dp = vector<vector<ll> > (N,vector<ll>(13,-1));
  dig = vector<ll> (N);
  dig[N-1] = 1;
  for(int i=N-2; i>=0; i--) dig[i] = (dig[i+1]*10) % 13;
  ll ans = solve(0,0);
  cout<<ans<<endl;
}

Measured memory_bytes: 20688
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] check = new int[26];
        String s = sc.next();
        char[] cc = s.toCharArray();
        for (int i = 0; i < s.length(); i++) {
            check[cc[i] - 'a']++;

        }
        boolean ans = true;
        for (int i = 0; i < s.length(); i++) {
            if (check[i] > 1) {
                ans = false;
            }
        }
        System.out.println(ans ? "yes" : "no");
        sc.close();
    }
}

Measured memory_bytes: 23508
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot

#############
# Main Code #
#############

A, B, C, D = getNM()
print(max(A * B, C * D))

Measured memory_bytes: 63980
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int head[N],col[N],dfn[N],low[N],s[N],in[N],xx[N],yy[N],pos[N];
int n,c,rt,ans,cnt,tmp,num,pre,top;
struct tree{
	int l,r;
}t[N<<2];
struct edge{
	int to,nex;
}e[N<<1];
struct node{
	int x,y;
	bool operator <(const node &b)const{
		return x<b.x;
	}
}a[N];
void add(int x,int y)
{
	if(x==y||!y)return;
	e[++cnt].to=y;e[cnt].nex=head[x];head[x]=cnt;
}
void build(int &x,int l,int r)
{
	if(l==r){
		x=(a[l].y<=n)?a[l].y+n:a[l].y-n;
		pos[a[l].y]=l;return;
	}x=++num;
	int mid=l+r>>1;
	build(t[x].l,l,mid);build(t[x].r,mid+1,r);
	add(x,t[x].l);add(x,t[x].r);
	return;
}
void change(int x,int l,int r,int L,int R,int p)
{
	if(L>R)return;
	if(l==L&&r==R)
	{
		add(p,x);return;
	}
	int mid=l+r>>1;
	if(mid>=R)change(t[x].l,l,mid,L,R,p);
	else if(L>mid)change(t[x].r,mid+1,r,L,R,p);
	else change(t[x].l,l,mid,L,mid,p),change(t[x].r,mid+1,r,mid+1,R,p);
	return;
}
void dfs(int x)
{
	dfn[x]=low[x]=++tmp;
	s[++top]=x;in[x]=1;
	for(int i=head[x];i;i=e[i].nex)
	{
		int y=e[i].to;
		if(!dfn[y])
		{
			dfs(y);
			low[x]=min(low[x],low[y]);
		}
		else if(in[y])low[x]=min(low[x],dfn[y]);
	}
	if(low[x]==dfn[x])
	{
		c++;int a=-1;
		do{
			a=s[top--];
			in[a]=0;
			col[a]=c;
		}while(a!=x);
	}
	return;
}
void init()
{
	memset(dfn,0,sizeof(dfn));
	memset(low,0,sizeof(low));
	memset(col,0,sizeof(col));
	tmp=c=0;
	return;
}
bool judge(int x)
{
	init();
	for(int i=1;i<=n*2;++i)head[i]=0;cnt=pre;
	for(int i=1;i<=n;++i)
	{
		int AL=lower_bound(a+1,a+1+2*n,(node){xx[i]-x+1,0})-a;
		int AR=upper_bound(a+1,a+1+2*n,(node){xx[i]+x-1,0})-a-1;
		if(AL<=AR)change(rt,1,n*2,AL,pos[i]-1,i),change(rt,1,n*2,pos[i]+1,AR,i);
		int BL=lower_bound(a+1,a+1+2*n,(node){yy[i]-x+1,0})-a;
		int BR=upper_bound(a+1,a+1+2*n,(node){yy[i]+x-1,0})-a-1;
		if(BL<=BR)change(rt,1,n*2,BL,pos[i+n]-1,i+n),change(rt,1,n*2,pos[i+n]+1,BR,i+n);
	}
	for(int i=1;i<=num;++i)
	if(!dfn[i])dfs(i);
	for(int i=1;i<=n;++i)
	if(col[i]==col[i+n])return 0;
	return 1;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d%d",&xx[i],&yy[i]);
		a[i*2-1].x=xx[i];a[i*2].x=yy[i];
		a[i*2-1].y=i;a[i*2].y=i+n;
	}num=n*2;
	sort(a+1,a+1+n*2);
	build(rt,1,n*2);
	int l=0,r=1e9;pre=cnt;
	while(l<=r)
	{
		int mid=l+r>>1;
		if(judge(mid))ans=mid,l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}


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

int main(){
  int N,cnt=0;
  string S;
  cin>>N>>S;

  for(int i=0; i<N-2; i++){
    if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C') cnt++;
  }

  cout << cnt <<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
        bool h[101][101];
        for(int i = 0; i < 101; i++)for(int j = 0; j < 101; j++) h[i][j] = false;
        int N;
        cin >> N;
        for(int i = 0; i < N; i++){
                int t;
                cin >> t;
                for(int j = 0; j < t; j++){
                        h[i][j] = true;
                }
        }
        int ret = 0;
        bool flag = false;
        for(int j = 0; j < 100; j++){
                for(int i = 0; i < 101; i++){
                        if(flag == false && h[i][j] == true){
                                ret++;
                                flag = true;
                        }else if(flag == true && h[i][j] == false) flag = false;
                }
                flag == false;
        }
        cout << ret << endl;
        return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import System.IO.Unsafe
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete


main = do
    [n, m] <- getInts
    when (n/=0 || m/=0) $ do
        replicateM n getInts >>= putStrLn . sjoin . map snd . sort . flip zip [1..] . map (negate . sum) . transpose >> main

Measured memory_bytes: 18516
n = int(input())
dic = {}
for i in range(n):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
dict_sorted = sorted(dic.items(), key=lambda x:x[1])
max_num = dict_sorted[-1][1]
ans = []
for a in dict_sorted:
    if a[1] == max_num:
        ans.append(a[0])
ans.sort()
for a in ans:
    print(a)


Measured memory_bytes: 45784
import java.io.*;
import java.util.*;
import java.math.*;
     
public class Main {
	//static int dir[][]={{0,1},{0,-1},{1,0},{-1,0}};
	public static void main(String[] args) throws Exception {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      OutputStream outputStream = System.out;
      PrintWriter out = new PrintWriter(outputStream);

      int i, j, u=0, v=0;
      StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
      int flag=0;
      for(i=9;i>0;i--)
      {
        flag=0;
        if(n%i==0)
        {
          if(n/i<10 && n/i>0)
            out.print("Yes");
          else
            out.print("No");
          flag=1;
          break;
        }
      }
      if(flag==0)
        out.print("No");
    	out.flush();
    	out.close();
    	}
    }

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

int main(void) {
	int A, B, C, K;
	cin >> A >> B >> C >> K;

	int ans = 0;
	if (K <= A)
		ans = K;
	else if (K <= A + B)
		ans = A;
	else {
		int neg = K - (A + B);
		ans = A - neg;
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = int(1e5);
int N;
ll a[MAX_N];
vector<ll> v;

void solve() {
    sort(v.begin(), v.end());
    ll ans[2][N];

    if (N == 2) {
        cout << abs(v[0] - v[1]) << endl;
    } else {
        int temp = 0, reptime = 0;
        if (N % 2 == 0) {
            temp = N / 2 - 1;
            reptime = temp + 2;
        } else {
            temp = N / 2;
            reptime = temp + 1;
        }
        REP(k, 2) {
            bool is_small = k % 2 == 0;
            int small = 0, big = static_cast<int>(v.size() - 1);
            REP(i, reptime) {
                if (is_small) {
                    if (temp + i < N) {
                        ans[k][temp + i] = v[small];
                        small++;
                    }
                    if (i != 0 && temp - i >= 0) {
                        ans[k][temp - i] = v[small];
                        small++;
                    }
                } else {
                    if (temp + i < N) {
                        ans[k][temp + i] = v[big];
                        big--;
                    }
                    if (i != 0 && temp - i >= 0) {
                        ans[k][temp - i] = v[big];
                        big--;
                    }
                }
                is_small = !is_small;
            }
        }
        ll ret = 0;
        REP(k, 2) {
            ll n = 0;
            REP(i, N - 1) {
                n += abs(ans[k][i] - ans[k][i + 1]);
            }
            ret = max(n, ret);
        }
        cout << ret << endl;
    }
}

int main() {
    cin >> N;
    ll temp;
    REP(i, N) {
        cin >> temp;
        v.emplace_back(temp);
    }
    solve();
    return 0;
}

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

using namespace std;


int32_t main() {

    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

    int n,ans = 0;
    cin>>n;
    for(int i=1;i<=n;i++){
        int cnt = 0;
        int t= i;
        while(t){
            t/=10;
            cnt++;
        }
        if(cnt&1) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

bool isPrime(int x){
    int i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int main(){
    ll int n,a[100001],b[100001],c[100001],l[100001],r[100001];
    c[0]=0;
    for (int i=1;i<100001;i++){
        if(isPrime(i)){
            a[i]=1;
            if(a[(i+1)/2]==1){
                b[i]=1;
            }else{
                b[i]=0;
            }
        }else{
            a[i]=0;
            b[i]=0;
        }
        c[i]=c[i-1]+b[i];
    }
    cin >> n;
    for (int i=0;i<n;i++){
        cin >> l[i] >> r[i];
        cout << c[r[i]]-c[l[i]-1] << endl;
    }
    
}

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

int main()
{
    int a, b, i;
    cin>>a>>b;

    if(a<b)
        for(i=0; i<b; i++)
            cout<<a;
    else if(b<a)
        for(i=0; i<a; i++)
            cout<<b;
    else
        for(i=0; i<a; i++)
            cout<<b;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 998244353
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
const double PI = acos(-1);
typedef long long ll;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(void) {
  int N;cin>>N;
  V<ll> D(N);
  V<ll> cnt(N,0);
  ll ans=1;
  ll m=0;
  REP(i,N){
    cin>>D[i];
    cnt[D[i]]++;
    m=max(m,D[i]);
  }

  if(D[0]!=0||cnt[0]>1){
    cout<<0<<endl;
    return 0;
  }

  FOR(i,1,m+1){
    ll p=modpow(cnt[i-1],cnt[i],MOD);
    ans=ans*p%MOD;
  }

  //printf("%lld\n",ans);
  cout<<ans<<endl;
  return 0;
}









Measured memory_bytes: 1792
#include <iostream>

using namespace std;

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

int T[100];
for (int i = 0; i < n; i++) cin >> T[i];

int m;
cin >> m;

int P[100], X[100];
for (int i = 0; i < m; i++) cin >> P[i] >> X[i];

for (int i = 0; i < m; i++) {
int ret = 0;
for (int j = 0; j < n; j++) {
if (P[i] == j + 1) ret += X[i];
else ret += T[j];
}
cout << ret << endl;
}

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 264000
#define ll long long
using namespace std;
ll seg[2][maxn<<1],tag[2][maxn<<1];
void push(int p,int lch,int rch,ll *seg,ll *tag) {
	seg[lch] += tag[p];		tag[lch] += tag[p];
	seg[rch] += tag[p];		tag[rch] += tag[p];
	tag[p] = 0;
}
void modify(int l,int r,int ql,int qr,int p,int type,ll val,ll *seg,ll *tag) {
	if(l == ql && r == qr) {
		if(type == 1) {
			assert(l==r);
			seg[p] = min(seg[p],val);
		}
		else {
			seg[p] += val;
			tag[p] += val;
		}
	}
	else {
		int mid = (l+r)>>1 , lch = p<<1 , rch = p<<1|1;
		push(p,lch,rch,seg,tag);
		if(qr <= mid)
			modify(l,mid,ql,qr,lch,type,val,seg,tag);
		else if(ql > mid)
			modify(mid+1,r,ql,qr,rch,type,val,seg,tag);
		else {
			modify(l,mid,ql,mid,lch,type,val,seg,tag);
			modify(mid+1,r,mid+1,qr,rch,type,val,seg,tag);
		}
		seg[p] = min(seg[lch],seg[rch]);
	}
}
ll query(int l,int r,int ql,int qr,int p,ll *seg,ll *tag) {
	if(l == ql && r == qr)
		return seg[p];
	else {
		int mid = (l+r)>>1 , lch = p<<1 , rch = p<<1|1;
		push(p,lch,rch,seg,tag);
		if(qr <= mid)
			return query(l,mid,ql,qr,lch,seg,tag);
		else if(ql > mid)
			return query(mid+1,r,ql,qr,rch,seg,tag);
		else
			return min(query(l,mid,ql,mid,lch,seg,tag),query(mid+1,r,mid+1,qr,rch,seg,tag));
	}
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,q;
	cin >> n >> q;
	int a,b;
	cin >> a >> b;
	int pre;
	cin >> pre;
	
	memset(seg,0x3f,sizeof seg);
	for(int i=0,coe=1;i<2;i++,coe*=-1) {
		modify(1,n,a,a,1,1,abs(b - pre) + coe * a,seg[i],tag[i]);
		modify(1,n,b,b,1,1,abs(a - pre) + coe * b,seg[i],tag[i]);
	}
	for(int i=2,x;i<=q;i++) {
		cin >> x;
		ll val = min(query(1,n,x,n,1,seg[0],tag[0]) - x , query(1,n,1,x,1,seg[1],tag[1]) + x);
		ll add = abs(x - pre);
		for(int j=0,coe=1;j<2;j++,coe*=-1) {
			modify(1,n,1,n,1,2,add,seg[j],tag[j]);
			modify(1,n,pre,pre,1,1,val + coe * pre,seg[j],tag[j]);
		}
		pre = x;
	}
	
	ll ans = -1;
	for(int i=1;i<=n;i++)
		for(int j=0,coe=1;j<2;j++,coe*=-1) {
			ll now = query(1,n,i,i,1,seg[j],tag[j]) - coe * i;
			if(ans == -1 || ans > now)
				ans = now;
		}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 16768
#include<stdio.h>
int main(void)
{
  int H,W;
  while(1)
  {
    scanf("%d %d",&H,&W);
    if(H==0&&W==0) break;

    for(int i=0;i<H;i++)
      {
        for(int k=0;k<W;k++)
          putchar('#');
        printf("\n");
      }
      printf("\n");
  }
  return 0;
}

Measured memory_bytes: 1796
function solve(N:number, A: number[]):number{
  const f=fact(N);
  let sum=0;
  for(let i=0;i<N;i++){
    sum+=mul(A[i],sub(add(tasuyatu(N-i),tasuyatu(i+1)),1));
  }
  sum=mul(sum,f);
  return sum;
}
function Main(raw: string) {
  const input = raw.split("\n");
  const N = parseInt(input[0], 10);
  const H = parseInt(input[1], 10);
  const W = parseInt(input[2], 10);

  //出力
  console.log("%d", (N-H+1)*(N-W+1));
}

//DO NOT EDIT
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const ll INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

int a[200000];
int f[200000];
int b[200000];

int main(void){
    int n; cin >> n;
    for(int i = 0;i < n;i++)cin >> a[i];
    f[0] = a[0];
    for(int i = 1;i < n-1;i++){
        f[i] = max(f[i-1], a[i]);
    }
    b[n-1] = a[n-1];
    for(int i = n-2;i > 0;i--){
        b[i] = max(b[i+1], a[i]);
    }
    printf("%d\n", b[1]);
    for(int i = 1;i < n-1;i++){
        printf("%d\n", max(f[i-1], b[i+1]));
    }
    printf("%d\n", f[n-2]);
	return 0;
}

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

int main() {
  int t_hp, a_hp, a_atk, t_atk;
  cin >> t_hp >> t_atk >> a_hp >> a_atk;
  
  while (1) {
    a_hp -= t_atk;
    if (a_hp <= 0) {
      cout << "Yes" << endl;
      break;
    }
    t_hp -= a_atk;
    if (t_hp <= 0) {
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3636
N=int(input())
DMY=10**9

mmax=None
mmin=None
dmax=None
dmin=None
for i in range(N):
    x,y = map(int, input().split())
    if not mmax:
        mmax=(x,y,x+y)
        mmin=(x,y,x+y)
        dmax=(x,y,x+DMY-y)
        dmin=(x,y,x+DMY-y)
        continue
    if x+y > mmax[2]:
        mmax=(x,y,x+y)
    elif x+y < mmin[2]:
        mmin=(x,y,x+y)
    if x+DMY-y > dmax[2]:
        dmax=(x,y,x+DMY-y)
    elif x+DMY-y < dmin[2]:
        dmin=(x,y,x+DMY-y)

print(max(mmax[2]-mmin[2],dmax[2]-dmin[2]))


Measured memory_bytes: 9260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(ll (i)-1 = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

int main()
{	
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 0;

    REP(i, n-1){
        string s1 = s.substr(0, i+1);
        string s2 = s.substr(i+1);
        ll count = 0;

        for(char c = 'a'; c <= 'z'; c++){
            bool ok_s1 = false;
            bool ok_s2 = false;
            REP(i, s1.length()) if(s1[i] == c) ok_s1 = true;
            REP(i, s2.length()) if(s2[i] == c) ok_s2 = true;
            if(ok_s1 && ok_s2) count++;
        }
        ans = max(ans, count);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream & operator >> (istream & is, vector<T> & vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;

int main() {
	int n, m; CI n >> m;
	vector<pair<int, int>> a(n); 
	REP(i, n) {
		CI a[i].first >> a[i].second;
	}

	sort(a.begin(), a.end());

	ll ans = 0;
	int j = 0;
	for (int i = 0;;) {
		ans += a[i].first;
		a[i].second--;
		j++;
		if (a[i].second == 0)i++;
		if (j == m)break;
	}
	CO ans EN;
}

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

using namespace std;

int F(long long a, long long b) {
    int count = 0;
    long long c = max(a,b);
    while (c > 0) {
        count++;
        c /= 10;
    }
    return count;
}

int main() {
    long long n;
    cin >> n;
    long long a;
    long long ans = n;
    for (a = 1; a <= sqrt(n); a++) {
        if (n % a == 0)
            ans = (ans > F(a, n/a)) ? F(a, n/a) : ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n;
    cin >> n;

    ll cnt(0);
    while (n>0)
    {
        n -= 1000;
        cnt++;
    }

    cout << -n << endl;

    return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<set>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cstdlib>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>
#include<tr1/unordered_set>
#include<tr1/unordered_map>
using namespace std;
using namespace tr1;
#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define ll long long int
//Make sure no overflow problems
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define ld long double
const int INF = 1000000009;
const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;

int main(){
    ios_base:: sync_with_stdio(false); 
    cin.tie(0);
/*
    #ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin); 
       	freopen("output.txt", "w", stdout); 
    #endif */
        int A, B;
        cin >> A >> B;
        if(A > 9 || B > 9)
        	cout << -1;
       	else
       		cout << A*B;
    	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(int i=a;i<b;i++)
#define rFor(i,a,b) for(int i=a;i>b;i--)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<b>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  double a,b;
  ci(a>>b);
  co(ceil(a/b)-floor(a/b));
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))


//セグ木ここから
//*
//↓ここを変える
typedef struct atai{ll a;}atai;
atai xx(atai x,atai y){
	atai r;
	r.a=x.a+y.a;
	return r;
}
atai aid={0};
//↑ここを変える

int segNUM;
atai *segN,*seg;
void seguse(int n){
	segN=(atai*)calloc(2*n,sizeof(atai));
	segNUM=n;
	seg=segN+segNUM;
	rep(i,1,2*segNUM)segN[i]=aid;
}
//seg[]に値を与えてから初期化
void seginit(){for(int node=segNUM-1;node;node--)segN[node]=xx(segN[node*2],segN[node*2+1]);}
void segupdate(int node,atai x){
	//seg[node]をxに更新
	node+=segNUM;
	segN[node]=x;
	while(node/=2)segN[node]=xx(segN[node*2],segN[node*2+1]);
}

atai segcalcsub(int l,int r,int k,int cl,int cr){
	if(l>=r)return aid;
	//完全に含むとき
	if(l<=cl&&cr<=r)return segN[k];

	int cm=(cl+cr)/2;
	//左側だけ
	if(r<=cm)return segcalcsub(l,r,2*k  ,cl,cm);
	//右側だけ
	if(cm<=l)return segcalcsub(l,r,2*k+1,cm,cr);
	//両方
	return xx(segcalcsub(l,r,2*k,cl,cm),segcalcsub(l,r,2*k+1,cm,cr));
}
atai segcalc(int l,int r){return segcalcsub(l,r,1,0,segNUM);}
//セグ木ここまで
//*/


int main(){
	int n,q;
	scanf("%d%d",&n,&q);
	seguse(1<<17);
	while(q--){
		int t,x,y;
		scanf("%d%d%d",&t,&x,&y);
		if(t)printf("%lld\n",segcalc(x,y+1).a);
		else{
			atai a={y+segcalc(x,x+1).a};
			segupdate(x,a);
		}
	}
}


Measured memory_bytes: 3908
#include <stdio.h>

int main(void){

int c,n,x;
int l=0;
int i,j,k;

for(c=1;c>0;c++){
  scanf("%d %d",&n,&x);
  if(n==0 && x==0){
  break;}
  for(i=1;i<=n;i++){
  //printf("i %d\n",i);
  for(j=i;j<=n;j++){
  //printf("j %d\n",j);
  for(k=j;k<=n;k++){
  //printf("k %d\n",k);
  if(i+j+k==x && i!=j && j!=k){
  /*printf("%d ",i);
  printf("%d ",j);
  printf("%d ",k);
  printf("%d\n",i+j+k);*/
  l++;
  }}}}
  printf("%d\n",l);
  l=0;}
return 0;}


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

int main() {
  
  int N;
  cin >> N;
  
  vector<int> A(N);
  
  for ( int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  
  int count = 0;
  
  for ( int i = 0; i < N; i++){
    while(A.at(i) % 2 == 0 ){
      A.at(i) /= 2;
      count++;
    }
  }
  
  cout << count << endl;
  
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#define repeat(i,n)     for(int i=0; i<(n); ++i)
#define repeat1(i,n)    for(int i=1; i<=(n); ++i)
#define range(i,l,r)    for(int i=(l); i<(r); ++i)

using namespace std;
typedef long long llint;

int iin();
llint   lin();
double  fin();

int main() {
    int k = iin();
    int t = iin();
    vector<int> tcake(t);

    repeat(i, t) {
        tcake[i] = iin();
    }
    if(t == 1) {
        printf("%d\n", tcake[0]-1);
        return 0;
    }

    sort(tcake.begin(), tcake.end(), greater<int>());
    int sum = accumulate(tcake.begin()+1, tcake.end(), 0);
    if(tcake[0] - sum < 2) {
        printf("0\n");
    }
    else {
        printf("%d\n", tcake[0] - sum - 1);
    }
    return 0;
}

//////////////////////////////////////////////////////////////////////////////

int iin() {
    int x;
    scanf("%d", &x);
    return  x;
}

llint lin() {
    llint x;
    scanf("%lld", &x);
    return  x;
}

double fin() {
    double  x;
    scanf("%lf", &x);
    return x;
}


Measured memory_bytes: 256
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int perm_input(int K, vector<vector<int> > &perm) {
	vector<int> p(K);
	for (int i = 0; i < K; ++i) cin >> p[i], --p[i];
	return lower_bound(perm.begin(), perm.end(), p) - perm.begin();
}
int main() {
	int N, K;
	cin >> N >> K;
	vector<vector<int> > perm;
	vector<int> pperm(K);
	for (int i = 0; i < K; ++i) pperm[i] = i;
	do {
		perm.push_back(pperm);
	} while (next_permutation(pperm.begin(), pperm.end()));
	vector<vector<int> > F(N, vector<int>(K));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < K; ++j) {
			cin >> F[i][j];
		}
	}
	int fact = perm.size();
	vector<vector<int> > P(fact, vector<int>(N)), IP(fact, vector<int>(N));
	for (int i = 0; i < fact; ++i) {
		for (int j = 0; j < N; ++j) {
			P[i][j] = j;
		}
		sort(P[i].begin(), P[i].end(), [&](int x, int y) {
			for (int j = 0; j < K; ++j) {
				if (F[x][perm[i][j]] != F[y][perm[i][j]]) {
					return F[x][perm[i][j]] < F[y][perm[i][j]];
				}
			}
			return false;
			});
		for (int j = 0; j < N; ++j) {
			IP[i][P[i][j]] = j;
		}
	}
	int D;
	cin >> D;
	vector<vector<int> > G(N);
	vector<int> deg(N);
	for (int i = 0; i < D; ++i) {
		int a, b;
		cin >> a >> b; --a, --b;
		++deg[b];
		G[a].push_back(b);
	}
	int cur = 0, pre = perm_input(K, perm), R;
	vector<int> ord(N + 1);
	cin >> R;
	for (int i = 0; i < R; ++i) {
		int tm, nxt;
		cin >> tm;
		nxt = perm_input(K, perm);
		for (int j = cur; j < tm; ++j) {
			ord[j] = pre;
		}
		cur = tm;
		pre = nxt;
	}
	for (int i = cur; i <= N; ++i) {
		ord[i] = pre;
	}
	vector<priority_queue<int> > que(fact);
	for (int i = 0; i < N; ++i) {
		if (deg[i] >= 1) continue;
		for (int j = 0; j < fact; ++j) {
			que[j].push(IP[j][i]);
		}
	}
	vector<bool> used(N, false);
	for (int i = 0; i < N; ++i) {
		int u = -1;
		while (u == -1 || used[u]) {
			u = P[ord[i]][que[ord[i]].top()];
			que[ord[i]].pop();
		}
		used[u] = true;
		cout << u + 1 << '\n';
		for (int j : G[u]) {
			--deg[j];
			if (deg[j] == 0) {
				for (int k = 0; k < fact; ++k) {
					que[k].push(IP[k][j]);
				}
			}
		}
	}
	return 0;
}


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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(long long A, long long B, long long H, long long M) {
    double ta = 4 * acos(0) * (H/12.0 + M/720.0);
    double tb = 4 * acos(0) * M / 60.0;
    double ax = A * sin(ta);
    double ay = A * cos(ta);
    double bx = B * sin(tb);
    double by = B * cos(tb);
    double ans = sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by));
    printf("%.20f\n", ans);
}

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


Measured memory_bytes: 4068