akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

double A[35] = { 0 }, B[1600] = { 0 };

int main()
{
	int a, b, c, d, e, f,i, j,  k,x,water,sugar,z=0;
	double maxden=0, den;
	cin >> a >> b >> c >> d >> e >> f;
	for(i=0;i<30;i++)//枚举所有加水方案
		for (j = 0; j < 30; j++)
		{
			x = a*i + b*j;
			if (x&&x*100 <= f&&!A[x]) A[x] = 1;
		}
	for (i = 0; i<=1500; i++)//枚举所有加糖方案
		for (j = 0; j <= 1500; j++)
		{
			x = c*i + d*j;
			if (x&&x <= 1500 && !B[x]) B[x] = 1;
		}
	for (i = 1; i < 30; i++)//混合各种加水加糖方案
	{
		if (A[i])
		{
			j = e*i;
			if (j > 1500)j=1500;
			while ((!B[j] || i * 100 + j > f) && j >= 0) j--; 
			if (j == -1)continue;
			den = (double)j*100 / (double)(i * 100 + j);
			if (den > maxden)//不断刷新最大浓度，同时：水，糖质量
			{
				maxden = den;
				water = i * 100;
				sugar = j;z++;
			}
		}
	}if(z)
	cout << water + sugar << " " << sugar << endl;
	else cout << a*100  << " " << 0 << endl;
	return 0;
}

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

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n;
  string s1, s2;
  cin >> n >> s1 >> s2;
  mint ans = 1;
  for(int i = 0; i < n; ++i){
    if(i == 0){
      if(s1[i] == s2[i]){
        ans *= 3;
      } else {
        ans *= 6;
        i++;
      }
    } else if(s1[i] == s2[i]){
      if(s1[i - 1] == s2[i - 1]) ans *=2;
    } else {
      if(s1[i - 1] == s2[i - 1]){
        ans *= 2;
      } else {
        ans *= 3;
      }
      i++;
    }
  }

  cout << ans.x << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
struct E
{
    long long x,y;
}a[N];

bool cmp1(E e1,E e2)
{
    return e1.y>e2.y;
}

bool cmp2(E e1,E e2)
{
    return e1.x>e2.x;
}

int main()
{
    int n,s,i;
	cin>>n>>s;
    for(i=0;i<n;i++)
	{
        cin>>a[i].x>>a[i].y;
    }
    sort(a,a+n,cmp2);
    long long max_x=a[0].x;
    sort(a,a+n,cmp1);
    int len_t=n;
    for(i=0;i<n;i++)
	{
        if(a[i].y<max_x)
		{
            len_t=i;
            break;
        }
    }
    long long sum=0;
    int res=0;
    for(i=0;i<len_t;i++)
	{
        sum+=a[i].y;
        res++;
        if(sum>=s)
		{
            cout<<res<<endl;
            return 0;
        }
    }
    s-=sum;
    res+=ceil(s*1.0/max_x);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 1792
//************************
//*  Date: 2018.9.22     *
//*  Problem:            *
//*  Author: xuziyuan    * 
//************************

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,m,xx,yy;
int x[300],y[300];

int main()
{
	cin>>n>>m>>xx>>yy;
	rep(i,n) cin>>x[i];
	sort(x,x+n);
	rep(i,m) cin>>y[i];
	sort(y,y+m);
	//cout<<y[0]<<' '<<y[1]<<endl;
	for(int z=xx+1;z<=yy;z++)
	{/*
		if(z==16)
		{
			cout<<x[n-1]<<' '<<z<<' '<<y[0]<<endl;
		}*/
		if(x[n-1]<z&&y[0]>=z)
		{
			puts("No War");
			rt0;
		}
	}
	puts("War");
	rt0;
}

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

int main() {
  int n, d; cin >> n >> d;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    long long x, y; cin >> x >> y;
    ans += d >= sqrt(x * x + y * y);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
import org.w3c.dom.ls.LSOutput;

import java.util.*;

import static java.lang.Math.*;

class Main {
    final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        long n = sc.nextLong();
        int[] m = new int[100];
        Arrays.fill(m, -1);

        for (int i = 1; i < 100; i++) {
            m[i] = (int) (n % 26);
            if (m[i] == 0)
                m[i] = 26;
            n = (n - m[i]) / 26;
            if (n == 0) {
                break;
            }
        }

        for (int i = 99; i > 0; i--) {
            if (m[i] == -1)
                continue;
            System.out.print((char) ('a' + m[i] - 1));
        }
        System.out.println("");
    }
}


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

int main() {
  string S,T;
  cin >> S >> T;

  int count =0;
  for(int i=0; i<S.size(); i++){
    if(S.at(i)!=T.at(i)){
      count++;
    }
  }


  cout << count << endl;

}


Measured memory_bytes: 3924
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  if (a == b) {
    cout << "Draw" << endl;
  } else if (a == 1) {
    cout << "Alice" << endl;
  } else if (b == 1) {
    cout << "Bob" << endl;
  } else {
    if (a>b) {
      cout << "Alice" << endl;
    } else {
      cout << "Bob" << endl;
    }
  }
}

Measured memory_bytes: 384
S = input()
first = 0
last = 0

for i in range(0, len(S)):
    if S[i] == 'A':
        first = i
        break

for i in range(len(S)-1, -1, -1):
    if S[i] == 'Z':
        last = i
        break

