akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  long long n; cin >> n;
  long long x; cin >> x;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long res = (long long) 1e18, tmp = 0;
  long long memo[n];
  for (int i = 0; i < n; i++) memo[i] = (long long) 1e18;
  for (int i = 0; i < n; i++) {
    tmp = 0;
    for (int j = 0; j < n; j++) {
      memo[j] = min(memo[j], a[(j + n - i) % n]);
      tmp += memo[j];
    }
    tmp += i * x;
    res = min(res, tmp);
  }
  cout << res << "\n";
  return 0;
}

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

int n,k,x;
vector <int> V;
int dp[100010];

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> x;
        V.push_back(x);
    }

    for (int i = 0; i <= k; i++) {
        bool t=false;
        for (int j = 0; j < n; j++) {
            if (i - V[j] < 0) continue;
            if (dp[i - V[j]] == 0) t=true;
        }
        dp[i] = t;
    }

    if (dp[k]) cout << "First";
    else cout << "Second";
}


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

int main() {
    string S;
    cin >> S;
    
    vector<int> cnt(3, 0);
    rep(i, S.size()) ++cnt[S[i] - 'a'];
    string ans = "YES";
    rep(i, 3) rep(j, 3) {
        if (abs(cnt[i] - cnt[j]) > 1) ans = "NO";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007
// #define mod 163577857 
// #define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()
 
//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    int fact[200010], factinv[200010] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,200010)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t; 
    while(t--)
        solve();
} 

void solve()            
{
    string s;
    cin >> s;
    char c = s[s.length()-1];
    if(c=='3')
        cout << "bon";
    else if(c=='0' || c=='1' || c=='6' || c=='8')
        cout << "pon";
    else
        cout << "hon";
}

Measured memory_bytes: 3588
from itertools import accumulate, combinations
from collections import Counter
def main():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    A = [0] + list(accumulate(A))
    A = [A[j] - A[i] for i, j in combinations(range(n + 1), 2)]
    C = Counter(A)
    ans = 0
    i = pow(2, 39)
    for _ in range(40):
        cnt = 0
        for key, value in C.items():
            b = ans + i
            if b & key == b: cnt += value
        if cnt >= k: ans += i
        i //= 2
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 59952
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll h,w;
cin >> h >> w;
vector<string> stones(h);
ll cnt = 0;
for(ll i = 0; i < h; i++){
    cin >> stones[i];
    for(ll j = 0; j < w; j++){
        if(stones[i][j] == '#')
            cnt++;
    }
}
cout << (cnt == h + w - 1 ? "Possible" : "Impossible") << endl;
}

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

