akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES

#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
#include <ctgmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll inf = 10e17;
const ll mod = inf;//1000000007;
const ld eps = 10e-9;



ll solve(void);
ll gcd(ll x, ll y);


ll mulmod(ll x, ll y)
{
	return (x * y) % mod;
}

ll submod(ll x, ll y)
{
	return (x - y + 100 * mod) % mod;
}

ll power(ll n, ll r)
{
	if ( r == 0 ) { return 1; }
	if ( r == 1 ) { return n; }
	if ( n == 0 ) { return 0; }
	if ( n == 1 ) { return 1; }

	if (r % 2 == 0)
	{
		ll y = power(n, r/2);
		return mulmod(y, y);
	}
	else
	{
		ll y = power(n, (r-1)/2);
		return n * mulmod(y, y) % mod;
	}
}

ll gcd(ll x, ll y)
{
	if (y == 1) { return 1;}
	if (x % y == 0) { return y; }
	return gcd(y, x % y);
}

vector<ll> perm;
vector<ll> inv;
void init_inv(ll m)
{
	perm.resize(m);
	inv.resize(m);
	
	perm[0] = 1;
	inv[0] = 1;

	for (ll i = 1; i < m; i++)
	{
		perm[i] = mulmod(perm[i-1], i);
	}
	
	for (ll i = 1; i < m; i++)
	{
		inv[i] = power(perm[i], mod - 2);
	}
}

ll ncr(ll n, ll r)
{
	// n (n-1) ... (n-r)
	if ( r == n || r == 0 ) { return 1; }

	ll ans = 1;
	for (ll i = 0; i < r; i++)
		ans = mulmod(ans, n - i);

	 return mulmod(ans, inv[r]);
	// return mulmod(perm[n], mulmod(inv[n-r], inv[r]));
}

bool binary_check(ll mid, ll key)
{
	return mid >= key;
}

ll binary_search()
{
//	ll ng = 0;
//	ll ok = x;
//
//	while (abs(ok - ng) > 1)
//	{
	//	ll mid = (ok+ng) / 2;
	//	if (binary_check(mid, k)) ok = mid;
	//	else ng = mid;
	//}

	return 0;
	//return ok;
}

ll a, b, n;

ll f(ll x)
{
	return (a * x) / b - (x) / b;
}

ll solve(void)
{
	cin >> a >> b >> n;

	cout << min(f(b-1), f(n)) << endl;

	return 0;
}

int main(void)
{
	while (solve())
	{
	}
	return 0;
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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 n, num_a, num_b, num_c;
int a[310];
double dp[310][310][310];

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

    cin >> n;
    num_a = 0, num_b = 0, num_c = 0;
    rep(i, 0, n) {
        cin >> a[i];
        if(a[i] == 1) num_a++;
        else if(a[i] == 2) num_b++;
        else num_c++;
    }

    rep(c, 0, n + 1) rep(b, 0, n + 1) rep(a, 0, n + 1) {
        if(a == 0 and b == 0 and c == 0) continue;
        dp[a][b][c] = 1.0 * n;
        if(a > 0) dp[a][b][c] += 1.0 * a * dp[a - 1][b][c];
        if(b > 0) dp[a][b][c] += 1.0 * b * dp[a + 1][b - 1][c];
        if(c > 0) dp[a][b][c] += 1.0 * c * dp[a][b + 1][c - 1];
        dp[a][b][c] *= 1.0 / (a + b + c);
    }

    printf("%.10f\n", dp[num_a][num_b][num_c]);
}


Measured memory_bytes: 227584
N, M = map(int, input().split())
req = [tuple(map(int, input().split())) for _ in range(M)]
req.sort(key=lambda x: x[1])

res = 0
i = 1
for m in range(M):
    if req[m][0] >= i:
        i = req[m][1]
        res += 1

print(res)


Measured memory_bytes: 18248
S = input()

head = int(S[:2])
tail = int(S[2:])

ans = "NA"
if 1 <= head <= 12:
    if 1 <= tail <= 12:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"
elif 1 <= tail <= 12:
    ans = "YYMM"

print(ans)


Measured memory_bytes: 38256
import numpy as np

def main():
    N, K = (int(x) for x in input().split())
    h = np.array([int(x) for x in input().split()])
    INF = 10**10
    dp = np.array([INF]*N)
    dp[0] = 0

    for i in range(N):
        dp[i:i+K+1] = np.minimum(dp[i:i+K+1], dp[i]+np.abs(h[i:i+K+1]-h[i]))

    print(int(dp[N-1]))

if __name__ == '__main__':
    main()

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a > c) swap(a, c);
  if(a > b) swap(a, b);
  if(b > c) swap(b, c);
  
  cout << (c - b) + (b - a) << endl;
  return 0;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    
    set<long long int> s;
    for(int n=0; n<N; n++) {
        long long int num;
        cin >> num;

        if(s.count(num)) {
            s.erase(num);
        } else {
            s.insert(num);
        }
    }

    cout << s.size() << endl;

    return 0;
    
}

