akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

void print_vec(vector<int> vec) {
  cout << "[";
  for (int i = 0; i < vec.size(); i++) {
    if (i) {
      cout << ", ";
    }
    cout << vec.at(i);
  }
  cout << "]...size: " << vec.size() << endl;
}

int main() {
  int r, c;
  cin >> r >> c;

  vector<vector<int>> vec(r + 1, vector<int>(c + 1, 0));

  rep(i, r) {
    rep(j, c) {
      int num;
      cin >> num;
      vec.at(i).at(j) = num;
      vec.at(i).at(c) += num;
      vec.at(r).at(j) += num;
      vec.at(r).at(c) += num;
    }
  }

  rep(i, r + 1) {
    rep(j, c + 1) {
      if (j) {
        printf(" ");
      }
      printf("%d", vec.at(i).at(j));
    }
    printf("\n");
  }
}



Measured memory_bytes: 3268
x, n = map(int, input().split())
if (n == 0):
    print(x)
    exit()
p = list(map(int, input().split()))
pp = list(set(sorted([i - x for i in p if i-x > 0])))
pm = list(set(sorted([abs(i - x) for i in p if i - x < 0])))
pp.append(9999)
pm.append(9999)
if ([1 for i in p if i == x]):
    pass
else:
    print(x)
    exit()
a = 1
i = 0
while 1:
    if (pm[i] != a):
        print(x - a)
        exit()
    if(pp[i] != a):
        print(x + a)
        exit()
    a += 1
    i += 1


Measured memory_bytes: 9024
# pythonでスタック、キューを実現するためにdequeをimport
from collections import deque

N, M = map(int, input().split())

# 辺集合EとグラフGの構築
G = [[] for _ in range(N)]
E = []
for _ in range(M):
    a, b = map(int, input().split())
    # 入力は1-indexedだがこれを扱いやすいように0-indexedに変更
    a -= 1
    b -= 1
    E.append((a, b))
    G[a].append(b)
    G[b].append(a)
# print(G)

# 橋を数えるための変数cntを用意
cnt = 0
for edge_to_remove in E:
    # 橋であるか判定したい辺を取り除いてみる
    i, j = edge_to_remove
    G[i].remove(j)
    G[j].remove(i)

    # 深さ優先探索
    seen = [False] * N
    todo = deque()
    # 適当な頂点から深さ優先探索をスタート（ここでは頂点0をスタートに選んだ）
    todo.append(0)
    seen[0] = True
    while todo:
        here = todo.pop()
        for neighbor in G[here]:
            if seen[neighbor] == False:
                seen[neighbor] = True
                todo.append(neighbor)
    # print(seen)
    # もし訪問できていない頂点があれば連結でないというなので今着目している辺は橋であった！
    if False in seen:
        cnt += 1

    # 次の辺について調べるために今取り除いた辺を再びGに戻しておく
    G[i].append(j)
    G[j].append(i)
print(cnt)


Measured memory_bytes: 3316
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        pp: [u64;n]
    }
    let mut pp = pp;
    pp.sort();
    pp.reverse();
    let res = pp[0] / 2 + pp.iter().skip(1).sum::<u64>();
    println!("{}", res);
}


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

int main() {
    int N;
    string S;
    cin >> N >> S;
    bool a =true;
    if(N%2==0){
        for(int i=0;i<N/2;i++){
            if(S.at(i)!=S.at(i+N/2)){
                a=false;
                break;
            }
        }
    }
    else a=false;
    if(a==true)cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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

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

    string N;
    cin >> N;

    if(N.length() == 1) {
        cout << N << endl;
        return 0;
    }
    ll rsl = 0;
    int idx = N.length() - 1, idx2 = 0, idx3 = 0;
    bool flag = false, flag2 = false;
    while(idx >= 0) {
        if(flag and N[idx] != '9') {
            flag2 = true;
            idx3 = idx;
        }
        if(not flag and N[idx] != '9') {
            idx2 = idx;
            flag = true;
        }
        idx--;
    }

    if(flag and (not flag2) and idx2 - 1 >= 0) rsl += N[idx2 - 1] - '0' - 1 + 9 * (N.length() - 1);
    else if(flag2) rsl += N[idx3] - '0' - 1 + 9 * (N.length() - 1);
    else {
        rep(i, 0, N.length()) rsl += N[i] - '0';
    }
    cout << rsl << endl;


}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    public static void Main()
    {
        var s = Console.ReadLine().Split(' ');
        int A = int.Parse(s[0]);
        int B = int.Parse(s[1]);
        int C = int.Parse(s[2]);
        int ctr = 0;
        int i = Math.Min(B, C);
        ctr += 2 * i;
        B -= i;
        C -= i;
        i = Math.Min(A, C);
        ctr += i;
        A -= i;
        C -= i;
        ctr += B;
        if (C > 0)
            ctr++;
        Console.WriteLine(ctr);
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1e9+7;
const int INF=1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin>>n;
    map<string,int> mp;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        mp[s]++;
    }
    int mx=0;
    for(auto e:mp){
        mx=max(mx,e.second);
    }
    for(auto e:mp){
        if(mx==e.second){
            cout<<e.first<<endl;
        }
    }
}


