akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int c = 12800;

bool dp[2][80][25600];

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector< vector<int> > a(n, vector<int>(m));
    vector< vector<int> > b(n, vector<int>(m));
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            cin >> a[i][j];
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            cin >> b[i][j];
    for (int i = 0; i < 2; ++i)
        for (int j = 0; j < 80; ++j)
            for (int k = 0; k < 25600; ++k)
                dp[i][j][k] = false;
    dp[0][0][a[0][0] - b[0][0] + c] = true;
    dp[0][0][b[0][0] - a[0][0] + c] = true;
    for (int i = 0; i < m - 1; ++i)
    {
        for (int r = -12800; r <= 12800; ++r)
        {
            if (dp[0][i][r + c])
            {
                int r2 = r + a[0][i + 1] - b[0][i + 1];
                dp[0][i + 1][r2 + c] = true;
                int r3 = r + b[0][i + 1] - a[0][i + 1];
                dp[0][i + 1][r3 + c] = true;
            }
        }
    }
    for (int i = 0; i < n - 1; ++i)
    {
        int p = i % 2;
        for (int j = 0; j < m; ++j)
        {
            for (int r = -12800; r <= 12800; ++r)
            {
                if (dp[p][j][r + c])
                {
                    int r2 = r + a[i + 1][j] - b[i + 1][j];
                    dp[p ^ 1][j][r2 + c] = true;
                    int r3 = r + b[i + 1][j] - a[i + 1][j];
                    dp[p ^ 1][j][r3 + c] = true;
                }
            }
        }
        p = ((i % 2) ^ 1);
        for (int j = 0; j < m - 1; ++j)
        {
            for (int r = -12800; r <= 12800; ++r)
            {
                if (dp[p][j][r + c])
                {
                    int r2 = r + a[i + 1][j + 1] - b[i + 1][j + 1];
                    dp[p][j + 1][r2 + c] = true;
                    int r3 = r + b[i + 1][j + 1] - a[i + 1][j + 1];
                    dp[p][j + 1][r3 + c] = true;
                }
            }
        }
        for (int j = 0; j < m; ++j)
            for (int r = -12800; r <= 12800; ++r)
                dp[i % 2][j][r + c] = false;
    }
    int odp = 1000000000;
    for (int i = -12800; i <= 12800; ++i)
        if (dp[(n - 1) % 2][m - 1][i + c])
            odp = min(odp, (int) abs(i));
    cout << odp;
    return 0;
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        int[] b = new int[n];
        int[] w = new int[n];
        if(s[0] == '.') w[0] = 1;
        else b[0] = 1;
        for (int i = 1; i < n; i++) {
            b[i] = b[i-1];
            w[i] = w[i-1];
            if(s[i] == '.') w[i]++;
            else b[i]++;
        }
        int ans = Integer.MAX_VALUE;
        for (int i = 0; i <= n; i++) {
            if(i == 0){
                ans = Math.min(ans, w[n-1]);
            }else if(i == n){
                ans = Math.min(ans, b[n-1]);
            }else{
                ans = Math.min(ans, b[i-1] + (w[n-1] - w[i-1]));
            }
        }
        System.out.println(ans);
        sc.close();
    }

}


Measured memory_bytes: 28728
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>
#include <stack>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int N, sz = 150000;
long long int A[110000];
bool flag[110000];
long long int BIT[210000];

void add(int a, long long int w){
	
	// a番目の要素にwを足す O(log N)
	
	for(int x = a; x <= sz; x += x & -x){
		BIT[x] += w;
	}
}

long long int sum(int a){
	
	// 1からaまでの要素の合計を返す O(log N)
	
	long long int ret = 0;
	for(int x = a; x > 0; x -= x & -x){
		ret += BIT[x];
	}
	return ret;
}

void init(){
	for(int i = 0; i < sz; i++){
		BIT[i] = 0;
	}
}

bool check(long long int min_A){
	for(int i = 0; i < N; i++){
		flag[i] = (A[i] >= min_A);
	}
	vector<P> v;
	long long int cnt = 0, S = 0;
	v.push_back(make_pair(0, 1));
	for(int i = 0; i < N; i++){
		if(flag[i]){
			S += 1;
		}else{
			S -= 1;
		}
		v.push_back(make_pair(S, i + 2));
	}
	sort(v.begin(), v.end());
	init();
	for(int i = 0; i < v.size(); i++){
		cnt += sum(v[i].second);
		add(v[i].second, 1);
	}
	//cout << min_A << " " << cnt << endl;
	return cnt >= (N * (N + 1) / 2 + 1) / 2;
}

long long int bin_search(long long int lef, long long int rig){
	long long int middle = (lef + rig) / 2;
	//cout << middle << " ";
	if(rig - lef <= 1){
		if(check(rig)){
			return rig;
		}else{
			return lef;
		}
	}
	if(check(middle)){
		lef = middle;
	}else{
		rig = middle;
	}
	return bin_search(lef, rig);
}

