akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, L; cin >> N >> L;
    vl A(N); REP(i, N) cin >> A[i];
    ll mx_idx = -1;
    REP(i, N-1){
        if(A[i]+A[i+1] >= L){
            mx_idx = i+1; break;
        }
    }
    if(mx_idx < 0){
        cout << "Impossible" << endl; return 0;
    }
    else{
        cout << "Possible" << endstr;
        FOR(i, 1, mx_idx){
            cout << i << endstr;
        }
        for(ll i = N-1; i > mx_idx;i --){
            cout << i << endstr;
        }
        cout << mx_idx << endstr;
    }
    return 0;
}


Measured memory_bytes: 1664
N = gets.to_i
A = gets.split.map &:to_i
ruijou = 1

if A.include?(0)
  puts 0
else
  A.each { |num|
    ruijou *= num
    break if ruijou > 10**18
  } 
  puts ruijou > 10**18 ?  -1 : ruijou
end


Measured memory_bytes: 21668
#include <cmath>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>

using namespace std;

#define forsn(i,s,n) for (int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for (int i = (n-1);i >= (int)(s);i--)
#define dforn(i,n) dforsn(i,0,n)
#define all(v) (v).begin(), (v).end()
#define F first
#define S second

int l[256];

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

	int n; cin >> n;
	forn(i, 2 * n) cin >> l[i];
	
	sort(l, l + (2 * n));
	
	int res = 0;
	forn(i, n) res += l[2 * i];
	
	cout << res << endl;
}


Measured memory_bytes: 256
let one_to_nine = function | 1 -> 9 | 9 -> 1 | x -> x
let _ =
	let a, b, c = Scanf.scanf "%1d%1d%1d\n" (fun a b c -> a, b, c) in
    print_int @@ one_to_nine a;
    print_int @@ one_to_nine b;
    print_int @@ one_to_nine c

Measured memory_bytes: 2432
n, m, x = map(int, input().split())
A = list(map(int, input().split()))

cnt_down = 0
cnt_up = 0
for i in range(x, 0, -1):
    if i in A: cnt_down += 1

for j in range(x, n+1, 1):
    if j in A: cnt_up += 1

ans = min(cnt_down, cnt_up)
print(ans)

Measured memory_bytes: 9132
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <set>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
struct edge{int to,cost;};
vector<int> G[100005];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
std::vector<P> tree[100010];
ll i,j;

ll n,m,k,l;
long long int ans=0;
ll zen=0,kou=0;
ll num[300005];
ll aa[300005],bb[300005];

