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

#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define lli long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i, n)  for(int i=0;i<n;++i)
#define rforn(i,start) for(int i = start; i >= 0;--i)
#define forsn(i,start,end) for(int i=start;i<end;++i)
#define rforsn(i,start,end) for(int i=start;i>=end;--i)
#define debug(x) cout<<#x<<" = "<<x<<"\n";
const int CONST = 1e9 + 7;

#define MAX 2000000
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
int32_t main(){
	fastio;
    #ifndef ONLINE_JUDGE
	   freopen("input.txt", "r", stdin);
	   freopen("output.txt","w",stdout);
	#endif
	
    int h, w, si, sj, di, dj;
    cin>>h>>w;
    cin>>si>>sj;
    cin>>di>>dj;
    
    --si, --sj;
    --di, --dj;
    char mat[h][w];

    forn(i, h){
        forn(j, w){
            cin>>mat[i][j];
        }
    }

    vector<std::vector<int> > dist(h, std::vector<int>(w, INT_MAX));
    dist[si][sj]=0;

    deque<pii> dq;
    dq.push_back({si, sj});

    while(!dq.empty()){
        int x= dq.front().first;
        int y = dq.front().second;
        dq.pop_front();

        if(x==di && y==dj){
            cout<<dist[x][y]<<endl;
            return 0;
        }
        forn(i, 4){
            int u=x+dx[i], v=y+dy[i];

            if(u<0 || v<0 || u>=h || v>=w)  continue;
            if(mat[x][y]=='#')  continue;

            if(dist[u][v]>dist[x][y]){
                dist[u][v]=dist[x][y];
                dq.push_front({u, v});    
            }
        }

        for(int i=-2;i<=2;++i){
            for(int j=-2;j<=2;++j){
                int u=x+i, v=y+j;
                if(u<0 || v<0 || u>=h || v>=w)  continue;
                if(mat[x][y]=='#')  continue;

                if(dist[u][v]>dist[x][y]+1){
                    dist[u][v]=dist[x][y]+1;
                    dq.push_back({u, v});   
                }
            }
        }
    }

    if(dist[di][dj]==INT_MAX)    cout<<"-1"<<endl;
    else cout<<dist[di][dj]<<endl;

	return 0;
}


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

using namespace std;
typedef long long ll;

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

  int n;
  cin >> n;
  int d[n];
  for(int i=0;i<n;i++) cin >> d[i];
  set<ll> st;
  for(int i=0;i<n;i++){
    ll tmp=0;
    for(int j=i;j<min(n,i+9);j++){
      tmp=tmp*10+d[j];
      st.insert(tmp);
       // cout<<tmp<<endl;
    }
  }
  bool flag=true;int idx=-1;
  while(flag){
    idx++;
    if(!(st.find(idx)!=st.end())){
      flag=false;
    }
  }
  cout << idx << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<int> V(N, 2e9);
  V.at(0) = 0;
  for (int i = 0; i < N; i++) {
    if (i + 1 < N) V.at(i + 1) = min(V.at(i + 1), V.at(i) + abs(A.at(i + 1) - A.at(i)));
    if (i + 2 < N) V.at(i + 2) = min(V.at(i + 2), V.at(i) + abs(A.at(i + 2) - A.at(i)));
  }
  cout << V.at(N - 1) << "\n";
}

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

int f(int x,int y,int a,int b){
	if( x >= 5 && y >= 2 ) return ( a * x + b * y ) * 8 / 10;
	return ( a * x + b * y );
}

int main(){
	int Q;
	cin >> Q;
	while(Q--){
		int c,a,n;
		cin >> c >> a >> n;
		int sum = 0;
		while( c && a && n ){
			c--;
			a--;
			n--;
			sum ++;
		}
		while( c >= 2 && a ){
			c-=2;
			a--;
			sum ++;
		}
		while( c >= 3 ){
			c-=3;
			sum ++;
		}
		cout << sum << endl;
	}
	
}

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

#define pb push_back
typedef long long int ll;
typedef vector<ll> vl;
typedef map<ll,ll> ii;
typedef vector<vl> vvl;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    ll t;cin>>t;
    ll s=sqrt(t);
    
    ll p=pow(10,13);
    for(ll i=1;i<=s;i++){
        if(!(t%i)){
            p=min(p,(i+t/i)-2);
        }
    }
    cout<<p<<" ";
    return 0;
}
    


Measured memory_bytes: 256
A,B,K = map(int,input().split())

K1 = K - A

if K >= A:
    A = 0
else:
    A = A - K

if K1 > 0:
    if B >= K1:
        B = B - K1
    else:
        B = 0
        

