akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;

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

const double EPS = 1e-10;
const int INF = 1e7;

int main(){
  int h, w;
  scanf("%d%d", &h, &w);
  vector<string> vec_s;
  string s;
  for (int i=0; i<h; ++i) {
  	cin >> s;
    vec_s.push_back(s);
  }
  bool is_suc = true;
  for (int i=0; i<h; ++i) {
  	for (int j=0; j<w; ++j) {
      if (vec_s[i][j] == '#') {
        if (i-1 >=0 && vec_s[i-1][j] == '#') {
          continue;
      	}
        if (i+1 < h && vec_s[i+1][j] == '#') {
          continue;
      	}
        if (j-1 >=0 && vec_s[i][j-1] == '#') {
          continue;
      	}
        if (j+1 < w && vec_s[i][j+1] == '#') {
          continue;
      	}
        is_suc = false;
      }
    }
  }
  if (is_suc){
    std::cout << "Yes\n";
  } else {
    std::cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 256
#define watch5(a,b,c,d,e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d << " | "<<#e<<": "<<e<<endl;
#define watch4(a,b,c,d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define watch3(a,b,c) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define sharingan cerr << "\n-------------------------------------------\n\n";
#define watch2(a,b) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<< endl;
#define Yup ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(a) cerr <<#a<<": "<<a<<endl;
#define __gcd(a, b) __algo_gcd(a, b)
#define PI 3.14159265358979323846
#define mod 1000000007
#include "bits/stdc++.h"
using namespace std;
#define int long long

string s, t;

int dp[3001][3001];

int f( int i, int j ){
    if( i == s.size() || j == t.size() )return 0;
    if( dp[i][j] != -1 )return dp[i][j];
    int len = 0;
    if( s[i] == t[j] ){
        len = 1 + f(i+1, j+1);
    }
    else{
        len = f(i+1, j);
        len = max(len, f(i, j+1));
    }
    dp[i][j] = len;
    return len;
}

void print( int i, int j, int l ){
    if( l == 0 )return;
    if( s[i] == t[j] && dp[i][j] == l ){
        cout << s[i];
        print(i+1, j+1, l-1);
    }
    else{
        if( dp[i+1][j] == l ){
            print(i+1, j, l);
        }
        else{
            print(i, j+1, l);
        }
    }
}

int32_t main(){
    memset(dp, -1, sizeof(dp));
    cin >> s >> t;
    int l = f(0, 0);
    print(0, 0, l);
}

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

int main() {
  int N,abc;
  abc =0;
  cin >> N;
  for(int i=0;i<N;i++){
    string S;
    cin >> S;
    if(S=="Y"){
      abc=1;
      break;
    }
  }
   if(abc==1){
      cout << "Four" << endl;
    }else{
      cout << "Three" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int x,y;
	scanf("%d",&x);
	y=x%7;
	if(y==1) printf("fri\n");
	if(y==2) printf("sat\n");
	if(y==3) printf("sun\n");
	if(y==4) printf("mon\n");
	if(y==5) printf("tue\n");
	if(y==6) printf("wed\n");
	if(y==0) printf("thu\n");
		
	return 0;
}


Measured memory_bytes: 2080
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end() //使うときはsort(all())という感じで
using ll = long long;
#define PI 3.14159265359

int main(void){
  string s;
  cin>>s;
  rep(i,s.size()){
    cout<<'x';
  }
  cout<<endl;
  return 0;
}


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

const int A = 1000005;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> c(A);
    
    for (int i = 0; i < n; i++ ) {
        cin >> a[i];
        c[a[i]]++;
    }
    int pairwise = true;
    for (int i = 2; i < A; i++) {
        int cnt = 0;
        for (int j = i; j < A; j += i) {
            cnt += c[j];
        }
        if (cnt > 1) {
            pairwise = false;
            break;
        }
    }
    if (pairwise) {
        cout << "pairwise coprime" << endl;
        return 0;
    } else {
        int g = 0;
        for (int i = 0; i < n; i++) {
            g = gcd(g, a[i]);
            if (g == 1) {
                cout << "setwise coprime" << "\n";
                return 0;
            }
        }
    }
    cout << "not coprime" << "\n";
    return 0;
}

Measured memory_bytes: 11116
using System;
class Product
{
	static void Main(string[] args)
	{
		string[] s = Console.ReadLine().Split(' ');
		int a = int.Parse(s[0]);
		int b = int.Parse(s[1]);
		int k = int.Parse(s[2]);
		
		for(int i = a; i <= b; i++)
		{
			if(i < a + k || i > b - k)
				Console.WriteLine(i);
		}
	}
}

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

typedef long long ll;
const ll MOD = 1e9+7;

int n,k;
int a[105];
bool dp[100005];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i];

    for(int i=1;i<=k;i++){
        for(int j=1;j<=n;j++){
            if(i-a[j]>=0){
                dp[i]|=(!dp[i-a[j]]);
            }
        }
    }
    if(dp[k])cout<<"First";
    else cout<<"Second";
    return 0;
}


Measured memory_bytes: 384
S = input()
arr = []
for s in S:
    arr.append(s)
if (arr[0] == arr[1]):
    if (arr[0] != arr[2] and arr[2] == arr[3]):
        ans = "Yes"
    else:
        ans = "No"