int main(){
	priority_queue <ll,vector<ll>,greater<ll>> a;
	priority_queue <ll> b;
	cin>>n;
	for(i=1;i<=3*n;i++){
		cin>>num[i];
		if(i<=n){
			a.push(num[i]);
			zen+=num[i];
		}
		if(i>=2*n+1){
			b.push(num[i]);
			kou+=num[i];
		}
	}
	aa[0]=zen;

	bb[n]=kou;
	for(i=n+1;i<=2*n;i++){
		a.push(num[i]);
		zen += num[i]-a.top();
		a.pop();
		aa[i-n]=zen;
	}
	for(i=2*n;i>=n+1;i--){
		b.push(num[i]);
		kou += num[i]-b.top();
		b.pop();
		bb[i-n-1]=kou;
	}
	ll ans=-1*INF;
	for(i=0;i<=n;i++){
		ans = max(ans,aa[i]-bb[i]);
	}
	/* for(i=0;i<=n;i++){
		cout<<aa[i]<<" "<<bb[i]<<endl;
	} */
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12404
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b;
    cin>>a>>b;
    cout<<max(0,a-2*b);
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

type list struct {
	c string
	s int
	o int
}
type Lists []list

func (l Lists) Len() int {
	return len(l)
}

func (l Lists) Less(i, j int) bool {
	if l[i].c != l[j].c {
		return l[i].c < l[j].c
	} else {
		return l[i].s > l[j].s
	}
}

func (l Lists) Swap(i, j int) {
	l[i], l[j] = l[j], l[i]
}

func main() {
	var (
		N int
	)
	fmt.Scan(&N)
	lists := make([]list, N)
	for i := 0; i < N; i++ {
		var (
			city string
			s    int
		)
		fmt.Scan(&city, &s)
		lists[i] = list{
			c: city,
			s: s,
			o: i + 1,
		}
	}

	sort.Sort(Lists(lists))
	for _, list := range lists {
		fmt.Println(list.o)
	}
}


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

using namespace std;
double PI = 3.1415926535897932;

int main() {
  double a,b,h,m,x,y,z;
  cin >> a >> b >> h >> m;
  
  x = 360*h/12 + 360* m/(60*12);
  y = 360*m/60;
  z = abs(x-y);
  double ans = a*a + b*b - 2*a*b*cos(z*PI/180);

  cout << fixed << setprecision(20) << sqrt(ans) << endl;
}

Measured memory_bytes: 4228
a, b, c = [int(i) for i in input().split()]

if a == 7:
    if b == 5 and c == 5:
        print("YES")
    else:
        print("NO")
elif a == 5:
    if b == 5 and c == 7:
        print("YES")
    elif b == 7 and c == 5:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
const LL MOD = 1000000007LL;
int dp[100000][18];
int x[100000];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> x[i];
	int L;
	cin >> L;
	for (int i = 0; i < N; i++) {
		dp[i][0] = upper_bound(x, x + N, x[i] + L) - x - 1;
	}
	for (int i = 1; i < 18; i++) {
		for (int j = 0; j < N; j++) {
			dp[j][i] = dp[dp[j][i - 1]][i - 1];
		}
	}
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int a, b;
		cin >> a >> b; a--; b--;
		if (a > b) swap(a, b);
		int ans = 0;
		for (int i = 17; i >= 0; i--) {
			if (dp[a][i] < b) {
				a = dp[a][i];
				ans += (1 << i);
			}
		}
		ans++;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 8192
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
char s[100005];
char t[100005];
int num[1000]={0};
int num2[1000]={0};
vector<int>ss[1000];
int main()
{
    scanf("%s",s);
    scanf("%s",t);
    int n=strlen(s);
    int m=strlen(t);
    for(int i=0;i<n;i++){
        num[s[i]]++;
        ss[(s[i])].push_back(i);
    }
    for(int i=0;i<m;i++){
        if(num[(t[i])]==0){
            cout << -1 << endl;
            return 0;
        }
        num2[(t[i])]++;
    }
    int loop=0,ind=-1;
    int ans=0;
    vector<int>::iterator it;
    for(int i=0;i<m;i++){
        it=upper_bound(ss[(t[i])].begin(),ss[(t[i])].end(),ind);
        if(it==ss[(t[i])].end()){
            loop++;
            ind=ss[(t[i])][0];
        }
        else{
            ind = *it;
        }
    }
    cout << 1ll*loop*n+ind+1 <<endl;
    return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include<string.h>
#include <math.h>
#include <stack>
#define ll long long
using namespace std;
int main() {
	int a, b, k;
	int cnt = 0;
	scanf("%d %d %d", &a, &b, &k);
	for (int i = a; i >= 1; i--) {
		if (a % i == 0 && b % i == 0)
			cnt++;
		if (cnt == k) {
			printf("%d\n", i);
			return 0;
		}
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long L;
const int N=2e5+11,p=1e9+7;

int main(){
	int t=0,u=0;
	int i,x,n;
	cin>>n;
	while(n--){
		cin>>x;
		u=(u+(L)x*t)%p;
		t=(t+x)%p;
	}
	cout<<u<<endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

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

    private Scanner scan = new Scanner(System.in);
    private final int x;
    private final int a;
    private final int b;

    public Main() {
	x = Integer.parseInt(scan.next());
	a = Integer.parseInt(scan.next());
	b = Integer.parseInt(scan.next());

	scan.close();
    }

    public final void answer() {
	System.out.println(Math.abs(x-a) < Math.abs(x-b) ? "A" : "B");
    }
}


Measured memory_bytes: 20688
// AOJ 2481 Earn Big
// 2018.2.7 bal4u
 
#include <stdio.h>

double dp[1002];

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

	scanf("%d%d", &n, &m);
	dp[0] = 1;
	for (i = 0; i < n; i++) {
		j = 0;
		while (i+j < n && j < m) dp[i + ++j] += dp[i] / (n-i);
    }
	printf("%.8lf\n", dp[n]);
	return 0;
}



Measured memory_bytes: 2108
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	long[] a = new long[N];
	long[] b = new long[N];
	long[] offset = new long[N];
	long result = 0;
	long totalminus = 0;
	for(int i = 0; i<N; i++){
	    a[i] = sc.nextInt();
	}
	for(int i = 0; i<N; i++) {
	    b[i] = sc.nextInt();
	    if(a[i]<b[i]) {
		result++;
		totalminus += b[i]-a[i];
	    }
	}

	if(totalminus == 0) {
	    System.out.println(result);
	    return;
	}

	for(int i = 0; i<N; i++) {
	    offset[i] = a[i]-b[i];
	}
	Arrays.sort(offset);

	for(int i = N-1; i>=0; i--) {
	    totalminus = totalminus - offset[i];
	    result++;
	    if(totalminus <= 0) {
		System.out.println(result);
		return;
	    }

	}
	System.out.println(-1);
    }
}

Measured memory_bytes: 89848
import math
x = int(input())
rooted = math.sqrt(x)
max_num = 1
l = 2
while True:
    i = 2
    if l > rooted:
        break
    while True:
        beki = pow(l,i)
        i += 1
        if beki <= x:
            if beki == x:
                print(x)
                exit()
            else:
                if beki > max_num:
                    max_num = beki
        else:
            l += 1
            break
print(max_num)

Measured memory_bytes: 3064
def rot(s, n):
    anslet = ''
    for let in s:
        if let in alp:
            anslet = anslet + chr(ord('a') + (ord(let) - ord('a') + n) % 26)
        else:
            anslet = anslet + let

    return anslet

alp = 'abcdefghijklmnopqrstuvwxyz'

while True:
    try:
        letlst = input()

    except:
        break

    for i in range(27):
        word = rot(letlst, i)
        if ('this' in  word) or('that' in word) or ('the' in word):
            num = i

    letlst = rot(letlst, num)
    print(letlst)


Measured memory_bytes: 5556
#include <bits/stdc++.h>
using namespace std;
int main(){
        int n, k; cin >> n >> k;
        set<int> s;
        for (int x = 1; x <= k; ++x){
            int d; cin >> d;
            while (d--){
                int q; cin >> q;
                s.insert(q);
            }
        }
        cout << n-s.size() << endl;
    return 0;
}


Measured memory_bytes: 3624
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
//const ll mod=1e9+7;         
const int N=1e5+4;

int mod;

vector<int> v[N];

vector<int> suf[N],pre[N];

int up[N],dp[N];

int add(int a,int b)
{
	a+=b;

	if(a>=mod)
	a-=mod;

	return a;
}

void mul_self(int &a,int b)
{
	a=(1LL*a*b)%mod;
}

void dfs(int node,int par)
{
	dp[node]=1;

	for(int it:v[node])
	if(it!=par)
	{
		dfs(it,node);

		mul_self(dp[node],add(dp[it],1));
	}

	int sz=(int)v[node].size();

	pre[node].resize(sz); suf[node].resize(sz);

	rep(i,0,sz)
	{
		int x=v[node][i];

		pre[node][i]=1;

		if(i!=0)
		pre[node][i]=pre[node][i-1];

		if(x==par)
		continue;

		mul_self(pre[node][i],add(dp[x],1));
	}

	for(int i=sz-1;i>=0;i--)
	{
		int x=v[node][i];

		suf[node][i]=1;

		if(i!=sz-1)
		suf[node][i]=suf[node][i+1];

		if(x==par)
		continue;

		mul_self(suf[node][i],add(dp[x],1));
	}
}

void dfs1(int node,int par)
{
	int sz=(int)v[node].size();

	rep(i,0,sz)
	{
		int x=v[node][i];

		if(x==par)
		continue;

		int here=1;

		if(par!=-1)
		here=up[node]+1;

		if(here>=mod)
		here-=mod;

		if(i!=0)
		mul_self(here,pre[node][i-1]);

		if(i!=sz-1)
		mul_self(here,suf[node][i+1]);

		//here++;

		//if(here>=mod)
		//here-=mod;

		up[x]=here;

		dfs1(x,node);
	}
}

int main()
{
	int n;

	scn(n); scn(mod);

	rep(i,0,n-1)
	{
		int a,b;

		scn(a); scn(b);

		v[a].pb(b); v[b].pb(a);
	}

	dfs(1,-1);

	//up[1]=1;

	dfs1(1,-1);

	rep(i,1,n+1)
	{
		int ans=(1LL*dp[i]*add(up[i],1))%mod;

		//cout<<i<<" "<<dp[i]<<" "<<up[i]<<endl;

		priln(ans);
	}

    return 0;
}

Measured memory_bytes: 25088
program main
implicit None
	integer(8)::x,y,z,k,i,j
	integer(8),allocatable::a(:),b(:),c(:),d(:),e(:)
	
	read*,x,y,z,k
	allocate(a(x),b(y),c(z),d(x*y),e(k*z))
	read*,a;read*,b;read*,c
	
	do i =1,x
		do j =1,y
			d((i-1)*y+j) = a(i)+b(j)
		enddo
	enddo
	
	call h1(d,x*y)
	call rev(d,x*y)
	e = 0
	
	do i =1,k
		do j = 1,z
			e((i-1)*z+j) = d(i)+c(j)
		enddo
		if((i+1)>x*y)exit
	enddo
	
	call h1(e,k*z)
	call rev(e,k*z)
	
	do i = 1,k
		print"(i0)",e(i)
	enddo
end program main

subroutine rev(a,n)
Implicit None
	integer(8)::a(n),b(n)
	integer(8)::n,i
	
	do i =1,n
	b(i) = a(n-i+1)
	enddo
	
	a =b
end subroutine rev

subroutine h1(a,n)
implicit None
	integer(8)::a(n),x
	integer(8)::n,i,ie,i0,i1,i2
	
	do i = n/2,1,-1
		x = a(i);ie = n + 1; i0 = i; i1 = i0 * 2
		do while(i1 < ie)
			i2 = i1 + 1
			if(i2 < ie .and. a(i1) < a(i2)) i1 = i2
			if(a(i1) > x)then
				a(i0) = a(i1);a(i1) = x
				else
				exit
			endif
			i0 = i1;i1 = i0 *2
		enddo
	enddo
	do ie = n,2,-1
		x = a(ie)
		a(ie) = a(1)
		a(1) = x
		i0 =1;i1 =2
		do while(i1 <ie)
			i2 = i1 +1
			if(i2 < ie .and. a(i1) < a(i2)) i1 = i2
			if(a(i1) > x)then
				a(i0) = a(i1);a(i1) = x
				else
				exit
			endif
			i0 = i1;i1 = i0 *2
		enddo
	enddo
end subroutine h1

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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

const double eps = 1e-10;
const int MOD = 1000000007;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, s.size()) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  string s;
  cin >> s;
  int g = 0;
  int p = 0;
  int sc = 0;
  REP(i, SZ(s)) {
    if(p < g) {
      p++;
      if(s[i] == 'g') sc++;
    } else {
      g++;
      if(s[i] != 'g') sc--;
    }
  }

  cout << sc << endl;
}


