akhauriyash/Code-Regression huggingface dataset:
sx, sy, tx, ty = map(int, input().split())

dx, dy = tx - sx, ty - sy
print('U' * dy + 'R' * dx + 'D' * dy + 'L' * (dx + 1) + 'U' * (dy + 1) +
      'R' * (dx + 1) + 'DR' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U')


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

void maxHeapify(int i){
    int l, r, largest;
    l = 2*i;
    r = 2*i + 1;

    //左の子、自分、右の子で値が最大のノードを選ぶ
    if(l <= H && A[l] > A[i]) largest = l;
    else largest = i;
    if(r <= H && A[r] > A[largest]) largest = r;

    if(largest != i){
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

int extract(){
    int maxv;
    if(H<1) return -INFTY;
    maxv = A[1];
    A[1] = A[H--];
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i, int key){
    if(key < A[i]) return;
    A[i] = key;
    while(i > 1 && A[i/2] < A[i]){
        swap(A[i], A[i/2]);
        i = i/2;
    }
}

void insert(int key){
    H++;
    A[H] = -INFTY;
    increaseKey(H, key);
}

int main(){
    int key;
    char com[10];

    while(1){
        scanf("%s", com);
        if(com[0] == 'e' && com[1] == 'n') break; //end処理
        if(com[0] == 'i'){
            scanf("%d", &key);
            insert(key);
        }else{
            printf("%d\n", extract());
        }
    }

    return 0;
}


Measured memory_bytes: 6476
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

int main() {
    ll N;
    cin >> N;
    ll A[N+2];
    ll S = 0;
    A[0] = 0;
    A[N+1] = 0;

    for (int i = 0; i < N; i++) {
        cin >> A[i+1];
        S += abs(A[i] - A[i+1]);
    }
    S += abs(A[N]-A[N+1]);

    for (int i = 1; i < N+1; i++) {
        cout << S + abs(A[i-1]-A[i+1]) - (abs(A[i-1]-A[i]) + abs(A[i]-A[i+1])) << endl;
    }
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
 
int factorial(int x){
  int sum=1;
  for(int i=1; i<=x; i++)
    sum *= i;
  return sum;
}

int main() {
  int N, n=0;
  cin >> N;
  vector<int> x(N), y(N);
  vector<int> p;
  for(int i=0; i<N; i++)
    p.push_back(i);
  for(int i=0; i<N; i++)
    cin >> x.at(i) >> y.at(i);
  
  double d=0;
  
  while(n < factorial(N)){
  for(int i=0; i<N-1; i++){
    d += sqrt( pow(x.at(p.at(i)) - x.at(p.at(i+1)),2) + pow(y.at(p.at(i)) - y.at(p.at(i+1)),2) );
  }
  next_permutation(p.begin(), p.end());
  n++;
  }
  d = d/(double)factorial(N);
  cout << fixed << setprecision(10);
  cout << d << endl;
}

Measured memory_bytes: 256
using System;
class Program{
	private int max(int x ,int y){
		return (x > y) ? x : y;
	}
	public static void Main(){
		Program prog = new Program();
		int N = int.Parse(Console.ReadLine());
		int[,] A = new int[2,N];
		int p, q;
		string[] str;
		for (p = 0 ;p < 2 ;p++ ){
			str = Console.ReadLine().Split(' ');
			for (q = 0 ;q < N ;q++){
				A[p,q] = int.Parse(str[q]);
			}
		}
		int[,] B = new int[2,N];
		B[1,N-1] = A[1,N-1];
		B[0,N-1] = A[0,N-1] + A[1,N-1];
		if (N >= 2){
			for (q = 1 ;q < N ;q++ ){
				B[1,N-1-q] = A[1,N-1-q] + B[1, N-q];
				B[0,N-1-q] = prog.max(B[1,N-1-q],B[0,N-q]) + A[0,N-1-q];
			}
		}
		Console.WriteLine(B[0,0]);
	}
}


Measured memory_bytes: 13140
#include <iostream>
#include <queue>
#include <vector>
#include <utility>
using namespace std;

#define INF 10000000

int dijkstra(int map[101][101],int a,int b,int N){
    bool checked[1001];
    for(int i=0;i<=1000;i++) checked[i]=false;
    int d[101];
    for(int i=0;i<=100;i++) d[i]=INF;

    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> Q;
    Q.push(make_pair(0,a));
    d[a]=0;

    while(!Q.empty()){
        int u=Q.top().second;
        Q.pop();
        if(checked[u]) continue;
        checked[u]=true;
        for(int i=1;i<=N;i++){
            if(map[u][i]==INF) continue;
            if(d[i]>d[u]+map[u][i]){
                d[i]=d[u]+map[u][i];
                Q.push(make_pair(d[u]+map[u][i],i));
            }
        }
    }

    return d[b];
}

int main(){
    int N,M;
    cin >> N >> M;

    int map[101][101],dist[101][101];
    queue<pair<int,int>> edge;
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            map[i][j]=INF;
            dist[i][j]=INF;
        }
    }
    for(int i=0;i<M;i++){
        int a,b,c;
        cin >> a >> b >> c;
        map[a][b]=c;
        map[b][a]=c;
        edge.push(make_pair(a,b));
    }

    int count=0;
    while(!edge.empty()){
        pair<int,int> cur=edge.front();
        edge.pop();

        if(map[cur.first][cur.second]>dijkstra(map,cur.first,cur.second,N)) count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#YYMM or MMYY or AMBIGUOUS or NA

inputLine = input()

firstPart = int(inputLine[0:2])
secondPart = int(inputLine[2:4])

#initialization
naFlag = False
firstPartYear = False
firstPartAmb = False
secondPartYear = False
secondPartAmb = False

# firstPartの属性判定
if firstPart < 0:
    naFlag = True

elif firstPart == 0:
    firstPartYear = True
    
elif firstPart < 13:
    firstPartAmb = True
    
else: 
    firstPartYear = True
    
# secondPartの属性判定
if secondPart < 0:
    naFlag = True

elif secondPart == 0:
    secondPartYear = True
    
elif secondPart < 13:
    secondPartAmb = True
    
else: 
    secondPartYear = True
    
if naFlag:
    print('NA')

elif secondPartYear:
    if firstPartYear:
        print('NA')
    elif firstPartAmb:
        print('MMYY')

elif secondPartAmb:
    if firstPartYear:
        print('YYMM')
    elif firstPartAmb:
        print('AMBIGUOUS')
  

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
 
int main(){
    int n,tmp,count = 0,limit;
    scanf("%d",&n);
 
    for(int i = 0; i < n; i++)
    {
        scanf("%d",&tmp);
        limit = sqrt(tmp);
        for(int j = 2; j <= limit; j++){
            if(tmp%j==0){
                count++;
                break;
            }
        }
    }
    printf("%d\n",n-count);
}


Measured memory_bytes: 2100
n = int(input())
A = list(map(int,input().split()))
s = sum(A)
r = [0]*(n+1)
for i in range(n):
    r[i+1] = r[i] +A[i]
ans = 10**15
for i in range(1,n):
    ans = min(ans,abs(s-2*r[i]))
print(ans)


Measured memory_bytes: 23800
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
const int MAX_V = 1e5;
vector<int> g[MAX_V], du(MAX_V,-1), dv(MAX_V,-1);

void dfs(int p, int l, int f) {
  f == 0 ? du[p] = l : dv[p] = l;  
  for(auto k : g[p]) {
    if((f == 0 && du[k] == -1) || (f == 1 && dv[k] == -1)) dfs(k,l+1,f);
  }
}

int main(){
  int n, u, v, x, y;
  cin >> n >> u >> v;
  u--; v--;
  rep(i,n-1) {
    cin >> x >> y;
    x--; y--;
    g[x].push_back(y); g[y].push_back(x);
  }
  if(g[u].size() == 1 && g[u][0] == v) {
    cout << 0 << endl;
    return 0;
  }
  dfs(u,0,0); dfs(v,0,1);
  int ans = 1;
  rep(i,n) {
    if(du[i] < dv[i]) ans = max(ans,dv[i]-1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10368
<?php
fscanf(STDIN,"%d",$N);
fscanf(STDIN,"%d",$K);

$board = 1;
//$plusJudge = false;
for($i=0;$i<$N;$i++){
  if($board*2 >= $board+$K){
    $board += $K;
//    $plusJudge = true;
  }else{
    $board *= 2;
  }
}
echo $board;

Measured memory_bytes: 3576
import heapq
import sys
from collections import deque


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    N = int(input())
    tree = [[] for _ in range(N)]
    edge = deque([])

    for _ in range(N - 1):
        a, b = map(int, input().split())
        tree[a - 1].append(b - 1)
        tree[b - 1].append(a - 1)
        edge.append((a - 1, b - 1))

    C = list(map(int, input().split()))
    C.sort()
    D = []
    for c in C:
        heapq.heappush(D, -c)

    answer = [0] * N
    a, b = edge.popleft()
    c = heapq.heappop(D) * (-1)
    d = heapq.heappop(D) * (-1)
    if len(tree[a]) == 0:
        answer[a] = c
        answer[b] = d
    else:
        answer[a] = d
        answer[b] = c

    new_node = deque([])
    for n in tree[a]:
        new_node.append(n)
    for n in tree[b]:
        new_node.append(n)

    while new_node:
        s = new_node.popleft()
        if answer[s] == 0:
            answer[s] = heapq.heappop(D) * (-1)
        for n in tree[s]:
            if answer[n] == 0:
                new_node.append(n)

    print(sum(C[:-1]))
    print(*answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 13368
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

int main(){
  int a,b,absHeight,height=0;
  cin >> a >> b;
  absHeight = b-a;
  for(int i = 1 ; i < absHeight;i++){
    height += i;
  }
  cout << (height - a) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     vi              vector<int>
#define     vll             vector<ll>
#define		vii 			vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
ll NcR(ll n, int r)
{
    ll res = 1;
    if ( r > n - r )
        r = n - r;
    loop(r,i,0){
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}
int main() {
	int n;cin>>n;
	ll res=0;
	int arr[n];
	map<int,ll>mp;
	loop(n,i,0){
		cin>>arr[i];
		mp[arr[i]]++;
	}
	for(auto x:mp){
		if(x.second==1)
			continue;
		res+=NcR(x.second,2);
	}
	loop(n,i,0){
		res-=(mp[arr[i]]-1);
		cout<<res<<endl;
		res+=(mp[arr[i]]-1);
	}
}


Measured memory_bytes: 10240
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  int n,x;
  cin>>n>>x;
  if(x==1||x==2*n-1){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  if(n==2){
    for(int i=1;i<=3;i++){
	 cout<<i<<endl;
    }
    return 0;
  }
  int ans[222222]={};
  if(x==2){
    ans[n-2]=x+2;
    ans[n-1]=x;
    ans[n]=x-1;
    ans[n+1]=x+1;
    int cnt=1;
    for(int i=0;i<2*n-1;i++){
	 if(ans[i])continue;
	 if(cnt==x-1)cnt=x+3;
	 ans[i]=cnt;
	 cnt++;
    }
  }else{
    ans[n-2]=x-1;
    ans[n-1]=x;
    ans[n]=x+1;
    ans[n+1]=x-2;
    int cnt=1;
    for(int i=0;i<2*n-1;i++){
	 if(ans[i])continue;
	 if(cnt==x-2)cnt=x+2;
	 ans[i]=cnt;
	 cnt++;
    }
  }
  for(int i=0;i<2*n-1;i++)cout<<ans[i]<<endl;
  return 0;
}


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

int main() {
  long double n,k,ans=0;
  cin >> n >> k;
  for(int i=1 ;i<=n ;i++){
    if(i<k){
      ans += pow(n,-1)*pow(0.5,ceil(log2(k/i)));
    }else{
      ans += pow(n,-1);
    }
  }
  cout << setprecision(20) << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define repi(i,n) for(int i=0;i<(int)(n);i++)
#define repd(i,n) for(int i=(int)(n);i>=0;i--)

int main()
{
    long Q,H,S,D;
    cin >> Q >> H >> S >> D;
    long N; 
    cin >> N;
    H = min(Q*2,H);
    S = min(S,H*2);
    if(S * 2 <= D){
        cout << N * S << endl;
    }else{
        cout << N/2*D + (N%2)*S << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n, x, y = map(int,input().split())

ans = [0]*(n-1)
for i in range(1,n+1):
    for j in range(i+1,n+1):
        ans[min(j-i,abs(x-i)+1+abs(y-j))-1] += 1
        #ans.append(min(j-i,abs(x-i)+1+abs(y-j)))
for k in range(n-1):
    print(ans[k])

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  int ans = 0;
  rep(i, n) {
    for (int j = i + 1; j < n; j++) {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
  return 0;
}


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

int *A;

int Fibonacci(int n){
    
    if((n == 0) || (n == 1))return 1;
    else if(A[n] != -1)return A[n];
    A[n] = Fibonacci(n - 1) + Fibonacci(n - 2);
    
    return A[n];
    
}
/*
 * 
 */
int Fibonacci(int n);

int main(int argc, char** argv) {
    
    int n;
    scanf("%d",&n);
    A = (int*)malloc(n * sizeof(int));
    for(int a = 0; a < n + 1; a++){
        A[a] = -1;
    }

    int result = Fibonacci(n);
    printf("%d\n",result);
    
    return (0);
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		int B[] = new int[N];
		int maxFirst, maxSecond;

		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			B[i] = A[i];
		}

		Arrays.sort(A);
		maxFirst = A[N - 1];
		maxSecond = A[N - 2];

		for (int i = 0; i < N; i ++) {
			if (B[i] != maxFirst) {
				System.out.println(maxFirst);
			} else {
				System.out.println(maxSecond);
			}
		}
	}
}


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

const long long MOD = 1000000007;
using ll = long long;

void solve(long long N, std::vector<long long> A){
    ll sum = accumulate(A.begin(), A.end(), 0LL);
    ll ans = 0;
    for(int i = 0;i < N;i++){
        sum %= MOD;
        sum += MOD;
        sum -= A[i] % MOD;
        sum %= MOD;
        ans += sum * (A[i]) % MOD;
        ans %= MOD;
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4836
#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> 

using namespace std;

#define _int64 long long

int a[200000];

int main()
{
  int i,n,ans,dire,tmp;
  scanf("%d",&n);
  for (i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
  }
  ans=1;
  dire=0;
  for (i=1;i<n;i++)
  {
    tmp=a[i]-a[i-1];
    if (tmp<0) tmp=-1;
    else if (tmp>0) tmp=1;
    if (dire==0) dire=tmp;
    else if (dire!=tmp)
    {
      if (tmp!=0)
      {
        ans++;
        dire=0;
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
    using namespace std;
     
    long long solve(vector<vector<long long> >&ans, vector<int> &val, vector<int> &wt, int i, int w)
    {
     
        if(i<0)return 0;
        if(w==0)return 0;
     
        if(ans[i][w]!=-1)return ans[i][w];
     
        ans[i][w]=0;
        long long temp1 = solve(ans,val,wt,i-1, w);
        if(w>=wt[i])
            temp1 = max(temp1, (long long)val[i] + solve(ans,val,wt,i-1,w-wt[i]));

    ans[i][w]=temp1;
    return ans[i][w];
}
const long long  INF=1e12+5;
int main()
{
    long long n,w;
    cin>>n>>w;
    vector<int> val(n);
    vector<long long> wt(n);
    
    for(int i=0; i<n; i++)
        cin>>wt[i]>>val[i];
 
    vector<vector<long long> >  ans(n,vector<long long> (100001,INF));
 
    ans[0][0]=0;
    for(int i=1; i<=val[0]; i++)
        ans[0][i]=wt[0];
 
    for(int i=1; i<n; i++)
    {
        for(int v=0; v<100001; v++)
        {
            ans[i][v] = ans[i-1][v];
            if(v-val[i]>=0)
            {
                ans[i][v] = min(ans[i][v], ans[i-1][v-val[i]] + wt[i]);
            }
            else
            {
                ans[i][v] = min(ans[i][v], wt[i]);
            }
        }
    }
    int a=100000;
    while(ans[n-1][a]>w)a--;
    cout<<max(a,0);
    return 0;
}

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

#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define MOD 1000000007

const int MAX_M = 100000;


int main(){
  ll n, m;
  //string s;
  cin >> n >> m;
  
  rep(i,0,m){
    ll a;
    cin >> a;
    n = n - a;
  }
  
  cout << ((n>=0)? n : -1) << endl;
}

Measured memory_bytes: 3624
import java.util.*;


class Main{
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		int[] A = new int[ N ];
		int[] std = new int[ N + 1] ;
		
		for(int i = 0 ; i < N ; i ++){
			A[ i ] = sc.nextInt();
			
			if(i == 0){
				std[ 0 ] = Math.abs( A[0] - 0 ); 
			}else if(i == N - 1){
				std[ N ] = Math.abs( 0 - A[N - 1] );
				std[ i ] = Math.abs( A[i] - A[ i - 1] );
			}else{
				std[ i ] = Math.abs( A[i] - A[ i - 1] );
			}
		}
		
		int sum = 0;
		for(int i = 0 ; i < N + 1; i ++){ // 辞める番号
			sum = sum + std[i] ;
		}
		
		
		System.out.println( sum + Math.abs( A[1] - 0 ) - std[0] - std[1] );
		
		for(int i = 1 ; i < N - 1 ;i ++){
			System.out.println( sum + Math.abs( A[i + 1] - A[ i - 1]  ) - std[i] - std[i + 1] );
		}
		
		System.out.println( sum + Math.abs( 0 - A[ N - 2] ) - std[N - 1] - std[N] );
	}
}


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

int main() {
  int N;
  int total=0; //各位の和
  int i; //桁数(roop count)
  int j=0; //計算結果保存用 
  int k;
  
  cin >> N;
  
  for ( i = 8 ; i >= 0 ; i--) {
    
    int l = 1 ;
    
    for ( k = i ; k > 0 ; k-- ) l *= 10 ;
    
    total += N / l - j * 10 ;
    j = N / l ;
    
  }
  
  if ( N % total == 0 ){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
}


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

#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

bool isprime(int x){
    if (x ==2) return true; 
    if (x % 2 == 0 || x < 2) return false;
    int i = 3;
    while (i <= sqrt(x)){
        if (x%i==0) return false;
        i += 2;
    }
    return true;
}

int main(){

    int n,x,count= 0;
    scanf("%d",&n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d\n",&x);
        if(isprime(x))  count++;

    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 3228
M, D = map(int, input().split())
count = 0
for i in range(M+1):
    for j in range(D+1):
        d10 = int(j /10)
        d1 = int(j % 10)
        if d10 >=2 and d1 >=2 and d10 * d1 ==i:
            count += 1
print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<numeric>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

ll modpow(ll a, ll n, ll m){
    if(n == 0) return 1;
    ll half = modpow(a,n/2,m);
    ll res = half * half % m;
    if(n & 1) res = res * (a%m) % m;
    return res;
}


int main(){
    int n; cin >> n;
    ll ans = ((modpow(10,n,MOD)+modpow(8,n,MOD))%MOD-2*modpow(9,n,MOD))%MOD;
    if(ans < 0) ans += MOD;
    cout << ans << endl;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string L; cin >> L;
    int n = L.size();

    vector<vll> dp(n+1, vll(2));
    dp[0][0] = 1LL;

    rep(i, n){
        rep(j, 2){
            ll cur = dp[i][j];
            if(cur == 0LL) continue;

            int ni = i + 1;

            // (0, 0)
            int nj = j;
            if(L[i] == '1') nj = 1;
            dp[ni][nj] = ADD(dp[ni][nj], cur);

            // (0, 1), (1, 0)
            nj = j;
            if(j == 1 or L[i] == '1'){
                dp[ni][nj] = ADD(dp[ni][nj], MUL(cur, 2LL));
            }
        }
    }

    ll res = ADD(dp[n][0], dp[n][1]);
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 5840
H, W, h, w = map(int, input().split())

if H % h == 0 and W % w == 0:
    print('No')
    exit()

big = 1000
mul = h*w-1
print('Yes')
for y in range(1, H+1):
    arr = []
    for x in range(1, W+1):
        if y % h == 0 and x % w == 0:
            arr.append(-(big*mul+1))
        else:
            arr.append(big)
    print(' '.join(map(str, arr)))



Measured memory_bytes: 9192
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int mod = 1e9 + 7;
const int MX = 1100000;
ll inv[MX], f[MX], invf[MX];
void calc(){
	inv[0] = inv[1] = f[0] = f[1] = invf[0] = invf[1] = 1;
	for (int i = 2; i < MX; i++){
		inv[i] = mod - mod / i * inv[mod % i] % mod;
		f[i] = f[i - 1] * i % mod;
		invf[i] = invf[i - 1] * inv[i] % mod;
	}
}
inline ll C(ll n, ll k){
	if(n < k || k < 0) return 0;
	return f[n] * invf[k] % mod * invf[n - k] % mod;
}
int main(){
	calc();
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m; cin >> n >> m;
	vi a(n), b(m);
	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];
	sort(all(a)); sort(all(b));
	
	ll ans = 1;
	int x = 0, y = 0, use = 0;
	
	for(int i = n * m; i > 0; i--){
		bool af = binary_search(all(a), i);
		bool bf = binary_search(all(b), i);
		
		if(!af && !bf){
			ans *= x * y - n * m + i;
		}
		else if(af && bf){
			x++; y++; use++;
		}
		else if(af){
			ans *= y; x++; use++;
		}
		else{
			ans *= x; y++; use++;
		}
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int s, k;

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

  long long res = 0;
  for (int a = 0; a <= k; a++) {
    res += max(0, min(s - a, k) - max(s - a - k, 0) + 1);
  }
  cout << res << '\n';
  return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, sz(s)) ans += (s[i] != t[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3884
#include<bits/stdc++.h>
using namespace std;
const int N = 305;
int n,m,a[N][N],idx[N],dead[N],cnt[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> a[i][j];
        }
        cnt[a[i][0]]++;
    }
    int ans = INT_MAX;
    for (int w = m; w >= 1; --w) {
        int mx = 0, mxi = -1;;
        for (int j = 1; j <= m; ++j)
            if (cnt[j] > mx)
                mx = cnt[j], mxi = j;
        ans = min(ans, mx);
        dead[mxi] = 1;
        cnt[mxi] = 0;
        if (w > 1) {
            for (int i = 0; i < n; ++i)
                if (a[i][idx[i]] == mxi) {
                    while (dead[a[i][idx[i]]])
                        ++idx[i];
                    ++cnt[a[i][idx[i]]];
                }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
import sys
import bisect
from collections import deque
input = lambda: sys.stdin.readline().rstrip()


def solve():
    s = list(map(lambda x: ord(x) - ord('a'), input()))
    t = list(map(lambda x: ord(x) - ord('a'), input()))
    n = len(s)
    a_list = [[] for _ in range(26)]

    for i in range(n):
        a_list[s[i]].append(i)

    for tt in list(set(t)):
        if len(a_list[tt]) == 0:
            print(-1)
            exit()

    now_i = -1
    count = 0
    t = deque(t)
    ts = t.popleft()
    while True:
        index = bisect.bisect_right(a_list[ts], now_i)
        if index == len(a_list[ts]):
            count += 1
            now_i = -1
        else:
            now_i = a_list[ts][index]
            if not t:
                break
            ts = t.popleft()

    print(n * count + now_i + 1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 51836
N,A,B=map(int, input().split())
S=input()
a,b,c=0,0,0
for s in S:
    if s=='a':
        a+=1
        if c < A+B:
            print('Yes')
            c+=1
        else:
            print('No')
    elif s=='b':
        b+=1
        if (c < A+B) and b <= B:
            print('Yes')
            c+=1
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 4016
A,B,C = int(input()),int(input()),int(input())

for n in range(-300,301):
    ans = [[A,B,n],[0,C,0],[0,0,0]]
    s = sum(ans[0])
    ans[2][1] = s - B - C
    ans[2][2] = s - C - A
    ans[1][2] = s - n - ans[2][2]
    ans[1][0] = s - C - ans[1][2]
    ans[2][0] = s - A - ans[1][0]
    if s == sum(ans[2]) == ans[0][2] + ans[1][1] + ans[2][0]:
        for row in ans:
            print(' '.join(map(str,row)))
        break


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using ll = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__

	int N;
	cin>>N;
	set<int> st;
	REP(i,N){
		int a;
		cin>>a;
		if(st.count(a)==0)st.insert(a);
		else st.erase(a);
	}
	cout<<st.size()<<endl;
	return 0;
}


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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;

//---------------------------------------------------------------

int main(){
  vector<vec> c(3,vec(3));
  int num = 0;
  rep(i,3){
  cin>>c.at(i).at(0);
  cin>>c.at(i).at(1);
  cin>>c.at(i).at(2);
  num+=c.at(i).at(0)+c.at(i).at(1)+c.at(i).at(2);
  }
  string ans = "Yes";
  if(num%3!=0)ans = "No";
  else{
    int b1,b2,b3,a2,a3;
    b1 = c.at(0).at(0);
    b2 = c.at(0).at(1);
    b3 = c.at(0).at(2);
    a2 = c.at(1).at(0)-b1;
    a3 = c.at(2).at(0)-b1;
    if(a2!=c.at(1).at(1)-b2)ans = "No";
    if(a3!=c.at(2).at(1)-b2)ans = "No";
    if(a2!=c.at(1).at(2)-b3)ans = "No";
    if(a3!=c.at(2).at(2)-b3)ans = "No";

  }
  cout<<ans<<endl;

}


Measured memory_bytes: 256
function main(input) {
    const nums = input.split(" ");
    var count5 = 0, count7 = 0;
    
    nums.forEach( num => {
        if(num == 5) {
            count5 += 1;
        }
        if(num == 7) {
            count7 += 1;
        }
    })
    console.log(count5 === 2 && count7 === 1 ? "YES" : "NO");
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

bool isPalindrome(string s) {
    string reverse(s.rbegin(), s.rend());
    return s == reverse;
}

int main() {
    string s;
    cin >> s;
    int length = s.length();
    cout << (isPalindrome(s) && isPalindrome(s.substr(0, (length - 1) / 2)) && isPalindrome(s.substr((length + 3) / 2 - 1)) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
# cook your dish here

n, k = map(int,input().split())
a = list(map(int,input().split()))

Sum = sum(a)

divisor = []
i = 1
while i*i <= Sum:
    if Sum % i == 0:
        divisor.append(i)
        divisor.append(Sum//i)
    i += 1
    
divisor = set(divisor)

ans = 0
for div in divisor:
    remain = []
    for ai in a:
        remain.append(ai % div)
    
    remain.sort()
    l = 0 
    r = len(remain) - 1;
    
    operator = 0
    while l < r:
        need = min(remain[l],div - remain[r])
        operator += need
        
        remain[l] -= need
        remain[r] += need
        
        if remain[l] == 0: l += 1
        if remain[r] == div: r -= 1
    
    if (operator <= k): ans = max(ans, div)    


print(ans)

Measured memory_bytes: 41964
#include <iostream>

using namespace std;

int main()
{
  int n; cin>>n;
  string str; cin>>str;
  int cnt = 0;
  for(int i = 0 ; i < n - 2; i++)
  {
    string tm  = str.substr(i,3);
    if(tm == "ABC") cnt++;
  }
  cout<<cnt;
  return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	ll s,c;
	std::cin >> s >> c;
	if (s >= c / 2) {
		std::cout << c/2 << '\n';
	}
	else {
		std::cout << s + (c-s*2)/4 << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n;
    scanf("%d",&n);
    int p[n];
    int num=0;
    int min=n+1;
    for(int i=0;i<n;i++){
        scanf("%d",&p[i]);
    }
    for(int i=0;i<n;i++){
        if(min>p[i] || min==p[i]){
            min=p[i];
            num++;
        }
    }
    printf("%d",num);
    return 0;
}

Measured memory_bytes: 896
import math

def combinations_count(n, r):
	if n < 2:
		return 0
	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


a = input().split(" ")
n = int(a[0])
m = int(a[1])

c = combinations_count(n, 2)
c += combinations_count(m, 2)

print(c)



Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
   	int n;
  	cin >> n;
  	int a[n],su;
  	cin >>a[0];
	su+=abs(a[0]);
  	for(int i=1;i<n-1;i++){	
    	cin >> a[i];
      	su+=abs(a[i]-a[i-1]);
    }
  	cin >> a[n-1];
  	su+=abs(a[n-1]-a[n-2]);
  	su+=abs(-a[n-1]);
  	cout << su-abs(-a[0])-abs(a[1]-a[0])+abs(-a[1]) << endl;
  	for(int i=1;i<n-1;i++){	
    	cout << su-abs(a[i+1]-a[i])-abs(a[i]-a[i-1])+abs(a[i+1]-a[i-1]) << endl;
    }
  	cout << su-abs(-a[n-1])-abs(a[n-1]-a[n-2])+abs(-a[n-2]) << endl;
  	}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int a;
    cin >> a;
    string s;
    cin >> s;
    if(a<3200) cout << "red" << endl;
    else cout << s << endl;
}

Measured memory_bytes: 256
use proconio::*;

use std::f64::consts::PI;

#[fastout]
#[allow(non_snake_case)]
fn main() {
    input! {
        A: f64, B: f64, H: f64, M: f64,
    }
    let A_k = 360.0 * (H + M / 60.0) / 12.0;
    let B_k = 360.0 * M / 60.0;
    let mut k = if A_k >= B_k { A_k - B_k } else { B_k - A_k };
    if k >= 180.0 {
        k = 360.0 - k;
    }
    k = k / 180.0 * PI;
    println!("{}",
        (A.powi(2) + B.powi(2) - 2.0 * A * B * k.cos()).powf(0.5)
    );
}


Measured memory_bytes: 3064
n = int(input())
L = sorted([int(i) for i in input().split()])
ans = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if L[i] + L[j] > L[k] and len(set([L[i], L[j], L[k]]))==3:
                ans += 1
print(ans)

Measured memory_bytes: 9192
//When I wrote this only God and I knew what it is
//Now, only The_Blitz knows...
#pragma GCC optimize ("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define pb push_back
#define FER(i,a,b) for(int i =int(a); i < int(b); ++ i)
#define IFR(i,a,b) for(ll i = ll(a); i >= ll(b); -- i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ff first
#define ss second
typedef long long ll;
typedef pair<int, int> ii;

const int N = 2e3 + 3;

vector<int> adj[N];
int dist[N], dp[N];

void dfs(int x){
	queue<int> q;
	q.push(x); dist[x] = 0;
	while(!q.empty()){
		int u = q.front(); q.pop();
		dp[dist[u]] ++;
		for(auto v: adj[u]){
			if(dist[v] == -1){
				dist[v] = dist[u] + 1;
				q.push(v);
			}
		}
	}
}

int main(){
	fastio;
	int n, x, y; cin >> n >> x >> y;
	FER(i, 1, n) adj[i].pb(i + 1), adj[i + 1].pb(i);
	adj[x].pb(y); adj[y].pb(x);
	FER(i, 1, n + 1){
		FER(j, 1, n + 1) dist[j] = -1;
		dfs(i);
	}
	FER(i, 1, n) cout << dp[i] / 2 << endl;
	return 0;
}



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

int main(){
    string S, revS; cin >> S;
    revS = S;
    reverse(revS.begin(), revS.end());
    int count = 0;
    int k;
    while(true){
        k = 0;
        for (int i = 0; i < S.size()/2; i++)
        {
            if(S.at(i) != revS.at(i)){
                revS.at(i) = S.at(i);
                count++;
                break;
            }else{
                k++;
            }
        }
        if(k == S.size()/2) break;
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

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

  int ans = max({A + B, A - B, A * B});
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
W, H, N = map(int, input().split())
X, Y = 0, 0
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        X = max(X, x)
    elif a == 2:
        W = min(W, x)
    elif a == 3:
        Y = max(Y, y)
    elif a == 4:
        H = min(H, y)
rx = W - X
ry = H - Y
if rx < 0 or ry < 0:
    print(0)
else:
    print(rx * ry)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
    #include<ext/pb_ds/assoc_container.hpp>
    #include<ext/pb_ds/tree_policy.hpp>

    using namespace std;
    using namespace __gnu_pbds;

    typedef pair<int,int> ii;
    typedef long long ll;
    typedef long double ld;
    typedef unsigned long long ull;
    typedef tree<pair<int,int>, null_type,less<pair<int, int> >,rb_tree_tag,tree_order_statistics_node_update > pbds;

    #define debug(x) cout<<#x<<" :: "<<x<<endl;
    #define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
    #define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
    #define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
    #define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
    #define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
    #define pb push_back
    #define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    ll power(ll a, ll b, ll mod) {
        ll res = 1;
        a %= mod;
        while(b) {
            if(b % 2) {
                res *= a;
                res %= mod;
            }
            a = a * a % mod;
            b >>= 1;
        }
        return res % mod;
    }
    const int INF = 2e9;

    // ----------------------------------------------------------
    const int N = 2e5 + 5;
    int n, m;
    const int dx[] = {1, -1, 0, 0};
    const int dy[] = {0, 0, 1, -1};
    const ll mod = 1e9 + 7;

    signed main() {
        int n, k;
        cin >> n >> k;
        ll g[k+1] = {0};
        for(int i=k; i>=1; i--) {
            g[i] = power(k/i, n, mod);
            for(int j=2*i; j<=k; j+=i) {
                g[i] -= g[j];
                g[i] += mod;
                g[i] %= mod;
            }
        }
        ll tot = 0;
        for(int i=1; i<=k; i++) {
            tot += (i*g[i])%mod;
            tot %= mod;
        }
        cout << tot << '\n';
        return 0;
    }



Measured memory_bytes: 4400
#include <stdio.h>
int main()
{
    int n,l[1001],r[1001],i;
    long ans=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d",&l[i],&r[i]);
        ans+=(r[i]-l[i]+1);
    }
    printf("%ld",ans);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main(){
 	int b,c,i,j,n;	
  	long ans = 0;
  	long a[200001] = {0};
  long aa[200001] = {0};
  
  
  	long m = 1000000007;
  scanf("%d",&n);
  for(i=0;i<n;i++){
   scanf("%ld",&a[i]); 
  }
  
  for(i=1;i<=n;i++){
    aa[i] = aa[i-1]+a[i-1];
    if(aa[i]>m){
     aa[i]=aa[i]%m; 
    }
  }
  
  for(i=n;i>1;i--){
      ans+=(a[i-1]*aa[i-1])%m; 
     
  }
    
     if(ans>=m){
      ans=ans%m;
     }
  printf("%ld\n",ans);
  return 0;
}






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

const int MAX_N = 10010;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> Array;
typedef vector<Array> Graph;
typedef pair<double, double> pdd;
const ull mod = 1000000000 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int A, B, C;
    cin >> A >> B >>C;
    if(A<=C && C<=B){
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

void solve() {
	
}

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

    int n;
    cin >> n;
    if(n == 0) cout << 1  << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main()
{
    long n, tmp;

    std::cin >> n;
    int i;
    for (i = 0; i < n; i++)
    {
        std::cin >> tmp;
        if (tmp % 2 == 0 && tmp % 3 != 0 && tmp % 5 != 0)
            break;
    }

    std::cout << (i == n ? "APPROVED" : "DENIED") << std::endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

    public static void main(String[] args){
        Main main = new Main();
        main.input();
        main.solve();
        main.output();
    }

    long a;
    long b;
    long c;
    long d;
    long result;

    private void input() {
        Scanner sc = new Scanner(System.in);
        a = sc.nextLong();
        b = sc.nextLong();
        c = sc.nextLong();
        d = sc.nextLong();
    }

    private void solve() {
        long ac = a*c;
        long ad = a*d;
        long bc = b*c;
        long bd = b*d;
        result = max(max(ac,ad), max(bc,bd));
    }

    private long max(long l1, long l2) {
        if (l1 > l2) {
            return l1;
        } else {
            return l2;
        }
    }

    private void output() {
        System.out.println(result);
        /*
        System.out.println((n==0) ? "Yes" : "No");
        */
    }
}


Measured memory_bytes: 36100
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

struct edge{
  int to, cost;
};

vector<vector<edge>> G(1100);

map<P, int> dijkstra(int s, map<P, int>mp) {
    vector<int> d(1100, mod), path(1100, mod);
	priority_queue<P, vector<P>, greater<P>>que;
	d[s] = 0;
    path[s] = -1;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first)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;
				que.push(P(d[e.to], e.to));
                path[e.to] = v;
			}
		}
	}
    rep(i, 110){
        if(path[i] != mod && path[i] != -1){
            mp[{min(i, path[i]), max(i, path[i])}] = 0;
        }
    }
    return mp;
}

int main() {
    int n, m;
    cin >> n >> m;
    map<P, int> mp;
    rep(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
        mp[{min(a, b), max(a, b)}] = 1;
    }
    rep(i, m)mp = dijkstra(i, mp);
    int ans = 0;
    for(auto x : mp)ans += x.second;
    cout << ans << endl;
}

Measured memory_bytes: 3796
<?php
    fscanf(STDIN, "%d", $a);
    $x = 0; // largest times divided
    $m = 1; // number of choice
    for ($n = 1; $n <= $a; $n++) {
        $d = $n;
        $i = 0; // start counting times divided by 2
        while (($d % 2) == 0) { // warikireru
	        $i++;
	        if ($i > $x) {
	            $x = $i;
	            $m = $n;
	        }
	        // next division
	        $d = intval($d/2);
	    }
	}
	echo $m;
?>


Measured memory_bytes: 3576
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a,b] <- getIntList
    print $ a * b


Measured memory_bytes: 3680
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var x = input.split('\n');
for(i=0; i<x.length; i++){
    var row = x[i].split(' ').map(Number);
    a = row[0];
    b = row[1];
    if(a === 0 && b === 0)break;
    var m = row.sort(function(a, b){return a - b});
    console.log(m.join(' '));
}


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

int main() {
	int n;
    cin >> n;
    vector<int> a(n);
    map<int, bool> m;
    set<int> s;
    rep(i, n) {
        cin >> a[i];
        if (s.count(a[i])) {
            m[a[i]] = true;
        } else {
            s.insert(a[i]);
        }
    }
    vector<bool> b(1000001, true);
    for (int x : s) {
        for (int i = x + x; i <= 1000000; i += x) {
            b[i] = false;
        }
    }
    int cnt = 0;
    rep(i, n) {
        if (m[a[i]]) {
            continue;
        }
        if (b[a[i]]) {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 22624
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
la=[0]
lb=[0]
t=0
g=N
for i in range(N):
    t+=A[i]
    la.append(t)
    if t>K:
        g=i
        break
t=0
for i in B:
    t+=i
    lb.append(t)
a=g
s=0
for i in range(g,-1,-1):
    while s<M:
        s+=1
        if K<la[i]+lb[s]:
            s-=1
            break
    if a<i+s:
        a=i+s
print(a)

Measured memory_bytes: 40756