else:
    if (arr.count(arr[0]) == 2 and arr.count(arr[1]) == 2):
        ans = "Yes"
    else:
        ans = "No"

print(ans)



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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

int N, C;
int D[31][31], c[501][501];
vector<int> change[3];
int sum[3][31] = {};


int getDef(){
	int ret = 0;
	for(int i = 0; i < 3; i++){
		for(int j = 1; j <= 30; j++){
			for(int k = 0; k < change[i].size(); k++){
				sum[i][j] += D[ change[i][k] ][j];
			}
		}
	}

	return ret;
}

int main(){
	cin >> N >> C;
	for(int i = 1; i <= C; i++){
		for(int j = 1; j <= C; j++){
			cin >> D[i][j];
		}
	}
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= N; j++){
			cin >> c[i][j];
			change[(i+j)%3].pb(c[i][j]);
		}
	}

	getDef();

	int ret = inf;
	for(int i = 1; i <= C; i++){
		int sum1 = sum[0][i];
		for(int j = 1; j <= C; j++){
			if(i == j) continue;
			int sum2 = sum[1][j];
			for(int k = 1; k <= C; k++){
				if(i == k || j == k) continue;
				int sum3 = sum[2][k];
				ret = min(ret, sum1 + sum2 + sum3);
			}
		}
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 2416
/***
بسم الله الرحمن الرحيم
اللهم ما صلّ على سيدنا محمد
اذكر الله
واتقوا يوما ترجعون فيه إلى الله ثم توفى كل نفس ما كسبت وهم لا يظلمون
****/

#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define shalaby ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);cerr.tie(0);

using namespace std;

inline int D()
{
    int t;
    scanf("%d",&t);
    return t;
}
inline ll llD()
{
    ll t;
    scanf("%lld",&t);
    return t;
}

const ll OO=-1e18;
int xt[4]= {1,0,0,-1};
int yt[4]= {0,1,-1,0};
////////////////////////////////////////////////////////////////////////////////////
const int N = 1e6+1;
int mem[200005],n,m,mod=1e9+7,cnt;
bool valid(int x,int y)
{
    return x>-1 && y>-1 && x<n && y<m;
}
void init()
{
    memset(mem,-1,sizeof mem);
}
bool visited[200005];
vector <int> adj[200005];
int dfs(int s)
{
    int &ret=mem[s];
    if(~ret)return ret;
       ret=0;
      /// visited[s] = true;

    for(int i = 0; i < adj[s].size(); ++i)
    {
        if(visited[adj[s][i]] == false)
        {
            ret= max(ret, dfs(adj[s][i])+1);
        }
    }
    return ret;
}
int main()
{
    init();
    int x,y;
    cin >> n;
    cin >> m;
    for(int i = 0; i < m; ++i)
    {
        cin >> x >> y;
        adj[x].push_back(y);
    }
    int mx=0,mn=2000006;
    for(int i = 1; i <= n; ++i)
    {
            cnt= dfs(i);
            mx=max(cnt,mx);
        }

    cout<<mx;
}




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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

const string YES = "Yes";
const string NO = "No";

void func(long long H, long long N, std::vector<long long> A){
    long long sum = 0;
    for (auto v : A) {
        sum += v;
    }
    cout << (sum>=H? YES:NO) << endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    func(H, N, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;
using int64 = long long;

vector<bool> primes(int n) {
    vector<bool> prime(n+1, true);
    prime[0] = prime[1] = false;
    for (int64 i=4; i<=n; i+=2) prime[i] = false;
    for (int64 i=3; i<=n; i+=2) {
        if (prime[i]) {
            for (int64 j=i*i; j<=n; j+=i) {
                prime[j] = false;
            }
        }
    }
    return prime;
}

int main() {
    int q;
    cin >> q;
    vector<bool> prime = primes(100000);
    vector<int> dp(100002, 0);
    for (int i=1; i<=100000; i++) {
        dp[i] += prime[i] && prime[(i+1)/2];
        dp[i] += dp[i-1];
    }



    for (int i=0; i<q; i++) {
        int l,r;
        cin >> l >> r;
        cout << dp[r] - dp[l-1] << endl;
    }

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int N,C;
int s[100000],t[100000],c[100000];
int sm[200002],tt[200002];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>N>>C;
    REP(i,N){
        cin>>s[i]>>t[i]>>c[i];
    }

    for(int i=1;i<=C;i++){
        for(int j=0;j<200002;j++) tt[j]=0;
        for(int j=0;j<N;j++) if(c[j]==i) tt[s[j]*2-1]++,tt[t[j]*2]--;
        for(int j=1;j<200002;j++) tt[j]+=tt[j-1];
        for(int j=0;j<200002;j++) if(tt[j]>0)sm[j]++;
    }
    int ma=0;
    for(int j=0;j<200002;j++) if(ma<sm[j]) ma=sm[j];
    cout<<ma<<endl;
}

Measured memory_bytes: 2944
import numpy as np
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
li = [a,b,c,d,e]
li_min = min(li)
ans = int(np.ceil(n/li_min)) + 4
print(ans)

Measured memory_bytes: 12508
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


int BIT[200001];

void add(int A) {
	while (A > 0) {
		BIT[A]++;
		A -= A & -A;
	}
}

int query(int A) {
	int kotae = 0;
	while (A <= 200000) {
		kotae += BIT[A];
		A += A & -A;
	}
	return kotae;
}


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


	char S[200000];
	scanf("%s", S);
	int N = strlen(S);
	vector<int> V[26];
	rep(i, N) V[S[i] - 'a'].pb(i);
	int kisuu = 0;
	rep(i, 26) if (V[i].size() & 1) kisuu++;
	if (kisuu > 1) {
		printf("-1");
		return 0;
	}
	int kazu = 0;
	ll kotae = 0;
	int atta = 0;
	rep(i, N) {
		if (kazu * 2 >= N - 1) break;
		if (S[i] >= 'a') {
			int kari = V[S[i] - 'a'].back();
			if (i == kari) {
				atta = 1;
				continue;
			}
			kotae += N - kari - 1 - query(kari) + atta;
			S[kari] = 0;
			add(kari);
			V[S[i] - 'a'].pop_back();
			kazu++;
		}
	}
	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 1912
#include <iostream>
using namespace std;
 
int main() {
 
int a;int b;
cin >>a;cin >>b;
if (a>b) {cout<<"a > b" << endl;}
else if (a==b) {cout << "a == b"<<endl;}
else {std::cout << "a < b"<<endl;};
return 0 ;}


Measured memory_bytes: 3020
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

map<int, int> mp;

void bunkai(int val){
  int i = 2;
  while(val >= i * i){
    if(val%i == 0){
      val /= i;
      mp[i]++;
    }
    else{
      i++;
    }
  }
  mp[val]++;
}

int
main(void){  
  ios_base::sync_with_stdio(false);

  int n;
  int ans2=0, ans4=0, mid=0;
  cin >> n;
  
  REP(i, n) {
    int tmp;
    mp.clear();
    cin >> tmp;
    bunkai(tmp);
    if(mp[2] > 1) ans4++;
    else if(mp[2] > 0) ans2++;
  }

  //cout << ans2 << " " << ans4 << endl;
  
  if(n/2 <= ans4 || n <= ans2 || n/2 <= ans4+(ans2/2)) cout << "Yes" << endl;
  else cout << "No" << endl;
  /*
    n = 2:
    ans4 = 1 or ans2 = 2
    n = 3:
    ans4 = 1 or ans2 = 3
    n = 4:
    ans4 = 2 or ans4 = 1 ans2 = 2 or ans2 = 4
    n = 5:
    ans4 = 2 or ans4 = 1 ans2 = 2 or ans2 = 5
   */
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

struct data{
    int a;
    int b;
};

int main(){
    int n,m,tsum, hsum, t[105], h[105];
    struct data ans;
    while(cin >> n >> m, n||m){
        tsum = hsum = 0;
        ans.a = ans.b = 2 << 24;
        rep(i,n){
            cin >> t[i];
            tsum+= t[i];
        }
        rep(i,m){
            cin >> h[i];
            hsum+= h[i];
        }
        rep(i,n){
            rep(j,m){
                if(tsum - t[i] + h[j] == hsum - h[j] + t[i] && ans.a + ans.b > t[i] + h[j]){
                    ans.a = t[i];
                    ans.b = h[j];
                }
            }
        }
        if(ans.a == 2 << 24)
            cout << "-1" << endl;
            else
                cout << ans.a << ' ' << ans.b << endl;
    }
}

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

int main(){
int a,b,c,x,y;
cin>>a>>b>>c>>x>>y;
int ans;
if((a+b)>2*c){
if(x>=y){
ans=y*2*c+(x-y)*a;

}else{
ans=x*2*c+(y-x)*b;

}
if(ans>(2*c*max(x,y))){
ans=2*c*max(x,y);
}


}else{
ans=a*x+b*y;



}
cout<<ans<<endl;

}

Measured memory_bytes: 3668
using System;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var a = int.Parse(_[0]);
            var b = int.Parse(_[1]);
            var c = int.Parse(_[2]);
            var d = int.Parse(_[3]);

            var s = Math.Max(a, c);
            var e = Math.Min(b, d);
            var t = e - s;

            Console.WriteLine(t >= 0 ? t : 0);
        }
    }
}


Measured memory_bytes: 13140
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
hash = Hash.new(0)
a.each do |i|
    hash[i] += 1
end
count = 0
hash.each do |j|
    if j[0] == j[1]
        next
    elsif j[0] < j[1]
        count += j[1] - j[0]
    elsif j[0] > j[1]
        count += j[1]
    end
end
puts count

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;

  if (a+b==c+d) {
    cout << "Balanced" << endl;
  }
  else if (a+b>c+d) {
    cout << "Left" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}


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

int main(int argc, const char * argv[]) {
    
    int N, X;
    cin >> N >> X;
    vector<int> m(N);
    for (int i = 0; i < N; i++) {
        cin >> m.at(i);
        X -= m.at(i);
    }
    
    int ans = N;
    sort(m.begin(), m.end());
    ans += (X / m.at(0));
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#ifdef _DEBUG
#define dd(x) cout << #x << " : " << x << endl
#else
#define dd(x)
#endif
using namespace std;
using ll = int64_t;

constexpr int SIZE = 1e6;
struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n = 1) : n(n), f(n + 1) {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; ++i) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i * i; j <= n; j += i) {
                if (!f[j]) f[j] = i;
            }
        }
    }
    bool isPrime(int x) { return f[x] == x; }
    vector<int> factorList(int x) {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<pair<int, int>> factor(int x) {
        vector<int> fl = factorList(x);
        if (fl.size() == 0) return {};
        vector<pair<int, int>> res(1, {fl[0], 0});
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
};

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

    Sieve s(SIZE);

    for(int i = x; i <= SIZE; i++) {
        if(s.f[i] == i) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 7812
#include<stdio.h>

int main() {
    int n,i;
    char s[11];
    long cm = 0, ca = 0, cr = 0, cc = 0, ch = 0,ans=0;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s", &s);
        if (s[0] == 'M')
            cm++;
        if (s[0] == 'A')
            ca++;
        if (s[0] == 'R')
            cr++;
        if (s[0] == 'C')
            cc++;
        if (s[0] == 'H')
            ch++;
    }
    ans += cm * ca*cr;
    ans += cm * ca*cc;
    ans += cm * ca*ch;
    ans += cm * cr*cc;
    ans += cm * cr*ch;
    ans += cm * cc*ch;
    ans += ca * cr*cc;
    ans += ca * cr*ch;
    ans += ca * cc*ch;
    ans += cr * cc*ch;
    printf("%ld", ans);
    return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

double func(vector<int> a,vector<int> b,int d) {
	double ans = 0;
	for (int i = 0; i < d; i++) {
		ans += (a[i] - b[i]) * (a[i] - b[i]);
	}
	return sqrt(ans);
}

int main() {
	int n, d;
	int i, j;
	int count = 0;
	cin >> n >> d;
	vector<vector<int>> x(n, vector<int>(d));
	for (i = 0; i < n; i++) {
		for (j = 0; j < d; j++) {
			cin >> x[i][j];
		}
	}
	for (i = 0; i < n-1; i++) {
		for (j = i + 1; j < n; j++) {
			double c = func(x[i], x[j],d);
			if (c - (int)c == 0)count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;

ll mpow(ll x, ll n){
ll ans = 1;
while(n != 0){
if(n&1) ans = ans*x % mod;
x = x*x % mod;
n = n >> 1;
}
return ans;
}


int main() {
    int n;
    ll a,b,c;
    cin >> n >> a >> b >> c;
    ll ans=0;
    vector<ll> kj(n+1),gj(n+1);
    kj[0]=1;gj[0]=1;
    rep(i,n){
        (kj[i+1]=kj[i]*(i+1))%=mod;
        (gj[i+1]=gj[i]*mpow(i+1,mod-2))%=mod;
    }
    ll k=kj[n];
    vector<ll> co(n+1);
    rep(i,n+1){
        co[i]=((k*gj[n-i])%mod)*gj[i]%mod;
    }
    rep(i,n+1){
        ll t=c-i*b;
        ll u=t/a;
        if (t%a==0 && u>=0 && u<n+1){
            (ans+=co[u]*co[i]%mod)%=mod;
        }
    }
    cout << ans << endl;
}


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

using namespace std;
struct ans {
  int fx;
  int fy;
  int tx;
  int ty;
  friend ostream &operator<<(ostream &o, const ans &a) {
    o << (a.fx + 1) << " " << (a.fy + 1) << " " << (a.tx + 1) << " " << (a.ty + 1);
    return o;
  }
};

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

  int h, w;
  cin >> h >> w;
  vector<vector<int>> field(h, vector<int>(w));
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> field[i][j];
      field[i][j] %= 2;
    }
  }

  vector<ans> answer;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (field[i][j] == 1) {
        if (0 < i) {
          if (field[i - 1][j] == 1) {
            answer.push_back(ans{i, j, i - 1, j});
            field[i - 1][j] = field[i][j] = 0;
            continue;
          }
        }
        if (0 < j) {
          if (field[i][j - 1] == 1) {
            answer.push_back(ans{i, j, i, j - 1});
            field[i][j - 1] = field[i][j] = 0;
            continue;
          }
        }
        if (j < w - 1) {
          if (field[i][j + 1] == 1) {
            answer.push_back(ans{i, j, i, j + 1});
            field[i][j + 1] = field[i][j] = 0;
            continue;
          }
        }
        if (i < h - 1) {
          if (field[i + 1][j] == 1) {
            answer.push_back(ans{i, j, i + 1, j});
            field[i + 1][j] = field[i][j] = 0;
            continue;
          }
        }
        if (j < w - 1) {
          answer.push_back(ans{i, j, i, j + 1});
          field[i][j] = 0;
          field[i][j + 1] = 1;
          continue;
        }
        if (i < h - 1) {
          answer.push_back(ans{i, j, i + 1, j});
          field[i][j] = 0;
          field[i + 1][j] = 1;
          continue;
        }
      }
    }
  }
  /*
  for (auto &row : field) {
    for (auto &e : row) {
      cout << e << " ";
    }
    cout << "\n";
  }
  cout << "\n";
  */
  cout << answer.size() << "\n";
  for (auto &a : answer) {
    cout << a << "\n";
  }
}