Measured memory_bytes: 512
import java.util.*
import java.math.*
import java.lang.Math.*


private val readString: ()->String = {readLine()!!}
private val readInt: ()->Int = { readLine()!!.toInt() }
private val readLong: ()->Long = { readLine()!!.toLong() }
private val readListInt: ()->List<Int> = { readLine()!!.split(' ').map(String::toInt) }
private val readListLong: ()->List<Long> = { readLine()!!.split(' ').map(String::toLong) }
private val errPrintln: (String)->Unit = { msg -> System.err.println(msg) }
private val MOD = 1e9.toLong()+7
private val INF = Int.MAX_VALUE/2
private val LINF = Long.MAX_VALUE/2


fun solveC(eg :Array<ArrayList<Int>>): Int {
    var res = 0
    val N = eg.size;
    val vis = BooleanArray(N){false}

    fun dfs(n: Int, x: Int): Unit {
        if (n>=N-1) {
            if (vis.count{it} == N) res++
            return
        }

        for (nx in eg[x]) {
            if (vis[nx]) continue
            vis[nx] = true
            dfs(n+1, nx)
            vis[nx] = false
        }
    }

    vis[0] = true
    dfs(0, 0)

    return res
}


fun main(args: Array<String>) {
    val (N,M) = readListInt()
    val eg = Array(N){ArrayList<Int>()}
    for(i in 0 until M) {
        val (a, b) = readListInt().map{it -1}
        eg[a].add(b)
        eg[b].add(a)
    }

    val ans = solveC(eg)

    println(ans)
}


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

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

    int n;
    cin >> n;
    vector<int> A(n), B(n);
    REP(i, n){
        cin >> A[i];
        B[i] = A[i];
    }
    
    sort(A.begin(), A.end());
    
    REP(i, n){
        int idx = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        if(idx < n / 2){
            cout << A[n / 2] << endl;
        }else{
            cout << A[n / 2 - 1] << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3840
import java.util.Scanner;

class Main {  
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    double x1 = in.nextDouble();
    double x2 = in.nextDouble();
    double y1 = in.nextDouble();
    double y2 = in.nextDouble();

    double distance = Math.sqrt((x1 - y1)*(x1 - y1) + (x2 - y2)*(x2 - y2));
    
    System.out.printf("%5.8f", distance);
    
  }
}

Measured memory_bytes: 19056
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

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

	double l;
	cin >> l;

	double ln = l/ 3;
	l -= ln;

	double breadth = l / 2;

	double height = l - breadth;

	cout << fixed << setprecision(10) <<  ln * breadth * height;



    return 0;
}

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

