akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<random>
#include<stdio.h>
using namespace std;

typedef long long ll;
ll pow(ll x, ll n ,ll MOD) {
    ll ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x % MOD;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}

ll even(ll i){
    if (i%2==0){
        return 1;
    }
    else{
        return -1;
    }
}

int main(){
    ll p;
    cin>>p;
    vector<ll> a(p);
    for (ll i=0;i<p;i++){
        cin>>a[i];
    }

    vector<ll> inverse(p);
    for (ll i=0;i<p;i++){
        inverse[i]=pow(i,p-2,p);
    }

    vector<ll> data(p+1);
    data[1]=1;
    for (ll i=1;i<p;i++){
        data[i+1]=1;
        for (ll j=i;j>0;j--){
            data[j]=(-i*data[j]+data[j-1])%p;
        }
    }

    vector<vector<ll>> coef(p,vector<ll>(p));
    for (ll j=0;j<p;j++){
        coef[0][j]=data[j+1];
    }
    for (ll i=1;i<p;i++){
        coef[i][0]=(-data[0]*inverse[i])%p;
        for (ll j=1;j<p;j++){
            coef[i][j]=((coef[i][j-1]-data[j])*inverse[i])%p;
        }
    }

    vector<ll> factorial(p);
    factorial[0]=1;
    for (ll i=1;i<p;i++){
        factorial[i]=(factorial[i-1]*i)%p;
    }

    for (ll i=0;i<p;i++){
        factorial[i]=inverse[factorial[i]];
    }

    vector<ll> ans(p,0);
    for (ll i=0;i<p;i++){
        for (ll j=0;j<p;j++){
            ans[j]+=a[i]*even(p-1-i)*factorial[i]*factorial[p-i-1]*coef[i][j];
            ans[j]%=p;
        }
    }

    for (ll i=0;i<p;i++){
        if (0>ans[i]){
            ans[i]=p+ans[i];
        }
        cout<<ans[i]<<" ";
    }


}


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

int main(void)
{
    int N,i,max=-1e9,min=1e9;
    int a[100];
    cin >> N;
    for(i=0;i<N;++i)
    {
        cin >> a[i];
    }
        for(i=0;i<N;++i)
    {
        if(a[i]>max) max = a[i];
        if(a[i]<min) min = a[i];
    }

    cout << max - min << endl;
    return 0;
}

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

typedef pair<int,int> P;

int main(){
  int n;
  while(cin >> n && n){
    int m;
    P p[200], p2[1000];
    set<P> s;
    for(int i=0;i<n;i++){
      cin >> p[i].first >> p[i].second;
      if(i > 0){
        p[i].first -= p[0].first;
        p[i].second -= p[0].second;
      }
    }

    cin >> m;
    for(int i=0;i<m;i++){
      cin >> p2[i].first >> p2[i].second;
      s.insert(p2[i]);
    }

    for(int i=0;i<m;i++){
      bool f = false;
      for(int j=1;j<n;j++){
        if(s.find(P(p2[i].first+p[j].first, p2[i].second+p[j].second)) == s.end()){
          f = true;
          break;
        }
      }
      if(!f){
        cout << p2[i].first-p[0].first << ' ' << p2[i].second-p[0].second << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 1248
//Author: AnandRaj uux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define forn(i,f,n) for(int i=f;i<f+n;i++)
#define rforn(i,l,n) for(int i=l;i>l-n;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int i=f;i<f+n;i++) cin>>V[i]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1e5+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            {
				is_prime[j] = false;
    		}
    	}
	}
}
//////////////////Sieve////////////////////

int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	ll ans=0;
	for(int len=1;2*len<n;len++)
	{
		for(int i=0;i+2*len<n;i++)
		{
			if(s[i]!=s[i+len]&&s[i]!=s[i+2*len]&&s[i+len]!=s[i+2*len])
			{
				ans++;
				//cout<<i+1<<" "<<i+1+len<<" "<<i+len+len+1<<endl;
			}
		}
	}
	ll secans=0;
	vvl dp(n+1,vl(3));
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<3;j++) dp[i][j]=dp[i-1][j];
		if(s[i-1]=='R') dp[i][0]++;
		else if(s[i-1]=='G') dp[i][1]++;
		else dp[i][2]++;
	}
	// for(int i=1;i<=n;i++)
	// {
	// 	cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
	// }
	for(int i=3;i<=n;i++)
	{
		if(s[i-1]=='R')
		{
			secans+=dp[i][1]*dp[i][2];
		}
		else if(s[i-1]=='G')
		{
			secans+=dp[i][0]*dp[i][2];
		}
		else secans+=dp[i][0]*dp[i][1];
	}
	cout<<secans-ans<<endl;
}		

Measured memory_bytes: 3788
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
#define U(v) cerr << #v << ": " << (v) << endl
 
