akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(void)
{
	int n,i,j,l,a=0;
	int ar[4][13]={{0}};
	char s,kaigyokun=0;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++)
	{
		scanf("%c",&kaigyokun);
		scanf("%c %d", &s, &l);
		
		if(s == 'S') a = 0;
		else if (s == 'H') a = 1;
		else if (s == 'C') a = 2;
		else if (s == 'D') a = 3;
		
		ar[a][l-1] = 1;
	}
	
	for(i = 0; i < 4; i++)
	{
		for(j = 0; j < 13; j++)
		{
			if((ar[i][j]) != 1)
			{
				if(i == 0) s = 'S';
				else if (i == 1) s = 'H';
				else if (i == 2) s = 'C';
				else if (i == 3) s = 'D';
				
				printf("%c %d\n", s, j+1 );
			}
		}
	}
	
	return 0;
}




Measured memory_bytes: 2044
import java.util.*;

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();
    }
    int ans = Integer.MAX_VALUE;
    for(int t = -100; t <= 100; t++) {
      int m = 0;
      for(int i = 0; i < n; i++) {
        m += ((a[i] - t) * (a[i] - t));
      }
      ans = Math.min(ans, m);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35924
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  if (k <= a){
    cout << k << endl;
  }else if (k <= a+b){
    cout << a << endl;
  }else{
    cout << a-(k-a-b) << endl;
  }
}

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

typedef long long ll;
int n;string s;
void dfs(int now,int mx){
    if(now==n){cout<<s<<endl;return;}
    for(int i='a';i<=mx+1;i++) {s[now]=i;dfs(now+1,max(i,mx));}
}
int main() {
    cin>>n;for(int i=0;i<n;i++) s.push_back('a'); 
    dfs(1,'a');
    return 0;
}

Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int h,w; cin >> h >> w;
    char g[h][w]; REP(i,h)REP(j,w) cin >> g[i][j];
    bool ok = 1;
    /*黒いマスは上下左右も黒いマスじゃないとアウト*/REP(i,h)REP(j,w) if (g[i][j]=='#'&&g[i][j-1]!='#'&&g[i-1][j]!='#'&&g[i][j+1]!='#'&&g[i+1][j]!='#') ok = 0;
    Yn(ok);

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
#define repe(i,x) for (edge *i=fst[x]; i; i=i->nxt)
using namespace std;

typedef long long LL;
const int p=1e9+7;
int n,x,y,c[200100],w[200100],fa[200100],s[200100],minw[200100],min1,min2,cnt[200100],inv[200100];
struct edge
{
    int v;
    edge *nxt;
} pool[200100],*tp=pool,*fst[200100];

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

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

void merge(int u,int v)
{
    if ((u=find(u))==(v=find(v)))
        return;
    if (s[u]>s[v])
        swap(u,v);
    fa[u]=v,s[v]+=s[u];
}

int main()
{
    scanf("%d%d%d",&n,&x,&y),w[0]=1<<30;
    repu(i,1,n)
    {
        c[i]=getint(),w[i]=getint(),s[fa[i]=i]=1;
        if (w[i]<w[minw[c[i]]])
            minw[c[i]]=i;
        if (w[i]<w[min1])
        {
            if (c[i]!=c[min1])
                min2=min1;
            min1=i;
        }
        else
            if (w[i]<w[min2] && c[i]!=c[min1])
                min2=i;
    }
    repu(i,1,n)
    {
        if (w[i]+w[minw[c[i]]]<=x)
            merge(i,minw[c[i]]);
        int t=c[i]==c[min1]?min2:min1;
        if (w[i]+w[t]<=y)
            merge(i,t);
    }
    int ans=1;
    repu(i,1,n)
    {
        if (find(i)==i)
            repu(j,2,s[i])
                ans=LL(ans)*j%p;
        *tp=(edge){i,fst[fa[i]]},fst[fa[i]]=tp++;
    }
    inv[0]=inv[1]=1;
    repu(i,2,n)
        inv[i]=LL(p-p/i)*inv[p%i]%p;
    repu(i,1,n)
        if (fa[i]==i)
        {
            repe(j,i)
                ans=LL(ans)*inv[++cnt[c[j->v]]]%p;
            repe(j,i)
                cnt[c[j->v]]=0;
        }
    printf("%d\n",ans);
    return 0;
}

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

#define ll long long
#define ld long double
#define ull unsigned long long
#define endl "\n"
#define MohamedMotaz ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
#define f(a, b, c) for(int a = b; a < c; a++)
using namespace std;
const ll mod = 1e9 + 7;