int main(){
	
	cin >> N;
	
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	
	cout << bin_search(0, 1e10) << endl;
	
	return 0;
}


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

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

	int j, y;
	cin >> j >> y;

	vector<string> vec;
	for(int i = 0; i < (1 << (j + y)); ++i){
		string str;
		int cnt = 0;
		for(int k = 0; k < (j + y); ++k){
			if((i >> k) & 1){
				cnt++;
				str += 'B';
			}
			else str += 'A';
		}
		if(cnt != y) continue;
		else {
			int a = 0;
			int b = 0;
			bool check = false;
			for(size_t k = 0; k < str.length(); ++k){
				if(str[k] == 'A') ++a;
				if(str[k] == 'B') ++b;
				if(k != str.length() - 1 && ((a >= 5 && b < 4) || (a < 4 && b >= 5))){
					check = true;
					break;
				}
			}
			if(check) continue;
			vec.push_back(str);
		}
	}

	sort(vec.begin(), vec.end());
	for(size_t i = 0; i < vec.size(); ++i){
		cout << vec[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)){
			int start = sc.nextInt();
			int target = sc.nextInt();
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();

			int total = 0;
			if (start<0) total = -start*a+b+c*target;
			else total = c*(target-start);
			System.out.println(total);
		}
	}
}


Measured memory_bytes: 26136
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

int main() {
  int64_t ans=0,temp=0;
  string S; cin>>S;
  rep(i,S.size()-1){
    if(S.at(i)=='A') temp++;
    else if(S.at(i)=='B'&&S.at(i+1)=='C'){
      ans+=temp;
      S.at(i+1)='A';
      i++;
    }
    else temp=0;
  }
  cout<<ans;      
}


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

template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=1e5+5;
int fa[N],d[N],cnt[N],q[N];
vector<int>lk[N];

int main()
{
	//freopen("1.in","r",stdin);
	int n;
	cin>>n;
	rep(i,2,n)
	{
		scanf("%d",fa+i);
		++cnt[fa[i]];
	}
	int tail=0;
	rep(i,1,n)
	if(!cnt[i])q[++tail]=i;
	rep(head,1,tail)
	{
		int x=q[head];
		sort(lk[x].begin(),lk[x].end());
		rep(i,0,cnt[x]-1)chmax(d[x],lk[x][i]+cnt[x]-i);
		int y=fa[x];
		lk[y].push_back(d[x]);
		if(lk[y].size()==cnt[y])q[++tail]=y;
	}
	cout<<d[1];
}

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

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

    int ans1 = 0;
    char c = '0';
    for (size_t i = 0; i < S.size(); ++i) {
        if (S[i] != c) {
            ++ans1; 
        }

        if (c == '1') {
            c = '0';
        } else {
            c = '1';
        }
    }

    int ans2 = 0;
    c = '1';
    for (size_t i = 0; i < S.size(); ++i) {
        if (S[i] != c) {
            ++ans2; 
        }

        if (c == '1') {
            c = '0';
        } else {
            c = '1';
        }
    }

    std::printf("%d\n", std::min(ans1, ans2));

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstring>

using namespace std;

int change(char c){
    if(c=='I')return 1;
    if(c=='V')return 5;
    if(c=='X')return 10;
    if(c=='L')return 50;
    if(c=='C')return 100;
    if(c=='D')return 500;
    if(c=='M')return 1000;
    return 0;
}

int main(void){
    char str[100];
    int sum;
    
    while(cin>>str){
        sum=0;
        for(int i=0;i<strlen(str);i++){
            if(change(str[i])>=change(str[i+1])){
                sum+=change(str[i]);
            }
            else{
                sum+=change(str[i+1])-change(str[i]);
                i++;
            }
        }
        cout<<sum<<endl;
    }
    return(0);
}

Measured memory_bytes: 1140
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<ctype.h>
using namespace std;

int main()
{
    char str[110];
    int y;
    scanf("%s",str);
    y= strlen(str);
    printf("%c%d%c\n",tolower(str[0]),y-2,tolower(str[y-1]));

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int S,h,m,s;
	scanf("%d",&S);
	h = S/3600;
	m = (S-h*3600)/60;
	s = S-h*3600-m*60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}



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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/04  Problem: 064_arc_c / Link: https://arc064.contest.atcoder.jp/tasks/arc064_c?lang=en  ----- */
/* ------問題------

xy 平面があります。 すぬけ君は座標 (xs,ys) から座標 (xt,yt) まで移動しようとしています。 すぬけ君は好きな向きへ速さ 1 で動くことができます。 なお、すぬけ君は大きさのない点と見なすことにします。
平面上には N 個の円形のバリアが張ってあります。 i 番目のバリアは中心が (xi,yi) で半径が ri です。 バリアは互いに重なっていたり、互いを含んでいたりすることがあります。
平面上の各座標について、その座標がどのバリアの内部にも含まれない場合、その座標には宇宙線が降り注いでいます。
すぬけ君は移動中にできるだけ宇宙線を浴びたくないので、宇宙線を浴びる時間が最小になるように移動します。 すぬけ君が移動中に宇宙線を浴びる時間の最小値を求めてください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



using Type = pair<double, int>;

vector<double> Dijkstra(vector<vector<pair<int,double>>>& G, int s) {
	vector<double> dist(SZ(G), LINF);
	dist[s] = 0;
	priority_queue<Type, vector<Type>, greater<Type>> que;
	que.push(Type(0LL, s));

	while (!que.empty()) {
		Type p = que.top(); que.pop();
		int v; /* 頂点*/ double d; /* 頂点vまでの距離 */
		tie(d, v) = p;

		if (d > dist[v]) continue;

		FOR(i, 0, (int)G[v].size()) {
			int nv = G[v][i].first;
			if (dist[nv] > dist[v] + G[v][i].second) {
				dist[nv] = dist[v] + G[v][i].second;
				que.push(Type(dist[nv], nv));
			}
		}
	}
	return dist;
}