template <class T>
struct BIT {
    vector<T> a;
    BIT(int size) : a(size, 0) {}
    T sum(int r) const {
        T sm = 0;
        for (--r; r >= 0; r = (r & r + 1) - 1)
            sm += a[r];
        return sm;
    }
    T sum(int l, int r) const {
        return sum(r) - sum(l);
    }
    T at(int i) const {
        return sum(i, i + 1);
    }
    void add(int i, T v) {
        for (; i < (int)a.size(); i |= i + 1)
            a[i] += v;
    }
    void set(int i, T v) {
        add(i, v - at(i));
    }
};
 
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<pair<int, int>> b(n);
    for (int i = 0; i < n; ++i) {
        cin >> b[i].first;
        b[i].second = i;
    }
    sort(b.begin(), b.end());
    for (int i = 0; i < n; ++i)
        a[b[i].second] = i;
    BIT<int> bit(n);
    long long sm = 0;
    for (int i = n - 1; i >= 0; --i) {
        sm += bit.sum(a[i]);
        bit.add(a[i], 1);
    }
    cout << sm << endl;
    return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int DP[410][410];

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	rep(i, 0, 410)rep(j, 0, 410)DP[i][j] = INF;
	DP[0][0] = 0;

	int N, Ma, Mb;
	cin >> N >> Ma >> Mb;
	int a, b, c;
	rep(i, 0, N)
	{
		cin >> a >> b >> c;
		rrep(l, 0, 410)rrep(r, 0, 410)
		{
			if (DP[l][r] != INF)
			{
				chmin(DP[l + a][r + b], DP[l][r] + c);
			}
		}
	}

	int ans = INF;
	rep(l, 0, 410)rep(r, 0, 410)
	{
		if (l == 0 && r == 0)continue;
		if (DP[l][r] != INF)
		{
			if (Mb*l == Ma * r)
			{
				chmin(ans, DP[l][r]);
			}
		}
	}

	if (ans == INF)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << ans << endl;
	}

	return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;
#define NODE 100001
#define INF 1000000000
vector<vector<pair<ll,ll> > > v(NODE);
int dist[NODE];
int dijkstra(int start){
	for(int i = 0;i < NODE;i++)dist[i] = INF;
	dist[start] = 0;
	priority_queue<P,vector<P>,greater<P> > pq;
	pq.push(make_pair(0,start));
	while(!pq.empty()){
		P now = pq.top();pq.pop();
		ll d = now.first;
		ll node = now.second;
		if(dist[node] < d)continue;
		for(int i = 0;i < v[node].size();i++){
			ll opp_n = v[node][i].first;
			ll opp_d = v[node][i].second;
			if(dist[opp_n] > d + opp_d){
				dist[opp_n] = d + opp_d;
				pq.push(make_pair(dist[opp_n],opp_n));
			}
		}
	}
}

int main(){
	int n;cin >> n;
	REP(i,n){
		int a,b;cin >> a >> b;
		REP(j,b){
			int x,y;cin >> x >> y;
			v[a].PB(MP(x,y));
		}
	}
	dijkstra(0);
	
	REP(i,n){
		cout << i << ' ' << dist[i] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 14516
n,k = map(int,input().split())
ans1 = 0
ans2 = 0
ans = 0
for x in range(1,n+1):
    if x % k ==0:
        ans1 +=1
if k % 2 == 0:
    for y in range(1,n+1):
        if y % k == k/2:
            ans2 +=1
print(ans1**3+ans2**3)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define db double
#define Pi acos(-1)
db A, B, H, M;
int main(){
    cin>>A>>B>>H>>M;
    db a = 2 * Pi / 60.0 * (H * 60 + M);
    db b = 2 * Pi / 720.0 * (H * 60 + M);
    db c = fabs(a - b);
    printf("%.9lf\n", sqrt(A * A + B * B - 2 * B * A * cos(c)));
    return 0;
}


Measured memory_bytes: 4208
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;

using namespace std;

int main(){
    ll n;
    cin >> n;
    vector<ll> t[n+1];
    for(ll i = 2; i <= n; i++){
        ll boss;
        cin >> boss;
        t[boss].push_back(i);
    }
    for(ll i = 1; i <= n; i++){
        cout << t[i].size() << endl;
    }
    return 0;
}

Measured memory_bytes: 14432
#pragma region

#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin); i < (end); i++)
#define _irep3(i, begin, end) for (register int i = (end)-1; i >= (begin); i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;
typedef long long ll;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);

  int A, B;
  cin >> A >> B;
  if (A > B) swap(A, B);
  if (A == 1 && B == 2)
    out(3) else if (A == 1 && B == 3)
        out(2) else if (A == 2 && B == 3)
            out(1);
}


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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

namespace pb_ds {   
    namespace io {
        const int MaxBuff = 1 << 15;
        const int Output = 1 << 23;
        char B[MaxBuff], *S = B, *T = B;
        #define getc() ((S == T) && (T = (S = B) + fread(B, 1, MaxBuff, stdin), S == T) ? 0 : *S++)
        char Out[Output], *iter = Out;
        inline void flush() {
            fwrite(Out, 1, iter - Out, stdout);
            iter = Out;
        }
    }

    template<class Type = int> inline Type read() {
        using namespace io;
        register char ch; register Type ans = 0; register bool neg = 0;
        while(ch = getc(), (ch < '0' || ch > '9') && ch != '-')     ;
        ch == '-' ? neg = 1 : ans = ch - '0';
        while(ch = getc(), '0' <= ch && ch <= '9') ans = ans * 10 + ch - '0';
        return neg ? -ans : ans;
    }

