akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;

struct edge{
    int to, cost;
};

double p;
int n;
vector<edge> G[100010];
double x[100010];

void dfs(int pos, int prev){
    x[pos] = 0;
    for(int i = 0; i < G[pos].size(); i++){
        edge e = G[pos][i];
        if(e.to == prev) continue;
        dfs(e.to, pos);
        x[pos] += (double)(x[e.to] + e.cost) * p;
        cout << x[pos] << endl;
    }
}

double solve(int pos, int prev){
    double res = x[0];
    for(int i = 0; i < G[pos].size(); i++){
        edge e = G[pos][i];
        if(e.to == prev) continue;
        res += (solve(e.to, pos) + (double)e.cost) * p;
    }
    return res;
}

signed main(){
    cin >> p >> n;
    rep(i, 0, n - 1){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        G[a]. push_back((edge){b, c});
        G[b]. push_back((edge){a, c});
    }
    dfs(0, -1);
    // rep(i, 0, n){
    //     printf("%.10lf\n", x[i]);
    // }
    printf("%.10lf\n", solve(0, -1));
}

Measured memory_bytes: 18872
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

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

int main()
{
	int h, w, b;
	while(cin >> w >> h, w | h){
		vector<vector<int>> G(h * w);
		for(int i = 0;i < h * 2 - 1;i++){
			if(i & 1){
				for(int j = 0;j < w;j++){
					cin >> b;
					if(b == 0){
						G[(i / 2 + 1) * w + j].push_back(i / 2 * w + j);
						G[i / 2 * w + j].push_back((i / 2 + 1) * w + j);
					}
				}
			}
			else{
				for(int j = 1;j < w;j++){
					cin >> b;
					if(b == 0){
						G[i / 2 * w + j - 1].push_back(i / 2 * w + j);
						G[i / 2 * w + j].push_back(i / 2 * w + j - 1);
					}
				}
			}
		}
		vector<int> res(h * w, -1);
		queue<P> q;
		q.push(P(0, 1));
		res[0] = 1;
		while(!q.empty()){
			auto p = q.front(); q.pop();
			for(auto to : G[p.first]){
				if(res[to] == -1){
					q.push(P(to, p.second + 1));
					res[to] = p.second + 1;
				}
			}
			if(res[h * w - 1] != -1){
				break;
			}
		}
		cout << (res[h * w - 1] == -1 ? 0 : res[h * w - 1]) << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    vector<LL> t(n), a(n), fixed(n, 0);
    REP(i, n) cin >> t[i];
    REP(i, n) cin >> a[i];
    
    int high = -1;
    REP(i, n){
        if(high < t[i]){ fixed[i] = 1; high = t[i]; }
    }

    high = -1;
    for(int i = n-1; i >= 0; i--){
        if(high < a[i]){
            if(fixed[i] != 0 && a[i] != t[i]){
                cout << 0 << endl;
                return 0;
            }
            fixed[i] = 1;
            high = a[i];
        }else{
            if(fixed[i] != 0 && t[i] > a[i]){
                cout << 0 << endl;
                return 0;
            }
        }
    }

    LL ans = 1;
    REP(i, n){
        if(fixed[i] == 0){
            ans = ans * min(t[i], a[i]) % MOD;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> // プログラムの耳と口
#include <vector> // 超有能配列秘書
#include <algorithm> // みんな大好きソートと二分探索
#include <queue> // きゅーちゃん、だいすき
#include <string> // to_string
#include <functional> // 関数を変数に入れる子
#include <set> // 値の取得・挿入・削除を高速に
#include <map> // setの妹 これまた優秀
#include <random> // 乱択さん
#include <ctime>
#include <bitset>

#define DB cerr<<"D"<<endl
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";};
using P=pair<ll,ll>;
const ll M = 1e9+7;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;}
bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
int keta(ll a) {int res=0; while(a>0) res+=a%10, a/=10; return res;}
const int up[]={1,-1,0,0}, lf[]={0,0,1,-1};
ll gcd(ll a, ll b) {if (b==0) return a; else return gcd(b, a%b);}

// 1つめ：すべて素（レア）
// 2つめ：全体gcd
  const int mmmmmmaaaaaaxxxxx = 1000100;
  vector<int> v[mmmmmmaaaaaaxxxxx+1];
  bool b[mmmmmmaaaaaaxxxxx]={};
int main() {
  for(int i=2;i<=mmmmmmaaaaaaxxxxx;i++) {
    if (v[i].empty()) {
      for(int j=i; j<=mmmmmmaaaaaaxxxxx; j+=i) {
        v[j].push_back(i);
      }
    }
  }

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

  for(int i=0;i<n;i++) {
    for(int x : v[a[i]]) {
      if (b[x]) pc = false;
      b[x] = true;
    }
  }

  ll val = gcd(a[0],a[1]);
  for(int i=2;i<n;i++) {
    val = gcd(val, a[i]);
  }
  bool sc = val == 1;

  if (pc) {
    cout<<"pairwise coprime"<<endl;
  } else if (sc) {
    cout<<"setwise coprime"<<endl;
  } else {
    cout<<"not coprime"<<endl;
  }
}
// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest


Measured memory_bytes: 67688
import itertools
import math
import fractions
import functools
n, t = map(int, input().split())
pair = []
for i in range(n):
    ci, ti = map(int, input().split())
    pair.append([ci, ti])

c = 1001
for i in range(n):
    if pair[i][1] <= t:
        c = min(c,pair[i][0])

if c == 1001:
    print("TLE")
else: print(c)

Measured memory_bytes: 66156
package main

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

const scBufSize = 1 * 1024 * 1024 // 1MB
var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, scBufSize), scBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func main() {
	n := scani()
	k := scani()
	l := scani()

	road := NewUnion(n)
	rail := NewUnion(n)
	for i := 0; i < k+l; i++ {
		o, d := scanRoad()
		if i < k {
			road.unite(o, d)
		} else {
			rail.unite(o, d)
		}
	}
	group := map[[2]int]int{}
	for i := 0; i < n; i++ {
		road[i] = road.root(i)
		rail[i] = rail.root(i)
		group[[2]int{road[i], rail[i]}]++
	}
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = strconv.Itoa(group[[2]int{road[i], rail[i]}])
	}
	fmt.Println(strings.Join(ret, " "))
}

type union []int

func NewUnion(n int) union {
	var u union = make([]int, n)
	for i := 0; i < n; i++ {
		u[i] = i
	}
	return u
}

func (u union) root(x int) int {
	if u[x] == x {
		return x
	}
	u[x] = u.root(u[x])
	return u[x]
}

func (u union) unite(x, y int) {
	r1 := u.root(x)
	r2 := u.root(y)
	if r1 == r2 {
		return
	}
	u[r2] = r1
}

func scani() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanRoad() (o, d int) {
	o = scani() - 1
	d = scani() - 1
	return
}


Measured memory_bytes: 24320
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	string s;
	int k;
	cin >> s >> k;
	for(int i = 0; i < sz(s); i++)
		if(s[i] != 'a' && 'z' - s[i] < k){
			k -= 'z' - s[i] + 1;
			s[i] = 'a';
		}
	if(k > 0)
		s[sz(s) - 1] = 'a' + ((s[sz(s) - 1] - 'a' + k) % 26);
	cout << s << endl;
	return 0;
}

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