LL N;

double ans = 0LL;
struct Circle {
	double x, y, r;
	Circle() { x = y = r = 0; }
};

double distance(Circle &a, Circle &b) {
	double d =hypot(a.x - b.x, a.y - b.y)- (a.r + b.r );
	return (d > 0 ? d : 0);
}
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	double sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty >> N;
	vector < Circle > Cir(N + 2);
	FOR(i, 0, N) {
		cin >> Cir[i].x >> Cir[i].y >> Cir[i].r;
	}
	const int S = N;
	const int T = N + 1;
	Cir[S].x = sx; Cir[S].y = sy;
	Cir[T].x = tx; Cir[T].y = ty;
	N += 2;
	
	vector<vector<pair<int,double>>> G(N);
	FOR(i, 0, N) {
		FOR(j, i + 1, N) {
			double d = distance(Cir[i], Cir[j]);
			G[i].push_back(pair<int, double>(j,d));
			G[j].push_back(pair<int, double>(i,d));
		}
	}
	vector<double> dist = Dijkstra(G, S);
	ans = dist[T];
	cout << fixed<<setprecision(10)<<ans << "\n";

	return 0;
}


Measured memory_bytes: 22256
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
x = [0]*n
y = [0]*n
h = [0]*n

for i in range(n):
    x[i], y[i], h[i] = MAP()

for i in range(101):
    for j in range(101):
        H = 0
        for k in range(n):
            if h[k] != 0:
                if H == 0 or H == h[k] + abs(x[k]-i) + abs(y[k]-j):
                    H = h[k] + abs(x[k]-i) + abs(y[k]-j)
                else:
                    break
        else:
            for k in range(n):
                if h[k] == 0:
                    if H - abs(x[k]-i) - abs(y[k]-j) <= 0:
                        continue
                    else:
                        break
            else:
                print(i,j,H)

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

const LL maxn=3e5+10;

LL n,a[maxn];
LL pre[maxn],suf[maxn],Sum,Ans=-1e18;

priority_queue<LL,vector<LL>,greater<LL> > q1;
priority_queue<LL> q2;

int main()
{
#ifdef h10
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	LL i;
	scanf("%lld",&n);
	for (i=1;i<=3*n;i++)
		scanf("%lld",&a[i]);

	Sum=0;
	for (i=1;i<=n;i++)
	{
		q1.push(a[i]);
		Sum+=a[i];
	}
	pre[n]=Sum;
	for (i=n+1;i<=2*n;i++)
	{
		q1.push(a[i]);
		Sum+=a[i];
		Sum-=q1.top();
		q1.pop();
		pre[i]=Sum;
	}

	Sum=0;
	for (i=3*n;i>2*n;i--)
	{
		q2.push(a[i]);
		Sum+=a[i];
	}
	suf[2*n+1]=Sum;
	for (i=2*n;i>=n;i--)
	{
		q2.push(a[i]);
		Sum+=a[i];
		Sum-=q2.top();
		q2.pop();
		suf[i]=Sum;
	}

	for (i=n;i<=2*n;i++)
		Ans=max(Ans,pre[i]-suf[i+1]);
	printf("%lld\n",Ans);
}


Measured memory_bytes: 7668
import sys
input = sys.stdin.readline
from itertools import groupby
def print_ans(input_line):
    """Test Case
    >>> print_ans("aabbbbaaca")
    5
    >>> print_ans("aaaaa")
    1
    >>> print_ans("xxzaffeeeeddfkkkkllq")
    10
    """
    print(len(list(groupby(input_line))))

if __name__ == '__main__':
    N = int(input().rstrip())
    s = input().rstrip()
    print_ans(s)