//ll fact[1000001]; ll inv[1000001];
//ll primes[100007];
//ll arr[1000007];
//ll modPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//
//	ll halfpow = modPower(b, p / 2);
//	ll toReturn = (halfpow * halfpow) % mod;
//	if (p % 2)
//		toReturn = (toReturn * b) % mod;
//
//	return toReturn;
//}
//
//ll fastPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//	ll ans = fastPower(b, p / 2);
//	ans = (ans * ans);
//	if (p % 2 != 0)
//		ans = (ans * b);
//	return ans;
//}
//ll GcdRecursive(ll a, ll b) {
//	if (b == 0) return a;
//	return GcdRecursive(b, a % b);
//}
//ll modLCM(ll a, ll b) {
//	ll val = GcdRecursive(a, b);
//	ll tmp = ((a % mod) * (b % mod)) % mod;
//	ll finalVal = ((tmp % mod) * (arr[val] % mod)) % mod;
//	return finalVal;
//
//}
//ll LCM(ll a, ll b) {
//	return (a * b) / GcdRecursive(a, b);
//}
//void move1step(ll& a, ll& b, ll q) { // a and b by reference
//	ll c = a - q * b;
//	a = b;
//	b = c;
//}
//ll GcdIterative(ll a, ll b) {
//	while (b) move1step(a, b, a / b);
//	return a;
//}
//
//void pre(ll n) {
//
//	fact[0] = 1;
//	inv[0] = 1;
//
//	for (ll i = 1; i <= n; i++) {
//		fact[i] = (i * fact[i - 1]) % mod;
//		inv[i] = modPower(fact[i], mod - 2);
//		arr[i] = modPower(i, mod - 2);
//	}
//}
//
//ll npr(ll n, ll r) {
//	return ((fact[n] * inv[n - r]) % mod);
//}
//
//ll ncr(ll n, ll r) {
//	return ((((fact[n] * inv[n - r]) % mod) * inv[r]) % mod);
//}
//
//void sieve(ll val) {
//	memset(primes, 1, sizeof primes);
//	primes[0] = primes[1] = false;
//	for (int i = 2; i <= val; i++) {
//		if (primes[i]) {
//			for (int j = i * i; j <= val; j += i) {
//				primes[j] = 0;
//			}
//		}
//	}
//
//}






int main()
{
    MohamedMotaz;


    string s;
    cin >> s;

    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes";
    else cout << "No";

}








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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;

const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    friend std::istream &operator>>(std::istream &in, mint &o) {
        ll a;
        in >> a;
        o = a;
        return in;
    }

    friend std::ostream &operator<<(std::ostream &out, const mint &o) {
        out << o.x;
        return out;
    }

};

int main() {

    int n, x;
    cin >> n >> x;
    vector<int> v(n);
    rep(i, n) cin >> v[i];

    sort(v.rbegin(), v.rend());

    vector<vector<mint>> dp(n + 1, vector<mint>(x + 1, 0));
    dp[0][x] = 1;

    rep(i, n) {
        rep(j, x + 1) {
            // 採用する
            dp[i + 1][j % v[i]] += dp[i][j];

            //　採用しない
            dp[i + 1][j] += dp[i][j] * (n - i - 1);
        }
    }

    mint ans = 0;
    rep(j, x + 1) ans += dp[n][j] * j;

    cout << ans << endl;

}

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

typedef long long ll;

ll gcd(ll m, ll n)
{
  ll _m = m;
  ll _n = n;
  ll _r = _m%_n;
  while (0 != _r)
  {
    _m = _n;
    _n = _r;
    _r = _m%_n;
  }
  return _n;
}

int main()
{
  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  ll C_min = (0 == A%C ? A : C*(A/C + 1));
  if (C_min < A)
    C_min += C*((A - C_min)/C + 1);
  ll C_max = C*(B/C);
  if (B < C_max)
    C_max -= C*((C_max - B)/C + 1);
  ll C_count = (C_max - C_min)/C + 1;

  ll D_min = (0 == A%D ? A : D*(A/D + 1));
  if (D_min < A)
    D_min += D*((A - D_min)/D + 1);
  ll D_max = D*(B/D);
  if (B < D_max)
    D_max -= D*((D_max - B)/D + 1);
  ll D_count = (D_max - D_min)/D + 1;

  ll CD = C*D/gcd(C, D);
  ll CD_min = (0 == A%CD ? A : CD*(A/CD + 1));
  if (CD_min < A)
    CD_min += CD*((A - CD_min)/CD + 1);
  ll CD_max = CD*(B/CD);
  if (B < CD_max)
    CD_max -= CD*((CD_max - B)/CD + 1);
  ll CD_count = (CD_max - CD_min)/CD + 1;
  
  cout << B - A + 1 - C_count - D_count + CD_count;
}


Measured memory_bytes: 256
a, b, h, m = gets.chomp.split.map(&:to_i)

prog_a = (h + m / 60.0).to_f / 12.0 * 2 * Math::PI
prog_b = m.to_f / 60.0 * 2 * Math::PI

pt_a = { x: Math.cos(prog_a) * a, y: Math.sin(prog_a) * a }
pt_b = { x: Math.cos(prog_b) * b, y: Math.sin(prog_b) * b }

dist_sq = (pt_a[:x] - pt_b[:x]) ** 2 + (pt_a[:y] - pt_b[:y]) ** 2
puts Math.sqrt(dist_sq)


Measured memory_bytes: 14808
#include<iostream>
#include<iomanip>
using namespace std; 
 