print(last - first + 1)

Measured memory_bytes: 3516
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

typedef pair<int, int> pii;
typedef pair<int, pii> road;

const int SIZE = 100005;
vector<road> edges;
vector<pii> vx;
vector<pii> vy;
int x[SIZE];
int y[SIZE];
int N;

vector<road> selected;
int parent[500005];
int ufFind(int u){
	if(parent[u] < 0)
		return u;
	return parent[u] = ufFind(parent[u]);
}

bool ufUnion(int u, int v){
	u = ufFind(u);
	v = ufFind(v);
	if(u == v)
		return false;
	parent[u] = v;
	return true;
}

long long int kruscal(){
	long long int ret = 0;
	sort(edges.begin(), edges.end());
	for(int i=0; i<edges.size(); i++){
		int weight = edges[i].first;
		int u = edges[i].second.first, v = edges[i].second.second;
		if(ufUnion(u, v)){
			selected.push_back(edges[i]);
			ret += weight;
		}
	}
	return ret;
}

int main(){
	scanf("%d", &N);
	for (int i=1; i<=N; ++i) {
		scanf("%d %d", x+i, y+i);
		vx.push_back({x[i], i});
		vy.push_back({y[i], i});
	}
	sort(vx.begin(), vx.end());
	sort(vy.begin(), vy.end());
	memset(parent, -1, sizeof(parent));
	for(int i=1; i<N; ++i){
		edges.push_back({abs(vx[i].first-vx[i-1].first), {vx[i].second, vx[i-1].second}});
		edges.push_back({abs(vy[i].first-vy[i-1].first), {vy[i].second, vy[i-1].second}});
	}
	printf("%lld\n", kruscal());

}


Measured memory_bytes: 10212
#include<stdio.h>
int d[13]={0};
int f(int t){
  int i;
  for(i=0;i<10;i++)if(d[i])break;
  if(i==10)return 1;
  if(d[i]>2){
    d[i]-=3;
    if(f(t))return 1;
    d[i]+=3;
  }
  if(t==0&&d[i]>1){
    d[i]-=2;
    if(f(1))return 1;
    d[i]+=2;
  }
  if(d[i]&&d[i+1]&&d[i+2]){
    d[i  ]--;
    d[i+1]--;
    d[i+2]--;
    if(f(t))return 1;
    d[i  ]++;
    d[i+1]++;
    d[i+2]++;
  }
  return 0;
}  
int main(){
  int h,i,j,n[10];
  char s[13];
  while(scanf("%s",s)!=EOF){
    //for(i=0;s[i];i++)printf("%d",s[i]-'0');printf("\n");
    for(i=0;i<10;i++)n[i]=0;
    for(i=0;s[i];i++)n[s[i]-'0']++;
    //for(i=1;i<10;i++)printf("%d",n[i]);printf("\n");
    for(i=h=1;i<10;i++){
      if(n[i]==4)continue;//printf(":%d ",i);
      for(j=1;j<10;j++)d[j]=n[j];//,printf("%d ",d[j]);printf("\n");
      d[i]++;
      if(f(0)){
	if(h==0)printf(" ");
	printf("%d",i);
	h=0;
      }
      d[i]--;
    }
    if(h)printf("0");
    printf("\n");
  }
  return 0;
}
      

Measured memory_bytes: 544
H,W = map(int,input().split())
field = []
for i in range(H):
    field.append(list(input()))
flag = True

#4方向走査
#下、上、左、右
dy = [1,-1,0,0]
dx = [0,0,1,-1]


for y in range(H):
    for x in range(W):
        if field[y][x] == "#":
            state = False
            for k in range(4):
                ny = y + dy[k]
                nx = x + dx[k]
                if 0 <= ny and ny < H and 0 <= nx and nx < W:
                    if field[ny][nx] == "#":
                        state = True
            if state:
                continue
            else:
                flag = False
                break

if flag:
    print("Yes")
else:
    print("No")

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

int main(){
  int a,b,c,d;
  
  cin >> a >> b >> c >> d;
  if (a+b > c+d)
    cout << "Left" << endl;
  else if (a+b == c+d)
    cout << "Balanced" << endl;
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int d,n;
  cin>>d>>n;
  
  if(d==0 && n<100) cout<<n<<endl;
  else if(d==0 && n==100) cout<<101;
  else if(d==1 && n<100) cout<<100*n<<endl;
  else if(d==1 && n==100) cout<<10100<<endl;
  else if(d==2 && n<100) cout<<10000*n<<endl;
  else cout<<1010000<<endl;
  return 0; 
}