Measured memory_bytes: 5236
using System;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Collections.Generic;

namespace cs_pro_0906
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            //これではスペース区切りに対抗できない
            //int a = int.Parse(Console.ReadLine());
            //int b = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');//一行入力を、スペース区切りごとに受け入れる
            int a = int.Parse(str[0]);//０番目
            int b = int.Parse(str[1]);//１番目


            if(a*b%2 == 0)
            {
                Console.WriteLine("Even");
            }
            else Console.WriteLine("Odd");

        }
        
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename... Types>
struct dynarr: std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto&& operator[](size_type i) { return this->at(i); }
  auto&& operator[](size_type i) const { return this->at(i); }
};

int main() {
  i64 a, b;
  cin >> a >> b;
  if(a < 10 && b < 10) {
    cout << a * b << endl;
  } 
  else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		String b = sc.next();
		b = b.replace(".", "");
		long b100 = Long.parseLong(b);
		long answer = a * b100;
		System.out.println(answer/100);
	}

}

Measured memory_bytes: 35808
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 998244353;

int main() {
	
	char a;
	cin >> a;

	cout << (0 <= a - 'a' && a - 'a' <= 25 ? "a" : "A") << endl;

}

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

int main()
{
    vector<int> v;
    for(int i = 0; i < 3; i++){
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    if(v.at(0) + v.at(1) == v.at(2)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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


int main () {

 int K,S,ans=0;
 cin >> K >> S;

 for(int i = 0; i <= K; i++) {
  for(int j = 0; j <= K; j++) {
   int k = S - (i + j);
   if(k >= 0 && k <= K) {
    ans++;
    }
  }
 }

 cout << ans << endl;
 return 0;
}

Measured memory_bytes: 384
# include "cmath"
# include "queue"
# include "cstdio"
# include "cstring"
# include "iostream"
# include "algorithm"
# define Maxn
# define fi first
# define se second
# define P pair<int,int>
# define rep(i,x,y) for(int i=x;i<=y;i++)
# define rep_d(i,x,y) for(int i=x;i>=y;i--)
# define rep_t(u) for(int i=head[u];i;i=f[i].next)
using namespace std;
typedef long long ll;
inline int read()
{
	int ok=1,k=0;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')
		ok=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		k=k*10+c-'0';
		c=getchar();
	}
	return ok*k;
}
int main()
{
	int a,b;
	a=read();
	b=read();
	printf("%d\n",max(a-2*b,0));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

signed main() {
    string S;
    cin >> S;
    vector<int> ans(S.length() + 1, 0);
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == '<') ans[i + 1] = ans[i] + 1;
    }
    for (int i = S.length() - 1; i >= 0; i--) {
        if (S[i] == '>') ans[i] = max(ans[i], ans[i + 1] + 1);
    }
    cout << accumulate(ans.begin(), ans.end(), 0LL) << endl;
}


Measured memory_bytes: 4740
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int out = 1;
        if(a != b && b != c && c != a){
            out = 3;
        }else if((a == b && b != c) ||( a != b && b == c) || (a == c && a != b)){
            out = 2;
        }
        System.out.println(out);
    }
}

