akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string S[50],T[50];
    int N,M;
    cin >> N >> M;
    for(int i=0;i<N;i++)cin >> S[i];
    for(int i=0;i<M;i++)cin >> T[i];
    int isFalse =0;
    for(int i=0;i<=N-M;i++){
        isFalse = 0;
        for(int j=0;j<=N-M;j++){
            isFalse=0;
            for(int k=0;k<M && isFalse==0;k++){
                for(int m=0;m<M && isFalse==0;m++){
                    if(S[i+k][j+m] != T[k][m])isFalse=1;
                
                }                
            }
            if(isFalse==0){
            cout << "Yes";
            return 0;
            }
        }
        
    }
    cout << "No";
    return 0;
    
}


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

using namespace std;


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

	int n;
	cin >> n;
	vector< string> s(n);
	for (string &x : s) {
		cin >> x;
		sort(begin(x), end(x));
	}

	long long result = 0;
	map< string, int> mp;
	for (int i = 0; i < n; i ++) {
		result += mp[s[i]];
		mp[s[i]] ++;
	}
	cout << result << endl;
}

Measured memory_bytes: 16768
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N;
	cout << N / 3 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mx 100000
#define pb push_back
#define siz(v) v.size();
typedef unsigned long  ull;
typedef long long int lli;
using namespace std;

int main()
{
 	ios_base::sync_with_stdio(0);
 	cin.tie(0); cin.tie(0);
	
	double a;
	 double pi =3.14159;
	cin>>a;
	cout<<fixed<<setprecision(2)<<(2*pi*a)<<"\n";






 return 0;
 }


Measured memory_bytes: 3800
#include <iostream>
using namespace std;
int main(void){
    
    int a,b;
    cin >> a >> b;
    
    if (a == 1 && b == 2 ){
        cout << '3' << endl;
    }
    
    else if (a == 2 && b == 1){
        cout << '3' << endl;
    }
    
    else if (a == 2 && b == 3){
        cout << '1' << endl;
    } 
    
    else if (a == 3 && b == 2){
        cout << '1' << endl;
    }
    
    else cout << '2' << endl;
    
}

 


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int p[7]={2,3,5,7,11,13,17};
int po[7][10];
int Q;
int M[333],X[333];

int ans;

int e[7];

void calc(){

    int val=0;
    map<int,int>mp;
    rep(i,Q){
        bool ok=true;
        int m=M[i];
        rep(j,7){
            int f=0;
            while(m%po[j][f+1]==0)f++;
            if(f>e[j])ok=false;
            m/=po[j][f];
        }

        if(!ok)continue;
        if(m==1)val+=X[i];
        else{
            mp[m]+=X[i];
        }
    }

    for(auto &p:mp)val+=max(0ll,p.se);
    chmax(ans,val);

}

void dfs(int n){
    if(n==7){
        calc();
        return;
    }

    for(int i=0;po[n][i]<=300;i++){
        e[n]=i;
        dfs(n+1);
    }
}

signed main(){
    cin>>Q;
    rep(i,Q){
        cin>>M[i]>>X[i];
    }

    rep(i,7){
        po[i][0]=1;
        for(int j=1;j<10;j++)po[i][j]=po[i][j-1]*p[i];
    }

    dfs(0);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int INF = INT_MAX / 2;

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

    vector<int> dp(n+1, INF);
    dp[n] = 0;
    for(int i=n; i>0; --i){
        for(int a=6; a<=i; a*=6)
            dp[i-a] = min(dp[i-a], dp[i] + 1);
        for(int a=9; a<=i; a*=9)
            dp[i-a] = min(dp[i-a], dp[i] + 1);
    }

    int ans = INF;
    for(int i=0; i<=n; ++i)
        ans = min(ans, dp[i] + i);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<cctype>
#include <string>
#include <algorithm>
using namespace std;

int main(){
string W;
string T;
string END = "END_OF_TEXT";
int count = 0;
cin >> W;

while(1){
cin >> T;

if (T == END) {
  break;
}

//transform(T.begin(), T.end(), T.begin(), tolower);
transform(T.begin(), T.end(), T.begin(), ::tolower);
if(T == W){
  count++;
}
}
cout << count << endl;
return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }


ll a[220000];
int main(){
    ll n,k,ans=0;
    //cin>>n;
    string s;
    cin>>s;
    if(s=="ABC")cout<<"ARC";
    else if(s=="ARC") cout<<"ABC";
    
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main (){
    string S;cin>>S;
    if(S=="SUN")cout<<7<<endl;
    if(S=="MON")cout<<6<<endl;
    if(S=="TUE")cout<<5<<endl;
    if(S=="WED")cout<<4<<endl;
    if(S=="THU")cout<<3<<endl;
    if(S=="FRI")cout<<2<<endl;
    if(S=="SAT")cout<<1<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int n = sc.nextInt();
			double debt = 100000;
			for (int i = 0; i < n; i++) {
				debt *= 1.05;
				debt = Math.ceil(debt/1000) * 1000;
			}
			System.out.println((int)debt);
		}
	}
}