Measured memory_bytes: 27264
// In the name of Allah. Ya ali!
#include<bits/stdc++.h>
#define double long double
#define debug(x)//  cerr << #x << " = " << x << endl
typedef long long ll;
const ll MAX_N = 2e5+100;
const ll MOD = 1e9+7;
using namespace std;

ll dp[MAX_N];
ll sum[MAX_N];
int n,m;

int main()
{
    cin >> n >> m;
    string s;
    cin >> s;
    if (s[0]=='B')
    {
        for(int i = 0;i<m;++i)
        {
            if (s[i]=='B')
                s[i] = 'R';
            else
                s[i] = 'B';
        }
    }
    bool ok = false;
    for(int i = 0;i<m;++i)
        ok |= (s[i]=='B');
    if (!ok)
    {
        dp[1] = 1;
        dp[3] = 1;
        sum[1] = 1;
        sum[2] = 1;
        sum[3] = 2;
        for(int i = 4;i<=n+1;++i)
        {
            dp[i] = sum[i-2];
            sum[i] = (sum[i-1]+dp[i])%MOD;
        }
        ll ans = dp[n+1]+1;
        for(ll i = 1;i<n;++i)
        {
            ans += (i*dp[n-i])%MOD;
            ans %= MOD;
        }
        cout << ans;
        return 0;
    }
    for(int i = m-1;i>=0;--i)
    {
        if (s[i]=='B')
        {
            m = i+1;
            break;
        }
    }
    vector<int> vc;
    int cnt = 0;
    for(int i = 0;i<m;++i)
    {
        if (s[i]=='B')
        {
            if (cnt)
                vc.push_back(cnt);
            cnt = 0;
        }
        else
            cnt++;
    }
    int mn = 1e9;
    if (vc[0]%2==0)
        mn = vc[0]+1;
    for(auto x:vc)
    {
        if (x&1)
            mn = min(mn,x);
    }
    int lim = mn;
    dp[1] = 1;
    dp[3] = 1;
    for(int i = 5;i<=n;i+=2)
    {
        dp[i] = (dp[i-2]*2ll)%MOD;
        if (i>=lim+3)
            dp[i] = (dp[i]-dp[i-lim-3]+MOD+MOD)%MOD;
    }
    ll ans = 0;
    for(ll i = 1;i<=min(n-1,lim);i+=2)
    {
        ans += ((i+1ll)*dp[n-i])%MOD;
        ans %= MOD;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    vector<int>t(n);
    cin >> n;
    for(int i = 0; i < n ;i++){
        cin >> t[i];
    }
    cin >> m;
    vector<pair<int , int>> p(m);
    for(int i = 0;i < m;i++){
        cin >> p[i].first >> p[i].second;
    }
    int cnt = 0;
    for(int i = 0;i < m;i++){
        int cnt = 0;
        for(int j = 0; j < n;j++){
            if(p[i].first == j + 1){
                cnt += p[i].second;
            }else{
                cnt += t[j];
            }
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 16640
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		
		// 入出力高速化 java.io.* とthrows IOExceptionを忘れずに
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int K, T;
		String[] KT = br.readLine().split(" ");
		K = Integer.parseInt(KT[0]);
		T = Integer.parseInt(KT[1]);

		int[] a = new int[T];
		String[] A = br.readLine().split(" ");
		for(int i=0; i<T; i++) {
			a[i] = Integer.parseInt(A[i]);
		}
		
		PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
		for(int i=0; i<T; i++) {
			pq.add(-a[i]);
		}
		
		int prev = 0, pprev = 0;
		while(pq.size() != 0) {
			int now = pq.peek();
			pq.poll();
			pprev = prev;
			prev = now + 1;
			if (pprev != 0) pq.add(pprev);
		}
		
		System.out.println(-prev);
	}
}


Measured memory_bytes: 32868
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define rrep(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end());
#define ll long long 
#define vi vector<int>
#define vvi vector<vector<int> >

using namespace std;

void p(int x) {
	cout << x << endl;
}

void pp(string s) {
	cout << s << endl;
}

int main() {
	int n, m;
	cin >> n >> m;
	vi v(m);
	int maxx=0, maxnum;
	rep(i, 0, m) {
		cin >> v[i];
		if (maxx < v[i]) {
			maxx= v[i];
			maxnum = i;
		}
	}

	int sum = 0;
	rep(i, 0, m) {
		if (i != maxnum)  sum += v[i];
	}

	int ans = maxx - sum - 1;
	if (ans >= 0) cout << ans << endl;
	else cout << 0 << endl;


	return 0;
}


Measured memory_bytes: 256
//HovalHaq!
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
const int maxN = 32;

int n, m, r, A[maxN][maxN],
	 Dx[4] = {+1, 0, -1, 0},
	 Dy[4] = {0, +1, 0, -1};

void clear() {
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++) 
			if(A[i][j] >= 1) {
				r = max(r, A[i][j] - 2);
				A[i][j] = 1;
			}
	
}

int main() {
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++) {
			char x; cin >> x;
			if(x == '#') A[i][j] = -2;
			else A[i][j] = 1;
		}
	for(int x = 1; x <= n; x++)
		for(int y = 1; y <= m; y++) 
			if(A[x][y] == 1) {
				queue<PII> Q;
				A[x][y] = 2;
				Q.push({x, y});
				while(Q.size()) {
					PII v = Q.front();
					Q.pop();
//					cout << x << " " << y << ": " << v.first << " " << v.second << endl;
					for(int i = 0; i < 4; i++)
						if(A[v.first + Dx[i]][v.second + Dy[i]] == 1) {
							A[v.first + Dx[i]][v.second + Dy[i]] = A[v.first][v.second] + 1;
							Q.push({v.first + Dx[i], v.second + Dy[i]});
						}
				}
				clear();
			}
	cout << r;
}


