akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpl;
typedef vector<tuple<int, int, int>> vti;
const double PI=3.14159265358979323846;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    double a, b, x;
    cin >> a >>  b >> x;
    
    double rate = x / (a*a*b);
    
    double t;
    if (rate > 0.5){
        rate = 1 - rate;
        t = (a) / (2*rate*b);
        double rad = 90 - (180 * atan(t) / PI);
        printf("%.7f\n", rad);
    } else{
        t = (b) / (2*a*rate);
        double rad = 180 * atan(t) / PI;
        printf("%.7f\n", rad);
    }

}


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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void solve() {
    string s, t;
    cin >> s >> t;
    ll c = 0;
    rep(i, sz(s)){
        c += ((s[i] != t[i]) ? 1 : 0);
    }
    cout << c << endl;
}

int main() {
    IOS;
    //io_set();
    ll tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
    }
    return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

struct Data {
  int x,dir,index;
};

int n,l,cnt[1000];

void compute(vector<Data> vec){
  int timer = 0, ant = -1;
  while( !vec.empty() ){
    ++timer;
    rep(i,l+1) cnt[i] = 0;
    vector<Data> nvec = vec;
    rep(i,nvec.size()) {
      nvec[i].x += nvec[i].dir;
      ++cnt[nvec[i].x];
    }
    vector<Data> inner,outer;
    rep(i,nvec.size()) {
      if( nvec[i].x == 0 || nvec[i].x == l ) {
	outer.push_back(nvec[i]);
      } else {
	inner.push_back(nvec[i]);
      }
    }
    
    rep(i,l+1) if( cnt[i] >= 2 ){
      rep(j,inner.size()) if( inner[j].x == i ) {
	inner[j].dir *= -1;
      }
    }

    vec = inner;
    if( vec.empty() ) {
      if( outer.size() == 1 ) ant = outer[0].index + 1;
      else {
	assert( outer.size() == 2 );
	rep(i,outer.size()) if( outer[i].x == 0 ) {
	  ant = outer[i].index + 1;
	  break;
	}
      }
    }
  }
  cout << timer << " " << ant << endl;
}

int main(){
  while( cin >> n >> l, n|l ) {
    vector<Data> vec(n);
    rep(i,n){
      char d;
      cin >> d >> vec[i].x;
      vec[i].dir = ((d=='L')?-1:1);
      vec[i].index = i;
    }
    compute(vec);
  }
  return 0;
}

Measured memory_bytes: 1224
#include <stdio.h>

#define MAX 100000

int binarySearch(int*,int,int);

int main(){

int n,s[MAX],q,t[MAX],i,j,count=0;

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

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

if(binarySearch(&s[0],n,t[i])==1) count++;

}

printf("%d\n",count);

return 0;


}

int binarySearch(int A[], int n, int key){

  int left,right,mid;

  left=0;
  right=n; 

  while(left<right){
    mid=(left+right)/2;
    if(A[mid]==key) return 1;
    else if(key<A[mid]) right=mid;
    else left=mid+1;
}

return 0;

}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, string>> pa;
  for(int i=0; i < m; i++){
    int p; string s;
    cin >> p >> s;
    pa.push_back(make_pair(p, s));
  }
  bool acc[n];
  for(int i=0; i < n; i++) acc[i] = false;
  int w[n+1] = {0};
  int ac = 0;
  for(int i=0; i < m; i++) {
    if(pa[i].second == "AC" && !acc[pa[i].first-1]) {
      ac++;
      acc[pa[i].first-1] = true;
    }
    if(pa[i].second == "WA" && !acc[pa[i].first-1]) w[pa[i].first-1]++;
  }
  int wa = 0;
  for(int i=0; i < n; i++) if(acc[i]) wa += w[i];
  cout << ac << " " << wa << endl;
}


Measured memory_bytes: 7024
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        for (int i=0; i<N;i++){
            if (sc.next().equals("Y")){
                System.out.println("Four");
                System.exit(0);
            }
        }
        System.out.println("Three");
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
const int M = 1000000007;
const double PI = atan(1) * 4;
const int oo = 1000000000;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define pb push_back 
#define all(c) (c).begin(),(c).end()
int n,m;
ll f[N];

int main(){
	f[1]=1;
	for(ll i=2; i<N; ++i)
		f[i]=(f[i-1]*i)%M;
	cin>>n>>m;
	if(abs(n-m)>1)return cout<<0<<endl,0;
	if(n==m)cout<<(2*f[n]*f[m])%M<<endl;
	else cout<<(f[n]*f[m])%M<<endl;
}




Measured memory_bytes: 1024
from fractions import gcd


def main():
    A, B = map(int, input().split(" "))
    g = gcd(A, B)
    answer = [1]
    while not g % 2:
        g //= 2
        answer.append(2)
    i = 3
    while i * i <= g:
        if not g % i:
            g //= i
            answer.append(i)
        else:
            i += 2
    if not g == 1:
        answer.append(g)
    print(len(set(answer)))


if __name__ == '__main__':
    main()



Measured memory_bytes: 5048
from collections import deque


n, q = map(int, input().split())
n_t = deque()
for i in range(n):
    s, j = input().split()
    n_t.append([str(s), int(j)])

timer = 0

while n_t:
    s, i = n_t.popleft()
    if i > q:
        i -= q
        timer += q
        n_t.append([s, i])
    else:
        timer += i
        print("{0} {1}".format(s, timer))

Measured memory_bytes: 15932
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

signed main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    
    sort(all(v));
    reverse(all(v));
    
    
    vector<int> w;
    rep(i,n-1){
        if(v[i]==v[i+1]){
            w.pb(v[i]);
            i++;
        }
    }
    
    if(w.size()<=1)cout<<0<<endl;
    else cout<<w[0]*w[1]<<endl;
}