int main ()
{
char array[100000];
for(int q=1;q<100000;q++)
{
    cin>>array[q];
    if(array[q]==0)
    break;
}
for(int i=1;i<500000;i++)
{
    if(i%2!=0)
    cout<<array[i];
    if(array[i+1]==0)
    break;
}
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

#define MOD (1e9 + 7);
#define PI (3.14159265358979323846)

using ll = int64_t;
using ull = uint64_t;

using namespace std;

[[maybe_unused]] static auto __x = [](){ios_base::sync_with_stdio(0); cin.tie(0);};

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

    unordered_map<string, int> m = {
        {"SUN", 0},
        {"MON", 1},
        {"TUE", 2},
        {"WED", 3},
        {"THU", 4},
        {"FRI", 5},
        {"SAT", 6},
    };

    cout << (7 - m[a]);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
        b.at(i) = a.at(i);
    }
    sort(b.begin(), b.end());
    int ans;
    for (int i = 0; i < n; i++) {
        if (a.at(i) == b.at(n - 1)) {
            ans = b.at(n - 2);
        } else {
            ans = b.at(n - 1);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n);i>=(j);i--)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

int n,m;

int main(){
    cin>>n>>m;
    vector<int> x(m);
    rep(i,0,m) cin>>x[i];
    sort(x.begin(),x.end());
    vector<int> ans(m-1);
    rep(i,0,m-1) ans[i]=x[i+1]-x[i];
    int sum=0;
    sort(ans.begin(),ans.end());
    rep(i,0,m-n) sum+=ans[i];
    cout<<sum<<"\n";
    return 0;
}


Measured memory_bytes: 4000
n = int(input())
w = list(map(int,input().split()))

ans = sum(w)
s2 =  sum(w)
s1 = 0

for i in range(0,n):
    s1 += w[i]
    s2 -= w[i]
    if abs(s2-s1) <ans :
        ans = abs(s2-s1)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	string S;
	cin >> S;
	ll an=0;
	ll b=0;
	rep(i, S.size()) {
		if (S.at(i) == 'W') {
			an += b;
		}
		else {
			b++;
		}
	}
	cout << an << endl;
}

Measured memory_bytes: 640
require 'pp'

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end

def min(a, b)
  return a < b ? a : b
end

n, hlist = gets_n_and_i_list
INF = Float::INFINITY

# DP 配列全体を「DP の種類に応じた初期値」で初期化
dp = Array.new(n, INF)

# 初期条件を入力
dp[0] = 0

# 配るDP
0.upto(n-1) do |i|
  if i + 1 < n
    diff1 = (hlist[i + 1] - hlist[i]).abs + dp[i]
    dp[i + 1] = min(diff1, dp[i+1])
  end

  if i + 2 < n
    diff2 = (hlist[i + 2] - hlist[i]).abs + dp[i]
    dp[i + 2] = min(diff2, dp[i+2])
  end

end

puts dp.last

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

int main()
{
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    for (auto& i : a) scanf("%d", &i);
    sort(a.begin(), a.end());
    long long s = a[n - 1];
    int c = n - 2;
    for (int i = n - 2; i > 0; i--)
    {
        if (c > 1) c -= 2, s += a[i] * 2;
        else if (c == 1) c--, s += a[i];
        else break;
    }
    printf("%lld\n", s);
    return 0;
}

