akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

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

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


string S;

void input() {
	cin>>S;
}

void solve() {
	if(S.find("AC")==string::npos) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
const int INF = 1e9;
using namespace std;
typedef long long ll;


int main()
{
    ll n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;
    ll k = min({a,b,c,d,e});
    if(n % k == 0){
        cout << n / k + 4 << endl;
    }else{
        cout << n / k + 5 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define File freopen("in.in","r",stdin);freopen("out.out","w",stdout)
#define ll long long
ll a[(int)1e5+10]={0};
ll dp[(int)1e5+10];
ll n;
ll solve(int i){
    if(i+1==n)return 0;
    if(i>n)return 1e9;
    ll &re = dp[i];
    if(re!=-1)return re;
    return re = min(abs(a[i]-a[i+1])+solve(i+1),abs(a[i]-a[i+2])+solve(i+2));
}
int main(){
    fastIO;
    //File;
    int _(1);
    //cin >> _;
    while (_--){
        memset(dp,-1,sizeof dp);
        cin>>n;
        memset(a,0,sizeof a);
        for(int i = 0 ; i < n ; i++)cin>>a[i];
        cout<<solve(0)<<endl;
    }
}


Measured memory_bytes: 4224
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        long sum = k;
        for (int i = 1; i < n; i++) {
            sum *= (k-1);
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 23764
import java.util.*;
public class Main {
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int min = -1, max = 0;
		for(int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if(c == 'A' && min < 0) min = i;
			else if(c == 'Z' && i > max) max= i;
		}
		System.out.println(max - min + 1);
	}
 
}

Measured memory_bytes: 26228
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define ull unsigned long long
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define eps 1e-9
#define P pair<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()

void YES() { cout << "YES\n"; }
void NO() { cout << "NO\n"; }
void Yes() { cout << "Yes\n"; }
void No() { cout << "No\n"; }
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

int main() {
	int n;
	ll ans = 1, a;

	cin >> n;
	while (n--) {
		cin >> a;
		ans = lcm(ans, a);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
from sys import stdin

def main():
    s = [int(x) if x != "?" else "?" for x in stdin.readline().rstrip()]

    dp = [1] + [0]*12
    mod = 10 ** 9 + 7
    mul = 1
    s.reverse()

    for i in (range(0,len(s))):
        next_dp = [0]*13
        if s[i] == "?":
            for k in range(0, 10):
                for j in range(0, 13):
                    next_dp[(k*mul+j)%13] += dp[j]
                    next_dp[(k*mul+j)%13] %= mod

        else:
            k = s[i]
            for j in range(0, 13):
                    next_dp[(k*mul+j)%13] += dp[j]
                    next_dp[(k*mul+j)%13] %= mod

        mul = mul * 10 % 13
        dp = next_dp

    print(dp[5])

if __name__ == '__main__':
    main()


Measured memory_bytes: 47468
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include <utility>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int n,flag=0;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];

    rep(i,n){
        if(a[i]%2==0 && a[i]%3!=0 && a[i]%5!=0)
            flag++;
    }

    if(flag==0)
        cout <<"APPROVED"<< endl;
    else
        cout << "DENIED"<< endl;
    return 0;
}

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

using namespace std;

namespace solve {

const int maxn = 200005;

int n, a[maxn], tree[maxn * 2];
int64_t sum = 0;

int cmp(int i, int j) { return a[i] <= a[j] ? i : j; }

int query(int l, int r) {
  int ans = l;
  for (l += n, r += n; l <= r; l = (l + 1) / 2, r = (r - 1) / 2) {
    if (l % 2 != 0) ans = cmp(ans, tree[l]);
    if (r % 2 == 0) ans = cmp(ans, tree[r]);
  }
  return ans;
}

void get_ans(int l, int r) {
  if (r < l) return;
  int pos = query(l, r);
  sum += 1LL * (pos - l + 1) * (r - pos + 1) * a[pos];
  get_ans(l, pos - 1);
  get_ans(pos + 1, r);
}

void solve() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    tree[n + i] = i;
  }
  for (int i = n - 1; i > 0; --i) tree[i] = cmp(tree[i * 2], tree[i * 2 + 1]);
  get_ans(0, n - 1);
  cout << sum << '\n';
}
}

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

  solve::solve();
}


Measured memory_bytes: 8832
#include <iostream>
#include <vector>
#include <algorithm>

std::vector<int> input_vector(int n)
{
	std::vector<int> v(n);
	for (int i = 0; i < n; i++)
	{
		std::cin >> v[i];
	}
	return v;
}

