akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

constexpr char endl('\n');

long long abso(long long x) {
    return x > 0 ? x : -x;
}


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

    size_t n, x, y;
    cin >> n >> x >> y;

    if (x == 1 && y == n) {
        
        if (n % 2 == 0) {
            for (auto i = 0; i < n / 2 - 1; ++i) {
                cout << n << ::endl;
            }
            cout << n / 2 << ::endl;
            for (auto i = 0; i < n / 2 - 1; ++i) {
                cout << 0 << ::endl;
            }
        }
        else {
            for (auto i = 0; i < n / 2; ++i) {
                cout << n << ::endl;
            }
            for (auto i = 0; i < n / 2; ++i) {
                cout << 0 << ::endl;
            }
        }
    }
    else {
        vector<int> l(n - 1);
        for (auto i = 1; i <= n; ++i) {
            for (auto j = i + 1; j <= n; ++j) {
                long long len1 = j - i - 1;
                long long len2 = ::abso(j - y) + ::abso(x - i);
                l.at(min(len1, len2))++;
            }
        }
        for (auto i = 0; i < n - 1; ++i) {
            cout << l.at(i) << ::endl;
        }
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll, ll> pll;


ll n;
vector< ll > a;
bool ok(vector<ll> &a)
{
        for(ll i=1;i<n;i++){
                if(a[i] < a[i-1]) return false;
        }
        return true;
}
int main()
{
        cin >> n;
        for(ll i=0;i<n;i++) {
                ll x;
                cin >> x;
                a.pb(x);
        }
        if(ok(a)) {
                cout << "YES\n"; return 0;
        }

        for(ll i=0;i<n;i++){
                for(ll j=i+1;j<n;j++) {
                        swap(a[i], a[j]);
                        if(ok(a)){
                                cout << "YES\n"; return 0;
                        }
                        swap(a[i], a[j]);
                }
        }
        cout << "NO\n";
        return 0;
}


Measured memory_bytes: 256
<?php
$numbers = preg_split("/[\s,]+/", rtrim(fgets(STDIN)));
$n = intval($numbers[0]);
$q = intval($numbers[1]);


$a = [];
for ($i = 0; $i < $n; $i++){
    $a[] = [];
}

for($i = 0; $i < $q; $i++){
    $numbers = preg_split("/[\s,]+/", rtrim(fgets(STDIN)));
    if (intval($numbers[0]) === 0){
        $a[intval($numbers[1])][] = $numbers[2];
    } else if (intval($numbers[0]) === 1){
        for ($j = 0; $j < count($a[intval($numbers[1])]); $j++){
    
            print $a[intval($numbers[1])][$j];
            if($j < count($a[intval($numbers[1])]) -1 ){
                print " ";
            }
        }
        print "\n";
    } else {
        $a[intval($numbers[1])] = [];
    }
}


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

def gcd(m, n):
  t = m % n
  while(t>0):
    m = n
    n = t
    t = m % n
  
  return n

def lcm(m, n):
  return m * n // gcd(m, n)

print(lcm(a, b))


Measured memory_bytes: 3060
//
//  main.cpp
//  B - Nice Shopping
//
//  Created by Hashizo on 2020/03/08.
//  Copyright © 2020 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())


int main(int argc, const char * argv[]) {


	ll a,b,m;
	cin >> a >> b >> m;

	ll raiMin = LONG_MAX;
	vector<ll> rei(a);
	REP(i, a) {
		cin >> rei[i];
		if (raiMin > rei[i]) {
			raiMin = rei[i];
		}
	}

	ll denMin = LONG_MAX;
	vector<ll> den(b);
	REP(i, b) {
		cin >> den[i];
		if (denMin > den[i]) {
			denMin = den[i];
		}
	}

	ll total = raiMin + denMin;
	vector<ll> x(m);
	vector<ll> y(m);
	vector<ll> c(m);
	REP(i, m) {
		cin >> x[i] >> y[i] >> c[i];
		ll syoukei = rei[x[i]-1] + den[y[i]-1] -c[i];
		if (total > syoukei) {
			total = syoukei;
		}
	}

	cout << total << endl;
	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  int A, B, T;
  cin >> A >> B >> T;
  int ans = 0;
  for (int i = 1; i*A <= T; i++) {
    ans += B;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())

a = []
for i in range(1,int(N**0.5)+1):
    if i**2 == N:
        a.append(i)
    elif N%i==0:
        a.append(i)
        a.append(N//i)

a.sort()

count=0
for i in a:
    if i!=1:
        M = N
        while M%i==0:
            M//=i
        if M%i == 1:
            count+=1

b = []
for i in range(1,int((N-1)**0.5)+1):
    if i**2 == N-1:
        b.append(i)
    elif (N-1)%i==0:
        b.append(i)
        b.append((N-1)//i)


for i in b:
    if N%i==1:
        count+=1


print(count)

Measured memory_bytes: 40940
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;

int main()
{
	int n, m, l, r, nowl, nowr;
	cin >> n >> m >> nowl >> nowr;
	for (int i = 1; i < m; ++i)
	{
		cin >> l >> r;
		if (l > nowl)
		{
			nowl = l;
		}
		if (r < nowr)
		{
			nowr = r;
		}
	}
	if (nowr >= nowl)
	{
		cout << nowr - nowl + 1 << endl;
	}
	else
	{
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

ll n, k;
const ll mod = 1000000007;

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    cin >> n >> k;
    ll ans = 0;
    for(int i=k; i<=n+1; i++)
    {
        ans += (ll)(n+1-i) * (ll)i;
        ans++;
        ans %= mod;
    }
    cout << ans << endl;

}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define dfor(i,a,b) for(ll i=(a);i>=(b);i--)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define ll long long
#define ull unsigned long long
#define MOD  1000000007
#define MAX  1e9
#define pb   push_back
#define F    first
#define S    second


signed main() {
	int t=1;
	//cin>>t;
	while(t--){
		long double a,b;
		cin>>a>>b;
		long long ans = a*b;
		
		// ll ans = trunc(p);
		// cout<<p<<" ";
		cout<<ans;
		
	}
	
}

Measured memory_bytes: 3728
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		double a = scan.nextDouble();
		double b = scan.nextDouble();
		double h = scan.nextDouble();
		double m = scan.nextDouble();

		double ah = 0;
		double am = 0;
		am = m * 6;
		ah = h * 30 + m / 2;

		double angle = Math.abs(am - ah);
		if(angle > 180) {
			angle = 360 - angle;
		}

		// System.out.println(angle);

		double r=Math.sqrt(Math.pow(b,2)+Math.pow(a,2)-2*b*a*Math.cos(Math.toRadians(angle)));

		System.out.println(r);

	}
}

Measured memory_bytes: 28876
import heapq
import sys

finput = sys.stdin.readline

n,m = map(int, finput().split())

q = [[] for i in range(m)]

for i in range(n):
    a,b = [int(j) for j in finput().split()]
    if a>m:
        continue
    q[a-1].append(-b)

hq = []
heapq.heapify(hq)
ans = 0
for i in range(m):
    if len(hq)==0 and len(q[i])==0:
        continue
    for j in range(len(q[i])):
        heapq.heappush(hq, q[i][j])
    ans += heapq.heappop(hq)

print(-ans)


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

#define rep(i, n) for(int i = 0; i < (n); ++i)

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

  string s; cin >> s;
  int N = s.size();
  map<char, int> mp;
  rep(i, N) mp[s[i]] = 1;
  bool flag = !(mp['N']^mp['S']) && !(mp['E']^mp['W']);

  cout << (flag ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
#include "tuple"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int n,m,a[100000],x,y,cnt;
ll s;
pair<iP,iP> g[100000];
priority_queue<iP,vector<iP>,greater<iP>>p;
set<iP>st;

int t(int x){
	if(g[x].first.first==x)
		return x;
	else return t(g[x].first.first);
}

int u(int x,int y){
	int X=t(x),Y=t(y);
	if(X!=Y){
		if(g[X].first.second<g[Y].first.second){
			g[X].first.first=Y;
			g[Y].first.second+=g[X].first.second;
			if(g[X].second.first<g[Y].second.first)
				g[Y].second=g[X].second;
		}
		else{
			g[Y].first.first=X;
			g[X].first.second+=g[Y].first.second;
			if(g[Y].second.first<g[X].second.first)
				g[X].second=g[Y].second;
		}
	}
	return 0;
}

int main() {
	cin>>n>>m;
	rep(n){
		cin>>a[i];
		p.push(mkp(a[i],i));
		g[i]=mkp(mkp(i,1),mkp(a[i],i));
	}
	rep(m){
		cin>>x>>y;
		u(x,y);
	}
	cnt=s=0;
	rep(n){
		if(g[i].first.first==i){
			++cnt;
			s+=g[i].second.first;
			st.insert(g[i].second);
		}
	}
	if((cnt-1)*2>n)
		cout<<"Impossible"<<endl;
	else{
		if(cnt==1)
			cout<<0<<endl;
		else{
			rep(cnt-2){
				while(st.find(p.top())!=st.end())
					p.pop();
				s+=p.top().first;
				p.pop();
			}
			cout<<s<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 7668
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

map<ll, ll> p_f(ll n) {
	map<ll, ll> ans;
	for (ll i = 2; i < sqrt(n)+1; i++) {
		if (n == 1)break;
		while (n % i == 0) {
			n /= i;
			ans[i]++;
		}
	}
	if (n != 1)ans[n]++;
	return ans;
}
int main() {
	int comb[100050][50];
	comb[0][0] = 1;
	for (int i = 1; i < 100050; i++) {
		comb[i][0] = 1;
		for (int j = 1; j < 50; j++) {
			comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % MOD;
		}
	}

	ll N, M;
	cin >> N >> M;
	auto a = p_f(M);
	ll ans = 1;
	for (auto itr = a.begin(); itr != a.end(); itr++) {
		ans = (ans * comb[itr->second + N - 1][itr->second]) % MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 19840
#include <bits/stdc++.h>
#define mod 998244353
using namespace std;
inline int read()
{int x=0,f=0;
char c=getchar();
while (c<'0'||c>'9') 
{if (c=='-') f=1;
c=getchar();
}
while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
if (f) x=-x;
return x;
}
int a[100005],n,m;
bool vis[100005];
int head[100005],nxt[400005],w[400005],v[400005],tot=0;
inline void add(int a,int b,int c)
{tot++;nxt[tot]=head[a];head[a]=tot;v[tot]=b;w[tot]=c;}
void dfs(int pos)
{vis[pos]=1;
for (int i=head[pos];i;i=nxt[i])
{if (vis[v[i]]&&a[v[i]]==a[pos]+w[i]) continue;
if (vis[v[i]]) {puts("No");exit(0);}
a[v[i]]=a[pos]+w[i];
dfs(v[i]);
}
}
int main (){
	int i,j,k,ad,b,c;
	n=read();m=read();
	for (i=1;i<=m;i++)
	{ad=read();b=read();c=read();
	add(ad,b,c);add(b,ad,-c);
	}
	for (i=1;i<=n;i++)
	{if (!vis[i])
	{a[i]=0;
	dfs(i);
	}
	}
	puts("Yes");
	return 0;
}
	
	

Measured memory_bytes: 7680
n,m=map(int,input().split())
x='No'
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
def c(i,j):
  global m
  global a
  global b
  for k in range(m):
    for l in range(m):
      if b[k][l]!=a[i+k][j+l]:
        return 0
  return 1
for i in range(n-m+1):
  for j in range(n-m+1):
    if c(i,j)==1:
      x='Yes'
      break
print(x)

Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define lb long double
#define vec vector<int>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	ll maxx = -100000000;
	ll mini = 100000000;
	ll sum = 0;
	rip(i, n) {
		cin >> a[i]; 
		sum += a[i];
		mini = min(mini, a[i]);
		maxx = max(maxx, a[i]);
	}
	cout << mini << " " << maxx << " " << sum << endl;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
 
#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 2e3 + 5;
pair<ll, ll> a[N];
ll dp[N][N];
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        //freopen("VLJUM.INP", "r", stdin);
        //freopen("VLJUM.OUT", "w", stdout);
        ll n;
        cin >> n;
        for (int i = 1; i <= n; i++){
                cin >> a[i].first;
                a[i].second = i;
        }
        sort(a + 1, a + n + 1, greater<pair<ll, ll>>());
        for (int i = 1; i <= n; i++){
                for (int j = 0; j <= i; j++){
                        if (j > 0) dp[i][j] = dp[i - 1][j - 1] + a[i].first * abs(a[i].second - j);
                        if (j < i) {
                                dp[i][j] = max(dp[i - 1][j] + a[i].first * abs(a[i].second - (n - (i - j - 1))), dp[i][j]);
                        }
                }
        }
        ll ans = 0;
        for (int i = 1; i <= n; i++){
                ans = max(ans, dp[n][i]);
        }
        cout << ans;
}

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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

using ll = long long;
using pii = pair<int, int>;

void solve() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a * c, a * d, b * c, b * d});
}

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define UB upper_bound
#define LB lower_bound
#define all(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define int ll

int fact[214514]={};

int power(int x, int n){
    int tmp = 1;
  
    if(n>0){
      tmp = power(x, n/2);
      if(n%2==0) tmp = (tmp*tmp)%MOD;
      else tmp = (((tmp*tmp)%MOD)*x)%MOD;
    }
    return tmp;
}

void f(){
    fact[0] = fact[1] = 1;
    FOR(i,2,214514) fact[i] = (fact[i-1] * i) % MOD;
}

int com(int h,int w){
    return (fact[h+w] * power((fact[h]*fact[w])%MOD,MOD-2)) % MOD;
}

signed main(){
    int h,w,a,b;
    scanf("%lld%lld%lld%lld",&h,&w,&a,&b);
    f();

    int ans = com(h-1,w-1);

    int sub = 0;

    for(int i=h-a;i<h;i++){
        sub += (com(i,b-1) * com(h-1-i,w-1-b)) % MOD;
        sub %= MOD;
    }

    ans -= sub;

    while(ans<0) ans += MOD;

    printf("%lld\n",ans%MOD);


    return 0;
}

Measured memory_bytes: 1920
"use strict";
function Main(input) {
  const args = input.split('\n');
  const NM = args.shift().split(' ').map(m => parseInt(m));
  const N = NM.shift();
  const M = NM.shift();
  let cL = 0;
  let cR = Math.pow(10, 5);
  for (let arg of args) {
    const LR = arg.split(' ').map(m => parseInt(m));
    const L = LR.shift();
    if (L > cL) {
      cL = L;
    }
    const R = LR.shift();
    if (R < cR) {
      cR = R;
    }
  }
  const ret = cR - cL + 1;
  console.log(ret > 0 ? ret : 0);

}

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


Measured memory_bytes: 29292
#include <iostream>
#include <string>
#include <map>
#include <vector>
#define rep(i, n) for(int i=0 ; i<n; ++i)
#define rep2(i, j, n) for(int i=j; i<n; ++i)
using namespace std;
typedef long long ll;
typedef unsigned long ul;

int main(){
    ll A, B;
    cin>>A >> B;
    ll ans=0;
    if(A > 2*B) ans = A - 2*B;

    cout<<ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
  int ma,mb,n,m,i,j,suma,sumb;
  while(1){
    int min=0;
    suma=0;
    sumb=0;
    cin>>n>>m;
    if (n==0) break;
    int a[n];
    int b[m];
    for (i=0;i<n;i++){
      cin>>a[i];
    }
    for (i=0;i<m;i++){
      cin>>b[i];
    }
    
    //a??¨b???????¨?????¨????
    for (i=0;i<n;i++){
      suma=suma+a[i];
    }
    for (i=0;i<m;i++){
      sumb=sumb+b[i];
    }
    
//(a[i]-b[j])*2=suma-sumb??¨???????????????????????????????????°??????
    for (i=0;i<n;i++){
      for (j=0;j<m;j++){
        if((a[i]-b[j])*2==suma-sumb){
          if(a[i]+b[j]<min||min==0){
            min=a[i]+b[j];
            ma=a[i];
            mb=b[j];
          }
        }
      }
    }
    if (min==0) cout<<-1<<endl;
    if (min!=0) cout<<ma<<" "<<mb<<endl;
  }
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void)
{
    int A, B, C;

    scanf("%d%d%d", &A, &B, &C);

    if(A == B && B != C)
        printf("Yes");
    else if(B == C && C != A)
        printf("Yes");
    else if(C == A && A != B)
        printf("Yes");
    else
        printf("No");
       
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

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

const int MOD = 1000000007;

int main() {
    int x,y; cin >> x >> y;
    string s; cin >> s;
    int a[s.length()+1]; int sum = 0;
    for(int i = 0;i < s.length()+1;i++){
        a[i] = 0;
    }
    for(int i = 0;i < s.length()+1;i++){
        if(s[i] == 'A' && s[i+1] == 'C'){
            sum ++;
            a[i+1] = sum;
        }else{
            a[i+1] = sum;
        }
    }
    
    for(int i = 0;i < y;i++){
        int d,f; cin >> d >> f;
        cout << a[f-1]-a[d-1] << endl;
    }
}



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

long long gcd (long long x, long long y) {
  long long r;   
  if (x < y) {
    swap(x, y);  
  }
  while (x % y != 0) {
    r = x % y;
    x = y;
    y = r;
  }  
  return y;
}

int main () {
  long long n;
  cin >> n;
  long long A[n];
  for (long long i = 0; i < n; i++) {
    cin >> A[i];      
  }
  long long min = A[0];
  for (long long i = 1; i < n; i++) {
    min = min / gcd(A[i], min);
    min = min * A[i];    
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll s;cin>>s;
  map<ll,ll> mp;
  ll now=s;
  mp[s]++;
  for(ll i=2;;i++){
    if(now%2==0)now/=2;
    else now=3*now+1;
    if(mp[now]==1){
      cout<<i<<endl;
      return 0;
    }
    mp[now]++;
  }
}
  


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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  int n, cmd;
  string str;
  cin >> n >> cmd >> str;

  ll left = 0,right = -1;
  int cmdCnt = 0;
  bool flag = false;
  ll maxLength = 0;

  for(;; right ++){
    if(right == n-1) break;
    if(flag){ //0が連続している
      if(str[right+1] != '0'){
        flag = false;
      }
    }
    else{
      if(str[right+1] == '0'){
        if(cmdCnt == cmd) break;
        else{
          cmdCnt++;
          flag = true;
        }
      }
    }
  }

  maxLength =  right - left + 1;

  while(true){
      //左を縮める
      bool leftFlag = false;
      while(left <= right){
          if(leftFlag == false){
              if(str[left] == '1') left++;
              else{leftFlag = true; left++;}
          }else{
              if(str[left] == '1'){break;}
              else left++;
          }
      }
      //右を伸ばす
      bool rightFlag = false;
      while(right < n){
          if(right == n-1) break;
          if(rightFlag == false){
              if(str[right+1] == '0') right++;
              else{rightFlag = true; right++;}
          }else{
              if(str[right+1] == '0') break;
              else right++;
          }
      }
      //cout << left << ' ' << right << endl;
      if(right == n-1){
          cout << max(maxLength, right - left + 1) << endl;
          break;
      }else{
          maxLength = max(right - left + 1, maxLength);
      }
  }

  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
main(void){
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/b;
    printf("%d %d %.8lf\n",d,r,f);
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<complex>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int mon[11] = {0};
    rrep(i, 1, 11) {
        if (i % 2 != 0) {
            mon[i] = 20;
        } else {
            mon[i] = 19;
        }
    }
    int oney = 0;
    rrep(i, 1, 11) oney += mon[i];
    int mon2[11] = {0};
    rrep(i, 1, 11) mon2[i] = 20;
    int oney2 = 20 * 10;
    int mil = 0;
    rrep(i, 1, 999) {
        if (i % 3 == 0) {
            mil += oney2;
        } else {
            mil += oney;
        }
    }
    int n; cin >> n;
    rep(i, n) {
        int y, m, d; cin >> y >> m >> d;
        int ans = 0;
        rrep(j, 1, y) {
            if (j % 3 == 0) {
                ans += oney2;
            } else {
                ans += oney;
            }
        }
        if (y % 3 == 0) {
            ans += 20 * (m - 1);
        } else {
            rep(j, m) ans += mon[j];
        }
        ans += d - 1;
        cout << mil - ans + 200 << endl;
    }
}



Measured memory_bytes: 3228
#include<stdio.h>
int dp[10001]={0};

int inarea(int n)
{
    if(n <= 2)return 0;
    dp[n] = inarea(n-1)+n-2;
    return dp[n];
}

int main()
{
    int n;
    while(scanf("%d",&n) != -1)
    {
        printf("%d\n",2*n+inarea(n));
    }
    return 0;
}

Measured memory_bytes: 1212
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {

		while (sc.hasNext()) {
			char[] code = sc.nextLine().toCharArray();

			decode(code);
		}

	}

	private static void decode(char[] code) {
		char[] decode = new char[code.length];

		for(int i = 0; i < 26; i++) {

			for(int j = 0; j < code.length; j++) {

				if ( code[j] == '.' || code[j] == ' ' || code[j] == '\n') {
					decode[j] = code[j];

				} else {
					int num = ( code[j] - 'a' + i ) % 26;
					decode[j] = (char) ('a' + num);

				}
			}

			String str = String.valueOf(decode);

				if (str.contains("the") || str.contains("this") || str.contains("that")) {
					System.out.println(str);
					break;
				}

		}
	}

}


Measured memory_bytes: 25940
#include <cstdio>

const int MAXN=2e5+10;

int N;
int arr[MAXN];

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

    for(int i=1;i<N;i++){
        int Ai;
        scanf("%d",&Ai);
        arr[Ai]++;
    }

    for(int i=1;i<=N;i++) printf("%d\n",arr[i]);

    return 0;
}

Measured memory_bytes: 2512
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
string S; 
cin >> S; 
int A[5] = {}; 
for(int i = 0; i < S.size(); i++){
if(S.at(i) == 'N'){
A[0] ++; 
}
if(S.at(i) == 'E'){
A[1] ++; 
}
if(S.at(i) == 'W'){
A[2] ++; 
}
if(S.at(i) == 'S'){
A[3] ++; 
}
}
string ans = "Yes"; 
if(A[0] == 0 && A[3] != 0){
ans = "No"; 
}
if(A[3] == 0 && A[0] != 0){
ans = "No"; 
}
if(A[1] == 0 && A[2] != 0){
ans = "No"; 
}
if(A[2] == 0 && A[1] != 0){
ans = "No"; 
}
cout << ans << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define MAX_N 100100

using namespace std;

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n+1), right_gcd(n+1), left_gcd(n+1);
  for(int i = 0; i < n; i++)
    cin >> a[i];
  
  //gcd with binary search
  left_gcd[1] = 0;
  right_gcd[n] = 0;
  for(int i = 2; i <= n; i++){
    right_gcd[n+1-i] = gcd(max(right_gcd[n+2-i], a[n+1-i]), \
                          min(right_gcd[n+2-i], a[n+1-i]));
    left_gcd[i] = gcd(max(left_gcd[i-1], a[i-2]), \
                          min(left_gcd[i-1], a[i-2]));
  }
  
  //merge gcd
  int answer = 0;
  for(int i = 1; i <= n; i++){
    int i_gcd = gcd(max(left_gcd[i], right_gcd[i]), \
                          min(left_gcd[i], right_gcd[i]));
    if(answer < i_gcd)
      answer = i_gcd;
  }
  cout << answer << endl;
}
  


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

using namespace std;
const int maxn = 1e5+10;
int cnt[maxn];
int main(){
    int n;
    cin >> n;
    for(int i = 1;i * i<=n;i++){
        for(int j = 1;j * j<=n;j++){
            for(int k =1;k * k<=n;k++){
                cnt[i *i + j *j + k *k + i*j + j *k +i *k]++;
            }
        }
    }
    for(int i = 1;i<=n;i++){
        cout << cnt[i] << endl;
    }
    // system("pause");
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#include <vector>
#include <string>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

bool compare_array(vector<int> a1, vector<int> a2) {
  int n = min(a1.size(), a2.size());
  for(int i=0; i<n; i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
    return a1.size() - a2.size();
  }
}

bool array_equal(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return false;
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return false;
    }
  }
  return true;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

int main() {
  std::cout << std::setprecision(9);
  int n;
  cin >> n;

  vector<string> s(n);
  for (int i=0; i<n; i++) {
    cin >> s.at(i);
    sort(s.at(i).begin(), s.at(i).end());
  }
  sort(s.begin(), s.end());

  long ans = 0;
  long count = 1;
  for (int i=1; i<n; i++) {
    if (s.at(i - 1) == s.at(i)) {
      ans += count;
      count++;
    }
    else {
      count = 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 7296
#include <iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    int a = 0; int b = 0; int c = 0;
    while (cin >> x) {
        if (x > a) {
            c = b;
            b = a;
            a = x;
        }
        else if (x > b) {
            c = b;
            b = x;
        }
        else if (x > c)
            c = x;
    }
    cout << a << "\n" << b << "\n" << c << "\n";
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 87;
int a[N], la[20];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    long long ans = 0;
    int pr = -1;
    fill_n(la,20,-1);
    for (int i = 0; i < n; ++i) {
        for (int j = 0, x = a[i]; j < 20; ++j, x>>=1)
            if (x&1) {
                pr = max(pr, la[j]);
                la[j] = i;
            }
        ans += i - pr;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
using ulong = unsigned long;
using ll = long long;
const int M = 1e9 + 7;
#pragma unused(M)

double solve(int n, double d1, double dSum, double x){
    double d2 = d1 + x, d2n_1 = d1 + (2 * n - 2) * x, d2n = d1 + (2 * n - 1) * x;
    cout<<n<<' '<<d1<<' '<<dSum<<endl;
    if(!n){ return 0; }
    return dSum / 2 / n + solve(n - 1, d1 + d1 / n + 5.0 / 2 / n * x, dSum - (d1 + d2 + d2n_1 + d2n) / 2 / n, x + 2 * x / n);
}

int main(){
	double n, d1, x, ans = 0;
	cin >> n >> d1 >> x;
    // cout << fixed << setprecision(10) << solve(n, d1, d1 * 2 * n + 2 * n * x * (2 * n - 1) / 2, x) << endl;
    double dSum = d1 * 2 * n + 2 * n * x * (2 * n - 1) / 2;
    while(n){
        ans += dSum / 2 / n;
        double d2 = d1 + x, d2n_1 = d1 + (2 * n - 2) * x, d2n = d1 + (2 * n - 1) * x;
        dSum -= (d1 + d2 + d2n_1 + d2n) / 2 / n;
        d1 += d1 / n + 5.0 / 2 / n * x;
        x += 2 * x / n;
        n--;
    }
    cout << fixed << setprecision(10) << ans << endl;
	return 0;
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var (
		a, b, c, d int
	)
	fmt.Scan(&a, &b, &c, &d)
	left := a + b
	right := c + d
	if left > right {
		fmt.Println("Left")
	} else if left == right {
		fmt.Println("Balanced")
	} else {
		fmt.Println("Right")
	}
}


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

const int size = 100001;
int N;
int A[size];
int numOfCards[size];
int numOf2, numOf1;

void init() {
  cin >> N;
  
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    numOfCards[A[i]] += 1;
  }

  for(int i = 1; i < size; i++) {
    if(numOfCards[i] == 0)
      continue;
    if(numOfCards[i] % 2 == 0) {
      numOf2 += 1;
    }else {
      numOf1 += 1;
    }
  }
}

void solve() {
  if(numOf2 == 0) {
    cout << numOf1 << endl;
    return;
  }
  
  if(numOf2 % 2 == 0) {
    cout << numOf1 + numOf2 << endl;
    return;
  }

  cout << numOf1 + numOf2 - 1 << endl;

}

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


Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.List;
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];
		List<Integer> list = new ArrayList<Integer>();
		int count = 1;
		int Hakai = 0;

		for(int i = 0;i < a.length;i++) {
			a[i] = sc.nextInt();
		}



		for(int i = 0;i < a.length;i++) {
			if(a[i] == count) {
				count++;
			}else {
				Hakai++;
			}
		}
		if(count-1 + Hakai == n && count != 1) {
			System.out.println(Hakai);
		}else {
			System.out.println(-1);
		}

	}

}


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

int main() {
  int N, A, B;
  cin >> N;
  vector<int>W(N);
  vector<int>X(N - 1);
  vector<char>Y(N - 1);
  for (int i = 0; i < N; i++) {
    cin >> W.at(i);
  }
  for (int i = 0; i < N - 1; i++) {
    A = 0;
    B = 0;
    for (int j = 0; j <= i; j++) {
      A += W.at(j);
    }
    for (int j = i + 1; j < N; j++) {
      B += W.at(j);
    }
    if (A == B) {
      Y.at(i) = 'Z';
      X.at(i) = 0;
    }
    else if (A > B) {
      Y.at(i) = 'P';
      X.at(i) = A - B;
    }
    else {
      Y.at(i) = 'M';
      X.at(i) = B - A;
    }
  }
  if (Y.at(0) == 'P') {
    cout << X.at(0);
  }
  if (Y.at(N - 2) == 'M') {
    cout << X.at(N - 2);
  }
  if (Y.at(N - 2) == 'Z') {
    cout << 0;
  }
  for (int i = 0; i < N - 2; i++) {
    if (Y.at(i) == 'Z') {
      cout << 0;
      break;
    }
    if (Y.at(i) == 'P' && Y.at(i + 1) == 'M') {
      cout << min(X.at(i), X.at(i + 1));
    }
    if (Y.at(i) == 'M' && Y.at(i + 1) == 'P') {
      cout << min(X.at(i), X.at(i + 1));
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>
 
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
 
#define MAX  40002
#define BASE 20000
 
int a[MAX];
int sum[MAX]; int sz;
int left[MAX];
 
int main()
{
    int i, j, k, x, h, s, ans;
    int c;
 
    h = BASE, ans = s = 0;
    for (x = 1; ; x++) {
        c = gc();
        if (c <= ' ') break;
        if (c == '\\') {
            if (s > 0) ans += s, sum[sz++] = s, s = 0;
            a[--h] = x;
        } else if (c == '/') {
            if (a[h] > 0) left[sz] = a[h], s += x-a[h];
            else if (s > 0) ans += s, sum[sz++] = s, s = 0;
            h++;
        }
    }
    if (s > 0) ans += s,  sum[sz++] = s;
 
    printf("%d\n", ans);
    k = sz;
    i = sz-1; while (i > 0) {
        j = i-1; while (j >= 0 && left[j] > left[i]) {
            sum[i] += sum[j], sum[j] = 0, j--, k--;
        }
        i = j;
    }
 
    printf("%d", k);
    for (i = 0; i < sz; i++) if (sum[i] > 0) printf(" %d", sum[i]);
    putchar('\n');
    return 0;
}


Measured memory_bytes: 2104
// sync

#include <algorithm>
#include <cstdio>
#include <cstring>

const int N = 1e5 + 51;

int dp[N], xorv[N];
int dfs(int S) {
	if (dp[S]) return dp[S];
	int ret = __builtin_popcount(S) - 1;
	for (int T = (S - 1) & S; T; T = (T - 1) & S)
		if (!xorv[T]) ret = std::min(ret, dfs(T) + dfs(S ^ T));
	return dp[S] = ret;
}

int n, x, y, z, v[N], c[22], ans, msk;
int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		scanf("%d%d%d", &x, &y, &z), x++, y++;
		x[v] ^= z, y[v] ^= z;
	}
	for (int i = 1; i <= n; i++) i[v][c]++;
	for (int i = 1; i <= 15; i++) {
		ans += i[c] / 2;
		msk |= (i[c] & 1) << (i - 1);
	}
	for (int S = 0; S < 32768; S++)
		for (int j = 1; j <= 15; j++)
			if ((S >> (j - 1)) & 1) xorv[S] ^= j;
	printf("%d", ans + (msk ? dfs(msk) : 0));
}

Measured memory_bytes: 896
#include <stdio.h>

int main(){
  char a[300];
  unsigned long b;
  scanf("%s", &a);
  scanf("%lu", &b);
  
  if( b > 101 ) b = 101;
  int c = b - 1;
  
  char ans;
  for(int i = 0; i < 101; i++){
    if(a[i] != '1'){
      ans = a[i];
      break;
    }else{
      if(i == c){
        ans = '1';
        break;
      }
    }
  }
  
  printf("%c\n", ans);
  
  return 0;
  
}

Measured memory_bytes: 128
//gauravsinghh
#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;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair < ll, ll >&a, const pair < ll, ll >&b){
    return ((a.ss < b.ss) || (a.ss == b.ss && a.ff < b.ff));
}

signed main(){ 
    IOS
    //io_set();
    ll n, c = 1;
    cin >> n;
    unordered_map < ll , ll > mpp;
    while(1){
        if(mpp[n]){
            break;
        }
        mpp[n] = 1;
        if(n&1){
            ll x = 3*n+1;
            n = x;
        }
        else{
            n /= 2;
        }
        c++;
    }
    cout << c << endl;
    return 0;
}



Measured memory_bytes: 384
#include<stdio.h>

int main(){
int a,b,c,ans=0;
scanf("%d%d%d",&a,&b,&c);
if(a!=b)ans++;
if(a!=c)ans++;
if(b!=c)ans++;
if(ans==0)ans++;
printf("%d\n",ans);
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int main(){
    char a[1000];
    
    while(scanf("%s", a), a[0] != '0'){
        int b = 0;
        for(int i = 0; i < strlen(a); i++){
            int c = a[i] - '0';
            b += c%10;
        }
        printf("%d\n", b);    
    }
    return 0;
}


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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define INF LLONG_MAX

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int n;
  cin >> n;
  
  vector<int> upper(n);
  vector<int> lower(n);
  int curTotal = 0;
  for(int i=0;i<n;i++){
    cin >> upper[i];
    if(i==0) curTotal = upper[i];
  }
  for(int i=0;i<n;i++){
    cin >> lower[i];
    curTotal += lower[i];
  }

  int maxTotal = curTotal;
  for(int i=1;i<n;i++){
    curTotal += upper[i];
    curTotal -= lower[i-1];
    maxTotal = max(maxTotal,curTotal);
  }

  cout << maxTotal << endl;
  
  return 0;
}



Measured memory_bytes: 3732
N, X = map(int, input().split())
*xs, = map(int, input().split())

S = [0]*(N+1)
r = 0
for i in range(N):
    S[i+1] = r = xs[i] + r

ans = 10**30
for k in range(1, N+1):
    r = (S[N] - S[N - k]) * 5
    for i in range(1, (N-1)//k):
        r += (S[N - k*i] - S[N - k*(i+1)]) * (2*i + 3)
    p = (N-1)//k
    r += (S[N - k*p]) * (2*p + 3)
    ans = min(ans, r + (k + N)*X)
print(ans)


Measured memory_bytes: 26408
function main()
  
  (N,M) = map(x -> parse(Int,x), split(readline()))
  X = map(x -> parse(Int,x), split(readline()))
  check = zeros(Int,N)
  sum = Int[]
  sort!(X)
  
  for i in 1:M-1
    push!(sum,abs(X[i]-X[i+1]))
  end

  sort!(sum,rev = true)

  ans = 0
  count = 1
  
  for i in 1:length(sum)
    if count < N
      count += 1
    else
      ans += sum[i]
    end
  end
  
  println(ans)
  
end

main()

Measured memory_bytes: 172576
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << # x << "; "<< x << endl


int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	for (int i = 0; i < 200; i++) {
			C -= B;
			if (C <= 0) {
				cout << "Yes" << endl;
				break;
			}
			else if (A > 0) {
				A -= D;
				if (A <= 0) {
				cout << "No" << endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 3600
y = {'r' => 'qwertasdfgzxcvb', 'l' => 'yuiophjklnm'}
while (n = gets.chomp) != '#'
  f, *s = n.split('')
  h = y['r'].include?(f) ? 'r' : 'l'
  c = 0
  s.each do |k|
    unless y[h].include?(k)
      h = h == 'r' ? 'l' : 'r'
      c += 1
    end
  end
  p c
end

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

signed main() {
	int a, b, k; cin >> a >> b >> k;
	rep(i, k) {
		if (i & 1) {
			if (b & 1)b--;
			a += b / 2;
			b /= 2;
		}
		else {
			if (a & 1)a--;
			b += a / 2;
			a /= 2;
		}
	}
	cout << a << ' ' << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int v[100009][3];
int dp[100009][3];
int n;
int vacation(int i, int j)
{
    if(i==n-1)
        return dp[i][j]=v[i][j];
    if(i>=n || j>=3)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    int temp = INT_MIN;
        if(j==0)
        {
             temp = max(vacation(i+1,j+1)+v[i][j],temp);
        temp = max(vacation(i+1,j+2)+v[i][j],temp);
 return dp[i][j]= temp;
        }
      else  if(j==1)
        {
             temp = max(vacation(i+1,0)+v[i][j],temp);
        temp = max(vacation(i+1,2)+v[i][j],temp);
 return dp[i][j]= temp;
        }
        else
        {
             temp = max(vacation(i+1,1)+v[i][j],temp);
        temp = max(vacation(i+1,0)+v[i][j],temp);
         return dp[i][j]= temp;
        }
}

int main()
{
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(int i=0; i<n; i++)
        cin>>v[i][0]>>v[i][1]>>v[i][2];
    cout<<max(vacation(0,0),max(vacation(0,1),vacation(0,2)))<<endl;
}


Measured memory_bytes: 7296
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 2 * 100000 + 47;
const int MOD = 1000 * 1000 * 1000 + 7;

int A[MAX];
void sim(string& s)
{
	int p = 0;
	int d = 1;
	while (1)
	{
		if (p == -1 || p == SZ(s)) break;
		if (s[p] == 'A')
		{
			s[p] = 'B';
			d *= -1;
			p += d;
			continue;
		}
		else
		{
			s[p] = 'A';
			p += d;
		}
	}
}

void sim(string& s, int k)
{
	FOR(i, 0, k)
	{
		sim(s);
	}
}

void calc(string& s, int k)
{
	int rev = 0;
	int p = 0;
	int n = SZ(s);
	if (n == 1)
	{
		s[0] = ((s[0] - 'A') ^ (k & 1)) + 'A';
		return;
	}

	FOR(i, 0, n) A[i] = s[i] == 'B';

	FOR(i, 0, min(k, 4 * n + k % 2))
	{
		if (A[p] ^ rev == 0)
		{
			A[p] ^= 1;
			continue;
		}

		rev ^= 1;
		A[p] = rev;
		p++;
		if (p == n) p = 0;
	}

	FOR(k, 0, n)
	{
		int i = p + k;
		if (i >= n) i -= n;

		s[k] = (A[i] ^ rev) + 'A';
	}
}

string s;
int k, n;
void gen()
{
	n = rand() % 10 + 1;
	s.clear();
	FOR(i, 0, n)
	{
		s.push_back(rand() % 2 + 'A');
	}

	k = rand() % 10 + 1;
}

//#define TEST

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);

#ifdef TEST
	while (1)
	{
		gen();
		cout << s << " " << k << endl;
		string s1 = s;
		calc(s, k);
		sim(s1, k);
		if (s1 != s)
		{
			cout << "fail" << endl;
			cout << s << endl;
			cout << s1 << endl;
			return 0;
		}
	}
#else
	cin >> n >> k >> s;
	calc(s, k);
	cout << s << endl;
#endif

}

Measured memory_bytes: 1560
def a_range_product(A, B):
    ans = ''
    if A * B <= 0:
        ans = 'Zero'  # 区間 [A,B] の内部に必ず0を含む
    else:
        if A > 0:
            ans = 'Positive'  # A>0ならB>0
        else:  # A<0,B<0のときここを通る
            ans = 'Negative' if abs(B - A + 1) % 2 == 1 else 'Positive'
    return ans

A, B = [int(i) for i in input().split()]
print(a_range_product(A, B))

Measured memory_bytes: 3060