akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

class Solution {
public:
	/* time: O(n^2), space: O(n^2) */
	int league(const vector<vector<int>>& A) {
		/* Build the dependency graph of all matches */
		const int n = A.size();
		vector<vector<int>> adjLists(n * n);
		for (int i = 1; i <= n; ++i) {
			int prevMatch = -1;
			for (int j : A[i - 1]) {
				const int playerX = min(i - 1, j - 1), playerY = max(i - 1, j - 1);
				const int currMatch = playerX * n + playerY;
				if (prevMatch != -1)
					adjLists[prevMatch].push_back(currMatch);
				prevMatch = currMatch;
			}
		}

		/* Run topological sort (Kahn's algorithm) */
		vector<int> inDegree(n * n);
		for (const auto& adjList : adjLists) {
			for (int v : adjList)
				++inDegree[v];
		}

		queue<int> q;
		for (int i = 0; i < n * n; ++i) {
			if (!inDegree[i])
				q.push(i);
		}

		int ans = 0, nVisited = 0;
		for (int depth = 1; !q.empty(); ++depth) {
			for (int i = q.size(); i > 0; --i) {
				const int u = q.front();
				++nVisited, q.pop();
				for (int v : adjLists[u]) {
					if (inDegree[v] && !--inDegree[v])
						q.push(v);
				}
			}
			ans = max(ans, depth);
		}
		if (nVisited < n * n)
			return -1; /* failed */
		return ans;
	}
};