using namespace std;

int main()
{
    long long int n,i,j,total=0;
    cin>>n;
    long long int a[n],b[n];
    for(i=0;i<n;i++)
    b[i]=0;
    
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        b[a[i]-1]++;
    }
    
    for(i=0;i<n;i++)
    {
        if(b[i]>1)
        {
            total+=(b[i]-1)*b[i]/2;
        }
    }
    
    for(i=0;i<n;i++)
    {
        if(b[a[i]-1]>1)
        {
            cout<<total-(b[a[i]-1]*(b[a[i]-1]-1)/2)+((b[a[i]-1]-1)*(b[a[i]-1]-2)/2)<<"\n";
        }
        else
        cout<<total<<"\n";
    }
}

Measured memory_bytes: 5760
import java.util.Scanner;
 
public class Main {
	static Scanner in = new Scanner(System.in);
	public static void main(String[] args){
		long N = in.nextLong();
		
		int min	 = Integer.MAX_VALUE;
		for(int i = 1; i <= (int)Math.sqrt(N); i++){
			if(N % i == 0){
				int j = (int)(N / i);
				min = Math.min(min, Math.max(String.valueOf(j).length(), String.valueOf(i).length()));
			}
		}
		System.out.println(min);
		
	}
}

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



template<class T>

class DoubleLinkedList{
  public:
    struct Node{
      T value;
      Node* prev;
      Node* next;
    };
    DoubleLinkedList(){
      topnode = new Node;
      topnode->next =  topnode;
      topnode->prev = topnode;
    }
    void Insert(T x){
      Node* prevnode = topnode->prev;
      topnode->prev = new Node;
      topnode->prev->value = x;
      topnode->prev->prev = prevnode;
      topnode->prev->next = topnode;
      prevnode->next = topnode->prev;
      topnode = topnode->prev;
    }
    void Delete(T x){
      Node* nextnode = topnode;
      while(nextnode->value != x){
        if(nextnode->next == topnode){
          return;
        }
        nextnode = nextnode->next;
      }
      if(nextnode != topnode){
        nextnode->prev->next = nextnode->next;
        nextnode->next->prev = nextnode->prev;
        delete nextnode;
      }else{
        nextnode->prev->next = nextnode->next;
        nextnode->next->prev = nextnode->prev;
        delete nextnode;
        topnode = topnode->next;
      }
    }
    void DeleteFirst(){
      topnode->prev->next = topnode->next;
      topnode->next->prev = topnode->prev;
      Node* tmpnode = topnode;
      topnode = tmpnode->next;
      delete tmpnode;
    }
    void DeleteLast(){
      if(topnode->prev->prev != topnode){
        Node* lastnode = topnode->prev->prev;
        topnode->prev->prev = topnode->prev->prev->prev;
        topnode->prev->prev->next = topnode->prev;
        delete lastnode;
      }else{
        Node* lastnode = topnode->prev->prev;
        topnode->prev->prev = topnode->prev->prev->prev;
        topnode->prev->prev->next = topnode->prev;
        delete lastnode;
        topnode = topnode->next;
      }
    }
    void ShowList(){
      Node* tmpnode = topnode;
      while(tmpnode->next != topnode){
        printf("%d",tmpnode->value);
        tmpnode = tmpnode->next;
        if(tmpnode->next != topnode){
          printf(" ");
        }
      }
      printf("\n");
    }
  private:
    Node* topnode;
};