Measured memory_bytes: 15860
#include "bits/stdc++.h"
using    namespace std;
typedef  long double ld;
#define  int long long
typedef  pair<int,int> pii;
#define  RAGE ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  rep(i,n) for(i=0; i <n; i++)
#define  repv(i,k,n) for(int i=k; i<=n; i++)
#define  pb push_back
#define  mp make_pair
#define  F  first
#define  S  second
#define  sz(x)  (int)x.size()
#define  all(v) v.begin(),v.end()
#define  endl '\n'
#define  deb(x) c out<<#x<<" = "<<x<<endl
#define  gcd   __gcd
#define  inf   LLONG_MAX
#define  minf  LLONG_MIN 
#define  gi  greater<int> 
#define  gpi greater<pii>  
#define  sp(n) fixed<<setprecision(n)
const int mod = (int)(1e9+7);
int power(int x,int n)
{   
    if(n==0)    return 1;
    if(n==1)    return x%mod;
    if(n%2==0)  {   int y = power(x,n/2)%mod;return (y*y)%mod;}
    if(n&1)     {   int y = power(x,n-1);return (x%mod * y%mod)%mod;}
    return 0;
}
int pct(int x)
{   return __builtin_popcountll(x);}
int  lcm(int a,int b){return a*b/gcd(a,b);}
bool is_power_2(int n){ return log2(n)==floor(log2(n));}
bool is_prime(int n){for(int i=2; i*i<=n; i++)if(n%i==0)return 0; return 1;}
void db()
{   
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
void timeit()
{  
    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed: " <<sp(5)<< 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}
int     dx []    =  {-1 , 0 , 1 , 0 ,-1,-1, 1,  1};
int     dy []    =  { 0 , 1 , 0 ,-1 ,-1, 1, 1, -1};
char    dir[]    =  {'U','R','D','L'};
/* ---------------------- ar.cpp --------------------------------- */
const int maxn = 1e5+5;
void solve(int tc)
{
    //  cout<<"Case #"<<tc<<": ";
    int n,i,j,p,k,m,q,l,r;
    cin>>n;
    int ar[n];
    rep(i,n)
        cin>>ar[i];
    vector<int> dp(n , inf);
    dp[0] = 0;
    repv(i,1,n-1)
    {
        if(i-1 >= 0)
            dp[i] = min(dp[i] , dp[i-1] + abs(ar[i] - ar[i-1]));
        if(i-2>=0)
            dp[i] = min(dp[i] , dp[i-2] + abs(ar[i] - ar[i-2]));
    }
    cout<<dp[n-1];
}       
signed main()
{
    // ar.cpp
    RAGE;
 //   db();    
    int t=1;
    //cin>>t;
    for(int i=1; i<=t; i++)
    {
        solve(i);
    }
//    timeit();
    return 0;
}


Measured memory_bytes: 4760
def main():
	md=998244353
	n=int(input())
	s = input()
	r=[]
	g=[]
	b=[]
	for i in range(n*3):
		if s[i]=="R":r.append(i+1)
		elif s[i]=="G":g.append(i+1)
		else:b.append(i+1)

	u=[]
	m=[]
	l=[]
	
	for i in range(n):
		uu=max(r[i],g[i],b[i])
		ll=min(r[i],g[i],b[i])
		u.append(uu)
		l.append(ll)
		m.append(r[i]+g[i]+b[i]-uu-ll)
	cu=0
	cm=0
	cl=0
	ans=1

	for i in range(n):
		while cu<=n-1 and u[n-1-cu]>m[n-1-i]:
			cu+=1
		while cl<=n-1 and l[cl]<m[i]:
			cl+=1
		ans=(ans*(i+1)*(cu-i)*(cl-i))%md
	print(ans)
main()


Measured memory_bytes: 21360
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> sum(n+1);
    for(int i = 0; i < q; i++)
    {
        int a;
        cin >> a;
        sum[a]++;
    }

    for(int i = 1; i <= n; i++)
    {
        if(q - sum[i] >= k)
        {
            cout << "No" << endl;
        }
        else cout << "Yes" << endl;
    }
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
double eps=1e-8;
ll mod=1e9+7;
ll inf=1e9;
priority_queue<P,vector<P>,greater<P> > pq;

template <typename T>
int Count(const vector<T> &v, T l,T r){
  //counting [l,r]
  auto L = lower_bound(v.begin(), v.end() , l );
  auto R = upper_bound(v.begin(), v.end(), r );
  // [l,r) change upper -> lower

  return R-L;
}

int main(){
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  cout<<min((n+a-1)/a*b,(n+c-1)/c*d)<<endl;
  return 0;
}



Measured memory_bytes: 3096
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    s = ns()
    t = ns()

    if s == t[:-1]:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9672
#include<stdio.h>
int main(){

   int A,B;
   char op;

   scanf("%d %c %d",&A,&op,&B);

   if(op == '+'){
      printf("%d\n",A + B);
   }else if(op == '-'){
      printf("%d\n",A - B);
   }

   return 0;
}

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

int main(){
 int N;   
 cin >> N ;
 if (N/100==7||(N%100)/10==7||(N%10==7)){
   cout << "Yes" << endl; 
 }
 else {
   cout << "No"  << endl; 
 }
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
  final static long MOD = 1000000007;

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

    while (in.hasNext()) {
      int N = in.nextInt();
      String S = in.next();
      int[] countChar = new int[26];

      for (int i = 0; i < S.length(); ++i) {
        ++countChar[S.charAt(i) - 'a'];
      }

      long count = 1;
      for (int i = 0; i < countChar.length; ++i) {
        count *= countChar[i] + 1;
        count %= MOD;
      }

      System.out.println(count - 1);
    }
  }
}

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

typedef long long ll;

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

    int n; cin>>n;
    ll A[n+1], b;

    for (int i=0;i<=n;++i) cin>>A[i];
    ll ans = 0;
    for (int i=0;i<n;++i){
        cin>>b;
        ans += min(A[i], b);
        b -= min(A[i], b);

        ans += min(A[i+1], b);
        A[i+1] -= min(A[i+1], b);
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 1024
def g(x, y, z):
    g_xyz = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    return g_xyz


N = int(input())
ans_list = [0 for _ in range(60000)]
for x in range(1, 100):
  for y in range(1, 100):
      for z in range(1, 100):
          ans_list[g(x=x, y=y, z=z) - 1] += 1
           
for i in range(N):
    print(ans_list[i])

Measured memory_bytes: 9684
#include <bits/stdc++.h>
#include <queue>
using namespace std;
int main(){
	int H, W; cin >> H >> W; 
	int A[1010][1010] = {}; queue<pair<int, int>> que; 
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			char c; cin >> c; 
			if(c == '#'){
				A[i][j] = 1; 
				que.push(make_pair(i, j)); 
			}
		}
	}
	while(que.size()){
		pair<int, int> p = que.front(); que.pop(); 
      int i = p.first; int j = p.second; 
		if(i > 0 && A[i-1][j] == 0){
			A[i-1][j] = A[i][j] + 1; que.push(make_pair(i-1, j)); 
		}
		if(i < H-1 && A[i+1][j] == 0){
			A[i+1][j] = A[i][j] + 1; que.push(make_pair(i+1, j)); 
		}
		if(j > 0 && A[i][j-1] == 0){
			A[i][j-1] = A[i][j] + 1; que.push(make_pair(i, j-1)); 
		}
		if(j < W-1 && A[i][j+1] == 0){
			A[i][j+1] = A[i][j] + 1; que.push(make_pair(i, j+1)); 
		}
	}
	int ans = 0; 
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			ans = max(ans, A[i][j]); 
		}
	}
	cout << ans - 1 << endl; 
}

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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000

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

    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    ll ans = min(a,b) + min(c,d);

    cout << ans << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {

    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    use std::cmp::min;
    use std::cmp::max;
    input! {
        n: usize,
        m: usize,
        k: usize,
        A: [usize; n],
        B: [usize; m]
    }
    let mut count:usize = 0;
    let mut a = vec![0; n+1];
    let mut b = vec![0; m+1];
    for i in 1..n+1{
        a[i] = a[i-1] + A[i-1]
    }
    for i in 1..m+1{
        b[i] = b[i-1] + B[i-1]
    }
    let (mut ans, mut j) = (0, m);
    for i in 0..n+1{
        if a[i] > k{
            break
        }
        while b[j] > k - a[i]{
            j -= 1;
        }
        ans = max(ans, i+j);
    }
    println!("{}", ans)
}


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