int main() {
	int n;
	cin >> n;
	vector<vector<int>> A(n, vector<int>(n - 1));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n - 1; ++j)
			cin >> A[i][j];
	}

	Solution sol;
	int ans = sol.league(A);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 49188
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
int	a[10005];
int main()
{
	int n,cou=0;
	sc(n);
	for(int i=1;i<=n;i++){
		sc(a[i]);
	}sort(a+1,a+n+1);
	for(int i=1;i<=n-2;i++){
		for(int j=i+1;j<=n-1;j++){
			for(int k=j+1;k<=n;k++){
				if(a[k]<a[i]+a[j]&&a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k])cou++;
			}
		}
	}pf("%d\n",cou);
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(ll i=(ll)(x);i<(ll)(y);++i)
#define For(i,x,y)  for(ll i=(ll)(x);i<=(ll)(y);++i)
#define FOr(i,x,y)  for(ll i=(ll)(x);i>=(ll)(y);--i)
#define pi acos(-1) 
#define mk make_pair
#define pa pair<ll,ll>
#define lf else if
#define IL inline
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)      ((x)*(x))
#define Mul(x,y)    ((x)=1LL*(x)*(y)%mod)
#define Add(x,y)    ((x)=((x)+(y))%mod)
#define E(x)        return writeln(x),0
#define LL			(long long)
#define p(x)        printf("~%lld~\n",LL(x))
#define pp(x,y)     printf("~~%lld %lld~~\n",LL(x),LL(y))
#define ppp(x,y,z)  printf("~~~%lld %lld %lld~~~\n",LL(x),LL(y),LL(z))
#define pppp(a,b,c,d)	printf("~~~%lld %lld %lld %lld\n",LL(a),LL(b),LL(c),LL(d))
#define f_in(x)     freopen(x".in","r",stdin)
#define f_out(x)    freopen(x".out","w",stdout)
#define open(x)     f_in(x),f_out(x)
#define fi first
#define se second
#define GuYue		puts("\nGuYueNa________________________________________________________________________________")
#define y1			fafa____
typedef complex<double> E;
namespace SHENZHEBEI{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_; 
#endif 
#define NEG 1
    static const int GYN=2333333;
    char SZB[GYN],*S=SZB,*T=SZB;
    inline char gc(){   if (S==T){  T=(S=SZB)+fread(SZB,1,GYN,stdin); if (S==T) return '\n';  }   return *S++;    }
#if NEG
    inline ll read(){    ll x=0,g=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') g=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*g; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
	void Print(long long *a,int s,int t){For(i,s,t)printf("%lld ",a[i]);puts("");}
	void Print(int *a,int s,int t){For(i,s,t)printf("%d ",a[i]);puts("");}
	void Print(char *a,int s,int t){For(i,s,t)putchar(a[i]);puts("");}
	void writeln(ll x){write(x);putchar('\n');}
}using namespace SHENZHEBEI;
const ll N=200010;
vector<ll>g[N];
ll n;
ll dfs(ll x){
	vector<ll>h;
	rep(i,0,g[x].size())h.push_back(dfs(g[x][i]));
	ll ans=0;
	sort(h.begin(),h.end());
	rep(i,0,h.size())
		ans=max(ans,h[i]+h.size()-i);
	return ans;
}
int main(){
	n=read();
	For(i,2,n)g[read()].push_back(i);
	writeln(dfs(1));
}

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

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

int const maxn=103; 

char s[maxn][maxn]; 
int a,b; 

int main(){
	scanf("%d%d",&a,&b); 
	fo(i,100) fo(j,100) s[i][j]= i<50? '#':'.'; 
	int x=0,y=0,z=0; 
	fo(i,a-1){
		s[x][y]='.'; 
		y+=4; 
		if(y>=100) {
			x++,y=((++z)&1)? 3:0;  
		}
	}
	x=51,y=0,z=0; 
	fo(i,b-1){
		s[x][y]='#'; 
		y+=4; 
		if(y>=100){
			x++,y=((++z)&1)? 3:0;  
		}
	}
	printf("100 100\n"); 
	fo(i,100){
		fo(j,100) putchar(s[i][j]); 
		puts(""); 
	}
	return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include <cmath>
using namespace std;
int main(){
	int N,X;
	cin>>N;
	X=(int)(N/1.08);
	for(int i=X-1;i<=X+1;i++){
		if(floor(i*1.08)==N){cout<<i;return 0;}
	}
	
	cout<<":(";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

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

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

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

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

void solve() {
  inl(N);
  vll a(3 * N);
  rep(i, 3 * N) cin >> a[i];

  vll plus(N + 1, 0LL);
  plus[0] = accumulate(&a[0], &a[N], 0LL);
  priority_queue<ll, vll, greater<ll>> que;
  rep(i, N) que.push(a[i]);
  rep(i, N) {
    que.push(a[N + i]);
    auto min = que.top();
    que.pop();
    plus[i + 1] = plus[i] + a[N + i] - min;
  }

  vll minus(N + 1, 0LL);
  minus[0] = accumulate(&a[2 * N], &a[3 * N], 0LL);
  priority_queue<ll> que2;
  rep(i, N) que2.push(a[2 * N + i]);
  rep(i, N) {
    que2.push(a[2 * N - i - 1]);
    auto max = que2.top();
    que2.pop();
    minus[i + 1] = minus[i] + a[2 * N - i - 1] - max;
  }

  ll ret = plus[0] - minus[0];
  rep(i, N + 1) {
    auto diff = plus[i] - minus[N - i];
    if (diff > ret)
      ret = diff;
  }

  out(ret);
}


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

int main() {
	int a, b;
	cin >> a >> b;
	if (a < b) {
		cout << "a < b" << endl;
	} else if (a > b) {
		cout << "a > b" << endl;
	} else {
		cout << "a == b" << endl;
	}

	return 0;
}


Measured memory_bytes: 3076
import java.util.Scanner;

public class Main {
    static final long MOD = 1000000007;
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        long L = scanner.nextInt();
        long R = scanner.nextInt();
        if ((R - L) >= 1000) {
            System.out.println(0);
            return;
        }
        long ans = 1000000;
        for (long i = L; i < R; i++) {
            for (long j = i+1; j <= R; j++) {
                ans = Math.min(ans, (i*j) % 2019L);
            }
        }
        System.out.println(ans);
    }
}


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

int n;
int a[200010];
int k[200010];

int main () {

	cin >> n;
	for (int i = 0; i < n; i ++) cin >>a[i];
	int sol = 0;
	for (int i = 0; i < n; i ++) {
		k[ a[i] ] = k[ a[i]-1 ] + 1;
		sol = max(sol, k[ a[i] ]);
	}
	cout << n - sol;

	return 0;
}

Measured memory_bytes: 1792
import itertools
from typing import List


def main():
    h, w, k = map(int, input().split())
    c = []
    for _ in range(h):
        c.append(list(input()))

    print(hv(c, h, w, k))


def hv(c: List[List[str]], h: int, w: int, k: int) -> int:
    ret = 0
    for comb_h in itertools.product((False, True), repeat=h):
        for comb_w in itertools.product((False, True), repeat=w):
            cnt = 0
            for i in range(h):
                for j in range(w):
                    if comb_h[i] and comb_w[j] and c[i][j] == '#':
                        cnt += 1
            if cnt == k:
                ret += 1
    return ret


if __name__ == '__main__':
    main()


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int x, a; cin >> x >> a;
    if(x < a) cout << 0 << endl;
    else cout << 10 << endl;

    return 0;
}


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

using namespace std;
using ll = long long;

void solve(){
	int n;
	cin >> n;
	vector<int> value(n),cost(n),diff(n);
	for(int i=0;i<n;++i) cin >> value[i];
	for(int i=0;i<n;++i) cin >> cost[i];
	for(int i=0;i<n;++i) diff[i] = value[i] - cost[i];
	int ans = 0;
	for(int i=0;i<n;++i)
		if(diff[i] > 0)
			ans+=diff[i];
	cout << ans << '\n';
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--){ 
		solve();
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n, p, q;
  cin >> n >> p >> q;
  vector<ll> c(n);
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    sum += c[i];
    c[i] += i * p;
  }
  sort(c.rbegin(), c.rend());
  vector<ll> s(n + 1);
  for (int i = 0; i < n; i++) s[i + 1] = s[i] + c[i];
  ll ans = sum;
  for (ll i = 1; i <= n; i++) {
    ll temp = (p * q + p * (q + 2 * (i - 1))) * i / 2;
    temp += s[n - i];
    temp -= n * (n - 1) / 2 * p;
    ans = max(ans, temp);
  }
  cout << ans << endl;
  return 0;
}



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

ll MAX = 10e6;
vector<bool> isPrime(MAX + 1, true);
int exist[1000001];

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

    bool pairwise = true;
    bool setwise = true;

    rep(i, 1000001) exist[i] = 0;
    rep(i, N)++ exist[A[i]];

    for (int i = 2; i < 1000001; ++i) {
        int cnt = 0;
        cnt += exist[i];
        if (isPrime[i]) {
            for (int j = i * 2; j < 1000001; j += i) {
                isPrime[j] = false;
                cnt += exist[j];
            }
        }
        if (cnt > 1) pairwise = false;
        if (cnt == N) setwise = false;
    }
    if (pairwise) {
        cout << "pairwise coprime" << endl;
    } else if (setwise) {
        cout << "setwise coprime" << endl;
    } else
        cout << "not coprime" << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