Measured memory_bytes: 256
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

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

int main(int argc, char* argv[]) {
    int N, D;
    cin >> N >> D;
    vector<vector<int>> xs;
    for (int i = 0; i < N; i++) {
        xs.push_back(vector<int>());
        for (int j = 0; j < D; j++) {
            int x;
            cin >> x;
            xs[i].push_back(x);
        }
    }
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            vector<int> v1 = xs[i];
            vector<int> v2 = xs[j];
            int sq_dist = 0;
            for (int d = 0; d < D; d++) {
                sq_dist += (v1[d] - v2[d]) * (v1[d] - v2[d]);
            }
            int dist = (int)roundf(sqrt(sq_dist));
            if (sq_dist == dist * dist) {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}



Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;


int main() {
    int h, w;
    cin >> h >> w;
    vector<string> red(h, string(w, '.')), blue(h, string(w, '.'));
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            char c; cin >> c;
            if (c == '#')
                red[i][j] = blue[i][j] = '#';
            else if ((j < w-1 && i % 2 == 0) || j == 0)
                red[i][j] = '#';
            else 
                blue[i][j] = '#';
        }
    }
    for (auto r:red) cout << r << endl;
    for (auto b:blue) cout << b << endl;
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
//A
int main(){
    int n;
    scanf("%d",&n);
    int x=n/100,y=n/10%10,z=n%10;
    if(x==7||y==7||z==7) printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
int main(void) {
    int a, b; cin >> a >> b;
    if(a%3==0||b%3==0||(a+b)%3==0) cout << "Possible";
    else cout << "Impossible";
}


Measured memory_bytes: 256
# D - Equals

from collections import deque

N, M = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(M)]

neighbor = [[] for _ in range(N)]
for idx in range(M):
    neighbor[xy[idx][0]-1].append(xy[idx][1]-1)
    neighbor[xy[idx][1]-1].append(xy[idx][0]-1)
    
can_swap = []
visited = [-1]*N

for start in range(N):
    if visited[start] == -1:
        tmp = [start] # startから到達可能なpointのリスト
        d = deque([start])
        while d:
            current_point = d.pop()
            visited[current_point] = 1
            for next_point in neighbor[current_point]:
                if visited[next_point] == -1:
                    d.append(next_point)
                    tmp.append(next_point)
        can_swap.append(tmp)                

ans = 0
for idx_group in can_swap:
    tmp_p = [p[idx]-1 for idx in idx_group]
    ans += len(set(tmp_p) & set(idx_group))

print(ans)

Measured memory_bytes: 110060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(),(v).end())
#define RSORT(v) sort((v).rbegin(),(v).rend())
const ll MOD = 1000000007;

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}



void solve(long long N, std::vector<long long> a){
    SORT(a);
    cout << a[N-1] - a[0] << endl;
}

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


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

using namespace std;

int minus_rotate(int minus_n, int v) {
	if (v == 1)return 1;
	if (v == 0) {
		if (minus_n % 2 == 0)return 0;
		else return 2;
	}
	if (v == 2) {
		if (minus_n % 2 == 0)return 2;
		else return 0;
	}
}

int kakeru(int a, int b) {
	int list[3][3] = { {0,0,0},{0,1,1},{0,1,2} };
	return list[a][b];
}

int tasu(int a, int b) {
	int list[3][3] = { {0,1,2},{1,1,2},{2,2,2} };
	return list[a][b];
}