int main(){
  long n;
  scanf("%ld",&n);
  DoubleLinkedList<int> list;
  for(int i = 0;i < n;i++){
    char com[30];
    int key;
    scanf("%s %d",com, &key);
    if(com[0] == 'i'){
      list.Insert(key);
    }else if(strlen(com) <= 6){
      list.Delete(key);
    }else if(com[6] == 'L'){
      list.DeleteLast();
    }else{
      list.DeleteFirst();
    }
  }
  list.ShowList();
}



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

#define int long long int 

int32_t main()
{
    int n;
    cin>>n;
    int ans=INT_MAX;
    for(int i=0;i<=n;i++)
    {
        int t=i;
        int cache=0;
        while(t>0)cache+=t%6,t/=6;
        t=n-i;
        while(t>0)cache+=t%9,t/=9;
        ans=min(ans,cache);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
const int maxn=2000*2000,p=1e9+7;
int fac[maxn+9],ifac[maxn+9];
inline int poww(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=1ll*a*ans%p;b>>=1;
		a=1ll*a*a%p;
	}return ans;
}
int C(int n,int m){
	if(n<m)return 0;
	return 1ll*fac[n]*ifac[m]%p*ifac[n-m]%p;
} 
void init(){
	int inv2=p-(p/2);
	fac[0]=1;for(int i=1;i<=maxn;++i)fac[i]=1ll*fac[i-1]*i%p;
	ifac[maxn]=poww(fac[maxn],p-2);for(int i=maxn-1;i>=0;--i)ifac[i]=1ll*(i+1)*ifac[i+1]%p;
}
int n,k,f[2020][2020];
int main(){
	init();
	cin>>n>>k;
	if(k==1){cout<<1;return 0;}
	for(int i=1;i<=n;++i)f[i][0]=1;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=i;++j){
			f[i][j]=f[i-1][j];
			f[i][j]=(f[i][j]+1ll*f[i][j-1]*(n-j+1)%p*C(n*k-i-(j-1)*(k-1)-1,k-2)%p)%p;
		}
	cout<<f[n][n];
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))
#define each(i, map) for (auto& i : map)