int n, p[100001], ans = 0;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> p[i];
	}

	for (int i = 1; i <= n; i++) {
		if (p[i] == i) {
			i++;
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main()
{
    int  H,N,dam;
    int A[100100];
    cin >> H>> N;

    for(int i=0;i<N;i++)
    {
        cin >> A[i];
    }

    for(int j=0;j<N;j++)
    {
        dam = A[j]+ dam;
    }

    if(dam >= H) cout <<"Yes"<<endl;
    else cout <<"No"<<endl;
    return 0;    
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

static const ll INF = 1e15;

int main(void)
{
	ll n, k;
	cin >> n >> k;

	ll low = n % k;
	low = min(low, abs(low - k));
	cout << low << endl;
	return 0;
}


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

struct Point{
  double x,y;
};

void koch(int n,struct Point a,struct Point b){
  if(n==0)return;

  struct Point s,t,u;
  double th=M_PI*60.0/180.0;

  s.x=(2.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}

int main(){
  struct Point a,b;
  int n;

  scanf("%d",&n);

  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}

Measured memory_bytes: 640
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
a=5
ans=0
if n%2==1:
  print(0)
  exit()
while True:
    if a>n:
        break
    ans+=(n//a)//2
    a*=5
print(ans)

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

int main()
{ 
  int n, m, x ;
  cin >> n >> m >> x ;
  vector<int> data(n) ;
  for(int i = 0 ; i < m ; i++)
  {
    int x ;
    cin >> x ;
    data.at(x)++ ;
  }

  int left = 0 ;
  int right = 0 ;
  for(int i = 0 ; i < n; i++)
  {
    if(i < x)
    {
      left += data.at(i) ;
    }
    else if(i > x)
    {
      right += data.at(i) ;
    }
  }

  cout << min(left, right) << endl ;
}


Measured memory_bytes: 256
from fractions import gcd
t=int(input())
for i in range(t):
	a,b,c,d=map(int,input().split())
	if a<b or b>d:
		print("No")
	elif b<=c:
		print("Yes")
	else:
		g=gcd(b,d)
		if (g-a%g)>=b-c:
			print("Yes")
		else:
			print("No")

Measured memory_bytes: 5048
#include <vector>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

const int N=1e5+5;

typedef vector<int> vec;

int n,k,c[N];
bool vis[N];
vec a[7],A,p,q;

vec inv(vec a) {
	vec b;b.resize(n);
	fo(i,0,n-1) b[a[i]]=i;
	return b;
}

vec mult(vec a,vec b) {
	vec c;c.resize(n);
	fo(i,0,n-1) c[i]=a[b[i]];
	return c;
}

vec pwr(vec a,int t) {
	vec b;b.resize(n);
	fo(i,0,n-1) vis[i]=0;
	fo(i,0,n-1)
		if (!vis[i]) {
			if (a[i]==i) {b[i]=i;continue;}
			int x=i,m=0;
			do {vis[c[m++]=x]=1;x=a[x];} while (x!=i);
			fo(j,0,m-1) b[c[j]]=c[(j+t)%m];
		}
	return b;
}

int main() {
	scanf("%d%d",&n,&k);
	p.resize(n);q.resize(n);
	fo(i,0,n-1) scanf("%d",&p[i]),p[i]--;
	fo(i,0,n-1) scanf("%d",&q[i]),q[i]--;
	a[1]=p;a[2]=q;
	if (n<=6) {
		fo(i,3,n) a[i]=mult(a[i-1],inv(a[i-2]));
		fo(i,0,n-1) printf("%d ",a[n][i]+1);
		return 0;
	}
	fo(i,3,6) a[i]=mult(a[i-1],inv(a[i-2]));
	A.resize(n);fo(i,0,n-1) A[i]=i;
	A=mult(A,q);A=mult(A,inv(p));A=mult(A,inv(q));A=mult(A,p);
	A=pwr(A,(k-1)/6);
	vec an=a[(k-1)%6+1];
	an=mult(A,an);an=mult(an,inv(A));
	fo(i,0,n-1) printf("%d ",an[i]+1);
	return 0;
}

Measured memory_bytes: 6752
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define sort(v)     sort((v).begin(),(v).end())
#define rall(v)     (v).rbegin(),(v).rend()
#define rsort(v)     sort((v).rbegin(),(v).rend())
#define gcd(a,b)    __gcd((a),(b))
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;
//x.substr(start, length);
/*
// Create a vector containing n 
//vectors of size m.  
    vector<vector<int> > vec( n , vector<int> (m, 0));  
*/
struct type{
    int k, i, j;
};
//to check if a no is prime or not?
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

// minimum subaaray sum of size k-sliding window approach
int findSubarray(int arr[], int n, int k)
{
	int window_sum = 0;
	int min_window = INT_MAX;
	int last = 0;
	for (int i = 0; i < n; i++)
	{
		window_sum += arr[i];
		if (i + 1 >= k)
		{
			if (min_window > window_sum)
			{
				min_window = window_sum;
				last = i;
			}
			window_sum -= arr[i + 1 - k];
		}
	}
	int sum=0;
	for(int i=last-k+1;i<=last;i++)
	{
	    sum+=arr[i];
	}
	return sum;
}
signed main() 
{
    fastio;
    //cout << fixed << setprecision(0);
    vector<pair<string,int>>a;
    int n;
    cin>>n;
    f(i,n)
    {
        string s;
        int x;
        cin>>s>>x;
        a.pb({s,x});
    }
    string c;
    cin>>c;
    int t=-1;
    for(int i=0;i<n;i++)
    {
        if(a[i].F==c)
        {
            t=i;
            break;
        }
    }
    
    int ans=0;
    for(int i=t+1;i<n;i++)
    {
        ans+=a[i].S;
    }
    cout<<ans<<endl;
    
}


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

int main() {
    long long x, y;
    cin >> x >> y;

    long long ans = 0;
    while (x <= y) {
        y /= 2;
        ans++;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#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 FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);


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

  ll n; cin >> n;
  vector<ll> a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];

  if (SUM(a) < SUM(b)) {
    puts("-1");
    return 0;
  }

  ll ans = 0;
  ll rem = 0;
  vector<ll> d;
  rep(i, n) {
    if (a[i] < b[i]) {
      rem += (b[i] - a[i]);
      ans++;
    } else if (a[i] > b[i]) {
      d.push_back(a[i] - b[i]);
    }
  }
  sort(ALL(d));
  for (auto itr = d.rbegin(); itr != d.rend(); itr++) {
    if (rem > 0) {
      rem -= *itr;
      ans++;
    }
    if (rem <= 0) break;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2428
A,B=map(int,input().split())
S=str(input())
T=sorted(S[:])
#print(*T)
p=0
if (A+B+1)!=len(S):
  print("No")
else:
  if S[A]=="-":
    for i in range(1,len(S)):
      if 48<=ord(T[i])<=57:
        #print(i,T[i],ord(T[i]))
        p=1
      else:
        p=0
        break
    #print(p)
    print("Yes" if p!=0 else "No")
  else:
    print("No")

Measured memory_bytes: 3064
n = gets.to_i
ans = Array.new(10050, 0)

for i in 1..105
  for j in 1..105
    for k in 1..105
      num = (i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i)
      if num < 10050
        ans[num] += 1
      end
    end
  end
end

for i in 1..n
  puts ans[i]
end

Measured memory_bytes: 14388
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 25, M = 1e6 + 25, oo = 1e9+7, mxmsk = 1 << 16;
const long long OO = 1e18+25;
    
#define par pair<pair<int,int>, int>
#define f first
#define s second

int n,k;
char s[55];


int main() {
    scanf("%d%d%s",&n,&k,s);
    s[k-1] += 'a' - 'A';
    printf("%s",s);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    string n; cin >> n;
    for (int i = 0; i < n.size(); ++i) {
        if (n[i] == '1') {
            cout << '9';
        }
        else {
            cout << '1';
        }
    }
    cout << endl;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

auto prime_factor = [](ll x){map<ll, int> xfact;for(int i=2; (ll)i*i<=x; i++) {while(x % i == 0) {xfact[i]++;x /= i;}}if(x > 1) xfact[x]++;return xfact;};

int main() {
  ll N, P; cin >> N >> P;
  auto m = prime_factor(P);
  ll ans = 1;
  for (auto e: m) {
    ans *= std::pow(e.first, e.second / N);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int t,s;
  int cnt=0;
  cin>>t>>s;
  for(int i=0;i<=t;i++){
    for(int j=0;j<=t;j++){
      if(0<=s-i-j&&s-i-j<=t)cnt++;
    }
  }
  cout<<cnt<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX_N 1000001
#define MAX_M 100000
#define MOD = 1000000007;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,m,n) for(int i=m;i<(int)n;++i)
#define INF 1e+9
#define ent cout<<endl
using P = pair<int, int>;
#define YES "Yes"
#define NO "No"
#define MAX_V 1000
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

// テレンス「もしかしてACですかーッ!?」　ジョセフ「Yse! Yse! Yse! Oh~MyGod」

int main() {
  int n;
  cin>>n;
  vecvec M(3,vec(n*2+1,0));
  vecvec dp(3,vec(n*2+1,0));
  for(int i=1;i<3;i++){
    for(int j=1;j<=n;j++){
      cin>>M[i][j];
    }
  }
  for(int i=1;i<3;i++){
    for(int j=1;j<=n;j++){
      dp[i][j]=max(dp[i-1][j]+M[i][j],max(dp[i][j-1]+M[i][j],dp[i][j]));
    }
  }
  cout<<dp[2][n]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k; cin >> k;
  ll tmp = 7;
  if(k == 7 || k == 1) {
    cout << 1 << endk;
    return 0;
  }
  rep(i, k+1) {
    if(tmp==0) {
      cout << i+1 << endk;
      return 0;
    }
    tmp = tmp*10+7;
    tmp %= k;
  }
  cout << -1 << endk;
  return 0;
}


Measured memory_bytes: 3616
import math

def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

line = list(get_input())
for l in range(len(line)):
    a,b = [int(i) for i in line[l].split()]
    S = a + b
    keta = 0
    while S > 0:
        S = math.floor(S / 10)
        keta = keta + 1
    print(keta)




Measured memory_bytes: 5680
import collections

def prime_factorize(n):
  a = []
  while n % 2 == 0:
    a.append(2)
    n //= 2
  f = 3
  while f * f <= n:
    if n % f == 0:
      a.append(f)
      n //= f
    else:
      f += 2
  if n != 1:
    a.append(n)
  return a

N,P = map(int,input().split())

primes = collections.Counter(prime_factorize(P))
#print(primes)

ans = 1
for k,v in primes.items():
  if v >= N:
    ans *= k**(v//N)
print(ans)

Measured memory_bytes: 38512
import java.util.*;
import java.io.*;
import java.lang.Math;
public class Main {
    public static void main (String [] args) throws IOException
    {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        
        StringTokenizer s = new StringTokenizer(in.readLine());
        
        long a = Long.parseLong(s.nextToken());
        String bS = s.nextToken();
        int bTop = Integer.parseInt(bS.substring(0,1));
        int bBottom = Integer.parseInt(bS.substring(2));
        int c = bTop * 100 + bBottom;
        long result = a * c / 100;

        System.out.println(result);
    }
}

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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

int dp[2][101][101][101];
int H,W;
string bd[100];
int ei,ej;
int cs[2][101][101];

int main() {
	cin >> H >> W;
	for (int i=0;i<H;i++) cin >> bd[i];
	for (int i=0;i<H;i++) for (int j=0;j<W;j++) {
		if (bd[i][j]=='E') {
		ei=i;
		ej=j;
		}
		else if (bd[i][j]=='o') {
			cs[0][i][j+1]++;
			cs[1][i+1][j]++;
		}
		cs[0][i][j+1]+=cs[0][i][j];
		cs[1][i+1][j]+=cs[1][i][j];
	}
	int p=0;
	for (int i=H;i>=0;i--,p=1-p) for (int j=H-i;j>=0;j--)
		for (int k=W;k>=0;k--) for (int l=W-k;l>=0;l--) {
			if (i+j==H || k+l==W) {
				dp[p][j][k][l]=0;
				continue;
			}
			
			int &r=dp[p][j][k][l];
			int t=0;
			if (ei+i+1<H-j) {
				int lb=max(k,ej-l),ub=min(W-l,ej+k+1);
				if (lb<ub) t+=cs[0][ei+i+1][ub]-cs[0][ei+i+1][lb];
			}
			t+=dp[1-p][j][k][l];
			r=t;

			t=0;
			if (ei-j-1>=i) {
				int lb=max(k,ej-l),ub=min(W-l,ej+k+1);
				if (lb<ub) t+=cs[0][ei-j-1][ub]-cs[0][ei-j-1][lb];
			}
			t+=dp[p][j+1][k][l];
			if (t>r) r=t;

			t=0;
			if (ej+k+1<W-l) {
				int lb=max(i,ei-j),ub=min(H-j,ei+i+1);
				if (lb<ub) t+=cs[1][ub][ej+k+1]-cs[1][lb][ej+k+1];
			}
			t+=dp[p][j][k+1][l];
			if (t>r) r=t;

			t=0;
			if (ej-l-1>=k) for (int c=max(i,ei-j);c<min(H-j,ei+i+1);c++)
				if (bd[c][ej-l-1]=='o') t++;
			t+=dp[p][j][k][l+1];
			if (t>r) r=t;

		}

	cout << dp[1-p][0][0][0] << endl;
}

Measured memory_bytes: 8320
#include <iostream>
#include <set>

int main() {
  int a, b, c;
  std::set<int> st;
  std::cin >> a >> b >> c;

  st.insert(a);
  st.insert(b);
  st.insert(c);
  
  if (2 == st.size()) {
    std::puts("Yes");
  } else {
    std::puts("No");
  }
  return 0;
}


Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

const int INF = 1e+9;

struct edge {int from, to, C;};

int BellmanFord(vector<edge>& G, vector<int>& d,
                 vector<bool>& reachable_from_1, 
                 vector<bool>& reachable_from_N, int N, int M){
    d[0] = 0;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < M; ++j){
            edge e = G[j];
            if(!reachable_from_1[e.to] or !reachable_from_N[e.to]) continue; 
            if(!reachable_from_1[e.from] or !reachable_from_N[e.from]) continue; 
            if(d[e.from] == INF) continue;
            if(d[e.to] > d[e.from]+e.C){
                d[e.to] = d[e.from]+e.C;
                if(i == N-1) return -1;
            }
        }
    }
    return 0;
}

void dfs(int pos, vector<vector<int>>& G, vector<bool>& reachable){
    if(reachable[pos]) return;
    reachable[pos] = true;
    for(int v: G[pos]){
        dfs(v, G, reachable);
    }
}


int main()
{
    int N, M, P;
    cin >> N >> M >> P;
    vector<edge> edges(M);
    vector<vector<int>> G(N), rG(N); 
    for( int i = 0; i < M; ++i ){
        int A, B, C;
        cin >> A >> B >> C;
        --A, --B;
        edges[i] = {A, B, -(C-P)};
        G[A].push_back(B);
        rG[B].push_back(A);
    }

    // Preprocess
    // 1 -> N の間に存在しない頂点を見つける
    vector<bool> reachable_from_1(N, false), reachable_from_N(N, false);
    dfs(0, G, reachable_from_1);
    dfs(N-1, rG, reachable_from_N);
    //for(int i = 0; i < N; ++i)
    //    cout << i << " " << (reachable_from_1[i] and reachable_from_N[i]) << endl;

    // Bellman Ford
    vector<int> d(N, INF);
    int ret = BellmanFord(edges, d, reachable_from_1, reachable_from_N, N, M);

    if(ret == -1) cout << -1 << endl;
    else cout << max(-d[N-1], 0) << endl;
    
    return 0;
}

Measured memory_bytes: 768
n,k=map(int,input().split())
L=list(range(n+1))

cnt=0
ans=0

def calc(i):
    smallest=(i-1)*i//2
    largest=(2*n-i+1)*i//2
    return largest-smallest+1


for i in range(k,n+2):
    cnt+=calc(i)
    cnt%=(10**9+7)
    

print(cnt)

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

using namespace std;
int main(){
	int N;
	cin >> N;

	int mod2 = 0;
	int mod4 = 0;
	int modX = 0;

	unsigned int A;
	for(int i=0; i<N; i++){
		cin >> A;
		if(A % 4 == 0) mod4++;
		else if(A % 2 == 0) mod2++;
		else modX++;
	}

	if((mod2==0 && mod4>=modX-1) || (mod2>0 && mod4>=modX)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main{
 public static void main(String[] args)throws IOException{
  int a,b,c,i,ans;
  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  
   String str = br.readLine(); 
   String[] strAry = str.split(" ");
   a = Integer.parseInt(strAry[0]);  
   b = Integer.parseInt(strAry[1]);   
   c = Integer.parseInt(strAry[2]); 
   
   i=0;
   for(ans=a;ans<=b;ans++){
     if(c%ans==0){i++;} 

   }
  System.out.println(i); 
 }
}

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

class Program
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var p = Console.ReadLine().Split(' ').Select(x=>Int32.Parse(x)).ToArray();
        var sortedP = p.OrderBy(x => x).ToArray();
        var ans = "YES";
        var defferentNum = -100;
        for (int i=0;i<N;++i)
        {
            if (p[i] != sortedP[i])
            {
                if(defferentNum==-100)defferentNum = i;
                else
                {
                    var temp = p[defferentNum];
                    p[defferentNum] = p[i];
                    p[i] = temp;
                    for (int j=0;j<N;++j)
                    {
                        if (p[j] != sortedP[j])
                        {
                            ans = "NO";
                            break;
                        }
                    }
                }
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;

int main(){
    string s;cin>>s;
    int ans=1000000;
    for(int i=0;i<s.size()-2;i++){
        int a=stoi(s.substr(i,3));
        ans=min(ans,abs(a-753));
    }
    cout<<ans;
}

Measured memory_bytes: 256
using System;

namespace abc135A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = A + B;
            if (C % 2 == 0)
            {
                int D = C / 2;
                Console.WriteLine(D);
            }
            else
            {
                Console.WriteLine("IMPOSSIBLE");
            }
        }
    }
}


Measured memory_bytes: 11092
use proconio::*;
use proconio::marker::Usize1;

// 削除時にうまいこと更新できるのか
// 逆から見ると嬉しいのか
//
// 枝刈りBFS?

fn chmin<T: Ord>(x: &mut T, a: T) -> bool {
    if *x > a {
        *x = a;
        true
    } else {
        false
    }
}

#[fastout]
fn run() {
    input! {
        n: usize,
        p: [Usize1; n * n],
    }
    let mut cost = vec![vec![std::usize::MAX; n]; n];
    for (i, c) in cost.iter_mut().enumerate() {
        for (j, c) in c.iter_mut().enumerate() {
            chmin(c, i);
            chmin(c, j);
            chmin(c, n - 1 - i);
            chmin(c, n - 1 - j);
        }
    }
    let neighbor = |x: usize, y: usize| -> [(usize, usize); 4] {
        [(x - 1, y), (x + 1, y), (x, y - 1), (x, y + 1)]
    };
    let mut empty = vec![vec![false; n]; n];
    let mut q = std::collections::VecDeque::new();
    let mut ans = 0;
    for p in p {
        let x = p / n;
        let y = p % n;
        let mut v = cost[x][y];
        ans += v;
        for &(a, b) in neighbor(x, y).iter() {
            if a < n && b < n {
                let mut d = cost[a][b];
                if !empty[a][b] {
                    d += 1;
                }
                chmin(&mut v, d);
            }
        }
        cost[x][y] = v;
        empty[x][y] = true;
        q.push_back((x, y));
        while let Some((x, y)) = q.pop_front() {
            for &(a, b) in neighbor(x, y).iter() {
                if !(a < n && b < n) {
                    continue;
                }
                let mut d = cost[x][y];
                if !empty[x][y] {
                    d += 1;
                    if d < cost[a][b] {
                        cost[a][b] = d;
                        q.push_back((a, b));
                    }
                } else {
                    if d < cost[a][b] {
                        cost[a][b] = d;
                        q.push_front((a, b));
                    }
                }
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


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

int main()
{
	string s;
	cin>>s;
	if(s=="SUN")
		cout<<"7";
	if(s=="MON")
		cout<<"6";
	if(s=="TUE")
		cout<<"5";
	if(s=="WED")
		cout<<"4";
	if(s=="THU")
		cout<<"3";
	if(s=="FRI")
		cout<<"2";
	if(s=="SAT")
		cout<<"1";

	return 0;
}

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

int h,w;
int main(){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        char str[128];cin>>str;
        int n=-1;
        for(int j=0;j<w;j++){
            if(str[j]=='c')n=j;
            if(j)cout<<" ";
            if(~n)cout<<j-n;
            else cout<<-1;
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1164
from functools import partial
from itertools import islice


def take(n, iterable):
    return list(islice(iterable, n))


def chunked(iterable, n):
    return iter(partial(take, n, iter(iterable)), [])


def solve(s):
    h, w, *a = map(int, s.split())
    *a, = chunked(a, w)
    ans = []
    for i in range(h):
        for j in range(w - 1):
            if a[i][j] % 2 == 1:
                ans.append("{} {} {} {}".format(i + 1, j + 1, i + 1, j + 2))
                a[i][j + 1] += 1
    for i in range(h - 1):
        if a[i][w - 1] % 2 == 1:
            ans.append("{} {} {} {}".format(i + 1, w, i + 2, w))
            a[i + 1][w - 1] += 1
    return "{}\n".format(len(ans)) + "\n".join(ans)


n, m = map(int, input().split())
print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 112148
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,w,z;
    char ca,cb,cc;
    cin>>a>>b>>c>>d;
    if(abs(b-a)<=d&&abs(b-c)<=d||abs(a-c)<=d) Yes;
    else No;
    return 0;
}


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n,m;
cin>>n>>m;
vector<ll> h(n);
rep(i, n) cin >> h[i];
vector<bool> good(n, true);
int a,b;
rep(i,m){
    cin>>a>>b;
    a--, b--;
    if(h[a]>h[b]){
        good[b] = false;
    }
    else if(h[a]==h[b]){
        good[a] = false;
        good[b] = false;
    }
    else{
        good[a] = false;
    }
}
ll ans=0;
rep(i, n){
    ans += good[i];
}
cout<<ans<<endl;
return 0;
}

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

int main(){
	int x,y;
	while (1){
		scanf("%d %d",&x,&y);
		if (x == 0 && y==0)break;
		if (x < y){
			printf("%d %d\n",x,y);
		}
		else{
			printf("%d %d\n", y, x);
		}
	}
	return 0;
}

Measured memory_bytes: 600
fn main() {
    {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line);
    };
    let a: Vec<i64> = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line);
        line.split_whitespace().map(|a| a.parse().unwrap()).collect()
    };
    let mut con = 0;
    let mut ret = 0;
    for i in 0..(a.len() - 1) {
        if a[i] >= a[i + 1] {
            con += 1;
            ret = std::cmp::max(ret, con)
        } else {
            con = 0;
        }
    }
    println!("{}", ret);
}


Measured memory_bytes: 8444
D, G = map(int,input().split())
pc = [list(map(int,input().split())) for _ in range(D)]

ans = 1e9
for i in range(1 << D):
  cnt = 0
  point = 0
  for j in range(D):
    if(((i >> j) & 1) == 1):
      point += pc[j][0]*100*(j+1) + pc[j][1]
      cnt += pc[j][0]
    else:
      tmp = j
  if(point < G):
    x = G - point
    if((pc[tmp][0]-1)*(tmp+1)*100 < x):
      continue
    cnt += -(-x//(100*(tmp+1)))
  ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 3064
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<vector>

using namespace std;

int main(void) {

	char s[120] = "\0";
	char t[55] = "\0";

	int count = 0;

	scanf("%s", s);

	scanf("%s", t);

	for (int i = 50; i > 0; i--) {
		if (t[i] != '\0') {
			count = i;
			break;
		}
	}
	for (int i = 50; i > 0; i--) {
		if (s[i + count] != '\0') {
			count = i + count;
			break;
		}
	}

	bool frag = false;
	for (int i = count; i >= 0; i--) {
		bool frag2 = true;
		for (int j = 0; t[j] != '\0'; j++) {
			if (s[i + j] != t[j] && s[i + j] != '?')
				frag2 = false;
		}
		if (frag2) {
			for (int j = 0; t[j] != '\0'; j++) {
				s[i + j] = t[j];
			}
			frag = true;
			break;
		}
	}
	if (frag) {
		for (int i = 0; s[i] != '\0'; i++) {
			if (s[i] == '?')
				printf("a");
			else
				printf("%c", s[i]);
		}
	} else
		printf("UNRESTORABLE");
	printf("\n");
	return 0;
}

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

int main(){
    int a, b;
    int cont=0;
    scanf("%d %d", &a, &b);

    for(int i=0;(a+i)<=b;i++){
        int c[5];
        c[4]=(a+i)%10;
        c[3]=((a+i)/10)%10;
        c[2]=((a+i)/100)%10;
        c[1]=((a+i)/1000)%10;
        c[0]=((a+i)/10000)%10;
        if((c[4]==c[0]) && (c[3]==c[1])){
            cont++;
        }
    }
    printf("%d\n", cont);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

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

    char[] s = scanner.next().toCharArray();
    for (int i = 1; i < 3; i++) {
      if (s[i] != s[i - 1]) {
        System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }
}


Measured memory_bytes: 21972
#include <iostream>
using namespace std;
class dice
{
public:
	int l[6];//label
	void in()
	{
		for(int i=0;i<6;i++)cin>>l[i];
	}
	void r(char a)//roll
	{
		if(a=='S')
		{
			int sto=l[0];
			l[0]=l[4];
			l[4]=l[5];
			l[5]=l[1];
			l[1]=sto;
		}
		else if(a=='N')
		{
			int sto=l[0];
			l[0]=l[1];
			l[1]=l[5];
			l[5]=l[4];
			l[4]=sto;
		}
		else if(a=='E')
		{
			int sto=l[0];
			l[0]=l[3];
			l[3]=l[5];
			l[5]=l[2];
			l[2]=sto;
		}
		else if(a=='W')
		{
			int sto=l[0];
			l[0]=l[2];
			l[2]=l[5];
			l[5]=l[3];
			l[3]=sto;
		}
		return;
	}
};

int main() {
	dice d;
	d.in();
	string s;cin>>s;
	for(int i=0;i<s.length();i++)d.r(s[i]);
	cout<<d.l[0]<<endl;
	return 0;
}

Measured memory_bytes: 3212
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<vector>
#include<list>
#include<set>
#include<bitset>
#include<stack>
#include<cctype>
#define sc(x) scanf("%d",&x);
#define pr(x) cout<<#x<<": "<<x<<" ";
#define prln(x) cout<<#x<<": "<<x<<endl;
#define bug() cout<<"bug: "<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const double eps = 1e-4;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5+7;
const int maxm = 1e6+7;
const double pi = acos(-1.0);

int a[maxn];
bool cmp(int a,int b){
	return a>b;
}
int main(){
	int n; scanf("%d",&n);
	for(int i=1; i<=n; i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1,cmp);
	int cnt=0; ll tmp1,tmp2;
	bool flag=false;
	for(int i=1; i<=n; i++)
		if(a[i]==a[i+1]){
			cnt++; i++;
			if(cnt==1) tmp1=a[i];
			else if(cnt==2){
				tmp2=a[i];
				flag=true;
				break;
			}
		}
	ll ans;
	if(flag)
		ans=tmp1*tmp2;
	else
		ans=0;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int[] num = new int[N];
    for(int i = 0; i < N; i++){
      num[i] = Integer.parseInt(sc.next());
    }
    
    int ans = 0;
    for(int i = 0; i < N; i++){
      if(i == num[num[i]-1]-1){
        ans++;
      }
    }
    System.out.println(ans/2);
  }
}

Measured memory_bytes: 49080
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <stack>
using namespace std;
typedef long long int lli;
const long long int MaxN=200005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	lli dp[123][100002]; 
	// dp[ind][ganado]=min(dp[ind-1][ganado],dp[ind-1][ganado-valor[ind]]+peso[ind])
	lli peso[MaxN];
	lli valor[MaxN];
	void solve(){
		lli N,W,i,j,p,q;
		cin>>N>>W;
		for(i=1;i<=N;i++){
			cin>>peso[i]>>valor[i];
		}
		for(i=1;i<=100000;i++){
			dp[1][i]=1e10;
		}
		dp[1][0]=1e10;
		dp[1][valor[1]]=peso[1];	
		for(i=2;i<=N;i++){
			dp[i][valor[i]]=peso[i];
			for(j=0;j<=100000;j++){
				if(dp[i][j]==0)dp[i][j]=1e10;
				dp[i][j]=min(dp[i][j],dp[i-1][j]);
				if(j-valor[i]<0)continue;
				dp[i][j]=min(dp[i][j],dp[i-1][j-valor[i]]+peso[i]);
			}
		}
		lli res=0;
		for(i=1;i<=100000;i++){
			if(dp[N][i]<=W)res=i;
			//cout<<dp[N][i]<<" "<<i<<"\n";
		}		
		/*for(i=1;i<=N;i++){
			for(j=1;j<24;j++){
				if(dp[i][j]==1e10)cout<<"0 ";
				else cout<<dp[i][j]<<" ";
			}
			cout<<"\n";
		}*/
		cout<<res<<"\n";
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,j,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
	
}

Measured memory_bytes: 81700
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int  num = scanner.nextInt();//要素数
		int count = 0;
		int prime_num = 0;
		boolean prime = false;
		
		while( count < num ) {
			prime = isPrime(scanner);
			if( prime ) {
				prime_num ++;
			}
			count ++;
		}

		 System.out.println(prime_num);
		
		scanner.close();
	}

	public static boolean isPrime(Scanner scanner) {
		int  num = scanner.nextInt();//要素数
		
	    if (num == 2) return true;
	    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
	
	    double sqrtNum = Math.sqrt(num);
	    for (int i = 3; i <= sqrtNum; i += 2)
	    {
	        if (num % i == 0)
	        {
	            // 素数ではない
	            return false;
	        }
	    }
	
	    // 素数である
	    return true;
	}
}


Measured memory_bytes: 42296
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
 
#define cost first
#define state second
#define all(c) (c).begin(),(c).end()
 
using namespace std;
 
typedef pair<int,vector<int> > p2;
 
map<vector<int>,int> dist2;
 
int n;
queue<p2> que;

map<vector<int>,int> bfs(vector<int>start){
  
  map<vector<int>,int> dist;

  que.push(p2(0,start));
  dist[start]=0;
  while(!que.empty()){
    p2 now = que.front();
    que.pop();
    
    if(dist.find(now.state)!=dist.end() && dist[now.state]<now.cost)continue;
    if(now.cost>=(n-1)/2)continue;
     
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	vector<int>t=now.state;
	reverse(t.begin()+i,t.begin()+j+1);
	if(dist.find(t)==dist.end()){
	  dist[t]=now.cost+1;
	  que.push(p2(now.cost+1,t));
	}
      }
    }
  }
  return dist;
}

int solve(vector<int> start){
  map<vector<int>,int>a,b;
  a=bfs(start);
  vector<int>goal=start;
  sort(all(goal));
  b=bfs(goal);

  int ans=start.size()-1;
  if(a.find(goal)!=a.end())ans = min(ans,a[goal]);

  do {
      if(a.find(goal) == a.end()) continue;
      if(b.find(goal) == b.end()) continue;
      ans = min(ans, a[goal] + b[goal]);
  } while(next_permutation(all(goal)));

  return ans;
}

int main(void){
 
  cin >> n;
 
  vector<int>v(n);
  for(int i=0;i<n;i++)cin >> v[i];
 
  cout << solve(v) << endl;
   
  return 0;
}

Measured memory_bytes: 97624
unittest
{
	assert( [ "5", "ababa" ].solve == 2 );
	assert( [ "2", "xy" ].solve == 0 );
	assert( [ "13", "strangeorange" ].solve == 5 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto s = input.front.to!( dchar[] );
	
	auto ans = 0L;
	foreach( i; 0L .. n )
	{
		foreach( j, z; z_algorithm( s[ i .. $ ] ) )
		{
			ans = max( ans, min( j, z ) );
		}
	}
	return ans;
}

// 最長共通接頭辞の長さ（s[ 0 .. l ] == s[ b .. b+l ] が成り立つbごとのlの最大値）
auto z_algorithm( dchar[] s )
{
	auto zs = new long[ s.length ];
	zs[ 0 ] = s.length;
	for( auto b = 1L, l = 0L; b < s.length; /* nop */ )
	{
		while( b + l < s.length && s[ l ] == s[ b + l ] ) l++;
		zs[ b ] = l;
		if( l == 0 )
		{
			b++;
			continue;
		}
		
		auto c = 1L;
		while( b + c < s.length && zs[ c ] + c < l )
		{
			zs[ b + c ] = zs[ c ];
			c++;
		}
		b += c;
		l -= c;
	}
	return zs;
}


Measured memory_bytes: 7160
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>

int main(){
    long A,B;
    
    std::cin >> A >> B;
    
    std::cout << std::abs(A-2)*std::abs(B-2) <<std::endl;
}

Measured memory_bytes: 256
s=input()
s1=int(s[:2])
s2=int(s[2:])
if(s1==0 or s2==0):
  if(s1==0 and 1<=s2<=12):
    print("YYMM")
  elif(s2==0 and 1<=s1<=12):
    print("MMYY")
  else:
    print("NA")
elif(1<=s1<=12):
  if(1<=s2<=12):
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if(1<=s2<=12):
    print("YYMM")
  else:
    print("NA")


Measured memory_bytes: 38256
#include<iostream>
using namespace std;
int main() {
	int n,i,j,k;
	int b,f,r,v;
	int nucom[4][3][10]={{{}}};
	cin >> n;  
 	for(i=0;i<n;i++) {
		cin >> b >> f >> r >> v;
		nucom[b-1][f-1][r-1]+=v;
	}
	for(i=0;i<4;i++) {
		for(j=0;j<3;j++) {
			for(k=0;k<10;k++) {
				cout << " ";
				cout << nucom[i][j][k];
			}
		cout << endl;	
	}	
	if(i<3)cout<< "####################" << endl;
	}
}



Measured memory_bytes: 3088
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    int ans = 0;
    cin >> n;
    vector<int> p(n);
    rep(i, n) {
      cin >> p[i];
    }

    FOR(i, 1, n - 1) {
      if ((p[i] > p[i - 1] && p[i] < p[i + 1]) || (p[i] < p[i - 1] && p[i] > p[i + 1])) {
        ++ans;
      }
    }

    cout << ans << '\n'; 

    return 0;
}


Measured memory_bytes: 256
def resolve():
    import sys
    input = sys.stdin.readline
    a,b,c,d = list(map(int, input().split()))
    while True:
        c = c -b
        if c<=0:
            print("Yes")
            break
        a = a - d
        if a<=0:
            print("No")
            break



if __name__ == "__main__":
    resolve()


Measured memory_bytes: 61804
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))

left = 0
right = max(A) + 1

while left+1!=right:
  mid = (left + right)//2
  x = 0
  for a in A:
    x += math.ceil(a/mid) - 1
  if x<=K:
    right = mid
  else:
    left = mid
  
print(right)

Measured memory_bytes: 93884
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,p=0,q=0,i,n,k;
    cin>>n>>m;
    int a[m+2];
    int b[n+3]= {0};
    string s[m+2];
    for(i=0; i<m; i++)
    {
        cin>>a[i]>>s[i];
    }
    for(i=0; i<m; i++)
    {
        if(s[i]=="WA")
        {
            if(b[a[i]]>=0)
            {
                b[a[i]]++;
            }

        }
        else
        {
            if(b[a[i]]>=0)
            {
                p++;
                q=q+b[a[i]];
                b[a[i]]=-1;
            }
        }
      //  cout<<b[a[i]]<<endl;

    }
    cout<<p<<" "<<q<<endl;

}


Measured memory_bytes: 7464
from sys import stdin
##  input functions for me
def ria(sep = ''):
    if sep == '' :
        return list(map(int, input().split())) 
    else: return list(map(int, input().split(sep)))
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##

## main ##
A, B, C = map(int, input().split())
print("Yes" if (A == B and B == C) else "No")



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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int a [] = new int [N];
		for (int i=0; i<N; i++)
			a[i]=sc.nextInt();
		
		Arrays.sort(a);
		int temp = 0;
		for (int i=0; i<N-1; i++){
			temp+=a[i];
		}
		
		if (temp>a[N-1])
			System.out.println("Yes");
		else
			System.out.println("No");
		sc.close();

	}

}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    string S; cin >> S;

    int ans = 0;
    deque<char> deq;
    rep (i, 0, S.size()) deq.push_back(S[i]);
    while (deq.size() > 1) {
        if (deq.front() != deq.back()) ++ans;
        deq.pop_front();
        deq.pop_back();
    }

    cout << ans << endl;
}

Measured memory_bytes: 256