int main(){
  int n,max=0,v,sum=0;
  cin>>n;
  int l[n];
  for(int i=0;i<n;i++){
    cin>>l[i];
    if(max < l[i]){
      max=l[i];
      v=i;
    }
  }
  for(int i=0;i<n;i++){
    if(v != i){
      sum+=l[i];
    }
  }
  if(max < sum){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const int MOD = 1000000007;

int main() {
  string s; cin >> s;
  int result=0 ; rep(i,4) if (s[i]=='2') result++;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
const ll mod = 1e9+7;

int main(){
    int n;
    string s,t;
    cin >> n;
    cin >> s >> t;
    string ans = "";
    rep(i,n){
        ans += s[i];
        ans += t[i];
    }
    PRINT(ans);
}


Measured memory_bytes: 256
import collections 
import sys,heapq,bisect,math,itertools,string,queue,datetime
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n,m = inpl()
t = []
cnt = [0] * (n+1)
ans = 0
for i in range(m):
    a,b = inpl()
    t.append([a,b])
    cnt[a] += 1
    cnt[b] += 1
# print(cnt)
while m:
    flag = False
    for i in range(1,n+1):
        if cnt[i] == 1:
            flag = True
            cnt[i] = 0
            ans += 1
            for j in t:
                if j[0] == i:
                    cnt[j[1]] -= 1
                    t.remove(j)
                elif j[1] == i:
                    cnt[j[0]] -= 1
                    t.remove(j)
            break
    if flag == False:
        break
    m -= 1
        # print(i,cnt)
print(ans)

Measured memory_bytes: 4324
#include<bits/stdc++.h>
using namespace std;
char s[20];
int main(){
	scanf("%s",s+1);
	int len=strlen(s+1);
	if(len%2==1){
		cout<<"No";
		return 0;
	}
	for(int i=1;i<=len;i++){
		if(i%2==1&&s[i]!='h'){
			cout<<"No";
			return 0;
		}
		else if(i%2==0&&s[i]!='i'){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(long long i=0; i<x;i++)
#define mod 1000000007
#define INF 10000000000000000
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


struct UnionFind {
	vector<int> par;
  
  UnionFind(int N): par(N){
  	for(int i=0;i<N;i++) par[i] =i;
  }
};





int main(){
  ios::sync_with_stdio(false);
  
  int N,K;
  cin>>N>>K;
  ll h[N];
  rep(i,N) cin>>h[i];
  
  
  ll DP[N];
  
  rep(i,N)DP[i]=INF;
  DP[0] =0;
  for(int i = 1; i<N;i++){
    for(int j=1;j<=K;j++){
  	if(i-j>=0){
    	DP[i] = min(DP[i],DP[i-j]+abs(h[i]-h[i-j]));
    }
    }
  }
  
  cout<<DP[N-1];
}

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

using namespace std;

typedef long long ll;

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

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

ll solve_for_two(const int N, const string S) {
    ll acc = 0;
    for (int i = 0; i < N; i++) {
        int d = S[i] - '0';
        if (d % 2 == 0) {
            acc += i + 1;
        }
    }
    return acc;
}

ll solve_for_five(const int N, const string S) {
    ll acc = 0;
    for (int i = 0; i < N; i++) {
        int d = S[i] - '0';
        if (d % 5 == 0) {
            acc += i + 1;
        }
    }
    return acc;
}

ll solve_for_others(const int N, const int P, const string S) {
    // {remain, nums}
    map<ll, ll> m;
    ll acc = 0;
    ll x = 0;
    m[0]++;
    ll tenfactor = 1;
    for (int i = 0; i < N; i++) {
        int d = S[i] - '0';
        x = (x + (d * tenfactor) % P) % P;
        acc += m[x];
        m[x]++;
        tenfactor = (tenfactor * 10) % P;
        // printf("i: %d, acc: %d, x: %lld\n", i, acc, x.x);
    }
    return acc;
}

int main(void) {
    int N, P;
    string S;
    cin >> N >> P >> S;

    if (P == 2) {
        cout << solve_for_two(N, S) << endl;
    } else if (P == 5) {
        cout << solve_for_five(N, S) << endl;
    } else {
        reverse(S.begin(), S.end());
        cout << solve_for_others(N, P, S) << endl;
    }

    return 0;
}


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

using ll = long long;
const ll INF = 1e18;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    rep(i, H) cin >> S[i];
    int i = 0, j = 0;
    while (i != H - 1 || j != W - 1) {
        S[i][j] = '.';
        if (i == H - 1) {
            if (S[i][j + 1] == '.') {
                cout << "Impossible\n";
                return 0;
            }
            j++;
            continue;
        } else if (j == W - 1) {
            if (S[i + 1][j] == '.') {
                cout << "Impossible\n";
                return 0;
            }
            i++;
            continue;
        } else {
            if (S[i][j + 1] == '.') {
                if (S[i + 1][j] == '.') {
                    cout << "Impossible\n";
                    return 0;
                }
                i++;
                continue;
            } else {
                if (S[i + 1][j] == '#') {
                    cout << "Impossible\n";
                    return 0;
                }
                j++;
                continue;
            }
        }
    }
    S[H - 1][W - 1] = '.';
    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == '#') {
                    cout << "Impossible\n";
                    return 0;
            }
        }
    }
    cout << "Possible\n";
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	mod int = 1e9 + 7
)

func main() {
	a := getInt()
	b := getInt()

	if a <= b {
		fmt.Println(strings.Repeat(strconv.Itoa(a), b))
	} else {
		fmt.Println(strings.Repeat(strconv.Itoa(b), a))
	}
}

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

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

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray) - 1])
}