int main()
{
    int N, K; cin >> N >> K;
    map<int, int> mp;
    rep (i, 0, K) {
        int d; cin >> d;
        rep (j, 0, d) {
            int a; cin >> a;
            ++mp[a];
        }
    }

    int ans = 0;
    rrep (i, 1, N) {
        if (mp[i] == 0) ++ans;
    }
    cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    string s = to_string(i);
    if (s.length() % 2 == 1) ans++;
  }
  cout << ans << '\n';
  return 0;
}

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

public class Main {
    static Scanner in = new Scanner(System.in);

    public static void main(String[] args) {
        int N = Integer.parseInt(in.nextLine().split(" ")[0]);
        String[] s = new String[N];
        for(int i =0; i < N; i++){
            s[i] = in.nextLine();
        }
        Arrays.sort(s);
        for(int i = 0; i < N; i++){
            System.out.print(s[i]);
        }
        System.out.println();

    }
}



Measured memory_bytes: 21204
n = int(input())
numlist = list(map(int, input().split()))
# print(numlist)
result = [0] * n
# print(result)

for i in numlist:
	result[i - 1] = result[i - 1] + 1

for j in range(len(result)):
	print(result[j])
# for i in range(1, n + 1):
#	print(numlist.count(i))

Measured memory_bytes: 32292
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())

    if N % 2:
        print(0)
        return

    ans = 0
    N //= 2
    while N:
        N //= 5
        ans += N

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9160
N,M=map(int,input().split())
f=set()
t=set()
for i in range(M):
  a,b=map(int,input().split())
  if a<2:
    f.add(b)
  if b==N:
    t.add(a)
print("IM"*(len(f&t)^1)+"POSSIBLE")

Measured memory_bytes: 19024
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    String s=sc.next();
    if(a<3200){
      System.out.println("red");
    }else{
      System.out.println(s);
    }
  }
}


Measured memory_bytes: 21588
require 'matrix'

h, w = gets.split.map(&:to_i)
rows = Array.new(h, w){gets.chomp.bytes}
a = Matrix.rows(rows.shift(h))
n = '#'.ord
d = '.'.ord
b1 = Matrix[[n, n], [n, n]]
b2 = Matrix[[d, n], [n, n]]
b3 = Matrix[[n, n], [n, d]]
(h - 1).times do |i|
  (w - 1).times do |j|
    if a.minor(i, 2, j, 2) == b1 || a.minor(i, 2, j, 2) == b2 || a.minor(i, 2, j, 2) == b3
      puts 'Impossible'
      exit
    end
  end
end
puts 'Possible'

Measured memory_bytes: 2684
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int d[205][205];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, R;
	cin >> n >> m >> R;
	vector<int> r(R);
	rep(i, R) cin >> r[i], r[i]--;
	sort(all(r));
	rep(i, n)rep(j, n) d[i][j] = inf;
	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		d[a][b] = c;
		d[b][a] = c;
	}
	for (int k = 0; k < n; ++k) {
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	int ans = inf;
	do {
		int tmp = 0;
		rep(i, R - 1) {
			tmp += d[r[i]][r[i + 1]];
		}
		ans = min(ans, tmp);
	} while (next_permutation(all(r)));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            for (var i = 1L; i <= (long)1e7; ++i)
            {
                if (N <= i * (i + 1) / 2)
                {
                    for (var j = 1; j <= i; ++j)
                    {
                        if (j == i * (i + 1) / 2 - N)
                            continue;
                        WriteLine(j);
                    }
                    return;
                }
            }
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};
#define MOD 1000000007

void Main(){
  int n,k;
  cin>>n>>k;
  vi p(n);
  cin>>p;
  v(double) a(n);
  rep(i,n){
    a[i] = ( p[i]*(p[i]+1)/2 )/(double)p[i];
  }
  double ans = 0.0;
  double sum = 0.0;
  rep(i,k){
    sum+=a[i];
  }
  ans=sum;
  rep(i,n-k){
    sum += a[i+k] - a[i];
    // cout<<sum<<endl;
    chmax(ans,sum);
  }
  cout<<setprecision(8)<<fixed<<ans<<endl;

} signed main(int argc,char** argv)
{fastio; myio; myloopset Main();}


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

using namespace std;
typedef long long ll;
typedef long double ld;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))

int main(){
    FAST
    ld L; cin >> L;
    cout << setprecision(11)<<(L/3.0) * (L/3.0) * (L/3.0);
    return 0;
}


