akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n;
    cin >> n;
    vector<ll> z(n);
    for (int i = 0; i < n; i++) {
        cin >> z[i];
    }
    ll m;
    cin >> m;
    vector<ll> x(m);
    for (int i = 0; i < m; i++) {
        cin >> x[i];
    }
    sort(z.begin(), z.end());
    sort(x.begin(), x.end());
    ll now = 0;
    for (int i = 0; i < n; i++) {
        if (z[i] == x[now])now++;
        if (now == m)break;
    }
    if (now == m)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 6344
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    A, B = list(map(int, input().split()))
    if A - 2*B > 0:
        print(A-2*B)
    else:
        print("0")

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    V = list(map(int, input().split()))
    C = list(map(int, input().split()))

    res = 0
    for i in range(n):
        diff = V[i] - C[i]
        res += diff if diff > 0 else 0

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long ll;
using namespace std;
int n;
vector<vector<int>> v(8);
ll dfs(int x,vector<bool>& used){
    bool ok=true;
    rep(i,n)if(!used[i])ok=false;
    if(ok)return 1;
    ll now=0;
    rep(i,v[x].size()){
        int y=v[x][i];
        if(used[y])continue;
        auto u=used;
        u[y]=true;
        now+=dfs(y,u);
    }
    return now;
}

