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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

const int MOD = 1e9 + 7;

long long power(long long a, int b) {
    long long ret = 1;
    for (; b>0; b/=2) {
        if (b % 2) ret = ret * a % MOD;
        a = a * a % MOD;
    }
    return ret;
}

int choose(int n, int k) {
    long long ret = 1;
    for (int i=0; i<k; i++)
        ret = ret * power(i + 1, MOD - 2) % MOD * (n - i) % MOD;
    return ret;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, a, b;
    cin >> n >> a >> b;

    cout << ((power(2, n) - choose(n, a) - choose(n, b) - 1) % MOD + MOD) % MOD << "\n";

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll N, T;
    cin >> N >> T;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    map<ll, ll> mp;
    ll mi = A[0];
    repd(i, 1, N) {
        mp[A[i] - mi]++;
        chmin(mi, A[i]);
    }

    ll ans = 0;
    if (mp.size() >= 1) ans = mp.rbegin()->second;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7296
#include<stdio.h>

int main(){
  char S[11];
  scanf("%s",S);
  int i,k,max;
  int num[11];
  for(i=0;i<=10;i++){
    for(k=i;k<=10;k++){
      if(S[k] != 'A' && S[k] != 'T' && S[k] != 'G' && S[k] != 'C'){
        num[i] = k - i;
        break;
       };
      };
      };
  max = 0;
  for(i=0;i<=9;i++)
    if(num[i] > max) max = num[i];
  printf("%d",max);
}

Measured memory_bytes: 128
def solve(a,k):
    curr_char = a[0]
    curr_len = 0
    segs = 1
    for x in a:
        if x==curr_char:
            curr_len += 1
        else:
            segs += 1
            curr_len = 1
            curr_char = x
    return len(a)-max(1,segs-2*k)
n,k = map(int,input().split())
print(solve([1 if c=='L' else 0 for c in input()],k))

Measured memory_bytes: 79220
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  ll asum=0,bsum=0;
  vi A(n);for(auto &a:A){cin>>a;asum+=a;}
  vi B(n);for(auto &a:B){cin>>a;bsum+=a;}
  if(bsum>asum)cout<<-1<<endl;
  else{
    priority_queue<ll>que;
    for(int i=0;i<n;i++){
      if(B[i]<A[i])que.push(A[i]-B[i]);
    }
    ll sum=0;
    ll ans=0;
    for(int i=0;i<n;i++){
      if(B[i]>A[i]){
	while(sum-(B[i]-A[i])<0){
	  sum+=que.top();
	  que.pop();
	  ans++;
	}
	sum-=(B[i]-A[i]);
	ans++;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2428
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


a, b = list(map(int, sys.stdin.buffer.readline().split()))
c, d = list(map(int, sys.stdin.buffer.readline().split()))
print((a -c ) * (b - d))


Measured memory_bytes: 13440
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (a : b : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  putStrLn . concat . replicate (max a b) $ show (min a b)

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


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

const int maxn = 100010;

char str[maxn];

int main(){
  scanf("%s", str + 1);
  int n = strlen(str + 1);
  int ans = 0;
  for(int i = 1, j;i <= n;){
    for(j = i + 1;j <= n && str[j] == str[i];++j);
    i = j;
    ans++;
  }
  printf("%d\n", ans - 1);
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int T = sc.nextInt();

		int answer = (N/X)*T;
		if(N%X!=0) {
			answer += T;
		}
		System.out.println(answer);
	}

}


Measured memory_bytes: 35844
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp; 
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字tryIndexでループするfor文に置換します
#define FOR_RANGE(tryIndex, beg, end)     for (ll tryIndex = beg; tryIndex < N; ++tryIndex)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

struct st{
    int numofCards;
    ll score;
};

int main() {
    int N, M;
    ll A[(int)1e5];
    st BC[(int)1e5];

    cin >> N >> M;
    for (int i = 0; i < N; ++i) cin >> A[i];
    for (int i = 0; i < M; ++i) {
        int b;
        ll c;
        cin >> b >> c;
        BC[i].numofCards = b;
        BC[i].score = c;
    };

    std::sort(A, A+N); // 昇順
    std::sort(BC, BC + M, [](st l, st r) { return l.score > r.score; }); // 降順

    ll sum = 0;
    int tryIndex = 0, cardIndex = 0;
    for (tryIndex = 0; tryIndex < M; ++tryIndex) {
        if (cardIndex >= N) break;
        int nextCardIndex = cardIndex + BC[tryIndex].numofCards - 1;
        if (nextCardIndex >= N) nextCardIndex = N - 1;
        if (BC[tryIndex].score < A[nextCardIndex]) {
            // 順番に比較
            int i;
            for (i = 0; i <= BC[tryIndex].numofCards; ++i) {
                if (A[cardIndex + i] >= BC[tryIndex].score) {
                    break;
                }
            }
            cardIndex += i;
            sum += BC[tryIndex].score * i;

            break; 
        }

        if (cardIndex + BC[tryIndex].numofCards <= N) {
            sum += BC[tryIndex].score * BC[tryIndex].numofCards;
            cardIndex += BC[tryIndex].numofCards;
        } else {
            int usedCnt = N - cardIndex;
            sum += BC[tryIndex].score * usedCnt;
            cardIndex += usedCnt;
        }
        
    }

    for (int i = cardIndex; i < N; i++) sum += A[i];

    cout << sum;

    return 0;
}



Measured memory_bytes: 2560
function main(input) {
  const args = input.split(' ');
  var A = Number(args[0]);
  var B = Number(args[1]);
  var K = Number(args[2]);
  var cu = 0;
  var sum;
  var count = 0;
  for (cu = A; cu > 0; --cu) {
    if (Number.isInteger(A / cu) && Number.isInteger(B / cu)) {
      count++;
      if (count === K) {
        sum = cu;
        break;
      }
    }
  }
  console.log(sum);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int v[3];
    rep(i,3) cin >>v[i];
    sort(v,v+3);

    int ct[2]={};
    rep(i,3) ++ct[v[i]%2];

    int ans = 0;

    if(ct[0]==2 || ct[1]==2){
        int f = 0;
        if(ct[1]==2) f = 1;

        ++ans;
        rep(i,3)if(v[i]%2==f) ++v[i];
        sort(v,v+3);
    }
    rep(i,3) ans += (v[2]-v[i])/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define let auto
#define of :
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
#define _matrix(T) vector<vector<T>>
template<class T>
auto matrix( int r, int c, T v ){
	return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
const int mod = (int)1e9 + 7 ;
const int inf = (int)1e18 ;
void mxz( int &a, int b ){
	a = max( a, b ) ;
}

signed main(){
	int n ; cin >> n ;
	string s ; cin >> s ;
	int len = s.size() ;
	int left = 0, right = len - 1, cnt = 0 ;
	while( left < right ){
		if( s[right] == 'R' ) {
			if( s[left] != 'W' ) ++left ;
			else ++cnt, ++left, --right ;
		}		
		else {
			if( s[left] == 'W' ){
				--right ;
			}
			else{
				++left, --right; 
			}
		}
	} 
	cout << cnt ;
	return 0 ;
}


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

unsigned long long dp[51][51][2501];

int main()
{
    int n, A;
    cin >> n >> A;
    vector<int> x(n);
    for (int i = 0; i < n; i++)
        cin >> x[i];
    dp[0][0][0] = 1;
    for (int i = 0; i < n; i++)
        for (int j = 0; j <= n; j++)
            for (int k = 0; k <= n * A; k++)
            {
                dp[i + 1][j][k] = dp[i][j][k];
                if (j > 0 && k >= x[i])
                    dp[i + 1][j][k] += dp[i][j - 1][k - x[i]];
            }
    unsigned long long ans = 0;
    for (int j = 1; j <= n; j++)
        ans += dp[n][j][j * A];
    cout << ans << endl;
}

Measured memory_bytes: 50048
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	double R=in<double>();
	double pi = 4.0*atan(1.0);
	
	printf("%.6lf %.6lf\n",pi*R*R,2.0*pi*R);
	return 0;
}



Measured memory_bytes: 3188
#include <stdio.h>
#include <math.h>
int figure_count(long long n){
  int cou = 0;
  while(n > 0){
    n /= 10;
    cou++;
  }
  return cou;
}

int main(void)
{
  long long n, i, j;
  int min = 10, a, b, res;
  scanf("%lld", &n);
 
  for(i = 1; i <= sqrt((double)n); i++){
    if(n % i == 0){
      a = figure_count(i);
      b = figure_count(n/i);
      if(a > b) res = a;
      else res = b;
    }
    if(min > res) min = res;
  }

  printf("%d\n", min);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>

#include <map>
 
using namespace std;
typedef long long ll; 


ll ans,mx,sum,mn=1e10,flag;
int main(){
	ll n;
	cin>>n;
	ll a[n],b[n];
	for(ll i=0; i<n; i++){
		cin>>a[i];
		b[i]=a[i];
		sum += a[i];	
	}
	for(ll i=0; i<n; i++){
		if(i>0) b[i] += b[i-1];
	}
	for(ll i=0; i<n; i++){
		if(i<n-1) {
			flag = sum-b[i];
			
			mn = min(mn,abs(b[i]-flag));
		}
	}
	cout<<mn<<endl;
}



Measured memory_bytes: 3328
a=input()
b=input()
if len(a)<len(b):
    print("LESS")
elif len(a)>len(b):
    print("GREATER")
else:
    for i in range(len(a)):
        if a[i]<b[i]:
            print("LESS")
            break
        elif a[i]>b[i]:
            print("GREATER")
            break
    else:
        print("EQUAL")

Measured memory_bytes: 3060
<?php
	fscanf(STDIN, "%d %d %d %d", $A, $B, $C, $D);
	$L = $A + $B;
	$R = $C + $D;
	if($L == $R){
		echo 'Balanced';
	}else if($L > $R){
		echo 'Left';
	}else{
		echo 'Right';
	}
?>

Measured memory_bytes: 4604
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;
typedef vector<int> vi;
using Graph = vector<vector<int>>;

int main() {
  int a, b;
  cin >> a >> b;
  int num_min = min(a, b);
  int num_max = max(a, b);

  rep (i, num_max) cout << num_min;
  cout << endl;
  return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>

int main()
{
	int W,H,x,y,r;
	
	
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if((x + r <= W&&x - r >=0)&&(y + r<=H&&y - r>=0))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	    
	return 0;
}


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

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int& x : A) cin >> x;
    vector<int> dsc = A;
    sort(dsc.rbegin(), dsc.rend());
    for (int i = 0; i < N; i++) {
        cout << (A[i] == dsc[0] ? dsc[1] : dsc[0]) << endl;
    }
}


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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) (in).begin(),(in).end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

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; } //最小公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
  string s,t;
  cin >> s >> t;
  int ans = 0;
  REP(i,s.size())if(s.at(i)==t.at(i))ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll T, A;
  ll tmpt, tmpa;
  ll tmpt1, tmpa1, tmpt2, tmpa2;
  ll num;
  for(int i=0;i<N;++i) {
    cin>>tmpt>>tmpa;
    if(i==0) {
      T = tmpt;
      A = tmpa;
    }
    else {
      tmpt1 = T + (tmpt-T%tmpt)%tmpt;
      tmpa1 = tmpt1/tmpt*tmpa;
      tmpa2 = A + (tmpa-A%tmpa)%tmpa;
      tmpt2 = tmpa2/tmpa*tmpt;
      if(tmpt1<T || tmpa1<A) {
        num = 1;
        while(tmpt1*num<T || tmpa1*num<A) {
          num++;
        }
        tmpt1 *= num;
        tmpa1 *= num;
      }
      if(tmpt2<T || tmpa2<A) {
        num = 1;
        while(tmpt2*num<T || tmpa2*num<A) {
          num++;
        }
        tmpt2 *= num;
        tmpa2 *= num;
      }
      if(tmpt1+tmpa1<tmpt2+tmpa2) {
        T = tmpt1;
        A = tmpa1;
      }
      else {
        T = tmpt2;
        A = tmpa2;
      }
    }
  }
  cout<<T+A<<endl;
}



Measured memory_bytes: 3580
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;

int n, a, b, c, co[100005];
vector< pair<int, int> > g[100005];

void dfs(int k) {
    for (auto i : g[k]) {
        if (co[i.first] == -1) {
            co[i.first] = co[k] ^ (i.second%2);
            dfs(i.first);
        }
    }
}

int main() {
    memset(co, -1, sizeof co);
    cin >> n;
    for (int i=0; i<n-1; i++) {
        cin >> a >> b >> c;
        g[a].push_back({b, c});
        g[b].push_back({a, c});
    }
    co[1] = 0; dfs(1);
    for (int i=1; i<=n; i++) {
        cout << co[i] << '\n';
    }
}

Measured memory_bytes: 7552
def floor_linear_sum(n,m,a,b):
    res = 0
    while True:
        if a >= m:
            res += (n-1)*n*(a//m)//2
            a %= m
        if b >= m:
            res += n * (b//m)
            b %= m

        y_max = (a*n+b)//m
        if y_max == 0:
            return res
        x_max = y_max*m-b
        res += (n - (x_max + a - 1)//a)*y_max
        n,m,a,b = y_max, a, m, (a-x_max)%a

T = int(input())
for _ in range(T):
    print(floor_linear_sum(*map(int,input().split())))


Measured memory_bytes: 70984
Flag = False
A = []
for i in range(3):
  A.extend(list(map(int, input().split())))

N = int(input())
B = [int(input()) for i in range(N)]

for i in B:
  if i in A:
    A[A.index(i)] = 0

for i in range(3):
  if A[i] + A[i+3] + A[i+6] == 0:
    Flag = True
  if A[3*i] + A[3*i+1] + A[3*i+2] == 0:
    Flag = True

if A[0] + A[4] + A[8] == 0 or A[2] + A[4] + A[6] == 0:
  Flag = True

if Flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static double xA, yA, xB, yB, xC, yC, xD, yD; 
	static double a1, a2;
	static final double EPS = 0.00001;
	public static void main(String[] args) {
		while(read()){
			slove();
		}
	}
	static boolean read(){
		if(!sc.hasNextDouble())return false;
		
		xA = sc.nextDouble();
		yA = sc.nextDouble();
		xB = sc.nextDouble();
		yB = sc.nextDouble();
		xC = sc.nextDouble();
		yC = sc.nextDouble();
		xD = sc.nextDouble();
		yD = sc.nextDouble();
		return true;
	}
	static void slove(){
		//System.out.println(xA + "," + yA);
	if((xB - xA == 0 && yB - yA == 0) || (xD - xC == 0 && yD -yC == 0)){	
		System.out.println("NO");
		}else if(xB - xA == 0 && yD -yC == 0){
			System.out.println("YES");
		}else if(yB - yA == 0 && xD - xC == 0){
			System.out.println("YES");
		}else if((yB - yA) / (xB - xA)*(yD - yC) / (xD - xC) == -1){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 12000
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;
#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

char in[5];
int main() {
	scanf("%s", in);
	return !printf("%c\n", in[0] + 1);
}

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

using namespace std;

int main() {
	int N;

	cin >> N;
	vector<int> a(N);

	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

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

	int n = a[N - 1], r;

	if (n % 2 == 0) {
		int r = n / 2;
		auto ite = lower_bound(a.begin(), a.end(), r);
		if (a[ite - a.begin()] != r) {
			if (a[ite - a.begin()] - r < r - a[ite - a.begin() - 1])
				r = a[ite - a.begin()];
			else
				r = a[ite - a.begin() - 1];
		}
		cout << n << " " << r << endl;
	}
	else {
		int r1 = (n - 1) / 2;
		auto ite = lower_bound(a.begin(), a.end(), r1);

		if (a[ite - a.begin()] == r1 || a[ite - a.begin()] == r1 + 1) {
			r1 = a[ite - a.begin()];
		}
		else {
			if (a[ite - a.begin()] - r1 - 1 < r1 - a[ite - a.begin() - 1])
				r1 = a[ite - a.begin()];
			else
				r1 = a[ite - a.begin() - 1];
		}

		cout << n << " " << r1 << endl;
	}

	return 0;
}

Measured memory_bytes: 640
let () =
    let main () =
        let s = read_line () in
        let len = String.length s in
        let a = Array.make len (-1) in
        for i = 0 to len - 1 do
            let rec loop prev pos =
                if a.(pos) <> -1 then a.(pos) else
                    let r =
                        if s.[pos] = prev then loop prev (if s.[pos] = 'R' then pos + 1 else pos - 1)
                            else (if prev = 'R' then pos * 2 - 1 else pos * 2 - 3)
                    in
                    let () = a.(pos) <- r in
                    r
            in
            if a.(i) = -1 then (
                let r = loop s.[i] (if s.[i] = 'R' then i + 1 else i - 1) in
                a.(i) <- r
            )
        done;
        let t = Array.make len 0 in
        Array.iteri (fun i v ->
            let va, vb = if v > i * 2 then v / 2, v / 2 + 1 else v / 2 + 1, v / 2 in
            let x = if (abs (v - i*2) /2) mod 2 = 0 then va else vb in
            t.(x) <- t.(x) + 1
        ) a;
        Array.iter (Printf.printf "%d ") t;
        print_newline ()
    in
    main ()

Measured memory_bytes: 9728
#include <iostream>
#include <algorithm>
#include <functional>
#include <set>
#include <vector>
#include <array>
#include <cmath>

#define r(i, v, n) for(int i = v; i < n; i++)
#define re(i, v, n) for(int i = v; i <= n; i++)
#define rr(e, v) for(auto&& (e) : (v))

using namespace std;

struct UnionFindTree {
    vector<int> parent;

    explicit UnionFindTree(int n) : parent((unsigned long)n) {
        r(i, 0, n) {
            parent[i] = i;
        }
    }

    int root(int x) {
        if(parent[x] == x) return x;
        return parent[x] = root(parent[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        parent[rx] = ry;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

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

    unsigned long m;
    int n, a, b;

    cin >> n >> m;
    auto v = vector<vector<int>>(m, vector<int>(2));

    r(i, 0, m) {
        cin >> a >> b;
        v[i] = {a, b};
    }

    int count = 0;
    r(i, 0, m) {
        auto uft = UnionFindTree(n);
        r(j, 0, m) {
            if (i == j) continue;
            uft.unite(v[j][0] - 1, v[j][1] - 1);
        }

        if(!uft.same(v[i][0] - 1, v[i][1] - 1)) count++;
    }

    cout << count;

    return 0;
}


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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h1,m1,h2,m2,k;
	cin >> h1 >> m1 >> h2 >> m2 >> k; 
	int gap = (h2 - h1) * 60;
	gap += m2 - m1;
	cout << gap - k << '\n';
	return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
//#define int ll
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back

void solve()
{
    int n, x, t; cin>>n>>x>>t;
    cout << (n+x-1)/x * t << '\n';
}

signed main(void)
{
    int T = 1;
    // cout << fixed;
    // cout.precision(44);
    ios_base::sync_with_stdio(0); cin.tie(0);
    //cin >> T;
    while (T--) solve();
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<vector<int>> honestList(n);
    vector<vector<int>> unkindList(n);

    for(int i = 0; i < n; ++i)
    {
        int t;
        cin >> t;
        for(int j = 0; j < t; ++j)
        {
            int x, y;
            cin >> x >> y;
            --x;
            if(y == 1)
            {
                honestList[i].push_back(x);
            }
            else
            {
                unkindList[i].push_back(x);
            }
            
        }
    }

    int ans = 0;
    for(int i = 0; i < (int)pow(2,n); ++i)
    {
        int tans = 0;
        bool result = true;
        for(int j = 0; (j < n) && result; ++j)
        {
            if((i & (1<<j)) == 0)
            {
                continue;
            }
            bool hResult = true;
            bool uResult = true;
            for(int honest : honestList[j])
            {
                if( (i & (1 << honest)) == 0)
                {
                    hResult = false;
                    break;
                }
            }
            for(int unkind : unkindList[j])
            {
                if( (i & (1 << unkind)) != 0)
                {
                    uResult = false;
                    break;
                }
            }
            if(!hResult || !uResult)
            {
                result = false;
                break;
            }
            if((i & (1<<j)) != 0)
            {
                ++tans;
            }
        }
        if(result)
        {
            ans = max(ans,tans);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int[][] a = new int[3][3];
    for(int i=0; i<3; i++) {
      String[] str = in.readLine().split(" ");
      for(int j=0; j<3; j++) {
        a[i][j] = Integer.parseInt(str[j]);
      }
    }
    
    int n = Integer.parseInt(in.readLine());
    int[] b = new int[n];
    for(int i=0; i<n; i++) {
      b[i] = Integer.parseInt(in.readLine());
      for(int j=0; j<3; j++) {
        for(int k=0; k<3; k++) {
          if(a[j][k]==b[i])
            a[j][k]=0;
        }
      }
    }
    
    boolean hantei = false;
    for(int i=0; i<3; i++){
      if(a[i][0] == a[i][1] && a[i][1] == a[i][2])
        hantei = true;
    }
    for(int i=0; i<3; i++){
      if(a[0][i] == a[1][i] && a[1][i] == a[2][i])
        hantei = true;
    }
    if(a[0][0] == a[1][1] && a[1][1] == a[2][2])
      hantei = true;
    if(a[0][2] == a[1][1] && a[1][1] == a[2][0])
      hantei = true;
    
    System.out.println(hantei==true?"Yes":"No");
  }
}

Measured memory_bytes: 24660
a, b, m = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
bs = gets.split.map(&:to_i)

ans = as.min + bs.min

m.times do
  x, y, c = gets.split.map(&:to_i)
  x -= 1
  y -= 1
  if ans > as[x] + bs[y] - c
    ans = as[x] + bs[y] - c
  end
end

puts ans


Measured memory_bytes: 18588
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  double t,x;
  cin >> t >> x;

  cout << t / x;
  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

#define N 50
int a[N];
int b[N];
int n,m;


int p[N];
int par(int x)
{
  if(p[x]==x)return x;
  p[x]=par(p[x]);
  return p[x];
}

void join(int x, int y)
{
  p[par(x)]=par(y);
}

bool isbr(int e)
{
  for(int i=0;i<n;i++)
    p[i]=i;
  for(int i=0;i<m;i++)
    if(i!=e)
      join(a[i],b[i]);
  int r=par(0);
  for(int i=0;i<n;i++)
    if(par(i)!=r)
      return true;
  return false;
}

int main()
{
  cin>>n>>m;
  for(int i=0;i<m;i++)
    {
      cin>>a[i]>>b[i];
      a[i]--;
      b[i]--;
    }
  int res=0;
  for(int i=0;i<m;i++)
    if(isbr(i))
      res++;
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
  int n,m,s,g1,g2,hoge[101][101],a,b,c;
  while(1){
    cin >> n >> m >> s >> g1 >> g2;
    if(n==0&&m==0&&s==0&&g1==0&&g2==0)break;
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
	hoge[i][j] = 100000000;
      }
      hoge[i][i]=0;
    }
    for(int i=0;i<m;i++){
      cin >> a >> b >> c;
      hoge[a][b] = c;
    }
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
	for(int k=1;k<=n;k++){
	  if(hoge[j][k] > hoge[j][i] + hoge[i][k]){
	    hoge[j][k] = hoge[j][i] + hoge[i][k];
	  }
	}
      }
    }
    int MIN=1000000000;
    for(int i=1;i<=n;i++)
      MIN = min(MIN,hoge[s][i]+hoge[i][g1]+hoge[i][g2]);
    cout << MIN << endl;
  }
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    int ans = 0;
    if(A + B <= 2 * C) {
        ans += A * X + B * Y;
    } else {
        ans += 2 * C * min(X, Y);
        if(X > Y) {
            ans += min(A, 2 * C) * (X - Y);
        } else {
            ans += min(B, 2 * C) * (Y - X);
        }
    }
    cout << ans;
    return 0;
}


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

struct edge { int to, cost; };
typedef pair<int, int> P;
typedef pair<string, int> SP;
#define rep(i, n) for(int i = 0; i < n; ++i)

const int INF = 1e9 + 7;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // vvvi V (50, vvi(50, vi(2500)));

    int K;
    cin >> K;
    ll ans = 0;
    for(int i = 1; i <= K; ++i){
        for(int j = 1; j <= K; ++j){
            for(int k = 1; k <= K; ++k){
                ans += gcd(gcd(i, j), k);
                // cout << i << " " << j << " " << k << " " << gcd(gcd(i, j), k) << endl;
            }    
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int t;
    cin>>t;
    long long int ans = LLONG_MAX;
    while(t--)
    {
        int a;
        cin>>a;
        long long int count=0;
        while(a%2==0)
        {
            count++;
            a/=2;
        }
        ans = min(ans,count);
    }    
    cout<<ans<<"\n";
}

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


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

    bool isdifficult = false;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){
        isdifficult = true;
    }

    cout << (isdifficult? "Bad": "Good");
    

}


Measured memory_bytes: 256
h,w=map(int,input().split())
hans=0
wans=0
yn=0
wlist=[]
for i in range(26):
    a=65+i
    wlist.append(chr(a))
for i in range(h):
    s=list(input().split())
    for j in range(w):
        if s[j]=="snuke":
            hans=i+1
            wans=j
            yn=1
            break
    if yn==1:
        break
print(wlist[wans]+str(hans))


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int M; cin >> M;
    ll sum = 0;
    ll sumc = 0;
    rep(i,M){
        int d; cin >> d;
        ll c; cin >> c;
        sum += d*c;
        sumc += c;
    }
    ll ans = sumc-1;
    ans += (sum-1)/9;

    cout << ans << endl;

}


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

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

  if(a > b){
    cout << "a > b" << endl;
  }
 else if(a < b){
  cout << "a < b" << endl;
 }

 else{
  cout << "a == b" << endl;
 }

} 


Measured memory_bytes: 3072
#include<stdio.h>

int main(void) {

 int n;

 int x;

 int num;

 int min = 1000001;

 int max = -1000001;

 long total = 0;




 scanf("%d",&n);

 for(x = 0; x < n; x++){

 scanf("%d",&num);

 if(min >num)min = num;

 if(max < num)max = num;

total += num;

}

printf("%d %d %ld\n",min,max,total);

return 0;

}

 

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

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	int count = 0;
	for (int n = 0; n < N; ++n) {
		int num;
		cin >> num;
		if (num < 0 ) {
			A[n] = -num;
			count++;
		}
		else {
			A[n] = num;
		}
	}	
	long long ans = 0;
	for (int n = 0; n < N; ++n) {
		ans += A[n];
	}
	sort(A.begin(), A.end());
	if (1 == count %2) {
		ans -= 2*A[0];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main() {
    int n; scanf("%d", &n);
    vector<ll> a(n);
    ll sum = 0;
    for (int i = 0; i < n; i++){
        scanf("%lld", &a[i]);
        (sum += a[i]) %= MOD;
    }
 
    ll ans = 0;
    for (int i = 0; i < n; i++){
        sum -= a[i];
        if (sum < 0) sum += MOD;
 
        ans += a[i] * sum;
        ans %= MOD;
    }
	printf("%lld\n", ans);
}

Measured memory_bytes: 4756
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007
 
signed main(){
 
	lli n,w;
	vector<pair<lli,lli>> p;
 
	cin>>n>>w;
	REP(i,0,n){
		lli a,b;
		cin>>a>>b;
		p.push_back(make_pair(a,b));
	}
 
 	/*価値を引数にwを返す*/
	lli dp[100100]={INF};
	REP(i,0,100100)dp[i]=INF;
	dp[0]=0;
 
	REP(i,0,n){
		for(lli j=100000;j>=0;j--){
			if(dp[j]==INF)continue;
			if(DEBUG)cout<<"j="<<j<<" dp[j]="<<dp[j]<<endl;
			lli nextV = j + p[i].second;
			lli nextW = dp[j] + p[i].first;
			if(nextW>w)continue;
			if(dp[nextV]>nextW){
				dp[nextV]=nextW;
				if(DEBUG)cout<<"nextV="<<nextV<<" nextW="<<nextW<<endl;
			}
		}
	}
 
	lli ans=0;
	REP(i,0,100010){
		if(dp[i]&&dp[i]!=INF)ans=i;
	}
	cout<<ans<<endl;
 
	return 0;
}

Measured memory_bytes: 1024
n, a, b = map(int, input().split())
# 全通り - nCa - nCb
mod = 10 ** 9 + 7


def inv(x):
    return pow(x, mod - 2, mod)

# n ~ n - k + 1


def c(n, k):
    res = 1
    for i in range(0, k):
        res = res * (n - i) * inv(i + 1) % mod
    return res


print(((pow(2, n, mod) - c(n, a) - c(n, b) - 1) % mod + mod) % mod)


Measured memory_bytes: 9132
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int N = Integer.parseInt(s);

            System.out.println(N / 3);
        }
    }
}


Measured memory_bytes: 20692
from collections import Counter
n = int(input())
S = input()
alr = set(S)
temp = Counter(S)
for _ in range(n-1):
    S = Counter(input())
    alr &= set(S)
    for k, v in S.items():
        if k in alr:
            temp[k] = min(temp[k], v)
ans = []
for k in list(alr):
    for _ in range(temp[k]):
        ans.append(k)
ans.sort()
print("".join(ans))


Measured memory_bytes: 3316
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{     int n,i,j,s;
    while(~scanf("%d",&n)) 
  {  int a[n];  
   for(i=0;i<n;i++)
  scanf("%d",&a[i]);
  sort(a,a+n);
  printf("%d\n",a[n/2]-a[n/2-1]);
  	
  }
      
  
  
}


Measured memory_bytes: 640
#! usr/bin/env python
# -*- coding: utf-8 -*-


def gcd(a, b):
    if not b:
        return a
    return gcd(b, a % b)


def main():
    n, m = map(int, input().split())
    s, t = input(), input()
    l = n // gcd(n, m) * m

    dic = {}
    for i in range(n):
        dic[i*l//n+1] = s[i]

    for i in range(m):
        if i * l // m + 1 in dic and dic[i*l//m+1] != t[i]:
            print(-1)
            exit()

    print(l)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15352
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef long long ll;
typedef pair<int,int> pint;
const ll mod= 1e9+7;
const int inf=1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int dp[101010];
int rec(int n){
  if(dp[n]!=0)return dp[n];
  if(n==0)return 0;
  int res=rec(n-1)+1;
  int x=6;
  while(x<=n){
    res=min(res,rec(n-x)+1);
    x*=6;
    }
  x=9;
  while(x<=n){
    res=min(res,rec(n-x)+1);
    x*=9;
    }
  return dp[n]=res;
  }
int main(){
  int n;
  cin>>n;

  cout<<rec(n)<<endl;
    

  return 0;
  }


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


int main()
{
    string s, t;
    cin >> s >> t;

    int count = 0;
    for (int i = 0, n = s.size(); i < n; i++)
    {
        if (s[i] != t[i])
            count++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3876
#include<bits/stdc++.h>
using namespace std;
int fun(int a,int b,int c)
{
    int temp = __gcd(a,b);
    return __gcd(temp,c);
}
int main()
{
    int k;
    cin >>k;
    unsigned long long int sum=0;
    for (int i = 1; i <= k; ++i)
    {
        for (int j = 1; j <=k; ++j)
        {
            for (int z = 1; z <= k; ++z)
            {
                sum+=fun(i,j,z);
            }
        }
    }
    cout << sum ;


    return 0;
}

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

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

    T.erase(T.end() - 1);
    if (S == T) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3168
import collections

N = int(input())
A = list(map(int, input().split()))

c = collections.Counter(A)

sum_dict = {}
sum_dict_n = {}

sum = 0
sum_n = 0

for key in c.keys():
    coll = c[key] * (c[key] - 1) // 2
    sum_dict[key] = coll
    sum += coll
    value_k = c[key] - 1
    coll_n = value_k * (value_k - 1) // 2
    sum_dict_n[key] = coll_n

for a in A:
    ans = sum
    ans = ans - sum_dict[a] + sum_dict_n[a]
    print(ans)


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

using namespace std;

const int mod = 1e9 + 7;
const int maxb = 2e5;
long long mem[maxb + 2];

long long power(long long a, long long b){
    long long  res = 1;

    while(b){
        if(b & 1){
            res = res * a % mod;
        }
        a = (long long)(a * a) % mod;
        b >>= 1;
    }

    return res;
}

int main(){

    int n, k;
    cin >> n >> k;

    long long ans = 1;

    mem[1] = 1;
    for(int i = 2; i <= n; i++){
        mem[i] = (mod - (mod / i)) * mem[mod % i] % mod;
    }

    long long C = 1, H = 1;

    for(int i = 1; i <= min(n - 1, k); i++){
        C = (C * (n - i)) % mod;
        C = (C * mem[i]) % mod;
        H  = (H * (n - i + 1)) % mod;
        H = (H * mem[i]) % mod;

        ans = (ans + (C * H) % mod) % mod;
    }

    cout << ans;
}

Measured memory_bytes: 1792
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    b = [int(i) for i in input().split()]
    c = [int(i) for i in input().split()]

    p = -1
    s = 0
    for i in a:
        s += b[i - 1]
        if p == (i - 1):
            s += c[i - 2]
        p = i

    print(s)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29036
function main(input) {
    var args = input.split(' ');
    var a = parseInt(args[0]);
    var b = parseInt(args[1]);
  	var c = [1,2,3];
  
  	const t = a*b;
  	var flag = false;
  	c.forEach( n => {
      if(t * n % 2 == 1){
		flag = true;
      }
    })
    console.log(flag ? 'Yes' : 'No');
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int main(){
  int N, t;
  cin >> N;
  t = 0;
  vector<int> vec(N);
  for(int i = 0; i< N; i++){
    cin >> vec.at(i);
    t += vec.at(i);
  }
  sort(vec.begin(), vec.end(), greater<int>());
  int s;
  s = 0;
  for(int i = 0; i < N; i = i + 2){
    s += vec.at(i);
  }
  cout << s - (t - s) << endl;
}
  

Measured memory_bytes: 256
h,w = map(int, input().split())
a = [input().split() for i in range(h)]
b = []
 
for i in range(h):
  a[i].insert(0,'#')
  a[i].append('#')
  
for i in range(w+2):
  b.append('#')
 
a.insert(0,b)
a.append(b)
  
for i in a:
  print("".join(list(map(str,i))))

Measured memory_bytes: 3188
while True:
	n = input()
	if n == 0:
		break
	s = map(int, raw_input().split())
	sumS = 0.0
	sum  = 0.0
	for i in s:
		sumS += i**2
		sum += i
	v = sumS / n - (sum / n)**2
	print v**0.5

Measured memory_bytes: 4328