print("{} {}".format(A, B))

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long int ll;
using ipair = pair<int,int>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
const int MOD=1000000007;
int main(){   
    int n;cin>>n;
    vector<vector<int>> to(n),c(n);
    rep(i,n-1){
        int a,b,w;
        cin>>a>>b>>w;a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
        c[a].push_back(w);
        c[b].push_back(w);
    }
    vector<int> ans(n,-1);
    queue<int> q;
    q.push(0);ans[0] = 0;
    while(!q.empty()){
        int u = q.front();q.pop();
        rep(i,to[u].size()){
            int v = to[u][i];
            if(ans[v]!=-1)continue;
            ans[v] = (ans[u]+c[u][i])%2;
            q.push(v);
        }
    }
    rep(i,n)cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 11904
#include <iostream>

using namespace std;

int main()
{
        int debt = 100000;
        int n;

        cin >> n;
        for (int i = 0; i < n; i++) {
                debt += debt * 0.05;
                if (debt % 1000 != 0) {
                        debt += (1000 - debt % 1000);
                }
        }
        cout << debt << endl;

        return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define N 200010
#define mod 1000000007
#define ll long long
using namespace std;
int n, X, Y, x, y, jc[N], inv[N], p, p1, sum, sum1, l, a[N], ans;
vector<int>son[N];
int main(){
	scanf("%d%d%d", &n, &X, &Y);
	for(int i=1; i<=n; i++)son[i].clear();
	for(int i=1; i<=n; i++){scanf("%d%d", &x, &y); son[x].push_back(y);}
	for(int i=1; i<=n; i++)sort(son[i].begin(), son[i].end());
	jc[0]=1; for(int i=1; i<=n; i++)jc[i]=(ll)jc[i-1]*i%mod;
	inv[0]=inv[1]=1; for(int i=2; i<=n; i++)inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod;
	for(int i=1; i<=n; i++)inv[i]=(ll)inv[i]*inv[i-1]%mod;
	p=0;
	for(int i=1; i<=n; i++)if(son[i].size()){
		if(!p)p=i; else if(son[p][0]>son[i][0])p=i;
	}
	p1=0;
	for(int i=1; i<=n; i++)if(son[i].size()&&p!=i){
		if(!p1)p1=i; else if(son[p1][0]>son[i][0])p1=i;
	}
	if(!p1){printf("1"); return 0;}
	if(son[p][0]+son[p1][0]>Y){printf("1"); return 0;}
	sum=1; for(int i=1; i<son[p].size(); i++)if(son[p][0]+son[p][i]<=X)sum++;
	sum1=1; for(int i=1; i<son[p].size(); i++)if(son[p1][0]+son[p][i]<=Y)sum1++;
	l=1; a[1]=max(sum, sum1);
	for(int i=1; i<=n; i++)if(son[i].size()&&p!=i&&son[p][0]+son[i][0]<=Y){
		sum=1; for(int j=1; j<son[i].size(); j++)if(son[i][0]+son[i][j]<=X)sum++;
		sum1=1; for(int j=1; j<son[i].size(); j++)if(son[p][0]+son[i][j]<=Y)sum1++;
		a[++l]=max(sum, sum1);
	}
	sum=0; for(int i=1; i<=l; i++)sum+=a[i];
	ans=jc[sum]; for(int i=1; i<=l; i++)ans=(ll)ans*inv[a[i]]%mod;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 11648
#include<bits/stdc++.h>
using namespace std;
string s[55];
int main(){
	map<string,int>m;
	int n;
	cin >> n;
	int sum=0;
	for(int i=1;i<=n;i++){
		int a;
		cin >> s[i] >> a;
		m[s[i]]=a;
		sum+=a;
	}
	string ss;
	cin >> ss;
	for(int i=1;i<=n;i++){
		if(s[i]!=ss)
		sum-=m[s[i]];
		else{
			sum-=m[s[i]];
			break;
		}
	}
	cout << sum << endl;
	return 0;
} 

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define maxn 100050
using namespace std;
typedef long long LL;

int n;
char s[maxn]={'0'};

void init()
{
	scanf("%s",s+1);
	n=strlen(s+1); 
}

bool judge()
{
	if (s[1]!='1')	return 0;
	for (int i=1;i<=n;++i) 
		if (s[i]!=s[n-i])
			return 0;
	return 1;
} 

void solve()
{
	if (!judge())
		printf("-1\n");
	else
	{
		int u=1;
		for (int i=2;i<=n;++i)
		{
			printf("%d %d\n",u,i);
			if (s[i-1]=='1')
				u=i;
		}
	}
}

int main()
{
//    freopen("c.in","r",stdin);
    init();
    solve();
    return 0;
}

Measured memory_bytes: 1536
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define INF 1200000000



int main(){
    long A,B;
    cin>>A>>B;
    if(A<B){
        int co=A;
        A=B;
        B=co;
    }
    long AA=A;
    long BB=B;
    long r=A%B;
    if(r==0){
        cout<<A<<endl;
        return 0;
    }
    while(r!=0){
        A = B;
        B = r;
        r = A % B;
  }
    cout<<AA*BB/B<<endl;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String op;
    int a;
    int b;
    int sum = 0;
    int dec = 0;
    int multi = 0;
    int div = 0;

    do{
       
       a = sc.nextInt();
       op = sc.next();
       b = sc.nextInt();



    if(op.equals("+")){
       sum = a+b;
       System.out.println(sum);
    }else if(op.equals("-")){
       dec = a-b;
       System.out.println(dec);
    }else if(op.equals("*")){
       multi = a*b;
       System.out.println(multi);
    }else if(op.equals("/")){
      switch(b){
        case 0:
        break;
      default:
       div = a/b;
       System.out.println(div);
    }
  }
}while(!(op.equals("?")));




sc.close();
}

  }



Measured memory_bytes: 26248
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Main {

    public static int nex_combination(int sub) {
        int x = sub & (-sub);
        int y = sub + x;
        return (((sub & ~y) / x) >> 1) | y;
    }

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

        while (true) {
            int n = sc.nextInt();
            int x = sc.nextInt();

            if (n == 0 && x == 0) {
                break;
            }

            int ans = 0;

            for (int i = 1; i <= n; i++) {
                for (int j = i + 1; j <= n; j++) {
                    for (int k = j + 1; k <= n; k++) {
                        if (i + j + k == x) {
                            ans++;
                        }
                    }
                }
            }

            System.out.println(ans);
        }

        sc.close();
    }
}


Measured memory_bytes: 26684
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<n-1;i++){
		string a=s.substr(0,i+1);
		string b=s.substr(i+1,n-i-1);
		if(a==b){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}






Measured memory_bytes: 3656
#include<iostream>
#include<math.h>
const int MOD = 1e9+7;
using namespace std;

int main(){
  int n,ans=1;cin>>n;
  int a[n];
  int b[n];
  for(int i=0;i<n;i++)b[i]=0;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)b[a[i]]++;
  if(n%2==0){
    for(int i=1;i<n;i+=2){
      (ans *= 2) %= MOD;
      if(b[i]!=2){
        cout<<0<<endl;
        return 0;
      }
    }
  }else{
    b[0]++;
    for(int i=0;i<n;i+=2){
      if(i)(ans *= 2) %= MOD;
      if(b[i]!=2){
        cout<<0<<endl;
        return 0;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);
	std::vector<int> p(n);
	std::vector<std::vector<int>> g(n);
	for(int i = 0; i < n; i++) scanf("%d", &p[i]);
	for(int i = 0; i < n - 1; i++) {
		int a, b; scanf("%d%d", &a, &b);

		g[a - 1].push_back(b - 1);
		g[b - 1].push_back(a - 1);
	}

	// t = 0: 戻らない
	// t = 1: 戻る
	std::vector<std::map<int, std::vector<std::vector<int>>>> dp(n);
	auto dfs = [&](auto&& dfs, int v, int par, int t, bool f) -> std::vector<int> {
		if(dp[v].count(par)) return dp[v][par][t];

		auto X = std::vector<int>(1, p[v]);
		auto Y = std::vector<int>(1, p[v]);
		if(f or par == -1) {
			for(auto e: g[v]) {
				if(e == par) continue;
				auto A = dfs(dfs, e, v, 0, f);
				auto B = dfs(dfs, e, v, 1, f);
				
				if(B[0] - 2 > 0) Y[0] += B[0] - 2;
			}
			for(auto e: g[v]) {
				if(e == par) continue;
				auto A = dfs(dfs, e, v, 0, f);
				auto B = dfs(dfs, e, v, 1, f);
				
				if(B[0] - 2 > 0) X.push_back(p[v] - 1 + A[0] + (Y[0] - (B[0] - 2) - p[v]));
				else X.push_back(p[v] - 1 + A[0] + (Y[0] - p[v]));
			}
			sort(begin(X), end(X));
			reverse(begin(X), end(X));
			X.resize(2);
		} else {
			auto PA = dfs(dfs, par, v, 0, f);
			auto PB = dfs(dfs, par, v, 1, f);
			auto AA = dfs(dfs, v, -1, 0, f);
			auto AB = dfs(dfs, v, -1, 1, f);

			Y[0] = AB[0];
			if(PB[0] - 2 > 0) Y[0] -= PB[0] - 2;
			if(p[v] - 1 + PA[0] + (Y[0] - p[v]) == AA[0]) {
				if(AA.size() >= 1) X[0] = AA[1] - (PB[0] - 2 > 0 ? PB[0] - 2 : 0);
			} else {
				X[0] = AA[0] - (PB[0] - 2 > 0 ? PB[0] - 2 : 0);
			}
			X[0] = std::max(X[0], p[v]);
		}
		dp[v][par].resize(2);
		dp[v][par][0] = X;
		dp[v][par][1] = Y;
	
		return dp[v][par][t];
	};
	dfs(dfs, 0, -1, 0, 1);
	dfs(dfs, 0, -1, 0, 0);

	int ans = -(1 << 30);
	for(int v = 0; v < n; v++) {
		auto X = dfs(dfs, v, -1, 0, 0);
		auto Y = dfs(dfs, v, -1, 1, 0);

		ans = std::max({ans, X[0], Y[0]});
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 108712
import java.awt.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        Point[] arr = new Point[n];
        for (int i = 0; i < n; i++) {
            arr[i] = new Point(sc.nextInt(), sc.nextInt());
        }

        int ans = Integer.MAX_VALUE;

        for (Point p : arr) {
            if (p.y <= t) {
                ans = Math.min(ans, p.x);
            }
        }
        System.out.println(ans != Integer.MAX_VALUE ? ans : "TLE");
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
int main(void){
	int a[100],n,max,min,i;

	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	max=a[0];
	min=a[0];
	for(i=1;i<n;i++){
		if(max<a[i])
			max=a[i];
		else if(min>a[i])
			min=a[i];
	}
	printf("%d",max-min);
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    int dist = abs(b-a);
    int spe = (v-w);
    if ((long long)spe*t >= dist) printf("YES");
    else printf("NO");
}


Measured memory_bytes: 3760
/*  AtCoder Beginner Contest 133 A - T or T
    2019.07.24 by meyon  */

#include <stdio.h>

int main()
{
  // data input and judgment
  int N;    // number of people
  int A;    // train fare
  int B;    // taxi fare
  scanf("%d %d %d", &N, &A, &B);
  if(N<1 || N>20 || A<1 || A>50 || B<1 || B>50) {
    printf("Error!\n");
    return 1;
  }

  // extract the lowest fare
  int lowestFare = N * A;
  if(lowestFare > B) {
    lowestFare = B;
  }

  // display the lowest fare
  printf("%d\n", lowestFare);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <cstdio>
#include <bitset>
#include <map>


using namespace std;

struct card
{
    char suit;
    int rank;
};

int main()
{
    // bitset<14> spade;
    // bitset<14> heart;
    // bitset<14> club;
    // bitset<14> diamond;

    int n;
    cin >> n;

    char suit;
    int rank;


    //method 1

    //C++11
    // map<int, char> suit_name {{0, 'S'}, {13, 'H'}, {26, 'C'}, {39, 'D'}};

    //C++98
    // map<int, char> suit_name;
    // suit_name[0] = 'S';
    // suit_name[13] = 'H';
    // suit_name[26] = 'C';
    // suit_name[39] = 'D';


    // vector< bitset<13> > cards(4);

    // while (n--)
    // {
    //     cin >> suit >> rank;

    //     if (suit == 'S')
    //     {
    //         cards[0].set(--rank);
    //     }
    //     else if (suit == 'H')
    //     {
    //         cards[1].set(--rank);
    //     }
    //     else if (suit == 'C')
    //     {
    //         cards[2].set(--rank);
    //     }
    //     else
    //     {
    //         cards[3].set(--rank);
    //     }
    // }

    // int m = -1;
    // while (++m < 4)
    // {

    //     n = -1;
    //     while (++n < 13)
    //     {
       
    //         if (cards[m][n] == 0)
    //         {
    //             cout << suit_name[m*13] << ' ';  
    //             cout << n+1 << endl;                  
    //         }
                             
    //     }
       
    // }


    //method 2
    map<int, char> suit_name;
    suit_name[0] = 'S';
    suit_name[1] = 'H';
    suit_name[2] = 'C';
    suit_name[3] = 'D';

    map<char, int> suit_num;
    suit_num['S'] = 0;
    suit_num['H'] = 13;
    suit_num['C'] = 26;
    suit_num['D'] = 39;


    bitset<52> card_check;

    while (n--)
    {
        cin >> suit >> rank;
        card_check.set(suit_num[suit] + --rank);
    }

    int i = -1;
    while (++i < 52)
    {
        if (card_check[i] == 0)
        {
            cout << suit_name[i / 13] << ' '
                 << i % 13 + 1 << endl;
        }
    }
}


Measured memory_bytes: 3096
N,M=list(map(int,input().strip().split(' ')))
A=input()
B=input()
def gcd(a,b):
    if a>b:
        a,b=b,a
    if b%a==0:
        return a
    return gcd(b%a,a)
g=gcd(M,N)
m=M//g
n=N//g
flag=1
for r in range(g):
    if A[n*r]!=B[m*r]:
        flag=0

if flag==1:
    print(g*m*n)
else:
    print(-1)


Measured memory_bytes: 39792
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;

    vector<string> a(h);
    rep(i, 0, h) cin >> a[i];

    queue<pair<int, int>> que;
    vector<vector<int>> dist(h, vector<int>(w, -1));
    rep(i, 0, h) rep(j, 0, w) {
        if (a[i][j] == '#') {
            que.push(make_pair(i, j));
            dist[i][j] = 0;
        }
    }

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

    while (!que.empty()) {
        int x = que.front().first;
        int y = que.front().second;
        que.pop();

        rep(i, 0, 4) {
            int nx = x + dx[i];
            int ny = y + dy[i];

            if (nx < 0 || h <= nx || ny < 0 || w <= ny) continue;
            if (a[nx][ny] == '#' || dist[nx][ny] != -1) continue;

            dist[nx][ny] = dist[x][y] + 1;
            que.push(make_pair(nx, ny));
        }
    }

    int ans = 0;
    rep(i, 0, h) rep(j, 0, w) ans = max(ans, dist[i][j]);

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

Measured memory_bytes: 13456
/*
Rathin Bhargava
IIIT Bangalore

*/
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 


int main()
{
  __;
  int n,k;
  cin >> n >> k;
  vector<int> v(n);
  for(int i=0;i<n;i++) cin >> v[i];

  bool is_left_small = false;
  int left = 0, right = k-1;
  
  set<int> s;
  for(int i=0;i<=right;i++) s.insert(v[i]);

  int cnt = 0;
  int cnt2 = 0;
  vector<int> check;


  while(right < n)
  {
    s.insert(v[right]);
    if(!(is_left_small && *s.rbegin() == v[right])) cnt++;
    // t(left,right,cnt);

    if(*s.begin() == v[left]) is_left_small = true;
    else is_left_small = false;

    s.erase(v[left]);
    left++;
    right++;
  }

  int run = 0;
  int prev = -1;
  for(int i=0;i<n;i++)
  {
    if(v[i] > prev) run++;
    else
    {

      if(run >=k) cnt2 ++;
      run = 1;
    }
    prev = v[i];
  }
  if(run >= k) cnt2 ++;

  // t(cnt2);
  if(cnt2) cnt2--;

  cout << cnt-cnt2 << endl;
  return 0;
}



Measured memory_bytes: 10368
import math
def mink(x,y,p):
    return (sum([math.fabs(_x - _y)**p for _x, _y in zip(x,y)]))**(1/p)
def mink_i(x,y):
    return max([math.fabs(_x - _y) for _x, _y in zip(x,y)])
n = int(input())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
print(mink(x,y,1))
print(mink(x,y,2))
print(mink(x,y,3))
print(mink_i(x,y))



Measured memory_bytes: 5720
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int a[] = new int[N];
		for (int i=0;i<K;i++) {
			int d = sc.nextInt();
			for (int j=0;j<d;j++) {
				int temp = sc.nextInt();
				a[temp-1]++;
			}
		}
		int count =0;
		for (int i=0;i<N;i++) {
			if (a[i]==0) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 46732
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <queue> 
using namespace std;
int main(){
    int n;
    cin >> n;
    int count=0;
    vector<queue<int>> vec(n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n-1;j++){
            int N;
            scanf("%d", &N);
            N--;
            vec[i].push(N);
        }
    }
   // cout<<vec[1].front()<<endl;
   bool kuzu=false;
    while(1){
        bool h=true;
        vector<bool> bl(n,true); 
        for(int i=0;i<n;i++){
            if(vec[i].empty()){
                continue;
            }
            int a = vec[i].front();
            if(bl[i]==false){
                continue;
            }
            if(bl[a]==false){
                continue;
            }
          //  cout<<a<<endl;
         //   cout<<"入った"<<endl;
            
            if(vec[a].front()==i){
                //cout<<"入った"<<endl;
                vec[i].pop();
                vec[a].pop();
                h=false;
                bl[i]=false;
                bl[a]=false;
             //   cout<<"i"<<i+1<<"a"<<a+1<<endl;
            }
        }
        if(h){
            break;
        }
        count++;
        if(count==10000){
            kuzu=true;
            break;
        }
    }
    bool ha=true;
    for(int i=0;i<n;i++){
        if(!vec[i].empty()){
            ha=false;
            break;
        }
    }
    if(kuzu)cout<<499500<<endl;
    else if(ha){
        cout<<count<<endl;
    }
    else{
        cout<<-1<<endl;
    }
}

Measured memory_bytes: 4736
#include<iostream>
#include<iomanip>
#include<cmath>
#define PI 3.14159265359
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
cout<<setprecision(20)<<0.5*sin(c*PI/180)*a*b<<" "<<a+b+sqrt(a*a+b*b-2*a*b*cos(c*PI/180))<<" "<<b*sin(c*PI/180)<<endl;
}

Measured memory_bytes: 1268
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;
int main(){
  ll n,T;
  cin >> n>> T;
  ll sum=0;
  ll t[n];
  for(int i=0;i<n;i++) cin >>t[i];
  for(int  i=0;i<n-1;i++){
    sum+=min(T,t[i+1]-t[i]);
  }
 cout << sum+T<<endl;
}


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

signed main(){
	lint N; cin >> N;
	vector<lint> a(N), sum(N + 1, 0);
	for(lint i = 0; i < N; i++) cin >> a[i], sum[i + 1] = sum[i] + a[i];
	vector<vector<lint> > dp(N, vector<lint> (N, INF));
	for(lint i = 0; i < N; i++) dp[i][i] = 0;
	for(lint i = 1; i < N; i++){
		for(lint j = 0; j + i < N; j++){
			for(lint k = j; k < j + i; k++){
				lint x = dp[j][k] + dp[k + 1][j + i];
				lint y = sum[k + 1] - sum[j] + sum[j + i + 1] - sum[k + 1];
				dp[j][j + i] = min(dp[j][j + i], x + y);
			}
		}
	}
	cout << dp[0][N - 1] << endl;
}

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

int main(void) {
	int A, B, C;
	cin >> A >> B >> C;
	if ((A == 5 && B == 5 && C == 7) || (A == 5 && B == 7 && C == 5) || (A == 7 && B == 5 && C == 5)) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
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: 3076
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.trim().split(" ");
	input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var N = parseInt(input[0].split(" "));
  var list = input[1].split(" ");
  
  while(true){
    var tmp = N.toString().split("");
    var breakFlag = true;
    for(var i = 0; i < tmp.length; i++){
      if(list.indexOf(tmp[i]) != -1){
         breakFlag = false;
      }
    }
    if(breakFlag){
       break;
    }else{
      N++;
    }
  }
  myout(N);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 13056
#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 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

ll bit[100050];
void update(int p, ll v) {
	for (; p <= 100001; p += p & (-p)) bit[p] = (bit[p] + v) % MOD;
}
ll getsum(int p) {
	ll rv = 0;
	for (; p; p -= p & (-p)) rv = (rv + bit[p]) % MOD;
	return rv;
}

vector <int> Vx;
vector <int> Vy;

int in1[100050];
int in2[100050];
pii Qu[100050];

int main() {
	int N, M, i, j;
	scanf("%d %d", &N, &M);
	for (i = 1; i <= N; i++) scanf("%d", &in1[i]);
	for (i = 1; i <= M; i++) scanf("%d", &in2[i]);

	int c = 0;
	for (i = 1; i <= N; i++) {
		int p = lower_bound(in2 + 1, in2 + M + 1, in1[i]) - in2;
		if (p == 1 || p == M + 1) continue;

		c++;
		Qu[c] = pii(in1[i] - in2[p - 1], in2[p] - in1[i]);
		Vx.push_back(Qu[c].first);
		Vy.push_back(Qu[c].second);
	}

	if (c == 0) return !printf("1\n");

	sort(all(Vx));
	sort(all(Vy));
	Vx.erase(unique(all(Vx)), Vx.end());
	Vy.erase(unique(all(Vy)), Vy.end());

	for (i = 1; i <= c; i++) {
		Qu[i].first = lower_bound(all(Vx), Qu[i].first) - Vx.begin() + 1;
		Qu[i].second = lower_bound(all(Vy), Qu[i].second) - Vy.begin() + 1;
	}
	sort(Qu + 1, Qu + c + 1, [](pii a, pii b) {
		if (a.first != b.first) return a.first < b.first;
		else return a.second > b.second;
	});

	update(1, 1);
	for (i = 1; i <= c; i++) {
		if (Qu[i] == Qu[i - 1]) continue;
		int t = Qu[i].second;
		update(t + 1, getsum(t));
	}
	return !printf("%lld\n", getsum(100001));
}

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

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

using namespace std;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

int main() {
	int N; cin >> N;
	map<string, int> mp;
	rep(i, N) {
		string S; cin >> S;
		++mp[S];
	}
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
}



Measured memory_bytes: 3604
// https://atcoder.jp/contests/practice2/tasks/practice2_a

#include <bits/stdc++.h>

using namespace std;

template <typename T>
class FenwickTree {
 private:
  std::vector<T> tree;

 public:
  FenwickTree(const std::size_t n) : tree(n + 1, 0) {}

  FenwickTree(const std::vector<T> vec) : tree(vec.size() + 1) {
    for (std::size_t i = 0; i < vec.size(); i++) {
      add(i, vec[i]);
    }
  }

  std::size_t size() const { return tree.size() - 1; }

  void add(const std::size_t idx, const T x) {
    for (std::size_t i = idx + 1; i < tree.size(); i += i & (~i + 1)) {
      tree[i] += x;
    }
  }

  T query(const std::size_t idx) {
    T res = 0;
    for (std::size_t i = idx; i != 0; i &= i - 1) {
      res += tree[i];
    }
    return res;
  }

  T query(const std::size_t l, const std::size_t r) { return query(r) - query(l); }
};

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int N, Q;
  std::cin >> N >> Q;
  vector<int64_t> A(N);
  for (auto&& e : A) {
    std::cin >> e;
  }
  FenwickTree ft(A);
  for (int i = 0; i < Q; i++) {
    int t;
    std::cin >> t;
    if (t == 0) {
      int idx, x;
      std::cin >> idx >> x;
      ft.add(idx, x);
    } else {
      int l, r;
      cin >> l >> r;
      std::cout << ft.query(l, r) << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 15084
C = []
for _ in range(4):
    c = [i for i in range(1, 14)]
    C.append(c)
n = int(input())
for _ in range(n):
    i, j = map(str, input().split())
    j = int(j)
    if i == 'S':
        C[0][j - 1] = 0
    elif i == 'H':
        C[1][j - 1] = 0
    elif i == 'C':
        C[2][j - 1] = 0
    else:
        C[3][j - 1] = 0
for i in range(4):
    for j in range(13):
        if C[i][j] != 0:
            if i == 0:
                print('S', end=' ')
                print(j + 1)
            elif i == 1:
                print('H', end=' ')
                print(j + 1)
            elif i == 2:
                print('C', end=' ')
                print(j + 1)
            else:
                print('D', end=' ')
                print(j + 1)


Measured memory_bytes: 5616
#include <iostream>

using namespace std;


int main() {
	int num, sum;
	scanf("%d%d", &num,&sum);

	int a,b;
	sum /= 1000;

	for (a = 0;a <= num;a++) {
		for (b = 0;b <= (num-a) ;b++) {
			if (9 * a + 4 * b == sum - num) {
				printf("%d %d %d\n", a, b, num - a - b);
				return 0;
			}
		}
	}

	
	printf("-1 -1 -1\n");

	return 0;

}


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

using namespace std;


int main(void)
{
    int n,m, k;


    cin >>n >>m;

    vector<int> sum(m, 0);

    for(int i = 0; i < n; i++){
        cin >>k;
        for(int j = 0; j < k; j++){
            int tmp;
            cin >> tmp;
            sum[tmp-1]++;
        }
    }

    int ans = 0;
    for(int i = 0; i < m; i++){
        if(sum[i] == n){
            ans++;
        }
    }

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

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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

vector<vector<pair<int, int> > > edge;//edge[i][j] firstがiからj番目のノード、secondがその重み
vector<int> d(100005,INF);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b;
	string s;
	cin >> a >> b >> s;
	rep(i, a+b+1){
		if(i < a || i > a){
			if(s[i] - '0' <= 9 && s[i] - '0' >= 0){

			}else{
				cout << "No" << endl;
				return 0;
			}
		}else if(i == a){
			if(s[i] == '-'){

			}else{
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <atcoder/all>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;
static const ll mod = 1e9 + 7;

template<typename T>
static inline void chmin(T & ref, const T  value) {
	if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T & ref, const T value) {
	if (ref < value) ref = value;
}

int main() {
	int k;
	cin >> k;
	rep(i, k) {
		cout << "ACL";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3664
#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);
  string s;cin>>s;
  bool N=false,S=false,E=false,W=false;
  for(int i=0;i<s.size();i++)
    if(s[i]=='N')N=true;
    else if(s[i]=='S')S=true;
    else if(s[i]=='W')W=true;
    else E=true;
  if(N&&S&&E&&W)cout<<"Yes"<<endl;
  else if(N&&S&&!E&&!W)cout<<"Yes"<<endl;
  else if(!N&&!S&&E&&W)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>

using ll = long long;
using namespace std;

#define Input(x) scanf("%lld",&x)

ll n, m, k;
ll a[23456];

const ll INF = 123456789012345678;

ll memo[23456];
ll dfs(ll x_)
{
	if (memo[x_] >= 0)return memo[x_];
	ll minor = INF,maxor = 0;
	ll answer = INF;
	for (int box = 1; box <= m; ++box)
	{
		if (x_ - box < 0)break;
		minor = min(minor, a[x_ - box]);
		maxor = max(maxor, a[x_ - box]);
		answer = min(answer, dfs(x_ - box) + k + box * (maxor - minor));
	}
	return memo[x_] = answer;
}

int main()
{
	Input(n); Input(m); Input(k);
	for (int i = 0; i < n; ++i)Input(a[i]);
	memset(memo, 0xFF, sizeof(memo));
	memo[0] = 0;
	printf("%lld\n", dfs(n));
	return 0;
}

Measured memory_bytes: 4280
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl

int main() {
    int k, s;
    cin >> k >> s;
    int ans = 0;
    rep(i,k+1) {
        rep(j,k+1) {
            if (i+j <= s && s-i-j <= k) ans++;
        }
    }
    ct(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>
 
using namespace std;

int main(){
  char a,b;
  cin >> a >> b;
  cout << (a == b ? '=' : a > b ? '>' : '<') << endl;
}

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

alp = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
name = ''
while(True):
    m = n%26
    if(m == 0):
        m = 26
        n -= 26
    name = alp[m-1] + name
    n = n//26
    if(n==0):
        break

print(name)

Measured memory_bytes: 9212
#abc 106 b yakusu
import itertools
def yakusu(x):
    wareru=[]
    for i in range(1,x+1):
        if x%i==0:
            wareru.append(i)
    num=len(wareru)
    return num

n=int(input())
ans=0
for i in range(1,n+1):
    if i%2==0:
        continue
    if yakusu(i)==8:
        ans+=1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using u32 = uint32_t;

int main() {
	u32 N;
	cin >> N;
	
	string S;
	cin >> S;
	
	u32 Q;
	cin >> Q;
	
	// set<u32> cm[26];
	map<char, set<u32>> cm;
	//for(u32 i=0; i<N; i++) cm[S[i] - 'a'].insert(i);
	for(u32 i=0; i<N; i++) cm[S[i]].insert(i);

	for(u32 q=0; q<Q; q++) {
		u32 t;
		cin >> t;
		
		if(t & 1) {
			u32 i;
			char c;
			cin >> i >> c;
	
			if(S[i-1] == c) continue;
			
			// cm[c - 'a'].insert(i-1);
			cm[c].insert(i-1);
			// cm[S[i-1] - 'a'].erase(i-1);
			cm[S[i-1]].erase(i-1);
			
			S[i-1] = c;
			
		} else {
			u32 l, r;
			cin >> l >> r;
			
			u32 ans = 0;
			
			// for(u32 i=0; i<26; i++) {
				// auto itr = cm[i].lower_bound(l - 1);
				// if(itr != cm[i].end() && *itr <= r - 1) ans++;
			// }
			for(auto ci=begin(cm); ci!=end(cm); ci++) {
				auto pi = (*ci).second.lower_bound(l - 1);
				if(pi != (*ci).second.end() && *pi <= r - 1) ans++;
			}
			
			cout << ans << endl;
		}
	}
	
	return 0;
}

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

int main(){
	int H, W;
	cin >> H >> W;

	for(int i = 0; i < W+2; i++)
		cout << '#';
	cout << endl;

	for(int i = 0; i < H; i++){
		string a;
		cin >> a;
		cout << '#' << a << '#' << endl;
	}

	for(int i = 0; i < W+2; i++)
		cout << '#';
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int T;
  R T;
  while(T--) {
    int n,x;
    cin >> n >> x;
    priority_queue<int,vector<int>,greater<int> > que;
    que.push(x);
    rep(i,n-1) {
      int y=que.top();que.pop();
      que.push(127^y);
      que.push(127);
    }
    int ans=0;
    while(!que.empty()) {
      ans+=que.top();que.pop();
    }
    pr(ans);
  }
}

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


Measured memory_bytes: 256
input = gets

 
key = ["SUN\n","MON\n","TUE\n","WED\n","THU\n","FRI\n","SAT\n"]
 
if input == key[0] then
    print 7
elsif input == key[1] then
    print 6
elsif input == key[2] then
    print 5
elsif input == key[3] then
    print 4
elsif input == key[4] then
    print 3
elsif input == key[5] then
    print 2
elsif input == key[6] then
    print 1
end

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int n,k,m,a,b,p[100000];
  while(cin>>n>>k,n||k){
    for(int i=0;i<k;++i){
      cin>>m;p[i]=m;
    }
    sort(p,p+k);
    a=b=0;m=1;
    for(int i=1;i<k;++i){
      if(i==1&&!p[0]) continue;
      if(p[i]==p[i-1]+1){
	++m;
	if(i==k-1) a=max(a,m+((!b&&!p[0])?1:b));
      }
      else if(p[i]==p[i-1]+2&&!p[0]){
	a=max(a,m+((!b&&!p[0])?1:b));b=m;m=2;
      }
      else{
	a=max(a,m+((!b&&!p[0])?1:b));m=1;b=0;
      }
    }
    cout<<a<<endl;
  }
  return 0;
}

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

int main(){
    string s;cin>>s;
    string t;cin>>t;
    int sl=s.length();
    int tl=t.length();
    vector<int> v(sl-tl+1);
    for(int i=0;i<=sl-tl;i++){
        for(int j=0;j<tl;j++){
            if(s[i+j]==t[j]) v[i]++;
        }
    }
    cout << tl-*max_element(v.begin(),v.end());
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int32_t main(){
    IOS;
    string s;
    cin >> s;
    int n = s.size();
    if(s[n-1] == 's'){
        s+='e';
        s+='s';
        cout << s << endl;
    }
    else {
        s+='s';
        cout << s << endl;
    }
    return 0;

}

Measured memory_bytes: 3656
#!ruby

KK = ARGF.gets.chomp.to_i
AA, BB = ARGF.gets.chomp.split.collect {|el| el.to_i}

ak = AA / KK

ans = "NG"

kk = ak * KK
if kk < AA
  kk += KK
end
if kk <= BB
  ans = "OK"
end

puts ans


Measured memory_bytes: 14368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
//long long dp[100010];
long long h[100010];

int main()
{
    int N; cin >> N;
    rep(i, N) cin >> h[i];

    vector<ll> dp(100010, INF);
    dp[0] = 0;

    Rep(i, 1, N)
    {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1)
            chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[N - 1] << endl;
}



Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	int a,b,c[7],i;
	for(i=0;i<7;i++){
		scanf("%d %d",&a,&b);
		c[i]=a-b;
	}
	for(i=0;i<7;i++){
		printf("%d\n",c[i]);
	}
	return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1000000007;
#define f(i,a,b) for(i=a;i<b;i++)
#define rf(i,a,b) for(i=a;i>=b;i--)
#define sf(i,s) for(i=0;s[i]!='\0';i++)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define inf 1e18
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tr(v,i) for(typeof(v).begin() i = v.begin(); i != v.end(); i++)
#define pre(v,x) (v.find(x) != v.end())
#define vpre(v,x) (find(all(v),x) != v.end())
#define gcd(x,y) __gcd(x,y)
#define bc(x) __builtin_popcountll(x)
//cin.ignore(1, '\n');
ll power(ll a, ll b)
{
    if (b == 0)
        return 1;
    if (b == 1)
        return a;
    else
    {
        ll t = power(a, b / 2);
        if (b % 2 == 0)
            return t*t;
        else
            return t*t*a;
    }
}
void solve()
{
    ll n,x,y,c=0;
    double d,z;
    cin>>n>>d;
    while(n--)
    {
        cin>>x>>y;
        z=x*x+y*y;
        z=(double)sqrt(z);
        if(z<=d)
        {
            c++;
        }
    }
    cout<<c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
const int m=1e9;


int main(){
 long long a,v,b,w,t;
 cin>>a>>v>>b>>w>>t;
 long long x=v-w;
 if(abs(b-a)<=t*x) {
      cout<<"YES"<<endl; 
     return 0;
 }
 else {
     cout<<"NO"<<endl;
     return 0;
 }
}

 


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(){
    string S;
    cin >> S;
    if(S == "SUN") cout << 7 << endl;
    if(S == "SAT") cout << 1 << endl;
    if(S == "FRI") cout << 2 << endl;
    if(S == "THU") cout << 3 << endl;
    if(S == "WED") cout << 4 << endl;
    if(S == "TUE") cout << 5 << endl;
    if(S == "MON") cout << 6 << endl;
    return 0;
}

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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

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

    int N;
    cin >> N;

    vector<int> H(N);
    REP(i, N) cin >> H[i];

    vector<int> v = {0};
    FOR(i, 1, N) {
        if (H[i-1] < H[i]) {
            v.push_back(i);
        }
    }

    v.push_back(N);

    int ret = 0;
    FOR(i, 1, v.size()) {
        ret = max(v[i] - v[i - 1] - 1, ret);
    }

    cout << ret << endl;
}


Measured memory_bytes: 1276