Measured memory_bytes: 21204
#include<iostream>
#include<string>
using namespace std;
int N_MAX=100000;
int main()
{
  int n,i,j,k,jj,kk;
  int a[3];
  string s,sb;
  char res[N_MAX];
  cin >> n >> a[0] >> a[1] >> a[2];
  cin >> sb;
  for(i=0;i<n;i++){
    if(i<n-1)
      cin >> s;
    j=(int)(sb[0]-'A');
    k=(int)(sb[1]-'A');
    jj=(int)(s[0]-'A');
    kk=(int)(s[1]-'A');
    if(a[j]==0&&a[k]==0){
      cout << "No" << endl;
      return 0;
    }
    if(a[j]>a[k]
       ||a[j]==a[k]&&(i==n-1||k==jj&&a[kk]==0||k==kk&&a[jj]==0)){
      a[j]--;
      a[k]++;
      res[i]=(char)('A'+k);
    }else{
      a[j]++;
      a[k]--;
      res[i]=(char)('A'+j);
    }
    sb=s;
  }
  cout << "Yes" << endl;
  for(i=0;i<n;i++)
    cout << res[i] << endl;
  return 0;
}

Measured memory_bytes: 3192
H,W,D=map(int,input().split())
data=[]
for i in range(1,H+1):
    tmp=list(map(int,input().split()))
    for j in range(1,W+1):
        data.append([i,j,tmp[j-1]])