int main(void){
    int m;cin>>n>>m;
    rep(i,m){
        int a,b;cin>>a>>b;a--;b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    vector<bool> used(8,false);
    used[0]=true;
    ll res=dfs(0,used);
    cout<<res<<endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    int k = 0;
    for (int i = 0; i < s.length(); i++)
        if (s[i] == 'R') k++;
    if (k == 2 && s[1] == 'S') cout << '1';
    else cout << k;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;


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

    if (S.length() == 2){
        cout << S << endl;
    }else{
        for (int i = S.length() - 1; i >= 0; i--){
            cout << S[i];
        }
        cout << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<string> s(n);
	vector<int> t(n);
	string x;
	REP(i,n) cin >> s[i] >> t[i];
	cin >> x;
	int ans = 0;
	bool flag = false;
	REP(i,n){
		if(flag) ans += t[i];
		if(s[i]==x) flag = true;
	}
	cout << ans << '\n';
	return 0;
}



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

int main(){
	int s, h, m, s2;
	cin >> s;
	h = s / 3600;
	m = (s / 60)% 60;
	s2 = s % 60;
	cout <<h<<":"<<m<<":"<<s2<< endl;
	return 0;
}


Measured memory_bytes: 3096
#include<cstdio>

int main()
{
	int a,i,j=0,count[1000];
	while(1)
	{
		scanf("%d",&a);
		if(a==0)
			break;
		i=0;
		while(a!=1)
		{
			if(a%2==0)
				a=a/2;
			else
				a=a*3+1;
			i++;
		}
		count[j]=i;
		j++;
	}
	for(i=0;i<j;i++)
		printf("%d\n",count[i]);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define M1 1000000007
#define M2 998244353

#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define ifl(i,a,b) for(ll i=b-1;i>=a;i--)
#define f(i,n)     for(int i=0;i<n;i++)
#define bf(i,n)    for(int i=n-1;i>=0;i++)


#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define bn "\n"

//------------------------------------------------------------------------ 
// #define V(a) vector<a>
// #define vt() vector< tuple < int ,int ,int > > ;
// #define vector< int ,int > pv;
// vector< pair <int,int> > vect;


//------------------------------------------------------------------------

ll modI(ll a,ll m);
ll gcd(ll a,ll b);
ll powM(ll x,ll y,ll m);
ll swap(ll a,ll b);

void swap(ll& a,ll& b)
{
    ll tp=a;
    a=b;
    b=tp;
}

ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powM(ll x,ll y,ll m)
{
    ll ans=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            ans*=x;
            ans%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return ans;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

//---------------------------------------------------------------------------

// variable = Expression1 ? Expression2 : Expression3
// max = (n1 > n2) ? n1 : n2; 
// (n>m) ? cout<<"True"<<endl:cout<<"false"<<endl ;

// ---------------------------------------------------------------------------	

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

//----------------------------------------------------------------------------

// vector< tuple < int ,int ,int > > tv;
// vector< int ,int > pv;


//----------------------------------------------------------------------------


int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int tt=1;
   // cin>>tt;
	while(tt--)
	{
	    int n,m;
	    cin>>m>>n;
	    if(n>=m)
	    cout<<"unsafe";
	    else
	    cout<<"safe";
	    cout<<bn;
	   
	   
	   
	    
	}
	
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 1000005
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef map<ll, ll> Map;

ll f(ll a, ll b) {
    ll x=min(a, b);
    ll y=max(a, b);
    
    if(y%x==0) return 2*y-x;
    return 2*x*(y/x)+f(x, y%x);
}

int main(void) {
    ll N, x;
    cin >> N >> x;
    ll ans=N;
    
    prin(ans+f(x, N-x));
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll power(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)

//your code here!

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート 1,2,....9
}

int main(void){
    ll N, score[1001], ans=0;
    scanf("%lld", &N);
    rep(i, N) {
        scanf("%lld", score+i);
        ans += score[i];
    }
    if(ans%10) {
        printf("%lld\n", ans);
        return 0;
    }
    else {
        qsort(score, N, sizeof(ll), cmp);
        rep(i, N) {
            if(score[i]%10) {
                printf("%lld\n", ans-score[i]);
                return 0;
            }
        }
        puts("0");
        return 0;
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define LL_MAX LLONG_MAX
#define ULL_MAX ULLONG_MAX
#define ull unsigned long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define mk make_pair
#define endl '\n'

int main()
{
    IOS;
    int n,d;
    cin>>n>>d;
    vector<bool> flag(n+1,0);
    for (int i = 0; i < d; i++)
    {
        int v;
        cin>>v;
        for (int j = 0; j < v; j++)
        {
            int x;
            cin>>x;
            flag[x]=true;
        }
        
    }
    int count=0;
    for (int i = 1; i < n+1; i++)
    {
        if(flag[i]==0)
            count++;
    }
    cout<<count;
}

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

int main() {

    string s;

    cin >> s;

    list<char> ans;

    for(auto i : s){
        if(i == 'B'){
            if(!ans.empty()){
                list<char>::iterator erase_itr = ans.end();
                erase_itr--;
                ans.erase(erase_itr);
            }
            continue;
        }
        ans.push_back(i);
    }

    for(auto output : ans){
        cout << output;
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template<typename T, typename E>
struct FGC{
  typedef function<T(T, E)> F;
  typedef function<E(E, E)> G;
  typedef function<bool(T,T)> C;
  F &f;
  G &g;
  C &c;
  FGC(F &f,G &g,C &c):f(f),g(g),c(c){}
};
template<typename T, typename E>
struct SkewHeap{
  SkewHeap *l,*r;
  T val;
  E add,e;
  FGC<T, E> &fgc;
  
  SkewHeap(T val,E e,FGC<T,E> &fgc):
    val(val),add(e),e(e),fgc(fgc){l=r=NULL;}
  
  void eval(){
    if(add==e) return;
    if(l) l->add=fgc.g(l->add,add);
    if(r) r->add=fgc.g(r->add,add);
    val=fgc.f(val,add);
    add=e;
  }
  
  T top(){
    return fgc.f(val,add);
  }
  
};

template<typename T, typename E>
SkewHeap<T, E>* meld(SkewHeap<T, E> *a,SkewHeap<T, E> *b){
  if(!a) return b;
  if(!b) return a;
  if(a->fgc.c(a->top(),b->top()))  swap(a,b);
  a->eval();
  a->r=meld(a->r,b);
  swap(a->l,a->r);
  return a;
}

template<typename T, typename E>
SkewHeap<T, E>* pop(SkewHeap<T, E>* a){
  a->eval();
  auto res=meld(a->l,a->r);
  free(a);
  return res;
};
//END CUT HERE

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  using Heap = SkewHeap<int, int>;
  
  FGC<int, int>::F f=[](int a,int b){return a+b;};
  FGC<int, int>::G g=[](int a,int b){return a+b;};
  FGC<int, int>::C c=[](int a,int b){return a<b;};
  FGC<int, int> fgc(f,g,c);
  
  Heap* base = new Heap(0,0,fgc);
  string s;
  while(cin>>s,s!="end"){
    int x;
    if(s=="insert"){
      cin>>x;
      base=meld(base, new Heap(x,0,fgc));
    }
    if(s=="extract"){
      x=base->top();
      base=pop(base);
      cout<<x<<endl;
    }
  }
  return 0;
}
/*
  verified on 2018/01/04
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_9_C&lang=jp
*/



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

int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  if (n >= k) {
    ans += (n / k) * (n / k) * (n / k);
  }
  if (k % 2 == 0) {
    ll mod = k / 2;
    if (n >= mod) {
      ans +=
          (((n - mod) / k) + 1) * (((n - mod) / k) + 1) * (((n - mod) / k) + 1);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <string>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  int id;
  ll a[10];
  ll min;
  cin >> n;
  for(int i=0;i<5;i++){
    cin >> a[i];
    if(i == 0) min = a[i] + 1;
    if(min > a[i]) {
      min = a[i];
      id = i;
    }
  }

  ll ans = 0;
  if((n % min) == 0) ans = 4 + (n / min);
  else ans = 5 + (n/min);
  cout << ans << endl;
  return 0;
}


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

int N;

int main() {
    cin >> N;
    double ans = 0.0;
    double a;
    for (int i = 0; i < N; i++) {
        cin >> a;
        ans += 1.0 / a;
    }
    cout << 1.0 / ans << endl;
}


Measured memory_bytes: 256
def data_input():
    a,b,c = input().split(' ')
    return (int(a),int(b),int(c))
def answer():
    """
    >>> output('5','-->--')
    3.83333333333333
    """
    s,a,b = data_input()
    _max = min(a,b)
    _min = 0
    if a+b > s:
        _min = (a+b) - s
    return (_max,_min)

def output():
    res = answer()
    print('{0} {1}'.format(res[0],res[1]))
output()

Measured memory_bytes: 3064
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int X;
    cin >> X;
    vector<bool> a(X+1);

    a[1] = true;
    for (int i = 2; i <= X;i++){
        int v = i * i;
            while(v<=X){
                a[v] = true;
                v *= i;
            }
    }
    for (int i = X; i >= 1;i--){
        if(a[i]){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n,q;
    cin >> n >> q;
    set<P> st;
    ll s,t,x;
    REP(i,n){
        cin >> s >> t >> x;
        s -= x;
        t -= x;
        st.insert(P(s, x));
        st.insert(P(t, -x));
    }
    ll ans[q];
    ll d;
    set<ll> now;
    auto itr = st.begin();
    REP(i,q){
        cin >> d;
        while(itr->first <= d && itr != st.end()){
            if(itr->second > 0) now.insert(itr->second);
            else now.erase(-(itr->second));
            itr++;
        }
        if(!now.empty()) ans[i] = *now.begin();
        else ans[i] = -1;
    }
    REP(i,q){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 37248
#include<bits/stdc++.h>
using namespace std;
#define ll long long
map <int,int>m,mm;
set <int> ss;
int main()
{
	ll x,y,co=1;
	scanf("%lld%lld",&x,&y);
	while(1)
	{
		x*=2;
		if(x>y)
			break;
		co++;
	}
	printf("%lld\n",co);
}

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

#define REP(i, a, b) 	for(int i = (a), _b = (b); i < _b; ++i)
#define FOR(i, a, b) 	for(int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i, a, b)	for(int i = (a), _b = (b); i >= _b; --i)
#define FILL(a, v, n)	for(int i = 0, _n = (n); i < _n; ++i) a[i] = v
#define DB(x) 				cerr << #x << " = " << x << endl

#define endl 		"\n"
#define newline 	cout << "\n"
#define long 		long long

#define two(n)					(1 << (n))
#define onbit(mask, i) 	(mask |= (1 << (i)))
#define getbit(mask, i)	((mask >> (i)) & 1)
#define pc(mask)				__builtin_popcount(mask)

using namespace std;
const int MAXN = 1E5+5;

int a[MAXN];
int N;

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
#ifdef Home
	freopen ("input.txt", "r", stdin);
#endif
	cin >> N;
	FOR(i, 1, N) {
		cin >> a[i];
	}	

	int ans = 0;

	FOR(i, 1, N) {
		if(a[i] == i) {
			++ans;
			a[i+1] = a[i]; 
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <cmath>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
  ll N;
  ll A[200010];
  cin >> N;
  rep(i,N){
    cin >> A[i];
  }
  
  sort(A, A+N, greater<ll>());
  
  ll tot = 0;
  
  if(N%2==0){
    rep(i, N/2-1) tot += A[i]; 
    FOR(i, 1, N/2) tot += A[i];
    tot += A[(N/2)-1];
  }else{
    rep(i, N/2) tot += A[i];
    FOR(i, 1, (N/2)+1) tot += A[i];
  }
  
  cout << tot << endl;  
}

Measured memory_bytes: 5240
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
    ullong N; cin >> N;
    ullong deno = 26;
    string S("");
    while(N) {
        ullong r = N % deno;
        if (r == 0) {
            S += 'z';
            r = 26;
        }
        else {
            S += ('a' + (r-1));
        }
        N = (N - r) / deno;
    }
    reverse(S.begin(), S.end());
    cout << S << endl;
}


Measured memory_bytes: 3608
import java.util.*;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        if(A+B>C+D){
            System.out.println("Left");
        }
        else if(A+B<C+D){
            System.out.println("Right");
        }
        else{
            System.out.println("Balanced");
        }
    } 
}

Measured memory_bytes: 21716
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

static char *strrstr(const char *string, const char *pattern) {
	size_t offset = 0;
	char *lastP = NULL;

	char *searchResult = NULL;
	while ((searchResult = strstr(&(string[offset]), pattern)) != NULL && string[offset] != '\0') {
		lastP = searchResult;
		offset++;
	}

	return lastP;
}

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) < *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

int main(void) {
	const char patternBase[] = "keyence";
	char top[8], bottom[8];
	char S[101];

	scanf("%s", S);

	const size_t len = strlen(S);
	bool found = false;

	for (size_t offset = 0; offset < strlen(patternBase); offset++) {
		strncpy(top, patternBase, offset);
		top[offset] = '\0';
		strncpy(bottom, &(patternBase[offset]), strlen(patternBase) - offset);
		bottom[strlen(patternBase) - offset] = '\0';

		const char *topSearch = strstr(S, top);
		if (topSearch != NULL) {
			const char *bottomSearch = strrstr(&(topSearch[offset]), bottom);
			if (bottomSearch != NULL) {
				size_t sepCount = 0;

				if (topSearch != S) {
					sepCount++;
				}
				if (&(topSearch[offset]) != bottomSearch) {
					sepCount++;
				}
				if (bottomSearch[strlen(bottom)] != '\0') {
					sepCount++;
				}

				if (sepCount <= 1) {
					found = true;
					break;
				}
			}
		}
	}

	puts((found ? "YES" : "NO"));

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int W, a, b;
  cin >> W >> a >> b;
  vector<int> A(2), B(2);
  A[0] = a;
  A[1] = a+W;
  B[0] = b;
  B[1] = b+W;
  if(A[1]<B[0]){
    cout << B[0]-A[1] << endl;
  }else if(B[1]<A[0]){
    cout << A[0]-B[1] << endl; 
  }else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long llong;

struct DrinkInfo{
    llong price;
    llong stock;

    DrinkInfo(llong inPrice, llong inStock){
        price = inPrice;
        stock = inStock;
    }
};

//DrinkInfoを値段で比較。ソートするために用意
bool cmpPrice(const DrinkInfo &a, const DrinkInfo &b){
    return a.price < b.price;
}

int main()
{
    llong N,M;
    scanf("%lld %lld",&N,&M);
    
    vector<DrinkInfo> drinkInfo;
    llong price;
    llong stock;
    for (int i = 0; i < N; i++){
        scanf("%lld %lld",&price,&stock);
        drinkInfo.push_back(DrinkInfo(price, stock));
    }

    llong currentTotalPrice = 0;
    llong currentTotalNumber = 0;
    sort(drinkInfo.begin(), drinkInfo.end(), cmpPrice);

    for (auto itr : drinkInfo){
        if(currentTotalNumber + itr.stock >= M){
            currentTotalPrice = currentTotalPrice + itr.price * (M - currentTotalNumber);
            currentTotalNumber = M;
            break;
        }else{
            currentTotalPrice = currentTotalPrice + itr.price * itr.stock;
            currentTotalNumber = currentTotalNumber + itr.stock;
        }
    }

    // 出力
    printf("%lld\n", currentTotalPrice);
    return 0;
}

Measured memory_bytes: 2420
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
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(); }

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	string s; cin >> s;
	int a=stoi(s.substr(0, 2));
	int b= stoi(s.substr(2));

	bool f = a >= 1 && a <= 12;
	bool g = b >= 1 && b <= 12;

	if (f) {
		if (g) {
			cout << "AMBIGUOUS" << endl;
		}
		else {
			cout << "MMYY" << endl;
		}
	}
	else {
		if (g) {
			cout << "YYMM" << endl;
		}
		else {
			cout << "NA" << endl;
		}
	
	}

	



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1e9+7
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int cnt = 0;
    rep(i,n-2) {
        if (s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') {
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3588
def main():
    x,y = map(int,input().split())

    for t in range(x+1):
        k = x - t
        t_l = t * 2
        k_l = k * 4
        if y == t_l+k_l:
            print('Yes')
            return
    print('No')
if __name__=='__main__':
    main()


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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

void resolve()
{
    int R;
    cin >> R;

    double ans = (double)(2 * R) * 3.1415926535;
    printf("%.10f\n", ans);
}

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


Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int a, b, c;
	cin >> a >> b >> c;
	c -= min(c, a - b);
	cout << c << '\n';
	
 	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;

// ユークリッドの互除法
int gcd(int a,int b) { return b?gcd(b,a%b):a; }

int main(){
  int n;
  cin >> n;
  VI a(n);
  rep(i,n) cin >> a[i];

  sort(a.begin(), a.end());

  int all = a[0];
  set<int> S;
  rep(i,n-1){
    set<int> tmp;
    if(i==0) tmp.insert(a[1]);
    int g = gcd(a[i+1], all);
    if(g < all){
      tmp.insert(all);
    }
    for(auto x : S){
      int h = gcd(a[i+1], x);
      tmp.insert(h);
    }
    S = tmp;
    all = g;
  }
 
  
  /*
  for(auto x : S){
    cout << x << " ";
  }
  cout << all << endl;
  */
  
  
  if(S.empty()){
    cout << all;
  }else{
    cout << *rbegin(S);
  }

  return 0;
}


Measured memory_bytes: 640
import java.util.*;

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) % 2 == 0){
            System.out.println("Even");
        }else{
            System.out.println("Odd");
        }
        
    }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll N, K; cin >> N >> K;
	vector<ll> a(N);
	vector<vector<ll>> po(2e5 + 1);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		po[a[i]].push_back(i);
	}

	vector<pair<ll, ll>> B(N);
	for (int i = 0; i <= 2e5; i++) {
		for (int j = 0; j < po[i].size(); j++) {
			if (j + 1 == po[i].size()) {
				B[po[i][j]].first = (po[i][0] + (ll)1) % N;
				B[po[i][j]].second = 1;
			}
			else {
				B[po[i][j]].first = (po[i][j + 1] + (ll)1) % N;
				if (B[po[i][j]].first < po[i][j]) B[po[i][j]].second = 1;
			}
		}
	}

	ll now = 0, T = 0;
	vector<ll> cir(N);
	while (1) {
		cir[T] = now;
		if (B[now].second) {
			T++;
		}
		now = B[now].first;
		if (now == 0)break;
	}
	vector<pair<ll, ll>> ans(N);
	vector<ll> mp(2e5 + 1, -1);
	ll cnt = 0;

	bool fl = true;
	if (po[a[N - 1]].size() == 1) {
		T++;
		if ((K - 1) % T == T - 1)cnt = 0, fl = false;
	}

	if (fl) {
		for (int i = cir[(K - 1) % (T)]; i < N; i++) {
			if (mp[a[i]] != (ll)-1) {

				cnt = mp[a[i]];
				for (int j = ans[cnt].second; j <= i; j++) {
					mp[a[j]] = -1;
					ans[j].first = 0;
					ans[j].second = 0;
				}
			}
			else {
				mp[a[i]] = cnt;
				ans[cnt].first = a[i];
				ans[cnt].second = i;
				cnt++;
			}
		}
	}
	for (int i = 0; i < cnt; i++) {
		cout << ans[i].first << " ";
	}
}

Measured memory_bytes: 25108
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
const long long INF = 1LL << 60;

int N,ac;
string str;

int main(){
  //cin >> N;
  cin >> str;
  for(int i = 1; i < str.length(); ++i){
    if((str.length()-i) % 2 == 1) continue;
    ac = 0;
    for(int j = 0; j < (str.length()-i)/2; ++j) if(str[j] == str[j + (str.length()-i)/2]) ac++;
    
    if(ac == (str.length()-i)/2){
      cout << str.length() - i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

ll N;
ll a[201010];
ll csum[201010];

int main() {
  cin >> N;
  repe(i, 1, N) {
    cin >> a[i];
    csum[i] = csum[i - 1] + a[i];
  }

  ll ans = INF;

  for (int i = 1; i < N; ++i) {
    ll x = csum[i];
    ll y = csum[N] - x;
    chmin(ans, abs(x - y));
  }

  cout << ans;
}


Measured memory_bytes: 6752
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d;
	cin>>a>>b>>c>>d;
	int ans=min(b,d)-max(a,c);
	if (ans<0)
	  cout<<0<<endl;
	else
	  cout<<ans<<endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define INF (1<<28)
#define DEKAI 1000000007
#define FDST int hogehogehoge;cin>>hogehogehoge;
//#define int long long

signed main(){
	string a,b,c;
	int n;
	cin>>n>>a>>b>>c;
	int ans=0;
	lp(i,n){
		if(a[i]==b[i]&&b[i]==c[i]){
			;
		}
		else if(a[i]==b[i]||b[i]==c[i]||c[i]==a[i]){
			ans++;
		}
		else ans+=2;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=1e5+50; 

/*
const int N=;

int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
*/

int n,L[N],R[N];
ll ans;
int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
//	freopen("my.out","w",stdout);
#endif
	scanf("%d",&n); 
	rep(i,1,n)scanf("%d%d",L+i,R+i);
	sort(L,L+n+1),reverse(L,L+n+1);
	sort(R,R+n+1);
	rep(i,0,n)ans+=max(0,L[i]-R[i]); 
	printf("%lld\n",ans*2);
	return 0;
}

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

int main() {
    int N,K;
    cin >> N >> K;

    int Mmin = N-1;
    int Mmax = (N-1)*(N-2)/2;
    if(K>Mmax){
        cout << -1 << endl;
        return 0;
    }
    
    int M = N*(N-1)/2 - K;
    cout << M << endl;
    int Mcnt = 0;
    for(int i = 1;i<N;++i)for(int j=i+1;j<=N;++j){
        cout << i << " " << j << endl;
        ++Mcnt;
        if(Mcnt == M) return 0;
    }
}

Measured memory_bytes: 256
def read_input():
    n = int(input())
    return n


def mymod(x):
    return x % (10**9 + 7)


def submit():
    N = read_input()
    N = list(map(int, list(bin(N)[2:])))

    dp = [[0]*(3) for _ in range(len(N) + 1)]
    dp[len(N)][0] = 1

    for i in range(len(N) - 1, -1, -1):
        for s in range(3):
            for k in range(3):
                new_s = 2 * s + N[len(N) - i - 1] - k
                if new_s < 0:
                    continue
                if new_s > 2:
                    new_s = 2
                dp[i][new_s] += dp[i + 1][s]
            dp[i][0] = mymod(dp[i][0])
            dp[i][1] = mymod(dp[i][1])
            dp[i][2] = mymod(dp[i][2])

    print(mymod((dp[0][0] + dp[0][1] + dp[0][2])))


if __name__ == '__main__':
    submit()


Measured memory_bytes: 38384
N,M = map(int,input().split())

m = M
f = {}
while m%2 == 0:
    f[2] = f.get(2,0) + 1
    m = m//2

k = 3
l = int(m**0.5)+1
while m != 1:
    if k > l:
        f[m] = f.get(m,0)+1
        break
    while m%k == 0:
        f[k] = f.get(k,0)+1
        m = m//k
    k += 2
C=[1]
for k in f:
    C_tmp = []
    for c in C:
        for i in range(f[k]):
            C_tmp.append(c*(k**(i+1)))
    C.extend(C_tmp)
ans_r = M
for c in C:
    if c>=N and c<ans_r:
        ans_r = c
print(M//ans_r)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;
// spring s; cin >> s;
// cout << res << endl;
// --------write my code!!!!!----------//

// I'm trying to ~~~
int main(){
    int A; cin >> A;
    if(A<1200) cout << "ABC" << endl;
    else if(A<2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.split(" ")
    val nlength = n[0].length
    var f = 0
    val b = (nlength - 1) / 4 - 1
    val a = (nlength - 1) / 2 - 1
    val l = n[0].toCharArray()
    for (i in 0..a) {
        var m = nlength - 1 - i
        if (l[i] != l[m]) {
            f = 1
        }
    }
    for (i in 0..b){
        var ll = (nlength - 1) / 2 - i - 1
        var lll = (nlength + 3) / 2 + i - 1
        var m = nlength - 1 - i
        if (l[i] != l[ll]){
            f = 1
        } else if (l[lll] != l[m]){
            f = 1
        }
    }
    if (f == 1){
        println("No")
    } else {
        println("Yes")
    }
}

Measured memory_bytes: 37928
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
typedef vector<ll> vll;
vll prime;
vector<pair<ll,ll> > Pair(100001);
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
int main() 
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	ll t=1;
//	cin>>t;
	while(t--)
	{
	    ll a,b,c;
	    cin>>a>>b>>c;
		if(c-a-b>0&&(c-a-b)*(c-a-b)>4*a*b)
	    	cout<<"Yes\n";
	    else cout<<"No\n";
	    	
	    
	    
		
	}
	return 0;
}




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

using namespace std;

int corattu(int num) {
	if (num % 2 == 0)return num / 2;
	return 3 * num + 1;
}


int main()
{

	int n;
	bool ans = false;
	cin >> n;

	if (n % 4 == 0 || n % 7 == 0) {

		ans = true;

	}
	else {

		while (n >= 0) {
			if (n % 4 == 0) {
				ans = true;
				break;
			}
			
			n -= 7;
		}
	}

	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;

}



Measured memory_bytes: 256
def gcd(x,y):
    while y>0:
        x,y = y,x%y
    return x
N,M = map(int,input().split())
S = input().strip()
T = input().strip()
a = gcd(N,M)
K = (N//a)*M
t = (N//a)*(M//a)
flag = 0
k = 0
while (k*t)//(K//N)<N and (k*t)//(K//M)<M:
    if S[(k*t)//(K//N)]!=T[(k*t)//(K//M)]:
        flag = 1
        break
    k += 1
if flag==0:
    print(K)
else:
    print(-1)

Measured memory_bytes: 64848
a,*s,g=input()
c=s.count
if a==g:
  if(len(s)-c(a)*2)%2:
    print('Second')
  else:
    print('First')
else:
  if(len(s)-max(c(a),c(g))*2)%2:
    print('First')
  else:
    print('Second')

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

# define FOR(i,a,b) for (int i=(a);i<(b);i++)
# define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
# define REP(i, n) for (int i = 0; i < (int)(n); i++)
# define RREP(i,n) for (int i=(n)-1;i>=0;i--)

# define int(x) int x; scanf("%d",&x);
# define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
# define string(x) string x; cin >> x;

using namespace std;

namespace utils{
  template <typename T> void print(vector<vector<T>> mat) {
    REP (i, mat.size()) {
      REP (j, mat[0].size()) cout << mat[i][j] << ' ';
      cout << endl;
    }
  }

  template <typename T> void print(vector<T> v) {
    REP (i, v.size())
      if (i >= v.size()-1)
	cout << v[i];
      else
	cout << v[i] << ' ';
    
    cout << endl;
  }

  template <typename T> pair<T, T> shape(vector<vector<T>> mat) {
    int d1, d2;

    d1 = mat.size();
    if (d1 > 0) d2 = mat[0].size();
    else int d2 = 0;
    cout << "(" << d1 << ", " << d2 << ")" << endl;
    return make_pair(0, 0);
  }

  template <typename T> vector<vector<T>> empty(int n, int m) {
    vector<vector<T>> mat(n, vector<T>(m));
    return mat;
  }
}


int main() {
  string(x);
  int mid = 0;
  for(int i = x.size(); i > 2; i-=2){
    x.pop_back();
    x.pop_back();
    mid = x.size()/2;
    string left = x.substr(0, mid);
    string right = x.substr(mid,mid);
    if(left == right){
      cout << mid*2 << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
const int N = 100005;

int n, m;
vector<int> a[N];
int s, f;

int d[N][3];
bool c[N][3];
int bfs()
{
    queue<pair<int, int> > q;
    c[s][0] = true;
    q.push(m_p(s, 0));
    while (!q.empty())
    {
        int x = q.front().first;
        int t = q.front().second;
        q.pop();
        if (x == f && t == 0)
            return (d[x][t]) / 3;
        for (int i = 0; i < a[x].size(); ++i)
        {
            int h = a[x][i];
            if (!c[h][(t + 1) % 3])
            {
                c[h][(t + 1) % 3] = true;
                d[h][(t + 1) % 3] = d[x][t] + 1;
                q.push(m_p(h, (t + 1) % 3));
            }
        }
    }
    return -1;
}

int main()
{
    scanf("%d%d", &n, &m);
    while (m--)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        a[x].push_back(y);
    }
    scanf("%d%d", &s, &f);
    printf("%d\n", bfs());
    return 0;
}


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

int main() {
    string S, T;
    cin >> S >> T;
    int N = S.size();
    for (int i = 0; i < N; i++) {
        if (S[i] != T[i]) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 3628
# coding: utf-8
import bisect

N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for i in range(N):
    for j in range(i + 1, N - 1):
        ans += max(bisect.bisect_right(L, L[i] + L[j] - 1) - j - 1, 0)
print(ans)

Measured memory_bytes: 43100
#include<iostream>
#include<cstdio>
using namespace std;
int a,b,c,a1,bb[100000+5];
int main()
{
	cin>>a>>b>>c;
	a=a%b;a1=a;
	if (a==0&&c==0) {cout<<"YES"<<endl;return 0;}
	if (a==0&&c!=0) {cout<<"NO"<<endl;return 0;}
	while (1)
	{
		if (a==c) {cout<<"YES"<<endl;return 0;}
		a+=a1;
		a=a%b;
		if (bb[a]==10) break;
		bb[a]++;
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define frw(i, a, b) for(int i = a; i < b; i++)
#define fi first
#define se second
#define pb push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define vpii vector<pii>
#define vpiii vector<piii>
#define vpll vector<pll>
#define vplll vector<plll>
#define mod 1000000007

ll maax=1000001;
ll p[10000001];

 ll dp[200000];

int inv(ll x,ll y)
{
	//ll y=mod-2;
	unsigned int res=1;
	while(y>0)
	{
		if(y&1)
			res=(res*x)%mod;
		y=y>>1;
		x=(x*x)%mod;
	}
	return res;
}
void seive()
{
	p[0]=1;
	p[1]=1;
	for(int i=2;i<maax;i++)
	{
		if(p[i]==0)
		{
			for(int j=2*i;j<maax;j+=i)
			{
				if(p[j]==0)
					p[j]=i;
	
			}
			p[i]=i;
		}
	}
}
ll md(ll a){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}
int main()
{
	int n,k;
	cin>>n>>k;
	int r,s,p;
	cin>>r>>s>>p;
	string t;
	cin>>t;
	ll a=0;
	for(int i=0;i<n;i++)
	{
		if(i<k)
		{
			if(t[i]=='r')
				a+=p;
			if(t[i]=='s')
				a+=r;
			if(t[i]=='p')
				a+=s;
		}
		else
		{
			if(t[i]=='r'&&t[i-k]!='r')
				a+=p;
			if(t[i]=='s'&&t[i-k]!='s')
				a+=r;
			if(t[i]=='p'&&t[i-k]!='p')
				a+=s;
			if(t[i]=='r'&&t[i-k]=='r')
				t[i]='x';
			if(t[i]=='s'&&t[i-k]=='s')
				t[i]='x';
			if(t[i]=='p'&&t[i-k]=='p')
				t[i]='x';

		}
	}
	cout<<a;
		


}


Measured memory_bytes: 512
/**
*    created: 31.05.2020 22:32:35
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long N;
    cin >> N;
    const auto &res = prime_factorize(N);
    ll ans = 0;
    for(auto p:res){
        int i = 1;
        while(1){
            if(p.second<i)
                break;
            p.second -= i;
            i++;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>
#include <atcoder/all>


using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;


#define REP(i, n) for(ll i = 0; i < n; i++)





















int main(){
    ll n, q;
    cin >> n >> q;
    dsu uni(n);
    REP(i, q){
        ll t, u, v;
        cin >> t >> u >> v;
        if(t == 0){
            uni.merge(u, v);
        }
        else{
            cout << uni.same(u, v) << endl;
        }
    }
}

Measured memory_bytes: 4080
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const ll int INF = 1e18+5;
int main()
{
    string s,t;
    cin >> s >> t;
    int m=s.size(),n=t.size();
    vector<vector<int>> dp(m+1,vector<int>(n+1,0));
    for(int i=0;i<=m;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else 
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j]);
                dp[i][j]=max(dp[i][j-1],dp[i][j]);
                if(s[i-1]==t[j-1])
                    dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
            }
        }
    }
    //cout << dp[m][n];//return 0;
    int index=dp[m][n]-1;
    vector<char> result(dp[m][n]);
    int i=m-1,j=n-1;
    while(index>=0)
    {
        if(s[i]==t[j])
        {
            result[index]=s[i];
            i--;j--;index--;
        }
        else if(dp[i+1][j]<dp[i][j+1])
        {
            i--;
        }
        else 
        {
            j--;
        }
    }
    for(int i=0;i<result.size();i++)
        cout << result[i];
}


Measured memory_bytes: 35584