Measured memory_bytes: 4060
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100000
typedef long long ll;
string tobin(int x){return !x?"":tobin(x/2)+(char)(x%2+'0');}
int main(){
    ll sum=0;
    string s;cin>>s;
    for(int i=0;i<(1<<(s.size()-1));++i){
        ll tmp=0;
        for(int j=0;j<s.size();++j){
            tmp=tmp*10+s[j]-'0';
            if((i>>j)&1){/*cout<<tmp<<endl*/;sum+=tmp;tmp=0;}
        }
        sum+=tmp;
        // cout<<tmp<<endl;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3636
def solve(h, a):
    if h % a == 0:
        return h // a
    else:
        return h // a + 1


def main():
    h, a = map(int, input().split())
    res = solve(h, a)
    print(res)
    # for r in res:
    #     print(r)


def test():
    assert solve(10, 4) == 3
    assert solve(1, 10000) == 1
    assert solve(10000, 1) == 10000


if __name__ == "__main__":
    test()
    main()


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

int main() {
    string s;

    cin >> s;

    int cnt = 0;
    int min_cnt = s.length();
    for ( int i = 0; i < 2; i++ ) {
        cnt = 0;
        for ( int j = 0; j < s.length(); j++ ) {
            if ( j % 2 == i ){
                if ( s.substr(j, 1) == "0" ) {
                    cnt++;
                }
            }
            else {
                if ( s.substr(j, 1) == "1" ) {
                    cnt++;
                }  
            }
        }
//        cout << cnt << endl;
        min_cnt = min(cnt, min_cnt);
    }

    cout << min_cnt << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <climits>
#include <vector>
#include <queue>

#define MAX_V 1024
using namespace std;

void get_map();
void check();
struct edge
{
  int to;
  int weight;
};


const int INF = INT_MAX/4;
vector<edge> g[2000];
int graph[MAX_V][MAX_V];
int dist[MAX_V];
int numofedge;
int vertex;
int start;
int flag=0;

int main()
{
  get_map();
  check();
  //for(int i=0;i<vertex;i++)
    {
      for(int j=0;j<vertex;j++)
	{
	  //if(i==j)
	    {
	      if(graph[start][j]<INF/2 && graph[j][j]<0)
		{
		  cout << "NEGATIVE CYCLE" <<endl;
		  return 0;
		}
	    }
	}
    }
  
    for(int i=0;i<vertex;i++)
      {
	if(graph[start][i]>=INF/2)
	  {
	    cout << "INF" << endl;
	  }
	else
	  {
	cout << graph[start][i] << endl;
	  }
      }
  return 0;
}

inline int fastmin(int a, int b)
{
  return (((a-b)>>31)&(a-b))+b;
}

void check()
{
  //  int next;
  //int here = start;
  //for(int i=0;i<vertex;i++)
  
  for(int k=0;k<vertex;k++)//v=4
    {
      for(int i=0;i<vertex;i++)
	{
	  int gik= graph[i][k];
	  for(int j=0;j<vertex;j++)
	    {
	      //if(graph[i][k] !=INF && graph[k][j]!=INF)
		{
	      graph[i][j]= fastmin(graph[i][j], gik+graph[k][j]);
		}
	    }
	}
    }
  
}

void get_map()
{
  int edge, from ,to;
  cin >> vertex >> numofedge >> start;
  
  fill(graph[0], graph[vertex], INF);
  
  for(int i=0;i<vertex;i++)
    {
      for(int j=0;j<vertex;j++)
      {
	if(i==j)
	  {
	    graph[i][j]=0;
	  }
	/*else
	  {
	    graph[i][j]=INF;
	    }*/
      }
    }

  /*for(int i=0;i<vertex;i++)
    {
      dist[i]=INF;
    }
  */
  for(int i=0;i<numofedge;i++)
    {
      cin>>from>>to;
      cin >> graph[from][to];
    }

  /*  for(int i=0;i<numofedge;i++)
    {
      int from, to, weight; 
      cin >> from >> to >> weight;
      g[from].push_back({to , weight});
   }
  */  

  /*  for(int i=0;i<vertex;i++)
    {
      for(int j=0;j<vertex;j++)
	{
	  cout << graph[i][j] << " ";
	}
      cout << endl;
      }*/
  // dist[start]=0;
  
  /*  cout << vertex << endl;
  for(int i=0;i<vertex;i++)
    {
      for(int j=0;j<vertex;j++)
	{
	  cout << graph[i][j] << " ";
	}  
      cout << endl;    
      }*/
  

}

Measured memory_bytes: 5296
while True:
  b,r,g,c,s,t=map(int, input().split())
  if t==0:
    break
  x=100
  y=b*5+r*3
  z=t-y-s
  a=x+(b+r)*15+g*7+y*13+c*2-z*3
  print(a)


Measured memory_bytes: 5600
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    long A =sc.nextLong();
    long B =sc.nextLong();
    long C =sc.nextLong();
    long K =sc.nextLong();
    if(K<A){System.out.println(K);}
    else if(K<A+B){System.out.println(A);}
    else{long D =A*2+B-K;
         System.out.println(D);}
  }
}

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

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORV(i,a,b) for(int i=a;i*i<=b;i++)
#define Forv(i,a,b) for(int i=a;i*i<b;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define Ford(i,a,b) for(int i=a;i>b;i--)
#define Fill(s,a) memset(s,a,sizeof(s))
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int n, m, cnt=0;
char c[1002][1002], x[3][3];

bool check(int i, int j)
{
    FOR(k, 1, 2)
        FOR(l, 1, 2)
            if(c[i+k-1][j+l-1] != x[k][l]) return false;
    return true;
}

int solve(char y, int i, int j)
{
    int cnt1=0, cnt2=0;
    char z = c[i][j];
    if(check(i, j))cnt1++;
    if(check(i-1, j-1))cnt1++;
    if(check(i-1, j))cnt1++;
    if(check(i, j-1))cnt1++;
    c[i][j] = y;
    if(check(i, j))cnt2++;
    if(check(i-1, j-1))cnt2++;
    if(check(i-1, j))cnt2++;
    if(check(i, j-1))cnt2++;
    c[i][j] = z;
    return (cnt2-cnt1);
}

int main()
{
    cin>>m>>n;
    FOR(i, 1, m)
    {
        scanf("\n");
        FOR(j, 1, n)
            scanf("%c", &c[i][j]);
    }
    scanf("\n%c%c\n%c%c", &x[1][1], &x[1][2], &x[2][1], &x[2][2]);
    For(i, 1, m)
        For(j, 1, n)
        {
            if(check(i, j))cnt++;
        }
    int res=0;
    FOR(i, 1, m)
        FOR(j, 1, n)
        {
            res = max(res, solve('J', i, j));
            res = max(res, solve('O', i, j));
            res = max(res, solve('I', i, j));
        }
    cout<<cnt+res<<'\n';
}

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

int main() {
  int N, M; cin >> N >> M;
  vector<string> A(N);
  vector<string> B(M);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < M; i++) cin >> B[i];

  for(int sy = 0; sy <= N - M; sy++) {
    for(int sx = 0; sx <= N - M; sx++) {
      int flag = 0; 
      for (int tgty = 0; tgty < M; tgty++) {
        if (A[tgty + sy].substr(sx, M) != B[tgty]) continue;
        flag++;
      }
      if (flag == M) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

string s, t;

int find(string s1, string s2) {
  for (int i=s1.size()-s2.size();i>=0;i--) {
    bool found = true;
    for (int j=0;j<s2.size();j++) {
      if (s1[i+j] != '?' && s1[i+j] != s2[j]) {
        found = false;
        break;
      }
    }
    if (found) {
      return i;
    }
  }
  return -1;
}

void solve() {
  int pos = find(s, t);
  if (pos == -1) {
    cout << "UNRESTORABLE" << endl;
    return;
  }
  for (int i=0;i<s.size();i++) {
    if (i == pos) {
      cout << t;
      i += t.size() - 1;
    } else {
      if (s[i] == '?') {
        cout << 'a';
      } else {
        cout << s[i];
      }
    }
  }
  cout << endl;
}

int main() {
  cin >> s >> t;
  solve();
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int h, w, n;cin >> h >> w >> n;
    set<pair<int, int>> s;
    vector<LL> cnt(10, 0);
    cnt[0] = LL(h-2)*LL(w-2);
    for(int k=0;k<n;k++){
        int a, b;cin >> a >> b;a--;b--;
        int t = max(0, a-2);
        int d = min(h, a+3);
        int l = max(0, b-2);
        int r = min(w, b+3);
        //cout << t << d << l << r << endl;
        for(int i=0;i<d-t-2;i++){
            for(int j=0;j<r-l-2;j++){
                int count = 0;
                for(int ii=0;ii<3;ii++){
                    for(int jj=0;jj<3;jj++){
                        int c = t+i+ii;
                        int d = l+j+jj;
                        if(s.find({c, d}) != s.end()){
                            count++;
                        }
                    }
                }
                cnt[count]--;
                cnt[count+1]++;
            }
        }
        //for(int i=0;i<10;i++) cout << cnt[i] << " ";
        //cout << endl;
        s.insert({a, b});
    }
    for(int i=0;i<10;i++){
        cout << cnt[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int val = scan.nextInt();
			if(val == 0){
				break;
			}
			for(int i = 0;i < 9;i++){
				val -= scan.nextInt();
			}
			System.out.println(val);
		}
	}
}

Measured memory_bytes: 17200
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}


int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}


int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}


