akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int n; cin >> n;
	vi x(n);
	vi y(n);
	REP(i, n) cin >> x[i];
	REP(i, n) cin >> y[i];
	int ans1 = 0;
	REP(i, n) {
		ans1 += abs(x[i] - y[i]);
	}
	cout << ans1 << endl;
	double ans2 = 0;
	REP(i, n) {
		ans2 += pow(x[i] - y[i], 2);
	}
	ans2 = sqrt(ans2);
	cout << ans2 << endl;
	double ans3 = 0;
	REP(i, n) {
		ans3 += pow(abs(x[i] - y[i]), 3);
	}
	ans3 = pow(ans3, (double)1 / (double)3);
	cout << ans3 << endl;
	int ans4 = -1;
	REP(i, n) {
		ans4 = max(ans4, abs(x[i] - y[i]));
	}
	cout << ans4 << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



Measured memory_bytes: 3500
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();

		if(N % 500 == 0) 
			System.out.println("Yes");
		else {
			N = N % 500;
			if(N < A) 
				System.out.println("Yes");
			else
				System.out.println("No");
		}

		sc.close();
	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
int n, m, q, ans = 0;
int a[60], b[60], c[60], d[60];
int A[60];
void dfs(int idx) {
  if (idx > n) {
    int sum = 0;
    for (int i = 1; i <= q; i++) {
      if (A[b[i]] - A[a[i]] == c[i]) {
        sum += d[i];
      }
    }
    ans = max(ans, sum);
    return;
  }
  for (int i = A[idx - 1]; i <= m; i++) {
    A[idx] = i;
    dfs(idx + 1);
  }
}
int main() {
  cin >> n >> m >> q;
  for (int i = 1; i <= q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  A[0] = 1;
  dfs(1);
  cout << ans << endl;
}


Measured memory_bytes: 3672
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

ll gcd(ll a,ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}

int main(void){
	          ll i,j;

	      	  cin.tie(0);  ios_base::sync_with_stdio(false);

	      	  ll N;
	      	  cin >> N;

	      	  if(N==2){
	      		  cout << 1 << ' ' << 2 << ' ' << 2 << endl;
	      		  return 0;
	      	  }
	      	  if(N==3){
	      		  cout << 1 << ' ' << 6 << ' ' << 6 << endl;
	      		  return 0;
	      	  }
	      	  if(N==4){
	      		  cout << 3 << ' ' << 3 << ' ' << 3 << endl;
	      		  return 0;
	      	  }

	      	  for(i=1;i<=3500;i++){
	      		  for(j=i;j<=3500;j++){
	      			  ll x=4*i*j-N*j-N*i;
	      			  ll y=N*i*j;
	      			  if(x>0){
	      				  ll g=gcd(x,y);
	      				  if(x==g){
	      					  cout << i << ' ' << j << ' ' << y/g << endl;
	      					  return 0;
	      				  }
	      			  }
	      		  }
	      	  }




	          return 0;
}



Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int count = 0;
        int result = 0;
        for (int i = 1; i <= N; i += 2) {
            for (int j = 1; j <= i; j++) {
                if (i % j == 0) {
                    count++;
                }
            }
            if (count == 8) {
                result++;
            }
            count = 0;
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(result);
        out.flush();
        sc.close();
    }
}

Measured memory_bytes: 35704
def two_count(num):
    count = 0
    while num % 2 == 0:
        count += 1
        num //= 2
    return count

n = int(input())

n_two_count = [two_count(n_i) for n_i in range(1, n+1)]
print(n_two_count.index(max(n_two_count))+1)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

ll s;

int main() {
    cin >> s;
    ll x = 1;
    x = max((ll)sqrt(s) - 10, 1LL);
    while (x*x < s) x++;
    ll y = 1;
    y = max(s/x - 10, 1LL);
    while (x*y < s) y++;
    ll d = x*y-s;
    cout << 0 << " " << 0 << " " << x << " " << 1 << " " << d << " " << y << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
          if(n/i==i)
            c++;
          else
            c+=2;
        }

    }

    
    return  c;
}
int func(int n)
{
    return (n*(n+1))/2;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   
     
  int a,b,c;
  cin>>a>>b>>c;
  int h=c%b;
  for(int i=1;i<=b;i++)
  {
    if((a*i)%b==h)
    {
        cout<<"YES";
        return 0;
    }
  }
  cout<<"NO";




 return 0;
}








Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

string s, t;

