akhauriyash/Code-Regression huggingface dataset:
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  
  string s,t;cin>>s>>t;
  int a = 0;
  for(int i = 0; 3 > i; i++){
    if(s[i] == t[i])a++;
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
using ll = long long int;

int main()
{
	ll n;
	cin >> n;
	string s;
	while(n > 0LL){
		ll d = n % 26;
		s += (char)('a' + ((d + 25) % 26));
		n = n / 26 - (d == 0);
	}
	reverse(s.begin(), s.end());
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

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 > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}

int main(void) {
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    for(int i=0; i<H; i++) {
        cin >> s[i];
    }

    WeightedGraph<int> g(H*W);
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            if(i+1<H) {
                if(s[i][j] == s[i+1][j]) {
                    g[i*W+j].emplace_back(i*W+W+j, 0);
                } else {
                    g[i*W+j].emplace_back(i*W+W+j, 1);
                }
            }
            if(j+1<W) {
                if(s[i][j] == s[i][j+1]) {
                    g[i*W+j].emplace_back(i*W+j+1, 0);
                } else {
                    g[i*W+j].emplace_back(i*W+j+1, 1);
                }
            }
        }
    }

    auto ans = dijkstra(g, 0);
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            cerr << ans[i*W+j] << ' ';
        }
        cerr << endl;
    }
    if(s[0][0] == '#') ans.back()++;
    if(s[H-1][W-1] == '#') ans.back()++;

    cout << ans.back()/2 << endl;
    return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int[] l = new int[n];
		l[0] = 0;
		for (int i = 1; i < n; i++) {
			final int nextInt = in.nextInt();
			l[i] = l[i - 1] + nextInt;
		}
		int posi = 0;
		int sum = 0;
		int pre, aft = 0;
		for (int i = 0; i < m; i++) {
			pre = aft;
			final int nextInt = in.nextInt();
			posi += nextInt;
			aft = l[posi];
			sum += Math.abs(pre - aft);
			if (sum >= 100000)
				sum %= 100000;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 94480
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

typedef struct {
    int x;
    int y;
    long long h;
} XYH;

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

    XYH xyh_ref;
    vector<XYH> xyh;
    for (int i = 0; i < N; i++) {
        int x, y;
        long long h;
        cin >> x >> y >> h;
        XYH xyh_i = {x, y, h};
        xyh.push_back(xyh_i);
        if (h > 0) {
            xyh_ref = xyh_i;
        }
    }

    for (int Cx = 0; Cx <= 100; Cx++) {
        for (int Cy = 0; Cy <= 100; Cy++) {
            long long H = abs(xyh_ref.x - Cx) + abs(xyh_ref.y - Cy) + xyh_ref.h;
            bool flag = true;

            for (int i = 0; i < xyh.size(); i++) {
                long long h = max(H - abs(xyh[i].x - Cx) - abs(xyh[i].y - Cy), 0LL);
                if (h != xyh[i].h) {
                    flag = false;
                    break;
                }
            }

            if (flag) {
                cout << Cx << " " << Cy << " " << H << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define db(x) cout<<#x<<"="<<x<<endl
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
#define EPS 1e(-9);
using namespace std;
typedef long long ll;

void Main(){

  string S; cin>>S;
  ll K; cin>>K;
  string s=S;
  ll ct=0; //最初がA
  ll ct1=0; //最初が最後
  reps(i,1,s.length()){
    if(s[i-1]=='A') continue;
    if(s[i]==s[i-1]){
      ct++;
      s[i]='A';
    }
  }

  if(s[s.length()-1]=='A'){
    cout<< K*ct <<"\n";
    return;
  }

  string ss=s[s.length()-1]+S;
  reps(i,1,ss.length()){
    if(ss[i-1]=='A') continue;
    if(ss[i]==ss[i-1]){
      ct1++;
      ss[i]='A';
    }
  }

  if(ss[ss.length()-1]=='A'){
    cout<< ((K+1)/2)*ct + (K/2)*ct1 <<"\n";
    return;
  }
  else{
    cout<< ct + (K-1)*ct1 <<"\n";
    return;
  }

}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>

using namespace std;

typedef long long ll;

#define drobucs ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff first
#define ss second

int main() {
	drobucs;

	ll n;
	cin >> n;

	vector<pair<ll, ll>> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i].ff >> v[i].ss;
	}

	sort(v.begin(), v.end(), [](pair<ll, ll> d1, pair<ll, ll> d2) {
		if (d1.ss != d2.ss) {
			return d1.ss < d2.ss;
		}
		else {
			return d1.ff < d2.ff;
		}
	});

	ll sum = 0;
	for (auto t : v) {
		sum += t.ff;
		if (sum > t.ss) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}
		

Measured memory_bytes: 3328
#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++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
   int n,C;cin>>n>>C;
   vector<int> v(2*(1e+5)+3,0); 
   vector<vector<int>> x(C,vector<int>(2*(1e+5)+3,0));
   rep(i,n){
       int s,t,c;cin>>s>>t>>c;s*=2;t*=2;c--;
       if(x[c][s]==0) v[s]++;
       for(int j=s+1;j<=t-1;j++) v[j]++;
       if(x[c][t]==0) v[t]++;
       x[c][s]++;
       x[c][t]++;
   }
   int res=0;
   rep(i,2*(1e+5)+3) chmax(res,v[i]);
   cout<<res<<endl;
}

Measured memory_bytes: 25344
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

signed main(){
  fastio
  string s;cin>>s;
  if(s=="ABC")  cout<<"ARC\n";
  else          cout<<"ABC\n";
  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
long long n;
void dfs(long long cur,int use,long long &counter){
    if(cur>n) return;
    if(use == 0b111) ++counter;

    dfs(cur*10+7,use | 0b001,counter);
    dfs(cur*10+5,use | 0b010,counter);
    dfs(cur*10+3,use | 0b100,counter);
}

int main(){
    cin >> n;
    long long res = 0;
    dfs(0,0,res);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
  
int main(){
    int cost[22][22]={0};
    int n,m,i,j,k,a,b,c,d;
    char cc;
    cin>>n>>m;
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            cost[i][j] = 28;
        }
    }
    for(i=0;i<m;i++){
        cin>>a>>cc>>b>>cc>>c>>cc>>d;
        cost[a][b]=c;cost[b][a]=d;
    }
    for(k=1;k<=n;k++){
        for(i=1;i<=n;i++){
            for(j=1;j<=n;j++){
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
                cin>>a>>cc>>b>>cc>>c>>cc>>d;
            }
        }
    }
    cout << c-d-cost[a][b]-cost[b][a] << endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <complex>
#include <cmath>
static double pi = M_PI;
static void k(int n, std::complex<double>& p1, std::complex<double>& p2) {
    if (n <= 0) {
        return;
    }
    std::complex<double> s = (p1 * 2. + p2) / 3.;
    std::complex<double> t = (p1 + p2 * 2.) / 3.;
    std::complex<double> u = s + (t - s) * std::polar(1., pi / 3.);
    k(n - 1, p1, s);
    std::cout << s.real() << ' ' << s.imag() << std::endl;
    k(n - 1, s, u);
    std::cout << u.real() << ' ' << u.imag() << std::endl;
    k(n - 1, u, t);
    std::cout << t.real() << ' ' << t.imag() << std::endl;
    k(n - 1, t, p2);
}
int main() {
    int n;
    std::cin >> n;
    std::complex<double> p1 { 0., 0. }, p2 { 100., 0. };
    std::cout << std::fixed << std::setprecision(6);
    std::cout << p1.real() << ' ' << p1.imag() << std::endl;
    k(n, p1, p2);
    std::cout << p2.real() << ' ' << p2.imag() << std::endl;
}



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

class Vector
{
public:
	double x,y;
	Vector (double x=0,double y=0):x(x),y(y){}
	
	Vector operator + (Vector p){return Vector(x+p.x,y+p.y);}
	Vector operator - (Vector p){return Vector(x-p.x,y-p.y);}
	Vector operator * (double a){return Vector(x*a,y*a);}
	Vector operator / (double a){return Vector(x/a,y/a);}
	
	double abs() {return sqrt(norm());}
	double norm(){return x*x+y*y;}
};

double cross(Vector a,Vector b)
{
	return abs(a.x*b.y-b.x*a.y);
}

int main()
{
	int n;cin>>n;
	Vector p0,p1,p2,p3;
	cout<<fixed<<setprecision(10);
	for(int i=0;i<n;i++)
	{
		cin>>p0.x>>p0.y>>p1.x>>p1.y>>p2.x>>p2.y>>p3.x>>p3.y;
		Vector base=p3-p2;
		Vector hypo1=p0-p2;
		Vector hypo2=p1-p3;
		
		double d1=cross(base,hypo1);
		double d2=cross(base,hypo2);
		
		double t=d1/(d1+d2);
		Vector x=p0+(p1-p0)*t;
		cout<<x.x<<" "<<x.y<<endl;
	}
	return 0;
}

Measured memory_bytes: 3288
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
#define NUM 1000000007
int main() {
    int n;
    cin>>n;
    ll power=1;
    repi(i,1,n+1){
        power=(power*i)%NUM;
    }
    cout<<power;
}

Measured memory_bytes: 3568
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

int main() {
  int sum = 0;
  vector<int> a(5);
  vector<int> b(5);
  for (int i = 0; i < 5; i++) {
    cin >> a[i];
    if (a[i] % 10 != 0) {
      b[i] = (a[i] / 10 + 1) * 10;
    } else {
      b[i] = a[i];
    }
    sum += b[i];
  }
  int ans = sum;
  for (int i = 0; i < 5; i++) {
    ans = min(ans, sum - b[i] + a[i]);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N = 0;
  cin >> N;
  long long l0 = 2;
  long long l1 = 1;
  rep(i, N-1){
    l1 = l1 + l0;
    l0 = l1 - l0;
  }
  cout << l1 << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> v(N);
  for(int i=0;i<N;i++){
    cin >> v.at(i);
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  int sum=0;
  for(int i=1;i<N;i++){
    sum+=v.at(i);
  }
  if(v.at(0)<sum){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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



int main(){
  long long N;
  cin >> N;
  vector<long long> a(N);
  for(long long i=0;i<N;i++){
    cin >> a[i];
  }
  int s=1;
  long long count=N;
  
  bool ju=false;
  
  for(long long i=0;i<N;i++){
    if(a[i]==s){
      count=count-1;
      s=s+1;
      ju=true;
    }
  }
  
  if(ju==true){
    cout << count << endl;
  }
  else{
    cout << -1 << endl;
  }
  return 0;
}
  
    

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,flag=0,count=0,ans=0;string S;cin>>N>>S;
  for(int i=0;i<N-1;i++){
    count=0;
    for(int j=0;j<26;j++){
      flag=0;
      for(int k=0;k<=i;k++){
        if(S.at(k)=='a'+j){
          flag++;
          break;
        }
      }
      if(flag==1){
        for(int k=i+1;k<N;k++){
          if(S.at(k)=='a'+j){
            flag++;
            break;
          }
        }
      }
      if(flag==2)count++;
    }
    ans=max(ans,count);
  }
  cout<<ans<<endl;
}

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

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define SIZE 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef vector<vector<pair<long long,long long>>> vvpl;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
/*ios_base::sync_with_stdio(false);cin.tie(0);*/

ll gcd(ll n,ll m){
    if (n==0)return m;
    return gcd(m%n,n) ;
}





int main(){
    ll n,m;
    cin >> n>>m;
    priority_queue<ll> qq;
    ll cur;
    for (int i = 0; i <n ; ++i) {
        cin >>cur;

        qq.push(cur);
    }

    for (int j = 0; j <m ; ++j) {
         cur= qq.top();

        qq.pop();
        ll t = cur /2;
        //cout <<t;
        qq.push(t);

    }
    ll ans=0;

    for (int k = 0; k <n ; ++k) {
      //  cout << qq.top()<<"\n";
        ans+=qq.top();
        qq.pop();
    }
    cout <<ans;
    return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int N;
    cin >> N;
    string s = "No";
    REP(i, 30)
    {
        if (i * 4 > N)
            break;
        if ((N - (i * 4)) % 7 == 0)
            s = "Yes";
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	double v,t,y;
	int n=1,h=0;
	while(scanf("%lf",&v)!=EOF)
	{
		t = v / 9.8;
		y = 4.9 * t*t;
		while(h<y)
		{
			n++;
			h=5*n-5;
		}
		printf("%d\n",n);
		n=1;
		h=0;
	}
	return 0;
}

Measured memory_bytes: 1056
//https://vjudge.net/contest/313071#problem/A

#include<bits/stdc++.h>
const int N = 1e5 + 5;
using namespace std;

typedef pair <int, int> ii;
vector <ii> G[N];
int n, d[N], ed, ver;
long long s[N], sum, ans[N];

void dfs(int u, int p){
    d[u] = 1;
    for (auto x : G[u]){
        int v = x.first, id = x.second;
        if (v == p) continue;
        dfs(v, u);
        d[u] += d[v];
        int num = n - 2 * d[v];
        if (num) ans[id] = (s[v] - s[u]) / (n - 2 * d[v]), sum += ans[id] * d[v];
        else ed = id, ver = v;
    }
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i < n; i++){
        int u, v; cin >> u >> v;
        G[u].push_back(ii(v, i));
        G[v].push_back(ii(u, i));
    }
    for (int i = 1; i <= n; i++) cin >> s[i];
    dfs(1, 1);
    if (ed) ans[ed] = (s[1] - sum) / d[ver];
    for (int i = 1; i < n; i++) cout << ans[i] << "\n";
}


Measured memory_bytes: 16128
import java.util.Scanner;
import java.util.Arrays;

public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer n = Integer.parseInt(scan.next());
        Integer d[] = new Integer[n];

        for(int i=0;i<n;i++)   
            d[i] = Integer.parseInt(scan.next());

        Arrays.sort(d);
        
        System.out.println(d[n/2] - d[n/2-1]);
    }
}

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

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

using namespace std;
using lint=long long;

int main(){
	lint n,a,b,c,d,e; cin>>n>>a>>b>>c>>d>>e;
	lint m=min({a,b,c,d,e});
	cout<<(n+m-1)/m+4<<endl;

	return 0;
}


Measured memory_bytes: 256
module Main where

import Data.Functor

main :: IO ()
main = do
  { [a,b,c] <- getInts
  ; let result = junban (a,b,c)
  ; putStrLn result
  }

junban :: (Int, Int, Int) -> String
junban (x,y,z)
  | x < y && y < z = "Yes"
  | otherwise      = "No"

getInts :: IO [Int]
getInts = map read . words <$> getLine

Measured memory_bytes: 3604
n, m, k = gets.split(" ").map(&:to_i)
a = gets.split(" ").map(&:to_i)
b = gets.split(" ").map(&:to_i)
aa = [0]
bb = [0]
for i in 0..n-1
  aa[i+1] = a[i] + aa[i]
end
for j in 0..m-1
  bb[j+1] = b[j] + bb[j]
end
ans = min = 0
j = m
(n+1).times{ |i|
  if aa[i] > k
    break
  end
  while (aa[i] + bb[j]) > k
    j -= 1
  end
  min = i + j
  if ans < min
      ans = min
  end
}
puts ans

Measured memory_bytes: 45220
//s.empty() //emptyなら1を出力 入っていれば0を出力
/*//ABC018-B 部分的にreverseをかける解法
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  rep(i,n) cin>>a.at(i)>>b.at(i);
  rep(i,n)a.at(i)--;
  rep(i,n)b.at(i)--;
  string t;
  rep(i,n){
    t = s;
    for(int k=0;k<=b.at(i)-a.at(i);k++){
      t.at(a.at(i)+k) = s.at(b.at(i)-k);
    }
    s = t;
  }
  cout << s << endl;
}
*///ABC018-B
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <iomanip>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int kaijou(int n){
  int kaijou_sum = 1;
  if(n!=0){
    for(int i=1;i<=n;i++){
      kaijou_sum *= i;
    }
    return kaijou_sum;
  }
  else return 1;
}

int main() {
  ll n;
  cin>> n;
  vector<ll>a(n);
  rep(i,n)cin>>a.at(i);
  ll sum = 0;
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
//  rep(i,n)cout<<a.at(i)<<endl;
  sum = a.at(0);
  n = n - 2;// n==6なので、sum=50を入れて、あと4回加えていく。
  if(n%2==0){
    for(int i=1;i<=n/2;i++){
    sum += a.at(i) * 2;
    }
  }
  else{
    for(int i=1;i<=n/2;i++){
    sum += a.at(i) * 2;
    }
    sum += a.at(n/2+ 1);
  }
  cout << sum << endl;
}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define pii make_pair
int ceil(int a, int b) { if(a%b==0) return a/b; else return a/b+1; }

main()
{
    //fastio;
    int n, k, x, y;
    cin>>n>>k>>x>>y;
    int rem=max(0LL, n-k);
    int mn=min(n, k);
    cout<<mn*x+rem*y;
}


Measured memory_bytes: 3608
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int r = 2;
    while (r <= N) {
      r *= 2;
    }
    r /= 2;
    System.out.println(r);
  }
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
	static void Main() => new Program().Solve();

	long h, w, k;
	char[][] c;
	long cnt;

	void Solve()
	{
		var hwk = ReadLongArray();
		h = hwk[0];
		w = hwk[1];
		k = hwk[2];

		c = new char[h][];

		for (var i = 0; i < h; i++) {
			c[i] = Console.ReadLine().ToArray();
		}

		sub1(0);

		Console.WriteLine(cnt);
	}

	void sub1(long y)
	{
		if (y == h) {
			sub2(0);
			return;
		}

		sub1(y + 1);

		var t = new char[w];
		for (var x = 0; x < w; x++) {
			t[x] = c[y][x];
			c[y][x] = 'R';
		}
		sub1(y + 1);
		for (var x = 0; x < w; x++) {
			c[y][x] = t[x];
		}
	}

	void sub2(long x)
	{
		if (x == w) {
			sub3();
			return;
		}

		sub2(x + 1);

		var t = new char[h];
		for (var y = 0; y < h; y++) {
			t[y] = c[y][x];
			c[y][x] = 'R';
		}
		sub2(x + 1);
		for (var y = 0; y < h; y++) {
			c[y][x] = t[y];
		}
	}

	void sub3()
	{
		var z = 0;
		for (var y = 0; y < h; y++) {
			for (var x = 0; x < w; x++) {
				if (c[y][x] == '#') z++;
			}
		}
		if (z == k) cnt++;
	}

	#region Console.Read 関係
	long[] ReadLongArray() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	long ReadLong() => long.Parse(Console.ReadLine());
	#endregion
}


Measured memory_bytes: 27936
function main(input) {
  var a = input.split(" ")[0]-0, b = input.split(" ")[1]-0, c = input.split(" ")[2]-0;
  var base = Math.min(a,b);
  for(var i=base;i>=1;i--){
    if(a%i==0 && b%i==0) c--;
    if(c==0) {console.log(i); return}
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using db = double;
#define pb push_back

ll ans = LLONG_MAX;

void renew(ll a, ll b, ll c) {
	ans = min(ans, max({a, b, c}) - min({a, b, c}));
}

void cal(ll s, ll n, ll m) {
	if (n >= 2) renew(s, n / 2 * m, (n + 1) / 2 * m);
	if (m >= 2) renew(s, m / 2 * n, (m + 1) / 2 * n);
}

int main() {
	ll n, m;
	cin >> n >> m;
	for (ll i = 1; i < n; ++i)
		cal(i * m, n - i, m);
	for (ll i = 1; i < m; ++i)
		cal(i * n, m - i, n);
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	final int LEN = 100000;

	void doIt() {
		String s = sc.next();
		char c[] = s.toCharArray();
		int cnt[] = new int[1000];
		Arrays.fill(cnt, 0);
		for(int i = 0; i < 4; i++) {
			cnt[c[i]]++;
		}
		for(int i = 0; i < 1000; i++) {
			if(cnt[i] == 0 || cnt[i] == 2) continue;
			System.out.println("No");
			return;
		}
		System.out.println("Yes");
	}
	public static void main(String[] args) {
		new Main().doIt();
	}
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int cnt = 15;
    for (char c : s) cnt -= (c == 'x');
    cout << (cnt >= 8 ? "YES" : "NO") << endl;
    return 0;
}

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

#define PI 3.14159265358979323846264338327950L

long double A,B,H,M;

void input(){
    cin >> A >> B >> H >> M;
}

void solve(){
    //角度がわかれば余弦定理から距離がわかる。
    //c^2 = a^2 + b^2 - 2*a*b*cos(theta)
    long double theta = 2.0*PI*((H+M/60.0)/12.0 - M/60.0);
    long double c = sqrtl(A*A + B*B - 2.0*A*B*cosl(theta));
    cout << fixed << setprecision(20) << c << endl;
}

int main(){
    input();
    solve();
    return 0;
}

//4.56425719433005567605

Measured memory_bytes: 3508
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    boolean flg = false;
    for(int i=0; i<=n/4; i++) {
      for(int j=0; j<=n/7; j++) {
        if((4*i+7*j)==n) {
          flg = true;
          break;
        }
      }
    }
    System.out.println(flg==true?"Yes":"No");
  }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

deque<int> split(const string& s)
{
  deque<int> r;
  stringstream ss(s);
  string token;
  while (getline(ss, token, ' ')){
    r.emplace_back(atoi(token.c_str()));
  }
  return r;
}

struct Solver {
  Solver(const string& s){
    R = split(s);
    L = R[0];
    R.pop_front();
    N = R.size();
  }
  bool solve(){
    for (int i = 0; i < (1 << N); i++){
      for (int j = 0; j < N; j++){
        dp[i][j] = 1e9;
      }
    }

    for (int i = 0; i < N; i++){
      dp[1 << i][i] = R[i] * 2;
    }
    for (int i = 0; i < (1 << N); i++){
      for (int j = 0; j < N; j++){
        if (dp[i][j] > 1e8) continue;
        for (int k = 0; k < N; k++){
          if ((i >> k) & 1) continue;
          dp[i | (1 << k)][k] = min(dp[i | (1 << k)][k], dp[i][j] + calc_add_dist(j, k));
        }
      }
    }
    ld mini = 1e9;
    for (int i = 0; i < N; i++){
      mini = min(dp[(1 << N) - 1][i], mini);
    }
    return (ld)L + 1e-9 > mini;
  }
  ld calc_add_dist(int a, int b){
    ld x = sqrt(sq(R[a] + R[b]) - sq(R[a] - R[b]));
    return R[b] + x - R[a];
  }
  deque<int> R;
  int L, N;
  ld dp[1 << 12][12];
};

int main()
{
  string line;
  while (getline(cin, line)){
    Solver sol(line);
    if (sol.solve()) puts("OK");
    else puts("NA");
  }

  return 0;
}

Measured memory_bytes: 1960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

typedef string::const_iterator State;



int main(){fastio
    while(1){
        ll n;cin>>n;
        if(n==0)break;
        vector<l_l>v;
        rep(i,0,n-1){
            string s;cin>>s;
            ll k=s[s.length()-1]-'0';
            if(s[s.length()-1]=='+')k=-1;
            else if(s[s.length()-1]=='*')k=-2;
            v.pb(l_l(s.length(),k));
        }
        reverse(v.begin(),v.end());
        for(ll len=10;len>=2;len--){
            vector<l_l>nv;
            ll vs=v.size();
            ll pos=0;
            while(pos<=vs-1){
                if(v[pos].first==len){
                    queue<ll>q;
                    q.push(v[pos].second);
                    pos++;
                    while(1){
                        if(v[pos].first==len){
                            q.push(v[pos].second);
                            pos++;
                        }else{
                            break;
                        }
                    }
                    if(v[pos].second==-1){
                        ll k=0;
                        while(!q.empty()){
                            k+=q.front();q.pop();
                        }
                        nv.pb(l_l(len-1,k));
                    }else if(v[pos].second==-2){
                        ll k=1;
                        while(!q.empty()){
                            k*=q.front();q.pop();
                        }
                        nv.pb(l_l(len-1,k));
                    }
                    pos++;
                }else{
                    nv.pb(v[pos]);
                    pos++;
                }
            }
            v.clear();
            for(auto x:nv)v.pb(x);
        }
        cout<<v[0].second<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3180
#include <iostream>
#include <fstream>
#include <string> 
#include <cstring>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>

#define BIT(a) (1 << (a))

using namespace std;

long long MOD = 1000000007;

long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

vector<int> X;
vector<int> a;

int main(void){
    int N;
    cin >> N;
    X = vector<int> (N);
    a = vector<int> (N);
    for (int i = 0; i < N; i++){
        cin >> X[i];
        a[i] = X[i];
    }
    sort(X.begin(), X.end());
    int tmp = X[(N+1)/2];
    for (int i = 0; i < N; i++){
        if (a[i] >= tmp){
            cout << X[(N+1)/2-1] << endl;
        }else{
            cout << tmp << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3712
#include<stdio.h>
 int main(void)
 {
     double X,A,B;

     scanf("%lf%lf%lf",&X,&A,&B);

     if(A>=B) printf("delicious\n");
     else if(B-A<X+1) printf("safe\n");
     else if(B-A>=X+1) printf("dangerous\n");

     return 0;
 }



Measured memory_bytes: 128
s = input()
a, d = [0], [0]
for char in s[:-1]:
    if char == 'A':
        a.append(a[-1] + 1)
    else:
        a.append(a[-1])
    if char == '?':
        d.append(d[-1] + 1)
    else:
        d.append(d[-1])

c, e = [0], [0]
for char in s[::-1][:-1]:
    if char == 'C':
        c.append(c[-1] + 1)
    else:
        c.append(c[-1])
    if char == '?':
        e.append(e[-1] + 1)
    else:
        e.append(e[-1])
c = c[::-1]
e = e[::-1]

ret = 0
mod = 10 ** 9 + 7
for char, aa, dd, cc, ee in zip(s, a, d, c, e):
    if char in 'B?':
        tmp1 = aa * pow(3, dd, mod)
        if dd != 0:
            tmp1 += dd * pow(3, dd - 1, mod)

        tmp2 = cc * pow(3, ee, mod)
        if ee != 0:
            tmp2 += ee * pow(3, ee - 1, mod)

        ret += tmp1 * tmp2
        ret %= mod

print(ret)


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int len = s.length();
    // sort(b.begin(), b.end());
    int count = 0;
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
    {
        cout << "Bad" << endl;
    }
    else
    {
        cout << "Good" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a[100000],c,mv=(1LL<<60);
int main(){
    cin>>n;for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++){if(a[i]>=(n+1)){c+=(a[i]-(n+1))/(n+1);a[i]%=(n+1);a[i]+=(n+1);}}
    for(int i=0;i<n;i++)a[i]+=c;
    sort(a,a+n);
    if(a[0]>=(n+1)){
        for(int i=0;i<n;i++)mv=min(mv,a[i]);c+=(mv-n)*n;
        for(int i=0;i<n;i++)a[i]=(a[i]-mv)+n;
    }
    while(true){
        sort(a,a+n);if(a[n-1]<n)break;
        for(int i=0;i<n-1;i++)a[i]++;
        a[n-1]-=n;c++;
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = a + b;


    if (a % 3 == 0 || b % 3 == 0 || x % 3 == 0) {
      System.out.println("Possible");
    } else {
      System.out.println("Impossible");
    }

  }

}


Measured memory_bytes: 23508
//copied
#include<cstdio>
using namespace std;
inline char tc(void){
	static char fl[10000],*A=fl,*B=fl;
	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;
}
inline int read(void){
	int a=0;static char c;
	while((c=tc())<'0'||c>'9');
	while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();
	return a;
}
int n,ans,a[100005];
int main(void){
	register int i;
	n=read();
	for(i=1;i<=n;++i)
		a[i]=read();
	for(i=1;i<=n;++i)
		if(a[i]==i)++ans,++i;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1976
/*program from Wolfycz*/
#include<map>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define Fi first
#define Se second
#define inf 0x7f7f7f7f
#define min(x,y) (x<y?x:y)
#define max(x,y) (x>y?x:y)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline char gc(){
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd(){
	int x=0,f=1; char ch=gc();
	for (;ch<'0'||ch>'9';ch=gc())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=gc())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline void print(int x){
	if (x<0)	putchar('-'),x=-x;
	if (x>9)	print(x/10);
	putchar(x%10+'0');
}
const int N=4e2;
int C[N+10][4];
ll v[N+10];
map<ll,int>Mp;
ll Hash(int a,int b,int c,int d){return ((ll)a<<30)|((ll)b<<20)|((ll)c<<10)|(ll)d;}
void Add(ll x,int v){
	for (int i=0;i<4;i++,x=(x>>10)|((x&1023)<<30)){
		if (Mp.find(x)==Mp.end())	Mp.insert(map<ll,int>::value_type(x,0));
		Mp.find(x)->Se+=v;
	}
}
int main(){
	int n=read(); ll Ans=0;
	for (int i=1;i<=n;i++){
		for (int j=0;j<4;j++)
			C[i][j]=read();
		v[i]=Hash(C[i][0],C[i][1],C[i][2],C[i][3]);
		Add(v[i],1);
	}
	for (int i=1;i<n-4;i++){
		Add(v[i],-1);
		for (int j=i+1;j<=n;j++){
			Add(v[j],-1);
			for (int k=0;k<4;k++){
				static ll A[4];
				A[0]=Hash(C[i][1],C[i][0],C[j][(k+1)%4],C[j][k    %4]);
				A[1]=Hash(C[i][2],C[i][1],C[j][k    %4],C[j][(k+3)%4]);
				A[2]=Hash(C[i][3],C[i][2],C[j][(k+3)%4],C[j][(k+2)%4]);
				A[3]=Hash(C[i][0],C[i][3],C[j][(k+2)%4],C[j][(k+1)%4]);
				int a=0,b=0,c=0,d=0;
				map<ll,int>::iterator it;
				if ((it=Mp.find(A[0]))==Mp.end())	continue;
				else	a=it->Se;
				if ((it=Mp.find(A[1]))==Mp.end())	continue;
				else	b=it->Se;
				if ((it=Mp.find(A[2]))==Mp.end())	continue;
				else	c=it->Se;
				if ((it=Mp.find(A[3]))==Mp.end())	continue;
				else	d=it->Se;
				if (!a||!b||!c||!d)	continue;
				ll res=1;
				for (int l=0;l<4;l++){
					res*=Mp.find(A[l])->Se;
					Add(A[l],-1);
				}
				Ans+=res;
				for (int l=0;l<4;l++)	Add(A[l],1);
			}
			Add(v[j],1);
		}
	}
	printf("%lld\n",Ans);
	return 0;
}

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

int main() {
	int n, k, x, y;
	cin >> n >> k >> x >> y;

	int ans = 0;

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

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

ll ma(ll x, ll y){
    if(x>y)return x;
    return y;
}
int p[100001];
int main(void){
    int n; cin >> n; int ans = 0; int flag = -1;
    for(int i = 1;i <= n;i++)cin >> p[i];
    for(int i = 1;i <= n;i++){
        if(p[i] == i){
            flag*=-1;
            if(flag == -1)ans++;
        }else{
            if(flag == 1){flag = -1;ans++;}
        }
    }
    if(flag == 1)ans++;
    cout << ans << endl;
 	return 0;
}


Measured memory_bytes: 640
using System;

public class hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        Console.WriteLine(getAns(s));
    }
    static int getAns(string s)
    {
        var sL = s.Length;
        var sL2 = sL / 2;
        var ans = 0;
        if (sL % 2 == 1 && (s[sL2] == '(' | s[sL2] == ')')) ans++;
        for (int i = 0; i < sL2; i++)
        {
            var w1 = s[i];
            var w2 = s[sL - 1 - i];
            if (w1 == w2 && (w1 == 'i' | w1 == 'w')) continue;
            else if ((w1 == '(' && w2 == ')') | (w1 == ')' && w2 == '(')) continue;
            ans++;
        }
        return ans;
    }
}




Measured memory_bytes: 17852
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: u64
    }

    println!("{}", if n%10==9||n/10%10==9 {"Yes"} else {"No"});
}

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

#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<LL>
#define VVL vector<vector<LL>>
#define VVVL vector<vector<vector<LL>>>
#define VB vector<bool>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, -1, 0, 1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;


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

    while (true) {
        int n;
        cin >> n;
        if (n == 0) { break; }
        vector<string> field;
        FOR(i, 0, n) {
            string s;
            cin >> s;
            field.emplace_back(s);
        }

        int ans = 0;
        VVI dp(n, VI(n, 0));
        FOR(y, 0, field.size()) {
            FOR(x, 0, field[0].size()) {
                if (field[y][x] == '*') {
                    dp[y][x] = 0;
                } else {
                    if (0 < y and 0 < x) {
                        dp[y][x] = min({dp[y - 1][x], dp[y][x - 1], dp[y - 1][x - 1]}) + 1;
                    } else {
                        dp[y][x] = 1;
                    }
                }

                ans = max(ans, dp[y][x]);
            }
        }
        print(ans);
    }
}



Measured memory_bytes: 7984
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int sz = 2e5+5;
ll int arr[sz]={0},arr1[sz]={0};
//ll int arr[100][100]= {0};
int prime[10005]= {0};
vector <ll int> vec,vec1,vec2;
//vector <pair <int,int>> vec;
set<ll int>st;

int main()
{
    ll int a,b,x;
    cin>>a>>b>>x;

    ll int k = b/x;
    ll int l = a/x;
    k++, l++;
    if(a%x==0)
        l--;

    cout<<k-l<<endl;

}


Measured memory_bytes: 3636
N=int(input())
ct,cx,cy=0,0,0
for i in range(N):
    t,x,y=map(int,input().split())
    dt=t-ct
    dx=x-cx
    dy=y-cy
    if dt<abs(dx)+abs(dy):
        print('No')
        exit()
    elif (dt-(abs(dx)+abs(dy)))%2!=0:
        print('No')
        exit()
    ct=t
    cx=x
    cy=y


print('Yes')

Measured memory_bytes: 9200
#include <iostream>
#include<cstring>
#include<algorithm>
using namespace std;

const int N = 2e5 + 10 ;

typedef long long ll;

int a[N];

int main()
{
    int k,n,ret=0;
    
    cin >>k>> n ;
    
    for(int i =0;i<n;i++)
    {
        cin >> a[i];
        if(i == 0) continue;
        else
        {
            ret = max(a[i]-a[i-1],ret);
        }
    }
    ret =  max(ret, k-a[n-1]+a[0]);
    cout<< k - ret ;
	
	
	return 0 ;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[100005];
int main(){
	scanf("%s",s);
	int n=strlen(s);
	int ans=0;
	for(int i=1;i<n;i++)ans+=s[i]!=s[i-1];
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256