Measured memory_bytes: 3784
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
  ll n,p,ans=0; cin>>n>>p;
  string s; cin>>s;
  map<int,int> c;
  if(p==2 || p==5){
      rep(i,n) if((s[i]-'0')%p==0) ans+=i+1;
  }
  else{
      vector<int> me(n,0); int cnt=10%p;
      me[n-1]=(s[n-1]-'0')%p;
      rep(i,n-1){
        me[n-i-2]=(me[n-i-1]+cnt*(s[n-i-2]-'0'))%p;
        cnt=(cnt*10)%p;
      }
      
      rep(i,n){
          if(c.count(me[i])){
              ans+=c[me[i]];
          }
          else{
              c[me[i]]=0;
          }
          c[me[i]]++;
       }
       if(c.count(0)) ans+=c[0];
       }
       cout<<ans<<endl; 
  }

Measured memory_bytes: 1668
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	final long M=(long)1e9+7;
	
	int MAX=5000;
	
	long[] fac=new long[MAX];
	long[] ifac=new long[MAX];
	long[] inv=new long[MAX];
	{
		fac[0]=fac[1]=ifac[0]=ifac[1]=inv[0]=inv[1]=1;
		for (int i=2;i<MAX;++i) {
			fac[i]=i*fac[i-1]%M;
			inv[i]=M-M/i*inv[(int)M%i]%M;
			ifac[i]=inv[i]*ifac[i-1]%M;
		}
	}
	
	long comb(int n,int k) {
		if (n<0||k<0||n-k<0) return 0;
		return fac[n]*ifac[k]%M*ifac[n-k]%M;
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		int S=sc.nextInt();
		long ans=0;
		for (int n=1;n<=S/3+10;++n) {
			int t=S-n*3;
			if (t<0) continue;
			ans+=comb(n+t-1,n-1);
			ans%=M;
		}
		System.out.println(ans);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

Measured memory_bytes: 32548
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N, M := nextInt(), nextInt()

	fmt.Println(resNum(N) * resNum(M))
}

func resNum(a int) int {
	switch a {
	case 1:
		return 1
	case 2:
		return 0
	default:
		return a - 2
	}
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a,b;
	cin>>a>>b;
	if(b%a==0)
		cout<<a+b<<endl;
	else
		cout<<b-a<<endl;
}

Measured memory_bytes: 256
N = int(input())
arr = list(map(int, input().split()))
if N == 1:
    print(1)
    exit()
start = 0
ans = 0
while start < N - 1:
    up_count = 0
    for i in range(start,N-1):
        if arr[i] <= arr[i+1]:
            up_count += 1
        else:
            break
    down_count = 0
    for i in range(start,N-1):
        if arr[i] >= arr[i+1]:
            down_count += 1
        else:
            break
    start += max(up_count,down_count) + 1
    if start == N - 1:
        ans += 2
        break
    ans += 1
print(ans)


Measured memory_bytes: 62704
// Problem : D - Redistribution
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
	ARIJIT SUR 
	@duke_knight
	@surcode
    @comeback
	IIT ISM 
 */