    template<class Type> inline void Print(register Type x, register char ch = '\n') {
        using namespace io;
        if(!x) *iter++ = '0';
        else {
            if(x < 0) *iter++ = '-', x = -x;
            static int s[100]; register int t = 0;
            while(x) s[++t] = x % 10, x /= 10;
            while(t) *iter++ = '0' + s[t--];
        }
        *iter++ = ch;
    }
}

using namespace pb_ds;

void File() {
#ifdef zjp_shadow
	freopen ("E.in", "r", stdin);
	freopen ("E.out", "w", stdout);
#endif
}

const int N = 5e5 + 1e3;

int n, d[N], pre[N], f[N];

int main () {

	File();

	n = read(); pre[0] = read(); f[n + 1] = 1;

	For (i, 1, n) 
		pre[i] = min(pre[i - 1], abs(pre[i - 1] - (d[i] = read())));
	Fordown (i, n, 1) 
		f[i] = f[i + 1] + ((f[i + 1] << 1) > d[i] ? d[i] : 0);

	using namespace io;
	For (i, 1, read()) {
		int x = read();
		if(pre[x - 1] >= f[x + 1]) *iter++ = 'Y', *iter++ = 'E', *iter++ = 'S';
		else *iter++ = 'N', *iter++ = 'O'; *iter++ = '\n';
	}
	flush();

	return 0;

}

Measured memory_bytes: 10112
#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
int main(){
	int a,b,x;
	scanf("%d%d",&a,&b);
	if((a+b)%2==1)
		printf("%d",(a+b)/2+1);
		else
			printf("%d",(a+b)/2);

	
}

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

int main(void){
    // Your code here!
    string s1, s2;
    cin >> s1 >> s2;
    s2.pop_back();
    if(s1 == s2){
        cout << "Yes" << endl;
    }
    else{cout << "No" << endl;}
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
map<string, int> freq;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n;
	string s;
	cin >> n;
	Foz(i, n) {
		cin >> s;
		freq[s]++;
	}

	int mx = 0;
	Trav(x, freq) ckmax(mx, x.second);

	vector<string> res;
	Trav(x, freq) if (x.second == mx) res.pb(x.first);
	sort(all(res));
	Foz(i, sz(res)) cout << res[i] << '\n';
}



