akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define ic_s string s;cin>>s;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
typedef long double ld;
const ld eps = 1.0e-10; // 許容される誤差
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n != 0) {
		sum += n % 10; n /= 10;
	}
	return sum;//Nanashi,tRue,wai
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */
ld mysqrtl(ld x)
{
	ld a = sqrtl((double)x); // 近似値
	do {
		a = (a + x / a) / 2.0L;
	} while (fabsl(x - a * a) > eps);
	return a;
}
//平方根を求める。sqrtより精度が高い。
//epsを変えて誤差を調整する。
int main(void) {
	Rapid_pleaseAC_fast;
	long long h,w,limit,nw=0,nh=0,ans=0,n,m;
	llint anw, anh, ans2=0;
	char c;
	bool check=false,acheck=false;
	cin >> n >> m ;
	ans = ((n - 1) * n / 2) + ((m - 1) * m / 2);
	std::cout << ans << endl;
	please AC;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <random>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

struct MyStruct {
	int x, y;
	bool cleared = false;
};

bool comp(const MyStruct& s, const MyStruct& t) {
	if (s.x != t.x)
		return s.x > t.x; //降順
	return s.y > t.y;
}

bool is_online(int x1, int y1, long long kx, long long ky, int cx, int cy) {
	long long dx = cx - x1;
	long long dy = cy - y1;
	if ((long long)kx*dy == (long long)dx*ky) return true;
	else return false;
}


int main() {
	long long W, H, x, y;
	cin >> W >> H >> x >> y;

	int check = 0;

	double area = W*H*1.0 / 2;

	if (W % 2 == 0 && x == W / 2 && H % 2 == 0 && H / 2 == y) {
		check = 1;
	}

	cout << fixed<<setprecision(7)<< area << " " << check << endl;


	return 0;
}


Measured memory_bytes: 256
using System;

namespace kawa
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			int[] high = new int[10];
			for (int i = 0; i < 10; i++)
			{
				high[i] = int.Parse(Console.ReadLine());
			}
			Array.Sort(high);
			for (int i = 9; i > 6; i--)
			{
				Console.WriteLine(high[i]);
			}
		}
	}
}

Measured memory_bytes: 9284
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
i = 0
flag = False
ans = 0
while i < n-1:
    if not flag and a[i+1] == a[i]:
        flag = True
        h = a[i]
        i += 2
    elif flag and a[i+1] == a[i]:
        ans = h * a[i]
        break
    else:
        i += 1

print(ans)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;



int main()
{
	string s,t;
	cin>>s>>t;
	if(s.length()>t.length())cout<<"GREATER"<<endl;
	else if(s.length()<t.length())cout<<"LESS"<<endl;
	else
	{
		if(s>t)cout<<"GREATER"<<endl;
		else if(s<t)cout<<"LESS"<<endl;
		else cout<<"EQUAL"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
    ll n ,m;
    char c;
    cin>>n>>m;
    vector<vector<ll>>grid(n,vector<ll>(m,0));
    int mod=1000000007;

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>c;
            if(c=='.')
            grid[i][j]=0;
            else
            {
                grid[i][j]=-1;
            }
            
        }
    }
    if(grid[0][0]==-1||grid[n-1][m-1]==-1)
    return -1;
    for(int i=1;i<n;i++)
    {
        if(grid[i][0]!=-1)
        grid[i][0]=1;
        else
        {
            break;
        }
        
    }


    
    for(int i=1;i<m;i++)
    {
        if(grid[0][i]!=-1)
        grid[0][i]=1;
        else
        {
            break;
        }
        
    }
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<m;j++)
        {   
            if(grid[i][j]>=0)
            {
            if(grid[i-1][j]>0)
            grid[i][j]=(grid[i][j]+grid[i-1][j])%mod;
            if(grid[i][j-1]>0)
            grid[i][j]=(grid[i][j]+grid[i][j-1])%mod;
            }
        }
    }
    cout<<grid[n-1][m-1];
    return 0;
}

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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int a, b, c;
	int temp = 0;
	cin >> a >> b >> c;
	temp = a;
	a = b;
	b = temp;
	temp = a;
	a = c;
	c = temp;
	
	cout << a << " " << b << " " << c;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

const i64 mod = 1e9 + 7;
i64 ipow(i64 a, i64 b) {
    i64 x = a, y = 1;
    for (; b > 0; b >>= 1) {
        if (b & 1) (y *= x) %= mod;
        (x *= x) %= mod;
    }
    return y;
}
i64 inv(i64 x) {
    return ipow(x, mod - 2);
}
i64 fact(i64 x) {
    static vector<i64> f;
    i64 i = f.size();
    if (x >= i) {
        f.resize(x + 1);
        for (; i <= x; ++i) {
            f[i] = i == 0 ? 1 : i * f[i - 1] % mod;
        }
    }
    return f[x];
}
i64 perm(i64 n, i64 k) {
    return k <= n ? fact(n) * inv(fact(n - k)) % mod : 0;
}
i64 conb(i64 n, i64 k) {
    return k <= n ? fact(n) * inv(fact(k) * fact(n - k) % mod) % mod : 0;
}