int parser(vector<int> vlist) {
	int minus_continue = 0;
	int step = 0;
	int A, B;
	int calc_kind = 0;
	for (int i = 0; i < vlist.size(); i++) {
		int now = vlist[i];
		if(step == 0){
			if (now == 100 && !minus_continue) {
				minus_continue = 1;
			}
			else if (minus_continue && now == 100) {
				minus_continue++;
			}
			else {
				A = minus_rotate(minus_continue, now);
				minus_continue = 0;
				step = 1;
			}
		}
		else if (step == 1) {
			if (now == -1) {
				calc_kind = 1;
			}
			if (now == -2) {
				calc_kind = 2;
			}
			step = 2;
		}
		else if (step == 2) {
			if (now == 100 && !minus_continue) {
				minus_continue = 1;
			}
			else if (minus_continue && now == 100) {
				minus_continue++;
			}
			else {
				B = minus_rotate(minus_continue, now);
				minus_continue = 0;
				//�v�Z�p�[�g�A�v�Z����A�Ɋi�[�����B
				if (calc_kind == 1) {
					A = kakeru(A, B);
				}
				if (calc_kind == 2) {
					A = tasu(A, B);
				}

				step = 1;
			}
		}
	}
	return A;
}

int calc(int a, int b, int c, string formula) {
	int ret = 0;
	bool isrem = false;//()�̒��g���L�����Ă邩
	string next;
	int nest = 0;
	vector<int> value;
	for (int i = 0; i < formula.size(); i++) {
		char now = formula[i];
		if (now == '(') {
			nest++; 
			if(nest == 1)isrem = true;
			else next += now;
		}
		else if (now == ')') {
			nest--;
			if (nest == 0) {
				isrem = false;
				value.push_back(calc(a, b, c, next));
				next.clear();
			}
			else next += now;
		}
		else if (isrem) {
			next += now;
		}
		else {
			if (now == '*')value.push_back(-1);
			if (now == '+')value.push_back(-2);
			if (now == '-') {
				value.push_back(100);
			}
			if (now == '0')value.push_back(0);
			if (now == '1')value.push_back(1);
			if (now == '2')value.push_back(2);
			if (now == 'P')value.push_back(a);
			if (now == 'Q')value.push_back(b);
			if (now == 'R')value.push_back(c);
		}
	}

	return parser(value);
}

int main() {
	string S;

	while (cin >> S, S != ".") {

		int cnt = 0;
		
		for (int a = 0; a < 3; a++) {
			for (int b = 0; b < 3; b++) {
				for (int c = 0; c < 3; c++) {
					if (calc(a, b, c, S) == 2) {
						cnt++;
					}
				}
			}
		}
		cout << cnt << endl;
		
	}
	
	return 0;
}