#include<bits/stdc++.h>
#define SIZE (ll)(1e4)
#define mod (ll)(1e9+7)
#define vi vector<int>
#define INF 0x3f3f3f3f
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(a) ((a)>0?(a):-(a))
#define sc(a) scanf("%d\n",&a);
#define all(a) a.begin(),a.end()
#define maxelem(a) *max_element(all(a))
#define minelem(a) *min_element(all(a))
#define pb push_back
#define pi pair<int,int>
#define pqq priority_queue
#define sort(a) sort(all(a))
#define reverse(a) reverse(all(a))
#define input(a) {for(int i1=0;i1<a.size();i1++) cin>>a[i1];}
#define display(a) {for(int i1=0;i1<a.size();i1++) cout<<a[i1]<<" "; cout<<endl;}
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned ll
using namespace std;
ull dp[SIZE];
ull work(int sum){
	if(sum==0) return 1;
	if(sum<0) return 0;
	if(dp[sum]!=-1) return dp[sum];
	ull cnt =0;
	for(int i=3;sum-i>=0 && i<=9;i++){
		cnt = (cnt%mod + work(sum-i)%mod)%mod;
	}
	return dp[sum] = cnt;
}
void solve(){
	int s; cin>>s; 
	cout<<work(s)<<endl;
}
int main()
{
    IOS
        int s;
    cin >> s;
    ll dp[2020];
    dp[0] = 1;
    ll x = 0;
    for (int i = 1; i <= s; i++) {
        if (i - 3 >= 0) x += dp[i - 3];
            x %= mod;
            dp[i] = x;
    }
    cout << dp[s] << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <array>
#include <set>
#include <tuple>

using namespace std;
typedef long long ll;

using T = array<ll, 4>;

int main(){
    vector<ll> x(3);
    ll k;
    cin >> x.at(0) >> x.at(1) >> x.at(2) >> k;
    vector<vector<ll>> ts(3);
    for(int i = 0; i < 3; ++i){
        ts.at(i).resize(x.at(i));
        for(ll j = 0; j < x.at(i); ++j){
            cin >> ts.at(i).at(j);
        }
        sort(ts.at(i).begin(), ts.at(i).end());
    }

    priority_queue<T> q;
    q.push({
        ts.at(0).back() + ts.at(1).back() + ts.at(2).back(),
        x.at(0) - 1, x.at(1) - 1, x.at(2) - 1
    });
    set<tuple<ll, ll, ll>> s;
    s.insert(make_tuple(
        x.at(0) - 1, x.at(1) - 1, x.at(2) - 1
    ));

    for(int i = 0; i < k; ++i){
        T t = q.top();
        q.pop();
        cout << t.at(0) << endl;
        
        for(int j = 0; j < 3; ++j){
            if(t.at(j + 1) == 0){ continue; }
            T t2 = t;
            t2.at(j + 1)--;
            if(s.count(make_tuple(t2.at(1), t2.at(2), t2.at(3)))){
                continue;
            }
            t2.at(0) = ts.at(0).at(t2.at(1)) + 
                ts.at(1).at(t2.at(2)) + 
                ts.at(2).at(t2.at(3)),
            q.push(t2);
            s.insert(make_tuple(
                t2.at(1), t2.at(2), t2.at(3)
            ));
        }
    }

    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 FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

template <typename T>
T gcd(T a, T b) {
  if (b == 0) return a;
  else return gcd(b, a % b);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int k;
	cin >> k;
	int res = 0;
	rep (i, k) {
	  rep (j, k) {
		rep (l, k) {
		  res += gcd(i + 1, gcd(j + 1, l + 1));
		}
	  }
	}
	cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <stack>

typedef long long ll;

int main(int argc, char* argv[])
{
  std::string s;
  std::string::iterator it;
  std::cin >> s;

  int ans = 0;
  for (it = s.begin(); it != s.end(); it++) {
    if (*it == '+') {
      ans++;
    } else {
      ans--;
    }
  }

  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int i = a; i <= (n); ++i)
#define repD(i, a, n) for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a) memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int MOD = 1e9 + 7;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	int n; cin >> n;
	ll ans = 1;
	string s1,s2; cin >> s1 >> s2;
	vi c;
	rep(i,n){
		if(s1[i] == s2[i]) c.pb(1);
		else c.pb(2), i++;
	}
	int m = sz(c);
	rep(i,m){
		if(i == 0){
			ans = (ans*c[i]*3)%MOD;
		}else{
			if(c[i] == 1){
				if(c[i-1] == 1)
					ans = (ans*2)%MOD;
				else
					ans = (ans*1)%MOD;
			}else{
				if(c[i-1] == 1)
					ans = (ans*2)%MOD;
				else 
					ans = (ans*3)%MOD;
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int m,f,r;
  while(scanf("%d %d %d\n",&m,&f,&r),m>-1||f>-1||r>-1){
      if(m<0||f<0){
          putchar('F');
      }
      else if(m+f>=80){
          putchar('A');
      }
      else if(m+f>=65){
          putchar('B');
      }
      else if(m+f>=50){
          putchar('C');
      }
      else if(m+f>=30){
        if(r>=50){
            putchar('C');
        }
        else{
          putchar('D');
        }
      }
      else{
        putchar('F');
      }
      putchar('\n');
  }
  return 0;  
}


Measured memory_bytes: 2124
#include <iostream>
#include <string>

using namespace std;

string str;
int t[3];
int p;
int main() {
	t[0] = 1;
	t[1] = t[2] = 0;
	while(cin >> str){
		if(str == "A,B"){
			p = t[0];
			t[0] = t[1];
			t[1] = p;
		}else if(str == "B,A"){
			p = t[0];
			t[0] = t[1];
			t[1] = p;
		}else if(str == "A,C"){
			p = t[0];
			t[0] = t[2];
			t[2] = p;
		}else if(str == "C,A"){
			p = t[0];
			t[0] = t[1];
			t[1] = p;
		}else{
			p = t[0];
			t[0] = t[1];
			t[1] = p;
		}
	}
	if(t[0]){
		cout << 'A' << endl;
	}else if(t[1]){
		cout << 'B' << endl;
	}else{
		cout << 'C' << endl;
	}	
	return 0;
}

Measured memory_bytes: 0