i64 dp[102][2][5];
string s;
int k, n;
i64 f(int i, bool b, int c) {
    if (c == 0) return 1;
    if (i == n) return 0;
    if (dp[i][b][c] > 0) return dp[i][b][c];
    int d = s[i] - '0';
    i64 res = 0;
    if (b) {
        if (d == 0) {
            res = f(i + 1, true, c);
        } else {
            res = f(i + 1, true, c - 1) + (d - 1) * f(i + 1, false, c - 1) + f(i + 1, false, c);
        }
    } else {
        res = 9 * f(i + 1, false, c - 1) + f(i + 1, false, c);
    }
    return dp[i][b][c] = res;
}

int main() {
    /*
    i64 r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    */
    cin >> s >> k;
    n = s.size();
    i64 ans = f(0, true, k);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,k,s,an;
void ss(int j,int sum,int kai){
  if(kai==k-1&&j<s-sum&&s-sum<=n)an++;
  if(kai<k-1&&s-sum>j)
    for(int i=j+1;i<=n;i++)ss(i,sum+i,kai+1);  
}

int main(){
  while(1){
    cin>>n>>k>>s;
    if(n==0)break;
    an=0;
    ss(0,0,0);
    cout<<an<<endl;
  } 
  return 0;
}

Measured memory_bytes: 1160
n = int(input())
g1, s1, b1 = map(int, input().split())
g2, s2, b2 = map(int, input().split())

go, back = [], []

if g1 > g2:
	back.append([g2, g1-g2])
elif g1 < g2:
	go.append([g1, g2-g1])

if s1 > s2:
	back.append([s2, s1-s2])
elif s1 < s2:
	go.append([s1, s2-s1])

if b1 > b2:
	back.append([b2, b1-b2])
elif b1 < b2:
	go.append([b1, b2-b1])

if len(go) == 0:
	m = n
elif len(go) == 1:
	m = go[0][1] * (n // go[0][0]) + n
else:
	dp1 = [n for _ in range(n+1)]
	for cost, value in go:
		for i in range(n-cost+1):
			dp1[i+cost] = max(dp1[i+cost], dp1[i] + value)
	m = dp1[n]

if len(back) == 0:
	ans = m
elif len(back) == 1:
	ans = back[0][1] * (m // back[0][0]) + m
else:
	dp2 = [m for _ in range(m+1)]
	for cost, value in back:
		for i in range(m-cost+1):
			dp2[i+cost] = max(dp2[i+cost], dp2[i] + value)
	ans = dp2[m]

print(ans)

Measured memory_bytes: 422320
def main():
    N = int(input())
    S = input()
    count_white = 0
    count_black = 0
    count_white_R = S.count('.')
    count_black_R = S.count('#')
    min_rev = count_black + count_white_R
    for i in range(len(S)):
        if S[i] == '#':
            count_black += 1
            count_black_R -= 1
        else:
            count_white += 1
            count_white_R -= 1
        rev = count_black + count_white_R
        min_rev = min(rev,min_rev)
    print(min(min_rev,S.count('.'),S.count('#')))

if __name__ == "__main__":
    main()
    

Measured memory_bytes: 3500
n,m,q=map(int,input().split())
def ruiseki(a):
    l=[0]
    for i in range(len(a)):
        l.append(l[i]+a[i])
    del l[0]
    return l
l=[]
def niruiseki(a):
    l.append(ruiseki(a[0]))
    for i in range(1,len(a)):
        p=[l[i-1][0]+a[i][0]]
        q=[a[i][0]]
        for j in range(1,len(a[i])):
            q.append(q[j-1]+a[i][j])
            p.append(q[j]+l[i-1][j])
        l.append(p)
ll=[[0]*(n+1) for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    ll[a][b]+=1
niruiseki(ll)
for i in range(q):
    a,b=map(int,input().split())
    print(l[b][b]+l[a-1][a-1]-l[a-1][b]-l[b][a-1])

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

#define MIN(A,B) (A)<(B)?(A):(B)
#define MAX(A,B) (A)>(B)?(A):(B)

#define N 200000

int main(){
  int n, a, b, c=0, i, m=0;
  int H[N]={0}, d;
  scanf("%d", &n);
  for (i=0; i<n; i++){
    scanf("%d", &H[i]);
  }

  for (i=n-2; i>=0; i--){
    if (H[i]>=H[i+1]) {
      c++;
      if (m<c) m=c;
    } else c=0;
  }
  printf("%d\n", m);
  return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repp(i, n) for(int i = 1; i <= (int)(n); i++)
#define co(x) cout<<x<<endl
typedef long long int lint;

int main(){
  int N,M,sum = 0;
  cin >> N >> M;
  vector<int> A(M);
  rep(i,M){cin >> A.at(i); sum += A.at(i);}

  if(sum <= N){co(N - sum);}
  else{co(-1);}
}  

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define bitoff(val,pos) val & ~(1<<pos)
#define biton(val,pos) val | (1<<pos)
#define bittgl(val,pos) val ^ (1<<pos)
#define bitchk(val,pos) (bool)(val & (1<<pos))
#define odevn(val,pos) (bool)(val & (1<<pos))
#define bitcnt(val) __builtin_popcount(val)
ll ar[1000000],br[1000000],vis[1000009],cm[1000009],ck,n,r,sum,k,sm;
string st;
vector<ll>vec;
vector<ll>vec2[200009];
queue<ll>qq;
stack<ll>stk;
map<string,ll>mp;map<ll,ll>mp1;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll min1=9999999999;
    ll i,j,e,d,t,s=0;
    double dd,vv,gg;
    cin >> d >> e;
    j=d/e;
    if(d%e!=0)
    {
        j++;
    }
    cout << j << endl;
}



Measured memory_bytes: 6400
x, k, d = map(int, input().split(' '))
x = abs(x)
if k * d <= x:
    print(x - k * d)
    exit(0)
p = x // d
assert p < k

x -= p * d
k -= p
x = abs(x)
ans = [x, abs(x - d)]
print(ans[k % 2])

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

int main(){
    long long n,m;
    cin >> n >> m;
    long long x[n],y[m];
    for(int i=0; i<n; i++) cin >> x[i];
    for(int i=0; i<m; i++) cin >> y[i];
    long long u[n-1],v[m-1];
    for(long long i=0; i<n-1; i++) u[i] = (i+1)*(n-1-i);
    for(long long i=0; i<m-1; i++) v[i] = (i+1)*(m-1-i);
    long long xx=0,yy=0;
    long long mod = 1000000007;
    for(int i=0; i<n-1; i++){
        xx += (u[i]*(x[i+1]-x[i]))%mod; 
        xx %= mod;
    }
    for(int i=0; i<m-1; i++){
        yy += (v[i]*(y[i+1]-y[i]))%mod;
        yy %= mod;
    }
    cout << xx*yy%mod << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 21;

int main() {
	ll a, b, c; cin >> a >> b >> c;

	ll ans = 0;
	if (b >= c) {
		ans = b + c;
	}
	else {
		if (a == c - b) {
			ans = a + b * 2;
		}
		else if (a < c - b) {
			ans = a + b * 2 + 1;
		}
		else if (a > c - b) {
			ans = b + c;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        boolean f=true;
        int[] c = new int[4];
        while(true){
            
            int sum = sc.nextInt();
            if(sum==0)break;
            if(!f)System.out.println();
            f=false;
            int coins = 0;
            for (int i = 0; i < c.length; i++) {
                c[i]=sc.nextInt();
                coins+=c[i];
            }
            int[] ans=new int[4];
            int min = 1<<29;
            for (int i = 0; i <= c[0]; i++) {
                for (int j = 0; j <= c[1]; j++) {
                    for (int j2 = 0; j2 <= c[2]; j2++) {
                        for (int k = 0; k <= c[3]; k++) {
                            int s = 0;
                            s+=i*p[0];
                            s+=j*p[1];
                            s+=j2*p[2];
                            s+=k*p[3];
                            if(s<sum)continue;
                            int[] change = change(sum,s);
//                            System.out.println(Arrays.toString(change));
                            if(i>0&&change[0]>0)continue;
                            if(j>0&&change[1]>0)continue;
                            if(j2>0&&change[2]>0)continue;
                            if(k>0&&change[3]>0)continue;

                            if(min>coins-(i+j+j2+k)+change[4]){
                                ans[0]=i;
                                ans[1]=j;
                                ans[2]=j2;
                                ans[3]=k;
                                min=coins-(i+j+j2+k)+change[4];
                            }
                        }
                    }
                }
            }
            for (int i = 0; i < p.length; i++) {
                if(ans[i]==0)continue;
                System.out.println(p[i]+" "+ans[i]);
            }
        }
    }
    static  int[] p = {10,50,100,500};
    static int[] res = new int[5];
    static int[] change(int sum,int s){
        
        
        s = s-sum;
        Arrays.fill(res, 0);
        for (int i = 3; i >= 0; i--) {
            while(s-p[i]>=0){
                s-=p[i];
                res[i]++;
                res[4]++;
            }
        }
        return res;
    }
}

Measured memory_bytes: 37804
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;

int a[300005];
int dp[300005][2];
int bit[20];

int main(){
    int n;
    scanf("%d", &n);
    int m = (1<<n);
    for(int i=0; i<m; i++) scanf("%d", &a[i]);
    bit[0] = 1;
    for(int i=1; i<20; i++) bit[i] = bit[i-1]<<1;
    int res = 0;
    for(int k=1; k<m; k++){
        if(a[k] > a[dp[k][0]]) dp[k][1] = dp[k][0], dp[k][0] = k;
        else if(a[k] > a[dp[k][1]] || dp[k][1] == dp[k][0]) dp[k][1] = k;
        for(int i=0; i<n; i++){
            int new_k = k|bit[i];
            if(a[dp[k][0]] > a[dp[new_k][0]]) dp[new_k][1] = dp[new_k][0], dp[new_k][0] = dp[k][0];
            else if(a[dp[k][0]] > a[dp[new_k][1]] && (dp[k][0] != dp[new_k][0] || dp[new_k][0] == dp[new_k][1])) dp[new_k][1] = dp[k][0];
            if(a[dp[k][1]] > a[dp[new_k][0]]) dp[new_k][1] = dp[new_k][0], dp[new_k][0] = dp[k][1];
            else if(a[dp[k][1]] > a[dp[new_k][1]] && (dp[k][1] != dp[new_k][0] || dp[new_k][0] == dp[new_k][1])) dp[new_k][1] = dp[k][1];
        }
        res = max(res, a[dp[k][0]]+a[dp[k][1]]);
        printf("%d\n", res);
    }
    return 0;
}


Measured memory_bytes: 6144
N = int(input())
AB = [list(map(int,input().split())) for _ in [0]*(N-1)]

E = [{} for _ in [0]*N]
for a,b in AB:
    E[a-1][b-1] = 1
    E[b-1][a-1] = 1

def dist_dfs_tree(N,E,start):
    d = [-1]*N
    d[start] = 0
    q = [start]
    while q:
        i = q.pop()
        ci = d[i]
        for j,cj in E[i].items():
            if d[j] !=-1:continue
            d[j] = ci+cj
            q.append(j)
    return d

D1 = dist_dfs_tree(N,E,0)
Dn = dist_dfs_tree(N,E,N-1)
d1n = D1[-1]
for i,dd in enumerate(zip(D1,Dn)):
    if dd[0] == d1n//2 and sum(dd) == d1n:break

di = Dn[i]
for j in E[i]:
    if Dn[j]==di-1:break
E[i].pop(j)
E[j].pop(i)
s1 = sum(s>=0 for s in dist_dfs_tree(N,E,0))
print("Fennec" if s1 > N//2 else "Snuke")

Measured memory_bytes: 75264
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 998244353;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()

ll modPow(ll a, ll n) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  ll t = modPow(a, n / 2);
  return (t * t) % MOD;
}

int main(){
  ll N,A,B,K,ans=0;
  cin >> N >> A >> B >> K;
  if(K%gcd(A,B)!=0){
    cout << 0 << endl;
    return 0;
  }
  vec comb(N+1);
  comb.at(0)=1;
  rep(i,N){
    comb.at(i+1)=comb.at(i)*(N-i);
    comb.at(i+1)%=MOD;
    comb.at(i+1)*=modPow(i+1,MOD-2);
    comb.at(i+1)%=MOD;
  }
  rep(i,N+1){
    if(K<A*i){
      break;
    }
    if((K-A*i)%B==0&&(K-A*i)/B<=N){
      ans+=comb.at(i)*comb.at((K-A*i)/B);
      ans%=MOD;
    }
  }
  cout << ans << endl;
      
}

Measured memory_bytes: 5640
#include <iostream>
#include <string>
#include <sstream>
#include <cctype>

using namespace std;

int solve(stringstream &ss, int remains, char &result){
	int length = 0;
	while(ss.tellg() < ss.str().size() && remains >= 0){
		if(isdigit(ss.peek())){
			int loop;
			ss >> loop;
			char c = ss.get();
			if(c == '('){
				streampos pos = ss.tellg();
				int len = solve(ss, remains, result);
				if(len < 0){ return -1; }
				if(len * loop > remains){
					ss.seekg(pos, ios_base::beg);
					solve(ss, remains % len, result);
					return -1;
				}
				remains -= len * loop;
				length += len * loop;
			}else{
				if(loop > remains){
					result = c;
					return -1;
				}
				remains -= loop;
				length += loop;
			}
		}else{
			char c = ss.get();
			if(c == ')'){
				break;
			}else if(remains-- == 0){
				result = c;
				return -1;
			}
			++length;
		}
	}
	return length;
}

int main(){
	while(true){
		string s;
		int pos;
		cin >> s >> pos;
		if(s == "0" && pos == 0){ break; }
		char answer = '0';
		stringstream ss(s);
		solve(ss, pos, answer);
		cout << answer << endl;
	}
	return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    FOREACH(x, v) { cout << x << " "; }                                        \
    cout << "\n";

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, M;
struct edge {
    ll to, cost;
    bool operator<(const edge &another) const { return cost < another.cost; };
    bool operator>(const edge &another) const { return cost > another.cost; };
};
vector<vector<edge>> g;
VL d;

void dijkstra(ll s) {
    priority_queue<edge, vector<edge>, greater<edge>> pq;
    d.assign(N, LINF);
    d[s] = 0;
    pq.push({s, 0});

    while(!pq.empty()) {
        edge now = pq.top();
        pq.pop();
        ll v = now.to;
        if(d[v] < now.cost) continue;

        REP(i, g[v].size()) {
            edge e = g[v][i];
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                pq.push({e.to, d[e.to]});
            }
        }
    }
}

int main() {
    cin >> N >> M;
    g.resize(N);
    REP(i, M) {
        LCIN(a, b);
        g[--a].push_back({--b, 1});
        g[b].push_back({a, 1});
    }
    dijkstra(0);
    if(d[N - 1] <= 2)
        cout << "POSSIBLE"
             << "\n";
    else
        cout << "IMPOSSIBLE"
             << "\n";
}

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

char s[200002]; int cnt[28];
int gc[28];
char pre[100002], suf[100002];
int ptr[28], num[100002];
int tr[100002];

long long group(int L){
  long long res = 0;
  int oc = 0, tc = 0, pc = 0, sc = 0;

  for(int i = 1; i <= L; i++){
    int x = s[i] & 31, &g = gc[x], c = cnt[x]; g += 2;

    if(g < c + 1){ res += oc + tc; pre[++pc] = s[i]; }
    else if(g == c + 1){ res += tc; oc++; }
    else{ tc++; suf[++sc] = s[i]; }
  }

  return res;
}

int main(){
  scanf("%s", s + 1); int L = strlen(s + 1);
  for(int i = 1; i <= L; i++) cnt[s[i] & 31]++;

  int odd = 0;

  for(int i = 1; i <= 26; i++) if(cnt[i] & 1) odd++;

  if(odd > 1){ puts("-1"); return 0; }

  long long ans = group(L);

  int M = L / 2;

  reverse(suf + 1, suf + M + 1);

  for(int i = 1; i <= M; i++){
    char c = pre[i]; int &p = ptr[c & 31];
    while(suf[++p] != c);

    num[p] = i;
  }

  for(int i = M; i >= 1; i--){
    int x = num[i];
    for(int y = x - 1; y > 0; y -= y & -y) ans += tr[y];
    for(; x <= M; x += x & -x) tr[x]++;
  }

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

Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int solve(int bin) {
    if(bin == 0) return 0;
    int ret = 1;
    while(bin != 0) {
        bin = bin % __builtin_popcount(bin);
        ++ret;
    }
    return ret;
}

int main() {
    int n; cin >> n;
    string x; cin >> x;
    int modPlus1 = 0, modMinus1 = 0, pow2 = 1, x_popcount = 0;
    rep(i, n) {
        if(x[i] == '1') ++x_popcount;
    }
    for(int i = x.size() - 1; i >= 0; --i) {
        modPlus1 = (modPlus1 + pow2 * (x[i] == '1')) % (x_popcount + 1);
        pow2 = (pow2 * 2) % (x_popcount + 1);
    }
    pow2 = 1;
    if(x_popcount > 1) {
        for(int i = x.size() - 1; i >= 0; --i) {
            modMinus1 = (modMinus1 + pow2 * (x[i] == '1')) % (x_popcount - 1);
            pow2 = (pow2 * 2) % (x_popcount - 1);
        }
        pow2 = 1;
    }
    int pow2Plus1 = 1, pow2Minus1 = 1;
    vector<int> ans;
    for(int i = x.size() - 1; i >= 0; --i) {
        if(x[i] == '1') {
            int mod = (x_popcount - 1);
            if(mod == 0) {
                ans.pb(0);
            } else if(x_popcount != 1 && (modMinus1 - pow2Minus1 + mod) % mod == 0) {
                ans.pb(1);
            } else {
                ans.pb(solve((modMinus1 - pow2Minus1 + mod) % mod));
            }
        }else {
            int mod = (x_popcount + 1);
            if((modPlus1 + pow2Plus1) % mod == 0) {
                ans.pb(1);
            }else {
                ans.pb(solve((modPlus1 + pow2Plus1) % mod));
            }
        }
        if(x_popcount - 1 != 0) pow2Minus1 = (pow2Minus1 * 2) % (x_popcount - 1);
        pow2Plus1 = (pow2Plus1 * 2) % (x_popcount + 1);
    }
    rep(i, ans.size()) {
        cout << ans[ans.size() - 1 - i] << endl;
    }
}


Measured memory_bytes: 4468
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(), v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 1;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        int g = 0;
        int a[n];
        unordered_map<int, int> vis;
        for(int &it : a){
            cin >> it;
            vis[it] = 1;
            g = __gcd(g, it);
        }
        if(g > 1){
            cout << "not coprime\n";
        }else{
            int flag = 1;
            vector<int> prime((int)1e6 + 1, 1);
            for(int i = 2; i <= 1e6; i++){
                if(!prime[i]){
                    continue;
                }
                int cnt = 0;
                if(vis[i]){
                    cnt++;
                }
                for(int j = 2 * i; j <= 1e6; j += i){
                    if(vis[j]){
                        cnt++;
                    }
                    prime[j] = 0;
                }
                if(cnt > 1){
                    flag = 0;
                    break;
                }
            }
            if(flag){
                cout << "pairwise coprime\n";
            }else{
                cout << "setwise coprime\n";
            }
        }
    }
}

Measured memory_bytes: 89532
#include <iostream>
#include <cmath>

using namespace std;

#define EPS 1e-7

class Point{
public:
  double x,y;
  Point(double x = 0.0,double y = 0.0) : x(x),y(y) {}
  Point operator + (Point p){ return Point(x+p.x, y+p.y); }
  Point operator - (Point p){ return Point(x-p.x, y-p.y); }
  Point operator * (double a){ return Point(x*a, y*a); }
  Point operator / (double a){ return Point(x/a, y/a); }
  double abs(){ return sqrt(norm()); }
  double norm(){ return x*x + y*y; }
};

typedef Point Vector;
double dot(Vector a,Vector b){
  return a.x*b.x + a.y*b.y;
}
double cross(Vector a,Vector b){
  return a.x*b.y - a.y*b.x;
}

class Segment{
public:
  Vector t,s;
  Segment(Vector t,Vector s) : t(t),s(s) {}
  Point projection(Point &p){
    Vector b = s - t;
    double d = dot(p-t,b) / b.norm();
    return t + b*d;
  }
};

class Circle{
public:
  double x,y,r;
  Circle(double x = 0.0,double y = 0.0,double r = 0.0) : x(x),y(y),r(r) {}
};

int N;
Point t,s;
Circle ci[300];

bool check(Point p0,Point p1,Point p2){
  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if(cross(a,b) > EPS) return false;
  if(cross(a,b) < -EPS) return false;
  if(dot(a,b) < -EPS) return false;
  if(a.norm() < b.norm()) return false;
  return true;
}

bool getStateCS(Circle c,Segment seg){
  Point cp = Point(c.x,c.y);
  Point p = seg.projection(cp);
  Point pp = p - cp;


  Vector a = seg.t - cp;
  Vector b = seg.s - cp;
    
  if((a.abs() > c.r && b.abs() < c.r) ||
     (a.abs() < c.r && b.abs() > c.r) ) return true;
  if(a.abs() > c.r && b.abs() > c.r){
    if(pp.abs()-EPS < c.r && check(seg.t,seg.s,p)){
      return true;
    }
  }
  return false;
}

bool judge(){
  Segment seg = Segment(t,s);

  for(int i = 0 ; i < N ; i++){
    if(getStateCS(ci[i],seg)) return true;
  }
  return false;
}

int main(){
  int M;
 
  while(cin >> N,N){
    for(int i = 0 ; i < N ; i++){
      cin >> ci[i].x >> ci[i].y >> ci[i].r;
    }
    cin >> M;
    for(int i = 0 ; i < M ; i++){
      cin >> t.x >> t.y >> s.x >> s.y; 
      if(judge()){
        cout << "Safe" << endl;
      }else{
        cout << "Danger" << endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1236
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

ll count(string s,char c){
    ll ret=0;
    rep(i,s.size())
        if(s[i]==c)ret++;
    return ret;
}

bool solve(){
    ll n;cin>>n;
    string s;cin>>s;
    vector<vector<ll>>dp(n+1,vector<ll>(2,INF));
    dp[0][0]=0;
    dp[0][1]=0;

    //0は#、1は.

    //前の奴
    rep(i,n){

        //0(#)
        if(s[i]=='#'){
            dp[i+1][0]=min(dp[i+1][0],dp[i][0]);
            dp[i+1][0]=min(dp[i+1][0],dp[i][1]);
        }
        if(s[i]=='.'){
            dp[i+1][0]=min(dp[i+1][0],dp[i][0]+1);
            dp[i+1][0]=min(dp[i+1][0],dp[i][1]+1);
        }

        //1
        if(s[i]=='#'){
            // dp[i+1][1]=min(dp[i+1][0]+1,dp[i][1]);
            dp[i+1][1]=min(dp[i+1][1],dp[i][1]+1);
        }
        if(s[i]=='.'){
            // dp[i+1][1]=min(dp[i+1][0],dp[i][1]);
            dp[i+1][1]=min(dp[i+1][1],dp[i][1]);
        }
    }
    // cout<<dp[1][0]<<" "<<dp[1][1]<<endl;
    cout<<min(dp[n][0],dp[n][1])<<endl;
    return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 11412
#include "iostream"

using namespace std;

int main() {

	int num;
	int a[100];

	int snum = 0;

	cin >> num;

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

	int frag = 1;
	while (frag == 1) {
		frag = 0;
		for (int j = num - 1; j > 0; j--) {
			if (a[j] < a[j - 1]) {
				int b = a[j];
				a[j] = a[j - 1];
				a[j - 1] = b;

				snum++;

				frag = 1;
			}
		}
	}

	for (int i = 0; i < num; i++) {
		cout << a[i];
		if (i < num - 1) cout << " ";

	}
	cout << endl;
	cout << snum << endl;


	return 0;
}

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

int main(){
    long long a,b,c,d,h,s,t,r;
    long long e1,e2,e3,e4;
    scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
    s=c;
    t=d;
    r=t%s;
    while(r!=0){
        t=s;
        s=r;
        r=t%s;
    }
    h=c*d/s;
    e1=b/c;
    e2=b/c-(a-1)/c;
    e3=b/d-(a-1)/d;
    e4=b/h-(a-1)/h;
    e1=b-a+1;
    printf("%lld\n",e1+e4-e2-e3);
}


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

int main(){
  int64_t n;
  cin >> n;
  vector<int64_t>al(n);
  for(int64_t i=0;i<n;i++)
    cin >> al.at(i);
  sort(al.begin(),al.end(),greater());
  int64_t ans=0;
  for(int64_t i=1;i<n;i++){
    ans+=al.at(i/2);
  }
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 4848
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function lower_bound(d,a,b,e){for(var c;1<b-a;)d[c=0|(a+b)/2]<e?a=c:b=c;return d[a]<e?b:a};

console.log(main());
function main(){
  var n = o.a();
  var q = o.a();
  var a;
  if(n & 1)a = [0].concat(o.l()), n++;
  else a = o.l();
  var x = o.r(q);
  var u = [0], v = [0];
  for(var i = 0; i < n; i++){
    u[i+1] = u[i] + a[i];
    if(i & 1)v[i+1] = a[i] + v[i];
    else v[i+1] = v[i];
  }
  var w = [0], z = n/2;
  for(i = 1; i < z; i += 2){
    w.push((a[i]+a[z++])/2);
  }
  var ans = [], wl = w.length;
  for(i = 0; i < q; i++){
    var t = lower_bound(w,0,wl,x[i]) - wl;
    ans[i] = u[n] - u[n+t-1];
    ans[i] += v[n+t*2-1];
  }
  return ans.join("\n");
}

Measured memory_bytes: 63484
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
using namespace std;
const int INF=(int)1e9+10;
const int MOD=998244353;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    string s;
    cin>>n>>s;
    if(n>=3200)
        cout<<s;
    else
        cout<<"red";
    return 0;
}



Measured memory_bytes: 256
// vim: shiftwidth=2 expandtab foldmethod=marker

// include {{{
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <utility>
#include <cstdlib>
#include <random>
#include <chrono>
// }}}

// debug(...) {{{
#ifdef LOCAL_DEBUG
#include "./debug.h"
#else
bool debug_enabled = false;
#define debug(...)
#define debugn(...)
#define debug_reset()
#endif

// }}}

// bin {{{
template<class T>
std::string bin(int bits, const T& x) {
  char buf[bits + 1];
  buf[bits] = '\0';
  for(int i = 0; i < bits; i++) {
    if((x >> i) & 1) {
      buf[bits - i - 1] = '1';
    } else {
      buf[bits - i - 1] = '0';
    }
  }
  return std::string(buf);
}
std::string bin(int x) {
  if(x < 0) return bin(32, x);
  for(int i = 4; i < 31; i++) {
    int y = 1 << i;
    if(x < y) return bin(i, x);
  }
  return bin(32, x);
}
// }}}

// misc {{{
using namespace std;
template<class T, class U>

using umap = unordered_map<T, U>;
template<class T>
using uset = unordered_set<T>;

typedef long long ll;

#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++)

template<class T>
void sort(T& arr) { // {{{
  std::sort(arr.begin(), arr.end());
} // }}}
template<class T, class By>
void sort_by(T& arr, By by) { // {{{
  std::sort(arr.begin(), arr.end(), [by](auto l, auto r){return  by(l) < by(r); });
} // }}}

template<class T>
void reverse(T& arr) { // {{{
  std::reverse(arr.begin(), arr.end());
} // }}}

class Random { // {{{
  public:
  std::uniform_int_distribution<> uniform_int;
  std::mt19937 rnd;
  std::bernoulli_distribution bern_dist;
  int uniform(int l, int r) {
    return uniform_int(rnd, std::uniform_int_distribution<>::param_type(l, r));
  }
  int next(int N) {
    return uniform(0, N - 1);
  }
  int bern(double p) {
    return bern_dist(rnd, std::bernoulli_distribution::param_type(p));
  }
}; // }}}

template <class A>
ostream& out_vec(const vector<A>& x, const string& sep) { // {{{
  rep(i, x.size()) {
    cout << x[i];
    if(i < x.size() - 1)
      cout << sep;
  }
  return cout;
} // }}}
// }}}

// main {{{
void solve();
int main() {
  cout << setprecision(20);
  solve();
}
// }}}

void solve() {
  int N;
  cin >> N;
  string S;
  cin >> S;

  vector<int> WR(N + 2);
  WR[N + 1] = 0;
  for(int i = N - 1; i >= 0; --i) {
    WR[i] = WR[i + 1] + (S[i] == '.' ? 1 : 0);
  }
  debugn(WR);

  vector<int> BL(N + 2);
  BL[0] = 0;
  for(int i = 0; i < N; ++i) {
    BL[i + 1] = BL[i] + (S[i] == '#' ? 1 : 0);
  }
  debugn(BL);

  int ans = INT_MAX;
  rep(i, N) {
    ans = min(BL[i] + WR[i + 1], ans);
  }
  ans = min(ans, WR[0]);
  cout << ans << endl;
}


Measured memory_bytes: 2172
#include "bits/stdc++.h"

using namespace std;

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

void Main() {
    int n;
    cin >> n;
    int a;
    cin >> a;
    for (int i = 1; i < n; ++i) {
        int b;
        cin >> b;
        a = lcm(a, b);
    }
    cout << a << endl;
}

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



Measured memory_bytes: 3108
/*
You're my honeybunch, sugar plum
Pumpy-umpy-umpkin
You're my sweetie pie
You're my cuppycake, gumdrop
Snoogums, boogums, you're
The apple of my eye

And I love you so
And I want you to know
That I'm always be right here
And I want to sing
Sweet songs to you
Because you are so dear...

*/
#include<iostream>

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define pai pair<int, int>
#define ar array

using namespace std;
int const maxn=2e9;
int const naxn=1e9;

void solve(){
  ll a,b,c,d;
  cin>> a >> b >> c >> d;
   ll z[5];
   z[0] = a*c;
z[1] = b*c;
z[2] = a*d;
z[3] = b*d;
ll box = -1e18;
for(int i=0;i<4;i++){
    box = max(z[i],box);
}
cout << box << endl;

}

int main(){
   boost;
        solve();
    
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
#define pb push_back
#define mp make_pair
const unsigned int mod = 1e9+7;
const int mx=100005;

int main(){
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout); 
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	string s;cin >> s;
	int count[2];
	count[0]=0;count[1]=0;
	int last=-1;
	char cur='R';
	int n=s.length();
	int ans[n];rep(i,n)ans[i]=0;
	//RRLRL
	rep(i,n){
		if(s[i]==cur)count[i%2]++;
		else{
			if(s[i]=='L'){
				last=i-1;
				ans[last]+=count[last%2];
				ans[last+1]+=count[(last+1)%2];
			}
			else {
				ans[last]+=count[last%2];
				ans[last+1]+=count[(last+1)%2];
			}

				count[0]=0;
				count[1]=0;
				count[i%2]++;
				cur=s[i];
		}
	}
	ans[last]+=count[last%2];
	ans[last+1]+=count[(last+1)%2];
	rep(i,n)cout << ans[i] <<" ";
	cout << endl;
	return 0;
}
	

Measured memory_bytes: 1104
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

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

int main() {
	int n, a, b;
	scanf("%d", &n);
	scanf("%d", &a);
	REP(i, n - 1) {
		scanf("%d", &b);
		a = gcd(a, b);
	}
	PRINTD(a);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)


int main() {

	int n; cin >> n;

	vector<int> a(n);

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

		mx = max(mx, a[i]);

		a[i] = 2 * a[i];
	}


	int ans = 1<<31-1;
	int diff = 1 << 31 - 1;
	for (int i= 0; i < n; i++) {
		if (diff >= abs(mx - a[i])) {
			diff = abs(mx - a[i]);
			ans = a[i] / 2;
		}
	}

	cout << mx <<" "<< ans << endl;

	return 0;
}

Measured memory_bytes: 640
import sys
# input = sys.stdin.buffer.readline
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)

from collections import Counter
N = int(input())
A = list(map(int, (input().split())))
c = Counter(A)
def nC2(n):
    return n*(n-1)//2

all_cnt = 0
for k, v in c.items():
    if v>1:
        all_cnt += nC2(v)

for i in range(N):
    k = c[A[i]]
    ans = all_cnt - nC2(k) + nC2(k-1)
    print(ans)

Measured memory_bytes: 26780
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner in=new Scanner(System.in);
        int F[][]=new int[2][2];
        for(int i=0;i<2;i++){
        	for(int j=0;j<2;j++)F[i][j]=in.nextInt();
        }
        
        int a=in.nextInt(),b=in.nextInt(),c=in.nextInt(),d=in.nextInt();
        
        int hiro=(a*F[0][0])+(b*F[0][1])+(F[0][0]/10*c)+(F[0][1]/20*d);
        int ken=(a*F[1][0])+(b*F[1][1])+(F[1][0]/10*c)+(F[1][1]/20*d);
        
        String res;
        if(hiro>ken)res="hiroshi";
        else if(ken>hiro)res="kenjiro";
        else res="even";
        
        System.out.println(res);
    }
}


Measured memory_bytes: 26200
#include <cstdio>
#include <algorithm>
#include <vector>

int main() {
  int n;
  scanf("%d", &n);

  if (n == 1)
    return !printf("Hello World\n");

  int a, b;
  scanf("%d %d", &a, &b);

  printf("%d\n", a+b);
}


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

int main(void) {
  int H, W, h, w;
  cin >> H >> W >> h >> w;

  int h2 = H - h;
  int w2 = W - w;
  cout << h2 * w2 << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>
#include <algorithm>
#define lint long long int
#define FOR(x, to) for(int x=0; x<(to); x++) // for簡略表記
#define DUMP(ar) for(int i=0; i<ar.size(); i++) cout << "[" << i << "]:" << ar[i] << endl // 配列一覧表示
#define DUMPL(ar) for(unsigned int i=0; i<ar.size(); i++) { cout << ar[i]; if(i<ar.size()-1) cout << ' '; } cout << endl; // 配列一行一覧表示"
#define COUT(x) cout << x << endl // 単要素出力
#define ALL(ar) ar.begin(), ar.end() // コンテナの全要素
#define LOOPD(i) cout << "ループ[" << i << "]回目---------------" << endl // ループ回数デバグ
using namespace std;
// cout << fixed << setprecision(4) で小数点以下4桁の桁そろえ
// cout << setw(5) << ... で表示形式を5桁に設定 5桁未満なら頭に空白がつく 5桁越なら先頭から5桁まで
// cout << setw(5) << setfill('0') << ... で空白部分の埋め文字に5を使う
// goto ANSWER; で最後へ飛ぶ
// getline(cin, [変数]); で空白など(ホワイトスペース)を含む入力
// cin >> ws; でそこまでに入力ストリームに残されたホワイトスペースを取り除く(=以降のgetlineの有効化)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    string s;
    cin >> n;
    cin >> s;
    int count = 0;
    for(int i=0; i<n; i++){
        // LOOPD(i);
        if(i == n-1){
            break;
        }
        if((s[i]=='O' && s[i+1]=='X') || (s[i]=='X' && s[i+1]=='O')){
            count++;
            i++;
        }
    }

    COUT(count);

    return 0;
}


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

namespace abc67
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) 
            {
                Console.WriteLine("Possible");
            }else
            {
                Console.WriteLine("Impossible");
            }
        }
    }
}


Measured memory_bytes: 11092