akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int n;
    cin >> n;
    s64 a, b;
    vector< pair<s64, s64> > vec(n);
    rep (i, n)
    {
        cin >> a >> b;
        vec[i] = make_pair(a + b, a);
    }
    sort(vec.begin(), vec.end(), greater< pair<s64, s64> >());


    s64 ans = 0;
    rep (i, n)
    {
        if (!(i & 1))
        {
            ans += vec[i].second;
        }
        else
        {
            ans -= vec[i].first - vec[i].second;
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

int H, N;

int main() {
	cin >> H >> N;
	vector<int> A(N);
	vector<int> B(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}
	vector<int> dp(H + 1, 100000000);
	dp[0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < H; j++) {
			if (j + A[i] > H) {
				dp[H] = min(dp[H], dp[j] + B[i]);
			}
			else {
				dp[j + A[i]] = min(dp[j + A[i]], dp[j] + B[i]);
			}
		}
	}
	cout << dp[H] << endl;
}

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

template <typename T>
struct RMQ{
	const T INF = numeric_limits<T>::max();
	int n;
	vector<T> dat;
	RMQ(int n_) : n(), dat(n_ * 4, INF){
		int x = 1;
		while(n_ > x){
			x *= 2;
		}
		n = x;
	}

	void update(int k, T a){
		k += n - 1;
		dat[k] = a;
		while(k > 0){
			k = (k - 1) / 2;
			dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}

	T query_sub(int a, int b, int k, int l, int r){
		if(r <= a || b <= l) return INF;
		else if(a <= l && r <= b) return dat[k];
		else{
			T vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
			T vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
			return min(vl, vr);
		}
	}

	T query(int a, int b){
		return query_sub(a, b, 0, 0, n);
	}
};

signed main(){
	int n, Q;
	vector<int> ans;
	scanf("%d %d", &n, &Q);
	RMQ<int> rmq(n);
	for(int i = 0; i < Q; i++){
		int type;
		scanf("%d", &type);
		if(type == 0){
			int s, x;
			scanf("%d %d", &s, &x);
			rmq.update(s, x);
		}
		else{
			int s, t;
			scanf("%d %d", &s, &t);
			ans.push_back(rmq.query(s, t + 1));
		}
	}
	for(int i = 0; i < ans.size(); i++) cout << ans[i] << endl;
}




Measured memory_bytes: 4812
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug(){
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

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

    long long n; cin >> n;

    cout << (n >= 30 ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
  int N, L;
  cin >> N >> L;
  //vector<vector<char>> S(N, vector<char>(L));
  vector<string> S;
  string tmp;
  for(int i = 0; i < N;i++){
    cin >> tmp;
    S.push_back(tmp);
  }
  sort(S.begin(), S.end());
  for(int i = 0; i < N;i++){
    cout << S.at(i);
  }
  cout << endl;
  return 0;
}


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

if s < 3:
    print(0)
    exit()

res = 0

mod = 10**9+7
n = 10**4
x = [1, 1]
y = [1, 1]
rev = [0, 1]
for i in range(2, n + 1):
    x.append((x[-1] * i) % mod)
    rev.append((-rev[mod % i] * (mod//i)) % mod)
    y.append((y[-1] * rev[-1]) % mod)


def solve(n, r):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return x[n] * y[r] * y[n-r] % mod


for i in range(s//3):
    s -= 3
    res += solve(s+i, i)
    res %= mod

print(res)

Measured memory_bytes: 10208
#include<set>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<=b;++i)
const int N=1e5+5,M=2e5+5,inf=1e9+7;
using namespace std;
bool vis[N];
int n,m,e,nxt[M<<1],lnk[N],ter[M<<1],dis[N],w[M<<1];
set<int>S[N];
priority_queue<pair<int,int> >q;
void add(int x,int y,int z)
{
    ter[++e]=y;
    nxt[e]=lnk[x];
    lnk[x]=e;
    w[e]=z;
}
void Solve()
{
    int x,y,z;
    rep(i,1,m)
    {
        scanf("%d%d%d",&x,&y,&z);
        add(x,y,z);
        add(y,x,z);
    }
    rep(i,1,n)
    {
        dis[i]=inf;
        vis[i]=true;
    }
    dis[1]=0;
    q.push(make_pair(0,1));
    for(; !q.empty();)
    {
        int u=q.top().second;
        q.pop();
        if(!vis[u])continue;
        vis[u]=false;
        for(int i=lnk[u]; i; i=nxt[i])
        {
            int v=ter[i];
            int c=(S[u].find(w[i])!=S[u].end()?0:1);
            if(dis[u]+c<dis[v])
            {
                dis[v]=dis[u]+c;
                S[v].clear();
                S[v].insert(w[i]);
                q.push(make_pair(-dis[v],v));
            }
            else if(dis[u]+c==dis[v])
            {
                S[v].insert(w[i]);
            }
        }
    }
    if(dis[n]==inf)puts("-1");
    else
        printf("%d\n",dis[n]);
}
void Clear()
{
    rep(i,1,n)lnk[i]=0;
    rep(i,1,n)S[i].clear();
    e=0;
}

int main()
{
    for(;scanf("%d%d",&n,&m)!=EOF;)
    {
        Solve();
        Clear();
    }
}


Measured memory_bytes: 20216
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	_ = nextInt()
	m := nextInt()

	llim := nextInt()
	rlim := nextInt()

	for i := 1; i < m; i++ {
		l := nextInt()
		r := nextInt()

		if rlim < l { //重なってない
			fmt.Println(0)
			return
		}
		if r < llim { //重なってない
			fmt.Println(0)
			return
		}

		llim = max(llim, l)
		rlim = min(rlim, r)

	}

	fmt.Println(rlim - llim + 1)

}
func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,ll> ii;
typedef pair <ll,ii> iii;

const int inf = 1<<30;
const ull mod = 1000000007;

ll v[105], w[105], dp[105][100005], weight;
int n;

ll solve(int id, ll sum){
    if(id == n || sum <= 0) return 0;
    int aux = int(((double)sum/(double)weight)*100000);
    if(dp[id][aux] != -1)
        return dp[id][aux];
    ll ans = solve(id+1, sum);
    if(sum >= w[id])ans = max(ans, solve(id+1, sum - w[id]) + v[id]);
    return dp[id][aux] = ans;
}

int main(){
    //fastio;
    //cout << int(((double)5/(double)15)*100000) << endl;
    memset(dp, -1, sizeof(dp));
    ll x,y;
    cin >> n >> weight;
    for(int i = 0; i < n; i++){
        cin >> w[i] >> v[i];
    }
    cout << solve(0, weight) << endl;
    return 0;
}


Measured memory_bytes: 82304
n = input()
a = list(map(int, input().split()))
flg = True
break_flg = False
total = 0
while True:
  for i, b in enumerate(a):
    if b%2 == 0:
      a[i] = b/2
    else:
      break_flg = True
  if break_flg :
    break
  else:
    total += 1
print(total)


Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main(){
    long long int n; cin >> n;
    long long int ex, base = 1, digits[32] = { 0 };

    if(!n){
        cout << 0 << endl; return 0; 
    }

    for(ex = 0, base = 1; n != 0; ex++, base <<= 1){
        digits[ex] = (abs(n) % (base*2)) ? 1 : 0;

        if(!(ex % 2)){
            n -= digits[ex]*base;
        } else {
            n += digits[ex]*base;
        }
    }

    for(int i = ex-1; i >= 0; i--) cout << digits[i];
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
l = [list(map(int,input().split())) for _ in range(3)]
lb = [[0 for j in range(3)] for i in range(3)]
bl = []
cnt = 0
f = 0

# print(l)
# print(lb)

n = int(input())

for i in range(n):
    bl.append(int(input()))

bll = list(dict.fromkeys(bl))
# print(bll)

for i in bll:
    for j in range(3):
        for k in range(3):
            if l[j][k] == int(i):
                # print('hit')
                lb[j][k] = 1
                break

# print(lb)

for i in range(3):
    for j in range(3):
        if lb[i][j] == 1:
            cnt += 1
        else:
            cnt = 0
            break
    else:
        if cnt == 3:
            f = 1
            break
        else:
            cnt = 0

cnt = 0

for i in range(3):
    for j in range(3):
        if lb[j][i] == 1:
            cnt += 1
        else:
            cnt = 0
            break
    else:
        if cnt == 3:
            f = 1
            break
        else:
            cnt = 0

if lb[0][0] == 1 and lb[1][1] == 1 and lb[2][2] == 1:
    f = 1
elif lb[0][2] == 1 and lb[1][1] == 1 and lb[2][0] == 1:
    f = 1

if f:
    print('Yes')
else:
    print('No')

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

# s=list(input())

# li = list(map(int,input().split()))	

# s = [2, 3, 1, 4, 5]
# sorted(range(len(s)), key=lambda k: s[k])

# a=input()
# a=int(a)
a=x-2*y
if(a<0):
    print(0)
else:
    print(a)

Measured memory_bytes: 2940
N, K, Q = gets.chomp.split.map(&:to_i)

if (Q - K)%2 == 0
	puts (Q - K)/2
else
	start = K - 1
	fin = N - Q
	if start < fin
		puts (Q-1+start+1)/2
	else
		puts (N-K+fin+1)/2
	end
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using lli = long long int;
ll MM = 1000000000;
ll mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)

ll n; 
ll ans = 0;

void dfs(ll x, int a, int b, int c){
    if(x > n) return;
    if(a == 1 && b == 1 && c == 1) ans++;
    dfs(10*x + 3, 1, b, c);
    dfs(10*x + 5, a, 1, c);
    dfs(10*x + 7, a, b, 1);
}

int main(){
    cin >> n;
    dfs(0,0,0,0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

void bfs(int s){
    queue<int> q;
    q.push(s);
    for(int i = 0; i < n; i++) d[i] = INFTY;
    d[s] = 0;
    int u;
    while(!q.empty()){
        u = q.front();
        q.pop();
        for(int v = 0; v < n; v++){
            if(M[u][v] == 0) continue;
            if(d[v] != INFTY) continue;
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    
    for(int i = 0; i < n; i++){
        cout << i+1 << " " <<((d[i] == INFTY) ? (-1) : d[i]) << endl;
    }
}

int main(){
    int u, k, v;
    
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++) M[i][j] = 0;
    }
    
    for(int i = 0; i < n; i++){
        cin >> u >> k;
        u--;
        for(int j = 0; j < k; j++){
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    
    bfs(0);
    
    return 0;
}


Measured memory_bytes: 3132
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) A[i] = scanner.nextInt();
    long[] csum = new long[N];
    csum[0] = A[0];
    for (int i = 1; i < N; i++) csum[i] = csum[i - 1] + A[i];

    int i = 0;
    int j = 2;
    long min = csum[N - 1];
    for (int k = 1; k < N - 2; k++) {
      if (j == k) j++;
      while (i + 1 < k && Math.abs(csum[k] - csum[i] * 2) > Math.abs(csum[k] - csum[i + 1] * 2)) {
        i++;
      }
      long ck = csum[N - 1] + csum[k];
      while (j < N - 2 && Math.abs(ck - csum[j] * 2) > Math.abs(ck - csum[j + 1] * 2)) {
        j++;
      }
      min = Math.min(min, diff(csum[i], csum[k] - csum[i], csum[j] - csum[k], csum[N - 1]- csum[j]));
    }
    System.out.println(min);
  }

  private static long diff(long a, long b, long c, long d) {
    return max(a, b, c, d) - min(a, b, c, d);
  }

  private static long max(long a, long b, long c, long d) {
    return Math.max(a, Math.max(b, Math.max(c, d)));
  }

  private static long min(long a, long b, long c, long d) {
    return Math.min(a, Math.min(b, Math.min(c, d)));
  }
}


Measured memory_bytes: 82596
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N=II()

xorsm=0
AS=LI()
for i in AS:
    xorsm ^= i
res = []
for i in AS:
    res.append("{}".format(xorsm ^ i))

print(" ".join(res))


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

using namespace std;

const int maxn = 70;
int n, a[maxn];

int main()
{
    cin >> n;

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

    bool b = 1;
    for (int i = 1; i < n; i++)
        if (a[i] - a[i - 1] != 1)
            b = 0;

    if (b)
        return cout << "YES", 0;

    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
        {
            swap(a[i], a[j]);

            b = 1;
            for (int t = 1; t < n; t++)
                if (a[t] - a[t - 1] != 1)
                    b = 0;

            if (b)
                return cout << "YES", 0;

            swap(a[i], a[j]);
        }

    cout << "NO";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

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

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

  vector<int> results;
  int min_count = 100;
  rep(i, 26) {
    int count = 0;
    results.resize(0);
    rep(j, s.size()) {
      if(s[j] - 'a' == i) {
        results.push_back(count);
        count = 0;
      } else {
        count++;
      }
    }
    results.push_back(count);
    sort(results.begin(), results.end(), greater<int>());
    min_count = min(min_count, results[0]);
  }
  cout << min_count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <chrono>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define fin cin
#define fout cout
#define int long long
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
#define all(x) x.begin(), x.end()
#define left vadia
#define lb lower_bound
#define right puta
using namespace std;
using namespace __gnu_pbds;
void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0); 
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}
typedef pair<ll, ll> pii;
typedef vector<vector<char>> mat;
typedef pair<int, string> pis;
const ll mod = 1e9+7;
const int MAXN = 2e5 + 5;
const int MAXV = 1e6+5;
typedef vector<int> vi;
typedef pair<int, pair<int, int>> piii;

int32_t main() {
	string s;
	cin >> s;
	if(s.back() == 's') {
		s += "es";
	}
	else s.pb('s');
	cout << s << endl;
}


Measured memory_bytes: 3600
#include<stdio.h>
int f(char s[]){
  int n=0,i,k=1;
  for(i=0;s[i];i++){
    if(s[i]=='m')n+=k*1000;
    if(s[i]=='c')n+=k*100;
    if(s[i]=='x')n+=k*10;
    if(s[i]=='i')n+=k*1;
    if('0'<=s[i]&&s[i]<='9')k=s[i]-'0';
    else k=1;
  }
  return n;
}
int main(){
  int i,n,a;
  char s1[10],s2[10];
  scanf("%d",&n);
  while(n--){
    scanf("%s %s",s1,s2);
    a=f(s1)+f(s2);
    if(a/1000>1)printf("%d",a/1000);
    if(a/1000)  printf("m");
    a%=1000;
    if(a/100>1)printf("%d",a/100);
    if(a/100)  printf("c");
    a%=100;
    if(a/10>1)printf("%d",a/10);
    if(a/10)  printf("x");
    a%=10;
    if(a>1)printf("%d",a);
    if(a)  printf("i");
    printf("\n");
  }
  return 0;
}
  

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define pli pair<int,int>
#define pint pair<int,int>
#define pid pair<int,double>
#define vi vector<int>
#define ff first
#define ss second
#define ll long long
#define ull unsigned long long
#define SIZE 200010
#define MOD 1000000007
#define BIG 999999937


int main()
{
	
	/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif*/
    
    int n;
    cin>>n;
    
    int h[n];
    for(int i=0;i<n;i++)
    {
    	cin>>h[i];
	}
	
	int dp[n];
	memset(dp,0,sizeof(dp));
	dp[n-1]=0;
	
	for(int i=n-2;i>=0;i--)
	{
		if(h[i+1]<=h[i])
		{
			dp[i]=dp[i+1]+1;
		}
		else
		{
			dp[i]=0;
		}
	}
	int ans=INT_MIN;
	for(int i=0;i<n;i++)
	{
		ans=max(ans,dp[i]);
	}
	
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}    //最大公約数
ll lcm(ll a, ll b) {return a * b / gcd(a, b);}   //最小公倍数

int main()
{
	ll a,b,c,d,e;
    cin>>a>>b>>c>>d;
    e=lcm(c,d);
    cout<<b-a+1-(b/c-(a-1)/c+b/d-(a-1)/d-b/e+(a-1)/e)<<endl;
 
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
queue<char>s1;
queue<char>s2;
char a1[10000],a2[10000];
int main()
{
	cin>>a1;cin>>a2;
	for(int i=0;i<strlen(a1);i++)
		s1.push(a1[i]);
	for(int i=0;i<strlen(a2);i++)
		s2.push(a2[i]);
	for(int i=0;i<strlen(a1);i++)
	{
		if(!s1.empty())
		{
			cout<<s1.front();
			s1.pop();
		}
		if(!s2.empty())
		{
			cout<<s2.front();
			s2.pop();
		}
	}
	cout<<endl;
}


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

int main()
{
   ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,sum=0,i,t=0,ch=0;
   cin>>n;
   ll a[n+5];
   for(i=0;i<n;i++){
       cin>>a[i];
       
   }
   sort(a,a+n);
   for(i=0;i<n;i++){
       if(a[i]==0){
           ch=1;
       }
       if(a[i]>0){
           
        sum+=a[i];           
           
       }if(a[i]<0){
           a[i]=a[i]*(-1);
           sum+=a[i];
           t++;
       }
   }
   sort(a,a+n);
   if(ch==1 || t%2==0){
       cout<<sum;
       return 0;
   }
   else{
      // cout<<sum<<" ";
       cout<<sum - 2*a[0];
   }
   
   
}


Measured memory_bytes: 1024
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

a, b, c = Is()
if a+b+c >= 22:
    print("bust")
else:
    print("win")

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


const ll MRINF = 5000000000000000;
int main() {

    string S;
    int K;
    cin >> S >> K;
    ll ans = 0;
    if(S.length() > K){
        if(S[K-1]=='1'){
            cout << 1 << endl;
            return 0;
        }
    }
    REP(i, S.length()){ 
        if(S[i]!='1'){
            cout << S[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;

    



}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>


using namespace std;
using ll = long long;


ll GCD(ll a, ll b)
{
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

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

int main()
{
    int n;
    cin >> n;

    ll ans = 1ll;

    for (int i = 0; i < n; ++i)
    {
        ll in;
        cin >> in;
        
        ans = LCM(ans, in);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import itertools

N, M , Q =  [int(i) for i in input().split()]

numbers = []
for i in range(Q):
    numbers.append([int(j) for j in input().split()])


A = list(itertools.combinations_with_replacement(range(1,M+1),N))

answer = 0
for k in  A:
    ans = 0
    for a, b, c, d in numbers:
        if int(k[b-1]) - int(k[a-1]) == c:
            ans += d
    if answer < ans:
        answer = ans
print(answer)


Measured memory_bytes: 21548
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

const ll MOD = 1000000007;

char prime[1000005];
void init_prime() {
    fill(prime, prime+1000005, 1);
    prime[0] = prime[1] = 0;
    for (int x = 2; x <= 1000000; ++x) {
        if (prime[x] && x <= 1000) {
            for (int y = x*x; y <= 1000000; y += x) prime[y] = 0;
        }
    }

}

ll N, Q[101010];

ll memo[101010];

int main() {
    init_prime();
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    for (int j = 1; j <= N; ++j) cin >> Q[j];
    reverse(Q+1, Q+N+1);

    fill(memo, memo+N+1, 0);
    memo[0] = 1;
    memo[1] = prime[Q[1]] ? 1 : 0;

    for (int j = 2; j <= N; ++j) {
        if (prime[Q[j]]) {
            if (Q[j-1] > Q[j]) {
                memo[j] = (memo[j] + memo[j-1]) % MOD;
            }

            if (Q[j-1] > 1 && (j < 3 || (prime[Q[j-2]] && Q[j-2] > Q[j]))) {
                memo[j] = (memo[j] + memo[j-2]) % MOD;
            }
        }
    }

    cout << memo[N] << endl;

    return 0;
}



Measured memory_bytes: 5720
X = int(input())

if X < 600:
    print(8)
elif X < 800:
    print(7)
elif X < 1000:
    print(6)
elif X < 1200:
    print(5)
elif X < 1400:
    print(4)
elif X < 1600:
    print(3)
elif X < 1800:
    print(2)
else:
    print(1)

Measured memory_bytes: 9116
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define ll long long
#define inf 0x3f3f3f3f
#define N 110
//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int l[N];
bool bingo(int i,int j,int k)
{
    if(l[i]!=l[j]&&l[i]!=l[k]&&l[k]!=l[j]&&l[i]+l[j]>l[k]&&l[i]+l[k]>l[j]&&l[k]+l[j]>l[i])
        return true;
    else return false;
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",l+i);
    }
    int ans=0;
    for(int i=1;i<=n-2;i++)
        for(int j=i+1;j<=n-1;j++)
            for(int k=j+1;k<=n;k++)
            {
                if(bingo(i,j,k))
                    ans++;
            }
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3820
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main(void)
{
	char s[100003];
	scanf("%s\n", s);
	for(int i = 0; s[i] != '\0'; ++i)
		if((i + 1) % 2 != 0)
			printf("%c", s[i]);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args)
			throws IOException {
		BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in));
		String s = br.readLine();
		char[] array = new char[s.length()];

		int i = 0;
		while (i < s.length()) {
			array[i] = s.charAt(i);
			++i;
		}

		while (--i >= 0) {
			System.out.print(array[i]);
		}

		System.out.println("");
	}
}

Measured memory_bytes: 24160
//
// Created by Tetsuya Shiota on 2019-04-13.
//

#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
#define FOR(e, o) for (auto &&e : o)
#ifdef LOCAL
#define pp(x) cerr << __LINE__ << ' ' << #x << " = " << (x) << endl
#define dump(x)                                                                \
  cerr << __LINE__ << ' ' << #x << " : ";                                      \
  FOR(e, x) cerr << e << ' ';                                                  \
  cerr << endl;
#else
#define pp(x)
#define dump(x)
#endif

using namespace std;

using Int = long long;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int, Int>;

template <typename T> void reverse(vector<T> &v) {
  reverse(v.begin(), v.end());
}
template <typename T> void sort(vector<T> &v) { sort(v.begin(), v.end()); }
template <typename T> void rsort(vector<T> &v) { sort(v.rbegin(), v.rend()); }
template <typename T> T sum(const vector<T> &v) {
  return accumulate(v.begin(), v.end(), T(0));
}
template <class T> void update_max(T &a, const T &b) { a = max(a, b); }
template <class T> void update_min(T &a, const T &b) { a = min(a, b); }
vector<pair<char, Int>> merge_cont_char(const string &s) {
  vector<pair<char, Int>> ret;
  if (s.empty())
    return ret;
  ret.push_back(make_pair(s[0], 0));
  FOR(c, s) {
    if (ret.back().first == c)
      ret.back().second++;
    else
      ret.push_back(make_pair(c, 1));
  }
  return ret;
}

class Shakutori {
public:
  // 全体の範囲
  // [0, end)
  // 注目している範囲
  // [tail, head)
  Int head, tail, end = 0;
  bool moveHead() {
    if (head == end) {
      return false;
    }
    head++;
    return true;
  }
  void moveTail() { tail++; }
  bool valid() {
    if (head == tail)
      return true;
    // [tail, head)
    // が解として適当か検証する
    return true;
  }
  void solve() {
    head = tail = 0;
    Int ans = 0;
    while (moveHead()) {
      while (!valid()) {
        moveTail();
      }
      // ここで解を更新する
    }
  }
};

class Solver {
public:
  Int N, K, ans;
  Solver() {}
  void input() {
    cin >> N >> K;
  }
  void solve() {
    N-=K;
    ans = N;
    if(K == 1)ans = 0;
  }
  void output() {
    cout << ans <<endl;
  }
};

void initilization() {
  struct BoolName : numpunct<char> {
    string t, f;
    BoolName(string t = "Yes", string f = "No") : t(t), f(f) {}
    string do_truename() const { return t; }
    string do_falsename() const { return f; }
  };
  cin.tie(nullptr);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(15) << boolalpha;
  cout.imbue(locale(cout.getloc(), new BoolName));
}

int main() {
  initilization();
#ifdef LOCAL
  while (1) {
    Solver s;
    s.input();
    if (cin.eof())
      break;
    s.solve();
    s.output();
  }
#else
  Solver s;
  s.input();
  s.solve();
  s.output();
#endif
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void) {
    int N;
    int ans = 0;

    cin >> N;

    if (N >= 105) ans++;
    if (N >= 165) ans++;
    if (N >= 195) ans++;

    if (N >= 135) ans++;
    if (N >= 189) ans++;

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const ll inf=1e18;
ll n,ans=inf,a[5],b[15],v[15];
int main()
{
	for(int i=1;i<=10;i++) b[i]=inf;
	b[0]=0,v[1]=1,v[2]=2,v[3]=4,v[4]=8;
	scanf("%lld%lld%lld%lld%lld",&a[1],&a[2],&a[3],&a[4],&n),n*=4;
	for(int i=1;i<=4;i++)
		for(int j=v[i];j<=10;j++)
			b[j]=min(b[j],b[j-v[i]]+a[i]);
	for(ll i=1;i<=10&&i<=n;i++) ans=min(ans,n/i*b[i]+b[n%i]);
	printf("%lld\n",ans);
	return 0;
}

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

int N, K;
int main(void){
    // Your code here!
    cin >> N;
    char S[N];
    cin >> S;
    cin >> K;
    
    char tmp = S[K-1];
    
    for(int i = 0; i < N; i++){
        if(tmp==S[i]){
            cout << S[i];
        } else{
            cout << "*";
        }
    }
    
    cout << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n+2,0);
    ll sum=0;
    for(ll i=1;i<=n;i++){
        cin>>a[i];
        sum+=abs(a[i]-a[i-1]);
    }
    sum+=abs(a[n]);

    vector<ll> ans(0);
    for(ll i=1;i<=n;i++){
        ll sub=sum;
        if(a[i-1]<a[i] && a[i+1]<a[i]){
            sub-=2*(a[i]-max(a[i+1],a[i-1]));
        }
        if(a[i]<a[i-1] && a[i]<a[i+1]){
            sub-=2*(min(a[i-1],a[i+1])-a[i]);
        }
        ans.push_back(sub);
    }
    for(ll i=0;i<n;i++){
        cout<<ans[i]<<endl;
    }

}

Measured memory_bytes: 2932
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <functional>
#include <stack>
#include <cstring>
#include <cstdio>
#include <string>
#include <random>
#include <chrono>

using namespace std;

using ll = long long;
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
}


const int N = 1e3 + 3;
int a[N];
int n;

int get_total(int p) {
	int ret = 0;
	for (int i = 0; i < n; i++)
		ret += (a[i] - p) * (a[i] - p);
	return ret;
}
int main() {
	//file();
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	int ans = 1e9;
	for (int i = 1; i <= 100; i++) {
		ans = min(ans, get_total(i));
	}
	printf("%d\n", ans);

	return 0;
}

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

int h[222222];
int main() {
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> h[i];
    sort(h, h + n);
    long r = 0;
    for(int i = 0; i < n - k; i++)
        r += h[i];
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,a,b;
  cin >> n >> a >> b;
  if(n==1&&a!=b){
  	cout << 0 << endl;
  	return 0;
  }
  if(a>b){
  	cout << 0 << endl;
  	return 0;
  }
  cout << (n-2)*(b-a)+1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>

using namespace std;

typedef long long int Int;

Int MARCH[100000];

int main(void) {
    int N;
    cin>>N;
    
    for(int i = 0;i < N;i++) {
        string s;
        cin>>s;
        
        if(s[0] == 'M')
            MARCH[0]++;
        else if(s[0] == 'A')
            MARCH[1]++;
        else if(s[0] == 'R')
            MARCH[2]++;
        else if(s[0] == 'C')
            MARCH[3]++;
        else if(s[0] == 'H')
            MARCH[4]++;
    }

    Int sum = 0;
    for(int i = 0;i < 3;i++) {
        for(int j = i+1;j < 4;j++) {
            for(int k = j+1;k < 5;k++) {
                sum += MARCH[i]*MARCH[j]*MARCH[k];
            }
        }
    }

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n;
    cin>>n;
    cout<<pow(n,3)<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
  
int binomialCoeff(int n, int k) 
{ 
    int C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (int i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (int j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 
int main()
{
	fast
	int N,M;
	cin>>N>>M;
	cout<<(binomialCoeff(N,2)+binomialCoeff(M,2))<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>
#define vi vector<int>
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
#define ios cin.tie(0); ios::sync_with_stdio(false)
#define FIX(a) cout << fixed << setprecision(a)
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//manip
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power_mod(T a, T b) {return b ? power_mod(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
template<class T> T power(T a, T b) {return b ? power(a * a, b / 2) * (b % 2 ? a : 1) : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!
#define outa(a, n) rep(i, n) cout << a[i] << " "; cout << endl
#define outaa(a, m, n) rep(i, m) {rep(j, n) cout << a[i][j] << " "; cout << endl;} cout << endl
#define out(a) cout << a << endl
#define outv(v) rep(i, SZ(v)) cout << v[i] << " "; cout << endl

//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms
//cast caution
//look constraints always
//product of minimum 9 prime numbers is above 1e9


int main() {
    
    int n; cin >> n;
    int a[n][3];
    rep(i, n) cin >> a[i][0] >>a[i][1] >> a[i][2];
    
    int dp[n + 1][3]; fill_n(*dp, (n + 1) * 3, 0);
    dp[1][0] = a[0][0]; dp[1][1] = a[1][0]; dp[1][2] = a[2][0];
    
    rep(i, n) {
        rep(j, 3) {
            dp[i + 1][j] = max(dp[i][(j + 1) % 3] + a[i][(j + 1) % 3], dp[i][(j + 2) % 3] + a[i][(j + 2) % 3]);
        }
    }
    
    out(max({dp[n][0], dp[n][1], dp[n][2]}));
    
}


Measured memory_bytes: 2560
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>
#include <queue>
#include <string.h>

int main(int argc, char *argv[])
{
	int n;
	string s;

	cin>>n>>s;

	ll c[3]={0,0,0};
	int id[26];
	id['R'-'A']=0;
	id['G'-'A']=1;
	id['B'-'A']=2;

	for (int i=0;i<n;i++)
	{
		c[id[s[i]-'A']]++;
	}
	ll ret=c[0]*c[1]*c[2];
	for (int d=1;2*d*+1<=n;d++)
	{
		for (int j=d;j<n-d;j++)
		{
			if (s[j]!=s[j-d] && s[j]!=s[j+d] && s[j-d]!=s[j+d]) ret--;
		}
	}

	cout<<ret<<endl;


	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;

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

int main() {
  ll  a[3],m[3];
  while(cin >>a[0]>>m[0]>>a[1]>>m[1]>>a[2]>>m[2],a[0]!=0) {
    ll ans[3] = {0};
    REP(k,3) {
      ll x=1;
      do {
        x = a[k]*x % m[k];
//      printf("[%d,%d,%d]\n",x,y,z);
        ans[k]++;
      } while(x!=1);
    }

    ll hoge = ans[0]*ans[1]/gcd(ans[0],ans[1]);

    cout << hoge*ans[2]/gcd(hoge,ans[2]) << endl;
  }
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
  
bool isPrime(int n) 
{ 
    // Corner case 
    if (n <= 1) 
        return false; 
  
    // Check from 2 to n-1 
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return false; 
  
    return true; 
} 
 
int main()
{
 long long X,i;
  bool b;
  b=false;
  cin>>X;
  for(i=X;true;i++)
  {
   b=isPrime(i);
    if(b==true)
      break;
  }
  cout<<i;
 return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    rep(i, S.length()) {
        if(S[i] != T[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
template<class T> inline void read(T &x){
	x=0; register char c=getchar(); register bool f=0;
	while(!isdigit(c))f^=c=='-',c=getchar();
	while(isdigit(c))x=x*10+c-'0',c=getchar(); if(f)x=-x;
}
template<class T> inline void print(T x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)print(x/10); putchar(x%10+'0');
}
template<class T> inline void print(T x,char c){print(x),putchar(c);}
const int N=2e3+10,E=4e6+10,M=1e7+10;
bool vis[M],b[M];
int n,s,e,max,cnt,ans,flow,cnt0,cnt1,tot=2;
int pre[N],cur[N],hed[N],dep[N],gap[N],a[N],pri[M/10],val[E],nxt[E],to[E];
int query(int x){
	if(x==2||x==4)return 2;
	if(!vis[x])return 1;
	if(x&1)return 3;
	return 2;
}
void init(int n){
	vis[1]=1;
	for(int i=2;i<=n;i++){
		if(!vis[i]){pri[++cnt]=i;}
		for(int j=1;j<=cnt&&i*pri[j]<=n;j++){
			vis[i*pri[j]]=1;
			if(i%pri[j]==0)break;
		}
	}
}
void add_edge(int u,int v){
	nxt[tot]=hed[u],to[tot]=v,val[tot]=1,hed[u]=tot++;
	nxt[tot]=hed[v],to[tot]=u,val[tot]=0,hed[v]=tot++;
}
int isap(){
	int u=s,res=0;gap[0]=e;
	while(dep[s]<e){
		bool flag=1;
		for(int&i=cur[u];i;i=nxt[i]){
			if(val[i]&&dep[to[i]]+1==dep[u]){pre[to[i]]=i,u=to[i];flag=0;break;}
		}
		if(flag){
			if(!--gap[dep[u]])break;
			dep[u]=e;
			for(int i=hed[u];i;i=nxt[i]){
				if(val[i]&&dep[to[i]]+1<dep[u])dep[u]=dep[to[i]]+1,cur[u]=i;
			}
			++gap[dep[u]];
			if(u!=s)u=to[pre[u]^1];
		}
		if(u==e){
			for(int i=pre[e];i;i=pre[to[i^1]])val[i]--,val[i^1]++;
			u=s,res++;
		}
	}
	return res;
}
int main(){
	// freopen("oatmeal.in","r",stdin);
	// freopen("oatmeal.out","w",stdout);
	read(n),init(1e7);
	for(int i=1;i<=n;i++)read(a[i]),max=std::max(max,a[i]+2);
	for(int i=1;i<=n;i++)b[a[i]]=1; n=0;
	for(int i=max;i;i--)b[i]^=b[i-1];
	for(int i=1;i<=max;i++)if(b[i])a[++n]=i;
	s=n+1,e=n+2;
	for(int i=1;i<=n;i++)(a[i]&1)?(++cnt1,add_edge(s,i)):(++cnt0,add_edge(i,e));
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(query(a[j]-a[i])==1){
				(a[i]&1)?add_edge(i,j):add_edge(j,i);
				// printf("> %d %d\n",i,j);
			}
	// for(int i=1;i<=n;i++)print(a[i]," \n"[i==n]);
	ans=flow=isap(),cnt0-=flow,cnt1-=flow; if(cnt1&1)ans+=3; ans+=((cnt0>>1)+(cnt1>>1))<<1;
	// printf("flow=%d cnt0=%d cnt1=%d\n",flow,cnt0,cnt1);
	printf("%d\n",ans);
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)  cin >> a[i];
    ll s = 0;
    rep(i, n) s ^= a[i];
    ll ans = s;
    rep(i,n) a[i] &= ~s;

    int r=0;
    vector<int> top(n);
    for(int i=60; i >= 0; --i){
        int j=r;
        for(;j < n; ++j){
            if (a[j]>>i & 1){
                swap(a[r], a[j]);
                break;
            }
        }
        if(j==n) continue;
        top[r] = i;
        rep(k,n){
            if(r == k) continue;
            if(a[k]>>i & 1) a[k] ^= a[r];
        }
        ++r;
    }
    ll x=0;
    for(int i=60; i >= 0; --i){
        ll nx = x|(1ll << i);
        {
            ll b=nx;
            rep(j, r){
            if (b>>top[j] & 1)  b ^= a[j];
            }
            if((b&nx) == 0){
                x = nx;
            }
        }    
    }
    ans += 2*x;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Ti = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct edge {
  int to, cap, rev;
  edge(){}
  edge(int to, int cap, int rev):to(to), cap(cap), rev(rev){}
};

using Graph = vector<vector<edge>>;

struct Dinic {
  Graph graph;
  vint level, iter;
  Dinic(int V):graph(V), level(V), iter(V){}
  void add_edge(int from, int to, int cap) {
    graph[from].emplace_back(to, cap, graph[to].size());
    graph[to].emplace_back(from, 0, graph[from].size()-1);
  }
  bool bfs(int s, int t) {
    fill(all(level), -1);
    level[s] = 0;
    queue<int> que({s});
    while(!que.empty()) {
      int v = que.front(); que.pop();
      rep(i, graph[v].size()) {
	edge& e = graph[v][i];
	if(e.cap > 0 && level[e.to] < 0) {
	  que.push(e.to);
	  level[e.to] = level[v]+1;
	}
      }
    }
    return ~level[t];
  }
  int dfs(int v, int t, int f) {
    if(v == t) return f;
    for(int& i = iter[v]; i < (int)graph[v].size(); i++) {
      edge& e = graph[v][i];
      if(e.cap > 0 && level[e.to] > level[v]) {
	int d = dfs(e.to, t, min(f, e.cap));
	if(d > 0) {
	  e.cap -= d;
	  graph[e.to][e.rev].cap += d;
	  return d;
	}
      }
    }
    return 0;
  }
  int max_flow(int s, int t) {
    if(s == t) return inf;
    int flow = 0;
    while(bfs(s, t)) {
      fill(all(iter), 0);
      int f; while((f=dfs(s, t, inf)) > 0) flow += f;
    }
    return flow;
  }
};

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, m;
  cin >> n >> m;
  vector<Pi> vec;
  rep(i, m) {
    int a, b;
    cin >> a >> b; --a, --b;
    vec.emplace_back(a, b);
  }
  int s = 0, t = 2*n, V = t+1;
  rep(i, m) {
    Dinic graph(V);
    rep(j, n) graph.add_edge(j, n+j, 1 + (j == 0));
    rep(j, i) {
      int a, b; tie(a, b) = vec[j];
      graph.add_edge(n+a, b, 1);
      graph.add_edge(n+b, a, 1);
    }
    int a, b; tie(a, b) = vec[i];
    graph.add_edge(n+a, t, 1);
    graph.add_edge(n+b, t, 1);
    int flow = graph.max_flow(s, t);
    cout << (flow == 2 ? "Yes" : "No") << endl;
  }

  return 0;
}

Measured memory_bytes: 3776
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        a: [usize;n],
    }

    let inf = 10_0000 + 5;
    let mut b: Vec<usize> = vec![0;inf];
    for i in 0..n {
        b[a[i]] += 1;
    }

    let mut cnt = 0;
    let mut cnt1 = 0;
    for i in 1..inf {
        if b[i]!=0 {
            cnt += 1;
            cnt1 += b[i] - 1;
        }
    }

    if cnt1%2==0 {
        println!("{}", cnt);
    } else {
        println!("{}", cnt-1);
    }

}


Measured memory_bytes: 4064