Measured memory_bytes: 3136
def main():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    ls = [0]
    t = 0
    for i in a:
        t += i
        ls.append(t)
    import collections
    ls = collections.Counter(ls).most_common()
    cnt = 0
    for k, v in ls:
        cnt += (v * (v - 1) // 2)
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 110160
#include <stdio.h>
int fmax(int a,int b)
{
	if(a>b)
	{
		return a;
	}else {
		return b;
	}
}
int main()
{
	int num1,num2;
	int add,red,mul;
	int  max;
	scanf("%d %d",&num1,&num2);
	mul=num1*num2;
	add=num1+num2;
	red=num1-num2;
	max=fmax(add,fmax(red,mul));
	printf("%d\n",max);
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
  int N;
  float T,A;
  scanf("%d%f%f",&N,&T,&A);
  float H[N];
  int i;
  for(i=0;i<N;i++) scanf("%f",&H[i]);
  int answer_index=0;
  float answer_temperature=fabsf(A-(T-H[0]*0.006));

  for(i=1;i<N;i++){
    if(fabsf(A-(T-H[i]*0.006))<answer_temperature){
      answer_index=i;
      answer_temperature=fabsf(A-(T-H[i]*0.006));
    }
  }
  printf("%d\n",answer_index+1);
  return 0;
}


Measured memory_bytes: 128
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>
#include <map>   
#include <stdio.h>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ull unsigned long long
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

int main() {
	int N, K, i, n, m;
	string S;
	cin >> N >> S;
	vector<int> A(200000), B(200000);
	if (S[0] == '#')
		B[0] = 1;
	else
		A[0] = 1;
	for (int i = 1; i < N; i++) {
		if (S[i] == '.') {
			A[i] = A[i - 1] + 1;
			B[i] = B[i - 1];
		}
		else {
			A[i] = A[i - 1];
			B[i] = B[i - 1] + 1;
		}
	}
	int MIN = A[N - 1];
	for (i = 0; i < N ; i++) {
		MIN = min(MIN, (A[N - 1] - A[i]) + (B[i]));
	}
	cout << MIN << endl;
	return 0;
}



Measured memory_bytes: 2180
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<set>
#include<stack>
#include<sstream>
#include<fstream>
#include<string>
#include<assert.h>
//#include<Eigen/Dense>
//using namespace Eigen;
using namespace std;

typedef long long ll;

ll a[105];
int main()
{
	ll n;
	while (cin >> n) {
		for (int i = 0; i < n; i++)
			cin >> a[i];
		 
		int ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				for (int k = j + 1; k < n; k++) {
					if (a[i] != a[j] && a[j] != a[k] && a[i]!=a[k]) {
						if (a[i] > max(a[j], a[k]) && a[i] < a[j] + a[k]) {
							ans++;
							//cout << a[i] << a[j] << a[k] << endl;
						}
						if (a[j] > max(a[i], a[k]) && a[j] < a[i] + a[k]) {
							ans++;
							//cout << a[i] << a[j] << a[k] << endl;
						}
						if (a[k] > max(a[j], a[i]) && a[k] < a[j] + a[i]) {
							ans++;
							//cout << a[i] << a[j] << a[k] << endl;
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;

}

 


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];

    ll odd_sum = 0, even_sum = 0;
    ll odd_cost = 0, even_cost = 0;
    rep(i, n) {
        if (i % 2) { // odd
            if (odd_sum + a[i] > 0) odd_sum += a[i];
            else {
                odd_cost += abs(1 - (odd_sum + a[i]));
                odd_sum = 1;
            }

            if (even_sum + a[i] < 0) even_sum += a[i];
            else {
                even_cost += abs(-1 - (even_sum + a[i]));
                even_sum = -1;
            }
        } else {
            if (odd_sum + a[i] < 0) odd_sum += a[i];
            else {
                odd_cost += abs(-1 - (odd_sum + a[i]));
                odd_sum = -1;
            }

            if (even_sum + a[i] > 0) even_sum += a[i];
            else {
                even_cost += abs(1 - (even_sum + a[i]));
                even_sum = 1;
            }
        }
    }
    cout << min(odd_cost, even_cost) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
const double PI = acos(-1);
 
int main(){
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  
  double th = double(h*60+m)/720 * 2*PI;
  double tm = double(m)/60 * 2*PI;
  double xh = a*cos(th), yh = a*sin(th);
  double xm = b*cos(tm), ym = b*sin(tm);
  double dx = xh-xm, dy=yh-ym;
  double ans = sqrt(dx*dx + dy*dy);
  printf("%.10f\n", ans);
 
  return 0;
}

Measured memory_bytes: 4040
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:256000000")
#include <iostream>
#include <iterator>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <cassert>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <climits>
#include <ctime>

using namespace std;
using ll = long long;
const int inf = 0x3f3f3f3f;
const int maxn = 200000;


void solve() {
	int k;
	scanf("%d", &k);
	vector<ll> a(k);
	for (int i = 0; i < k; ++i)
		scanf("%lld", &a[i]);
	ll l = 2, r = 2;
	for (int i = k-1; i >= 0; --i) {
		ll d = a[i];
		l = max(l, (l+d-1)/d*d);
		r = min(r, r/d*d);
		if (r < l) {
			printf("-1");
			return;
		}
		r += d-1;
	}
	printf("%lld %lld", l, r);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	solve();

#ifdef LOCAL
	cerr << double(clock()) / CLOCKS_PER_SEC << " sec" << endl;
#endif
	return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    x,a,b=map(int,input().split())
    if b<=a:
        print('delicious')
    elif b<=a+x:
        print('safe')
    else:
        print('dangerous')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
import numpy as np
n = int(input())
h = [int(i) for i in input().split()]
dp = [1000000000]*n
dp[0]=0
dp[1]=np.abs(h[1]-h[0])
for i in range(1,n-1):
    dp[i+1] = min(dp[i+1],dp[i]+np.abs(h[i]-h[i+1]))
    dp[i+1] = min(dp[i+1],dp[i-1]+np.abs(h[i-1]-h[i+1]))
print(dp[n-1])    

Measured memory_bytes: 23076
#include <stdio.h>
int main(void){
    long long int K;
    scanf("%lld",&K);
    long long int a[50]={};
    for(int i=0;i<50;i++)a[i]=((long long int)(K/50))+49-K%50;
    for(int i=0;i<(K%50);i++)a[i]+=50;
    printf("50\n");
    for(int i=0;i<50;i++)printf("%lld ",a[i]);
    return 0;
}


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

typedef long long ll;

unordered_map<int, bool> vis;
unordered_map<int, vector<int>> eg;

ll bfs(int st) {
    queue<int> q; q.push(st); vis[st] = true;
    int now, sz[2] = {};
    while (!q.empty()) {
        now = q.front(); q.pop(); sz[now > 0]++;
        for (auto i: eg[now]) {
            if (!vis.count(i)) q.push(i), vis[i] = true;
        }
    }
    //cout << st << ":" << sz[0] << "," << sz[1] << endl;
    return 1LL * sz[0] * sz[1];
}

int main() {
    ll ans = 0, n;
    cin >> n;
    for (int i = 0, x, y; i < n; i++) {
        cin >> x >> y;
        eg[x].push_back(-y), eg[-y].push_back(x);
    }
    for (auto i: eg) {
        if (!vis.count(i.first)) ans += bfs(i.first);
    }
    cout << ans - n << endl;
    return 0;
}


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

int main(){
	int n,ans=0;
	string s,t;
	cin>>s>>n;
	for(int i=0;i<n;i++){
		cin>>t;
		t += t;
		if(t.find(s,0)!=string::npos)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1212
main :: IO ()
main = getLine >>= print . solve . map read . words

solve :: [Int] -> Int
solve xs
  | odd (l * m - s) = (l * (m + 1) - s) `div` (l - 1)
  | otherwise = (l * m - s) `div` (l - 1)
    where
      l = length xs
      m = maximum xs
      s = sum xs


Measured memory_bytes: 508
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;

int main(void){
  int a,b,c;
  cin>>a>>b>>c;
  if(a<=c&&c<=b) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int N, K, size, i;
        N = input.nextInt();
        K = input.nextInt();
        i = 0;
        List<Integer> list = new Vector<>();
        while (K-- > 0) list.add(input.nextInt());
        String number = Integer.toString(N);
        size = number.length();
        while (i < size) {
            int num = number.charAt(i) - 48;
            if (list.contains(num)) {
                N++;
                number = Integer.toString(N);
                size = number.length();
                i = 0;
            }else i++;
        }
        System.out.println(N);
    }
}


Measured memory_bytes: 24148
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 
const int N = 0;
 
typedef long long int ll;
 
using namespace std;
 
int main(){FIN;
	int a,b,c;cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
long long f[100001];
int main()
{
	long long n,a,b;
	long long sum=0;
	cin>>n>>a>>b;
	for(int x=1;x<=n;x++)
	    scanf("%lld",&f[x]);
	for(int x=1;x<=n-1;x++)
	{
		if((f[x+1]-f[x])*a>b)
		    sum+=b;
		else
		    sum+=(f[x+1]-f[x])*a;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

int main(){
  int N,T;
  std::cin >> N >> T;
  int c[N];
  int t[N];
  int min=1001;
  for(int i;i!=N;i++){
    std::cin >> c[i] >> t[i];
    if(t[i]<=T){
      if(c[i]<min){
        min = c[i];
      }
    }
  }
  if(min==1001){
    std::cout << "TLE" << std::endl;
  }else{
    std::cout << min << std::endl;
  }
}

Measured memory_bytes: 256
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
x = int(input())
#n, k = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))


if x >= 30:
    print("Yes")
else:
    print("No")
        
            
    
        


Measured memory_bytes: 10160
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL n;
    cin >> n;
    if (n < 4) {
        cout << n - 1 << endl;
        return;
    }


    LL ans = 2;
    for (LL i = 2; i * i <= n; ++i) {
        //cerr << i << " " << n % i << endl;
        if (n % i == 1) ++ans;
        if (i != n / i && n % (n / i) == 1) ++ans;
        if (n % i == 0) {
            LL v = n;
            while (v % i == 0) v /= i;
            if (v % i == 1) {
                ++ans;
            }

            v = n;
            while (v % (n / i) == 9) v /= (n / i);
            if (v % (n / i) == 1) ++ans;
        }
    }
    cout << ans << endl;
    dump(ans);
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
ll a[999][999];
int main()
{
    ll n, m, k, c = 1;
    cin >> n >> m >> k;
    for (ll i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        for (ll j = 0; j < m; j++)
            if (s[j] == '#')
                a[i][j] = c++;
    }
    for (ll i = 0; i < n; i++)
    {
        c = 0;
        for (ll j = 0; j < m; j++)
        {
            if (!a[i][j])
                a[i][j] = c;
            else
                c = a[i][j];
        }
    }
    for (ll i = n - 1; ~i; i--)
    {
        c = 0;
        for (ll j = m - 1; ~j; j--)
        {
            if (!a[i][j])
                a[i][j] = c;
            else
                c = a[i][j];
        }
    }
    for (ll j = 0; j < m; j++)
    {
        c = 0;
        for (ll i = 0; i < n; i++)
        {
            if (!a[i][j])
                a[i][j] = c;
            else
                c = a[i][j];
        }
    }
    for (ll j = m - 1; ~j; j--)
    {
        c = 0;
        for (ll i = n - 1; ~i; i--)
        {
            if (!a[i][j])
                a[i][j] = c;
            else
                c = a[i][j];
        }
    }
    for (ll i = 0; i < n; i++)
    {
        for (ll j = 0; j < m; j++)
            cout << a[i][j] << " ";
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int d[500][500]; //d[u][v]は辺e=(u,v)のコスト（存在しない場合はINF、ただしd[i][i]=0とする）
int V = 10; //頂点数

void init() {
    for(int i = 0;i < 500;i++) {
        for(int j = 0;j < 500;j++) {
            if(i == j) {
                d[i][j] = 0;
            }
            else {
                d[i][j] = Inf;
            }
        }
    }
}

void warshall_floyd() {
	for(int k = 0;k < V;k++) {
		for(int i = 0;i < V;i++) {
			for(int j = 0;j < V;j++) {
				d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
			}
		}
	}
}

int main() {
    int H,W;
    cin >> H >> W;
    for(int i = 0;i < 10;i++) {
        for(int j = 0;j < 10;j++) {
            int A;
            cin >> A;
            d[i][j] = A;
        }
    }
    warshall_floyd();
    ll ret = 0;
    for(int i = 0;i < H;i++) {
        for(int j = 0;j < W;j++) {
            int A;
            cin >> A;
            if(A != -1) {
                ret += d[A][1];
            }
        }
    }
    cout << ret << endl;
}

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

using namespace std;

typedef int64_t LL;

template <class T>
inline void chmax(T& a, const T& b) { if (a < b) a = b; }

const int MAX_DIGIT{ 40 };

class D {
	LL N, K;
	vector<LL> A;

public:
	void solve()
	{
		LL mask{ 0 };
		LL dp[MAX_DIGIT + 1][2];
		memset(dp, -1, sizeof dp);
		dp[0][0] = 0;
		
		for (int i{ 0 }; i < N; i++)
			cin >> A[i];

		for (int d{ 0 }; d < MAX_DIGIT; d++)
		{
			mask = (1LL << (MAX_DIGIT - d - 1));
			LL set1{ 0 };
			LL set0{ 0 };

			for (int i{ 0 }; i < N; i++)
			{
				if (A[i] & mask)
					++set0;
			}
			set1 = N - set0;

			set1 *= mask;
			set0 *= mask;

			// smaller -> smaller
			if (dp[d][1] != -1)
			{
				chmax(dp[d + 1][1], dp[d][1] + max(set1, set0));
			}

			// exaxt -> smaller
			if (dp[d][0] != -1 && (K & mask))
			{
				chmax(dp[d + 1][1], dp[d][0] + set0);
			}

			// exaxt -> exaxt
			if (dp[d][0] != -1)
			{
				chmax(dp[d + 1][0], dp[d][0] + ((K & mask) ? set1 : set0));
			}

		}

		cout << max(dp[MAX_DIGIT][0], dp[MAX_DIGIT][1]) << endl;
		
	}

	D() { cin >> N >> K; A.resize(N); }
};

int main()
{
	D solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
#import numpy as np

# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
N = int(input())
X = list(map(int, input().split()))

X.sort()

minN = sys.maxsize
for i in range(100) :
  sum = 0
  for j in range(len(X)) :
    sum += (i-X[j]) ** 2
  minN = min(minN, sum)

print (minN)
  
  

Measured memory_bytes: 3436
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

int abs(int x,int y){
    if(x>y) return x-y;
    else return y-x;
}

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(((abs(a,b)<=d)&&(abs(b,c)<=d))||(abs(a,c)<=d)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define pb push_back
using namespace std;
typedef pair<int,int> p;
typedef long long ll;

int main(){
	int n,k,sum=0;
	cin>>n>>k;
	int x;
	rep(i,n){
		cin>>x;
		sum+=2*min(abs(x),abs(k-x));
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin>>n;
  vector<int>d(n);
  int sum = 0;
  rep(i,n){
    cin>>d[i];
    sum += d[i];
  }
  vector<int>s(n);
  rep(i,n)s[i]=sum-d[i];
  
  int ans = 0;
  rep(i,n)ans += d[i]*s[i];
  cout << ans/2 << endl;
}


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

int main(){
  int N;
  cin >> N;
  int N_tmp = N, N_len = 0, count = 0;
  while(N_tmp > 0) {
    N_len += 1;
    N_tmp /= 10;
  }
  for(int i = 0; i * 2 + 1 < N_len; i++) count += 9 * pow(10, (i * 2));
  if(N_len % 2 == 1) count += N - pow(10, (N_len - 1)) + 1;
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 512
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.p = [e for e in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    def same(self, u, v):
        return self.find_set(u) == self.find_set(v)

    def unite(self, u, v):
        u = self.find_set(u)
        v = self.find_set(v)

        if u == v:
            return

        if self.rank[u] > self.rank[v]:
            self.p[v] = u
            self.size[u] += self.size[v]
        else:
            self.p[u] = v
            self.size[v] += self.size[u]
            if self.rank[u] == self.rank[v]:
                self.rank[v] += 1

    def find_set(self, u):
        if u != self.p[u]:
            self.p[u] = self.find_set(self.p[u])

        return self.p[u]

    def update_p(self):
        for u in range(self.n):
            self.find_set(u)

    def get_size(self, u):
        return self.size[self.find_set(u)]


n, m = map(int, input().split())
l = []
for _ in range(n):
    k, *ls = map(int, input().split())
    l.append(ls)

uf = UnionFind(m)

for li in l:
    for e1, e2 in zip(li, li[1:]):
        e1 -= 1
        e2 -= 1
        uf.unite(e1, e2)

p = uf.find_set(l[0][0] - 1)
ans = "YES"
for e, *_ in l:
    if uf.find_set(e - 1) != p:
        ans = "NO"

print(ans)


Measured memory_bytes: 29904
#include <iostream>
#include <vector>
#include <string>
using namespace std;
using ll = long long int;

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 * b / gcd(a, b);
}

int main() {

	ll a, b;
	cin >> a >> b;
	cout << lcm(a, b) << endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long

int main() {
	int A, B;
	cin >> A >> B;
	if (B * 2 >= A) {
		cout << 0 << endl;
	}
	else {
		cout << A - B - B << endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cassert>
#include <queue>
#include <deque>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
#include <cstdlib>
#include <string>
#include <unordered_map>
#include <sstream>
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef unsigned char byte;
typedef unsigned int uint;
typedef unsigned long long int ulli;

inline int absi(int x) {
    return x > 0 ? x : -x;
}

int main() {
    int n, lx = 0, ly = 0, lt = 0;
    scanf("%d", &n);
    while (n--) {
        int t, x, y;
        scanf("%d%d%d", &t, &x, &y);
        int dist = absi(x - lx) + absi(y - ly);
        if (dist > t - lt) {
            return puts("No") & 0;
        }
        if ((dist ^ (t - lt)) & 1) {
            return puts("No") & 0;
        }
        lt = t;
        lx = x;
        ly = y;
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long
#define ld long double

#define mod 1000000007
#define EULER 2.7182818284
#define INF 1000000000

#define pb push_back
#define ins insert
#define IT iterator
#define PQ priority_queue
#define    nl           "\n"
#define fi first
#define se second
#define maxe max_element
#define mine min_element
#define er erase
#define lb lower_bound
#define ub upper_bound

#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()

#define mem(v,i) memset(v,i,sizeof(v)) // v is array. To set all elements to 0 or -1 only. mem(arr,0);


#define repab(i,a,b) for(int i=(a);i<=(b);i++)
#define reprab(i,a,b) for(int i=(a);i>=(b);i--)
#define repll(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,n) for(int i=(0);i<(n);i++)
#define repr(i,n) for(int i=(n);i>=0;i--)
#define bs bitset
#define bpc(a) __builtin_popcount(a)
#define tc int t;cin>>t;while(t--)
template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
    double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
    time_taken *= 1e-9;
    cout << "\nExecuted in: " << fixed
         << time_taken << setprecision(9);
    cout << " sec";
#endif
}

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

ll max(ll a,ll b)
{
    if(a>b)return a;return b;
}
ll min(ll a,ll b)
{
    if(a<b)return a;return b;
}

ll mypow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
//..............................!!!!!!Get ready to fight!!!!!!............................


int main()
{   
     auto start = chrono::high_resolution_clock::now();
    fast
    ll n,m,k;
    cin>>n>>m>>k;
    vll a(n+1),b(m+1);
    rep(i,n)cin>>a[i];
    rep(i,m)cin>>b[i];
    vll suma(n+1),sumb(m+1);
    suma[0]=0;sumb[0]=0;
    rep(i,n){
        suma[i+1]=suma[i]+a[i];
    }
    rep(i,m){
        sumb[i+1]=sumb[i]+b[i];
    }
    ll total=0;
    for(ll i=0;i<=n;i++){
        ll rem=k-suma[i];
        if(rem<0)
        continue;
        ll l=lower_bound(sumb.begin(),sumb.end(),rem)-sumb.begin();
        if(l>m||sumb[l]>rem)
        l--;
        total=max(total,i+l);
    }
    cout<<total<<nl;
    auto end = chrono::high_resolution_clock::now();
    TIME(start, end);
    return 0;
}

Measured memory_bytes: 9536
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
//ショートカット
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<n;i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

//関数
//最大公約数
long long gcd(long long m,long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m,long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x,long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  lin(H);lin(W);
  ll s[H][W];
  rep(i,H){
    string S;cin>>S;
    rep(j,W) s[i][j]=S[j];
  }
  
  ll res_v[H][W]; ll res_h[H][W];
  
  //まずは横に調べる
  rep(i,H){
    ll count=0;  ll nowp=0;
    rep(j,W){
      if(s[i][j]=='.'){
        
        if(j==W-1){
          count++;
          rep2(k,nowp,j+1) res_h[i][k]=count;
        }
        else{
          count++;
        }
        
      }
      else{
        rep2(k,nowp,j) res_h[i][k]=count;
        res_h[i][j]=-mod;
        nowp=j+1; count=0;
      }
    }
  }
  
  //縦に調べる
  rep(j,W){
    ll count=0;ll nowp=0;
    rep(i,H){
      if(s[i][j]=='.'){
        if(i==H-1){
          count++;
          rep2(k,nowp,i+1) res_v[k][j]=count;
        }
        else
          count++;
      }
      else{
        rep2(k,nowp,i) res_v[k][j]=count;
        res_v[i][j]=-mod;
        nowp=i+1; count=0;
      }
    }
  }
  
  
  ll res=0;
  rep(i,H){
    rep(j,W){
      if(s[i][j]=='.'){
        chmax(res,res_h[i][j]+res_v[i][j]-1);
      }
    }
  }
  
  cout<<res<<endl<<endl;
  
  /*
  //デバッグ
  cout<<"横に調べたもの"<<endl;
  rep(i,H){
    rep(j,W){
      cout<<res_h[i][j]<<" ";
    }
    cout<<endl;
  }
  cout<<endl;
  
  cout<<"縦に調べたもの"<<endl;
  rep(i,H){
    rep(j,W){
      cout<<res_v[i][j]<<" ";
    }
    cout<<endl;
  }
  */
}

Measured memory_bytes: 93952