#define ll long long

using namespace std;

const int maxn = 2e5 + 5;

ll a[maxn], b[maxn];

int main()
{
    ll n, m, k, x;

    cin >> n >> m >> k;

    for(int i = 1; i <= n; i++) cin >> x, a[i] = a[i - 1] + x;
    for(int i = 1; i <= m; i++) cin >> x, b[i] = b[i - 1] + x;

    int ans = 0;

    for(int i = 1; i <= n; i++){
        if(a[i] > k) break;

        int pos = upper_bound(b + 1, b + m + 1, k - a[i]) - b;

        ans = max(ans, i + pos - 1);
    }

    for(int i = 1; i <= m; i++){
        if(b[i] > k) break;

        int pos = upper_bound(a + 1, a + n + 1, k - b[i]) - a;

        ans = max(ans, i + pos - 1);
    }

    cout << ans << endl;

    return 0;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    double a,b,h,m; cin >> a >> b >> h >> m;
    double hoge,fuga;
    hoge = ((double)(1) / (double)(6)) * (double)PI * (double)h + ((double)(1) / (double)(360))*(double)PI * (double)m;
    fuga = ((double)(2) / (double)(60))*(double)PI*(double)m;
    double ans;
    // cout << hoge-fuga << endl;
    ans = a*a+b*b-(double)2*a*b*cos(hoge-fuga);
    cout << setprecision(15) << sqrt(ans) << endl;
}

Measured memory_bytes: 4228
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,t,i,p;
  cin>>n>>x>>t;
  for(i=0;i<n;i++){
      i=i+x;
  }
  p=i/x;
  cout<<p*t<<'\n';
  return(0);
}


Measured memory_bytes: 3632
#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;}

const double EPS = 1e-8;
using vec = vector<double>;
using mat = vector<vec>;

// 連立方程式Ax=bを解く
// Aは正方行列を仮定
// 解無し、一意に定まらない : 長さ0のvector
vec gauss_jordan(const mat &A, const vec &b){
    int d = A.size();
    mat B(d, vec(d+1));
    rep(i,d){
        rep(j,d) B[i][j] = A[i][j];
        B[i][d] = b[i];
    }

    rep(i,d){
        int pivot = i;
        for(int j=i; j<d; ++j){
            if( abs(B[j][i]) > abs(B[pivot][i]) ) pivot = j;
        }
        swap(B[i], B[pivot]);

        // 解無し、一意に定まらない : 長さ0のvector
        if(abs(B[i][i]) < EPS) return vec();

        // 注目する変数の係数を1にする
        for(int j=i+1; j<=d; ++j) B[i][j] /= B[i][i];
        rep(j,d){
            if(i==j) continue;
            // j番目の式からi番目の変数を除去
            for(int k=i+1; k<=d; ++k) B[j][k] -= B[j][i]*B[i][k];
        }
    }

    vec ret(d);
    rep(i,d) ret[i] = B[i][d];
    return ret;
}