func calcMod(x int) int {
	return x % mod
}


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

int main(){
    double r,s,l;
    const double pi = 3.141592653589;
    cin >> r;
    s = r*r*pi;
    l = 2*r*pi;
    
    cout << fixed << setprecision(15) << s << " "  << l << "\n";
    
    return 0;
}


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

int main()
{
    int i,j,i1=0,j1=0;
    int k,t=1,ten=1;
    scanf("%d %d",&i,&j);
    for(k=0;k<j;k++)
    {
        i1+=i*ten;
        ten=ten*10;
    }
    for(k=0;k<i;k++)
    {
        j1+=j*t;
        t=t*10;
    }
    if(i1>j1)
        printf("%d",i1);
    else
        printf("%d",j1);
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <functional>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod2 = 1000000007;
constexpr ll mod = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// --------------------------------------------------------------------------

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> T(N);
  int sum = 0;
  for(int i=0; i<N; i++){
    cin >> T[i];
    sum += T[i];
  }
  int M;
  cin >> M;
  for(int i=0; i<M; i++){
    int a,b;
    cin >> a >> b;
    a--;
    cout << sum - (T[a]-b) << "\n";
  }
  return 0;
}


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

int main(){
    int n,q; string s; cin>>n>>s>>q;
    vector<set<int>> moji(26);
    rep(i,n) moji[s[i]-'a'].insert(i);
    rep(j,q){
        int which;
        cin>>which;
        if(which==1){
            int i; char c; cin>>i>>c; i--;
            moji[s[i]-'a'].erase(i);
            s[i] = c;
            moji[s[i]-'a'].insert(i);
        }else{
            int l,r,ans=0; cin>>l>>r; l--;
            rep(i,26){
                auto it = moji[i].lower_bound(l);
                if(it!=moji[i].end()&& *it<r) ans++;
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 27244
import java.util.*;

public class Main {

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

		int N = sc.nextInt();
		int X = sc.nextInt();
		int T = sc.nextInt();
		int times;
		
		if(N%X == 0) {
			times = N/X;
		} else {
			times = N/X + 1;
		}
		System.out.print(times * T);
	}

}

Measured memory_bytes: 35892
#include <iostream>
#include <string>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

ll L[101];
int main() {
	ll n, x; cin >> n >> x;

	rep(i, 0, n)cin >> L[i];
	ll d = 0;
	ll ans = 1;
	repe(i, 1, n) {
		d = d + L[i-1];
		if (d <= x)ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
const int N=1505;
int b[N][N],S[N],n,u[N][N],l[1<<12|1],r[1<<12|1],flag[N][N];
char A[N][N];
int main(){
	scanf("%d",&n);
	for (register int i=1;i<=n;++i)scanf("%s",A[i]+1);
	for (register int i=1;i<=n;++i)
		for (register int j=1;j<=n;++j)flag[i][j]=A[i][j]>='0'&&A[i][j]<='9',b[i][j]=A[i][j]-'0';
	for (register int i=0;i<=n;++i)
		for (register int j=0;j<=n;++j)u[i][j]=flag[i][j]?min(i,min(u[i-1][j],u[i][j-1])):1<<30;
	long long ans=0;
	for (register int x=1;x<=n;++x){
		int t=(x&1)<<11;
		for (register int j=1;j<=n;++j)S[j]=S[j-1]+(u[x][j]<=x?b[x][j]:0);
		for (register int j=n+1;j;--j){
			if (flag[x][j]){
				l[t|j]=j-1;
				r[t|j]=max(r[t|(j+1)],j);
				ans+=b[x][j]*(S[r[t|j]]-S[l[t|j]]-b[x][j]);
			}
			else l[t|j]=1e9,r[t|j]=-1;
		}
		for (register int i=x-1;i;--i){
			int t=(i&1)<<11,t2=((i&1)^1)<<11;
			for (register int j=1;j<=n;++j)S[j]=S[j-1]+(u[x][j]<=i?b[x][j]:0);
			for (register int j=n+1;j;--j){
				if (flag[i][j]){
					l[t|j]=min(l[t|(j+1)],l[t2|j]);
					r[t|j]=max(r[t|(j+1)],r[t2|j]);
					if (l[t|j]<=r[t|j])ans+=b[i][j]*(S[r[t|j]]-S[l[t|j]]);
				}
				else l[t|j]=1e9,r[t|j]=-1;
			}
		}
	}
	printf("%lld\n",ans);
}


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

using namespace std;

const int MN = 2e5+10;
typedef long long ll;
typedef pair<int,int> ii;

vector<int> G1[MN], G2[MN];
int C1[MN], C2[MN];

void dfs(int nod, vector<int> G[], int C[], int color){
    C[nod] = color;
    for (int i=0; i < (int)G[nod].size(); i++){
        if (C[G[nod][i]] == 0){
            dfs(G[nod][i], G, C, color);
        }
    }
}

int main()
{
    #ifdef ACMTUYO
    freopen("a.in","r",stdin);
    #else
    cin.tie(0); ios_base::sync_with_stdio(0);
    #endif

    int N, K, L; cin >> N >> K >> L;

	for (int i=0; i < K; i++){
		int a, b; cin >> a >> b;
		G1[a].push_back(b);
		G1[b].push_back(a);
	}

	for (int i=0; i < L; i++){
		int a,b; cin >> a >> b;
		G2[a].push_back(b);
		G2[b].push_back(a);
	}

	int col1=0, col2=0;
	for (int i=1; i <= N; i++){
		if (C1[i] == 0){
			col1++;
			dfs(i,G1,C1,col1);
		}
		if (C2[i] == 0){
			col2++;
			dfs(i,G2,C2,col2);
		}
	}

	map<ii,int> mp;
	for (int i=1; i <= N; i++){
		ii atrib = ii(C1[i],C2[i]);
        mp[atrib]++;
	}

	cout << mp[ii(C1[1],C2[1])];
	for (int i=2; i <= N; i++){
		cout << " " << mp[ii(C1[i],C2[i])];
	}

	cout << "\n";

    return 0;
}


Measured memory_bytes: 27904
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<int> P(N), idx(N);
	for (int i = 0; i < N; i++) cin >> P[i];
	for (int i = 0; i < N; i++) idx[P[i] - 1] = i;

	multiset<lint> st;
	st.emplace(-1), st.emplace(-1);
	st.emplace(N), st.emplace(N); // 番兵
	lint ans = 0;
	for (int i = N - 1; i >= 0; i--) {

		auto ub1 = st.lower_bound(idx[i]);
		auto ub2 = next(ub1);
		auto lb1 = --st.upper_bound(idx[i]);
		auto lb2 = prev(lb1);

		ans += (idx[i] - *lb1) * (*ub2 - *ub1) * P[idx[i]];
		ans += (*ub1 - idx[i]) * (*lb1 - *lb2) * P[idx[i]];
		st.emplace(idx[i]);

	}

	cout << ans << "\n";

	return 0;
}

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

const int limit = 50;

int n, m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v){
    visited[v] = true;
    for (int v2 = 0; v2 < n; ++v2){
        if (graph[v][v2] == false) continue;
        if (visited[v2] == true) continue;
        dfs(v2);
    }
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i){
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    int ans = 0;

    for (int i = 0; i < m; ++i){
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

        for (int j = 0; j < n; ++j) visited[j] = false;

        dfs(0);

        bool bridge = false;
        for (int j = 0; j < n; ++j) if (visited[j] == false) bridge = true;
        if (bridge) ans += 1;

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
r, c = map(int, input().split())
A = []
B = []
C = []
for i in range(r):
    A.append(list(map(int, input().split())))
for i in range(r):
    b = [str(j) for j in A[i]]
    B.append(b)
    B[i].append(sum(A[i]))
for i in range(r):
    print(*B[i])

for i in range(c):
    S = 0
    for j in range(r):
        S += A[j][i]
    C.append(S)
C.append(sum(C))
print(*C)


Measured memory_bytes: 6760
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor_ct.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/strong_components.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/bellman_ford_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>
#include <iomanip>      // std::setprecision

#define REP(i, N) for(int i=0; i<(N); i++)
using namespace std;
using namespace boost::math;

int main() {
	int N;

	cin >> N;
    vector<int> A(N);
    double r = 0.0;
  
    for (auto& i : A) {
      cin >> i;
      r += 1.0 / (double)i;
    }

	cout << std::setprecision(9) << 1.0 / r << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    int ary[n][3];
    rep(i,n) rep(j,3) cin >> ary[i][j];

    ll dp[n+10][3];
    dp[0][0] = ary[0][0];
    dp[0][1] = ary[0][1];
    dp[0][2] = ary[0][2];
    REP(i,1,n)
    {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2])+ary[i][0];
        dp[i][1] = max(dp[i-1][2], dp[i-1][0])+ary[i][1];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1])+ary[i][2];
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
}


Measured memory_bytes: 3840
/*
	Failure is not the reason for you to stop trying 
	   it is actually a remainder that you should 
			KEEP GOING 
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define E endl
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	SaveTime;
	int T=1;
	// cin >> T;
	while(T--){
		string s,t;
		cin>>s>>t;
		cout <<t<<s<<endl;
	
	
	}
	
	cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 256
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var a,b int
    fmt.Scan(&a,&b)
    var s string
    fmt.Scan(&s)
    ans := "Yes"
    for i:=0; i<a; i++{
        if !(s[i]>='0' && s[i]<='9'){
            ans = "No"
        }
    }
    if s[a]!='-'{
        ans = "No"
    }
    for i:=a+1;i<a+b+1;i++{
        if !(s[i]>='0' && s[i]<='9'){
            ans = "No"
        }
    }
    fmt.Println(ans)
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int K,X; cin>>K>>X;
  string ans="No";
  if(500*K>=X)
    ans="Yes";
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#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()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
//ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int n;
int ver[105][105]={0};
int main(){
	cin>>n;
	if(n%2==0){
		for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){
			int x=i+1;
			int y=j+1;
			if(x+y!=n+1)ver[x][y]=1;
		}
	}else{
		for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){
			int x=i+1;
			int y=j+1;
			if(x+y!=n)ver[x][y]=1;
		}
		rep(i,n-1){
			ver[i+1][n]=1;
		}
	}
	int cnt=0;
	rep(i,n+1)rep(j,n+1)if(ver[i][j]==1)cnt++;
	cout<<cnt<<endl;
	rep(i,n+1)rep(j,n+1)if(ver[i][j]==1)cout<<i<<" "<<j<<endl;
}


Measured memory_bytes: 256
S = input()
answer = float('inf')
for i in range(len(S) - 3 + 1):
    # print(S[i:i + 3])
    if answer > abs(int(S[i:i + 3]) - 753):
        answer = abs(int(S[i:i + 3]) - 753)

print(answer)


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

typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<int> x(N), y(N), h(N);
  int si;
  for(int i=0; i<N; i++){
    cin >> x[i] >> y[i] >> h[i];
    if(h[i]>0) si = i;
  }

  for(int Cx=0; Cx<=100; Cx++){
    for(int Cy=0; Cy<=100; Cy++){
      int H = h[si]+abs(x[si]-Cx)+abs(y[si]-Cy);
      bool ok=true;
      for(int i=0; i<N; i++){
        if(h[i]>0){
          if((h[i]+abs(x[i]-Cx)+abs(y[i]-Cy)) != H){
            ok = false;
          }
        }
        if(h[i]==0){
          if(H>(abs(x[i]-Cx)+abs(y[i]-Cy))){
            ok = false;
          }
        }
      }
      if(ok){
        cout << Cx <<" "<< Cy <<" "<< H << endl;
        return 0;
      }
    }
  }

}

Measured memory_bytes: 256
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b

using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
const int MAXN=5000+2;
vector<int> g[MAXN];
int siz[MAXN],n;
const int MOD=1e9+7;
LL fact[MAXN];
LL dp[MAXN][MAXN][2]/*表示以i为根，j所在的联通快大小为j，断掉了k根绳子(k%2=p)*/,f[2][MAXN][2];
void dfs(int i,int pre){
	for(auto it:g[i]){
		if(it==pre) continue;
		dfs(it,i);
	}
	siz[i]=1;
	int now=1,prev=0;
	memset(f[prev],0,sizeof(f[prev]));
	f[prev][1][0]=1;
	for(auto it:g[i]){
		if(it==pre) continue;
		memset(f[now],0,sizeof(f[now]));/*
		rb(I,1,siz[i]+siz[it]){
			f[now][I][0]=f[now][I][1]=0;
		}*/
		rl(I,siz[i],1){
			LL save[2];
			rep(J,2)
				save[J]=f[prev][I][J];
			rep(J,2){
				if(save[J]){
					rb(k,1,siz[it]){
						rep(l,2){
							f[now][I+k][J^l]+=save[J]*dp[it][k][l]%MOD;
							if(k&1);
							else {
								f[now][I][J^l^1]+=fact[k-1]*save[J]%MOD*dp[it][k][l]%MOD;
							}
							f[now][I+k][J^l]%=MOD;
							f[now][I][J^l^1]%=MOD;
						}		
					}
				}
			}
		}
		swap(now,prev);
		siz[i]+=siz[it];
	}
	rep(I,siz[i]+1){
		rep(J,2){
			dp[i][I][J]=f[prev][I][J];
		}
	} 
}
int main(){
	fastio;
	R(n);
	fact[1]=1ll;
	rb(i,3,n)
		if(i&1)
		fact[i]=fact[i-2]*i,fact[i]%=MOD;
	rb(i,2,n){
		int u,v;
		R2(u,v);
		g[u].PB(v);
		g[v].PB(u);
	}
	dfs(1,0);
	LL res=0;
	rb(i,1,n){
		if(i&1);
		else{
			res+=dp[1][i][0]*fact[i-1]%MOD;
			res%=MOD;
		} 
	} 
	rb(i,1,n){
		if(i&1);
		else{
			res-=dp[1][i][1]*fact[i-1]%MOD;
			res+=MOD;
			res%=MOD;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 161516
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<int> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

int main(){
    string O,E;
    cin >> O;
    cin >> E;
    if (O.size() > E.size()){
        rep(i,E.size()){
            cout << O[i] << E[i];
        }
        cout << O[O.size()-1] << endl;
    }else{
        rep(i,E.size()){
            cout << O[i] << E[i];
        }
        cout << "" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int i,j,input,fundo[10]={0};
	
	while(scanf("%d",&input) != EOF){
		j=0;
		for(i=0;i < 10;i++) fundo[i] = 0;
		
		while(input > 0){
			for(i=512;i >= 1;i/=2){
				if(input-i >= 0){
					input -= i;
					fundo[j]=i;
					j++;
				}
			}
		}
		for(i=9;i > 0;i--){
			if(fundo[i] != 0) printf("%d ",fundo[i]);
		}
		printf("%d\n",fundo[i]);
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n),B(n),C(n);
  for(auto &a:A)cin>>a;
  for(auto &a:B)cin>>a;
  for(auto &a:C)cin>>a;
  sort(ALL(A));
  sort(ALL(B));
  sort(ALL(C));
  ll ans = 0;
  A.pb(llINF);C.pb(llINF);
  for(int i=0;i<n;i++){
    auto lb = lower_bound(ALL(A),B[i]);
    auto ub = upper_bound(ALL(C),B[i]);
    ll num = (lb-A.begin());
    ll num2 = n-(ub-C.begin());
    ans += num*num2;
    // cout<<num<<" "<<num2<<endl;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    ll n;
    cin >> n;
    string ans;
    while(n) {
        n--;
        ans += (char)('a' + (n % 26));
        n /= 26;
    }
    reverse(ALL(ans));
    cout << ans  << endl;

    return 0;
}

Measured memory_bytes: 3628
# E - ∙ (Bullet)
import sys
from collections import defaultdict

readline = sys.stdin.readline
MOD = 1000000007
N = int(readline())

# イワシの傾きをA/Bとする。
# A/Bは予めgcdで割って約分し、同じ傾きのものを揃えておく。
# このとき、仲の悪い組合せは(A, B)に対して(B, -A)となるもの。 
# 前者をS、後者をTとして考える。
d_S = defaultdict(int)
d_T = defaultdict(int)

def gcd(x, y):
    if x == 0:
        return y
    else:
        return gcd(y%x, x)

pow2_mod = [1] + [0] * (N * 2)
for i in range(1, N * 2):
    pow2_mod[i] = pow2_mod[i-1] * 2 % MOD

zeros = 0
for i in range(N):
    A, B = map(int, readline().split())
    # (0, 0)のイワシは他の全てのイワシと仲が悪いため、
    # 1匹のみでしか選ぶことができない。最後にこの数を足す。
    if A == 0 and B == 0:
        zeros += 1
    # (?, 0),(0, ?)のイワシは、?がどのような数字であろうとも
    # この組合せであれば仲が悪い。一律、(1,0)(0,-1)として考える。
    elif A == 0:
        d_S[(1, 0)] += 0
        d_T[(0, -1)] += 1
    elif B == 0:
        d_S[(1, 0)] += 1
        d_T[(0, -1)] += 0
    else:
        g = gcd(A, B)
        A //= g
        B //= g
        # いずれもマイナスの場合、傾きはプラスになる
        if A < 0 and B < 0:
            A *= -1
            B *= -1
        if A * B > 0:
            d_S[(A, B)] += 1
            d_T[(B, -A)] += 0
        # 片方がマイナスの場合、必ずAがマイナスになるよう揃える
        else:
            if A > B:
                A, B = B, A
            d_S[(-A, B)] += 0
            d_T[(B, A)] += 1

ans = 1
for (si, sj), s_cnt in d_S.items():
    t_cnt = d_T[(sj, -1*si)]
    tmp = 0
    tmp += pow2_mod[s_cnt] - 1 # Sから1匹以上選ぶ組合せ
    tmp += pow2_mod[t_cnt] - 1 # Tから1匹以上選ぶ組合せ
    tmp += 1 # どちらも選ばない組合せ
    ans = (ans * tmp)%MOD

ans -= 1 # 最終的に1匹も選ばない組合せ
ans += zeros # (0, 0)のイワシの数

print(ans%MOD)

Measured memory_bytes: 96500
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	g := make([][]int, n)
	for i := 0; i < n-1; i++ {
		a, b := scanInt()-1, scanInt()-1
		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}

	ans := 0
	all := mpow(2, n-1) - 1

	var dfs func(p, v int) int
	dfs = func(p, v int) int {
		res := 1

		for _, to := range g[v] {
			if to == p {
				continue
			}
			t := dfs(v, to)
			res += t
			ans -= mpow(2, t) - 1
			ans %= mod
		}

		ans += all
		ans %= mod

		ans -= mpow(2, n-res) - 1
		ans %= mod

		return res
	}

	dfs(0, 0)

	for i := 0; i < n; i++ {
		ans = div(ans, 2)
	}

	ans += mod
	ans %= mod

	fmt.Fprintln(wr, ans)
}

const mod = 1000000007

func mpow(a, n int) int {
	res := 1
	for n > 0 {
		if n&1 == 1 {
			res = res * a % mod
		}
		a = a * a % mod
		n >>= 1
	}
	return res
}

func div(b, c int) int {
	a, p, x, u := c, mod, 1, 0
	for p != 0 {
		t := a / p
		a, p = p, a-t*p
		x, u = u, x-t*u
	}
	res := b * x % mod
	if res < 0 {
		res += mod
	}
	return res
}


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

// a^n mod を計算する
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
 
// a^{-1} mod を計算する
ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}
 
const int MAX = 510000;
const int MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, K;
  cin >> N >> K;
  ll d = pow(10, 9) + 7;
  COMinit();
  int a = N - K;
  for (int i = 1; i <= K; i++) {
    if (a + 1 < i) {
      cout << 0 << "\n";
    } else {
      if (i == 1) {
        cout << a + 1 << "\n";
      } else {
        ll t = COM(K - 1, i - 1);
        ll k = a - (i - 1);
        ll b = COM(k + i, i) * t;
        b %= d;
        cout << b << "\n";
      }
    }
  }
  return 0;
}

Measured memory_bytes: 12288
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;
const int N_MAX = 200001;

int main() {
  int N, K; cin >> N >> K;
  int A[N]; rep(i, N) cin >> A[i];

  int count[N_MAX]={}; rep(i, N) count[A[i]]++;
  sort(count, count+N_MAX, [](int x,int y){return x>y;});

  int result = N;
  rep(i, K) result -= count[i];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1792
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
typedef pair<int,int> pii;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

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


void solve(){
   int a,b;
   cin >> a >> b;
   if(a<b)swap(a,b);
   int ans  = gcd(a,b);
   ans = (a*b)/ans;
   cout << ans << endl;
}

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 256