data.sort(key=lambda x:x[2])

ruiseki=[]
for i in range(D):
    tmp=[0]
    j=i+D
    while(j<H*W):
        tmp.append( abs(data[j][0]-data[j-D][0]) +abs(data[j][1]-data[j-D][1]) +tmp[-1])
        j+=D
    ruiseki.append(tmp)

Q=int(input())
for _ in range(Q):
    l,r=map(int,input().split())
    ind=l%D-1
    if(ind==-1):
        l-=D
        r-=D
    print(ruiseki[ind][r//D] - ruiseki[ind][l//D])

Measured memory_bytes: 25316
use proconio::input;
use proconio::marker::Bytes;

fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        css: [Bytes; h],
    }

    let mut ans = 0;
    for mask_i in 0..1 << h {
        for mask_j in 0..1 << w {
            let mut n = 0;
            for i in 0..h {
                for j in 0..w {
                    if (mask_i >> i) & 1 == 0 && (mask_j >> j) & 1 == 0 && css[i][j] == b'#' {
                        n += 1;
                    }
                }
            }
            if n == k {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2192
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main(){
    int n;
    int l;
    vector<int> v;
    cin >> n;
    
    int i;
    
    for(i = 0; i < n; i++){
        cin >> l;
        v.push_back(l);
    }
    
    sort(v.begin(), v.end());
    
    int sum = 0;
    
    for(i = 0; i < n-1; i++){
        sum += v[i];
    }
    
    if(sum > v[n-1]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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


int main()
{
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a <= k)
	{
		cout << "Yay!" << endl;
	}
	else
	{
		cout << ":(" << endl;
	}
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <algorithm>
#define ll long long
using namespace std;
const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;
char s[1005];
int main()
{
    while(~scanf("%s",&s))
    {
        int ls=strlen(s);
        if(ls==1&&s[0]=='0')
        break;
        int ans=0;
        for(int i=0;i<ls;++i)
        ans+=s[i]-'0';
        printf("%d\n",ans);
    }
    return 0;
}



Measured memory_bytes: 3132
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int xday = sc.nextInt();
        int before = sc.nextInt();
        int eat = sc.nextInt();
        int j = Math.abs(before - eat);
        
        if(before - eat >= 0){
            System.out.println("delicious");
        }else if(before - eat < 0 && j <= xday){
            System.out.println("safe");
        }else{
            System.out.println("dangerous");
        }
    }
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int k; cin >> k;
    queue<ll> qu;

    for(ll i = 1; i < 10;i++) qu.push(i);

    while(k > 0){
        ll n = qu.front();
        qu.pop();
        k--;
        if(k==0) cout << n << endl;
        ll m = n%10;
        if(m != 0) qu.push(n*10+m-1);
        qu.push(n*10+m);
        if(m != 9) qu.push(n*10+m+1);
    }
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;
int dp[101][101];vector<P> v;
const int INF=(1<<31)-1;
int dfs(int d,int u){
	if(u==d) return 0;
	if(dp[d][u]!=INF) return dp[d][u];
	int minCost=INF;
	for(int i = d; i < u; i++)
		minCost=min(minCost,v[d].second*v[u].first*v[i].first*v[i+1].second+dfs(d,i)+dfs(i+1,u));
	dp[d][u]=minCost;
	return dp[d][u];
}
int main(){
	int n;cin>>n;
	for(int i = 0; i < n; i++){
		int over,down;
		cin>>over>>down;
		v.push_back(P(over,down));
	}
	reverse(v.begin(),v.end());
	for(int i = 0; i < 101; i++)
		fill(dp[i],dp[i]+101,INF);
	cout<<dfs(0,n-1)<<endl;
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(){
  int X, Y;
  scanf("%d %d", &X, &Y);
  
  if(Y%2 == 0){
    if((2*X>=Y/2) && (X<=Y/2)){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1648
#map(int,input().split())
#int(x) for x in input().split()
#for _ in range(int(input())):
x,y=map(int,input().split())
if y%2!=0:
	print('No')
elif y>=x*2 and y<=x*4:
	print('Yes')
else:
	print('No')


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

ll modu = 1000000007;

// Refer to https://cp-algorithms.com/algebra/extended-euclid-algorithm.html
// a*x + b*y = gcd(a, b)
ll gcdExtended(ll a, ll b, ll *x, ll *y) {
   if (a == 0) {
      *x = 0;
      *y = 1;
      return b;
   }
   ll x1, y1;
   ll gcd = gcdExtended(b%a, a, &x1, &y1);
   *x = y1 - (b/a) * x1; //b mod a
   *y = x1;
   return gcd;
}

// Refer to https://en.wikipedia.org/wiki/Modular_multiplicative_inverse
ll modInverse(ll b, ll m) { 
    ll x, y;
    ll g = gcdExtended(b, m, &x, &y);
    if (g != 1) return -1;
    return (x%m + m) % m;
    
}

ll modDiv(ll a, ll b, ll m) {
  a %= m;
  ll inv = modInverse(b, m);
  return (a * inv) % m;
}

ll nCr(ll n, ll r) {
  ll res = 1;
  for (ll i = 1; i <= r; i++) {
    res *= n-i+1;
    res = modDiv(res, i, modu);
  }
  return res;
}

int main() {
  int n, k; cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    ll com = nCr(k-1, i-1)%modu;
    ll slot = nCr(n-k+1, i)%modu;
    ll ans = com*slot;
    cout << ans % modu << endl;
  }
  return 0;
}

Measured memory_bytes: 256
S = input()

if S == S[::-1] and S[:int((len(S)-1)/2):] == S[:int((len(S)-1)/2):-1] and S[int((len(S)+3)/2-1):] == S[:int((len(S)+3)/2-2):-1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
long long int gcd(long long int l, long long int r) {
	assert(l > 0 && r > 0);
	if (l > r)return gcd(r, l);
	else {
		const long long int num = r%l;
		if (num) {
			return gcd(l, num);
		}
		else {
			return l;
		}
	}
}
long long int lca(long long int l, long long int r) {
	return l / gcd(l, r)*r;
}

long long int gcd(vector<long long int>nums) {
	if (nums.size() == 1)return nums[0];
	long long int num = nums[0];
	
	for (int i = 1; i < nums.size(); ++i) {
		num = gcd(num, nums[i]);
	}
	return num;
}

long long int lca(const vector<long long int>&nums) {
	if (nums.size() == 1)return nums[0];
	else {
		long long int num = nums[0];
		for (int i = 1; i < nums.size(); ++i) {
			num = lca(num, nums[i]);
		}
		return num;
	}
}
int main() {
	while (1) {
		vector<long long int>as(3), ms(3),backs(3);
		for (int i = 0; i < 3; ++i)cin >> as[i] >> ms[i];
		if (!as[0])break;
		for (int i = 0; i < 3; ++i) {
			long long  int now = 1;
			while (backs[i]++,true) {
				now = (now*as[i]) % ms[i];
				if (now == 1)break;
			}
		}
		long long int ans = lca(backs);
		cout << ans << endl;
	}
	return 0;
}

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

#define fo(i, n) for(ll i = 0; i < n; i++)
#define endl "\n"
#define of(i, n) for(ll i = n - 1; i >= 0; i--)
#define ll long long
#define vec vector<ll>
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define rep(i,j,n) for (int i = j; i <= n; ++i)
ll mod= 1e9+7;


int dx[4]={0,-1,0,1};
int dy[4]={1,0,-1,0};
int vis[600][600];
int cnt=0,k;
ll n,m;
//int a[600][600];
vector<string> v;
vector<pair<int,int> > str;
int cnt2=0;
bool check(int x,int y){
    if(x<n && x>=0 && y<m && y>=0)return 1;
    return 0;
}

void dfs(int x,int y)
{
    vis[x][y]=1;
    cnt++;
    //cout<<cnt<<" "<<x<<" "<<y<<endl;
    if(v[x][y]=='.' && cnt>cnt2-k)
    {
        //cout<<cnt<<" "<<x<<" "<<y<<endl;
        str.push_back(make_pair(x,y));
    }
    rep(i,0,3)
    {
        int xx = x+dx[i];
        int yy = y+dy[i];
        if(check(xx,yy) && vis[xx][yy]==0)
        {
            if(v[xx][yy]=='.') dfs(xx,yy);
        }
    }



}

int main()
{
    double pi = 3.1415926535897932384;
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double t = h+m/60;
    double hx,hy,mx,my;
    hx = a*sin(t/12*2*pi);
    hy = a*cos(t/12*2*pi);
    mx = b*sin(t*2*pi);
    my = b*cos(t*2*pi);

    cout<<setprecision(15)<<sqrt((hx-mx)*(hx-mx) + (hy-my)*(hy-my));


}


Measured memory_bytes: 4164
N = int(input())
kushi = 2 * N

l = input().rstrip().split(" ")
L = []
for i in range(kushi):
    L.append(int(l[i]))

L.sort()
x = 0
for i in range(len(L)):
    if i % 2 == 0:
        x += L[i]
print(x)

Measured memory_bytes: 3060
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 

int main(){
    fastio
    int x , y , z , a , b ; 
    cin >> x >> y >> z >> a >> b ; 
    int ans = 1e9 + 10 ;
    ans = min(ans,x*a+y*b) ;  
    debug() << imie(ans) ; 
    ans = min(ans,b*2*z+ max(0,(a - (b*2)/2)*x));
    debug() << imie(ans) ; 
    ans = min(ans,a*2*z+ max(0,(b - (a*2)/2)*y) );
    debug() << imie(ans) ; 
    ans = min(ans,(a+b)*2*z) ; 
    debug() << imie(ans) ; 
    cout << ans << 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 n = sc.nextInt();
		boolean flag = false;
		for(int i = 0; i * 4 <= n; i++) {
			for(int j = 0; j * 7 + i * 4 <= n; j++) {
				if(j * 7 + i * 4 == n) {
					flag = true;
				}
			}
		}
		if(flag) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23124
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
using namespace std;

int main() {
	int ar[5];
	while (scanf("%d,%d,%d,%d,%d", &ar[0], &ar[1], &ar[2], &ar[3], &ar[4])+1) {
		sort(ar, ar + 5);
		int a = ar[0];
		int b = ar[1];
		int c = ar[2];
		int d = ar[3];
		int e = ar[4];

		if (a == d || b == e) { cout << "four card" << endl; }
		else if (a == c && d == e) { cout << "full house" << endl; }
		else if (a == b && c == e) { cout << "full house" << endl; }
		else if (b - a == 1 && c - b == 1 && d - c == 1 && e - d == 1) { cout << "straight" << endl; }
		else if (a == 1 && b == 10 && c == 11 && d == 12 && e == 13) { cout << "straight" << endl; }
		else if (a == c || b == d || c == e) { cout << "three card" << endl; }
		else if (a==b&&c==d) { cout << "two pair" << endl; }
		else if (a == b&&d == e) { cout << "two pair" << endl; }
		else if (b == c&&d == e) { cout << "two pair" << endl; }
		else if (a == b || b == c || c == d || d == e) { cout << "one pair" << endl; }
		else { cout << "null" << endl; }
	}
	return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
    ll n, k;
    cin >> n >> k;
    int seen[n] = {0};
    vector<int> a(n), r;
    rep(i, n) cin >> a[i], a[i]--;
    int p = 0, time = 0;
    r.push_back(0);
    seen[0] = 1;
    while(1) { //次の場所に来ていない
        if(seen[a[p]]) {
            r.push_back(a[p]);
            break;
        }
        r.push_back(a[p]);
        seen[a[p]] = 1; //来たらチェック
        p = a[p];       //次の場所
    }

    //ループ開始を取得
    int start;
    rep(i, n) {
        if(r[i] == r[r.size() - 1]) {
            start = i;
            break;
        }
    }
    if(k <= start) { // ループが始まるより少ない
        cout << r[k] + 1 << endl;
    } else {
        cout << r[start + (k - start) % (r.size() - 1 - start)] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 5832
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep2(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
const ll INF = ll(1e15)+10;
const int MOD = int(1e9)+7;
const ld EPS = 1e-10;

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
  long long val;
  constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
    if (val < 0) val += MOD;
  }
  constexpr int getmod() { return MOD; }
  constexpr Fp operator - () const noexcept {
    return val ? MOD - val : 0;
  }
  constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
  constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
  constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
  constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
  constexpr Fp& operator += (const Fp& r) noexcept {
    val += r.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  constexpr Fp& operator -= (const Fp& r) noexcept {
    val -= r.val;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr Fp& operator *= (const Fp& r) noexcept {
    val = val * r.val % MOD;
    return *this;
  }
  constexpr Fp& operator /= (const Fp& r) noexcept {
    long long a = r.val, b = MOD, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    val = val * u % MOD;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr bool operator == (const Fp& r) const noexcept {
    return this->val == r.val;
  }
  constexpr bool operator != (const Fp& r) const noexcept {
    return this->val != r.val;
  }
  friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
    return os << x.val;
  }
  friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
    if (n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1) t = t * a;
    return t;
  }
};
using mint = Fp<MOD>;


const int MAX = 2e6+10;

// initialization
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// binom mod MOD
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  COMinit();

  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;

  auto g = [&] (int r, int c) {
    return mint(COM(r + c + 2, r + 1)) - mint(1);
  };
  mint ans = g(r2, c2) - g(r2, c1-1) - g(r1-1, c2) + g(r1-1, c1-1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 47104
n, t = map(int, input().split())
tl = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    if tl[i+1] - tl[i] >= t:
        ans += t
    else:
        ans += tl[i+1] - tl[i]

print(ans+t)

Measured memory_bytes: 30772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

vector<ll> a, acc;

int main(){

    // input
    ll n;
    cin >> n;
    a.resize(n);
    acc.resize(n+1, 0);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) acc[i+1] = acc[i] + a[i];

    ll ans = 1e18;
    rep(i, 0, n+1) {
       ll l = 0, r = i;
       while(r - l > 1) {
           ll m = l + (r - l) / 2;
           if(acc[m] >= acc[i] - acc[m]) r = m;
           else l = m;
       } 
       ll p = acc[l], q = acc[i] - acc[l];
       ll p2 = acc[r], q2 = acc[i] - acc[r];
       ll left_min = min(p, q), left_max = max(p, q);
       if(abs(p2-q2) < abs(p-q)) left_min = min(p2, q2), left_max = max(p2, q2);
        
        
       l = i, r = n;
       while(r - l > 1) {
           ll m = l + (r - l) / 2;
           if(acc[m] - acc[i] >= acc[n] - acc[m]) r = m;
           else l = m;
       } 
       ll rr = acc[l] - acc[i], s = acc[n] - acc[l];
       ll r2 = acc[r] - acc[i], s2 = acc[n] - acc[r];
       ll right_min = min(rr, s), right_max = max(rr, s);
       if(abs(r2-s2) < abs(rr-s)) right_min = min(r2, s2), right_max = max(r2, s2);

       ll tmp = max(left_max, right_max) - min(left_min, right_min);
       ans = min(ans, tmp);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6384
#include <iostream>

int main(void) {
  using namespace std;
  int a,b;
  cin >> a >> b;
  if (a < b) for(int i = 0; i < b; i++) cout << a ;
  else for(int i = 0; i < a; i++) cout << b ;
  
  cout << endl;
  return 0;
}

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

int go(int * a,int n,int k,int * output)
{
	if(n<=1)
	return 0;
	if(output[n-1]!=-1)
	return output[n-1];
	int i=1;
	int mn=INT_MAX;
	for(i=1;i<=k&&i<n;i++){
		int value=abs(a[0]-a[i]);
	int ans=go(a+i,n-i,k,output);
	mn=min(ans+value,mn);
}
output[n-1]=mn;
return mn;	
}
int32_t main(){
	ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int n,k;
   cin >> n;
   cin >> k;
   int a[n];
   for(int i=0;i<n;i++)
   cin >> a[i];
   int output[n];
   for(int i=0;i<n;i++)
   output[i]=-1;
   int ans=go(a,n,k,output);
   cout << ans <<endl;
}


Measured memory_bytes: 11264