int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}


int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


int main(){
  int n;
  const lint INF=1LL<<60;
  vector<lint> h;
  cin>>n;
  lint dp[n];
  for(int i=0;i<n;i++) {
    lint j;
    cin>>j;
    h.pb(j);
    dp[i]=INF;
  }
  dp[0]=0;
  for(int i=1;i<n;++i){
    chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
    if(i>1) chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[n-1];


}

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

typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

// cout<<fixed<<setprecision(10);
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

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

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include <math.h>
#include <string>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i]>>y[i];
typedef long long int ll;
using namespace std;

int main(){
	int h,w; cin >>h>>w;
	string s;
	int cnth=-1;  int cntw=-1;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> s;
			if(s=="snuke"){
				cnth=i; cntw=j;
			}
		}
	}
	char a='A';
	for(int i=0;i<cntw;i++){
		a++;
	}
	cout << a <<cnth+1 << endl;
}


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

int chk(int n){
    int j=n%10;
    n/=10;
    while(n>0){
        if(n%10!=j-1){return false;}
        j=n%10;
        n/=10;
    }
    return true;
}

int main(){
    int i,j,n,c,m,bf;
    scanf("%d",&n);
    vector<int> l(n,0);
    for(i=0;i<n;i++){
        scanf("%d",&bf);
        l[i]=bf;
    }
    m=-1;
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            c=l[i]*l[j];
            if(chk(c)){m=max(m,c);}
        }
    }
    printf("%d\n",m);
    return 0;
}