struct Kupon
{
	int x, y, c;
};

std::vector<Kupon> input_vector_kupon(int n)
{
	std::vector<Kupon> v(n);
	for (int i = 0; i < n; i++)
	{
		std::cin >> v[i].x >> v[i].y >> v[i].c;
	}
	return v;
}

int min(int l, int r)
{
	if (l < r)
	{
		return l;
	}
	else
	{
		return r;
	}
}

void hitachi2()
{
	int A, B, M;
	std::cin >> A >> B >> M;

	std::vector<int> a = input_vector(A);
	std::vector<int> b = input_vector(B);
	std::vector<Kupon> m = input_vector_kupon(M);

	int min_price = 5e5;

	for (size_t im = 0; im < M; im++)
	{
		int price = a[m[im].x-1] + b[m[im].y-1] - m[im].c;
		min_price = min(min_price, price);
	}

	int min_a = *std::min_element(begin(a), end(a));
	int min_b = *std::min_element(begin(b), end(b));
	min_price = min(min_price, min_a + min_b);

	std::cout << min_price;
}

int main()
{
	hitachi2();
}


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

class UnionFind{
private:
    vector<int> Parent;

public:
    
    UnionFind(int N){
        Parent=vector<int>(N,-1);
    }
    int root(int A){
        if(Parent[A]<0) return A;
        return Parent[A] = root(Parent[A]);
    }

    int size(int A){
        return -Parent[root(A)];
    }

    bool connect(int A,int B){
        A=root(A);
        B=root(B);
        if(A==B) return false;

        if(size(A)<size(B)) swap(A,B);
        Parent[A]+=Parent[B];
        Parent[B]=A;
        return true;
    }
};

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> A(M),B(M);
    for(int i=0;i<M;i++){
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }

    vector<long long> ans(M);
    ans[M-1] = (long long)N*(N-1)/2;

    UnionFind Uni(N);

    for(int i=M-1;i>=1;i--){
        ans[i-1] = ans[i];
        if(Uni.root(A[i]) != Uni.root(B[i])){
            ans[i-1]-=(long long)Uni.size(A[i])*Uni.size(B[i]);
            Uni.connect(A[i],B[i]);
        }
    }

    for(int i=0;i<M;i++) cout << ans[i] << endl;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