Measured memory_bytes: 17168
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << endl;
#else
#define DBG(X)
#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

void solve()
{
	int n;
	cin >> n;

	vector<int> a(n);
	map<int, int> cnt;

	for(auto& x: a)
		cin >> x;

	int different = 0;

	for(auto& x: a)
	{
		++cnt[x];

		if(cnt[x] == 1)
			++different;
	}

	if(different > 3)
	{
		cout << "No" << endl;
		return;
	}

	for(auto& pr1: cnt)
	{
		for(auto& pr2: cnt)
		{
			auto temp = cnt;
			vector<int> seq(n, NIL);

			seq[0] = pr1.first, seq[1] = pr2.first;

			bool ok = true;

			for(int t = 0; t < 2; ++t)
			{
				if(temp[seq[t]])
					--temp[seq[t]];
				else
					ok = false;
			}

			for(int i = 2; i < n; ++i)
			{
				seq[i] = seq[i - 1] ^ seq[i - 2];

				if(!temp.count(seq[i]))
				{
					ok = false;
					break;
				}

				if(temp[seq[i]])
				{
					--temp[seq[i]];
				}
				else
				{
					ok = false;
					break;
				}
			}

			DBG(seq);

			for(int i = 0; i < n; ++i)
			{
				int prev = (n + i - 1) % n, nxt = (i + 1) % n;

				int r = (seq[prev] ^ seq[i] ^ seq[nxt]);

				if(r)
				{
					ok = false;
					break;
				}
			}

			if(ok)
			{
				cout << "Yes" << endl;
				return;
			}
		}
	}

	cout << "No" << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 4224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp62 {
    class Program {
        static void Main(string[] args) {
            string S = Console.ReadLine();
            int len = S.Length;

            if (S[0] != 'A') {
                Console.WriteLine("WA");
                return;
            }

            int C_counter = 0;

            int C_index = 0;

            for (int i = 2; i < len - 1; i++) {
                if (S[i] == 'C') {
                    C_counter++;
                    C_index = i;
                }
            }

            if (C_counter != 1) {
                Console.WriteLine("WA");
                return;
            }

            for (int i = 1; i < len; i++) {
                if (i == C_index) {
                    continue;
                }
                if (Char.IsUpper(S[i])) {
                    Console.WriteLine("WA");
                    return;
                }

            }

            Console.WriteLine("AC");


        }
    }
}

Measured memory_bytes: 11092
// B - Magic 2
#include <bits/stdc++.h>
using namespace std;
int K;

bool dfs(int i, int r, int g, int b){
	if(i > K) return false;
	if(r < g && g < b) return true;
	return dfs(i+1, r*2, g,   b  )
			|| dfs(i+1, r,   g*2, b  )
			|| dfs(i+1, r,   g,   b*2);
}

int main(){
	int r,g,b; cin>>r>>g>>b>>K;
	cout<< (dfs(0, r, g, b)? "Yes":"No") <<endl;
}


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

int main() {
    string S;
    cin >> S;
    int64_t ans = 0;
    if (S == "RRR") {
        cout << 3 << endl;
    } else if (S.find("RR") != string::npos) {
        cout << 2 << endl;
    } else if (S.find('R') != string::npos) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3628
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 998244353
#define mod MOD
#define sec setprecision
constexpr double eps = 1e-9;
constexpr double PI = 3.141592653589793238462643383279;
ll gcd(ll a, ll b) {
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
int ketasuu(ll h) {
	if (h < 0)return(-(ketasuu(-h)));
	else if (h < 10)return(1);
	else return(1 + ketasuu(h / 10));
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
vector<ll> soinnsuubunnkai(ll n) {
	vector<ll>a;
	while (n % 2 == 0) {
		a.push_back(2);
		n /= 2;
	}
	ll f = 3;
	while (f * f <= n) {
		if (n % f == 0) {
			a.push_back(f);
			n /= f;
		}
		else f += 2;
	}
	if (n != 1)
		a.push_back(n);
	return(a);
}
// 二項係数計算
long long com(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll pow(ll a, ll b) {
	a = a % mod;
	if (b == 0)return(1);
	else if (b % 2 == 0)return(pow((a * a) % mod, b / 2));
	else return(a * (pow(a, b - 1)));
}
void solve() {
	string s;
	cin >> s;
	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])cout << "Bad" << endl;
	else cout << "Good" << endl;
}
int main() {
	solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;
#define nl endl

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f

vi prime;
//void seive(ll N){for(int i=2;i<=N;i++){if(mark[i]==false){prime.pb(i);for(int j=i+i;j<N;j+=i)mark[j]=true;}}}
//freopen("input.txt", "r", stdin);

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   int n,k;
   cin>>n>>k;
   vll v(n+3),vv(n+3);
   for(int i=1;i<=n;i++) cin>>v[i];

   for(int i=1;i<=k&&i<=n;i++) vv[i]=abs(v[1]-v[i]);
   for(int i=k+1;i<=n;i++) vv[i]=1000000000;


   for(int i=k+1;i<=n;i++){
        int kk=k,ii=1;
       // cout<<"i "<<i<<endl;
   while(kk&&ii<i)
   {
       //if(i==5) cout<<"ii "<<ii<<endl;
        vv[i]=min(vv[i-ii]+abs(v[i]-v[i-ii]), vv[i]);
        kk--;ii++;
   }
}

//for(int i=1;i<=n;i++) cout<<vv[i]<< " ";
   cout<<vv[n]<<endl;
   return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <deque>
#include <iomanip>


using namespace std;


typedef long long ll;


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

  int A, B;
  cin >> A >> B;

  cout << max(max(A+A-1, B+B-1), A+B);


  return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class 	Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final long[] cities = new long[n + 1];
        final long[] braves = new long[n];

        for (int i = 0; i < n + 1; i++) {
            cities[i] = scanner.nextInt();
        }

        for (int i = 0; i < n; i++) {
            braves[i] = scanner.nextInt();
        }

        long result = 0;
        for (int i = 0; i < n; i++) {
            if (braves[i] > cities[i]) {
                result += cities[i];
                final long rest = braves[i] - cities[i];
                if (rest > cities[i + 1]) {
                    result += cities[i + 1];
                    cities[i + 1] = 0;
                } else {
                    cities[i + 1] -= rest;
                    result += rest;
                }
            } else {
                result += braves[i];
            }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 89656
N=int(input())
A = list(map(int,input().split()))
mod = 10**9+7
Ans = 0
for i in range(60):
  Po=sum([1 for j in A if j>>i & 1])
  Ans += Po*(N-Po)*(2**i)
  Ans = Ans % mod
print(Ans)

Measured memory_bytes: 42156
#include <iostream>
int main(){
   char S[4];
   int a = 0;
   
   std::cin >> S;
   for(int i = 0; i<4; i++){
		if(S[i] == '+'){
			a++;
		}
 		else{
			a--;
		}
   }
	std::cout << a;
}

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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////

const int N = 5e3 + 5;

int P[N], C[N][N], M[N][N];
ll DP[N][N];
// C[i][j] : # k : i <= k <= j && A[i] > A[k] 
// M[i][j] : index maximum A[k] <= j && k <= i
// DP[i][j] : answer for first i element and numbers less than j
int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));

	int n, A, B; cin >> n >> A >> B;
	for (int i = 1; i <= n; i++) cin >> P[i];
	for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) C[i][j] = C[i][j - 1] + (P[i] > P[j]);
	for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) M[i][j] = (P[i] <= j && P[i] > P[M[i - 1][j]]) ?  i : M[i - 1][j];
	for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) {
		if (!M[i][j]) continue;
		DP[i][j] = min(A + DP[i][P[M[i][j]] - 1], DP[M[i][j] - 1][j] + 1LL * C[M[i][j]][i] * B);
	}
	cout << DP[n][n] << endl;

	return 0;
}