int main()
{
    cin>>s>>t;
    for(ll i = 0; i < s.size(); i++)
    {
        if(t[i] != s[i])
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 3592
N = int(input())
c = input()

count = 0
if not(c.find('R') == -1 or c.find('W') == -1):
    idx_W = -1
    idx_R = -1
    while True:
        idx_W = c.find('W')
        idx_R = c.rfind('R')
        if idx_W >= idx_R:
            break
        c = c[:idx_W] + 'R' + c[idx_W+1:idx_R] + 'W' + c[idx_R+1:]
        count += 1
print(count)

Measured memory_bytes: 9920
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}


int main(){
    int N; cin >> N;
    vector<string> s(0);

    
    map<string,long long> mp;
    for(int i = 0; i < N; i++){
        string t; cin >> t;
        sort(t.begin(),t.end());
        s.push_back(t);
    }
    long long ans = 0;
    sort(s.begin(),s.end());
    for(int i = 1; i < N; i++){
        if (s[i-1] == s[i]) mp[s[i]]++;
    }
    for(int i = 1; i < N; i++){
        if (mp[s[i]] > 0){
            //cout << "mp[s[i] = " << mp[s[i]] << s[i] << endl;
            ans += mp[s[i]]*(mp[s[i]]+1)/2;
            mp[s[i]] = 0;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 12020
#include <iostream>
using namespace std;
int main(void) {
	int i;
	char wta[100];
	cin >> wta;
	if (wta[0] == 'S')
		cout << "Cloudy" << endl;
	else if (wta[0] == 'C')
		cout << "Rainy" << endl;
	else if(wta[0] == 'R')
		cout << "Sunny" << endl;
	return 0;
}

Measured memory_bytes: 256
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 47576
ABC = list(map(int, input().split()))

ans = 0
samenum = 0
for i in range(3):
    num = (max(ABC) - ABC[i]) // 2
    ABC[i] += num * 2
    ans += num
    if ABC[i] == max(ABC):
        samenum += 1

if samenum == 2:
    ans += 2
elif samenum == 1:
    ans += 1

print(ans)


Measured memory_bytes: 3060
/*
 ALLAH is Almighty....
*/
#include <bits/stdc++.h>
using namespace std;

#define pi                            acos(-1.0)
#define fastio                        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout << setprecision(12)
#define rep(i,a,n)                    for (ll i=a;i<n;i++)
#define per(i,a,n)                    for (ll i=n-1;i>=a;i--)
#define pb                            push_back
#define all(x)                        (x).begin(),(x).end()
#define fi                            first
#define se                            second
#define SZ(x)                         ((ll)(x).size())
#define cin1(x)                       cin >> x
#define cin2(x, y)                    cin >> x >> y
#define cin3(x, y, z)                 cin >> x >> y >> z
#define cin4(x, y, z, _)              cin >> x >> y >> z >> _
#define cin5(x, y, z, p, q)           cin >> x >> y >> z >> p >> q
#define cin6(x, y, z, p, q, r)        cin >> x >> y >> z >> p >> q >> r
#define cou(x)                        cout << x
#define cous(x)                       cout << x << " "
#define coul(x)                       cout << x << "\n"
#define ret(x)                        return x
#define MAX                           1000007
#define start                         int main() {   fastio
#define finish                        ret(0); }
#define Test                          ll _t; cin1(_t); rep(w, 0, _t)
#define fans(x)                       if ( x  ) coul("YES");  else coul("NO")


typedef long long ll;
const ll mod=1000000007;
const ll mx = 3e5 + 7;
const double eps = 1e-7;

// head collected
// Don't use variable name as --> prev, time, _t, w, y1
// Don't use ceil and pow function


ll n, a, b, _, ans, c, _1, _2, m, an, k, need, shuru, _3, _c, _a, _b, way, _0, mex, q;
double d;
ll ar[ mx ], co[ mx ];
string st, st1, st2, isGood;
vector < pair < ll, ll > > vs;
map < string, ll > mm;
set < string > ss;
pair < ll, ll > pr;
bool ok;
char ch;
vector <ll> sie;
ll spf[ MAX + 7 ];
ll prime[ MAX ], ultraPrime[ MAX ], sumOfPrimeArray[ MAX ];


ll f( ll i, ll j, ll k )
{
    if ( i == j && j == k )  return 1;
    else if ( i == j || j == k || i == k )  return 3;
    else return 6;
}

void helpPlz( )
{
    cin1( n );

    rep( i, 1, 100 + 1 )
        rep( j, i, 100 + 1 )
            rep( k, j, 100 + 1 ) {
                _ = i * i + j * j + k * k + i * j + i * k + j * k;
                if ( _ <= 1e4 )
                    co[ _ ] += f( i, j, k );
            }

    rep( i, 1, n + 1 )
        coul( co[ i ] );
}


start;         // Md. Inzamam-ul Haque

    helpPlz();


finish






Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> m(n);
    for (int i = 0; i < n; i++) {
        cin >> m.at(i);
        x -= m.at(i);
    }
    sort(m.begin(), m.end());
    cout << n + x / m.at(0) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INFTY 10000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
const int di[4] = {-1,0,1,0};
const int dj[4] = {0,-1,0,1};
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
int main(){
    int n;cin>>n;
    ll k;cin>>k;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++)cin>>a[i];
    vector<int> seen(n+1,0),no(n+1,0);
    ll ans;
    int now=1,cnt1=0;
    int t=0;
    while(true){
        //cout<<now<<endl;
        if(t==k){
            cout<<now;
            return 0;
        }
        if(seen[a[now]]==0){
            cnt1++;
            seen[a[now]]=1;
            no[a[now]] = cnt1;
            now = a[now];

        }
        else{
            //cout<<cnt1<<cnt1<<endl;
            if(now==1){
                ll sc = k%cnt1;
                rep(i,sc){
                    now = a[now];
                }
            }
            else {
                ll sc2 =(k-no[a[now]])%(cnt1-no[a[now]]+1);
                now=a[now];
                rep(i,sc2){
                    now = a[now];
                }
            }
            cout<<now;
            return 0;
        }
        t++;
    }
    return 0;
}

Measured memory_bytes: 5636
#define _CRT_SECURE_NO_WARNINGS
#define MOD 998244353 
#define INF 100000000
//#define MOD 922337203685419LL
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <functional>
#include <algorithm>
#include <iterator>
#include <cstdio>
#include <utility>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <chrono>
#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n-1,-1)
#define ALL(obj) (obj).begin(), (obj).end()

inline ll madd(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a + b) % MOD;
}
inline ll msub(ll a, ll b) {
	a %= MOD;b %= MOD;
	a += MOD;
	return (a - b) % MOD;
}
inline ll mmul(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a*b) % MOD;
}
inline ll mpow(ll a, ll r) {
	long long res = 1;
	while (r > 0) {
		if (r & 1) res = res * a % MOD;
		a = a * a % MOD;
		r >>= 1;
	}
	return res;
}
inline ll minv(ll a) {
	a %= MOD;
	ll b = MOD, u = 0, v = 1;
	while (a) {
		ll t = b / a;
		b -= t * a; swap(a, b);
		u -= t * v; swap(u, v);
	}
	if (u < 0) u += MOD;
	return u;
}
inline ll mdiv(ll a, ll b) {
	a %= MOD;
	a *= minv(b);
	return a%MOD;
}


//ll fact[]
//inline ll combi(int a, int b) {
//	return mmul(fact[a], mmul(fact_inv[b], fact_inv[a - b]));
//}

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int main() {
	string s;
	char c;
	cin >> s;
	deque<char> dq;
	for (auto c : s) dq.push_back(c);
	ll q, qq, a;
	cin >> qq;
	ll rev = 0;
	REP(i, qq) {
		cin >> q;
		if (q == 1) {
			rev++;
		}
		else {
			cin >> a >> c;
			if ((rev + a) % 2) dq.push_front(c);
			else dq.push_back(c);
		}
	}
	if (rev % 2) {
		auto it = dq.rbegin();
		while (it != dq.rend()) {
			cout << *it;
			it++;
		}
	}
	else {
		auto it = dq.begin();
		while (it != dq.end()) {
			cout << *it;
			it++;
		}
	}
	return 0;
}

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

int main()
{
    int n, a[10000],max ,min;
    double sum;
    cin >> n;

    cin >> a[0];
    max = a[0];
    min = a[0];
    sum = a[0];

    for (int i = 1; i < n; i++)
    {
        cin >> a[i];
        if (a[i] > max)
        {
            max = a[i];
        }
        else if (a[i] < min)
        {
            min = a[i];
        }
        sum += a[i];
    }

    cout << min << " " << max  << " " << fixed << setprecision(0) << sum << endl;
    return 0;
}



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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;
int t[22][22];

int mem[1<<18];

int dfs(int S){
	if(S==(1<<n)-1)return 0;
	if(mem[S]!=-1)return mem[S];
	int res=INF;
	rep(i,n){
		if(!((S>>i)&1)){
			int mincost=INF;
			rep(j,n+1){
				if(j==0||((S>>(j-1))&1))minch(mincost,t[i][j]);
			}
			minch(res,mincost+dfs(S|1<<i));
		}
	}
	return mem[S]=res;
}

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n;
		if(n==0)break;
		rep(i,n)rep(j,n+1){
			cin>>t[i][j];
		}
		memset(mem,-1,sizeof(mem));
		cout<<dfs(0)<<endl;
	}
	return 0;
}

Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep4(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vec vector<ll>
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

void solve(ll x, ll y){
    cout<<(x%y==0?-1:x)<<'\n';
}

int main(){
    ll x;
    scanf("%lld",&x);
    ll y;
    scanf("%lld",&y);
    solve(x, y);
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def log(v):
    print(v, file=sys.stderr)


s = sorted(input().strip())
t = sorted(input().strip())
t.reverse()

for i in range(0, max(len(s), len(t))):
    if len(s) <= i:
        print("Yes")
        exit(0)
    if len(t) <= i:
        print("No")
        exit(0)
    if s[i] > t[i]:
        print("No")
        exit(0)
    if s[i] < t[i]:
        print("Yes")
        exit(0)
print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  int n; cin>>n;
  vector<int> p(n);
  vector<int> q(n);
  rep(i, n) cin>>p[i];
  rep(i, n) cin>>q[i];
  vector<int> a(n);
  rep(i, n) a[i] = i+1;

  ll x=0, y=0;
  ll i = 0;
  do {
    if (a == p) x = i;
    if (a == q) y = i;
    i++;
  } while (next_permutation(a.begin(), a.end()));

  cout << abs(x-y) << endl;

  return 0;
}


Measured memory_bytes: 256
import itertools
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
N = [int(i) for i in range(1, n+1)]
l = []
for i in itertools.permutations(N):
    l.append(list(i))
#print(l)
p_num = l.index(p)
q_num = l.index(q)
print(abs(p_num-q_num))

Measured memory_bytes: 47836
/// __Macro's__
#include <bits/stdc++.h>
using namespace std;
#define ll                   long long
#define II                   pair<int,int>
#define III                  pair<int, II>
#define VL                   vector<ll>
#define VI                   vector<int>
#define VII                  vector<II>
#define VIII                 vector<III>
#define VVI                  vector<vector<int>>
#define VVII                 vector<vector<II>>
#define fr                   first
#define sc                   second
#define mkpr                 make_pair
#define PQ                   priority_queue
#define pb                   push_back
#define eb                   emplace_back
#define all(v)               v.begin(), v.end()
#define LINE                 putc('\n', stdout)
#define SPACE                putc(' ' , stdout)
#define TAB                  putc('\t', stdout)
#define fillarr(arr, val)    fill((int*)arr, (int*)arr+(sizeof(arr)/sizeof(int)), val)
#define Log2(x)              (31^__builtin_clz(x))
#define INF                  1000000007 
#define MOD                  1000000007 
#define getint ReadInt()
const char IO_MODE = 0; // in-->00<--out (MSB-->LSB) | 0: Norm, 1: Fast 
inline ll ReadInt(){ll x=0,s=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')s=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';
c=getchar();}return s*x;}inline void WriteInt(ll x){char c[20];if(!x){putchar('0');return;}if(x<0)putchar('-'),x=-x;int i=0;while(x>0)
c[++i]=x%10,x/=10;while(i)putchar(c[i--]+48);}template <typename T>inline void out(T x){if(IO_MODE&1)WriteInt(x);else if(typeid(x)==typeid(int))
printf("%i", x);else printf("%lld", (ll)x);}template<typename T, typename... Args>inline void out(T x,Args...args){out(x);SPACE;out(args...);}
template <typename T>inline void in(T &x){if(IO_MODE&2) x=ReadInt();else if(typeid(x)==typeid(int))scanf("%i",&x);else if(typeid(x)==typeid(ll))
scanf("%lld",&x);}template<typename T, typename... Args>inline void in(T &x,Args&...args){in(x);in(args...);}
int aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,kk,mm,nn,oo,pp,qq,rr,ss,tt,uu,vv,ww,xx,yy,zz;
int tc;
///
int n;
char s[3030];
int Dp[3030][3030];
int main()
{
  in(n);
  scanf("%s",s+1);
  Dp[0][0]=1;
  for(int i=1 ; i<n ; i++)
  {
    int sum=0;
    if(s[i]=='<')
    {
      for(int j=0 ; j<i ; j++)
        Dp[i-1][j] = sum=(sum + Dp[i-1][j])%MOD;

      for(int j=1 ; j<=i ; j++)
        Dp[i][j] = Dp[i-1][j-1];
    }
    else
    {
      for(int j=i ; j-- ; )
        Dp[i-1][j] = sum=(sum + Dp[i-1][j])%MOD;

      for(int j=i ; j>=0 ; j--)
        Dp[i][j] = Dp[i-1][j];
    }
  }
  cout << accumulate(Dp[n-1], Dp[n-1]+n, 0, [](int a, int b)->int{return (a+b)%MOD;}) << endl;
  return 0;
}

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