Measured memory_bytes: 4864
fun main(args : Array<String>) {
    val (h, w) = readLine()!!.split(' ').map(String::toInt)
    val s = Array(h) { readLine()!! }
    for (i in 0 .. h - 1) {
        val sb = StringBuilder("")
        for (j in 0 .. w - 1) {
            sb.append(if (s[i][j] == '#' || isBlue(i, j, h, w)) '#' else '.')
        }
        println(sb)
    }
    println()
    for (i in 0 .. h - 1) {
        val sb = StringBuilder("")
        for (j in 0 .. w - 1) {
            sb.append(if (s[i][j] == '#' || !isBlue(i, j, h, w)) '#' else '.')
        }
        println(sb)
    }
}

fun isBlue(i : Int, j : Int, h : Int, w : Int) : Boolean {
    return j == 0 || j != w - 1 && i % 2 == 0
}

Measured memory_bytes: 26968
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

//二項係数（nCk mod.p;1<=k<=n<=1e7,pは素数）
struct Combination{
    const int MOD = 1000000007;
    vector<ll> fac,finv,inv;
    Combination(const int MAX):fac(MAX),finv(MAX),inv(MAX){
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    long long comb(int n, int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
};

int factdp[3000];

ll fact(ll x){
    if(x==0)return 1;
    if(factdp[x]!=0)return factdp[x];
    return factdp[x]=x*fact(x-1)%1000000007;
}

int main(){
    ll N,K;cin >> N >> K;
    Combination C(10000);
    FOR(i,1,K+1){
        ll r = C.comb(K-1,i-1);
        ll a = r%1000000007;
        cout << a*C.comb(N-K+1,i)%1000000007 << endl;
    }
    return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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 (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

ll count_AB(string s){
  ll x = s.size();
  ll ans = 0;
  REP(i, x - 1){
    if(s[i] == 'A' && s[i + 1] == 'B') ans++;
  }
  return ans;
}
int main(){
  ll n; cin >> n;
  vector<string> s(n); REP(i, n) cin >> s[i];
  ll ans = 0;
  REP(i, n){
//    printf("s[i] = %sに含まれるABの個数は%lld個です\n", s[i].c_str(), count_AB(s[i]));
    ans += count_AB(s[i]);
  }
  ll p = 0, q = 0, r = 0;
  REP(i, n){
    if(s[i].front() == 'B' && s[i].back() == 'A') p++;
    else if(s[i].back() == 'A') q++;
    else if(s[i].front() == 'B') r++;
  }
  if(p != 0){
    ans += p - 1;
    if(q != 0){ans++; q--;}
    if(r != 0){ans++; r--;}
    ans += min(q, r);
  }
  else{
    ans += min(q, r);
  }
  cout << ans << endl;

}


Measured memory_bytes: 768
#include<cstdio>  
#include<cstring>  
#include<algorithm> 
#include<iostream>
#include<cmath> 
using namespace std;  
#define LL long long  
#define G  110000  

const int mod=1e9+7;
LL pri[G];  
LL ni[G],ans=1; 
int prm[32],step=0;
LL pow(LL a,int b)  
{  
    LL ans=1,base=a;  
    while (b)  
    {  
        if (b&1)  
            ans=(base*ans)%mod;  
        base=(base*base)%mod;  
        b>>=1;  
    }  
    return ans;  
}  
void s() 
{  
    pri[0]=1;  
    for(int i=1;i<=G;i++)  
    {  
        pri[i]=(pri[i-1]*i)%mod;
    }
    ni[G]=pow(pri[G],mod-2);
    for(int i=G-1;i>=0;i--)
    ni[i]=(ni[i+1]*(i+1))%mod; 
}
void divide(int n)
{
	for(int i=2;i<=sqrt(n);i++)
	{
		if(n%i==0) step++;
		while(n%i==0)
		{
			n/=i;
			prm[step]++;
		}
	}
	if(n>1){
		prm[++step]=1;
	}
	
}
int main()  
{  
    int n,m;
    scanf("%d%d",&n,&m);
	s();
    divide(m);
    for(int i=1;i<=step;i++) 
    {  
    long long now=(pri[n+prm[i]-1]*ni[n-1])%mod*ni[prm[i]]%mod;
    ans=ans*now%mod;} 
    printf("%lld",ans);
    return 0;  
}

Measured memory_bytes: 2048
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN           PIC X(500).
01 N            PIC 9(3).
01 cur          PIC 9(10) VALUE 1.
01 i            PIC 9(18) VALUE 1.
01 j            PIC 9(18).
01 len          PIC 9(10). 
01 A            PIC 9(4) VALUE 1.
01 FLG          PIC 9(1) VALUE 1.

PROCEDURE DIVISION.
MAIN.
  ACCEPT N.
  ACCEPT LN.
  PERFORM N TIMES
      PERFORM VARYING j FROM cur BY 1 UNTIL LN(j:1) = SPACE
      END-PERFORM
      COMPUTE len = j - cur
      MOVE LN(cur:len) TO A
      IF FUNCTION MOD(A, 2) = ZERO AND FUNCTION MOD(A, 3) NOT = ZERO
          AND FUNCTION MOD(A, 5) NOT = ZERO THEN
          MOVE ZERO TO FLG
          EXIT PERFORM
      END-IF
      COMPUTE cur = j + 1
      ADD 1 TO i
  END-PERFORM.
  IF FLG = 1
      DISPLAY "APPROVED"
  ELSE
      DISPLAY "DENIED"
  END-IF.

MAIN-EXIT.
  STOP RUN.


Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;
typedef pair<int, int> P;
bool IsPrime[30100];
vector<int> Prime;

void PrimeCalc()
{
	fill(IsPrime, IsPrime + 30100, true);
	IsPrime[0] = IsPrime[1] = false;
	for(int i = 2; i < 30100; ++i)
	{
		if(IsPrime[i])
		{
			Prime.push_back(i);
			for(int j = 2 * i; j < 30100; j += i)
			{
				IsPrime[j] = false;
			}
		}
	}
}

void solve()
{
	PrimeCalc();
	int n;
	while(cin >> n, n)
	{
		int size = Prime.size();
		set<long long int> Set;
		for(int i = 0; Prime[i] <= n; ++i)
		{
			for(int j = i; Prime[j] <= n; ++j)
			{
				if(n - Prime[i] - Prime[j] <= 0)
				{
					break;
				}
				if(n - Prime[i] - Prime[j] > 0 && IsPrime[n - Prime[i] - Prime[j]])
				{
					if(Prime[i] + Prime[j] > n - Prime[i] - Prime[j] &&
					   n - Prime[i] > Prime[i] &&
					   n - Prime[j] > Prime[j])
					{
						long long int a = Prime[i];
						a *= Prime[j];
						a *= n - Prime[i] - Prime[j];
						Set.insert(a);
					}
				}
			}
		}
		cout << Set.size() << endl;
	}
}

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

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

int main()
{
	
	int a;
	int b;

	int c;

	cin >> a;
	cin >> b;
	cin >> c;


	
	if (a <= c && c <= b)

		cout << "Yes" << endl;



	else

		cout << "No" << endl;
	
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,i,b,c;
    scanf("%d %d",&a,&b);
    c=a+b;
    if(a%3==0)
        printf("Possible\n");
    else if(b%3==0)
        printf("Possible\n");
    else if((a+b)%3==0)
        printf("Possible\n");
    else
        printf("Impossible\n");
    return 0;
}


Measured memory_bytes: 128
package main

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

// 標準偏差
func main() {
	sc := bufio.NewScanner(os.Stdin)
	s := ""
	for {
		sc.Scan()
		n, _ := strconv.Atoi(sc.Text())
		if n == 0 {
			break
		}

		ary := make([]float64, n)
		len := float64(n)
		var sum float64

		sc.Scan()
		for i, v := range strings.Split(sc.Text(), " ") {
			num, _ := strconv.ParseFloat(v, 64)
			ary[i] = num
			sum += num
		}
		m := sum / len
		var val float64
		for _, v := range ary {
			val += math.Pow(v-m, 2)
		}
		s += fmt.Sprintf("%v\n", math.Sqrt(val/len))
	}
	fmt.Print(s)
}



Measured memory_bytes: 1236
#include <iostream>
#include <cstring>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

typedef long long ll;

//             i
// 1 1 1 1 1 1 5

int ans;
char S[105], K[25];

int solve() {
	int i = 0;
	while ( S[i] == '1' && i < strlen(S) ) i++;

	if ( i == strlen(S) ) return 1;

	int retval = S[i] - '0';

	if (strlen(K) >= 4) return retval;

	int n = stoi(K) - 1;

	if (n < i) return 1;
	else return retval; 


}

int main(void) {
    scanf("%s", S);
    scanf("%s", K);
    
    printf("%d\n", solve());

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////


int main(){fastio
    
    ll a,b;cin>>a>>b;
           if(b==1){
             cout<<0<<endl;return 0;
           }
    ll x=a;
    ll c=1;
    while(x<b){
        c++;
        x+=a-1;
    }
    cout<<c<<endl;
    
    return 0;
}


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

std::vector<int> v(51),w(51);
int dfs(int N,int X){
  if(X<2000000)if(dp[N][X]!=-1)return dp[N][X];
  if(N>=X)return 0;
  if(N==0&&X)return 1;
  if(X<v[N]/2+1){
    if(X<2000000)dp[N][X]=dfs(N-1,X-1);
    return dfs(N-1,X-1);
  }
  if(X==v[N]/2+1){
    if(X<2000000)dp[N][X]=dfs(N-1,X-1)+1;
    return dfs(N-1,X-1)+1;
  }
  if(X>v[N]/2+1){
    if(X<2000000)dp[N][X]=w[N-1]+1+dfs(N-1,X-v[N-1]-2);
    return w[N-1]+1+dfs(N-1,X-v[N-1]-2);
  }
}


signed main(){
  int N,X;
  cin>>N>>X;
  v[0]=1;w[0]=1;
  for(int i=1;i<51;i++)v[i]=v[i-1]*2+3;
  for(int i=1;i<51;i++)w[i]=w[i-1]*2+1;
  for(int i=0;i<51;i++)for(int j=0;j<2000000;j++)dp[i][j]=-1;
  cout<<dfs(N,X)<<endl;
}


Measured memory_bytes: 797056
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

ans = 0
def main():
    H, W, K = map(int, readline().split())
    grid = []
    for _ in range(H):
        grid.append(list(input()))

    #再帰関数で二組の全bit探索を組む 
    #リストをコピーしない方法
    bitr = [0 for _ in range(H)]
    bitc = [0 for _ in range(W)]
    
    def dfsr(i): 
        if i == H:
            dfsc(0)
            return
        dfsr(i+1)
        bitr[i] = 1
        dfsr(i+1)        
        bitr[i] = 0
    
    def dfsc(i):
        global ans
        cnt = 0
        if i == W:
            #ここで処理をおこなう
            for j in range(H):
                #1が立っているならその行は全て赤とするので飛ばす
                if bitr[j] == 1: 
                    continue
                for k in range(W):
                    #1が立っているならその列は全て赤とするので飛ばす
                    if bitc[k] == 1:
                        continue
                    #飛ばされなかったマスのうち黒の数を数える
                    if grid[j][k] == '#':
                        cnt += 1
            if cnt == K:
                ans += 1
            return
        dfsc(i+1) 
        bitc[i] = 1
        dfsc(i+1)
        bitc[i] = 0
    
    dfsr(0)
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 75376
#include <iostream>

int main()
{
    int s1, s2, diag, rect = 0, diam = 0;
    char comma;
    while (std::cin >> s1 >> comma >> s2 >> comma >> diag) {
        if (s1 * s1 + s2 * s2 == diag * diag) ++rect;
        else if (s1 == s2) ++diam;
    }
    std::cout << rect << std::endl << diam << std::endl;
}

Measured memory_bytes: 1160
def main():
    n = int(input())
    s = input()
    dic = {'R':[],'G':[],'B':[]}
    for i in range(n):
        if s[i]== 'R':
            dic['R'].append(i)
        elif s[i]== 'G':
            dic['G'].append(i)
        else:
            dic['B'].append(i)
    cnt = len(dic['R'])*len(dic['G'])*len(dic['B'])
    for i in range(1,n//2+1):
        for j in range(n-2*i):
            if s[j]!=s[j+i] and s[j+i] != s[j+i+i] and s[j]!=s[j+i+i]:
                cnt -=1
    print(cnt)
     
            
if __name__ == "__main__":
    main()

Measured memory_bytes: 9224
#include<iostream>
using namespace std;
int main(void)
{
int n;
cin>>n;

for(int i=0;i<n;i++)
{
	int a[10]={0};
	for(int j=0;j<10;j++)
	{
	int x;
	cin>>x;
	a[j]=x;
	}
	int b=0,c=0,k;
		for(k=1;k<10;k++)
		{
			if(b<a[k])b=a[k];
			else if(c<a[k])c=a[k];
			else 
			{
			cout<<"NO"<<endl;
			break;
			}
		}
		if(k==10)cout<<"YES"<<endl;

}
return 0;
}

Measured memory_bytes: 1156
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n-1];

        for (int i = 0; i < n; i++) {
             a[i] = sc.nextInt() - 1;
        }

        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }

        for (int i = 0; i < n-1; i++) {
            c[i] = sc.nextInt();
        }

        int ans = b[a[0]];
        for (int i = 1; i < n; i++) {
            ans += b[a[i]];
            if (a[i]-1 == a[i-1])
                ans += c[a[i-1]];
        }

        System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 23252
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
//typedef long long int LL;
//typedef __int64 LL;

int n, x[100005];
int L;
int dp[18][100005];

void preprocess() {
	int end = n;
	for (int i = n; i >= 1; i--) {
		while (x[end] - x[i] > L) end--;
		dp[0][i] = end;
		for (int j = 1; j <= 17; j++) {
			dp[j][i] = dp[j - 1][dp[j - 1][i]];
		}
	}
}

int query(int a, int b) {
	if (a == b) return 0;
	int ret = 0;
	for (int i = 17; i >= 0; i--) {
		if (dp[i][a] >= b) continue;
		ret += 1 << i;
		a = dp[i][a];
	}
	while (a < b) {
		a = dp[0][a];
		ret++;
	}
	return ret;
}
int main()
{
	int Q, a, b;

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &x[i]);
	}

	scanf("%d", &L);
	preprocess();
	scanf("%d", &Q);
	for (int i = 1; i <= Q; i++) {
		scanf("%d %d", &a, &b);
		if (a > b) swap(a, b);
		printf("%d\n", query(a, b));
	}
	return 0;
}


Measured memory_bytes: 8192
import java.util.*;

public class Main {
	public static void main(final String[] args) {

        Scanner sc = new Scanner(System.in);

        // ボールの総数
        long n = sc.nextLong();

        // 末尾に加える青いボールの数
        long a = sc.nextLong();

        // 末尾に加える赤いボールの数
        long b = sc.nextLong();

        // 青いボールの個数
        long num = Math.floorDiv(n, (a + b)) * a;

        // 青いボールの端数
        long rem = n % (a + b);

        num += Math.min(a, rem);

        // 出力
        System.out.println(num);
    }
}

Measured memory_bytes: 22868
#include <iostream>

int main()
{
    using namespace std;

    long n, a, b;
    long blue, rest;

    cin >> n >> a >> b;

    if(n%(a+b) > a)
    {
        rest = a;
    } else
    {
        rest = n%(a+b);
    }

    blue = (n/(a+b)) * a + rest;

    cout << blue << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
int main()
{
    ll x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}

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

int main(void)
{
    char row, capital, small;

    while (1){
        scanf("%c", &row);
        if (row == '\n'){
            break;
        }else{
            capital = toupper(row);
            small = tolower(row);
            if (row == capital){
                printf("%c", small);
            }else{
                printf("%c", capital);
            }
        }
    }
    printf("\n");

    return 0;
}

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

int main()
{
    long long n,a[200005];
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<n;i++)
    {
    	if(a[i]==a[i+1])
    	{
    		cout << "NO";
    		return 0;
		}
	}
	cout << "YES";
	return 0;
}

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

int n, d;
vector<vector<int>> v;

int solve();

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

int solve() {
  int ans = 0;
  for(int i = 0; i < n; ++i)
    for(int j = i + 1; j < n; ++j) {
      int sum = 0;
      for(int k = 0; k < d; ++k)
        sum += (v[i][k] - v[j][k]) * (v[i][k] - v[j][k]);
      int x = sqrt(sum);
      if(x * x == sum) ++ans;
    }
  return ans;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    long long int a,b,c,k;
    cin>>a>>b>>c>>k;

    int sum = 0;
    for(int i=0;i<a;i++)
    {
        sum+=1;
        --k;
        if(k==0)
            break;
    }

    if(k>0)
    {
        for(int i=0;i<b;i++)
        {
            --k;
            if(k==0)
                break;
        }
    }
    if(k>0)
    {

        for(int i=0;i<c;i++)
        {
            sum--;
            --k;
            if(k==0)
                break;
        }
    }

    cout<<sum;
    
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
    for(auto &e:t) fill_v(e,v);
}

int main() {
  int n; cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];

  int sum = accumulate(a.begin(), a.end(), 0);

  int m = round(1.0 * sum / n);

  int ans = accumulate(a.begin(), a.end(), 0, [&](int acc, int x){
    return acc + (x - m) * (x - m);
  });

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H; cin >> H;
    if(H == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    if(H % 2 == 1) H--;
    ll a = 0;
    ll ans = 0, m = 1LL;
    while(H > 0)
    {
        H /= 2LL;
        ans += m;
        m *= 2LL;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a,b,i,sum,quotient;
    while(scanf("%d%d",&a,&b)!=EOF){
        sum=a+b;
        for(i=1;;i++)
        {
            quotient=sum/10;
            if(quotient!=0)
            {
                sum=quotient;
            }
            else if(quotient==0)
                break;
        }
        printf("%d\n",i);
    }
    return 0;
}

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

#define NMAX 100000
double dp[NMAX + 1];

int main()
{
  int n = NMAX;
  for (int i = 0; i < n + 1; i++) {
    dp[i] = 0.0;
  }
  for (int i = 0; i < n; i++) {
    long long int foo = 1;
    int bar = 1;
    for (int j = i + 1; j < n + 1 and foo < 1000000000; j++) {
      dp[j] += (1.0 - dp[i]) / foo;
      bar *= 2;
      foo *= bar;
    }
  }

  while (cin >> n and n > 0) {
    double ans = 0.0;
    for (int i = 1; i < n + 1; i++) {
      ans += dp[i];
    }
    printf("%.8f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1972
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

typedef struct edge{
    ll to;
    ll cost;
} edge;

typedef struct DP {
    ll cost;
    ll from;
} DP;

vector<edge> G[100002];

//自作構造体にしたいけど比較演算子の定義がわからないので保留
typedef pair<ll, ll> P; 

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    REP(i,n-1) {
        int a, b, c;
        cin >> a >> b >> c;
        G[a].push_back({b, c}); 
        G[b].push_back({a, c});
    }
    int q, k;
    cin >> q >> k;
    vector<int> x(q); 
    vector<int> y(q);
    REP(i,q) cin >> x[i] >> y[i];

    DP dp[n];
    REP(i,n) dp[i].cost = LINF;
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push({0, k});
        
    dp[k].cost = 0;
    while(!pq.empty()) {
        P now = pq.top(); pq.pop();
        ll v = now.second;
        if (dp[v].cost < now.first) continue;
        for (int i = 0; i < G[v].size(); ++i) {
            edge e = G[v][i];
            if (dp[e.to].cost > dp[v].cost+e.cost) {
                dp[e.to].cost = dp[v].cost+e.cost;
                dp[e.to].from = v;
                pq.push({dp[e.to].cost, e.to});
            }
        }
    }
    REP(i,q) {
        int X = x[i]; int Y = y[i];
        ll ans = dp[X].cost+dp[Y].cost;
        cout << ans << std::endl;
    }
    return 0;
}

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

using namespace std;

int main() {
  string s,t;
  cin >> s >> t;

  int ans = 0;
  for(int i = 0; i < s.length(); i++){
    if(s[i] != t[i]){
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3916
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    vector<int> p(n);
    for(int i=0; i<n; ++i)
        cin >> p[i];

    vector<int> minCost(n, INT_MAX);
    minCost[0] = 0;
    multimap<int, int> mm;
    mm.insert(make_pair(0, 0));
    while(!mm.empty()){
        int cost = mm.begin()->first;
        int pos = mm.begin()->second;
        mm.erase(mm.begin());
        if(cost > minCost[pos])
            continue;

        if(p[pos] == 0){
            for(int i=1; i<=6; ++i){
                int next = pos + i;
                if(next >= n)
                    break;
                if(cost + 1 < minCost[next]){
                    minCost[next] = cost + 1;
                    mm.insert(make_pair(cost + 1, next));
                }
            }
        }else{
            int next = pos + p[pos];
            if(cost < minCost[next]){
                minCost[next] = cost;
                mm.insert(make_pair(cost, next));
            }
        }
    }

    cout << minCost[n-1] << endl;

    return 0;
}

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

int main() {
	int N ;
	int mino, maxo;
	scanf("%d", &N);
	scanf("%d", &mino);
	maxo = mino;
	for(int i=1; i<N; i++) {
		int a ;
		scanf("%d", &a);
		mino = min(mino, a);
		maxo = max(maxo, a);
	}
	printf("%d\n", maxo - mino);
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] c = sc.next().toCharArray();
    Arrays.sort(c);
    System.out.println(c[0]-c[2] != 0 && c[0]-c[1]+c[2]-c[3] == 0 ? "Yes" : "No");

  }
}

Measured memory_bytes: 35828
#!/usr/bin/python3
# -*- coding: utf-8 -*-


N = int(input())
An = list(map(int, input().split()))
Bn = list(map(int, input().split()))
Cn = list(map(int, input().split()))

ret = Bn[An[0]-1]
for i in range(1,N):
  ret += Bn[An[i]-1]
  if An[i] == An[i-1]+1:
    ret += Cn[An[i-1]-1]
print(ret)

Measured memory_bytes: 38484
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	int n=Integer.parseInt(input.readLine());
	for(int i=0;i<n;i++)
	    {
		int out=0,hit=0,count=0;
		while(out!=3)
		    {
			String str=input.readLine();
			if(str.equals("HIT"))hit++;
			else if(str.equals("OUT"))out++;
			else if(str.equals("HOMERUN"))
			    {
				count+=hit+1;
				hit=0;
			    }
			if(hit==4)
			    {
				count++;
				hit--;
			    }
		    }
		System.out.println(count);
	    }
    }
}

Measured memory_bytes: 16868
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 

int main() {
  int a, b; cin >> a >> b;
  if (a * b % 2 == 0) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		int mod = 0;
		for (int i=0; i<s.length(); i++){
			int c = s.charAt(i) - '0';
			mod += c;
			mod %= 9;
		}
		if (mod == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}


}

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

int main()
{
    long long q,h,s,d,n;
	cin>>q>>h>>s>>d>>n;
    long long t=min({n*4*q,n*2*h,n*s});
    cout<<min(n/2*d+n%2*t/n,t)<<endl;
    return 0;
}


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

/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)

/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define MP make_pair 

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/* func */

/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

//#define int ll
//#define int long long

signed main()
{
  char b; cin >> b;
  
  if(b == 'A')
    cout << 'T';
    if(b == 'T')
      cout << 'A';
      if(b == 'C')
        cout << 'G';
        if(b == 'G')
  cout << 'C';
  

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef  long long int ll;
typedef long double ld;
#define pb  push_back
#define vll vector<ll>
#define mll map<ll,ll>
const double PI = 2*acos(0.0);
#define gcd(a,b)   __gcd((a),(b))
#define lcm(a,b)   ((a)/(__gcd((a),(b)))*(b))
#define INF         LLONG_MAX
#define ln  INT_MAX
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;
int main(){
string a,s;
cin>>a>>s;
ll k,p=0,l=0,m=1e5;
for(int i=0; i<a.size(); i++){
 p=0;
for(int j=0; j<s.size(); j++){
        if((i+j)>=a.size()){l++; break;}
        else{
if(s[j]!=a[i+j]){p++;}

        }
 }
 if(l==0){
 m=min(m,p); }}
 cout<<m;

return 0;
}


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

int main(){
  int n;
  cin>>n;
  int ans=0,b_=0,_a=0,b_a=0;
  rep(i,n){
    string s;
    cin>> s;
    int m=s.size();
    if(s[0]=='B') b_++;
    if(s[m-1]=='A') _a++;
    if(s[0]=='B' and s[m-1]=='A') b_a++;
    rep(j,m-1){
      if(s[j]=='A' and s[j+1]=='B') ans++;
    }
  }
  ans+= min(b_,_a);
  if(_a==b_ and b_==b_a and b_a!=0 ) ans--;
  cout << ans;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n,w;
    cin>>n>>w;
    vector<ll> wei(n),val(n);
    rep(i,n) cin>>wei[i]>>val[i];
    
    //vector<map<int,ll>> dp(110);
    vector<vector<ll>> dp(110,vector<ll>(110110,LINF));
    dp[0][0]=0;
    //dp[i][j]->i個目までみて価値jになるように詰めたときの重さのmin
    rep(i,n) {
        rep(j,100100) {
            if(j-val[i]>=0) dp[i+1][j]=min(dp[i+1][j],dp[i][j-val[i]]+wei[i]);
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
        }
    }
    
    int ans=0;
    rep(j,100100) {
        if(dp[n][j]<=w) ans=j;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 96128
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if a*500 + b*100 + c*50 == X:
                count += 1
print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int A, B;
	cin >> A >> B;
	cout << A * B << endl;
}


Measured memory_bytes: 3636
import heapq
import math
class Graph:
    def __init__(self,v,adj,w_v = None):
        super().__init__()
        self.v = v
        self.w_e = [{} for _ in [0]*self.v]
        self.neighbor = [[] for _ in [0]*self.v]
        
        self.w_v = w_v

        for i, adj_i in enumerate(adj):
            for j, w in enumerate(adj_i):
                self.w_e[i][j] = w #weight of edge
                self.neighbor[i].append(j)

    def dijkstra(self,v_n):
        d = [10**18]*self.v
        d[v_n] = 0
        prev = [-1]*self.v

        queue = []
        for i,d_i in enumerate(d): heapq.heappush(queue,(d_i,i))
        
        while len(queue)>0:
            d_u,u = queue.pop()
            if d[u]<d_u :continue
            for v in self.neighbor[u]:
                alt = d[u]+self.w_e[u][v]
                if d[v]>alt:
                    d[v] = alt
                    prev[v] = u
                    heapq.heappush(queue,(alt,v))

        return d,prev
    
    def WarshallFloyd(self):
        d = [[10**18]*self.v for _ in [0]*self.v]
        for i in range(self.v):
            for j in self.neighbor[i]:
                d[i][j] = self.w_e[i][j]
                
        for i in range(self.v):
            for j in range(self.v):
                for k in range(self.v):
                    check = d[i][k] + d[k][j]
                    if d[i][j] > check:
                        d[i][j] = check
        return d

def main():
    n = int(input())

    a = [[int(t)for t in input().split()]for _ in [0]*n]

    g = Graph(n,a)
    a_check = g.WarshallFloyd()

    s = 0
    for i in range(n):
        for j in range(n):
            a_ij = a[i][j]
            if a_ij != a_check[i][j]:
                print(-1)
                return
            if sum([a_ij == a[i][k] + a[k][j] for k in range(n) if k != i and k != j]) == 0:
                s+=a_ij
    print(s//2)

if __name__ == "__main__":
    main()


Measured memory_bytes: 53468
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

const int M = 1e9+7;

using namespace std;

map<ll,ll> f;

ll solve (ll x)
{
    if (f.find(x)!=f.end())
        return f[x]%M;
    f[x]=(solve(x/2)%M+solve((x-1)/2)%M+solve((x-2)/2)%M)%M;
    return f[x]%M;
}

main()
{
    fast;
    ll n;
    f[0]=1;
    f[1]=2;
    cin>>n;
    cout<<solve(n)<<endl;
}

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

int main() {
  int a,b;
  cin>>a>>b;
  if(a==b){
    cout<<"Draw"<<endl;
  }
  else if(a==1){
    cout<<"Alice"<<endl;
  }
  else if(b==1){
    cout<<"Bob"<<endl;
  }
  else if(a<b){
    cout<<"Bob"<<endl;
  }
  else{
    cout<<"Alice"<<endl;
  }
  
}

Measured memory_bytes: 256
N = int(input())
mod = 10 ** 9 + 7
memo = [{} for i in range(N+1)]
#print (memo)


#4文字を与えて条件に合致するかを判断
def check(last4):
    for i in range(4):
        t = list(last4) #4文字をリストに格納
        if i >= 1: #最初の文字以外に着目する時
            t[i-1], t[i] = t[i], t[i-1] #i番目とi-1番目を交換
        if ''.join(t).count('AGC') >= 1: #AGCが含まれているかどうかの確認
            return False
    return True

def dfs(cur, last3): #深さ優先探索
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in 'ATCG':
        if check(last3+c):
            ret = (ret+dfs(cur+1, last3[1:]+c))%mod
    memo[cur][last3] = ret
    return ret

print (dfs(0, 'TTT'))


#print (memo)

Measured memory_bytes: 47320
#include <bits/stdc++.h>
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;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

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

ll f(ll n) {
    ll now = 1;
    while(now * (now + 1) / 2 <= n) {
        now++;
    }
    now--;
    return now;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    auto mp = prime_factor(n);
    ll ans = 0;
    for(auto p : mp) {
        ans += f(p.second);
    }
    print(ans);
}

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

#define INF 100100100
#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long ;

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

   int N;
   cin>>N;

   string s = to_string(N);
   ll sum=0;
   for(int i=0;i<s.size();i++){
      sum += (int)(s[i]-'0');
   }

   if(N%sum==0)cout<<"Yes";
   else cout<<"No";
   return 0;
}


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

using namespace std;

//#define FILE_IO

const int KMAX = 1e5;

int N, K;
int a[105];
bitset<KMAX + 5> dp, done;

bool win(int K)
{
    if(done[K]) return dp[K];
    done[K] = 1;
    bool ok = false;
    for(int i = 1; i <= N; i++)
        if(K >= a[i])
            ok |= (!win(K - a[i]));
    dp[K] = ok;
    return dp[K];
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    //freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d", &N, &K);
    for(int i = 1; i <= N; i++)
        scanf("%d", &a[i]);

    int ans = win(K);

    if(ans) printf("First\n");
    else    printf("Second\n");

    return 0;
}


Measured memory_bytes: 8064
//  Created by liszt on 2019/07/22.
#include<bits/stdc++.h>
using namespace std;

int main(){
    string s,t; cin>>s >>t;
    int n=s.size();
    vector<int> cs(26,0),ct(26,0);
    for(int i=0;i<n;i++){
        cs[s[i]-'a']++;
        ct[t[i]-'a']++;
    }
    sort(cs.begin(),cs.end());
    sort(ct.begin(),ct.end());
    for(int i=0;i<26;i++){
        if(cs[i]!=ct[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 776
import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int n = Integer.parseInt(sc.next());
            long[] points = new long[n+2];
            long sum = 0;
            points[0] = 0;
            points[n+1] = 0;
            
            for(int i=1; i<n+1; i++){
            	points[i] = Long.parseLong(sc.next());
            	sum += Math.abs(points[i-1] - points[i]);
            }
            sum += Math.abs(points[n]);
            
            //出力
            for(int i=1; i<n+1; i++){
            	System.out.println(sum - Math.abs(points[i] - points[i-1]) - Math.abs(points[i] - points[i+1]) + Math.abs(points[i+1] - points[i-1]));
            }
            sc.close();
        }
    }


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

char S[200100];
int main() {
  cin >> S;
  int len = strlen(S);
  long long sum=0;
  for(int i=0; i<len; i++) {
    sum += S[i]-'0';
  }
  if(sum%9==0) cout << "Yes" << endl;
  else cout << "No" << endl;;
}

Measured memory_bytes: 3732
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 == 15) {
            System.out.println("+");
        } else if (a * b == 15) {
            System.out.println("*");
        } else {
            System.out.println("x");
        }
    }
}


Measured memory_bytes: 21844