Measured memory_bytes: 25584
import math
a = list(map(int,input().split()))
b = a[1]//a[0]
c = []
for i in range(1,int(math.sqrt(a[1]))+1):
    if a[1]%i==0 and i<=b:
        if a[1] // i <= b:
            c.append(a[1]//i)
        else:
            c.append(i)
c.sort(reverse=True)
print(c[0])

Measured memory_bytes: 3064
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_B&lang=jp"

#include <bits/stdc++.h>
using namespace std;
using lint = long long;

// #include "../../library/flow/primaldual.cpp"

template <typename T>
struct PrimalDual {
    struct edge {
        int to;
        T cap, cost;
        int rev;
        edge() {}
        edge(int to, T cap, T cost, int rev) : to(to), cap(cap), cost(cost), rev(rev) {}
    };
    const T inf = numeric_limits<T>::max() / 2;
    vector<vector<edge>> G;
    vector<T> h, dist;
    vector<int> prevv, preve;

    PrimalDual() {}
    PrimalDual(int n) : G(n), h(n), dist(n), prevv(n), preve(n) {}

    void addEdge(int from, int to, T cap, T cost) {
        G[from].emplace_back(to, cap, cost, G[to].size());
        G[to].emplace_back(from, 0, -cost, G[from].size() - 1);
    }

    void dijkstra(int s) {
        struct P {
            T first;
            int second;
            P(T first, int second) : first(first), second(second) {}
            bool operator<(const P &a) const { return first > a.first; }
        };
        priority_queue<P> que;
        fill(dist.begin(), dist.end(), inf);

        dist[s] = 0;
        que.emplace(dist[s], s);
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;
            if (dist[v] < p.first)
                continue;
            for (int i = 0; i < (int)G[v].size(); i++) {
                edge &e = G[v][i];
                if (e.cap == 0)
                    continue;
                if (dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
                    dist[e.to]  = dist[v] + e.cost + h[v] - h[e.to];
                    prevv[e.to] = v;
                    preve[e.to] = i;
                    que.emplace(dist[e.to], e.to);
                }
            }
        }
    }

    T flow(int s, int t, T f, int &ok) {
        T res = 0;
        fill(h.begin(), h.end(), 0);
        while (f > 0) {
            dijkstra(s);
            if (dist[t] == inf)
                return ok = 0;

            for (int v = 0; v < (int)h.size(); v++)
                h[v] += dist[v];

            T d = f;
            for (int v = t; v != s; v = prevv[v])
                d = min(d, G[prevv[v]][preve[v]].cap);

            f -= d;
            res += d * h[t];
            for (int v = t; v != s; v = prevv[v]) {
                edge &e = G[prevv[v]][preve[v]];
                e.cap -= d;
                G[v][e.rev].cap += d;
            }
        }
        ok = 1;
        return res;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, f;
    cin >> n >> m >> f;
    PrimalDual<int> graph(n);
    for (int i = 0; i < m; ++i) {
        int u, v, c, d;
        cin >> u >> v >> c >> d;
        graph.addEdge(u, v, c, d);
    }
    int ok    = 0;
    lint cost = graph.flow(0, n - 1, f, ok);
    if (!ok)
        cout << -1 << "\n";
    else
        cout << cost << "\n";
    return 0;
}



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

int main(){
  int n, m, c;
  cin >> n >> m >> c;
  vector<vector<int>> a(n, vector<int> (m));
  vector<int> b(m);
  for(int i = 0; i < m; ++i) cin >> b.at(i);
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j) cin >> a.at(i).at(j);
  }
  
  int cnt = 0;
  for(int i = 0; i < n; ++i){
    int sum = c;
    for(int j = 0; j < m; ++j){
      sum += a.at(i).at(j) * b.at(j);
    }
    if(sum > 0) ++cnt;
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 256
program five

 implicit none
 integer::x1,x2,x3,x4,x5

 read*,x1,x2,x3,x4,x5

 if(x1==0) print*,1
 if(x2==0) print*,2
 if(x3==0) print*,3
 if(x4==0) print*,4
 if(x5==0) print*,5

end program five

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

struct UnionFind {
  vector<int> par; //親の番号
  UnionFind(int N) : par(N) {
    rep(i, N) par[i] = i;
  }

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

  void unite(int x, int y){
    int rx = find(x);
    int ry = find(y);
    if(rx == ry) return;
    if(par[rx] > par[ry]) swap(rx, ry);
    par[ry] = rx;
  }

  bool same(int x, int y){
    int rx = find(x);
    int ry = find(y);
    return find(rx) == find(ry);
  }
};

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> p(N);
  rep(i, N){
    cin >> p[i];
  }
  UnionFind uf(N);
  int x, y;
  rep(i, M){
    cin >> x >> y;
    x--; y--;
    if(!uf.same(x, y)){
      uf.unite(x, y);
    }
  }
  int ans = 0;
  rep(i, N){
    if(uf.same(i, p[i]-1)){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
 
int main() {
  int n, m;
  cin >> n >> m;
  map<int, string> results;
  map<int, int> count;
  rep(i, m) {
    int a;
    cin >> a;
    string s;
    cin >> s;
    if(results.count(a)) {
      if(results.at(a) != "AC") {
        results[a] = s;
        count[a]++;
      }
    }
    else {
      results[a] = s;
      count[a] = 1;
    }
  }
  int ac = 0;
  for(auto p : results) {
    auto key = p.first;
    if(results.at(key) == "AC") ac++;
  }
  int pena = 0;
  for(auto p : count) {
    auto key = p.first;
    auto value = p.second;
    if(results.at(key) == "AC") (pena += value - 1);
  }
  cout << ac << " " << pena << endl;
}


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

int main(){
  int n,a,cnt=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    if(i%2 == 0 && a%2 == 1) cnt++;
  }

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

Measured memory_bytes: 3640
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n,a[110],i;
  cin >> n ;
  for(i=0;i<n-1;i++){
    cin >> a[i];
  }
  int ans=0;
  for(i=0;i<n;i++){
    if(i==0){
      ans+=a[i];
    }
    else if(i==n-1){
      ans+=a[i-1];
    }
    else{
      ans+=min(a[i-1],a[i]);
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll H, W;
    cin >> H >> W;
    vector<string> A(H+2);
    A[0] = string(W+2, '#');
    A[H+1] = string(W+2, '#');
    REP(i,1,H+1) {
        string a;
        cin >> a;
        A[i] = "#" + a + "#";
    }
    
    mat D(H+2, vec(W+2, INF));
    queue<pll> Q;
    REP(i,0,H+2) {
        REP(j,0,W+2) {
            if(A[i][j] == '#') {
                D[i][j] = 0;
                if(!(i == 0 || i == H+1 || j == 0 || j == W+1)) Q.push({i, j});
            }
        }
    }

    vector<pll> DIR = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
    while(!Q.empty()) {
        pll v = Q.front(); Q.pop();
        FORR(d,DIR) {
            ll i = v.first + d.first, j = v.second + d.second;
            if(D[i][j] >= INF) {
                D[i][j] = MIN(D[i][j],D[v.first][v.second]+1);
                Q.push({i, j});
            }
        }
    }

    ll m = 0;
    REP(i,0,H+2) {
        REP(j,0,W+2) m = MAX(m,D[i][j]);
    }
    PR(m);


    return 0;
}

/*



*/

Measured memory_bytes: 29260
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

N,K = map(int, sys.stdin.readline().split())
list_s = list(sys.stdin.readline().rstrip())

sum_inverse = 0
sum_happy = 0

for i in range(N-1):
    if(list_s[i] == list_s[i+1]):
        sum_happy += 1
    else:
        sum_inverse += 1


ans = min((sum_happy + K*2), (sum_happy + sum_inverse *2))

ans = min(ans, N-1)

print(ans)


Measured memory_bytes: 6132
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	ll x;
	scanf("%lld",&x);
	int cnt=0;
	ll now=100;
	while(now<x){
		now*=1.01;
		cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 3828
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int e[101][101];
    int R, C, r, c;
    int s, total;
    
    scanf("%d%d", &R, &C);
    for (r = 1; r <= R; r++) {
        for (c= 1; c <= C; c++) scanf("%d", &e[r][c]);
    }
    
    for (r = 1; r <= R; r++) {
        s = 0;
        for (c = 1; c <= C; c++) s += e[r][c];
        e[r][0] = s;
    }
    total = 0;
    for (c = 1; c <= C; c++) {
        s = 0;
        for (r = 1; r <= R; r++) s += e[r][c];
        e[0][c] = s;
        total += s;
    }
    for (r = 1; r <= R; r++) {
        for (c = 1; c <= C; c++) printf("%d ", e[r][c]);
        printf("%d\n", e[r][0]);
    }
    for (c = 1; c <= C; c++) printf("%d ", e[0][c]);
    printf("%d\n", total);
    return 0;
}


Measured memory_bytes: 2104
{-# OPTIONS_GHC -O #-}

import Control.Monad
import Data.List
import qualified Data.ByteString.Lazy.Char8 as B
import qualified Data.IntMap as M
import qualified Data.Set as S

readIntLL = map(unfoldr(B.readInt.B.dropWhile(==' '))).B.lines<$>B.getContents

insm2 n a b m
    | a==1 || a==n = insm b a m
    | b==1 || b==n = insm a b m
    | True = m

insm a b m = (M.insert a $ case M.lookup a m of
                Just s -> S.insert b s
                Nothing -> S.singleton b) m

f m n a = case M.lookup a m of
    Nothing -> False
    Just s -> S.member 1 s && S.member n s

main=do
    [n,m]:abs <- readIntLL
    --
    putStrLn $ if or $ map (f (mp n $ take m abs) n) [2..n-1] then "POSSIBLE" else "IMPOSSIBLE"
    where
        mp n abs = foldl' (\m [a,b]->insm2 n a b m) M.empty abs


Measured memory_bytes: 195836
#include <bits/stdc++.h>
using namespace std;
int f(string s) {
	vector<int> a;
	a.push_back(s[0] - '0');
	for (int i = 2; i < s.length(); i += 2) {
		if (s[i-1] == '+') {
			a.push_back(s[i] - '0');
		} else {
			a.back() *= s[i] - '0';
		}
	}
	int r = 0;
	for (int i = 0; i < a.size(); ++ i) r += a[i];
	return r;
}
int g(string s) {
	int r = s[0] - '0';
	for (int i = 2; i < s.length(); i += 2) {
		if (s[i-1] == '+') {
			r += s[i] - '0';
		} else {
			r *= s[i] - '0';
		}
	}
	return r;
}
int main() {
	string s;
	int n;
	cin >> s >> n;
	int r = 0;
	if (f(s) == n) r += 1;
	if (g(s) == n) r += 2;
	cout << "IMLU"[r] << endl;
}


Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    int n;
    cin>>n;
    map<int,int> m;
    rep(i,n){
        int a;
        cin>>a;
        m[a]++;
    }

    int ans=0;
    for(auto e : m){
        if(e.second%2==1) ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 8076
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
bool is(int mid,int arr[],int n,int k)
{int cnt=0;
    for(int i=0;i<n;i++)
    {
        cnt+=(arr[i]+mid-1)/mid;
        cnt-=1;
    }

    if(cnt<=k)
        return true;
    return false;





}
void solve()
{
 int n,k;
 cin>>n>>k;
 int arr[n];
 for(int i=0;i<n;i++)
    cin>>arr[i];
 int l=1,r=pow(10,12);
 int ans=pow(10,12);
 while(l<=r)
 {
     int mid=(l+r)/2;
     if(is(mid,arr,n,k))
     {
         ans=min(ans,mid);
         r=mid-1;
     }
     else
        l=mid+1;
 }
 cout<<ans<<endl;

}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
    return 0;
}


Measured memory_bytes: 5084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
const ll inf = 1001001001;
const ll mod = 1000000007;
 
int main() {
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;
}

Measured memory_bytes: 3596
def main():
    N = int(input())
    *H, = map(int, input().split())

    cond = True
    p = H[0] - 1
    for h in H[1:]:
        if p < h:
            p = h - 1
        elif p == h:
            pass
        else:
            cond = False
            break

    print('Yes' if cond else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 14396
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	N = 30
)

func main() {
	sc := newInputScanner(true, 1024)
	Q := sc.nextInt()
	sol := &solution{
		sideLength: uint64(math.Pow(3, N)),
	}
	for i := 0; i < Q; i++ {
		fmt.Println(sol.solve(sc.nextUInt64()-1, sc.nextUInt64()-1, sc.nextUInt64()-1, sc.nextUInt64()-1))
	}
}

type solution struct {
	debuggable
	sideLength uint64
}

func (sol *solution) solve(x1, y1, x2, y2 uint64) uint64 {
	sol.debug(func() {
		fmt.Printf("\nsolving %d %d %d %d\n", x1, y1, x2, y2)
	})
	return sol.abs(x1, x2) + sol.abs(y1, y2) + sol.max(sol.getExtra(x1, y1, x2, y2), sol.getExtra(y1, x1, y2, x2))
}

func (sol *solution) abs(m, n uint64) uint64 {
	if m < n {
		return n - m
	} else {
		return m - n
	}
}

func (spl *solution) max(m, n uint64) uint64 {
	if m < n {
		return n
	} else {
		return m
	}
}

func (spl *solution) min(m, n uint64) uint64 {
	if m < n {
		return m
	} else {
		return n
	}
}

func (sol *solution) getExtra(x1, y1, x2, y2 uint64) uint64 {
	s := sol.sideLength
	var blockX1, blockY1, blockX2, blockY2 uint64
	var left, right uint64
	var result uint64 = 0
	for {
		s /= 3
		if s == 0 {
			break
		}
		blockX1, blockX2 = x1/s, x2/s
		if blockX1 != blockX2 {
			break
		}
		if blockX1%3 != 1 {
			continue
		}
		blockY1, blockY2 = y1/s, y2/s
		if sol.abs(blockY1, blockY2) <= 1 {
			continue
		}
		left = s*blockX1 - 1
		right = s * (blockX1 + 1)
		result = sol.max(result, 2*sol.min(sol.min(x1, x2)-left, right-sol.max(x1, x2)))
		sol.debug(func() {
			fmt.Printf("size %d: (%d, %d), (%d, %d); left %d, right %d, result %d\n", s, x1, y1, x2, y2, left, right, result)
		})
	}
	return result
}

type inputScanner struct {
	*bufio.Scanner
}

func newInputScanner(enabledScanWords bool, sizeInKB int) *inputScanner {
	scanner := bufio.NewScanner(os.Stdin)
	if enabledScanWords {
		scanner.Split(bufio.ScanWords)
	}
	capacity := sizeInKB * 1024
	buf := make([]byte, capacity)
	scanner.Buffer(buf, capacity)
	return &inputScanner{
		Scanner: scanner,
	}
}

func (inputSc *inputScanner) nextInt() int {
	i, e := strconv.Atoi(inputSc.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (inputSc *inputScanner) nextUInt64() uint64 {
	i, e := strconv.ParseUint(inputSc.nextStr(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func (inputSc *inputScanner) nextStr() string {
	inputSc.Scan()
	return inputSc.Text()
}

type debuggable struct {
}

const (
	DEBUG_ON = false
)

func (d *debuggable) debug(f func()) {
	if DEBUG_ON {
		f()
	}
}


Measured memory_bytes: 2176
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define   ull unsigned long long 
const int MAX=1e6+9;
const int mod=1e9+7;
using namespace std;
int cnt[MAX];

int main(){
	ll a,b,c;
	cin>>a>>b;
	ll x=0;
	if((a-1)%4==0){
		x=a-1;
	}
	else if((a-1)%4==1){
		x=1;
	}
	else if((a-1)%4==2){
		x=a;
	}
	else{
		x=0;
	}


	if(b%4==0){
		x=x^b;
	}
	else if(b%4==1){
		x=x^1;
	}
	else if(b%4==2){
		x=x^(b+1);
	}
	else{
		x=x^0;
	}
	cout<<x;


	
	return 0;
}

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

int main(){
    int A, B;
    cin >> A >> B;
    if(B % A == 0) cout << A + B;
    else cout << B - A;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int a[4] = {};
    fr(4) a[i] = s[i] - '0';
    if (a[0] + a[1] + a[2] + a[3] == 7) {cout << a[0] << '+' << a[1] << '+' << a[2] << '+' << a[3] << "=7"; return 0;}
    if (a[0] + a[1] + a[2] - a[3] == 7) {cout << a[0] << '+' << a[1] << '+' << a[2] << '-' << a[3] << "=7"; return 0;}
    if (a[0] + a[1] - a[2] + a[3] == 7) {cout << a[0] << '+' << a[1] << '-' << a[2] << '+' << a[3] << "=7"; return 0;}
    if (a[0] + a[1] - a[2] - a[3] == 7) {cout << a[0] << '+' << a[1] << '-' << a[2] << '-' << a[3] << "=7"; return 0;}
    if (a[0] - a[1] + a[2] + a[3] == 7) {cout << a[0] << '-' << a[1] << '+' << a[2] << '+' << a[3] << "=7"; return 0;}
    if (a[0] - a[1] + a[2] - a[3] == 7) {cout << a[0] << '-' << a[1] << '+' << a[2] << '-' << a[3] << "=7"; return 0;}
    if (a[0] - a[1] - a[2] + a[3] == 7) {cout << a[0] << '-' << a[1] << '-' << a[2] << '+' << a[3] << "=7"; return 0;}
    if (a[0] - a[1] - a[2] - a[3] == 7) {cout << a[0] << '-' << a[1] << '-' << a[2] << '-' << a[3] << "=7"; return 0;}
}


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

int main(){
    //入力
    int A,B;
    char op;
    cin >> A >> op >> B;
    
    //出力
    if(op=='+'){
        cout << A+B << endl;
    }else{
        cout << A-B << endl;
    }
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N, M;
    ll maxL = 0, minR = LONG_LONG_MAX;
    cin >> N >> M;
    for(ll i = 0;i < M;i++) {
        ll L, R;
        cin >> L >> R;
        maxL = max(maxL, L);
        minR = min(minR, R);
    }
    cout << max(0LL, minR - maxL + 1) << endl;
    return 0;
}


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

using namespace std;

int main(){
	int n;
	int a[5000] = { 0 };

	while (cin >> n, n){
		int ans = -100000;
		for (int i = 0; i < n; i++){
			cin >> a[i];
		}
		for (int i = 0; i < n; i++){
			int sum = 0;
			for (int j = 0; (i + j < n); j++){
				sum += a[i + j];
				ans = max(sum, ans);
			}
		}
		cout << ans << endl;
	}

	return 0;

}

Measured memory_bytes: 1188
N, M = map(int, input().split())
P = [0] * M
Y = [0] * M

data = [[] for _ in range(N + 1)]

for i in range(M):
    P[i], Y[i] = map(int, input().split())
    data[P[i]].append(Y[i])

for k in set(P):
    data[k].sort()

x = [{} for _ in range(N + 1)]

for k in set(P):
    c = 0
    for v in data[k]:
        c += 1
        x[k][v] = c

for i in range(M):
    id_number = "{:06}{:06}".format(P[i], x[P[i]][Y[i]])
    print(id_number)


Measured memory_bytes: 61520
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s1,s2,s3;
  	cin>>s1>>s2>>s3;
  
  	cout<<(char)(s1.at(0)-32)<<(char)(s2.at(0)-32)<<(char)(s3.at(0)-32)<<endl;
  
}


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

int main() {
  string s;
  cin>>s;
  int N=s.size();
  if(N==1){cout<<"Yes"<<endl;return 0;}
  vector<char> S(N),T(N);
  for(int i=0;i<N;i++){S.at(i)=s.at(i);}
  for(int i=0;i<N;i++){cin>>T.at(i);}
  sort(S.begin(),S.end());
  vector<int> s_freq(0);
  int cnt=0;
  for(int i=0;i<N;i++){
    if(i==0){
      cnt++;
    }else if(S.at(i)==S.at(i-1)){
      cnt++;
      if(i==N-1){
        int cnt_i=cnt;
        s_freq.push_back(cnt_i);
      }
    }else{
      int cnt_i=cnt;
      s_freq.push_back(cnt_i);
      cnt=1;
      if(i==N-1){
        int cnt_i=cnt;
        s_freq.push_back(cnt_i);
      }
    }
  }
  sort(T.begin(),T.end());
  vector<int> t_freq(0);
  cnt=0;
  for(int i=0;i<N;i++){
    if(i==0){
      cnt++;
    }else if(T.at(i)==T.at(i-1)){
      cnt++;
      if(i==N-1){
        int cnt_i=cnt;
        t_freq.push_back(cnt_i);
      }
    }else{
      int cnt_i=cnt;
      t_freq.push_back(cnt_i);
      cnt=1;
      if(i==N-1){
        int cnt_i=cnt;
        t_freq.push_back(cnt_i);
      }
    }
  }
  if(s_freq.size()==t_freq.size()){
    sort(s_freq.begin(),s_freq.end());
    sort(t_freq.begin(),t_freq.end());
    for(int i=0;i<s_freq.size();i++){
      if(s_freq.at(i)!=t_freq.at(i)){cout<<"No"<<endl;break;}
      else if(i==s_freq.size()-1){cout<<"Yes"<<endl;}
    }
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 900
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val A, B, N = sc.nextLong
    var ans = Long.MaxValue
    for (i <- 1L to N) {
      if (B % i == 0) {
        for (j <- 1L to N) {
          ans = math.min(ans, math.abs(A - B / i * j))
        }
      }
    }
    println(ans)
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 45812
v=[[2e9,s=1]]
`sort -nr`.lines{|e|x,d=e.split.map &:to_i
d&&(r=1
r*=v.pop[1]while v[-1][0]<x+d
v<<[x,r+1])}
v.map{|_,y|s=s*y%998244353}
p s

Measured memory_bytes: 25076
#include "bits/stdc++.h"
using namespace std;
#define OUT(x) cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }

int n;
vector<int> g[101010];
vector<int> rg[101010];
vector<int> order;
bool used[101010];
int cmp[101010];

void add_edge(int from, int to) {
        g[from].push_back(to);
        rg[to].push_back(from);
}
void dfs(int v) {
        used[v] = true;
        for (auto i : g[v]) if (!used[i]) dfs(i);
        order.push_back(v);
}
void rdfs(int v, int k) {
        used[v] = true;
        cmp[v] = k;
        for (auto i : rg[v]) if (!used[i]) rdfs(i, k);
}
int StronglyConnectedComponent() {
        memset(used, 0, sizeof(used));
        order.clear();
        for (int i = 0; i < n; i ++) if (!used[i]) dfs(i);
        memset(used, 0, sizeof(used));
        int k = 0;
        for (int i = order.size() - 1; i >= 0; i --) if (!used[order[i]]) rdfs(order[i], k ++);
        return k;
}

signed main() { 
        int m;
        cin >> n >> m;
        rep(i, m) {
                int a, b;
                cin >> a >> b;
                add_edge(a, b);
        }
        StronglyConnectedComponent();
        int q;
        cin >> q;
        while (q --) {
                int a, b;
                cin >> a >> b;
                cout << (cmp[a] == cmp[b]) << endl;
        }
        return 0;
}               

Measured memory_bytes: 9232
fun main(args: Array<String>) {
  val s = readLine()!!
  val n = s.length
  var ok = true
  if (s[0] != '1') ok = false
  if (s[n - 1] != '0') ok = false
  var list = mutableListOf<Int>()
  for (i in 0 until n / 2) {
    if (s[i] == s[n - i - 2]) {
      if (s[i] == '0') continue
      list.add(i + 1)
      if (i != n - i - 2) list.add(n - i - 1)
    } else {
      ok = false
    }
  }
  if (!ok) {
    println(-1)
    return
  }
  var p = 1
  var c = 1
  list.sort()
  for (m in list) {
    while (c <= m) {
      c++
      println("$p $c")
    }
    p = c
  }
}


Measured memory_bytes: 44404
'''input
3 20
'''

def list_input():
    return list(map(int,input().split()))
def map_input():
    return map(int,input().split())
def map_string():
    return input().split()
    
x,y = map_input()
ans = 0
while x <= y:
	x *= 2
	ans += 1
print(ans)	

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
   long N = sc.nextLong();
    StringBuilder sb = new StringBuilder();
    sb.append("");
//System.out.println(N);
    if(N!=0){
      do{
    /*    switch (N%4){
          case 2:
          sb.insert(0, "10");
          N+=2;
          break;
          case 3:
          sb.insert(0, "11");
          N+=1;
          break;
          case 0:
          sb.insert(0, "00");
          break;
          case 1:
          sb.insert(0, "01");
          N-=1;
        }
        N=N/4;*/
      if(N%4==-2||N%4==2){
        sb.insert(0, "10");
        N+=2;
      }else if(N%4==-1||N%4==3){
        sb.insert(0, "11");
        N+=1;
      }else if(N%4==0){
        sb.insert(0, "00");
      }else{
        sb.insert(0, "01");
        N-=1;
      }
      N=N/4;
      }while(N!=0);

      while(sb.charAt(0)=='0'){
        sb = sb.deleteCharAt(0);
      }
      System.out.println(sb);
    }else{
      System.out.println(0);
    }
  }
}


Measured memory_bytes: 21972
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================

int main() {
	
	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================
	
	
	ll N, A, B;
	cin >> N >> A >> B;

	if ((A - B) % 2 == 0) {
		cout << abs(A - B) / 2;
		return 0;
	}
	else {

		ll first = min(min(A-1, B-1), min(N - A, N - B));

		ll sabun = abs(A - B);

		cout << sabun / 2 + first + 1;
		return 0;

	}






}



Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	long long a,b,c,wow;
    scanf("%lld%lld%lld",&a,&b,&c);
    if(b>=a)
    {
        printf("1\n");
        return 0;
    }
    if(c>=b)
    {
        printf("-1\n");
        return 0;
    }
    if((a-b)%(b-c)>=1) wow=1;
    printf("%lld\n",((a-c-1)/(b-c))*2+1);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int mod=1e9+7;
ll fac[2000010],finv[2000010],inv[2000010];
void init(int n);

int main(void){
  int x,y,m1,m2;
  cin >> x >> y;
  if ((x+y)%3!=0){
    cout << 0 << endl;
    return 0;
  }
  m1=x-(x+y)/3;
  m2=y-(x+y)/3;
  init(m1+m2);
  cout << fac[m1+m2]*(finv[m1]*finv[m2]%mod)%mod << endl;
  return 0;
}

void init(int n){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<=n;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;
  }
}

Measured memory_bytes: 20736
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	int h,w,n,a[10000] = {0};

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

	//sort(a,a+n);

	int c[100][100] = {0};

	int k = 0,cnt = 0;

	bool even = true;

	for(int i = 0; i < h; i++)
	{
		if (even)
		{
			for(int j = 0; j < w; j++)
			{
				c[i][j] = k+1;
				cnt++;
				if (cnt == a[k])
				{
					cnt = 0;
					k++;
				}
			}
			even = false;
		}else
		{
			for(int j = w-1; j >= 0; j--)
			{
				c[i][j] = k+1;
				cnt++;
				if (cnt == a[k])
				{
					cnt = 0;
					k++;
				}
			}

			even = true;
		}
	}

	for(int i = 0; i < h; i++)
	{
		for(int j = 0; j < w; j++)
		{
			if (j == w-1)
			{
				cout << c[i][j] << endl;
			}else
			{
				cout << c[i][j] << " ";
			}
		}
	}

	return 0;
}

Measured memory_bytes: 384