int main(){
    ll N, K; cin >> N >> K;
    vector<ll> h(N); REP(i, N) cin >> h[i];

    sort(all(h));

    // h[0]からK個分計算して、一番差が小さくなったペアを記録しておく
    ll res = 1000000007;
    REP(i, N - K + 1) {
        ll buff = h[i + K - 1] - h[i];
        if(res > buff) {
            res = buff;
        }

        if(res <= 0) {
            break;
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

ll cnt[10][10];
void solve(long long N){
  ll ans=0;
  FOR(i,1,N+1){
    ll l=i%10;
    ll ii=i;
    while(ii>=10){
      ii/=10;
    }
    ll r=ii;
    ++cnt[l][r];
  }
  FOR(i,1,10){
    FOR(j,1,10){
      ans+=cnt[i][j]*cnt[j][i];
    }
  }
  cout<<ans<<endl;
}

int main(){
  cout<<setprecision(1000);
  cin.tie(0);
  ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
import collections
import itertools

h, w = map(int, input().split())
maze = [list(input()) for _ in range(h)]

dis = [[-1] * w for _ in range(h)]
dis[0][0] = 0
que = collections.deque()
que.append((0, 0))


while que:
    py, px = que.popleft()
    for dy, dx in [(-1, 0), (0, -1), (1, 0), (0, 1)]:
        ny = py + dy
        nx = px + dx
        if 0 <= ny < h and 0 <= nx < w and dis[ny][nx] == -1 and maze[ny][nx] == ".":
            dis[ny][nx] = dis[py][px] + 1
            que.append((ny, nx))

if dis[h - 1][w - 1] == -1:
    print(-1)
else:
    cnt = 0
    for i, j in itertools.product(range(h), range(w)):
        if maze[i][j] == "#":
            cnt += 1
    print(h * w - cnt - dis[h - 1][w - 1] - 1)

Measured memory_bytes: 74156
//
//  main.cpp
//  Atcoder176
//
//  Created by Keita on 2020/08/22.
//  Copyright © 2020 Keita. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std ;

void doProblemA(){
    int x;
    cin >> x;
    if(x == 0){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

void doProblemB(){
    long long int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(max(a * c, a * d), max(b * c, b * d)) << endl;
}

int main(int argc, const char * argv[]){
    // insert code here...
    doProblemB();
    return 0;
}





Measured memory_bytes: 3168
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

f(N) :- N mod 10 =:= 9.
f(N) :- N div 10 =:= 9.

main :-
    get_number(N),
    f(N) -> writeln("Yes") ; writeln("No").


Measured memory_bytes: 8020
#include<stdio.h>
#include<map>
#include<algorithm>
#include<stack>
#include<queue>
#include<string.h>
#include<math.h>
#include<iostream>
using namespace std;
#define inf 1000000007
double a,b,c;
int main()
{
    scanf("%lf",&a);
    b=a/3;
    c=b*b*b;
    printf("%.12lf\n",c);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int n;
string s;
int cache[1000004][3];
int dp(int pos,int carr)
{
    if(pos==n)
        return carr;
    int &ans=cache[pos][carr];
    if(ans!=-1)
        return ans;
    ans=1e18;
    for(int i=0;i<10;i++)
    {
        int dig1=i;
        int dig2=(i+carr+s[pos]-'0')%10;
        ans=min(ans,dig1+dig2+dp(pos+1,(i+carr+s[pos]-'0')/10));
    }
    return ans;
}
int32_t main() 
{
    cin>>s;
    reverse(s.begin(),s.end());
    n=s.length();
    memset(cache,-1,sizeof(cache));
    print(dp(0,0));
}   


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

string sub(int n) {
  if (n == 0) return "0";
  string s;
  int c = 0;
  while (n != 0) {
    if (n % 2 == 0) {
      s = "0" + s;
    } else {
      s = "1" + s;
      n += c % 2;
    }
    n >>= 1;
    ++c;
  }
  return s;
}

int main() {
  int n;
  cin >> n;
  cout << sub(n) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,maps[20][20];
void    da(int x,int y){
    if(x>a || y>b) return;
    if(maps[y][x]==2) return;
    if(x==a && y==b){d++;return;}
    da(x+1,y);
    da(x,y+1);
}
int main(){
    while(1){
    d=0;
    cin>>a>>b;
    if(a+b==0)break;
    cin>>c;
    int x,y;
    for(int i=1;i<=b;i++)
    for(int j=1;j<=a;j++){maps[i][j]=0;}
        for(int i=0;i<c;i++){
        cin>>x>>y; maps[y][x]=2; }
        da(1,1);
        cout<<d<<endl;
    }
}

Measured memory_bytes: 3012
#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 gcd(ll a, ll b)
{
  if (a < b)
  {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

int main()
{
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; i++)
  {
    for (int j = 1; j <= n; j++)
    {
      for (int k = 1; k <= n; k++)
      {
        ans += gcd(gcd(i, j), k);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#モンスターの体力は H
#トキはN種類の魔法が使え、
#i番目の魔法を使うと、モンスターの体力を Ai減らすことができますが、
#トキの魔力を Bi消耗します。

#dp[i] = モンスターの体力を i 減らすため消耗する魔力の最小値
#dp[i+1] = min(dp[i-Ai]+Bi,dp[i])
#dp[0]=0

h, n = map(int, input().split())
dp=[10**8]*(10**5+1)

ab = [list(map(int, input().split())) for _ in range(n)]

for i in range(1,h+1):
  for j in range(0,n):
    if i-ab[j][0]<=0:
      x=ab[j][1]
    else:
      x=dp[i-ab[j][0]]+ab[j][1]
    dp[i]=min(dp[i],x)
print(dp[h])


Measured memory_bytes: 43244
n,m=map(int,input().split())
counter = {}
for i in range(n):
  counter[i] = [0,0]

for i in range(m):
  p,s = input().split()
  p = int(p)
  if counter[p-1][1] == 1:
    continue
  elif s == "WA":
    counter[p-1][0] += 1
  elif s =="AC":
    counter[p-1][1] = 1

crt = 0
pen = 0
for i in range(n):
  if counter[i][1] == 1:
    crt+=1
    pen+=counter[i][0]

print(crt,pen)

Measured memory_bytes: 23584
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE Strict #-}
{-# LANGUAGE StrictData #-}
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import Data.Array.Unboxed
import Data.Array.ST
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.List
import Data.Char

main :: IO ()
main = do
    [n,m] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    vec <- V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    vec2 <- V.replicateM m $ (\vec -> (vec V.! 0, vec V.! 1)) . V.unfoldrN 2 (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    let v :: V.Vector [Int]
        v = V.create $ do
            v <- VM.replicate n []
            forM_ [0..m-1] $ \i -> do
                let (x,y) = vec2 V.! i
                VM.modify v ((:) (x-1)) (y-1)
                VM.modify v ((:) (y-1)) (x-1)
            return v
    print $ length [ i | i <- [0..n-1], (vec V.! i) > (maxi $ map ((V.!) vec) (v V.! i)) ]

maxi :: [Int] -> Int
maxi [] = 0
maxi xs = maximum xs

Measured memory_bytes: 48484
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */

    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    // #define te
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 200100;
    typedef pair<pii, ll> piii;

    void solve() {
        ll n; string a, b;
        cin >> n >> a >> b;
        for(int i=0; i<n; i++) cout << a[i] << b[i];
    }

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      // ll ti;   cin >> ti;  while(ti--)
      solve();
      return 0;
    }


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

int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  vector<long long> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  long long A = accumulate(vec.begin(), vec.end(), 0LL);
  long long B = 0, ans = LLONG_MAX;

  for (int i = 0; i < N; i++) {
    B += vec.at(i);
    ans = min(ans, abs(B - (A - B)));
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;
const int MAXM=MAXN-1;

int n;
int ghead[MAXN],gnxt[2*MAXM],gto[2*MAXM],glen[MAXM];

int sz[MAXN];
ll dfs(int at,int par) {
	sz[at]=1; ll ret=0; int cmx=0;
	for(int x=ghead[at];x!=-1;x=gnxt[x]) {
		int to=gto[x]; if(to==par) continue;
		ret+=dfs(to,at); sz[at]+=sz[to]; cmx=max(cmx,sz[to]);
		int t=2*min(sz[to],n-sz[to]); if(sz[to]==n-sz[to]) --t; ret+=(ll)t*glen[x>>1];
	}
	cmx=max(cmx,n-sz[at]);
	if(2*cmx<n) {
		int emn=INT_MAX;
		for(int x=ghead[at];x!=-1;x=gnxt[x]) {
			int to=gto[x]; emn=min(emn,glen[x>>1]);
		}
		ret-=emn;
	}
	return ret;
}

void run() {
	scanf("%d",&n); REP(i,n) ghead[i]=-1;
	REP(i,n-1) {
		int a,b; scanf("%d%d%d",&a,&b,&glen[i]); --a,--b;
		gnxt[2*i+0]=ghead[a],ghead[a]=2*i+0,gto[2*i+0]=b;
		gnxt[2*i+1]=ghead[b],ghead[b]=2*i+1,gto[2*i+1]=a;
	}
	ll ret=dfs(0,-1); printf("%lld\n",ret);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 9600
import java.util.Scanner;
public class Main{
public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a == b)
            System.out.println("a == b");
        if (a > b)
            System.out.println("a > b");
        if (a < b)
            System.out.println("a < b");
}
}


Measured memory_bytes: 26312
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
int main(){
  int A,B, C, D ,E ,F;
  string S,Sa,Sb,Sc;
  cin >> A >> B >> C;
  bool ans = false;
  if(A + B == C)ans = true;
if(A + C == B)ans = true;
if(C + B == A)ans = true;
if(ans)cout << "Yes" << endl;
else cout << "No" << endl;
        return 0;
}

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

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

int main() {
  int N,W;
  cin >> N >> W;
  
  vector<int> weight(N), value(N);
  for (int i; i < N; ++i) cin >> weight[i] >> value[i];
  
  vector<vector<long long>> dp(N + 1, vector<long long>(W + 1, 0));
  for (int i = 0; i < N; ++i) {
    for (int w = 0; w <= W; ++w) {
      chmax(dp[i+1][w], dp[i][w]);
      if (w - weight[i] >= 0) {
        chmax(dp[i+1][w], dp[i][w - weight[i]] + value[i]);
      }
    }
  }
  cout << dp[N][W] << endl;
}

Measured memory_bytes: 80256
import scala.io.StdIn
import scala.annotation.tailrec

object Main{
  def main(args: Array[String]){
    StdIn.readLine()
    val line = StdIn.readLine().split(" ").toList.map(_.toInt)

    sSort(List(), line, 0)
  }

  @tailrec
  def sSort(sorted: List[Int], unsorted: List[Int], n: Int){
    if((sorted ::: unsorted).length == 1)
      println(unsorted.mkString(" ") + "\n" + n)
    else if(unsorted.sorted == unsorted)
      println((sorted ::: unsorted).mkString(" ") + "\n" + n)
    else if(unsorted.indexWhere(_ == unsorted.min) == 0)
      sSort(sorted :+ unsorted.head, unsorted.tail, n)
    else {
      val pos = unsorted.indexWhere(_ == unsorted.min)
      // pos??¨head???????´????swap?????????
      val swapped = unsorted.updated(0, unsorted(pos)).updated(pos, unsorted.head)

      sSort(sorted :+ unsorted.min, swapped.tail, n+1)
    }
  }
}

Measured memory_bytes: 45664
#include "bits/stdc++.h"
using namespace std;

int n,x;
set <int> s;

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&x),s.insert(x);

	if(s.size()==n) printf("YES");
	else printf("NO");
}

Measured memory_bytes: 9600
import sys
n, m = list(map(int, input().split()))
aaa = []
bbb = []
for i in range(n):
  a, b = list(map(int, input().split()))
  aaa.append(a)
  bbb.append(b)
c = zip(aaa, bbb)
c = sorted(c)
aaa, bbb = [list(x) for x in zip(*c)]
num = 0
ans = 0
for i in range(n):
  if num + bbb[i] >= m:
    ans += (m - num) * aaa[i]
    print(ans)
    sys.exit()
  else:
    ans += aaa[i] * bbb[i]
    num += bbb[i]
  

Measured memory_bytes: 27524
N = int(input())
S = list(map(str,input()))
l = []
for i in range(N):
  S_2 = set(S[:i]) #最初からi文字目まで
  S_3 = set(S[i:]) #i+1文字目から最後まで
  l.append(len(list(S_2 & S_3)))
print(max(l))

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
using namespace std;
int main() {
	int H, W;	cin >> H >> W;
	vector<string> C(H);
	for (int i = 0; i < H; ++i) {
		cin >> C[i];
	}
	for (int i = 0; i < H; ++i) {
		cout << C[i] << endl;
		cout << C[i] << endl;
	}

	cin >> H;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

int calc(int x,int base){
	int ret = 0;
	while(x){
		ret += x / base;
		x /= base;
	}
	return ret;
}

signed main(){
	int n;
	cin >> n;
	if(n % 2){
		cout << 0 << endl;
		return 0;
	}
	cout << min(calc(n / 2,2),calc(n / 2,5)) << endl;
}


Measured memory_bytes: 256
b1,b2,b3 = map(int,input().split())
if b1 == 1 and b2 == 0 and b3 == 0:
    print('Close')
elif b1 == 0 and b2 == 1 and b3 == 0:
    print('Close')
elif b1 == 1 and b2 == 1 and b3 == 0:
    print('Open')
elif b1 == 0 and b2 == 0 and b3 == 1:
    print('Open')
elif b1 == 0 and b2 == 0 and b3 == 0:
    print('Close')


Measured memory_bytes: 5596
import sys
input = sys.stdin.readline
from collections import Counter

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


def main():
    P = [[] for _ in range(M)]

    for x in X:
        P[x%M].append(x)

    ans = 0
    checked = [False]*M
    for m in range(M):
        if checked[m]:
            continue
        if m == 0 or m == M-m:
            ans += len(P[m])//2
        else:
            P1, P2 = P[m], P[M-m]
            L1, L2 = len(P[m]), len(P[M-m])
            if L2 > L1:
                P1, P2 = P[M-m], P[m]
                L1, L2 = len(P1), len(P2)
            
            C1 = Counter(P1)
            n = 0
            for num, c1 in C1.items():
                n += c1//2
            if L1 - n*2 <= L2:
                ans += (L1+L2)//2
            else:
                ans += L2 + n

            checked[m] = True
            checked[M-m] = True

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 19868
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  ll res = 0;
  for(int i = 0;i < n;i++){
    ll ina,inb;
    cin >> ina >> inb;
    res += inb - ina + 1;
  }
  cout << res << endl;
}



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

int main() {

	ll n;
	cin >> n;
	vector<ll> a(n), b(n);
	rep(i, n){
		cin >> a[i] >> b[i];
	}

	ll ans = 0;
	for(ll i=n-1; i>=0; --i){
		if((a[i]+ans) % b[i] != 0){
			ans += b[i] - ((a[i]+ans) % b[i]);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>
typedef long long LL;

using namespace std;



int main(void) {
	int n;
	cin >> n;
	vector<int>D(n);
	for (int i = 0; i < n; i++)cin >> D[i];
	int m;
	cin >> m;
	vector<int>T(m);
	for (int i = 0; i < m; i++)cin >> T[i];
	map<int, int>mpa, mpb;
	for (int i = 0; i < n; i++)mpa[D[i]]++;
	for (int i = 0; i < m; i++)mpb[T[i]]++;
	for (int i = 0; i < m; i++) {
		int x = T[i];
		if (mpb[x] > mpa[x]) {
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	return 0;
}

Measured memory_bytes: 20608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B && B == C){
        cout << "No" << endl;
    }
    else if (A == B || A == C || B == C){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	int N;
	cin >> N;
	vecl(A);
	fx(N) {
		vecpl(A);
	}
	fx(N-1) {
		A[x + 1] += A[x];
	}
	ll ans = LLONG_MAX;
	fy(N) {
		ans = min(abs(A[y]-(A[N-1] - A[y])),ans);
	}

	ce(ans)
    return 0;
}



Measured memory_bytes: 2420
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


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


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


# --------------------------------------------

dp = None


def main():
    A, B = li_input()

    for C in range(1, 4):
        if (A * B * C) % 2 == 1:
            print("Yes")
            return
    
    print("No")

main()


Measured memory_bytes: 5428
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>

#define INF 1000000000
using namespace::std;



long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int x) {
	if (x < 0) {
		return -x;
	}
	return x;
}



bool mode;//trueでx,falseでy
int  H, W, ans, N, B, num, mx[4000],my[4000];
string s,t,tt,ss;

int main() {
	cin >> W >> H>>N>>B;
	if (W + H == N + B) {
		cout << "Balanced" << endl;
		return 0;
	}
	if (W + H > N + B) {
		cout << "Left" << endl;
		return 0;
	}
	else {
			cout << "Right" << endl;
			return 0;
	}

		
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
	int n, m, a[100001]={}, ans[100001]={};
	
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int tmp; cin>>tmp;
		a[tmp]=1;
	}
	
	ans[1]=1;
	if(a[1]==1) ans[2]=1;
	else ans[2]=2;

	if(n>=3){
		for(int i=3;i<=n;i++){
			if(a[i-1]==1) ans[i]=ans[i-2];
			else if(a[i-2]==1) ans[i]=ans[i-1];
			else ans[i]=(ans[i-1]+ans[i-2])%1000000007;
		}
	}
	
	for(int i=1;i<n;i++){
		if(a[i]==1 && a[i+1]==1){
			cout<<0; return 0;
		}
	}
	
	cout<<ans[n];
	
	return 0;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
A = list(map(int, input().split()))

tab = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
A_cmp = {}
for Ai in sorted(A):
    A_cmp[tab[Ai]] = Ai
A = list(A_cmp.values())
A.sort(key=lambda x: -x)

memo = [None] * (N + 1)
memo[0] = 0

import sys
sys.setrecursionlimit(100000)

def dp(X):
    if X < 0: return -(1000000007)
    if memo[X] != None: return memo[X]
    #
    rets = []
    for i, Ai in enumerate(A):
        rets.append(dp(X - tab[Ai]) + 1)
    #
    ret = max(rets)
    memo[X] = ret
    return ret

ans_len = dp(N)

N_tmp = N
ans = ''
for i in range(ans_len):
    for j, Aj in enumerate(A):
        if dp(N_tmp) - 1 == dp(N_tmp - tab[Aj]):
            ans += str(Aj)
            N_tmp -= tab[Aj]
            break

print(ans)

Measured memory_bytes: 4980
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <vector>
#include <functional>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <cstdlib>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <deque>
#include <random>
#include <chrono>
#include <ctime>
#include <climits>
#include <stack>
#include <array>
#include <iomanip>
#include <complex>
#include <bitset>
#include <iostream>
#include <cstring>

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace
#define y0 withindarkness
#define y1 apinklotusbloomed
#define yn carryingapurplesoul
#define j1 togetherformingtheTeam

void useiostream() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.precision(8);
}

void drop(char const* bu) {
	printf("%s", bu);
	exit(0);
}

ull gcd(ull a, ull b) {
	return b == 0 ? a : gcd(b, a % b);
}

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

ld const pi = acos(-1.0L);
ld const eps = 0.0001L;

template<typename T, typename TT> bool mi(T& a, TT b) { return a > b ? (a = b, true) : false; }
template<typename T, typename TT> bool ma(T& a, TT b) { return a < b ? (a = b, true) : false; }

mt19937 ran(996);

int const mod = 1000000007;

ull bm(ull a, ull p, ull mod) {
	return (a * p - (ll)((ld)a * p / mod) * mod + mod) % mod;
}

ull bp(ull a, ull p, ull mod) {
	ull re = 1;
	while (p) {
		if (p & 1)re = bm(re, a, mod);
		p >>= 1;
		a = bm(a, a, mod);
	}
	return re;
}



int main() {
	useiostream();
#ifdef _DEBUG
	(void)freopen("input.txt", "r", stdin);
	(void)freopen("output.txt", "w", stdout);
#else
	//(void)freopen("bisector.in", "r", stdin);
	//(void)freopen("bisector.out", "w", stdout);
#endif

	int a, b;
	cin >> a >> b;
	cout << lcm(a, b);


	return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")

#include <iostream>
#include <string>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <tuple>
#include <queue>
#define PII pair<int, int>
#define T3I tuple<int, int, int>
using namespace std;

typedef long long ll;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;

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

    int n, m;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> m;
        if(m%2 == 0) {
            if(m%3 == 0 || m%5 == 0) {
                continue;
            }else {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}

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

#define pb(s) push_back(s)
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PI 3.14159265358979323846264338327950L


typedef long long ll;

const ll MOD =1e9+7;

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

    string str;
    cin>>str;
    int i=str.find('A');
    int j=str.size()-str.rfind('Z')-1;
    cout<<str.size()-(i+j);
    return 0;
}


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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    set<int> AB;
    REP (i, 2) {
        int v;
        cin >> v;
        AB.insert (v);
    }
    set<int> ABC {1, 2, 3};
    set<int> ans;
    set_difference (begin (ABC), end (ABC), begin (AB), end (AB),
                    inserter (ans, end (ans)));
    cout << *begin (ans) << endl;
    return 0;
}


Measured memory_bytes: 3556
def resolve():
    n = int(input())
    l = [int(input()) for i in range(n)]

    count = 0
    j = 1
    for i in range(n):
        j = l[j-1]
        count += 1
        if j == 2:
            return print(count)

    return print(-1)

if __name__ == '__main__':
    resolve()

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

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W, M;
    cin >> H >> W >> M;
    vector<int> X(M), Y(M);
    for(int i=0; i<M; i++)
    {
        cin >> X[i] >> Y[i];
        X[i]--; Y[i]--;
    }

    vector<int> cntH(H, 0), cntW(W, 0);
    for(int i=0; i<M; i++)
    {
        cntH[X[i]]++;
        cntW[Y[i]]++;
    }

    vector<P> pH;
    for(int i=0; i<H; i++) pH.emplace_back(cntH[i], i);
    vector<P> pW;
    for(int i=0; i<W; i++) pW.emplace_back(cntW[i], i);

    sort(pH.begin(), pH.end());
    sort(pW.begin(), pW.end());

    int maxH = pH[H-1].first;
    int maxW = pW[W-1].first;
    int num_maxH = pH.end() - lower_bound(pH.begin(), pH.end(), P(maxH, -1));
    int num_maxW = pW.end() - lower_bound(pW.begin(), pW.end(), P(maxW, -1));
    ll num = 1LL * num_maxH * num_maxW;
    int cnt = 0;
    for(int i=0; i<M; i++)
    {
        if(cntH[X[i]] + cntW[Y[i]] == maxH + maxW) cnt++;
    }
    int ans;
    if(cnt == num) ans = maxH + maxW - 1;
    else ans = maxH + maxW;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 16276
h, w = map( int, raw_input().strip().split() )

for i in range(h):

    data = raw_input().strip().split()

    for j in range(w):
        if data[j] == "snuke":
            ans1 = chr( j + ord('A') )
            ans2 = str( i+1 )

print ans1 + ans2

Measured memory_bytes: 2568
#include <bits/stdc++.h>
    using namespace std;
     
    int N,maxn=1;
     
    int main(){
    	cin>>N;
    	for(int i=2;i<=10000;i++){
    		int f=i*i;
    		while(f<=N){maxn=max(maxn,f);f*=i;}
    	}
    	cout<<maxn<<endl;
    	return 0;
    }

Measured memory_bytes: 256
import java.util.*;


public class Main {
	
	static boolean[] validDigit = new boolean[10];
	static int n, k;
	
	public static void main(String[] args) {
		
		Scanner cin = new Scanner(System.in);
		
		/*input*/
		n = cin.nextInt();
		k = cin.nextInt();
		
		Arrays.fill(validDigit, true);
		for (int i = 0; i < k; i ++) {
			validDigit[cin.nextInt()] = false;
		}
		
		/*start*/
		String num = String.valueOf(n);
		
		int[] nums = new int[num.length() + 1];
		nums[0] = 0;
		for (int i = 1; i < nums.length; i ++) {
			nums[i] = num.charAt(i-1) - '0';
		}
		
		int index = 1;
		for (; index < nums.length; ) {
			
			int a = nums[index];
			if (validDigit[a]) {
				index ++;
				continue;
			}
			
			//else not valid
			int b = increment(a);
			
			if (b > a) {
				nums[index] = b;
				index ++;
				break;
			}
			
			// else b < a
			if (index == 1) {
				nums[0] = increment(0);
				break;
			} 
			
			while (index > 0) {
				index --;
				int c = nums[index];
				int d = increment(c);
				if (d > c) {
					nums[index] = d;
					index ++;
					break;
				}
			}
			break;
			
		}
		
		int e = increment(-1);
		while(index < nums.length) {
			nums[index] = e;
			index ++;
		}
		
		/*finish*/
		for (int i = 0; i < nums.length; i ++) {
			if (i == 0 && nums[0] == 0) {
				continue;
			}
			
			System.out.print(nums[i]);
		}
		
		
	}
	
	public static int increment(int j) {
		
		int i = j + 1;
		
		for (; i < 20; i ++) {
			if (validDigit[i % 10]) {
				break;
			}				
		}
		
		return i % 10;
	}

}



Measured memory_bytes: 21844
# Setup
import sys
import math
import copy
sys.setrecursionlimit(4100000)

n,d = [int(i) for i in input().split()]
x = [[int(i) for i in input().split()] for i in range(n)]
counter = 0
for i in range(n):
    for k in range(i+1,n):
        current = 0

        for a in range(d):
            current += abs(x[i][a] - x[k][a])**2
        current = math.sqrt(current)
        if current.is_integer():
            counter += 1
print(counter)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define pii pair<int, int>
#define mkp(x, y) make_pair(x, y)
using namespace std;
const int MAXN = 1e5 + 7;
map<pii, int> mp;
set<int> s[MAXN];
int n, t, f[MAXN];
pii q[MAXN];

inline int getf(int x)
{
    return f[x] == x ? x : f[x] = getf(f[x]);
}

inline void solve()
{
    set<int>::iterator it;
    int u, v, h;
    h = 0;
    while (h < t)
    {
        u = q[++h].first;
        v = q[h].second;
        u = getf(u);
        v = getf(v);
        s[u].erase(v);
        s[v].erase(u);
        if (s[u].size() < s[v].size())
        {
            swap(u, v);
        }
        for (it = s[v].begin(); it != s[v].end(); it++)
        {
            int to = (*it);
            mp[mkp(to, v)] = mp[mkp(v, to)] = 0;
            s[to].insert(u);
            s[u].insert(to);
            mp[mkp(to, u)]++;
            mp[mkp(u, to)]++;
            if (mp[mkp(to, u)] == 2)
                q[++t] = mkp(to, u);
            s[to].erase(v);
        }
        f[v] = u;
        s[v].clear();
    }
    int s = 0;
    for (int i = 1; i <= n; i++)
    {
        s += f[i] == i;
    }
    if (s == 1)
        printf("YES");
    else
        printf("NO");
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        f[i] = i;
    for (int i = 1, u, v; i <= 2 * n - 2; i++)
    {
        scanf("%d%d", &u, &v);
        mp[mkp(u, v)]++;
        mp[mkp(v, u)]++;
        s[u].insert(v);
        s[v].insert(u);
        if (mp[mkp(u, v)] == 2)
            q[++t] = mkp(u, v);
    }
    solve();
    return 0;
}

Measured memory_bytes: 55936
<?php
fscanf(STDIN, "%d %d %d %d", $A, $B, $H, $M);
$L_KAKUDO = 90 - $H * 30 - $M / 2;
$S_KAKUDO = 90 - $M * 6;
// echo "{$L_KAKUDO} {$S_KAKUDO}" . PHP_EOL;

define('RAD', 180 / M_PI);

$L_X = cos($L_KAKUDO / RAD) * $A;
$L_Y = sin($L_KAKUDO / RAD) * $A;
$S_X = cos($S_KAKUDO / RAD) * $B;
$S_Y = sin($S_KAKUDO / RAD) * $B;

// echo "{$L_X} {$L_Y} {$S_X} {$S_Y}" . PHP_EOL;

$ans = sqrt(pow($L_X - $S_X, 2) + pow($L_Y - $S_Y, 2));
printf("%0.53f", $ans);


Measured memory_bytes: 16640