Measured memory_bytes: 2752
#include<stdio.h>
int main(void){
    int A,B,C,D;
    scanf("%d %d %d %d",&A,&B,&C,&D);
    int sum = 0;
    if(A<B) sum += A;
    else sum += B;
    if(C<D) sum += C;
    else sum += D;
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
def d_knight():
    X, Y = [int(i) for i in input().split()]

    def combination(n, r, mod):
        r = min(r, n - r)
        numerator, denominator = 1, 1
        for i in range(1, r + 1):
            numerator = (numerator * (n + 1 - i)) % mod
            denominator = (denominator * i) % mod
        return numerator * pow(denominator, mod - 2, mod) % mod

    if not (X <= 2 * Y and Y <= 2 * X):
        return 0

    n, m = (-X + 2 * Y) / 3, (2 * X - Y) / 3
    if not (n.is_integer() and m.is_integer()):
        return 0

    n, m = int(n), int(m)
    return combination(n + m, n, 10**9 + 7)

print(d_knight())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    ll n,k;
    cin >> n >> k;
    vector<int> a(n), visited(n);
    rep(i,0,n-1)cin >> a[i];
    int now = 0;
    int cnt = 1;
    int next;
    while(true){
        if(k == 0){
            cout << now+1 << endl;
            return 0;
        }
        visited[now] = cnt;
        next = a[now] -1;
        if(visited[next] > 0)break;
        now = next;
        cnt++;
        k--;
    }
    int period = visited[now] - visited[next] + 1;
    k %= period;
    while(true){
        if(k == 0){
            cout << now+1 << endl;
            return 0;
        }
        next = a[now] -1;
        now = next;
        k--;
    }   

    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 4816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

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

    if(S.size() + 1 == T.size()) {
        for(int i = 0; i < S.size(); i++) {
            if(S[i] != T[i]) {
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

int main(void){
  int R, G, B, n;
  int counter = 0;
  cin >> R >> G >> B >> n;

  for (int r = 0; r <= n; r += R) {
    for (int g = 0; g <= n - r; g += G) {
      int b = n - r - g;
      if (b % B == 0) {
        counter ++;
      }
    }
  }


  cout << counter << '\n';
  return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
  ll n;
  cin>>n;
  vector<int>vec;
  while(true){
    if(n==0){
      vec.push_back(0);
      break;
    }
    if(n==1){
      vec.push_back(1);
      break;
    }
    if(n%2==0){
      vec.push_back(0);
      n/=-2;
    }
    else {
      vec.push_back(1);
      n=(n-1)/-2;
    }
  }
  reverse(vec.begin(),vec.end());
  rep(i,vec.size()){
    cout<<vec[i];
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int a[8][8], row[8], col[8], d1[17], d2[17];

int f(int i, int j, int s){
    int i1 = i + (j==7), j1 = (j + 1) % 8;
    if(s == 0)
        return 1;
    if(i > 7)
        return 0;
    if(a[i][j] == 1){
        if(f(i1, j1, s-1))
            return 1;
        return 0;
    }
    if(row[i] == 0 && col[j] == 0 && d1[i + j] == 0 && d2[j - i + 7] == 0){
        a[i][j] = 1;
        row[i] = col[j] = d1[i + j] = d2[j - i + 7] = 1;
        if(f(i1, j1, s-1))
            return 1;
        row[i] = col[j] = d1[i + j] = d2[j - i + 7] = 0;
        a[i][j] = 0;
    }
    if(f(i1, j1, s))
        return 1;
    return 0;
}

int main(){
    int k, i, j, x, y;
    scanf("%d", &k);
    for(i = 1; i <= k; i++){
        scanf("%d %d", &x, &y);
        a[x][y] = 1;
        row[x] = col[y] = d1[x+y] = d2[y - x + 7] = 1;
    }
    f(0, 0, 8);
    for(i = 0; i < 8; i++){
        for(j = 0; j < 8; j++){
            if(a[i][j])
                printf("Q");
            else
                printf(".");
        }
        printf("\n");
    }





}

Measured memory_bytes: 1816
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+100;
const int mod=1e9+7;
long long int arr[maxn];
int T,n,m,k;

int main()
{
    cin>>n>>k;
    long long int res=1,sign=1,x,y;
    for(int i=1;i<=n;i++)
        cin>>arr[i];
    sort(arr+1,arr+1+n);
    int l=1,r=n;
    if(k&1)
    {
        res*=arr[r--];
        k--;
        if(res<0) sign=-1;
    }
    while(k>0)
    {
        x=arr[l]*arr[l+1],y=arr[r]*arr[r-1];
        if(x*sign>y*sign)
        {
            res=x%mod*res%mod;
            l+=2;
        }
        else
        {
            res=y%mod*res%mod;
            r-=2;
        }
        k-=2;
    }
    cout<<(res+mod)%mod<<endl;
}


Measured memory_bytes: 5128
private fun getLongs(): LongArray {
    return readLine()!!.split(" ").map {it.toLong()}.toLongArray()
}

fun main(){
    getLongs()
    val arr = getLongs()
    print(solver(arr))
}
private const val mod:Long = 1000000000 + 7

private fun modsum(a:Long,b:Long):Long {
    return (a+b) % mod
}
private fun modprod(a:Long,b:Long):Long {
    return (a*b) % mod
}

private fun solver(arr:LongArray):Long {
    // index番目まで足した奴の配列
    val sums = LongArray(arr.size)
    var sum = 0L
    for (i in arr.indices) {
        sum = modsum (sum,arr[i])
        sums[i] = sum
    }
    var total = 0L
    for (i in 1 until arr.size) {
        total = modsum(total, modprod(arr[i],sums[i-1]))
    }
    return total
}


Measured memory_bytes: 65188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
  int A, B;
  cin >> A >> B;
  int ans = -1;
  rep(i, 10001){
    if((8 * i / 100) == A && i / 10 == B){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int data[101],n,i,max=0;
	for(i=0;i<101;i++) data[i]=0;
	while(scanf("%d",&n)!=EOF){
		data[n]++;
		if(data[n]>max) max = data[n];
	}
	for(i=0;i<101;i++){
		if(data[i]==max) printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 1028
n = int(input())
scaffolding = input().rstrip().split()
scaffolding = list(map(int, scaffolding))
res=[0 for i in range(n)]
res[1]=abs(scaffolding[1]-scaffolding[0])

for i in range(2,n):
    cost_1 = abs(scaffolding[i]-scaffolding[i-1])
    cost_2 = abs(scaffolding[i]-scaffolding[i-2])
    res[i]= min(res[i-1]+cost_1, res[i-2]+cost_2)

print(res[n-1])

Measured memory_bytes: 20404
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(data, 10, sizeof(int), compare_int)

//long long int a[100100];

int main(){
	int x[10];
	int ans=0;
	for(int i=0; i<5; i++){
		scanf("%d", &x[i]);
		if(x[i] == 0) ans = i;
	}
	//scanf("%d%d", &n, &k);
	
	printf("%d", ans+1);
	
	return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define REP(i, n) for(int i=0; i<n; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9+7;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    int n; cin >> n;
    int ans = 0;
    int tmp = 0;
    for(int i=1; i<=n; i+=2){
        tmp = 0;
        for(int j=1; j<=i; j++){
            if(i%j == 0) tmp += 1;
        }
        if(tmp == 8) ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
import io

nime, mike = map(int, input().split())
mod = 2*mike
array = [[0]*(2*mike+1) for _ in range(2*mike+1)]

def gen_pattern(x):
    if x < mike-1:
        return [[0, x+1], [x+mike+1, 2*mike]]
    else:
        return [[x-mike+1, x+1]]

for _ in range(nime):
    x, y, c = input().split()
    x, y = int(x), int(y)
    if c == 'W':
        y += mike
    x %= mod
    y %= mod
    for tmp in [0, mike]:
        for l, r in gen_pattern((x+tmp) % mod):
            for b, t in gen_pattern((y+tmp) % mod):
                array[l][b] += 1
                array[l][t] -= 1
                array[r][b] -= 1
                array[r][t] += 1
print(np.max(np.cumsum(np.cumsum(array, axis=0), axis=1)))

Measured memory_bytes: 106412
import sys
input = sys.stdin.readline
mod=10**9+7
n_max=2*10**5
F,FI=[0]*(n_max+1),[0]*(n_max+1)
F[0],FI[0]=1,1
for i in range(n_max):
  F[i+1]=(F[i]*(i+1))%mod
  FI[i+1]=pow(F[i+1],mod-2,mod)
def comb(x,y):
  return (F[x]*FI[x-y]*FI[y])%mod
n,a,b,c=map(int,input().split())
ans=0
aa,bb=a*pow(a+b,mod-2,mod),b*pow(a+b,mod-2,mod)
an,bn=pow(aa,n,mod),pow(bb,n,mod)
for i in range(n):
  ans+=(n+i)*(an*pow(bb,i,mod)+pow(aa,i,mod)*bn)*comb(n+i-1,i)
  ans%=mod
print((ans*100*pow(100-c,mod-2,mod))%mod)

Measured memory_bytes: 44012
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    bool a=false;bool b=false;
    char c;
    for(int i=0;i<3;i++){
        cin>>c;
        if(c=='A'){
            a=true;
        }else{
            b=true;
        }
    }
    if(a&&b){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <limits.h>
#include <assert.h>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long int
#define db double
#define ldb long double
#define MOD 1000000007
#define Fi first
#define Se second
#define INF INT_MAX
#define NINF INT_MIN
#define L_INF LLONG_MAX
#define L_NINF LLONG_MIN
#define gc getchar
#define sz(x) (int)(x).size()
#define pii pair<int,int>
#define pll pair<ll,ll>

void fsscan(){ios_base::sync_with_stdio(false);cin.tie(NULL);}

void scani(int &x)
{
    register int c = gc();x = 0;int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

int main()
{
    fsscan();
    int n;
    cin>>n;
    if(n==1)
    cout<<"Hello World";
    else
    {
        int a,b;
        cin>>a>>b;
        cout<<a+b;
    }
    return 0;
}


Measured memory_bytes: 256
INF = 10**10


def partition(ary, p, r):
    x = ary[r][1]
    i = p - 1
    for j in range(p, r):
        if ary[j][1] <= x:
            i += 1
            ary[i], ary[j] = ary[j], ary[i]

    ary[i + 1], ary[r] = ary[r], ary[i + 1]

    return i + 1


def quick_sort(ary, p, r):
    if p < r:
        q = partition(ary, p, r)
        quick_sort(ary, p, q - 1)
        quick_sort(ary, q + 1, r)


def merge(ary, left, mid, right):
    lry = ary[left:mid]
    rry = ary[mid:right]
    lry.append(('INF', INF))
    rry.append(('INF', INF))

    i = 0
    j = 0
    for k in range(left, right):
        if lry[i][1] <= rry[j][1]:
            ary[k] = lry[i]
            i += 1
        else:
            ary[k] = rry[j]
            j += 1

    return right - left


def merge_sort(ary, left, right):
    cnt = 0
    if left + 1 < right:
        mid = (left + right) // 2
        cnt += merge_sort(ary, left, mid)
        cnt += merge_sort(ary, mid, right)
        cnt += merge(ary, left, mid, right)

    return cnt


# if __name__ == '__main__':
import sys
from copy import deepcopy

n = int(input())
# ary = [(lambda x: (x[0], int(x[1])))(input().split()) for i in range(n)]

ary = [(lambda x: (x[0], int(x[1])))(line.strip().split()) for line in sys.stdin]

qary = deepcopy(ary)
mary = deepcopy(ary)
quick_sort(qary, 0, n - 1)
merge_sort(mary, 0, n)

if qary == mary:
    print('Stable')
else:
    print('Not stable')
[print(*_) for _ in qary]



Measured memory_bytes: 19292
#include <iostream>
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

int main(void){
  int N;
  cin >> N;
  int A[N];
  bool flag = true;
  rep(i, N){
    cin >> A[i];
    if((A[i]&1) == 1)
      flag = 0;
  }
  //入力終了

  int ans = 0;
  while(flag){
    rep(i, N){
      A[i] = A[i]/2;
      //奇数になったらフラグをfalseにして終了
      if((A[i]&1) == 1)
	flag = false;
    }
    ans++;
  }

  //解答
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3604
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;

void main()
{
	int n = readln.chomp.to!int;
	int[] a = readln.chomp.split.map!(to!int).array;
	int[] b = readln.chomp.split.map!(to!int).array;
	int[][] modsA = new int[][](30, n);
	int[][] modsB = new int[][](30, n);
	int m = 2;
	foreach (k; 0..30) {
		foreach (i; 0..n) {
			modsA[k][i] = a[i] % m;
			modsB[k][i] = b[i] % m;
		}
		std.algorithm.sort(modsB[k]);
		m <<= 1;
	}
	int[] atom = new int[](31);
	m = 1;
	foreach (k; 0..30) {
		// [k, m].writeln;
		// modsB[k].writeln;
		foreach (i; 0..n) {
			const int c = modsA[k][i];
			// [T - c, 2T - c)
			int t = m;
			auto arr = modsB[k].assumeSorted;
			// writeln("\t\t", arr, " (", c, ") ", arr.lowerBound(t - c), " <=> ", arr.lowerBound(2 * t - c));
			int left = cast(int)arr.lowerBound(t - c).length;
			int right = cast(int)arr.lowerBound(2 * t - c).length;
			int sub = right - left;
			sub = sub.max(0);
			// writeln("\t\t\tsub := ", sub);
			// [3T - c, 4T - c)
			// writeln("\t\t", arr, " (", c, ") ", arr.lowerBound(3 * t - c), " <=> ", arr.lowerBound(4 * t - c));
			int left2 = cast(int)arr.lowerBound(3 * t - c).length;
			int right2 = cast(int)arr.lowerBound(4 * t - c).length;
			int sub2 = right2 - left2;
			// writeln("\t\t\tsub2 := ", sub2);
			sub2 = sub2.max(0);
			atom[k] = (atom[k] + sub + sub2) % 2;
		}
		// writefln("...atom[%d] = %d", k, atom[k]);
		m <<= 1;
	}
	// atom.writeln;
	int ans = 0;
	foreach (i, v; atom) {
		ans |= v << i;
	}
	ans.writeln;
}

Measured memory_bytes: 64680
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main()
{
  string s;
  cin>>s;
  ll ans=0;
  int l,r,num;
  for(int i=s.size()-1;i>=0;i--)
  {
    l=i;
    r=s.size()-1-i;
    num=s.at(i)-'0';
    rep(j,r+1)
    {
      ans+=num*pow(10,j)*pow(2,l)*pow(2,max(r-j-1,0));
    }
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
import math
def isPrime(x):
    if x <= 1:
        return False

    for i in range(2,int(math.sqrt(x))+1):
        if x % i == 0:
            return False

    return True
n = int(input())
ans = 0
for i in range(n):
    a = int(input())
    b = isPrime(a)
    if b:
        ans+=1
print(ans)


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

int digitsum(long long);
int sentou(long long);


int main(){
    long long N,M=1;
    int keta=0,aMax=0,bMax=0;
    
    cin>>N;

    keta = log10(N)+1;
    //16
    for(int i=0;i<keta-1;i++){
        M*=10;
    }
    //15
    for(int i=0;i<keta-1;i++){
        aMax+=9;
    }
    
    if(sentou(N)!=sentou(N+1)){
        cout<<digitsum(N)<<endl;
    }else if(N==M){
        cout<<aMax<<endl;
    }else{
        cout<<digitsum(sentou(N)*M-1)<<endl;
    }
    

    return 0;
}

//16
int digitsum(long long N){
    int tmp=0;
    while(N){
        tmp+=N%10;
        N/=10;
    }

    return tmp; 

}

int sentou(long long N){
    int sentou;
    while(N){
        sentou=N%10;
        N/=10;
    }
    return sentou;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int w,h,x,y,r;
    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
    if(x-r < 0 ||y-r < 0 ||x+r > w ||y+r > h){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 584
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if((a*b)%2 == 0) {
	        System.out.println("Even");
		}else {
			System.out.println("Odd");
		}
        sc.close();
	}

}

Measured memory_bytes: 21844