const int INF = 19191919;

int main(){
    int n,s,t;
    while(scanf(" %d %d %d", &n, &s, &t),n){
        --s;
        --t;

        vector<int> q(n);
        rep(i,n) scanf(" %d", &q[i]);

        vector<vector<int>> a(n,vector<int>(n));
        rep(i,n)rep(j,n) scanf(" %d", &a[i][j]);

        vector<int> d(n,INF);
        d[t] = 0;
        queue<int> que;
        que.push(t);
        while(!que.empty()){
            int v = que.front();
            que.pop();
            rep(i,n){
                if(a[v][i]==0) continue;
                if(d[i] > d[v]+a[v][i]){
                    d[i] = d[v]+a[v][i];
                    que.push(i);
                }
            }
        }

        mat A(n,vec(n));
        vec b(n);
        rep(i,n){
            if(d[i]==INF || i==t){
                A[i][i] = 1;
                continue;
            }

            int ct = 0;
            rep(j,n)if(a[i][j]>0){
                if(q[i] == 1){
                    if(d[i] != a[i][j]+d[j]) continue;
                }
                ++ct;
            }

            A[i][i] = 1;
            rep(j,n)if(a[i][j]>0){
                if(q[i] == 1){
                    if(d[i] != a[i][j]+d[j]) continue;
                }
                A[i][j] -= 1.0/ct;
                b[i] += (double)a[i][j]/ct;
            }
        }

        vec res = gauss_jordan(A,b);
        assert(res.size()==n);
        printf("%.10f\n", res[s]);
    }
    return 0;
}



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