ll n,k;

int main(){
	cin >> n >> k;
	vector<ll> vl(n,0);
	rep(i,n)cin >> vl[i];
	sort(ALL(vl));
	ll ans = INF;
	rep(i,n-k+1){
		ans = min(ans,vl[i+k-1]-vl[i]);
	}
	cout << ans << endl;
}

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

int main(){
    int n;
    cin>>n;
    set<string> st;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        st.insert(s);
    }
    cout<<st.size()<<endl;
}

Measured memory_bytes: 19252
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(void)
{
	int n,i;
	int k=0;
	scanf("%d",&n);

	char s[n][11];
	for(i=0;i<n;i++){
		scanf("%s",&s[i]);
	}
	qsort(s,n,11,strcmp);
	for(i=0;i<n-1;i++){
		if(strcmp(s[i],s[i+1])!=0) k++;
	}

	printf("%d\n",k+1);
	return 0;
}


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

int main(){
  string s;
  int n,ans=0;
  cin>>s;
  map<char,int> mp;
  for(int i=0;i<s.size();i++) mp[s.at(i)]++;
    
  if(mp.size()==2 && mp[s.at(0)]==2) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
#include <cstdio>
     
    int main() {
    	int a, b, c, d;
    	scanf("%d %d", &a, &b);
    	c=a*b;
    	d=2*(a+b);
    	printf("%d %d\n",c, d);
    	
    	return 0;
    }


Measured memory_bytes: 2688
import bisect
a,b,q = map(int,input().split())
s = list(int(input()) for _ in range(a))
t = list(int(input()) for _ in range(b))
x = list(int(input()) for _ in range(q))

s.insert(0,-10**18)
s.append(10**18)
t.insert(0,-10**18)
t.append(10**18)

for i in range(q):
    insert_xs = bisect.bisect_left(s,x[i])
    insert_xt = bisect.bisect_left(t,x[i])
    answer = 10**18
    for k1 in range(2):
        for k2 in range(2):
            distant = abs(s[insert_xs - k1]-x[i]) + abs(s[insert_xs - k1]-t[insert_xt - k2])
            if distant < answer:
                answer = distant
            distant = abs(t[insert_xt - k2]-x[i]) + abs(t[insert_xt - k2]-s[insert_xs - k1])
            if distant < answer:
                answer = distant
    print(answer)


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

using std::max; using std::swap; using std::abs; using std::priority_queue; using std::queue; using std::bitset; using std::make_tuple; 
using std::istream; using std::ostream; using std::fixed; using std::greater; using std::tuple; using std::tie; using std::make_pair;
using std::cout; using std::cerr; using std::endl; using std::lower_bound; using std::upper_bound; using std::deque; using std::min; 
using std::map; using std::string; using std::fill; using std::copy; using std::sort; using std::unique; using std::unordered_set; 
using std::multiset; using std::nth_element; using std::min_element; using std::max_element; using std::vector; using std::set; 
using std::unordered_map; using std::pair; using std::next_permutation; using std::reverse; using std::rotate; using std::cin; 
using std::iota; using std::function; using std::shuffle; using std::iter_swap;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

int const INF = 100 + (int) 1e9;
ll const INFL = 100 + (ll) 1e18;
ld const PI = 3.141592653589793238462643L;
std::mt19937 mt19937(960172);

ll rnd(ll x, ll y) { static auto gen = std::bind(std::uniform_int_distribution<ll>(), mt19937); return gen() % (y - x + 1) + x; }
bool is_prime(ll x) { if (x <= 1) return 0; for (ll y = 2; y * y <= x; ++y) if (x % y == 0) return 0; return 1; }
ll sqr(int a) { return (ll) a * a; } ld sqr(ld a) { return a * a; } ll sqr(ll a) { return a * a; }
ll gcd(ll a, ll b) { while (b > 0) { ll t = a % b; a = b; b = t; } return a; }




void solve() {
    
    int n;
    cin >> n;
    
    ll a = 1, b = 1;
    
    for (int i = 0; i < n; ++i) {
        ll x, y;
        cin >> x >> y;
        
        ll c1 = (a + x - 1) / x;
        ll c2 = (b + y - 1) / y;
        ll c = max(c1, c2);
        a = x * c;
        b = y * c;
    }

    cout << a + b << '\n';
}



int main() {
    
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    
    cout.precision(15);
    cout << fixed;
    cerr.precision(6);
    cerr << fixed;
    
    int tcn = 1;
    for (int tn = 1; tn <= tcn; ++tn)
        solve();
    
#ifdef LOCAL
    cerr << "time: " << (ll) clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int mod = 1E9 + 7;
const int inf = 1 << 29;

int main() {
  int n;
  cin >> n;
  ll max = 1e18;
  ll a, ans = 1;
  bool ng = false;
  rep(i, n) {
    cin >> a;
    if (a == 0) {
      cout << 0 << endl;
      return 0;
    }
    if (ng || max / ans < a) {
      ng = true;
    }
    ans *= a;
  }
  if (ng || ans > max)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}

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

int main()
{
    int n,p,temp=0;
    cin>>n;
    getchar();
    string s,a,b;
    cin>>s;

    p=(s.size()/2);
    //cout<<p<<endl;


    if(s.size()%2!=0)
        {
            cout<<"No"<<endl;
            return 0;
        }
    else
    {
        for(int i=0;i<s.size()/2;i++)
        {
            if(s[i]==s[p])
            {
                p++;
                continue;
            }
            else
            {
                temp=1;
                break;
            }
        }
    }
    if(temp==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
// AOJ DSL_4_A Union of Rectangles
// 2018.5.14 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define MAX_N 2005
#define MAX   4005

typedef struct { int x1, y1, x2, y2; } TBL;
TBL tbl[MAX_N];

int x[MAX], xs;
int y[MAX], ys;
int xx[MAX], yy[MAX];

short s[2][MAX];
short hi[MAX];
short a[MAX][MAX][2];

int cmp(int *a, int *b) { return *a - *b; }

int bsch(int *a, int x, int r)
{
	int m, l = 0;

    while (l < r) {
        m = (l + r) >> 1;
		if (a[m] == x) return m;
        if (a[m] < x) l = m + 1; else r = m;
    }
	return l-1;
}

int uniq(int *a, int n)
{
	int i, j;
	
	for (i = 0, j = 1; j < n; j++) {
		while (j < n && a[j] == a[i]) j++;
		if (j < n) if (++i != j) a[i] = a[j];
	}
	return i+1;
}

int main()
{
	int N, i, j, x1, y1, x2, y2, k1, k2;
	long long ans;

	N = in(); xs = ys = 0;
	for (i = 0; i < N; i++) {
		tbl[i].x1 = x1 = in(), tbl[i].y1 = y1 = in();
		tbl[i].x2 = x2 = in(), tbl[i].y2 = y2 = in();
		x[xs++] = x1, x[xs++] = x2;
		y[ys++] = y1, y[ys++] = y2;
	}
	qsort(x, xs, sizeof(int), cmp); xs = uniq(x, xs);
	qsort(y, ys, sizeof(int), cmp); ys = uniq(y, ys);

	for (j = 0, i = 0; i < N; i++) {
		x1 = bsch(x, tbl[i].x1, xs);
		x2 = bsch(x, tbl[i].x2, xs);
		y1 = bsch(y, tbl[i].y1, ys);
		y2 = bsch(y, tbl[i].y2, ys);
		xx[x1] = tbl[i].x1, xx[x2] = tbl[i].x2;
		yy[y1] = tbl[i].y1, yy[y2] = tbl[i].y2;

		a[y1][hi[y1]][0] = x1, a[y1][hi[y1]++][1] = 1;
		a[y1][hi[y1]][0] = x2, a[y1][hi[y1]++][1] = -1;
		a[y2][hi[y2]][0] = x1, a[y2][hi[y2]++][1] = -1;
		a[y2][hi[y2]][0] = x2, a[y2][hi[y2]++][1] = 1;
	}

	ans = 0;
	for (k1 = 1, k2 = 0, j = 0; j < ys; j++, k1 = k2, k2 = !k2) {
		memset(s[k2], 0, sizeof(s[k2]));
		for (i = 0; i < hi[j]; i++) s[k2][a[j][i][0]] += a[j][i][1];
		for (i = 0; i < xs; i++) {
			s[k2][i+1] += s[k2][i];
			s[k2][i] += s[k1][i];
		}
		for (i = 0; i < xs; i++) if (s[k2][i]) {
			ans += (long long)(xx[i+1]-xx[i])*(long long)(yy[j+1]-yy[j]);
		}
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 18012
X, K, D = map(int, input().split())

ans = X
m = min(K, abs(X) // D) * D
if X < 0:
    ans += m
else:
    ans -= m
K -= abs(X) // D
if K > 0:
    if K % 2 == 1:
        if ans < 0:
            ans += D
        else:
            ans -= D

print(abs(ans))

Measured memory_bytes: 9184
package main

import "fmt"

func main() {
	s := make([]int, 5)
	for i := range s {
		fmt.Scan(&s[i])
	}
	var k int
	fmt.Scan(&k)

	for i := range s {
		for j := i + 1; j < 5; j++ {
			if s[j]-s[i] > k {
				fmt.Println(":(")
				return
			}
		}
	}
	fmt.Println("Yay!")
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int d[100];

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

	int N; cin >> N;
	for (int i = 0; i < N; i++) cin >> d[i];
	ll sum = 0LL;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) sum += d[i] * d[j];
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
def solve():
    alpha = "abcdefghijklmnopqrstuvwxyz"
    inp1, inp2 = input(), input()
    sz = dict(zip(list(alpha), [0] * 26))
    tz = dict(zip(list(alpha), [0] * 26))
    for i in range(len(inp1)):
        sz[inp1[i]] += 1
        tz[inp2[i]] += 1
        if sz[inp1[i]] != tz[inp2[i]]:
            print("No")
            return
    print("Yes")


solve()


Measured memory_bytes: 42164
#include <iostream>
#include <string>
using namespace std;
int main(){
	int n,m;
	while(1){
		cin >> n ; if(!n) break;
		cin >> m ;
		string str="I"; int cnt=0;
		for(int i=0;i<n;i++) str+="OI";
		string comp,ptr; cin >> comp ;
		for(int i=0;i<m;i++){
			ptr=comp.substr(i,str.size());
			if(ptr==str) cnt++;
		};
		cout << cnt << '\n' ;
	};
}

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

int main(){
    int N;
    long long A[200200];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    long long L[200200], R[200200]; 
    //L:左からの累積和
    L[0]=0; R[0]=0;
    for(int i=0; i<N; i++){
        L[i+1] = L[i] + A[i];
        R[i+1] = R[i] +A[N-i-1];
    }

    const long long INF = pow(10,13); 
    long long min_dif=INF;
    int d[2];
    d[0]=0; d[1]=-1;
    long long mmin, mmax;
    mmin = INF;
    mmax = 0;
    for(int i=-1; i<N;i++){

        long long l= (L[i+1]+1)/2 ;//見つけたい値
        long long r= (R[N-i-1]+1)/2;

        long long *a = lower_bound(L,L+i+1,l);
        long long *b = lower_bound(R,R+N-i-1,r);

        for(int k=0; k<2; k++){
            for(int j=0; j<2; j++){
                long long * t=(a+d[k]);
                long long * s=(b+d[j]);
                if(  t-L >=0 && s-R>=0 ){//ダメじゃないとき
                long long P = *t; 
                long long Q = *s;
                long long T = L[i+1]-*t;
                long long S = R[N-i-1]-*s;
                long long E = max(max(P,Q), max(T,S)) - min( min(P,Q),min(T,S) );
                if(mmin > E){
//                    cout << P << T << S << Q;
//                    cout << t-L << " " << i+1 << " " << N-(s-R)-1 << endl;
                    mmin = E;
                }
                }
            }
        }
    }
    cout << mmin <<endl;
}

Measured memory_bytes: 4992
#include <stdio.h>

#define N 10000

int Search(int [],int, int);

int main()
{

  int i, S[N], n, q, count = 0, T;

  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%d", &S[i]);

  scanf("%d",&q);
  
  for(i = 0; i < q; i++) {
    scanf("%d",&T);
      if( Search(S, n, T) ) count++;
	 }
  
    printf("%d\n", count);

    return 0;
}


int Search(int S[], int n, int key)
{
  int i = 0;
  S[n] = key;
  while(S[i] != key){
    i++;
  }
  return i != n;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

    int n;
    cin >> n;
    VI a(n);
    VI r(n+1);
    REP(i,n){
        cin >> a[i];
        r[a[i]] = i+1;
    }
    for(int i=1; i < n+1; i++)cout << r[i] << " ";
    return 0;
}

Measured memory_bytes: 1536
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = INTINF;
	int tmp;
	ll h, w;
	cin >> h >> w;
	ll a, b, c;
	REP1(i, h-1){
		a = i * w;
		if((h-i) %2 == 0 || w % 2 == 0){
			b = (h-i)*w/2;
			c = (h-i)*w/2;
		}
		else{
			b = ((h-i)*w-min(h-i, w))/2 +min(h-i, w);
			c = ((h-i)*w-min(h-i, w))/2;
		}
		ans = min(ans, max({a,b,c}) - min({a,b,c}));
	} 
		REP1(i, w-1){
		a = i * h;
		if((w-i) %2 == 0 || h % 2 == 0){
			b = (w-i)*h/2;
			c = (w-i)*h/2;
		}
		else{
			b = ((w-i)*h-min(w-i, h))/2 +min(w-i, h);
			c = ((w-i)*h-min(w-i, h))/2;
		}
		//cout << a << " " << b << " " << c << endl;
		ans = min(ans, max({a,b,c}) - min({a,b,c}));
	} 
	cout << ans << endl;
}

Measured memory_bytes: 3632
n=int(input())
d=[]
for i in range(n):
    x,l=map(int,input().split())
    d.append((x-l,x+l))
d.sort()
ans=1
chk=d[0][1]
for i in d:
    if i[0]>=chk:
        ans+=1
        chk=i[1]
    else:
        chk=min(chk,i[1])
print(ans)

Measured memory_bytes: 56152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int K,A,B;
  cin>>K;
  cin>>A>>B;
  
  int sw=0;
  
  for(int i=A;i<B+1;i++){
    if(i%K==0){
      sw=1;
    }
  }
  
  if(sw==1){
    cout<<"OK"<<endl;
  }else{
    cout<<"NG"<<endl;
  }
    
}



Measured memory_bytes: 3632
#include <algorithm>
#include <vector>
#include <cstdio>
#include <iostream>
#include <queue>
using namespace std;
typedef long long int lli;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
int N,Q;
vector<int> children[100000];
int parent[100000];
char marked[100000],s[2];
int stack[100000],stc,a,b,init[100000];
char stack2[100000];
class UnionFind{
private:
	vector<int> par;vector<int> rank;
public:
	UnionFind(int n){
		par=vector<int>(n);rank=vector<int>(n,0);
		for(int i=0;i<n;i++){
			par[i]=i;
		}
	}
	int find(int x){
		if(par[x]==x)
			return x;
		else
			return par[x] = find(par[x]);
	}
	void unite(int x,int y){
		x=find(x);y=find(y);
		if(x==y)return;
		if(rank[x]<rank[y]){
			par[x]=y;
		} else{
			par[y]=x;
			if(rank[x]==rank[y]) rank[x]++;
		}
	}
	inline bool same(int x,int y){
		return find(x)==find(y);
	}
};
void bfs(int k,int value=0){
	queue<int> k_,value_;
	k_.push(k);value_.push(value);
	while(k_.empty()==false){
		value=value_.front();value_.pop();
		k=k_.front();k_.pop();

		if(marked[k]==true)value=k;
		init[k]=value;
		REP(i,children[k].size()){
			k_.push(children[k][i]);
			value_.push(value);
		}
	}
}
int main(){
	for(;;){
		scanf("%d%d",&N,&Q);stc=0;
		if(N==0)break;
		REP(i,N){
			children[i].clear();
			marked[i]=false;
		}
		REP(i,N-1){
			scanf("%d",&b);
			children[--b].push_back(i+1);
			parent[i+1]=b;
		}
		marked[0]=true;
		REP(i,Q){
			scanf("%s%d",s,&a);
			--a;
			if(s[0]=='M'&&marked[a])continue;
			if(s[0]=='M'){
				marked[a]=1;
			}
			stack2[stc]=s[0];
			stack[stc++]=a;
		}
		bfs(0,0);
		UnionFind uf(N);
		init[0]=0;
		REP(i,N){
			uf.unite(i,init[i]);
		}
		long long int ans=0;
		for(int i=--stc;i>=0;i--){
			if(stack2[i]=='Q'){
				ans+=init[uf.find(stack[i])]+1;
			}else{
				int v=init[uf.find(parent[stack[i]])];
				uf.unite(stack[i],parent[stack[i]]);
				init[uf.find(stack[i])]=v;
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 9392
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,m,k,ans,sum,nxt[N],A[N],B[N];
char s[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,nxt=0;char c=gc();
    while(!isdigit(c)){if(c=='-')nxt=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(nxt)return -ret;return ret;
}
signed main()
{
	n=read();m=read();k=read();
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='x')
		{
			nxt[i]=nxt[i-1];
			A[i]=A[i-1];
			continue;
		}
		if(i>=nxt[i-1])
		{
			nxt[i]=i+k+1;
			A[i]=A[i-1]+1;
		}
		else{
			nxt[i]=nxt[i-1];
			A[i]=A[i-1];			
		}
	}
	for(int i=n;i;i--)
	{
		if(s[i]=='x')
		{
			B[i]=B[i+1];
			continue;
		}
		B[i]=B[i+k+1]+1;
	}
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='x')continue;
		int x=max(nxt[i-1],i+1);
		if(A[i-1]+B[x]<m)printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 11008
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main() {

    int n;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    int ans=0;
    while(1){
        int sum=0;
        rep(i,n)sum+=v[i];
        if(sum==0)break;

        int minpos=0,minval=INF;
        rep(i,n){
            if(v[i]>0&&minval>v[i]){
                minval=v[i];
                minpos=i;
            }
        }
        int water=v[minpos];
        for(int i=minpos+1;i<n;i++){
            if(!v[i])break;
            v[i] = max(0,v[i]-water);
        }
        for(int i=minpos;i>=0;i--){
            if(!v[i])break;
            v[i] = max(0,v[i]-water);
        }
        ans+=minval;
        // dump(v);
    }
    fin(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <set>
#include <algorithm>
#include <map>
using namespace std;

bool MMYY(string& s){
    int m = (int)s[1]  - 48 + 10 * ((int)s[0] - 48);

    return (m <= 12 && m > 0);

}

bool YYMM(string& s){
    int m = (int)s[3]  - 48 + 10 * ((int)s[2] - 48);
    return (m <= 12 && m > 0);
}


int main()
{
    string s;
    cin >> s;
    if(MMYY(s) && YYMM(s)) cout << "AMBIGUOUS";
    else if(MMYY(s)) cout << "MMYY";
    else if(MMYY(s) && YYMM(s)) cout << "AMBIGUOUS";
    else if(YYMM(s)) cout << "YYMM";
    else cout << "NA";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;
 
signed main(){
    int N;cin>>N;
    map<int,int>memo;
    REP(i,N){
        int a;cin>>a;
        memo[-a]++;
    }
    int ans=0;
    bool check=false;
    for(auto v:memo){
        if(v.second>=4&&!check){
            ans=v.first*v.first;
        }
        else{
            if(v.second>=2){
                if(!check){
                  	ans=v.first;
                  	check=true;
                }
                else ans*=v.first;
            }
        }
        if(ans>0)break;
    }
    if(ans<=0)ans=0;
    cout<<ans<<endl;
}


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


int main(){
    int64_t N;
    int64_t ans = 0;
    cin >> N;
    vector<int64_t> cnt(N+1,0);

    for(int64_t i = 1; i <= N; i++){
        for(int64_t j = 1; i*j <=N; j++){
            cnt.at(i*j)++;
        }
    }
    for(int64_t i = 1; i <= N; i++){
        ans += cnt.at(i)*i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 81396
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main() {
	int n;
	string s;
	cin >> n >> s;
	int w[300001], e[300001];
	w[0] = 0; e[n] = 0;
	for (int i = 0;i < n;i++) {
		if (s[i] == 'W') w[i+1] = w[i] + 1;
		else w[i + 1] = w[i];
	}
	for (int i = n - 1;i >= 0;i--) {
		if (s[i] == 'E') e[i] = e[i + 1] + 1;
		else e[i] = e[i + 1];
	}
	int ans = 300001;
	for (int i = 0;i < n;i++) {
		ans = min(ans, (w[i] + e[i+1]));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int mod=1e9+7;

int main() {
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  vector<int>l(N),r(N);
  int g=0;
  for(int i=1;i<N;i++){
   g= __gcd(g,A[i-1]);
   l[i]=g;
  }
  g=0;
  for(int i=N-2;i>=0;i--){
    g=__gcd(g,A[i+1]);
    r[i]=g;
  }
  int MAX=0;
  for(int i=0;i<N;i++){
    chmax(MAX,__gcd(l[i],r[i]));
  }
  cout<<MAX<<endl;
  return 0;  
}

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

typedef long long int ll;

int main()
{
    string n;
    ll nc = 0;
    cin >> n;

    for(ll i = 0;i < n.size();i++){
        nc += n[i] - '0';
    }

    if(nc % 9 == 0){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    string s; cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size()/2; i++) {
        if (s[i] != s[s.size()-1-i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>  
using namespace std; 
// Recursive function to return gcd of a and b  
class gfg 
{ 
 public : long long gcd(long long a, long long b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
  
   
// Function to return LCM of two numbers  
  long long lcm(long long a, long long b)  
 {  
    return (a*b)/gcd(a, b);  
 }  
} ; 
// Driver program to test above function  
int main()  
{  
    gfg g; 
    long long  a,b;
  cin>>a>>b;
    cout<<g.lcm(a, b);  
    return 0;  }


Measured memory_bytes: 256
import java.util.*;
import java .io.*;
public class Main {
    static int size;
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int array[] = new int[n + 1];
        st = new StringTokenizer(br.readLine());
        for (int i = 1; i <= n; i++) {
            array[i] = Integer.parseInt(st.nextToken());
        }
        st = new StringTokenizer(br.readLine());
        int cnt[] = new int[n + 2];
        for(int i = 1;i <= n;i++){
            cnt[i] = Integer.parseInt(st.nextToken());
        }
        boolean mark[] = new boolean[n + 1];
        mark[1] = true;
        for(int i = 2;i <= n;i++)
            if(array[i] > array[i - 1])mark[i] = true;

        for(int i = n - 1;i >= 1;i--) {
            if(mark[i]){
                if(cnt[i] < array[i]){
                    System.out.print("0");
                    return;
                }
            }
            if (cnt[i] > cnt[i + 1]) {
                mark[i] = true;
                if(array[i] < cnt[i]){
                    System.out.print("0");
                    return;
                }
            }
        }
        if(mark[n] && array[n] != cnt[n]){
            System.out.print("0");
            return;
        }
        mark[n] = true;
        long ans = 1;
        int mod = 1000_000_000 + 7;
        for(int i = 1;i <= n;i++){
            if(mark[i])continue;
            ans *= Math.min(cnt[i],array[i]);
            ans %= mod;
        }
        System.out.print(ans);
    }
}

Measured memory_bytes: 31976
import bisect
import math
import sys
from collections import defaultdict
from copy import copy
from heapq import heapify, heappop, heappush, heapreplace
from operator import itemgetter
from queue import LifoQueue, PriorityQueue, Queue

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N, M = map(int, readline().split())
    S, T = readlines()
    
    # NとMの最大公約数が1ならば、最初の文字が合っていれば構成可能
    n, m = copy(N), copy(M)
    while m != 0:
        n, m = m, n%m
    if n == 1:
        if S[0] == T[0]:
            print(N*M)
        else:
            print(-1)
            
    # NとMの最大公約数が1でなければ、ループして被る場所が同じになることを確認する必要がある
    else:
        L = N * M // n
        LN = L // N
        LM = L // M
        
        # LNとLMの最小公倍数をループして文字列一致を確認
        LCM = M // n * N // n
        for i in range(0, L, LCM):
            if S[i // LN] != T[i // LM]:    
                print(-1)
                sys.exit()

        print(L)


if __name__ == "__main__":
    main()

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

int main() {
    int N, K;
    int res = 0;
    cin >> N >> K;

    for (int i = 0; i < N; i++) {
        int pos;
        cin >> pos;

        if ((K - pos) >= pos) {
            res += pos*2;
        }
        else {
            res += (K - pos)*2;
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
#define INF ((1LL<<62LL) - 1)

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    double d,t,s; cin >> d >> t >> s;

    if(s>= (d/t)){
        cout << "Yes\n";
    } else cout << "No\n";


}


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

int main() {
  
  int a, b, k;

  scanf("%d %d %d", &a, &b, &k);
  
  set<int> s;

  for(int j = a; j <= a + k - 1; j++){
    if(j <= b){
      s.insert(j);
    }
  }
  for(int i = b - k + 1; i <= b; i++){
    if(i >= a){
      s.insert(i);
    }
  }

  for(auto itr = s.begin(); itr != s.end(); itr++){
    cout << *itr << endl;
  }
}



Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N,A,B,C=map(int,input().split())

def zet(l,m,n):
    return abs(A-l)+abs(B-m)+abs(C-n)

def saiki(x,y,z,n,count,ans):
    if n==N:
        if x==0 or y==0 or z==0:
            return 10**18
        else:
            return min(zet(x,y,z),zet(x,z,y),zet(y,x,z),zet(y,z,x),zet(z,x,y),zet(z,y,x))+count*10
    else:
        ans=min(saiki(x+l[n],y,z,n+1,count+1 if x!=0 else count,ans),ans)
        ans=min(saiki(x,y+l[n],z,n+1,count+1 if y!=0 else count,ans),ans)
        ans=min(saiki(x,y,z+l[n],n+1,count+1 if z!=0 else count,ans),ans)
        ans=min(saiki(x,y,z,n+1,count,ans),ans)
    return ans

l=[]
for _ in range(N):
    l.append(int(input()))

print(saiki(0,0,0,0,0,10**18))



Measured memory_bytes: 3192
#include<stdio.h>
#define M 250

int parent(int i){
    return i/2;
}
int Left(int i){
    return 2*i;
}
int Right(int i){
    return 2*i+1;
}

int main(void){
    int i;
    int n;
    int heap[M];
    scanf("%d",&n);
    for(i=1;i<n+1;i++){
        scanf("%d",&heap[i]);
    }
    
    for(i=1;i<n+1;i++){
        if(i==1)printf("node %d: key = %d, ",i,heap[i]);
        else if(i>1)printf("node %d: key = %d, parent key = %d, ",i,heap[i],heap[parent(i)]);
        
        if(Left(i)<=n)printf("left key = %d, ",heap[Left(i)]);
        if(Right(i)<=n)printf("right key = %d, ",heap[Right(i)]);
        printf("\n");
            
            }
                             return 0;
}

Measured memory_bytes: 600
n=int(input())
a=input()
b=input()
if a[0]==b[0]:
  c=3
  i=1
  d=0
else:
  c=6
  i=2
  d=1

while i<n:
  if a[i]==b[i]:
    if d==0:
      c=(c*2)%(10**9+7)
    else:
      d=0
  else:
    i+=1
    if d==0:
      c=(c*2)%(10**9+7)
      d=1
    else:
      c=(c*3)%(10**9+7)
  i+=1
print(c)
  
  

Measured memory_bytes: 61928
import java.util.*;
class Main {
	public static void main(String[] args) {
		for(int i = 1; i <= 9; i++) {
			for(int j = 1; j <= 9; j++) {
				System.out.println(i + "x" + j + "=" + (i * j));
			}
		}
	}
}

Measured memory_bytes: 23872
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(X, Y):
    for i in range(X+1):
        j = X - i
        if 2*i + 4*j == Y:
            return 'Yes'
    return 'No'


def main():
    X, Y = read_int_n()
    print(slv(X, Y))


if __name__ == '__main__':
    main()


Measured memory_bytes: 76912
n=int(input())
arr=list(map(int,raw_input().split()))

def solve(arr,n):
    if arr==sorted(arr):
        return 0
    ans=0
    m=arr[0]
    for i in range(1,n):
        if arr[i]<m:
            ans+=m-arr[i]
        else:
            m=arr[i]
    return ans
print(solve(arr,n))

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

int main(){
  double t[1000],s[1000];
  int i,j,n,num[1000];

  j=0;
  while(scanf("%d,%lf,%lf",&num[j],&t[j],&s[j])!=EOF){
    j++;
  }


  for(i=0;i<j;i++){

    // cout << t[i]/(s[i]*s[i])<<endl;
    if(t[i]/(s[i]*s[i]) >= 25.0)cout << num[i] << endl;

  }



}

Measured memory_bytes: 0
n = int(input())

ls = []
for _ in range(n):
  ls.append(input())
ls = sorted(ls)


ans =[ [ls[0],1] ]
tmp = ls[0]
for i in range(1,n):
  if ls[i] == tmp:
    ans[-1][1] += 1
  else:
    ans.append( [ls[i],1] )
    tmp = ls[i]
ans = sorted(ans, key = lambda x: (-1*x[1],x[0]))

m = ans[0][1]
for i in range(len(ans)):
  if ans[i][1] == m:
    print(ans[i][0])
  else:
    break

Measured memory_bytes: 54144
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
long long MIN(long long a,long long b){
    return a<b?a:b;
}
int main()
{   
    long long h,n;
    scanf("%lld%lld",&h,&n);
    long long a[n],b[n];
    for(int i=0;i<n;i++){
        scanf("%lld%lld",&a[i],&b[i]);
    }
    long long dp[100001];
    for(int i=0;i<=100000;i++){
        dp[i]=1145141919810;
    }
    long long ans=1145141919810;
    dp[0]=0;
    for(int i=0;i<=h;i++){
        for(int j=0;j<n;j++){
            if(i+a[j]>=h){
                ans=MIN(ans,dp[i]+b[j]);
            }else{
                dp[i+a[j]]=MIN(dp[i+a[j]],dp[i]+b[j]);
            }
        }
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 896
from itertools import *
n,*s=open(0).read().split()
u=[[min(accumulate(chain([0],t),lambda a,b: a+(1 if b=="(" else -1))),2*t.count("(")-len(t)] for t in s]
m=0
for c,d in chain(sorted([x for x in u if x[1]>=0])[::-1],sorted([x for x in u if x[1]<0],key=lambda z:z[0]-z[1])):
    if m+c<0:print("No");break
    m+=d
else:print("No" if m else "Yes")

Measured memory_bytes: 275304