Measured memory_bytes: 3600
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let v: Vec<char> = get!(String).chars().collect();
    let mut now = v[0];
    let mut ans = 0;
    for i in 1..v.len() {
        if v[i] != now {
            ans += 1;
            now = v[i];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    A, B = input().split()
    A = int(A)
    B, C = map(int, B.split("."))

    print(A * (B * 100 + C) // 100)


if __name__ == "__main__":
    main()



Measured memory_bytes: 9860
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
//const ll big=998244353LL;
const ll big=1000000007LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int n,m;cin >> n >> m;
  	vec<P> b(n+m,{0,1});
  	rep(i,n)cin >> b[i].first;
  	rep(i,m)cin >> b[i+n].second >> b[i+n].first;
    
  	sort(rall(b));
    int index=0;//上からn個足す方のindex
    int i=0;//vec bの方のindex
    ll ans=0;
  	while(!0){
      	if(index>=n)break;
      	if(index+b[i].second>n){
          	ans+=(n-index)*b[i].first;
          	break;
        }else{
          	ans+=b[i].second*b[i].first;
          	index+=b[i].second;
        }
        i++;
    }
  	cout << ans << endl;
}

Measured memory_bytes: 6300
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize, k: isize, q: isize,
        av: [Usize1; q]
    };

    let mut solve_counts = vec![0_isize; n];
    for a in av {
        solve_counts[a] += 1;
    }
    for i in 0..n {
        let res = if k - q + solve_counts[i] > 0 {
            "Yes"
        } else {
            "No"
        };
        println!("{}", res);
    }
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int m;
	cin >> m;
	cout << 48 - m << endl;
}


Measured memory_bytes: 256
import collections

n=int(input())
a=map(int,input().split())
q=int(input())
b=[[int(i) for i in input().split()] for l in range(q)]

c=collections.Counter(a)
s=sum([j*k for j,k in c.items()])
for x in b:
    s=s-x[0]*c[x[0]]+x[1]*c[x[0]]
    c[x[0]],c[x[1]]=0,c[x[0]]+c[x[1]]
    print(s)

Measured memory_bytes: 38908
n = []
s = []
while True:
    a = int(input())
    if a == 0:
        break
    else:
        n.append(a)
        s.append(list(map(int, input().split())))
for i in range(len(n)):
    m = sum(s[i]) / n[i]
    dis = 0
    for j in range(n[i]):
        dis += (s[i][j] - m) ** 2 / n[i]
    dis = dis ** 0.5
    print(dis)


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

int ctoi(char c){
	switch(c){
	    case '0': return 0;
	    case '1': return 1;
	    case '2': return 2;
	    case '3': return 3;
	    case '4': return 4;
	    case '5': return 5;
	    case '6': return 6;
	    case '7': return 7;
	    case '8': return 8;
	    case '9': return 9;
	    default : return -1;
	 }
}