Measured memory_bytes: 391424
#include <iostream>
#include <cmath>
#include <cstdio>
//#include <fstream>

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.tr", "r", stdin );

	double q;

	while (cin >> q &&  q != -1.0 ){
		double x = q/2.;
		while (fabs (x*x*x - q) >= 0.00001*q  ){
			double y = (x*x*x - q )/(3.*x*x );
			x = x - y;
		} // end while
		printf ("%.6f\n", x );
	} // end loop
		
	return 0;
}

Measured memory_bytes: 3096
n,k=map(int,input().split())
s=input()
u=s+s[::-1]
t=min(u[i:i+n]for i in range(n+1))
h=t[0]
i=min(i for i in range(n)if t[i]!=h)
j=i<<min(k-1,13)
print((h*j+t[i:i+n-j])[:n])

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

int main()
{
    int n;
    cin>>n;
    int h[n+4],dp[n+4];
    for(int i=0; i<n; i++)
        cin>>h[i];
    for(int i=0; i<n; i++)
        dp[i]=INT_MAX;
    dp[0]=0;
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<=i+2; j++){
                if(j<n)
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
        }
    }
    /*for(int i=0;i<n;i++)
        cout<<dp[i]<<" ";
    cout<<endl;*/
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
//const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};


void solve(int ca){
    int a,b,c,d,e;
    int x[5];
    string s,t,u;
    for (int i = 0; i < 5; ++i) {
        cin>>x[i];
        if(x[i]==0){
            cout<<i+1<<endl;
            return;
        }
    }

}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