def prime_factorization(n):
    dct = {}
    tmp = n
    for i in range(2, int(n**0.5)+1):
        if tmp == 1:
            break
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            dct[i] = cnt
    if tmp != 1:
        dct[tmp] = 1
    if len(dct) == 0:
        dct[n] = 1

    return dct

ap = prime_factorization(A)
bp = prime_factorization(B)
ap[1] = 1
bp[1] = 1

ans = 0
for p in ap:
    if p in bp:
        ans += 1

print(ans)


Measured memory_bytes: 38512
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	long a,b,c,k; cin>>a>>b>>c>>k;
	if(k%2==0) cout<<a-b<<endl;
	else cout<<b-a<<endl;
	return 0;
}


Measured memory_bytes: 256
use std::io::prelude::BufRead;
use std::io::StdinLock;

pub fn read_line(locked_stdin: &mut StdinLock) -> std::io::Result<String> {
    let mut buf = String::new();
    locked_stdin.read_line(&mut buf).map(|_| buf)
}

pub fn read_to_string(locked_stdin: &mut StdinLock) -> std::io::Result<String> {
    read_line(locked_stdin).map(|s| s.trim().to_string())
}

fn main() {
    let s;

    {
        let stdin = std::io::stdin();
        let mut lkin = stdin.lock();
        s = read_to_string(&mut lkin).unwrap();
    }

    let s = s.into_bytes();
    let mut state = s[0];
    println!("{}", s.into_iter().fold(0, |ans, c| if state != c {state = c; ans + 1} else {ans}))
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
signed
main()
{
		ll n,m;
		cin >> n;
		vector<ll> a(n);
		for(int i=0;i<n;i++)
		{
				cin >> a[i];
		}
		sort(a.begin(),a.end());
		cin >> m;
		bool flag = true;
		for(int i=0;i<m;i++)
		{
				ll b;
				cin >> b;
				if(!binary_search(a.begin(),a.end(),b)) flag = false;
		}
		if(flag) cout << 1 << endl;
		else cout << 0 << endl;
}


Measured memory_bytes: 4380
#include <iostream>

using namespace std;

typedef long long ll;

ll n;

ll dfs(ll x, ll a, ll b, ll c) {
    if (x > n)
        return 0;
    
    ll ans = 0;
    if (x <= n && a > 0 && b > 0 && c > 0)
        ans++;
    
    return ans + dfs(x*10 + 3, a+1, b, c) + dfs(x*10 + 5, a, b+1, c) + dfs(x*10 + 7, a, b, c+1);
}

int main() {
    cin >> n;
    

    cout << dfs(0, 0, 0, 0) << endl;

    return 0;
}

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

int main() {
  int n,m;
  cin>>n>>m;
  int a[100005];
  for (int i=0; i<m; i++) {
    cin>>a[i];
  }
  int s[100005][2];
  s[0][0]=1;
  s[0][1]=0;
  int j=0;
  for (int i=1; i<=n; i++) {
    if (a[j]==i) {
      if (j+1<m) j++;
      s[i][0]=0;
      s[i][1]=s[i-1][0];
    }
    else {
      s[i][0]=(s[i-1][0]+s[i-1][1])%1000000007;
      s[i][1]=s[i-1][0];
    }
  }
  
  cout<<s[n][0]<<endl;
  return 0;
}



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


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

    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    if (b < 0 && d < 0) cout << a*c << endl;
    else if (a >= 0 && c >= 0) cout << b*d << endl;
    else if (a >= 0 && d < 0) cout << a*d << endl;
    else if (b < 0 && c >= 0) cout << b*c << endl;
    else if (a < 0 && b >= 0 && c >= 0) cout << b*d << endl;
    else if (a < 0 && b >= 0 && d < 0) cout << a*c << endl;
    else if (a < 0 && b >= 0 && c < 0 && d >= 0) cout << max(b*d, c*a) << endl;
    else if (c < 0 && d >= 0 && a >= 0) cout << b*d << endl;
    else if (c < 0 && d >= 0 && b < 0) cout << a*c << endl;
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
int main(){
	int n,k;
	cin>>n>>k;
	long long ans=1;
	lp(i,n) ans*=k,ans%=(1000000007);
	cout<<ans<<endl;
	return 0;		
}


Measured memory_bytes: 3100
N = int(input())
X_list = list(map(int, input().split()))

hp_list = []
for p in range(int(min(X_list)), int(max(X_list))):
    hp = 0
    for x in X_list:
        hp += abs(x - p) ** 2
    hp_list.append(hp)

print(min(hp_list) if len(hp_list) > 0 else 0)

Measured memory_bytes: 39280
def main():
    S = list(input())

    tmp_s = S.copy()
    tmp_s.reverse()

    if S == tmp_s:
        tmp = S[: (len(S) - 1) // 2]
        tmp_s = tmp.copy()
        tmp_s.reverse()
        if tmp == tmp_s:
            tmp = S[(len(S) + 3) // 2 - 1 :]
            tmp_s = tmp.copy()
            tmp_s.reverse()
            if tmp == tmp_s:
                print("Yes")
                return
    print("No")


if __name__ == "__main__":
    main()


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

int main() {
  int H, W; cin >> H >> W;
  int N; cin >> N;
  int masu = 0;

  masu = N/max(H, W);
  if(N%max(H, W) != 0) masu++;

  cout << masu << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    int res=n%2? n/2+1:n/2;
    cout<<res<<endl;
}


Measured memory_bytes: 256
from bisect import bisect_left as bl
n,a,b = map(int,input().split())
h = [int(input()) for i in range(n)]
h.sort()
t = a-b
r = 10**9+5
l = 0

while r-l > 1:
    m = (r+l)//2
    mi = m*b
    count = 0
    for i in h:
        if i > mi:
            count += (i-mi+t-1)//t
    if count <= m:
        r = m
    else:
        l = m
print(r)

Measured memory_bytes: 50776
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <set>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;


int main() {
    int X, N;
    cin >> X >> N;
    vi p(N);
    if(N== 0){
        cout << X << endl;
        return 0;
    }

    map<int, int> ma;
    for(int i=-1000; i<=1000; i++){
        ma[i] += 1;
    }
    for(int i=0; i<N; i++){
        cin >> p.at(i);
        ma.erase(p.at(i));
    }

    int ans_min = 1000;
    int ans = 1000;
    for(auto c : ma){
        if(abs(c.first-X) < ans_min){
            ans_min = abs(c.first-X);
            ans = c.first;
        }
    }
    cout << ans << endl;
}


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

int main(){
  ll l, r;
  cin >> l >> r;
  r = min(r, l+4038);
  int ans = 2018;
  for(ll i = l; i <= r;i++){
   	for(ll j = i+1; j <= r;j++){
      int x = i*j%2019;
      ans = min(ans, x);
    }
  }
  cout << ans << endl;  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#define S str[ima]
using namespace std;
map <string,int> mp;
int ima;
string str;

int check(char ch){
  if('A'<=ch && ch<='Z') return 1;
  if('a'<=ch && ch<='z') return 2;
  if('0'<=ch && ch<='9') return 3;
  if(ch == '(') return 4;
  return 5;
}

int formula(){
  int res=0;
  while(S != '\0'){
    int num=0;
    if(check(S) == 1) {
      string a="";
      a+=S;
      ima++;
      while(check(S)==2) a+=S,ima++;
      if(mp.count(a) != 1) return -1;
      while(check(S)==3) num*=10,num+=S-'0',ima++;
      res += (mp[a]*max(1,num));
    }
    else if(check(S)==4){
      ima++;
      int b =formula();
      if(b == -1) return -1;
      ima++;
      while(check(S)==3) num*=10,num+=S-'0',ima++;
      res += (b*max(1,num));
    }
    else break;
  }
  return res;
}

int main(){
  while(1){
    int n;
    cin >> str;
    if(str == "END_OF_FIRST_PART")break;
    cin >> n;
    mp[str] = n;
  }
  while(1){
    cin >> str;
    if(str=="0") break;
    ima = 0;
    int res = formula();
    if(res==-1 || res==0) cout <<"UNKNOWN"<<endl;
    else cout << res <<endl;
  }
  return 0;
}

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

int main()
{
    int n;
    string s;
    string t = "ABC";
    cin >> n >> s;
    int ans = 0;
    while( !s.empty() ){
        if( s.find(t) == -1 ){
            break;
        }
        else if( s.find(t) != -1 ){
            ans++;
            s.erase(s.begin(),s.begin() + (s.find(t)+3) );
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
	char day[256];
	gets(day);
	char *sun = "SUN";
	char *mon = "MON";
	char *tue = "TUE";
	char *wed = "WED";
	char *thu = "THU";
	char *fri = "FRI";
	if(strcmp(day,sun) == 0){
		printf("7");
	}
	else if(strcmp(day,mon) == 0){
		printf("6");
	}
	else if(strcmp(day,tue) == 0){
		printf("5");
	}
	else if(strcmp(day,wed) == 0){
		printf("4");
	}
	else if(strcmp(day,thu) == 0){
		printf("3");
	}
	else if(strcmp(day,fri) == 0){
		printf("2");
	}
	else{
		printf("1");
	}
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

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

	for (int i = 1;; i++) {
		if (i*i == N) {
			cout << i * i << endl;
			break;
		}else if(i*i>N){
			cout << (i - 1)*(i - 1) << endl;
			break;
		}
	}
}

Measured memory_bytes: 256
from operator import mul
from math import factorial
from functools import reduce

def modpow(a, n, mod): # a^n mod
    result = 1
    while n > 0:
        if n & 1: result = result * a % mod
        a = a * a % mod
        n >>= 1
    return result

X, Y = map(int, input().split())
MOD = (10 ** 9) + 7
if ((2 * X) - Y) % 3 != 0:
    print(0)
    exit()
q = ((2 * X) - Y) // 3
p = X - (2 * q)
if q < 0 or p < 0:
    print(0)
    exit()
r = max(p, q)
s = min(p, q)

over = 1
for i in range(2,r+s+1):
    over = (over * i) % MOD
under = 0
e = 1
f = 1
for i in range(2,s+1):
    e = (e * i) % MOD
for i in range(2,r+1):
    f = (f * i) % MOD
under = e * f

result = (over * modpow(under, MOD-2, MOD) % MOD)
print(result)


Measured memory_bytes: 3572
def add(x):
	if x in dic:
		dic[x]+=1
	else:
		dic[x]=1
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]
for i in range(n):
	b.append((b[-1]+a[i]-1)%k)
dic={}
ans=0
for i in range(n+1):
	add(b[i])
	ans+=dic[b[i]]-1
	if i-k+1>=0:
		dic[b[i-k+1]]-=1
print(ans)

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

using namespace std;
int main() {
  string s;
  cin >> s;
  int l = s.length() - 1;
  int result = 0;
  for (int i = 0; i <= l; i++) {
    if (s[i] != s[l]) ++result;
    --l;
  }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
int cnt[101010]; 
void make() {
  for (int i = 2; i < 101010; i++) {
    int x = 0;
    for (int j = 2; j * j <= i; j++) {
      if (i % j) continue;
      if (i / j != i) x += 2;
      else x++;
    }
    if (x > 2) cnt[i] = 1;
  }
  for (int i = 1; i < 101010; i++) {
    cnt[i] += cnt[i - 1];
  }
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  make();
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    cout << cnt[n] << '\n';
  }
  return 0;
}


Measured memory_bytes: 3600
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {
        n:usize,
        k:i64,
        ab:[(Usize1,Usize1);n-1],
    }
    let mut g = vec![Vec::new(); 101010];
    for (a, b) in ab {
        g[a].push(b);
        g[b].push(a);
    }
    let mut st = VecDeque::new();
    let mut ans = 1;
    let mut md = ModComb::new(MX, MOD);
    st.push_back((0usize, 0usize, 1));
    while let Some(s) = st.pop_front() {
        let (now, prev, cnt) = (s.0, s.1, s.2);
        if cnt == 1 {
            ans *= md.perm(k, g[now].len() as i64 + 1);
        } else {
            ans *= md.perm(k - 2, g[now].len() as i64 - 1);
        }
        for &nxt in g[now].iter() {
            if nxt == prev {
                continue;
            }
            st.push_back((nxt, now, cnt + 1));
        }
        ans %= MOD;
    }
    println!("{}", ans);
}
const MOD: i64 = 1000000007;
const MX: usize = 1010101;
/// x ^ n % m
pub fn mod_pow(x: i64, n: i64, m: i64) -> i64 {
    let mut res = 1;
    let mut x = x % m;
    let mut n = n;
    while n > 0 {
        if n & 1 == 1 {
            res = (res * x) % m;
        }
        x = (x * x) % m;
        n >>= 1;
    }
    res
}
struct ModComb {
    fact: Vec<i64>,
    fact_inv: Vec<i64>,
    n: usize,
    p: i64,
}
impl ModComb {
    fn initialize(&mut self) {
        let n = self.n;
        self.fact[0] = 1;
        for i in 1..n {
            self.fact[i] = (self.fact[i - 1] * i as i64) % self.p;
        }
        self.fact_inv[n - 1] = mod_pow(self.fact[n - 1], self.p - 2, self.p);
        for i in (0..n - 1).rev() {
            self.fact_inv[i] = (self.fact_inv[i + 1] * (i + 1) as i64) % self.p;
        }
    }
    fn new(max_n: usize, p: i64) -> ModComb {
        let mut ft = ModComb {
            fact: vec![0; max_n + 1],
            fact_inv: vec![0; max_n + 1],
            n: max_n + 1,
            p: p,
        };
        ModComb::initialize(&mut ft);
        ft
    }
    fn fact(&self, n: usize) -> i64 {
        self.fact[n]
    }
    fn comb(&self, n: i64, k: i64) -> i64 {
        if n < k {
            return 0;
        }
        (self.perm(n, k) * self.fact_inv[k as usize]) % self.p
    }
    fn perm(&self, n: i64, k: i64) -> i64 {
        if n < k {
            return 0;
        }
        self.fact[n as usize] * self.fact_inv[(n - k) as usize] % self.p
    }
    fn nsk(&self, n: i64, k: i64) -> i64 {
        if n < k {
            return 0;
        }
        let mut res = 0;
        for i in 0..k + 1 {
            let v = self.comb(k, i) * mod_pow(i, n, self.p) % self.p;
            if (k - i) % 2 == 1 {
                res = (res + self.p - v) % self.p;
            } else {
                res = (res + v) % self.p;
            }
        }
        return res * self.fact_inv[k as usize] % self.p;
    }
}


Measured memory_bytes: 29076
#include <bits/stdc++.h>
#include <unordered_map>
#define mem(ara, a) memset(ara, a, sizeof(ara))
#define fo freopen("output.txt", "w", stdout)
#define fi freopen("bruh.txt", "r", stdin)
#define int long long
#define sp " "
#define pb push_back
#define ff first
#define sz(x) x.size();
#define len(x) x.length();
#define ss second
#define vi vector<int>
#define double long double
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define pii pair<int, int>


long long inf = 2e18;
long long minf = -inf;
int ans = 0;
using namespace std;

signed main() {
    set <int >ar;
    for(int i=0; i<3; i++) {
        int a;
        cin >> a;
        ar.insert(a);
    }
    if (ar.size()==2) {
        cout << "Yes" << endl;
    } else  cout << "No" << endl;

}


Measured memory_bytes: 256
#ifdef ConanYu
#include "E:\yuzining\code\local.hpp"
#else
#pragma GCC optimize("-O3")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(...) do { } while(false)
void Main();
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie();
  Main();
  return 0;
}
#endif

void Main() {
  int k, n; cin >> k >> n;
  vector<int> v(n + 1);
  for(int i = 0; i < n; i++) {
    cin >> v[i];
  }
  v[n] = v[0] + k;
  int ans = k;
  for(int i = 0; i < n; i++) {
    ans = min(ans, k - (v[i + 1] - v[i]));
  }
  cout << ans << '\n';
}

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

int main(){
	int a,b,c,d,e,f,n=0;
	cin>>a>>b>>c;
	d=a%2;e=b%2;f=c%2;
	if(!(d==e&&e==f)){
		n++;
		if(d==e){a++;b++;}
		if(e==f){b++;c++;}
		if(f==d){c++;a++;}
	}
	
	if(a>b){
		n+=(a-b)/2;
		b=a;
	}else{
		n+=(b-a)/2;
		a=b;
	}
	if(b>c){
		n+=(b-c)/2;
	}else{
		n+=c-b;
	}
	
	cout<<n<<endl;
}

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

double W,H,x,y;
int c;

int main(){
	cin>>W>>H>>x>>y;

	cout<<W*H/2<<" ";

	if(W/2==x&&H/2==y)
		cout<<1<<endl;
	else
		cout<<0<<endl;

}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  int s[n];
  REP(i, n) cin >> s[i];
  int q;
  cin >> q;
  int ans = 0;
  REP(i, q) {
    int t;
    cin >> t;
    REP(j, n) {
      if (s[j] == t) {
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    
    int s;
    cin >> s;
    int h = 0;
    while(s - 3600 >= 0){
        s -= 3600;
        h++;
    }
    
    int m  = 0;
    while(s - 60 >= 0){
        s -= 60;
        m++;
    }
    
    cout << h << ":" << m << ":" << s << endl;
}



Measured memory_bytes: 3116
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

int main() {
    ll N;
    cin >> N;
    map<string, ll> cnt;
    for (ll i = 0; i < N; i++) {
        string s;
        cin >> s;
        cnt[s]++;
    }

    ll maxv = 0;
    for (auto &&e : cnt) chmax(maxv, e.second);
    for (auto &&e : cnt) if (e.second == maxv) cout << e.first << endl;
    return 0;
}



Measured memory_bytes: 23808
n = gets.to_i
s = gets

s_e = [0]
s_w = [0]

(2..n+1).each do |i|
  if s[i-2] == 'E'
    s_e[i-1] = s_e[i-2] + 1
    s_w[i-1] = s_w[i-2]
  else
    s_e[i-1] = s_e[i-2]
    s_w[i-1] = s_w[i-2] + 1
  end
end

min = 1000000
(1..n).each do |j|
  flip = (s_w[j-1] - s_w[0]) + (s_e[n] - s_e[j])
  min = flip if flip < min
end

puts min

Measured memory_bytes: 6900
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,n;
int main()
{
    cin>>a>>b>>c;
    if(b>=a)
    {
        cout<<1<<endl;
        return 0;
    }
    if(c>=b)
    {
        cout<<-1<<endl;
        return 0;
    }
    if((a-b)%(b-c)>=1)
		n=1;
    cout<<((a-b)/(b-c)+n)*2+1<<endl;
    return 0;
}

Measured memory_bytes: 256
a = gets.strip.to_i
b = gets.strip.to_i

ans = []
(0..2).each do |i|
  ans[i] = 0
end
ans[a-1] = 1
ans[b-1] = 1

(0..2).each do |i|
  puts (i+1).to_s if ans[i] == 0
end



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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(16);
    cin.tie(0); ios::sync_with_stdio(false);

    ll a, b;
    cin >> a >> b;
    vector<vector<ll>> res(100, vector<ll>(100));
    for(ll i=50; i<100; i++)
        for(ll j=0; j<100; j++)
            res[i][j] = 1;

    a--, b--;
    for(ll i=0; i<50 && a; i+=2)
        for(ll j=0; j<100 && a; j+=2)
            res[i][j] = 1, a--;
    for(ll i=51; i<100 && b; i+=2)
        for(ll j=0; j<100 && b; j+=2)
            res[i][j] = 0, b--;

    cout << "100 100" << endl;
    for(ll i=0; i<100; i++, cout << endl)
        for(ll j=0; j<100; j++)
            cout << (res[i][j] ? '.' : '#');

}


Measured memory_bytes: 384
#include <iostream>                                             
#include <cstdio>                                               
#include <cmath>                                                
#define USE_MATH_DEFINES                                        
using namespace std;                                            
                                                                
int main() {                                                    
  int a, b, c;                                                  
  double s, l, h;                                               
  cin >> a >> b >> c;                                           
  s = a*b*sin(c*M_PI/180)/2;                                    
  l = sqrt(a*a+b*b-2*a*b*cos(c*M_PI/180))+a+b;                  
  h = b*sin(c*M_PI/180);                                        
  printf("%.8f\n%.8f\n%.8f\n", s, l, h);                        
  return 0;                                                     
}                                                               
             

Measured memory_bytes: 3460
#include <iostream>
using namespace std;
 
int main() {
  int num;
  cin >> num;
 
  int *A;
  A = new int[num];
  for (int i = 0; i < num; i++) {
    cin >> A[i];
  }
 
  int numSwap = 0;
  for (int i = 0; i < num - 1; i++) {
    for (int j = num - 1; j >= i + 1; j--) {
      if (A[j] < A[j - 1]) {
        int tmp = A[j];
        A[j] = A[j - 1];
        A[j - 1] = tmp;
        numSwap++;
      }
    }  
  }
 
  for (int i = 0; i < num - 1; i++) {
    cout << A[i] << " ";
  }
  cout << A[num - 1] << endl;
  cout << numSwap << endl;

  return 0;
}


Measured memory_bytes: 3108
program ABC054B
    implicit none
    character(50)::s
    integer(8)::N,M,i,j,k,l,conv
    integer(8)::mask_sum=0
    integer(8)::flg=0
    integer(8),dimension(50,50)::img,mask
    read(5,*)N,M

    do i=1,N
        read(5,*)s
        do j=1,N
            if(s(j:j)==".")then
                img(j,i)=1
            else
                img(j,i)=0
            end if
        end do
    end do

    do i=1,M
        read(5,*)s
        do j=1,M
            if(s(j:j)==".")then
                mask(j,i)=1
                mask_sum=mask_sum+1
            else
                mask(j,i)=0
            end if
        end do
    end do


    do i=0,N-M
        do j=0,N-M
            conv=0
            do k=1,M
                do l=1,M
                    if(mask(l,k)==img(l+j,k+i))conv=conv+1
                end do
            end do
            if(conv==M*M)then
                flg=1
                exit
            end if
        end do
        if(flg==1)exit
    end do

    if(flg==1)then
        print'(A)',"Yes"
    else
        print'(A)',"No"
    end if
end program ABC054B

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int dp[8192];

void goup() {
	dp[0] = 1; dp[1] = 1; dp[2] = 2;

	for (int i = 3; i < 8192; i++) dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
	return;
}

int main() {
	int n;
	goup();

	while (1) {
		cin >> n;
		if (n == 0) break;
		cout << dp[n] / (365 * 10) + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
(* O(√n log n) *)
let n = read_int () in
let f a b =
  let rec f acc n = if n = 0 then acc else f (acc + 1) @@ n / 10 in
  f 0 @@ max a b in
let rec loop acc i =
  if i * i > n then acc
  else if n mod i <> 0 then loop acc @@ i + 1
  else loop (min acc @@ f i @@ n / i) (i + 1) in
loop max_int 1 |> Printf.printf "%d\n"

Measured memory_bytes: 384