using namespace std;
const int N = 1e5+100;
long long a[N],b[N];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n+1;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>b[i];
	long long ans=0;
	for(int i=1;i<=n;i++){
		if(b[i]>=a[i]){
			b[i]-=a[i];
			ans+=a[i];
			a[i]=0;
		}
		else{
			ans+=b[i];
			a[i]-=b[i];
			b[i]=0;
		}
		if(b[i]>=a[i+1]){
			ans+=a[i+1];
			b[i]-=a[i+1];
			a[i+1]=0;
		}
		else{
			ans+=b[i];
			a[i+1]-=b[i];
			b[i]=0;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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


using namespace std;

using ll   = long long;
using ii   = pair < int , int >;
using i3   = pair < int , ii >;
using li   = pair < ll , int >;
using lii  = pair <  ll,  ii >;
using vi   = vector < int >;
using vl   = vector < ll >;
using vli  = vector < li >;
using vii  = vector < ii >;
using vi3  = vector < i3 >;
using vlii = vector < lii >;

const int N = 2e5 + 5;
const ll INF = 1e17;
const double eps = 1e-12 , PI = acos(-1);

int n , m;

void solve(int cs){
    scanf("%d" , &n);

    int cnt = 0 , ans = 0 , now = 0 , prv = 0;
    for(int i = 1 ; i <= n ; i ++){
        scanf("%d" , &now);

        if( (i) && (now > prv) ){
            cnt = 0;
        }
        cnt ++;
        ans = max(ans , cnt-1);
        prv = now;
    }

    printf("%d\n" , max(ans , cnt-1));


}

main(){
    int t = 1;
    //scanf("%d" , &t);

    for(int cs = 1 ; t -- ; cs ++){
        solve(cs);
    }

    return 0;
}



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

int main()
{    
    int H, W;

    while(1){

        cin >> H >> W;

        if(H==0 && W==0){
            break;
        }

        for(int j=0; j<W; j++){
            cout << "#";
        }
        cout << "\n";

        for(int i=1; i<H-1; i++){
            cout << "#";
            for(int j=1; j<W-1; j++){
                cout << ".";
            }
            cout << "#";
            cout << "\n";
        }

        for(int j=0; j<W; j++){
            cout << "#";
        }
        cout << "\n\n";

    }

    return 0;
}


Measured memory_bytes: 3024
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

vector<int> divisors[1000001];
int done[1000001];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int ans=0;
    for (int i=1;i<1000001;++i)
    {
        for (int j=(i << 1);j<1000001;j+=i)
            divisors[j].push_back(i);
    }
    int n;
    bool b;
    cin>>n;
    int a[n];
    for (int i=0;i<n;++i)
    {
        cin>>a[i];
        ++done[a[i]];
    }
    for (int i=0;i<n;++i)
    {
        if (done[a[i]]>1)
            continue;
        b=1;
        for (auto x : divisors[a[i]])
            if (done[x])
            {
                b=0;
                break;
            }
        if (b)
            ++ans;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 122492
/* ***************************************
Author        :Scau.ion
Created Time  :2016/10/30 12:50:41 UTC+8
File Name     :ion.cpp
*************************************** */

#include <bits/stdc++.h>

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

using namespace std;

const int maxn=300000;

int a[maxn];
bool b[maxn],cango[maxn];

int main()
{
    IOS;
	int n;
    cin>>n;
    int tot=n*2-1;
    for (int j=1;j<=tot;++j)
        cin>>a[j];
    int l=1,r=tot;
    while (l+1<r)
    {
        int mid=(l+r)/2;
        for (int j=1;j<=tot;++j)
        {
            if (a[j]<mid) b[j]=0;
            else b[j]=1;
        }
        b[0]=b[1];
        b[tot+1]=b[tot];
        for (int j=1;j<=tot;++j)
        {
            if (b[j]!=b[j-1]&&b[j]!=b[j+1]) cango[j]=1;
            else cango[j]=0;
        }
        int ha=0;
        while (cango[n-ha]&&cango[n+ha]) ++ha;
        if (b[n-ha]) l=mid;
        else r=mid;
    }
    cout<<l<<endl;
	return 0;
}


Measured memory_bytes: 1536
#define ll long long
#define lld long double
#define cn(n)  ll n;cin >> n;
#define tes(t) ll t;cin>>t;while(t--) 
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define al(v) v.begin(), v.end()
#define oset(X) tree<X, null_type, less<X>, rb_tree_tag, tree_order_statistics_node_update>
#define roset(X) tree<X, null_type, greater<X>, rb_tree_tag, tree_order_statistics_node_update>
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const ll MOD2 = 998244353;
const long double PI = 3.141592653589793;
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
ll power(ll x, ll y, ll p){ll res = 1;x %= p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}
ll po(ll base, ll powerRaised){if (powerRaised != 0)return (base * po(base, powerRaised - 1));else return 1;}
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
ll lcm(ll a, ll b){return (a * b) / gcd(a, b);}
int main()
{
//   ios_base::sync_with_stdio(false);
//   cin.tie(NULL);
//   cout.tie(NULL);
// #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif //*
  // tes(p)
  // {
    string s,t;
    cin>>s>>t;
    int n=s.length();
    int m=t.length();
    int dp[n+1][m+1];
    for(int i=0;i<n+1;i++)
    dp[i][0]=0;
    for(int i=0;i<m+1;i++)
    dp[0][i]=0;
    int res=-1;
    for(int i=1;i<=n;i++)
    {
      for(int j=1;j<=m;j++)
      {
        if(s[i-1]==t[j-1])
        dp[i][j]=max(dp[i-1][j-1]+1,dp[i-1][j]);
        else  
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        res=max(dp[i][j],res);
      }
    }
    // for(int i=1;i<=n;i++)
    // {
    //   for(int j=1;j<=m;j++)
    //   {
    //     cout<<dp[i][j]<<" ";
    //   }
    //   cout<<endl;
    // }

    int row=-1,column;
    string ans="";
    for(int i=1;i<=n;i++)
    {
      for(int j=1;j<=m;j++)
      {
        if(dp[i][j]==res)
        {
          row=i;
          column=j;
          break;
        }
      }
      if(row!=-1)
      break;
    }
    // cout<<row<<" "<<column;
    int len=res;
    while(res>0)
    {
      if(dp[row][column]==dp[row-1][column])
      {
        row--;
      }
      else if(dp[row][column]==dp[row][column-1])
      column--;
      else 
      {
        ans+=s[row-1];
        res--;
        row--;
        column--;
      }
    }
    repd(i,len-1,0)
    cout<<ans[i];
}


Measured memory_bytes: 38792
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
template<typename T> ll min(ll a, const T&& b) { return a < b ? a : b; }
template<typename T> ll min(const T&& a, ll b) { return a < b ? a : b; }
template<typename T> ll max(ll a, const T&& b) { return a > b ? a : b; }
template<typename T> ll max(const T&& a, ll b) { return a > b ? a : b; }
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n; cin >> n;
  ll ans = 0;
  ll a = 0, b = 0, ba = 0;
  rep(i, n) {
    string s; cin >> s;
    rep(j, 1, s.size()) {
      if (s[j-1] == 'A' && s[j] == 'B') ++ans;
    }
    if (s.front() == 'B' && s.back() == 'A') {
      ba++;
    }
    else if (s.front() == 'B') {
      ++b;
    }
    else if (s.back() == 'A') {
      ++a;
    }
  }
  // cout << ans << " " << a << " " << b << " " << ba << endl;
  {
    ll use = min(a, b);
    a -= use;
    ans += use;
  }
  if (ba > 0) {
    bool f = false;
    if (b > 0) {
      ll use = min(b, ba);
      ba -= use;
      ans += use;
      f = true;
    }
    else if (a > 0) {
      ll use = min(a, ba);
      ba -= use;
      ans += use;
      f = true;
    }
    if (f && ba > 0) {
      ans += ba;
    }
    else if (ba > 0) {
      ans += ba-1;
    }
  }
  cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

const int MAXN = 1e5;

char s[MAXN + 1];
char t[MAXN + 1];
map<ll, char>icMap;

int main() {
  int n, m;
  cin >> n >> m;
  ll lcm = (ll)n * m / __gcd(n, m);
  cin >> s >> t;
  for (int i = 0; i < n; i++) icMap[i * (lcm / n) + 1] = s[i];
  for (int i = 0; i < m; i++) {
    if (icMap[i * (lcm / m) + 1] && icMap[i * (lcm / m) + 1] != t[i]) {
      cout << "-1" << endl;
      return 0;
    }
    icMap[i * (lcm / m) + 1] = t[i];
  }
  cout << lcm << endl;
  return 0;
}



Measured memory_bytes: 10752
s=input()
t=input()
 
result = 0
for i in range(len(s)):
  if len(s) < len(t) + i:
    break
  count = 0
  for j in range(len(t)):
    if t[j] == s[i+j]:
      count += 1
      
  result = max(result,count)
print(len(t)-result)

Measured memory_bytes: 8936
#include <algorithm>//min/max/sort(rand-access it)/merge
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <vector>

using namespace std;

typedef unsigned int ui;
typedef unsigned long long ull;

int main(void)
{
    ui n, c, k;
    cin >> n >> c >> k;
    std::vector<ui> t;
    for (size_t i = 0; i < n; ++i) {
        ui temp;
        cin >> temp;
        t.push_back(temp);
    }
    if (c == 1) {
        cout << n << endl;
        return 0;
    }
    sort(t.begin(), t.end());
    ull buses = 0UL;

    ui first_t = t[0];
    ui current_load = 1;
    for (size_t i = 1; i < n; ++i) {
        if (current_load == c || first_t + k < t[i]) {
            ++buses;
            first_t = t[i];
            current_load = 1;
        } else {
            ++current_load;
        }
    }

    cout << ++buses << endl;
    return 0;
}


Measured memory_bytes: 892
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	static void solve(){//Here is the main function
		ArrayList<Long> one = nextLongArray();
		long N = one.get(0);
		long A = one.get(1);
		long B = one.get(2);
		long loop = N / (A + B);
		long output = loop * A;
		long amari = N % (A + B);
		output += Math.min(amari, A);
		myout(output);

	}
	//Method addition frame start



	//Method addition frame end

	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	@SuppressWarnings("unchecked")
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        string s; cin >> s;
        ll k; cin >> k;
        rep(i, s.size()) {
            if(s[i] == 'a') continue;
            ll need = 'z' - s[i] + 1;
            if(k >= need) {
                s[i] = 'a';
                k -= need;
            }
        }
        if(k > 0) {
            k %= 'z' - 'a' + 1;
            int a = s.back() - 'a';
            a = (a + k) % ('z' - 'a' + 1);
            s.back() = a + 'a';
        }
        cout << s << endl;
        
        return 0;
    }
};

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


Measured memory_bytes: 592
#include<stdio.h>
#include<cstdio>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<utility>
#include<queue>
#define pi 3.14159
#define Inf (int)pow(2., 12.)

using namespace std;
typedef std::pair<int, int> mypair;
queue<mypair> qu;
#define M 1000000
 
int odd[M+1], all[M+1];
 
void update(int *ar, int x){
    for(int i = x; i <= M; ++i){
        ar[i] = min(ar[i], ar[i - x] + 1);
    }
}
 
int main(){
	odd[0] = all[0] = 0;
    for(int i = 1; i <= M; ++i){
        odd[i] = all[i] = 10000000;
    }
 
    for(int i = 1; ; ++i){
        int x = i * (i + 1) * (i + 2) / 6;
        if(x > M) break;
        update(all, x);
        if(x % 2 == 1) update(odd, x); 
    }
     
    int n;
    while(1) {
		cin >> n;
		if(n == 0) break;
		cout << all[n] << " " << odd[n] <<endl;
	}
}

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

vector <pair<ll,ll>> factorization(ll n){
  ll m=sqrt(n)+1;
  vector <pair<ll,ll>> a;
  for(int i = 1;i<m;i++){
    pair<ll,ll> p = pair<ll,ll>(i,0);
    if(i!=1)while(n%i==0){n/=i;p.second++;}
    //else {p.second++;}
    if(p.second!=0)a.push_back(p);
    if(i==m-1&&n!=1){a.push_back(pair <ll,ll> (n,1));}
  }
  return a;
}

int main(){
  ll n;
  vector <pair<ll,ll>> a;
  cin >> n;
  a = factorization(n);
  ll cnt=0;
  for(auto& e : a){
    rep(i,e.second){
      ll tmp =pow(e.first,i+1);
      if(n%tmp==0){
	n/=tmp;
	cnt++;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 4076
import math
a, b, x = map(int, input().split())

lim = a * b * (1/2) * a

if x > lim:# x = (1/2) * a**2 * (2b - a* tan(c))
  tan_c = 2 *(b - x/(a**2)) / a
  ans = math.atan(tan_c)
else:# x = (1/2) * a * b**2 / tan(c)
  tan_c = a * (b ** 2) / (2 * x)
  ans = math.atan(tan_c)
  
print(math.degrees(ans))
  
  


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

int main(int argc, char *argv[]){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int e,f;
    e=c/b+1;
    f=a/d+1;
    if(c%b==0) e--;
    if(a%d==0) f--;
    if(f<e) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3588