int main() {
	int n, m;
	cin >> n >> m;
	int s[m], c[m];
	for(int i = 0; i < m; i++) cin >> s[i] >> c[i];
	for(int i = 0; i < 1000; i++){
		string ans = to_string(i);
		if(ans.size() == n){
		bool check = true;
			for(int j = 0; j < m; j++){
				if(ctoi(ans[s[j] - 1]) != c[j]) check = false;
			}
			if(check){
				cout << ans << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;

const ll MOD=1000000007;

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear1(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p){
  ll n=solveLinear1(a,p,1);
  n=n%p;
  if(n<0)return n+p;
  return n;
}

int main(){
  int i,j,k,cnt=0;
  int x,y;
  cin>>x>>y;
  int p=(x+y)/3;
  if((x+y)%3!=0 || p>x || p>y){
    cout<<0<<endl;
    return 0;
  }
  int a=y-p,b=x-p;
  ll p1=1,p2=1;
  for(i=1;i<=b;i++){
    p1=(p1*(a+i))%MOD;
    p2=(p2*i)%MOD;
  }
  p2=modRev(p2,MOD);
  cout<<(p1*p2)%MOD<<endl;
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=[0]*(n+1)
b=[0]*(n+1)
for i in range(m):
  p,s=input().split()
  p=int(p)
  if a[p]==0:
      if s=="AC":
        a[p]=1
      else:
        b[p]+=1
for i in range(n+1):
    if a[i]==0:
        b[i]=0
print(sum(a),sum(b))

Measured memory_bytes: 4596
import sys
input = sys.stdin.readline


def lexicograph(a: str, b: str):
    l = min(len(a), len(b))
    for i in range(l):
        if ord(a[i].lower()) == ord(b[i].lower()):
            continue
        elif ord(a[i].lower()) < ord(b[i].lower()):
            return True
        else:
            return False
    if len(a) < len(b):
        return True
    else:
        return False


m = int(input())
taro = 0
hana = 0
for _ in range(m):
    a, b = input().strip().split()
    if a == b:
        taro += 1
        hana += 1
    elif lexicograph(a, b):
        hana += 3
    else:
        taro += 3

print(taro, hana)



Measured memory_bytes: 5604
#include <bits/stdc++.h>  // ver1.9.1
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(15);
  string s,ans;
  cin>>s;
  ans = "keyence";
  int l=s.size();
  
  /*if(s.substr(0,7)=="keyence") {
    cYES;
    return 0;
  }
  if(s.substr(l-7,7)=="keyence") {
    cYES;
    return 0;
  }*/
  
  rep(i,0,7){
    if(s.substr(0,i)==ans.substr(0,i) && s.substr(l-7+i,7-i)==ans.substr(i,7-i)){
      cYES;
      return 0;
    }
  }
  
  cNO;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(void){
        int n;
        int tmp=0;
        double Ex2;
        double Ex;
        double V;
        while(1) {
                Ex=0;
                Ex2=0;
                tmp=0;
                cin>>n;
                if(n==0) {return 0;}
                for(int i=0; i<n; i++) {
                        cin>>tmp;
                        Ex+=tmp;
                        Ex2+=tmp*tmp;
                }
                V=Ex2/n-(Ex/n)*(Ex/n);
                if(V<=0.001) {
                        printf("0\n");
                }
                else{
                        printf("%lf\n",sqrt(V));
                }

        }
}



Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int main(){
	long int i,n,p=0,h,c=0,t=0;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> h;
		if(h>p){
			c=0;
		}else{
			c++;
		}
		p=h;
		t=max(t,c);
	}
	cout << t;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;

typedef long long ll;
ll MOD = 1e9+7;
ll bit[70];

int main()
{
	ll a,b;
	ll ans=0;
	cin>>a>>b;
	fill(bit,bit+70,0);
	int i=0;
	while((ll)pow(2,i)<=b)
	{
		ll tmp=(ll)pow(2,i);
		bit[i]=(b/tmp/2-a/tmp/2)*tmp;//基本数
		cerr<<tmp<<" "<<bit[i]<<endl;
		//調整
		//下
		if(a%(tmp*2)>=tmp)
		{
			bit[i]-=a%(tmp*2)-tmp;
		}
		//上
		if(b%(tmp*2)>=tmp)
		{
			bit[i]+=b%(tmp*2)-tmp+1;
		}
		i++;
	}

	for(int j=0;j<64;j++)
	{
		//cerr<<bit[j]<<" ";
		if(bit[j]%2==1)
			ans+=(1LL<<j);
	}
	//cerr<<endl;
	cout<<ans<<endl;
	return 0;
}

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

const int INF = 1e9;
int G[51][51];

signed main(){

  int n,m; cin >> n >> m;
  fill(G[0],G[50],INF);
  for(int i = 0; i < m; i++){
    int a,b; cin >> a >> b;
    a--,b--;
    G[a][b] = G[b][a] = 1;
  }

  int cnt = 0;
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      if(G[i][j] == 1){
        int a[50][50];
        for(int x = 0; x < n; x++){
          for(int y = 0; y < n; y++){
            a[x][y] = G[x][y];
          }
        }
        a[i][j] = a[j][i] = INF;
        for(int k = 0; k < n; k++){
          for(int l = 0; l < n; l++){
            for(int m = 0; m < n; m++){
              a[l][m] = min(a[l][m],a[l][k]+a[k][m]);
            }
          }
        }

        int judge = 0;
        for(int k = 1; k < n; k++){
          if(a[0][k] > 114514) judge = 1;
        }
        if(judge) cnt++;
      }
    }
  }
  cout << cnt << endl;

  return 0;
}


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

typedef struct tag_circle {
	struct tag_circle *next;
	struct tag_circle *prev;
	int value;
} circle;

void rm_circle(circle *target) {
	if(target->next == target->prev)
		target->next->next = target->next->prev = NULL;
	else {
		target->prev->next = target->next;
		target->next->prev = target->prev;
	}
	free(target);
	return;
}

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

	circle *now, *first, *remove;

	do {
		scanf("%d %d", &n, &m);
		if(!n && !m)
			break;

		now = first = (circle*)malloc(sizeof(circle));
		now->next = NULL;
		now->prev = NULL;
		now->value = 1;

		for(i = 1; i < n; i++) {
			now->next = (circle*)malloc(sizeof(circle));
			now->next->prev = now;
			now = now->next; /* nowのさすアドレス変更 */
			now->next = NULL;
			now->value = i + 1;
		}

		now->next = first;
		first->prev = now;

		now = first;
		i = 1;
		while(now->next != NULL) {
			if(i % m == 0) {
				remove = now;
				now = now->next;
				rm_circle(remove);
			}

			else
				now = now->next;
			i++;
		}

		free(now);

		printf("%d\n", now->value);
	} while(1);

	return 0;
}

Measured memory_bytes: 1056
#include <cstdio>
int main() {
	int n, T, c, t, a = 0x3f3f3f3f;
	scanf("%d%d", &n, &T);
	for(int i = 1; i <= n; ++i) scanf("%d%d", &c, &t), a = (t <= T && c < a) ? c : a;
	if(a == 0x3f3f3f3f) printf("TLE");
	else printf("%d", a);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#define N 100001
#define INF 10000
using namespace std;


struct Node{
  int p,l,r;
};
Node t[N];

int sibling(int x){
  return t[x].r;
}

int dep(int x){
  int cnt=0;
  if(t[x].p>=0) cnt=dep(t[x].p)+1;
  return cnt;
}

int height(int x){
  int cntl=0,cntr=0;
  if(t[x].l>=0)cntl=height(t[x].l)+1;
  if(t[x].l>=0 && t[t[x].l].r>=0) cntr=height(t[t[x].l].r)+1;
  if(cntl<cntr)return cntr;
  else  return cntl;
}

int degree(int x){
  int cnt=0;
  if(t[x].l>=0)cnt++;
  if(t[x].l>=0 &&t[t[x].l].r>=0)cnt++;
  return cnt;
}

int main(){
  int n,id,c;
  cin>>n;
  for(int i=0;i<n;i++)t[i].l=-1,t[i].p=-1,t[i].r=-1;

  for(int i=0;i<n;i++){
    cin>>id;
    for(int j=0;j<2;j++){
      int befc=c;
      cin>>c;
      if(c>=0) t[c].p=id;
      if(j>0 && c>=0 && befc>=0)t[befc].r=c,t[c].r=befc;
      else if(j==0)t[id].l=c;
      if(t[id].l<0 && j>0)t[id].l=c;
    }
  }

  for(int i=0;i<n;i++){
    cout<<"node "<<i<<": parent = "<<t[i].p<<", sibling = "<<sibling(i)<<", degree = "<<degree(i) <<", depth = ";
    cout<<dep(i)<<", ";
    cout<<"height = "<<height(i)<<", ";
    if(t[i].l>=0 && t[i].p>=0) cout<<"internal node";
    else if(t[i].p==-1) cout<<"root";
    else cout<<"leaf";
    cout<<endl;
  }


  return 0;
}

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

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

  int x = max(A,C);
  int y = min(B,D);

  if (y-x<0){
    cout << 0 << endl;
  }
  else {
    cout << y-x << endl;
  }
}


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

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<string> S;
	for(int i = 0; i < N; ++i) {
		string s;
		cin >> s;
		S.push_back(s);
	}
	sort(S.begin(), S.end());
	int count = 1;
	int count_max = 1;
	deque<string> ans;
	ans.push_back(S[0]);
	for(int i = 1; i <= N; ++i) {
		if(i != N && S[i] == ans.back()) {
			++count;
		} else {
			if(count < count_max) {
				ans.pop_back();
			} else if(count > count_max) {
				ans.clear();
				ans.push_back(S[i - 1]);
				count_max = count;
			}
			if(i == N) break;
			count = 1;
			ans.push_back(S[i]);
		}
	}
	for_each(ans.begin(), ans.end(), [](string s) {
		cout << s << '\n';
	});
	return 0;
}



Measured memory_bytes: 15856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

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

	string str;
	str.push_back(s[0]);
	for (int i = 1; i < s.size(); i++) {
		if (s[i - 1] == s[i]) continue;
		else str.push_back(s[i]);
	}
	cout << str.size() - 1 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,b=0,ans=0,count=1;cin>>n;
  vector<int> a(1);
  a.at(0)=n;
  for(int i=0;b<2;i++){
    if(n%2==0)n/=2;
    else n=n*3+1;
    if(n==1)b++;
    a.push_back(n);
    count++;
  }
  
  for(int i=1;i<count-1;i++){
    for(int j=0;j<i;j++){
      if(a.at(i)==a.at(j)){
        ans=i+1;
        i=count;
        break;
      }
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	s = chomp(readline())
	k = readline() |> parseInt
	t = String[]
	l = length(s)
	for i in 1:min(k,l)
		for j in 1:l-i+1
			push!(t,s[j:j+i-1])
		end
	end
	u = Set(t)
	v = String[]
	for i in u
		push!(v,i)
	end
	v = sort(v)
	println(v[k])
end

main()


Measured memory_bytes: 116868
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

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

    vector<lint> a(n);
    for(auto& elem : a)  cin >> elem;

    partial_sum(begin(a), end(a), begin(a));
    a.insert(begin(a), 0);

    vector<lint> x;
    for(lint left=0; left<n; left++) {
        for(lint right=left+1; right<=n; right++) {
            x.push_back(a[right] - a[left]);
        }
    }

    bitset<60> ans;
    for(lint d=59; d>=0; d--) {
        vector<lint> cand;
        for(lint i=0; i<x.size(); i++) {
            bitset<60> bs(x[i]);
            if(bs.test(d))  cand.push_back(x[i]);
        }

        if(cand.size() >= k) {
            ans.set(d);
            x = cand;
        }
    }

    cout << ans.to_ullong() << endl;
}

Measured memory_bytes: 6392
# ABC 114 D

def resolve():
    N = int(input())
    e = [0] * (N+1)  # N! を素因数分解した結果の各素数の個数

    for i in range(2, N+1):
        # i の素因数分解を行う
        cur = i
        for j in range(2, i+1):
            while cur % j == 0:
                e[j] += 1
                cur //= j

    # dp[i][j] : i 番目の素因数まで考えたときに約数を j 個もつ数の個数
    dp = [[0] * 76 for _ in range(N+2)]
    dp[0][1] = 1

    for i in range(N+1):
        for have in range(76):
            for take in range(1, e[i]+2):
                if have * take > 75:
                    continue
                dp[i+1][have*take] += dp[i][have]

    print(dp[N][75])


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3316
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main()
{
  unsigned short *A,*B;
  int C[VMAX+1];
  int n,i,j;

  scanf("%d",&n);

  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);

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

 
  for(i=0;i<=VMAX;i++)
    {
      C[i]=0;
    }

  for(j=1;j<=n;j++)
    {
      C[A[j]]++;
    }

  for(i=1;i<=VMAX;i++)
    {
      C[i]=C[i]+C[i-1];
    }

  for(j=n;j>=1;j--)
    {
      B[C[A[j]]]=A[j];
      C[A[j]]--;
    }

  for(i=1;i<=n;i++)
    {
      printf("%d",B[i]);
      if(i<n)
        {
          printf(" ");
        }
      if(i==n)
        {
          printf("\n");
            }
    }


        
    
  
  return 0;
}
        


Measured memory_bytes: 9636
n=input('')
n=int(n)
s=[]
for a in range(n):
    b=input('')
    s.append(b)

vdic={}
for a in range(n):
    if s[a] in vdic:
        vdic[s[a]]=vdic[s[a]]+1
    else:
        vdic[s[a]]=1

max=0
for a in vdic:
    if vdic[a]>=max:
        max=vdic[a]

maxname=[]
for a in vdic:
    if vdic[a]==max:
        maxname.append(a)

maxname=sorted(maxname)

for a in maxname:
    print(a)

Measured memory_bytes: 36492
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
int main() {
    ios_base::sync_with_stdio(0);
    int l,r;
    cin >> l >> r;
    if (l<=0 && 0<=r) {
        cout << "Zero\n";
        return 0;
    }
    if (l<0) {
        int cnt=(r-l+1);
        if (cnt%2==0) cout << "Positive\n";
        else cout << "Negative\n";
    }
    else
    cout << "Positive\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N; long long D[101010];
int size[101010], parent[101010];
map<long long, int> D2I; //Distance-index;
vector<int> child[101010];
void check(bool p)
{
  if(!p)
  {
    puts("-1");
    exit(0);
  }
}
long long dfs(int ind, int height)
{
  long long ans = height;
  for(auto x: child[ind]) ans += dfs(x, height+1);
  return ans;
}
void verify_print()
{
  int root = 0;
  for(int i=1; i<=N; ++i)
  {
    if(parent[i]) child[parent[i]].push_back(i);
    else root = i;
  }
  check(dfs(root, 0) == D[root]);
  for(int i=1; i<=N; ++i)
    if(parent[i])
      printf("%d %d\n", parent[i], i);
  return;
}
int main()
{
  vector<pair<long long, int> > V;
  scanf("%d", &N);
  for(int i=1; i<=N; ++i)
  {
    scanf("%lld", D+i);
    V.emplace_back(D[i], i);
    D2I[D[i]] = i;
  }
  sort(V.rbegin(), V.rend());
  for(auto x: V)
  {
    long long distance; int index; tie(distance, index) = x;
    size[index]++;
    
    if(V[V.size()-1] == x) check(size[index] == N);
    else
    {
      check(size[index] <= (N-1)/2);
      long long pdist = distance - (N-2*size[index]);
      int pind = D2I[pdist]; check(pind != 0);
      parent[index] = pind; size[pind] += size[index];
    }
  }  
  verify_print();
  return 0;
}

Measured memory_bytes: 18672
#include <iostream>
#include <cstring>

using namespace std;

int w, h;
int mem[4][100][100];

#define START -1
#define PREV_IS_STRAIGHT_X 0
#define PREV_IS_STRAIGHT_Y 1
#define PREV_IS_TURN_X 2
#define PREV_IS_TURN_Y 3
#define MOD 100000


int dfs(int t,int x,int y){ // preが
	int res = 0;
	if(0 <= t && mem[t][x][y] != -1){
		return mem[t][x][y];
	}
	if(x == w - 1 && y == h - 1){
		return 1;
	}
	if(PREV_IS_STRAIGHT_X == t){
		if(x + 1 < w){
			res += dfs(PREV_IS_STRAIGHT_X,x + 1,y) % MOD;
		}
		if(y + 1 < h){
			res += dfs(PREV_IS_TURN_Y,x,y + 1) % MOD;
		}
	}else if(PREV_IS_STRAIGHT_Y == t){
		if(y + 1 < h){
			res += dfs(PREV_IS_STRAIGHT_Y,x,y + 1) % MOD;
		}
		if(x + 1 < w){
			res += dfs(PREV_IS_TURN_X,x + 1,y) % MOD;
		}
	}else if(PREV_IS_TURN_X == t){
		if(x + 1 < w){
			res += dfs(PREV_IS_STRAIGHT_X,x + 1,y) % MOD;
		}
	}else if(PREV_IS_TURN_Y == t){
		if(y + 1 < h){
			res += dfs(PREV_IS_STRAIGHT_Y,x,y + 1) % MOD;
		}
	}else{ // 初期状態
		if(x + 1 < w){
			res += dfs(PREV_IS_STRAIGHT_X,x + 1,y) % MOD;
		}
		if(y + 1 < h){
			res += dfs(PREV_IS_STRAIGHT_Y,x,y + 1) % MOD;
		}
		return res % MOD;
	}
	return mem[t][x][y] = res % MOD;
}




int main(void){

	while(1){
		cin >> w >> h;
		if(w == 0 && h == 0){
			break;
		}
		memset(mem,-1,sizeof(mem));
		cout << dfs(START,0,0) % MOD << endl;
	}
	return 0;
}

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

const int M=1e5+5;
vector<int> g[M];
int vis[M];
int pre[M];
int n,m;

int qu[M];

void bfs()
{
	int t=0;
	qu[t++]=1; pre[1]=1;
	for(int ii=0;ii<t;ii++)
	{
		int u=qu[ii];
		for(int v:g[u])
			if(!pre[v])
			{
				pre[v]=u;
				qu[t++]=v;
			}
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	int u,v;
	for(int i=0;i<m;i++)
	{
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	bfs();
	for(int i=1;i<=n;i++)
		if(!pre[i])
		{
			puts("No");
			return 0;
		}
	puts("Yes");
	for(int i=2;i<=n;i++)
		printf("%d\n",pre[i]);
	return 0;
}

Measured memory_bytes: 10860
t1, t2 = map(int,input().split())
a1, a2 = map(int,input().split())
b1, b2 = map(int,input().split())
a1 *= t1
b1 *= t1
a2 *= t2
b2 *= t2

if a1 + a2 == b1 + b2:
    print("infinity")
    exit()
if (a1 < b1 and a1+a2 < b1+b2) or (b1 < a1 and b1+b2 < a1+a2):
    print(0)
    exit()

d2 = abs(a1+a2-b1-b2)
d1 = abs(a1-b1)
print(1 + 2*(d1//d2) - (d1 % d2 == 0))

Measured memory_bytes: 9132
n, m = map(int, input().split())
mod = 10**9 + 7
# [[素因数,数]]を出力
def fctr1(n):
    f = []
    c = 0
    r = int(n**0.5)
    for i in range(2, r+2):
        while n % i == 0:
            c += 1
            n = n//i
        if c != 0:
            f.append([i, c])
            c = 0
    if n != 1:
        f.append([n, 1])
    return f

def comb(n, r):
    res = 1
    for i in range(1, r+1):
        res = res*(n-i+1) % mod
        res = res*pow(i, mod-2, mod) % mod
    return res

prime_count = fctr1(m)
#print(prime_count)
ans = 1
for p, e in prime_count:
    ans *= comb(e+n-1, e)
    ans %= mod
print(ans)

Measured memory_bytes: 63304
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

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

int main(){fastio
    ll n;cin>>n;
    vector<l_l>v[n+1];
    
    rep(i,0,n-2){
        ll a,b;cin>>a>>b;
        v[a].pb({b,i});
        v[b].pb({a,i});
    }
    ll mx=0;
    ll col[n-1];memset(col,0,sizeof(col));
    queue<ll>q;q.push(1);
    bool visit[n+1];memset(visit,false,sizeof(visit));visit[1]=true;
    while(!q.empty()){
        ll i=q.front();q.pop();
        set<ll>used;
        ll pos=1;
        for(auto x:v[i]){
            if(!visit[x.fi]){
                q.push(x.fi);visit[x.fi]=true;
            }
            if(col[x.se]){
                used.insert(col[x.se]);
            }
        }
        for(auto x:v[i]){
            if(!col[x.se]){
                while(used.find(pos)!=used.end())pos++;
                col[x.se]=pos;
                used.insert(pos);
                pos++;
            }
        }
    }
    //cout<<mx<<endl;
    rep(i,0,n-2)Max(mx,col[i]);
    cout<<mx<<endl;
    rep(i,0,n-2)cout<<col[i]<<endl;
    
    return 0;
}


Measured memory_bytes: 8960
a,b,c = map(int,input().split())
ans = 0
l = [a,b,c]
maa = max(l)
l.remove(maa)
maa2 = max(l)
l.remove(maa2)
maa3 = l[0]
for i in range(maa-maa2):
    maa3 += 1
    maa2 += 1
    ans += 1
if (maa-maa3)%2 == 0:
    ans += (maa-maa3)/2
    print(int(ans))
else:
    ans += (maa-maa3+1)/2
    print(int(ans+1))
    
    



Measured memory_bytes: 3064
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    s = input()

    for i in range(len(s)):
        if i % 2:
            if s[i] not in ['L', 'U', 'D']:
                print('No')
                sys.exit()
        else:
            if s[i] not in ['R', 'U', 'D']:
                print('No')
                sys.exit()

    print('Yes')


if __name__ == '__main__':
    main()

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

a = [n]

while True:
    if a[-1]%2 == 0:
        if a[-1]//2 not in a:
            a.append(a[-1]//2)
        else:
            print(len(a)+1)
            break
    else:
        if (3*a[-1]+1) not in a:
            a.append(3*a[-1]+1)
        else:
            print(len(a)+1)
            break

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

int main(){
    int n;
    string Taro, Hanaco;
    int T = 0, H = 0;
    cin >> n;

    for (int i = 0; i < n; i++){
        cin >> Taro >> Hanaco;
        if (Taro > Hanaco) T += 3;
        if (Taro == Hanaco) {
            T += 1;
            H += 1;
        }
        if (Taro < Hanaco) H += 3;
    }
    cout << T << " " << H << endl;
    return 0; 

}


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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

void chmin(int &a, int b){
  if(a > b)
    a = b;
}
void chmax(int &a, int b){
  if(a < b)
    a = b;
}

void llchmin(ll &a, ll b){
  if(a > b)
    a = b;
}
void llchmax(ll &a, ll b){
  if(a < b)
    a = b;
}

int main(){
  int a;
  cin >> a;
  
  cout << a+a*a+a*a*a << endl;
  
  return 0;
  
}

Measured memory_bytes: 3640
s = gets.chomp
S = s.split('')
a = Array.new
if s.length % 2 == 0
    for i in 0..(s.length / 2)-1
        a[i] = S[2 * i]
    end
else
    for i in 0..s.length / 2
        a[i] = S[2 * i]
    end
end

puts a.join('')

Measured memory_bytes: 7492
//#include "stdc++.h"
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

ll gcd(ll a, ll b){
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a, b);
}
int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x,y,v,n;
    n=(b-a)+1;
    x=(b/c)-(a/c);
    if(a%c==0)
    {
        x++;
    }
    y=(b/d)-(a/d);
    if(a%d==0)
    {
        y++;
    }
    //cout<<x<<y<<endl;
    ll z=lcm(c,d);
    //cout<<z<<endl;
    v=(b/z)-(a/z);
    if(a%z==0)
    {
        v++;
    }
    v=(x+y)-v;
    ll ans=n-v;
    cout<<ans<<endl;
    return 0;
}

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

int main(void){
    // Your code here!
    
    int n;
    int ans=0;
   char s[200001];
   char t[200001];
    scanf("%s %s",s,t);
    n=strlen(s);

for(int i=0;i<n;i++){
    if(s[i]==t[i]){
        ans++;
    }
}

    printf("%d",n-ans);
 
  return 0;
}

Measured memory_bytes: 2072
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<double> v;
  tools::read(v, N);

  std::sort(v.begin(), v.end());
  double answer = 0.0;
  for (i64 i = 0; i < N; ++i) {
    answer += v[i] / std::pow(2.0, std::min(N - i, N - 1));
  }
  std::cout << std::fixed << std::setprecision(5) << answer << std::endl;
  return 0;
}

Measured memory_bytes: 384
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*16
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
#define int long long
	int n;
	cin >> n;
	vector<int> a, b;
	REP(i, n) {
		int c;
		cin >> c;
		a.push_back(c);
	}
	REP(i, n) {
		int c;
		cin >> c;
		b.push_back(c);
	}
	vector<int> winning;
	int required = 0;
	int ans = 0;
	REP(i, n) {
		if (a[i] < b[i]) {
			required += b[i] - a[i];
			ans++;
		}
		else {
			winning.push_back(a[i] - b[i]);
		}
	}
	sort(winning.begin(), winning.end(), greater<int>());
	if (required == 0) {
		cout << ans << endl;
		return 0;
	}
	for (int i = 0; i < winning.size(); ++i) {
		required -= winning[i];
		ans++;
		if (required <= 0) {
			cout << ans << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 3316
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC_113_A solver = new ABC_113_A();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC_113_A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int x = in.nextInt();
            int y = in.nextInt();

            out.print(x + y / 2);
        }

    }
}



Measured memory_bytes: 24020
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int n = sz(s);
    ll ans = 0;
    rep(bit, 1<<(n-1)) {
        ll now = 0;
        ll cur = s[0] - '0';
        for (int i = 1; i < n; ++i) {
            if (bit>>(i-1)&1) {
                now += cur;
                cur = s[i] - '0';
            } else {
                cur *= 10;
                cur += s[i] - '0';
            }
        }
        now += cur;
        ans += now; 
    }
    cout << ans << endl;
}

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

using namespace std;

#define ll long long
#define ld long double

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector <int> a(n);
    int ans = 0;
    for (int i = 0; i < n; i ++) {
        cin >> a[i];
        ans ^= a[i];
    }
    for (int i = 0; i < n; i++) {
        ans ^= a[i];
        cout << ans << ' ';
        ans ^= a[i];
    }
    return 0;
}


Measured memory_bytes: 3988
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        String[] list = {"a", "b", "c", "d", "e", "f", "g",
                "h", "i", "j", "k", "l", "m", "n",
                "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};

        for (int i = 0; i < list.length ; i++) {
            if (s.equals(list[i])) {
                System.out.println(list[i + 1]);
                return;
            }
        }
    }
}

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

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

    string s;
    cin >> s;

    if (s[0] == s[1]) cout << "Bad" << endl;
    else if (s[1] == s[2]) cout << "Bad" << endl;
    else if (s[2] == s[3]) cout << "Bad" << endl;
    else cout << "Good" << endl;
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    int c=0;
    int m=1;
    while(m<=n){
        m*=10;
        c++;
    }
    if(c%2==0){
        int l=1;
        int d=0;
        while(l<m){
            d+=l;
            l*=100;
        }
        cout<<d*9<<endl;
    }else{
        int l=1;
        int d=0;
        while(l<m/10){
            d+=l;
            l*=100;
        }
        cout<<d*9+n-m/10+1<<endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define fast_io() ios::sync_with_stdio(false); cin.tie(nullptr)
#define fix(n) fixed << setprecision(n)

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    fast_io();
    
    ll h,w;
    cin >> h >> w;
    vector<vector<bool>> is_bomb(h+2, vector<bool> (w+2));
    rep(i,h){
        string s;
        cin >> s;
        rep(j,w){
            is_bomb[i+1][j+1] = (s[j] == '#');
        }
    }

    vector<vll> bomb_count(h,vll(w));

    rep(i,h){
        rep(j,w){
            if(!is_bomb[i+1][j+1]){
                ll count = 0;
                rep(find_i,3){
                    rep(find_j,3){
                        if(find_i == 1 && find_j == 1) continue;

                        if(is_bomb[i+find_i][j+find_j]) count++;
                    }
                }
                bomb_count[i][j] = count;
            } else {
                bomb_count[i][j] = -1;
            }
        }
    }


    for(auto v : bomb_count){
        for(auto i : v){
            if(i == -1){
                cout << '#';
            } else {
                cout << i;
            }
        }
        cout << endl;
    } 


    return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main() {
  Cin(int, n, l);

  int mindif = 1e9;
  int idx = 0;
  for (int i = 1; i <= n; ++i) {
    if (mindif > abs(l + i - 1)) {
      mindif = abs(l + i - 1);
      idx = i;
    }
  }

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

  sum -= (l + idx - 1);

  cout << sum << endl;
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256