vector<int> v1;
LL dp[100005];

int main(){
	int n,m;
	int i,j,k;
	LL a,b,c;
	LL s=0;
	cin>>n>>m;
	dp[m]=1;
	for(i=0;i<n;i++){
		cin>>a;
		v1.push_back(a);
	}
	sort(v1.rbegin(),v1.rend());
	for(i=0;i<n;i++){
		for(j=0;j<=m;j++){
			if(dp[j]==0)continue;
			a=dp[j],b=j%v1[i];
			dp[b]+=a;
			dp[j]+=a*(n-i-2);
			if(dp[j]>=MAX)dp[j]%=MAX;
			if(dp[b]>=MAX)dp[b]%=MAX;
			if(i==n-1 && j%v1[i]<j)dp[j]=0;
		}
	}
	for(i=0;i<m;i++){
		if(dp[i]==0)continue;
		s+=dp[i]*i;
		if(s>=MAX)s%=MAX;
	}
	cout<<s<<endl;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>

int main() {
    int n, x[105], y[105];
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &x[i]);
    for (int i = 0; i < n; i++)
        scanf("%d", &y[i]);
    for (int i = 1; i <= 3; i++) {
        double tt = 0;
        for (int j = 0; j < n; j++) {
            tt += pow(abs(x[j] - y[j]), i);
            // printf("%d ", tt);
        }
        printf("%.6lf\n", pow(tt, 1.00 / i));
    }
    int mx = 0;
    for (int i = 0; i < n; i++) {
        if (mx < abs(x[i] - y[i]))
            mx = abs(x[i] - y[i]);
    }
    printf("%d\n", mx);
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,x,ans=0;
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++)
    {
        for(int j=0;j<=b;j++)
        {
            for(int z=0;z<=c;z++)
            {
                if(i*500+j*100+z*50==x)
                    ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10
int func_judge(int number);
main()
{
	int n = 0, counter = 0;
	while(scanf("%d", &n) != EOF)
	{
		counter = func_judge(n);
		printf("%d\n", counter);
	}
	return 0;
}
int func_judge(int number)
{
	int a = 0, b = 0, c = 0, d = 0;
	int counter_in_func = 0;
	for(a = 0; a < MAX; a++)
	{
		for(b = 0; b < MAX; b++)
		{
			for(c = 0; c < MAX; c++)
			{
				for(d = 0; d < MAX; d++)
				{
					if((a + b + c + d) == number)
					{
						counter_in_func++;
						break;
					}
				}
			}
		}
	}
	return counter_in_func;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<ll>>;
ll inf = pow(2, 62);

int main(){
    ll n;cin >> n;
    vec L(n);
    rep(i,n){
        cin >> L[i];
    }
    if(n == 1 || n == 2){
        cout << 0 << endl;
    }
    else{
        ll ans = 0;
        sort(L.begin(),L.end());
        for(int i = 0;i < n-2;i++){
            for(int j = i + 1;j < n-1;j++){
                for(int k = j + 1;k < n;k++){
                    if(L[i] == L[j] || L[j] == L[k]){
                        continue;
                    }else{
                        if(abs(L[i] - L[j]) < L[k] && L[k] < L[i] + L[j]){
                            ans++;
                        }
                        else{
                            continue;
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

bool isp[10000000];

int main(){
	vector<int> qprime;
	isp[2] = true;
	for(int i = 3; i < 10000000; i+=2) isp[i] = true;
	for(int i = 3; i < 10000000; i+=2){
		if(isp[i]){
			if(i > 8 && isp[i-2]&&isp[i-6]&&isp[i-8]) qprime.push_back(i);
			for(int j = i*2; j < 10000000; j += i) isp[j] = false; 
		}
	}

	int n;
	while(cin >> n, n){
		int ans = -1;
		for(int i = 0; i < qprime.size(); i++){
			if(qprime[i] > n) break;
			ans = qprime[i];
		}
		cout << ans << endl;
	}


	return 0;
}

Measured memory_bytes: 10988
N = int(input())
N_ = str(N)
f_N, l_N = int(N_[0]), int(N_[-1])
digit = len(N_)
if digit > 2:
    inter_N = int(N_[1:digit-1])
cnt = 0
for num in range(1, N+1):
    num = str(num)
    f, l = int(num[-1]), int(num[0])
    if f == 0:
        continue
    for i in range(1, digit+1):
        if i == 1:
            if f == l:
                cnt += 1
            else:
                continue
        else:
            if i != digit:
                cnt += 10**(i-2)
            elif digit == 2 and i == digit:
                if f*10+l <= N:
                    cnt += 1
                else:
                    continue
            else:
                if f > f_N:
                    continue
                elif f == f_N:
                    if l > l_N:
                        cnt += inter_N
                    elif l <= l_N:
                        cnt += (inter_N+1)
                else:
                    cnt += 10**(i-2)
print(cnt)

Measured memory_bytes: 41964
#include <stdio.h>

int main(void){
	int i,j,k;
	int hist[10];
	int a,b;
	int c;
	int n = 0;
	while(1){
		c = getchar();
		if(c == '\n'){break;}
		n = n * 10 + (c -'0');
	}
	for(k = 0; k < n; k++){
		for(i = 0; i < 10; i++){
			hist[i] = 0;
		}
		while(1){
			c = getchar();
			if(c == '\n'){break;}
			hist[c-'0']++;
		}
		a = 0;
		b = 0;
		for(j = 9; j >= 0; j--){
			for(i = 0; i < hist[j]; i++){
				a = a * 10 + j;
			}
		}
		for(j = 1; j <= 9; j++){
			for(i = 0; i < hist[j]; i++){
				b = b * 10 + j;
			}
		}
		printf("%d\n",a-b);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;

const int N=1000005;
int n,l,a[N][2],cnt;
pair<int,int> p[N],q[N];
char s[N];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s+1),l=strlen(s+1);
		for(int j=1;j<=l;j++)
		{
			if(s[j]=='(') a[i][0]++;
			else if(a[i][0]) a[i][0]--;
			else a[i][1]++;
		}
		if(a[i][0]>=a[i][1]) p[++a[0][0]].fi=a[i][1],p[a[0][0]].se=a[i][0];
		else q[++a[0][1]].fi=-a[i][0],q[a[0][1]].se=a[i][1];
	}
	sort(p+1,p+a[0][0]+1),sort(q+1,q+a[0][1]+1);
	for(int i=1;i<=a[0][0];i++) 
	{
		if(cnt<p[i].fi)
		{
			printf("No\n");
			return 0;
		}
		cnt-=p[i].fi,cnt+=p[i].se;
	}
	for(int i=1;i<=a[0][1];i++)
	{
		if(cnt<q[i].se)
		{
			printf("No\n");
			return 0;
		}
		cnt-=q[i].se,cnt-=q[i].fi;
	}
	if(cnt==0) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 19240
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define D(x) cerr << #x << " is " << (x) << "\n";

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}

int main()
{
	int n;
	scanf("%i",&n);
	int a,b;
	scanf("%i %i",&a,&b);
	vector<int> p(3);
	for(int i=0;i<n;i++)
    {
        int t;
        scanf("%i",&t);
        if(t<=a)
            p[0]++;
        else
            if(t<=b)
                p[1]++;
            else
                p[2]++;
    }
    printf("%i\n",min(p[0],min(p[1],p[2])));
    return 0;
}


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

int main() {
    int n,m,x;
    cin>>n>>m>>x;
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));
    for(int i=0; i<n; i++) {
        cin>>c[i];
        for(int j=0; j<m; j++) {
            cin>>a[i][j];
        }
    }
    int ans = 1e9;
    for(int s=0; s < 1<<n; s++) {
        int sum = 0;
        vector<int> d(m);
        for(int i=0; i<n; i++) {
            if(s>>i&1) {
                sum += c[i];
                for(int j=0; j<m; j++) d[j] += a[i][j];
            }
        }
        bool flag = true;
        for(int j=0; j<m; j++) {
            if(d[j] < x) flag = false;
        }
        if(flag) ans = min(ans,sum);
    }
    if(ans == 1e9) cout<<-1<<"\n";
    else cout<<ans<<"\n";
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int N = sc.nextInt();

        System.out.println(solve2(N));
    }

    private static long solve2(int N) {
        long count = 0;

        int[][] list = new int[10][10];
        for (int i=1; i<=N; i++) {
            int top = String.valueOf(i).charAt(0) - '0';
            list[top][i%10]++;
        }

        for (int a=0; a<10; a++) {
            for (int b=0; b<10; b++) {
                count += list[a][b]*list[b][a];
            }
        }

        return count;
    }
}

Measured memory_bytes: 32596
#include <stdio.h>

int main(void) {
	int A[5];
	int i, j;
	scanf("%d %d %d %d %d\n", &A[0], &A[1], &A[2], &A[3], &A[4]);
	
	void swap(int a, int b) {
		int t;
		t = A[a];
		A[a] = A[b];
		A[b] = t;
	}
	
	for(i=0;i<4;i++) {
		for(j=i+1;j<5;j++) {
			if(A[i] < A[j]) {
				swap(i, j);
			}
		}
	}
	
	printf("%d %d %d %d %d\n", A[0], A[1], A[2], A[3], A[4]);
	return 0;
}

Measured memory_bytes: 600
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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<_>>()
    };

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"100"# => "111",
r#"111"# => "111",
r#"121"# => "222",
r#"998"# => "999",
r#"999"# => "999",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
    }
    let x = 111;
    let mut ans = 0;

    for i in 1..10 {
        if n <= x * i {
            ans = x * i;
            break;
        }
    }

    ans.to_string()
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <stdio.h>

using namespace std;

int bubbleSort(int A[],int N){
    int sw = 0;
    bool flag = 1;
    for (int i=0;flag;i++){
        flag = 0;
        for (int j=N-1;j>=i+1;j--){
            if(A[j]<A[j-1]){
                swap(A[j],A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main (){
    int A[100],N,sw;
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];

    sw = bubbleSort(A,N);

    for(int i=0;i<N;i++){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;
    
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;
  int count = 1;
  for(int i = 0;i<N-1;i++){
    if(s.at(i) != s.at(i+1)){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 512
// ==============================================
// Library
// ==============================================
#define _CRT_SECURE_NO_WARNINGS

// When you are using the gcc compiler, you need only the following lines.
// #include <bits/stdc++.h>

// When you are using other compilers, you need the following line instead.
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

// If you use this function, "cin" speeds up.
// However, you can not mix "cin" and "scanf", "cout" and "printf".
void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ==============================================
// ==============================================

int main()
{
	fastIOS();

	int n, k, x, y;
	cin >> n;
	cin >> k;
	cin >> x;
	cin >> y;

	int fee = 0;
	if (n <= k)
		fee += (n * x);
	else
	{
		fee += k * x;
		fee += (n - k) * y;
	}

	cout << fee << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    string S; cin >> S;
    int idx;
    for(idx = 0;; ++idx){
        if(S[idx] != 'R') break;
        if(idx == N){
            cout << 0 << endl;
            return 0;
        }
    }
    int cntR = 0, ret = 0;
    for(int i = idx; i < N; ++i) if(S[i] == 'R') cntR++;
    if(cntR == 0){
        cout << 0 << endl;
        return 0;
    }
    for(int i = idx; i < N; ++i){
        if(S[i] == 'R') cntR--;
        if(S[i] == 'W'){
            cntR--;
            ret++;
        }
        if(cntR == 0) break;
    }
    cout << ret << '\n';
    return 0;
}

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

#define mod 1000000007
#define LOCAL 0
#define pb push_back
#define ll long long

ll po(ll a,ll b){
	ll x = 1,y=a;
	while(b>0){
		if(b%2){
			x = x*y;
			x %= mod;
		}
		y=y*y;
		y%=mod;
		b/=2;
	}
	return x;
}

int main(){
	if(LOCAL){
    	freopen("C:/Users/gold/Desktop/sublime IO/input.txt","r",stdin);
    	freopen("C:/Users/gold/Desktop/sublime IO/output.txt","w",stdout);
	}
	int T = 1;
	//scanf("%d",&T);
	while(T--){
		int n;
		scanf("%d",&n);
		long long ans = 1;
		for(int i=0;i<n;i++){
			long long x;
			scanf("%lld",&x);
			long long y = __gcd(ans,x);
			ans = ans *(x/y);
		}
		printf("%lld\n",ans);
	}
	return 0;	
}

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

using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<int>> v(N);
  for(int i = 0; i < N-1; i++){
    int tmp1,tmp2;
    cin >> tmp1 >> tmp2;
    v.at(tmp1-1).push_back(tmp2-1);
    v.at(tmp2-1).push_back(tmp1-1);
  }
  
  map<int,int> m;
  for(int i = 0; i < M; i++){
    int tmp1,tmp2;
    cin >> tmp1 >> tmp2;
    if(m.count(tmp1-1) == 0){
      m[tmp1-1] = tmp2;
    } else { 
      m[tmp1-1] += tmp2;
    }
  }
  
  queue<int> q;
  q.push(0);
  map<int,bool> flg; // 到達済
  flg[0] = true;
  map<int,int> ans;
  
  for(int i = 0; i < N; i++){
    ans[i] = 0;
  }
  
  while(!q.empty()){
    int now = q.front();
    flg[now] = true;
    q.pop();
    ans[now] += m[now]; // 入力を足す
    for(auto x: v.at(now)){
      if(flg.count(x) == 0){
      	q.push(x);
        flg[x] = true;
      	ans[x] += ans[now]; // 1つ下に伝搬させる
      }
    }
  }
  
  for(int i = 0; i < ans.size(); i++){
    if(i == ans.size() -1){
      cout << ans[i] << endl;
    } else { 
      cout << ans[i] << " ";
    }
  }
  
}

Measured memory_bytes: 42228
#include<bits/stdc++.h>
using namespace std;
string a,b;
int ans=1000;
int main(){
    cin>>a>>b;
    for(int i=0;i<a.size();i++){
    	int k=0;
		for(int j=0;j<b.size();j++){
			if(a[i+j]!=b[j])
			k++;
		}
		if(ans>k)
		ans=k;
		if(i+b.size()>=a.size())
		break;
	}
	cout<<ans;
	return 0;
}

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

int n,tot=1,a[200005];

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
	for (int i=1;i<=n;i++)
	{
		if (a[i]==0)  return cout<<0<<endl,0;
	}
	for (int i=1;i<=n;i++)
	{
		if (tot>inf/a[i])  return cout<<-1<<endl,0;
		tot*=a[i];
	}
	cout<<tot<<endl;
	
	return 0;
}

Measured memory_bytes: 4400
mod utils {
    use std::error::Error;
    use std::io::stdin;
    use std::str::FromStr;

    #[allow(dead_code)]
    pub fn read_line<T>() -> Result<Vec<T>, Box<Error>>
    where
        T: FromStr,
        T::Err: 'static + Error,
    {
        let mut line = String::new();
        let _ = stdin().read_line(&mut line)?;
        let parsed_line = line.split_whitespace()
            .map(|x| x.parse::<T>())
            .collect::<Result<Vec<T>, T::Err>>()?;

        Ok(parsed_line)
    }

    #[allow(dead_code)]
    pub fn read_lines<T>(n: usize) -> Result<Vec<Vec<T>>, Box<Error>>
    where
        T: FromStr,
        T::Err: 'static + Error,
    {
        (0..n).map(|_| read_line()).collect()
    }
}

use std::cmp::min;
fn solve() -> Result<(), Box<std::error::Error>> {
    let header = utils::read_line::<usize>()?;
    let height = header[0];
    let width = header[1];
    let matrix = utils::read_lines::<usize>(height)?;

    let mut dp = matrix
        .iter()
        .map(|row| row.iter().map(|x| 1 - x).collect::<Vec<_>>())
        .collect::<Vec<_>>();

    for i in 1..height {
        for j in 1..width {
            if dp[i][j] != 0 {
                let minimum_neighbors = min(min(dp[i - 1][j - 1], dp[i][j - 1]), dp[i - 1][j]);
                dp[i][j] = minimum_neighbors + 1;
            }
        }
    }

    let l = dp.iter()
        .map(|row| row.iter().max().unwrap())
        .max()
        .unwrap();

    // println!("{:?}", dp);
    println!("{}", l * l);

    Ok(())
}

fn main() {
    match solve() {
        Err(err) => panic!("{}", err),
        _ => (),
    };
}



Measured memory_bytes: 50100
def gcd(a,b):
    while b != 0:
        a,b = b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

N = int(input())
a = list(map(int,input().split()))
f = a[0]

for i in range(1,N):
    f = lcm(f,a[i])

print(f)


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

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

	int n;
	cin >> n;
	int big = 0, big2 = 0;
	vector<int> x(n);
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a > big) {
			big2 = big;
			big = a;
		}
		else if (a > big2) {
			big2 = a;
		}
		x[i] = a;
	}

	for (int i = 0; i < n; i++) {
		if (x[i] == big) cout << big2 << endl;
		else cout << big << endl;
	}
}


Measured memory_bytes: 2432
#include <stdio.h>
int main(void){
    // Your code here!
    int i,sum;
    char number[1001];
    
    while(1){
        scanf("%s",&number);
        if(number[0]=='0') break;
        sum=0;
        for(i=0;number[i]!='\0';i++){
            sum+=number[i]-'0';
        }
        printf("%d\n",sum);
    }
    return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main() {
    char c;
    cin >> c;
    if(c-'a' < 0) cout << 'A' << endl;
    else cout << 'a' << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
    int a, b, c, n, m, l, r;
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int a, x[9], b, c, n;
int main() {
	cin >> n;
	for (int h = 0; h < n;h++){
		cin >> a;
		for (int i = 7; i >= 0; i--) {
			x[i] = (a / (int)pow(10, i)) % 10;
		}
		sort(x, x + 8); b = 0; c = 0;
		for (int i = 0; i < 8; i++) {
			b += x[i] * (int)pow(10, i);
			c += x[7 - i] * (int)pow(10, i);
		}
		cout << b - c << endl;
	}
}

Measured memory_bytes: 1220
int_x1, int_y1, int_x2, int_y2 = map(int, input().split())

int_x3 = int_y3 = int_x4 = int_y4 = 0

int_x = int_x2 - int_x1
int_y = int_y2 - int_y1

print(int_x2 - int_y, int_y2 + int_x, int_x1 - int_y, int_y1 + int_x)



Measured memory_bytes: 2940
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <climits>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define MAX 100000000

class Path{
public:
    int a, b, c;
};

int main(){
    int n, m;
    cin >> n >> m;
    vector< vector<int> > g(n);
    vector<Path> p(m);
    repi(i, g){
        *i = vector<int>(n, MAX);
    }
    
    rep(i, n){
        g[i][i] = 0;
    }
    
    for(int i = 0; i < m; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        g[a][b] = g[b][a] = c;
        Path pa;
        pa.a = a;
        pa.b = b;
        pa.c = c;
        p[i] = pa;
    }
    
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            for(int k = 0; k < n; ++k){
                g[j][k] = min(g[j][k], g[j][i] + g[i][k]);
            }
        }
    }
    
    int ret = 0;
    repi(i, p){
        //cout << (*i).a << " " << (*i).b << endl;
        bool flag = true;
        rep(j, n){
            if(g[(*i).a][j] == (*i).c + g[(*i).b][j]){
                flag = false;
                break;
            }
        }
        if(flag){
            ++ret;
        }
    }
    /*
    for_each(g.begin(), g.end(), [](vector<int> a){ 
        for_each(a.begin(), a.end(), [](int b){
            cout << b << " ";
        });
        cout << endl;
    });
    */
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 256
from math import gcd
k = int(input())
うんち = 0
for でびさま in range(1,k+1):
    for でびでび in range(1,k+1):
        for でびる in range(1,k+1):
            うんち += gcd(でびさま,gcd(でびでび,でびる))
print(うんち)

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

int n,m,par[100010],rnk[100010];
ll size[100010];

int find(int a){
    if(par[a]!=a){
        return par[a]=find(par[a]);
    }
    return a;
}

void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)return;
    if(rnk[a]<rnk[b]){
        par[a]=b;
        size[b]+=size[a];
    }else{
        par[b]=a;
        size[a]+=size[b];
        if(rnk[a]==rnk[b])rnk[a]++;
    }
}

int main(){
    int a[100010],b[100010];
    cin>>n>>m;
    for(int i=0;i<n;i++){
        par[i]=i;
        size[i]=1;
        rnk[i]=1;
    }
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
    }
    ll ans[100010];
    ans[m-1]=(ll)n*(n-1)/2;
    for(int i=m-1;i>=1;i--){
        if(find(a[i])!=find(b[i])){
            ans[i-1]=ans[i]-size[find(a[i])]*size[find(b[i])];
        }else{
            ans[i-1]=ans[i];
        }
        unite(a[i],b[i]);
    }
    for(int i=0;i<m;i++){
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 4480
// C - Guess The Number
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(int)(n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> p(m);
    rep(i, m) cin >>p[i].first >> p[i].second;
    rep(i, 1000){
        int keta = 1;
        int ni = i/10;
        vector<int> d(1, i%10);
        while(ni){
            keta++;
            d.push_back(ni%10);
            ni /= 10;
        }
        if(keta != n) continue;
        bool ok = true;
        reverse(d.begin(), d.end());
        rep(i, m){
            if(d[p[i].first-1] != p[i].second) ok = false;
        }
        if(ok){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3600