Measured memory_bytes: 1660
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) Yes;
  else No;
  return 0;
}



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

int main(){
    int x,y;
    for(int i=0;i<=3000;++i){
        cin >> x >> y;
        if(x==0 && y==0){
            break;
        }
        if(x>y){
            int tmp=x;
            x=y;
            y=tmp;
            cout << x << " " << y << endl;
        }else{
            cout << x << " " << y << endl;
        }
    }
    return 0;
}


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

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int> > A(N, vector<int>(M));
    for(int i=0; i<N; i++){
        cin >> C.at(i);
        for(int j=0; j<M; j++) cin >> A.at(i).at(j);
    }
    int min = 1200001;
    for(int tmp = 0; tmp < (1 << N); tmp++){
        bitset<12> s(tmp);
        vector<int> R(M, 0);
        int K = 0;
        for(int i=0; i<N; i++){
            if(s.test(i)){
                for(int j=0; j<M; j++) R.at(j) += A.at(i).at(j);
                K += C.at(i);
            }
        }
        bool flag = true;
        for(int j=0; j<M; j++){
            if(X > R.at(j)) flag = false;
        } 
        if(flag && K < min) min = K;
    } 
    if(min == 1200001) cout << -1 << endl;
    else cout << min << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

// order statistics tree
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
             tree_order_statistics_node_update> indexed_set;

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define rrep(i, b, a) for(int i = b; i >= a; --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

ll W, H, x,y;
int main() {
  cin.tie(0); cin.exceptions(cin.failbit);
  scanf("%lld%lld%lld%lld", &W, &H, &x, &y);
  bool mid = (x == W/2.0) && (y == H/2.0);
  printf("%lf %d\n", W*H/2.0, (int)mid);
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
 
n,w=map(int,input().split())
dp=[0]*(w+1)
 
def ans(n,w):
  for _ in range(n):
    c,p=map(int,input().split())
    for j in range(w,c-1,-1):
      tmp=dp[j-c]+p
      if dp[j]<tmp:
        dp[j]=tmp
  return dp[-1]
print(ans(n,w))

Measured memory_bytes: 7668
# あみだくじ
H, W, K = map(int,input().split())
# h番目のときに、k本目にたどりつく通り
dp = [[0 for j in range(W)] for i in range(H+1)] #高さHでK本
# dp[h][k] = dp[h-1][k-1]*(hにおけるk-1からkへの線の引き方) 
#          + dp[h-1][k]*(hにおける、k-1,k+1から線がひかれないとき) 
#          + dp[h-1][k*1]*(hにおけるk+1からkへの線の引き方)
# 線の引き方は、対象の線からフィボナッチ的に増えていく。
# なぜならx(引かない)の数だけ隣の候補が増える

def fib(n):
    fibonacci = [1,1,2,3,5,8,13,21,34]
    return fibonacci[n]

if W == 1:
    print(1)
else:

    dp[0][0] = 1
    for h in range(1,H+1):
        for k in range(W):
            if 0 < k < W-1: 
                num1 = dp[h-1][k-1]*fib(W-k-1)*fib(k-1)
                num2 = dp[h-1][k]  *fib(W-k-1)*fib(k)
                num3 = dp[h-1][k+1]*fib(W-k-2)*fib(k)
            if k == 0: 
                num1 = 0
                num2 = dp[h-1][k]  *fib(W-k-1)*fib(k)
                num3 = dp[h-1][k+1]*fib(W-k-2)*fib(k)
                
            if k == W-1: 
                num1 = dp[h-1][k-1]*fib(W-k-1)*fib(k-1)
                num2 = dp[h-1][k]  *fib(W-k-1)*fib(k)
                num3 = 0
            # print("({},{}):{}+{}+{}".format(h,k,num1,num2,num3))
            dp[h][k] = num1+num2+num3
    mod = 10**9+7
    print(dp[-1][K-1]%mod)



Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
const long long maxn=100000,mod=1e9+7;
long long n,m,a[22],jc[111111],injc[111111],dp[22][111111],ans;
long long binpow(long long a,long long t)
{
	long long res=1,p=a;
	for (long long i=t;i;i>>=1)
	{
		if (i&1) res=res*p%mod;
		p=p*p%mod;
	}
	return res;
}
void Init()
{
	jc[0]=injc[0]=1;
	for (long long i=1;i<=maxn;i++)
	{
		jc[i]=jc[i-1]*i%mod;
		injc[i]=injc[i-1]*binpow(i,mod-2)%mod;
	}
}
long long C(long long n,long long k)
{
	if (n<k) return 0;
	return (jc[n]*injc[n-k]%mod)*injc[k]%mod;
}
long long add(long long &a,long long b)
{
	a+=b;
	if (a>=mod) a-=mod;
	if (a<0) a+=mod;
}
int main()
{
	scanf("%lld%lld",&n,&m);
	for (long long i=1;i<=m;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+m+1);
	Init();
	dp[m][0]=1;
	for (long long i=m;i>=1;i--)
	{
		for (long long j=0;j<(1ll<<n);j++)
		{
			if (!dp[i][j]) continue;
			add(dp[i-1][j],dp[i][j]);
			for (long long k=0;k<n;k++)
			{
				if (j&(1ll<<k)) continue;
				add(dp[i-1][j|(1ll<<k)],(-dp[i][j]*C((1ll<<n)-a[i]-j,(1ll<<k)-1)%mod)*jc[1<<k]%mod);
			}
		}
	}
	for (long long j=0;j<(1ll<<n);j++)
	{
		add(ans,dp[0][j]*jc[(1ll<<n)-1-j]%mod);
	}
	ans=ans*(1ll<<n)%mod;
	printf("%lld\n",(ans+mod)%mod);
	return 0;
} 

Measured memory_bytes: 16256
#include <stdio.h>
#include <stdlib.h>
#include  <math.h>
int main()
{
   int i,n,cont=0;
    long long  a[10010];
   scanf("%d",&n);
   for(i=0;i<n;i++)
    scanf("%lld",&a[i]);
   for(i=0;i<n;i++)
   {
      while(a[i]%2==0)
      {
          cont++;
          a[i]=a[i]/2;
      }
   }
 printf("%d\n",cont);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

// cf https://qiita.com/drken/items/cce6fc5c579051e64fab
template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight; //親との差分
 
    UnionFind(int n = 1, Abel SUM_UNITY = 0){
        init(n, SUM_UNITY);
    }
 
    void init(int n = 1, Abel SUM_UNITY = 0){
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for(int i=0; i<n; i++) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }
 
    int root(int x){
        if(par[x] == x){
            return x;
        }
        else{
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }
 
    Abel weight(int x){
        root(x);
        return diff_weight[x];
    }
 
    bool issame(int x, int y){
        return root(x) == root(y);
    }
 
    // weight[y] - weight[x] = w になるようにマージする（x yがそれぞれの木でrootになってるわけではないことに注意）
    bool merge(int x, int y, Abel w){
        // xとyそれぞれについて、rootとの重み差分を補正
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if(x == y) return false;
        if(rank[x] < rank[y]) swap(x, y), w = -w;
        if(rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }
 
    Abel diff(int x, int y){
        return weight(y) - weight(x);
    }
};
 
int main(){
    int N, M; cin >> N >> M;
    UnionFind<int> uni(N);

    vector<int> l(M), r(M), d(M);
    for(int i=0; i<M; i++) cin >> l[i] >> r[i] >> d[i];

    for(int i=0; i<M; i++){
        l[i]--, r[i]--;
        
        if(uni.issame(l[i], r[i])){
            int diff = uni.diff(l[i], r[i]);
            if(diff != d[i]){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            uni.merge(l[i], r[i], d[i]);
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 3712
using System;
class Qsort
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int n = int.Parse(str[0]);
        int l = int.Parse(str[1]);

        if (l > 0)
        {
            Console.WriteLine((n - 1) * (l - 1) + n * (n +1) / 2 - 1);
        }
        else if (-n + 1 <= l && l <= 0)
        {
            Console.WriteLine((n - 1) * (l - 1) + n * (n + 1) / 2 - (1 - l));
        }
        else
        {
            Console.WriteLine((n - 1) * (l - 1) + n * (n + 1) / 2 - n);
        }


    }


}

Measured memory_bytes: 13140
/*
    _____
  .'|||||'.
 /  >   <  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
    |||||
*/

#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<set>
#include<map>
#include<vector>
#include<cstring>
#include<stack>
#include<cmath>
#include<queue>
using namespace std;
#define CL(x,v); memset(x,v,sizeof(x));
#define INF 0x3f3f3f3f
#define LL long long
#define REP(i,r,n) for(int i=r;i<=n;i++)
#define RREP(i,n,r) for(int i=n;i>=r;i--)
int n,a[200010],num[200010],b[200010];
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        b[i]=a[i];
        num[a[i]]++;
    }
    sort(a+1,a+1+n);
    for (int i=1;i<=n;i++)
    {
        if (b[i]!=a[n]) printf("%d\n",a[n]); else
        {
            if (num[a[n]]==1) printf("%d\n",a[n-1]); else printf("%d\n",a[n]);
        }
    }
    return(0);
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
#define int long long
#include<bitset>
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
void solve() {
   int n;
   cin>>n;
   for(int i=sqrt(n);i>=2;--i)
   {
       if(n%i==0)
       {
           //cout<<"D"<<i<<" ";
           cout<<i-1+((n/i)-1);
           return;
       }
   }
   cout<<n-1;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t=1;
    //cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 3568
N = 100

def mode_value(arr)
  n = 0
  mv = []
  
  N.times do |i|
    if n < arr[i]
      mv = [i + 1]
      n = arr[i]
    elsif n == arr[i]
      mv << i + 1
    end
  end
  
  return mv
end

arr = []

N.times do
  arr << 0
end


while line = gets
  arr[line.to_i - 1] += 1
end

mode_value(arr).each do |v|
  puts v
end

Measured memory_bytes: 6096
#include<bits/stdc++.h>
#define ll long long
#define int long long int
#define MOD 1000000007
#define mkp make_pair
#define maxN 100005
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
using namespace std;
const int infi=1e9+7;
void printVector(vector<int> v){
    for(int i=0;i<(int)v.size();i++)
        cout<<v[i]<<" ";
    out endl;
}

void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
cout<<endl;
}
 set<pair<int,int>> primeset;
 vi prime_number;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
           primeset.insert(mkp(p,1));
}
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}
int32_t main()
{
fastio;
int t=1;
//in t;
while(t--){
int a;int b;int c;
in a;in b;in c;
if(a+b+c>=22) out "bust";
else out "win";
}
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 300005
#define LL long long
#define mod 1000000007
//#define pr pair<int,int>
//#define mp(x,y) make_pair(x,y)
#define max(a,b) (((a)>(b))?(a):(b))
using namespace std;

int read(){
	char c=getchar();
	int t=0,f=1;
	while(c>'9'||c<'0') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') t=t*10+c-'0',c=getchar();
	return t*f;
}

void write(LL x){
	if(x>=10) write(x/10);
	putchar(x%10+'0');
}

int n,a[N],Q,q[N],tp,op;
LL sum[N],f[N],g[N],mx1[N],mx2[N],pre[N],suf[N],tmp[N];
double qY(int x){return ((!op)?f[x]:g[x])+0.5*(x-1)*x+sum[x];}
double qK(int x,int y){return (qY(y)-qY(x))/(y-x);}
void gsum(){for(int i=1;i<=n;i++)sum[i]=sum[i-1]+a[i];}

void DP(LL *dp){
	q[tp=1]=0;
	for(int i=1;i<=n;i++){
		while(tp>1&&qK(q[tp-1],q[tp])<=i) tp--;
		dp[i]=max(dp[i-1],dp[q[tp]]-(sum[i]-sum[q[tp]])+1LL*(i-q[tp])*(i-q[tp]+1)/2);
		while(tp>1&&qK(q[tp],i)>qK(q[tp-1],q[tp])) tp--;
		q[++tp]=i;
	}
}

void solve(int L,int R,LL *A,LL *pr,LL *su){
	if(L==R) return (void)(A[L]=pr[L-1]+1-a[L]+su[L+1]);
	int mid=(L+R)>>1;
	solve(L,mid,A,pr,su),solve(mid+1,R,A,pr,su),q[tp=1]=L;
	for(int i=L+1;i<=mid;i++){
		while(tp>1&&qK(q[tp],i)>qK(q[tp-1],q[tp])) tp--;
		q[++tp]=i;
	}
	for(int i=mid+1;i<=R;i++){
		while(tp>1&&qK(q[tp-1],q[tp])<=i) tp--;
		tmp[i]=pr[q[tp]]-(sum[i]-sum[q[tp]])+1LL*(i-q[tp])*(i-q[tp]+1)/2+su[i+1];
	}
	for(int i=R-1;i>mid;i--) tmp[i]=max(tmp[i],tmp[i+1]);
	for(int i=mid+1;i<=R;i++) A[i]=max(A[i],tmp[i]);
}

int main(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	op=0,gsum(),DP(f),reverse(a+1,a+n+1);
	op=1,gsum(),DP(g),reverse(a+1,a+n+1),reverse(g+1,g+n+1);
	op=0,gsum(),solve(0,n,pre,f,g),reverse(f+1,f+n+1),reverse(g+1,g+n+1),reverse(a+1,a+n+1);
	op=1,gsum(),solve(0,n,suf,g,f),reverse(f+1,f+n+1),reverse(g+1,g+n+1),reverse(suf+1,suf+n+1);
	for(int i=1;i<=n;i++) mx1[i]=f[i-1]+g[i+1],mx2[i]=max(pre[i],suf[i]);
	Q=read(),reverse(a+1,a+n+1);
	while(Q--){
		int po=read(),v=read();
		printf("%lld\n",max(mx1[po],mx2[po]+a[po]-v));
	}
}

Measured memory_bytes: 23680
/* 
 * Project: AtCoder Beginners Contest 175 A - Rainy Season
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/08/29
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstdint>
#include <algorithm>
using namespace std;

int main() {

    int8_t c;
    uint32_t cnt = 0;
    uint32_t max_cnt = 0;
    for (int i=0;i<3;i++) {
        scanf("%c", &c);
        if (c == 'R') {
            cnt++;
        } else {
            cnt = 0;
        }
        max_cnt = max(max_cnt,cnt);
    }
    printf("%d\n", max_cnt);

}

Measured memory_bytes: 3252
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
    int n;
    while(cin >> n,n){
        int res=-1;
        int cnt=0;
        vector<int> m(n);
        vector<int> v[n];
        for(int i=0;i<n;i++){
            cin >> m[i];
            for(int j=0;j<m[i];j++){
                int x; cin >> x;
                v[i].push_back(x);
            }
            sort(v[i].begin(),v[i].end());
        }
        int k; cin >> k;
        vector<int> vv(k);
        for(int i=0;i<k;i++){
            cin >> vv[i];
        }
        sort(vv.begin(), vv.end());
        for(int i=0;i<n;i++){
            int kk=0;
            for(int j=0;j<v[i].size();j++){
                if(vv[kk]==v[i][j]){
                    kk++;
                }
                if(kk==k)break;
            }
            if(kk==k){
                cnt++;
                res=i+1;
            }
        }
        if(cnt==1)printf("%d\n",res);
        else printf("-1\n");
    }
}



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

const int N = 200100;

ll n, k, a[N], f[N];

ll fu(ll x){
    ll sum = 0;
    for (int i = 1; i <= n; i++){
        sum += max(0ll, a[i]-x/f[i]);
    }
    return sum <= k;
}

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

    cin >> n >> k;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++){
        cin >> f[i];
    }
    sort(a+1, a+n+1);
    sort(f+1, f+n+1);
    reverse(f+1, f+n+1);
    ll l = 0, r = 1e12;
    while(l < r){
        ll mid = (l+r)>>1;
        if (fu(mid))
            r = mid;
        else
            l = mid+1;
    }
    cout << l;

}

Measured memory_bytes: 3328
import bisect
N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
count = 0
for b in B:
    a = bisect.bisect_left(A,b)
    c = bisect.bisect_right(C,b)
    count += a*(N-c)
print(count)

Measured memory_bytes: 29368
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2 ;
    int x3 = 0, y3 = 0, x4 = 0,y4 = 0;
    int dx = x2-x1 ,dy = y2-y1;
    x3 = x2 - dy;
    y3 = y2 + dx;
    x4 = x3 - dx;
    y4 = y3 - dy;

   
    cout << x3  << " " << y3 << " " << x4  << " " << y4 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define debug(x) cout << #x << " = " << x << endl
#define print(x) cout << x << endl;
ll MOD = 1000000007;

ll modPow(ll a, ll n, ll p)
{
    if (n == 1)
        return a % p;
    if (n % 2 == 1)
        return (a * modPow(a, n - 1, p)) % p;
    long long t = modPow(a, n / 2, p);
    return (t * t) % p;
}

ll modInv(ll a, ll p)
{
    ll b = p, u = 1, v = 0;
    while (b)
    {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= p;
    if (u < 0)
        u += p;
    return u;
}

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;

    ll nCa = 1;
    ll nCb = 1;

    ll a_inv = 1;
    ll b_inv = 1;
    for (ll i = 0; i < a; i++)
    {
        nCa = (nCa * (n - i)) % MOD;
        a_inv = (a_inv * (i + 1)) % MOD;
    }

    for (ll i = 0; i < b; i++)
    {
        nCb = (nCb * (n - i)) % MOD;
        b_inv = (b_inv * (i + 1)) % MOD;
    }

    nCa = (nCa * modInv(a_inv, MOD)) % MOD;
    nCb = (nCb * modInv(b_inv, MOD)) % MOD;

    ll ans = (modPow(2, n, MOD) - 1 - nCa - nCb + MOD + MOD) % MOD;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int N,B,A;
  scanf("%d%d%d",&N,&A,&B);
  char S[N];
  scanf("%s",S);

  int counta=0,countb=1;

  for(int i=0;i<N;i++){
    if(S[i]=='a'&& A+B>counta){
     
        counta++;
        printf("Yes\n");
      
	}
    else if(S[i]=='b' && A+B>counta && countb <=B){
      
        countb++;
        counta++;
        printf("Yes\n");
      
    }

    else {
      printf("No\n");
    }
}
  return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
int K,S;
int ctr = 0;
int main(){
    cin >> K >> S;
    for(int i = 0; i <= K;i++){
        for(int j = 0; j <= K; j++){
            if(i+j<=S && S-i-j <= K) ctr++;
        }
    }
    cout << ctr << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(int argc, char **argv)
{
  int a, b, c, i;
  scanf("%d %d %d\n", &a, &b, &c);
  for (i=0;i<c;i++) {
    b -= a;
    if (b < 0) break;
  }
  printf("%d\n", i);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int ,int> pi;
typedef pair<ll ,ll> pl;
typedef map<ll ,ll> ml;
#define modulo 1000000007
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N=1e7+1;
int arr[N];

void solve()
{
    for(int i=1;i<N;i++)
        for(int j=0;(j+=i)<N;)arr[j]++;
    ll n;
    cin >> n;
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        ans+=i*arr[i];
    }
    cout <<  ans << endl;
}

int main()
{
    fast;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 42696
#![allow(unused)]

use std::io::stdin;
use std::str::FromStr;

fn input<T: FromStr>() -> Result<T, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse()
}

fn input_vec<T: FromStr>() -> Result<Vec<T>, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse())
        .collect()
}

use std::cmp::max;

fn main() {
    let mut s: Vec<char> = input::<String>().unwrap().chars().collect();
    if s.len() % 2 == 1 {
        s.pop();
    } else {
        s.pop();
        s.pop();
    }

    while s.len() != 0 {
        if is_odd_str(&s) {
            println!("{}", s.len());
            break;
        }
        s.pop();
        s.pop();
    }
}

fn is_odd_str(s: &Vec<char>) -> bool {
    let n = s.len();
    let pre = &s[..n/2];
    let suf = &s[n/2..];
    pre == suf
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int arr[105] , dp[100005];
int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int n , k ;
	cin>>n>>k;
	for(int i = 0; i < n ; i++)
		cin>>arr[i];
	for(int i = 0 ; i <= k;  i++){
		for(int j = 0; j < n ; j++){
			if(i - arr[j] < 0)continue;
			if(dp[i - arr[j]] == 0)
				dp[i] = 1;
		}
	}
	if(dp[k])cout<<"First";
	else cout<<"Second";
    return 0;
}


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

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int k = int.Parse(Console.ReadLine());
        int x = int.Parse(Console.ReadLine());
        int y = int.Parse(Console.ReadLine());
        Console.WriteLine(n <= k?x * n:x * k + y*(n - k));
    }
}

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

int main() {
    int N, L;
    cin >> N >> L;
    vector<int> taste(N);
    int all = 0;
    rep(i, N) {
        cin >> taste[i];
        taste[i] = L + i;
        all += taste[i];
    }
    int ans = 1e9;
    rep(i, N) {
        int t = all - taste[i];
        if (abs(t - all) < abs(ans - all)) ans = t;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define fo(i,j,k) for(int i=j;i<=k;++i)
#define fd(i,j,k) for(int i=j;i>=k;--i)
using namespace std;
const int N=1e5+10;
int a[N];
bool cmp(int x,int y){
	return x>y;
}
int main()
{
	int n;
	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&a[i]);
	sort(a+1,a+n+1,cmp);
	int p=0,q=p;
	while(a[p+1]>=p+1) p++;
	p--;
	fo(i,p+1,n) if(a[i]<=p) break;
	else q=i;
	if((q-p)&1 && (a[p+1]-p)&1) printf("Second");
	else printf("First");
}


Measured memory_bytes: 512
n = int(input())
a = list(map(int,input().split()))

a.sort()
if a[-1] - a[0] >= 2:
    print("No")
elif a[-1] - a[0] == 1:
    m = 0
    for x in a:
        if x == a[0]:
            m += 1
        else:
            break
    if  a[-1]-m <= (n-m)//2 and a[-1]-m > 0:
        print("Yes")
    else:
        print("No")
else:
    if a[0] == n-1 or a[0] <= n//2:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 13964
n = int(input())
maxPlus, minPlus, maxMinus, minMinus = 0, 10**9 , -10**9, 10**9
for _ in range(n):
    x, y = map(int, input().split())
    maxPlus = max(x + y, maxPlus)
    minPlus = min(x + y, minPlus)
    maxMinus = max(x - y, maxMinus)
    minMinus = min(x - y, minMinus)
print(max(abs(maxPlus - minPlus), abs(maxMinus - minMinus)))

Measured memory_bytes: 9212
/** Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    if(s[0] == s[1] && s[1] == s[2])    cout<<"No";
    else    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        string S;
        cin >> N >> S;
        ll mx = -1;
        rep(i, 1, len(S)) {
                string a, b;
                a = S.substr(0, i);
                b = S.substr(i, len(S) - i);
                set<char> tmp1(all(a));
                set<char> tmp2(all(b));

                set<char> res;
                set_intersection(all(tmp1), all(tmp2), inserter(res, res.begin()));
                chmax(mx, len(res));
        }
        cout << mx << endl;
}

Measured memory_bytes: 256
n = int(input())
#l = [0]*n
l = [int(input()) for i in range(n)]

m_l = [0]
m_r = [0]

for i in range(n):
  m_l.append(max(m_l[i], l[i]))
  m_r.append(max(m_r[i], l[-(i+1)]))
m_r = m_r[::-1]
#print(m_l) 
#print(m_r)

for i in range(n):
  print(max(m_l[i], m_r[i+1]))

Measured memory_bytes: 15736
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

int N, M, L;
int G[310][310];
int P[310][310];
void warshall() {
	REP(i, N) {
		REP(j, N) {
			REP(k, N) {
				G[j][k] = min(G[j][k], G[j][i] + G[i][k]);
			}
		}
	}
}
void pwarshall() {
	REP(i, N) {
		REP(j, N) {
			REP(k, N) {
				P[j][k] = min(P[j][k], P[j][i] + P[i][k]);
			}
		}
	}
}

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

	cin >> N >> M >> L;
	REP(i, N) {
		REP(j, N)G[i][j] = INF+10;
	}
	REP(i, M) {
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		G[a][b] = c;
		G[b][a] = c;
	}

	warshall();
	REP(i, N) {
		REP(j, N) {
			if (G[i][j] <= L)P[i][j] = 1;
			else P[i][j] = INF;

		}
	}
	
	pwarshall();
	/*REP(i, N) {
		REP(j, N) {
			cout << P[i][j];
		}
		cout << endl;
	}
	REP(i, N) {
		REP(j, N) {
			cout << G[i][j];
		}
		cout << endl;
	}*/
	int q;
	cin >> q;
	REP(i, q) {
		int s, t;
		cin >> s >> t;
		s--;
		t--;

		if (P[s][t] == INF)cout << -1 << endl;
		else cout << P[s][t]-1 << endl;
		
	}

	return 0;
}



Measured memory_bytes: 2048
#include <stdio.h>
#include <stdlib.h>
#define inf (int)(1e9)

int min(int a, int b){
	return a <= b ? a : b;
}

int main(){
	int N, x, y, a, i, j, K = 16, ans = 0, remain_num, xor, i_num;
	scanf("%d", &N);
	int *val = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		val[i] = 0;
	}
	for(i = 1; i < N; i++){
		scanf("%d%d%d", &x, &y, &a);
		val[x] ^= a;
		val[y] ^= a;
	}
	int *remain = (int *)malloc(sizeof(int) * K);
	for(i = 0; i < K; i++){
		remain[i] = 0;
	}
	for(i = 0; i < N; i++){
		if(val[i] > 0 && remain[val[i]] == 1){
			ans++;
		}
		remain[val[i]] ^= 1;
	}
	remain[0] = 0;
	remain_num = 0;
	for(i = 0; i < K; i++){
		remain_num ^= (remain[i] << i);
	}
//	printf("ans = %d\n", ans);
//	printf("remain_num = %d\n", remain_num);
	int *dp = (int *)malloc(sizeof(int) * (1 << K));
	dp[0] = 0;
	for(i = 0; i < (1 << K); i++){
//		printf("dp[%d] = %d\n", i, dp[i]);
		xor = 0;
		i_num = 0;
		for(j = 0; j < K; j++){
			if((i & (1 << j)) != 0){
//				printf("j = %d\n", j);
				xor ^= j;
				i_num++;
			}
		}
		if(xor != 0){
			dp[i] = inf;
		}
		else{
			dp[i] = i_num - 1;
//			printf("dp[%d] = %d\n", i, dp[i]);
			for(j = i; j > 0; j = ((j - 1) & i)){
				dp[i] = min(dp[i], dp[j] + dp[i ^ j]);
			}
		}
		if(i == 0){
			dp[i] = 0;
		}
//		printf("dp[%d] = %d\n", i, dp[i]);
		if(i == remain_num){
			printf("%d\n", ans + dp[remain_num]);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String value = "";
		String valueSum = "";
		
		while(sc.hasNext()) {
			value = sc.nextLine();
			valueSum += value;			
		}
		
		int[] abc = {0,0,0,0,0,0,0,0,0,0,
				0,0,0,0,0,0,0,0,0,0,
				0,0,0,0,0,0};
		
		String a = "abcdefghijklmnopqrstuvwxyz";
		String A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		
		for(int i = 0; i < valueSum.length(); i++) {
			Character x = valueSum.charAt(i);
			for(int j = 0; j < a.length(); j++) {
				if(x.equals(a.charAt(j)) || x.equals(A.charAt(j))) {
					abc[j]++;
				}
			}
		}
		
		for(int i = 0; i<a.length(); i++) {
			System.out.println(a.charAt(i)+" : "+abc[i]);
		}		
		sc.close();
	}
}


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

signed main(){
  int N,M;cin>>N>>M;
  string S,T;cin>>S>>T;
  int ans=N*M/__gcd(N,M);
  int ss=ans/N,tt=ans/M;
  int NG=0;
  for(int i=0;i<__gcd(N,M);i++){
    if(S[tt*i]!=T[ss*i])ans=-1;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 512
#!/usr/bin/env python3
#AGC19 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


q,h,s,d = LI()
n = I()
a,b,c = q*8,h*4,s*2
x,y = q*4,h*2
if n % 2:
    ans = min(a,b,c,d)*(n//2) + min(x,y,s)
else:
    ans = min(a,b,c,d)*(n//2)
print(ans)


Measured memory_bytes: 38256
import sys
sys.setrecursionlimit(1000000)

n,u,v=map(int,input().split())
Graph=[]
for i in range(n):
    Graph.append([])
for i in range(n-1): #隣接頂点の登録
    a,b=map(int,input().split())
    Graph[a-1].append(b-1)
    Graph[b-1].append(a-1)

def dfs(s,b=-1): #深さ優先探索(グラフ,スタート,深さ)
    for i in Graph[s]: #隣接点に対して
        if i!=b: #前の点と一緒じゃないとき
            depth[i]=depth[s]+1
            dfs(i,s) #深さを増やし、スタートを更新して再探索

depth=[0]*n
dfs(u-1)
dT=depth

depth=[0]*n
dfs(v-1)
dA=depth

dArrest=0
for i in range(n):
    if dA[i]>dT[i]: #Tが先に着ける点のうち
        dArrest=max(dArrest,dA[i]) #一番Aから遠い点
print(dArrest-1)

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

int n,N;

bool TOP(vector<int> &w){
  if(w[n-2]+w[n-1]+w[n]==3)return 1;
  if(w[n-2]+w[n-1]+w[n]==2){
    if(w[n-1])return 1;
    for(int i=0;i<n-1;i++){
      int l=w[n-2-i],r=w[n+i];
      if(i&1){if(l||r)return 1;}
      else if(!(l&&r))return 0;
    }
    return !(n&1);
  }
  if(w[n-2]+w[n-1]+w[n]==1){
    if(!w[n-1])return 0;
    for(int i=0;i<n-1;i++){
      int l=w[n-2-i],r=w[n+i];
      if(i&1){if(!(l&&r))return 0;}
      else if(l||r)return 1;
    }
    return n&1;
  }
  return 0;
}

signed main(){
  cin>>n;N=2*n-1;
  vector<int> v(N),w(N);
  for(int i=0;i<N;i++)cin>>v[i];
  int l=0,r=N+1;//rが答え
  while(r-l>1){
    int mid=(r+l)>>1;
    for(int i=0;i<N;i++)w[i]=(v[i]<=mid);
    (TOP(w)?r:l)=mid;
  }
  cout<<r<<endl;
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define SENTINEL 1000000000
int count = 0;
void Merge(vector<int>& A,int left,int mid,int right){
    int n1 = mid - left;
    int n2 = right - mid;
    vector<int> L(n1+1),R(n2+1);
    rep(i,n1){
        L[i] = A[left + i];
    }
    rep(i,n2){
        R[i] = A[mid + i];
    }
    L[n1] = SENTINEL;
    R[n2] = SENTINEL;
    int i = 0;
    int j = 0;
    for(int k=left;k<right;k++){
        if(L[i] <= R[j]){
            A[k] = L[i];
            i = i+1;
        }else{
            A[k] = R[j];
            j = j+1;
        }
        count++;
    }
}
void MergeSort(vector<int>& A,int left,int right){
    if((left + 1) < right){
        int mid = (left+right)/2;
        MergeSort(A, left, mid);
        MergeSort(A, mid, right);
        Merge(A, left, mid, right);
    }
}
int main(){
    int N;
    cin >> N;
    vector<int> A(N+1);
    rep(i,N){
        cin >> A[i];
    }
    A[N] = SENTINEL;
    MergeSort(A,0,N);
    rep(i,N){
        cout << A[i];
        if(i < N-1)cout << " ";
    }
    cout << endl << count << endl;
    return 0;
}


Measured memory_bytes: 6772
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
struct node
{
	int hieght ;
	bool max_flag ;
};

int main()
{
	int N, M;
	cin >> N >> M ;
	
	vector<node> H(N) ;
	
	for(int i = 0; i<N ; ++i)
	{
		cin>>H.at(i).hieght ;
		H.at(i).max_flag = 1 ;
	}
	
	int A,B ;
	for(int i=0; i<M; ++i)
	{
		cin >> A >> B ;
		if(H.at(A-1).hieght <= H.at(B-1).hieght)
			H.at(A-1).max_flag = 0 ;
		if(H.at(B-1).hieght <= H.at(A-1).hieght)
			H.at(B-1).max_flag = 0 ;
	}
	
	int count = 0;
	
	for( int i=0 ; i<N ; ++ i)
	{
		if(H.at(i).max_flag)
			++count ;
	}
	cout << count <<endl;
}	


Measured memory_bytes: 4040
sx, sy, tx, ty = map(int, input().split())

w = tx - sx
h = ty - sy

ans = str()
ans += 'R' * w
ans += 'U' * h
ans += 'L' * w
ans += 'D' * h

ans += 'D'
ans += 'R' * (w + 1)
ans += 'U' * (h + 1)
ans += 'L'

ans += 'U'
ans += 'L' * (w + 1)
ans += 'D' * (h + 1)
ans += 'R'

print(ans)

Measured memory_bytes: 3064
from collections import defaultdict
from bisect import bisect_right

def sol():
    S = input()
    T = input()

    setS = set(S)
    setT = set(T)
    for t in setT:
        if not t in setS:
            print('-1')
            return

    posS = defaultdict(list)

    for i, s in enumerate(S):
        posS[s].append(i)

    for s in enumerate(S):
        posS[s].sort()

    prev = -1
    ans = 0
    N = len(S)

    for t in T:
        next = bisect_right(posS[t], prev)
        if next >= len(posS[t]):
            ans += N - prev
            ans += posS[t][0]
            prev = posS[t][0]
        else:
            ans += posS[t][next] - prev
            prev = posS[t][next]

    print(ans)

sol()


Measured memory_bytes: 68936
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,W;scanf("%d%d",&N,&W);
    vector<int> v(N),w(N);
    for(int i=0;i<N;i++)scanf("%d%d",&v[i],&w[i]);
    vector<int> dp(W+1);
    for(int i=0;i<N;i++){
        vector<int> ndp(W+1);
        for(int j=0;j<W+1;j++){
            if(j<w[i])ndp[j]=dp[j];
            else ndp[j]=max(dp[j],max(ndp[j-w[i]]+v[i],dp[j-w[i]]+v[i]));
        }
        dp=ndp;
    }
    printf("%d\n",dp[W]);
    return 0;
}


Measured memory_bytes: 3332
#![allow(dead_code, unused_imports, deprecated)]
use std::cmp::{max, min, Reverse};
use std::collections::*;
use maplit::*;
use num::Integer;
use proconio::input;
use proconio::marker::*;
use proconio::fastout;

const INF : usize = 1000000007;

#[fastout]
fn main() {
  input! {
    x : isize,
  };
  
  println!{"{}", if x >= 30 { "Yes" } else { "No" }};
}

Measured memory_bytes: 2140
mod = 10**9+7
H, W, K = map(int, input().split())
dp = [[0]*W for j in range(H+1)]
dp[0][0] = 1
if W == 1:
    print(1)
    exit()
for i in range(1, H+1):
    for j in range(1<<(W-1)):
        if any((j>>k) & 1 and j>>((k+1)) & 1 for k in range(W-2)):
            continue
        if j&1:
            dp[i][0] += dp[i-1][1]
        else:
            dp[i][0] += dp[i-1][0]
        dp[i][0] %= mod
        for k in range(1, W-1):
            if (j>>k)&1:
                dp[i][k]+= dp[i-1][k+1]
            elif (j>>(k-1))&1:
                dp[i][k]+= dp[i-1][k-1]
            else:
                dp[i][k]+=dp[i-1][k]
            dp[i][k] %= mod
        if (j>>(W-2))&1:
            dp[i][W-1] += dp[i-1][W-2]
        else:
            dp[i][W-1] += dp[i-1][W-1]
        dp[i][W-1] %= mod           
print(dp[H][K-1])
            

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

int main() {
    int n;
    cin >> n;

    map<string, int> mp;

    string s;
    rep(i,n) {
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }

    ll ans = 0;
    for (auto p : mp) {
        ll t = p.second;
        ans += t*(t-1)/2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int D = sc.nextInt();
		int N = sc.nextInt();

		if (N == 100) {
			System.out.println(101 * (int)Math.pow(100, D));

		} else {
			System.out.println(N * (int)Math.pow(100, D));
		}
	}
}


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

#define rp(i, k, n) for (ll i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;

int n, m;
    vector<int> p(100000);
    vector<int> y(100000);
    vector<vector<int>> yd(100001, vector<int>(m));

int main() {
    scanf("%d%d", &n, &m);
    rp(i, 0, m) {
        scanf("%d%d",&p.at(i), &y.at(i));
        yd.at(p.at(i)).push_back(y.at(i));
    }
    rp(i, 0, n) {
        sort(yd.at(i+1).begin(), yd.at(i+1).end());
    }

    rp(i, 0, m) {
        printf("%012lld\n", ll(p.at(i)) * 1000000 + int(lower_bound(yd.at(p.at(i)).begin(), yd.at(p.at(i)).end(), y.at(i)) - yd.at(p.at(i)).begin()) + 1); 
    }
    return 0;
} 

Measured memory_bytes: 7808
def counting_sort(a)
  k = a.max
  c = Array.new(k + 1){ 0 }
  a.each{|n| c[n] += 1 }

  1.upto(k){|i| c[i] += c[i-1] }

  b = []
  (a.size-1).downto(0) do |i|
    b[c[a[i]] - 1] = a[i]
    c[a[i]] -= 1
  end
  b
end

n = gets.to_s
a = gets.split.map(&:to_i)

puts counting_sort(a).join("\s")

Measured memory_bytes: 216188
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // long long64_t, long long*_t
#include <cstdio> // prlong longf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack 
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <list>
using namespace std;
int ans=0,n,q;
vector<long long> s;
void BinarySearch(int x){
    long long left,right,mid;
    left = 0;
    right = n;
    while(left<right){
        mid =(left+right)/2;
        if(s[mid]==x){
            ans++;
            break;
        }
        else if(s[mid]>x){
            right = mid;
        }
        else{
            left = mid+1;
        }
    }
}
int main(){
   cin >> n;
   for(int i=0; i<n; i++){
       long long inp;
       cin >> inp;
       s.push_back(inp);
   }
   cin >> q;
   vector<long long> t(q);
   for(int i=0; i<q; i++){
       cin >> t[i];
   }
   for(int i=0; i<q; i++){
       BinarySearch(t[i]);
   }
   cout << ans << endl;
}



Measured memory_bytes: 4176