akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
long long a[100010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%lld",a+i);

	int zero=0;
	for(int i=0;i<n;i++)if(a[i]==0)zero++;
	if(zero>0){
		puts("0");
		return 0;
	}
	
	long long prod=1;
	for(int i=0;i<n;i++){
		if(a[i]<=1000000000000000000/prod){
			prod*=a[i];
		}else{
			puts("-1");
			return 0;
		}
	}
	printf("%lld",prod);
}


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

int main()
{
    int i;

    //Input
    int ch;
    char s[1200];
    for( i = 0; (ch = getchar()); ++i ){
        if( ch == '\n' ){ s[i] = '\0'; break; }
        else s[i] = ch;
    }

    //Processing
    for( i = 0; s[i]; ++i ){
        if( isalpha(s[i]) ){
            if( islower(s[i]) ) s[i] = toupper(s[i]);
            else s[i] = tolower(s[i]);
        }
    }

    //Output
    printf("%s\n", s);

    return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
#define PI 3.14159265359
 
int main() {
  double R;
  cin >> R;
 
  double ret = double(2) * R * PI;
  printf("%lf\n", ret);
  return 0;
}

Measured memory_bytes: 3744
N, X = map(int, input().split())

mn = [0]*N
for i in range(N):
  mn[i] = int(input())
  
ans = N
x = X - sum(mn)

while(x >= min(mn)):
  if x // min(mn) == 0:
    mn[mn.index(min(mn))] = 1000000
  else:
    if x >= min(mn):
      x -= min(mn)
      ans += 1
      
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
using namespace std;

class Observatory{
  public:
    int hight;
    bool highest_flag;
    vector<Observatory *> nexts;

    void init(int input){
      this->hight = input;
      this->highest_flag = true;
    }
};

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

  vector<Observatory> observatory(N);
  int input, A, B, most_view_cnt;
  Observatory *target;
  int i, j;

  for(i=0; i<N; i++){
    cin >> input;
    observatory.at(i).init(input);
  }
  
  for(i=0; i<M; i++){
    cin >> A >> B;
    observatory.at(A-1).nexts.push_back(&(observatory.at(B-1)));
    observatory.at(B-1).nexts.push_back(&(observatory.at(A-1)));
  }

  most_view_cnt = 0;
  for(i=0; i<N; i++){
    for(j=0; j<observatory.at(i).nexts.size(); j++){
      target = observatory.at(i).nexts.at(j);
      if(observatory.at(i).hight <= target->hight){
        observatory.at(i).highest_flag = false;
      }
    }
    if(observatory.at(i).highest_flag){
      most_view_cnt++;
    }
  }
  cout << most_view_cnt << endl;
}

Measured memory_bytes: 9820
#include <iostream>
#include <string>

using namespace std;

int main(){

	string s;
	cin>>s;
	int n=s.size();
	int x=n-1;
	long long int ans=0;
	for(int i=n-1;i>-1;i--){
		if(s[i]=='B'){
			ans+=x-i;
			x--;
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 3716
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  vi v(2);
  v.at(0) = c - a;
  v.at(1) = d - b;
  rep(i,2){
    swap(v.at(0), v.at(1));
    v.at(0) *= -1;
    c += v.at(0);
    d += v.at(1);
    cout << c << " " << d;
    if(i==0){
      cout << " ";
    }else{
      cout << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
	bool is_visited;
} edge;

int main( void ){
	int N; cin >> N;
	vector<int> vec(N);
	double sum = 0;
	rep(i,0,N){
		cin >> vec[i];
		sum += (double)vec[i];
	}
	sum /= N;
	int balance0 = (int)ceil(sum), balance1 = (int)floor(sum);
	int cost[2] = {};
	rep(i,0,N){
		cost[0] += (vec[i]-balance0)*(vec[i]-balance0);
		cost[1] += (vec[i]-balance1)*(vec[i]-balance1);
	}
	cout << min(cost[0], cost[1]) << endl;;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

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

    if (abs(a - b) > 1e18) MSG("Unfair")
    else {
        if (k % 2 == 0) {
            MSG(a - b)
        } else {
            MSG(b - a)
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
  cin>>n;
  int h[n],dp[n+1];
   int i;
  for(i=0;i<n;i++) cin>>h[i];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(i=2;i<n;i++){
    dp[i]=min(dp[i-1] + abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
#define mod 1000000007
long long dp[102][100005];

long long solution(int* arr , int n , int k){
    for(int j=0 ; j<=k ; j++){
        if(j<=arr[0]){
            dp[0][j] = 1;
        }
    }

    
    for(int i=1 ; i<n ; i++){
        for(int j=0 ; j<=k ; j++){
            if(j==0){
                dp[i][j] = dp[i-1][j];
            }else{
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
                if(j-arr[i]-1 >= 0){
                    dp[i][j] = (dp[i][j] - dp[i-1][j-arr[i]-1]+mod)%mod;
                }
            }
        }      
    }

    // for(int i=0 ; i<n ; i++){
    //     for(int j=0 ; j<=k ; j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    
    return dp[n-1][k];
}


int main(){
    int n,k;
    cin>>n>>k;
    int* arr = new int[n];
    for(int i=0 ; i<n ; i++){
        cin>>arr[i];
    }
    cout<<solution(arr , n , k)<<endl;
}

Measured memory_bytes: 78336
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
int b=scan.nextInt();
int c=scan.nextInt();
int d=scan.nextInt();
if((a+b)<(c+d)) {
System.out.println("Right");
}
else if((a+b)>(c+d)){
	System.out.println("Left");
}
else {
	System.out.println("Balanced");
}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    bool flag=false;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==n) flag=true;
        }
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	int N;
	cin >> N;
	vector<int> A(N);
	map<int, int> mp;
	ll sum = 0;
	REP(i, N) {
		cin >> A[i];
		mp[A[i]]++;
		sum += A[i];
	}
	int Q;
	cin >> Q;
	REP(q, Q) {
		int B, C;
		cin >> B >> C;
		sum += (C - B) * mp[B];
		mp[C] += mp[B];
		mp.erase(B);
		cout << sum << endl;
	}

	return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string s;
int n, k, t;

int main() {
	cin >> s >> k;
	n = s.length();
	rep(i,n) {
		// kを無駄遣いしないように
		if (s[i]=='a') continue;
		// t回操作すればi文字目をaにできる
		t = 26 - (s[i]-'a');
		if (t<=k) {
			s[i] = 'a';
			k -= t;
		}
	}
	// 余った分は適当に最後の文字に足す
	s[n-1] += k%26;
	cout << s << ln;
}

Measured memory_bytes: 592
//diverta 2019 Programming Contest
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
    int r,g,b,n;
    cin>>r>>g>>b>>n;

    int ans=0;
    int nokori;
    rep(i,n+1){
        rep(j,n+1){
            nokori = (n-(r*i+g*j));
            if(nokori % b == 0 && nokori >= 0){
                //cout<<i<<" "<<j<<endl;
                ++ans;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<string.h>
#include<cstdio>
using namespace std;
int main(){
	char s[100];
	int o;
	gets(s);
	o=strlen (s);
	int count=0;
	for(int i=0;i<=o;i++){
		if(s[i]=='C') count=1;
		if(s[i]=='F'&&count==1) count=2;
	}
	if(count==2) printf("Yes");
	else printf("No");
	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max({a*c, a*d, b*c, b*d}) << '\n';
  return 0;   
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
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; }

int main(){
    int N,M;
    cin>>N>>M;
    vector<int> A(M,0);
    for(int i=0;i<N;i++){
        int K=0;
        cin>>K;
        for(int j=0;j<K;j++){
            int judge;
            cin>>judge;
             A.at(judge-1)++;
        }
    }
    int count=0;
    for(int i=0;i<M;i++){
        if(A.at(i)==N) count++;
    }
    cout<<count<<endl;
}    

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

void solve() {
    i64 x;
    cin >> x;

    cout << 10 - (x / 200) << endl;
}

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


Measured memory_bytes: 3640
S=input()
N=len(S)
l=int((N-1)/2)
ans="Yes"
for i in range(l):
    if(S[i]!=S[N-1-i]):
        ans="No"
Smae=S[0:l]
Susi=S[l+1:N]
m=int(((N-1)/2)/2)
for i in range(m):
    if(Smae[i]!=Smae[l-1-i]):
        ans="No"
    if(Susi[i]!=Susi[l-1-i]):
        ans="No"
print(ans)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define int long long
#define INT_MAX INT64_MAX
#define INT_MIN INT64_MIN
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
signed main(){
    string str;
    cin >> str;
    int len = str.length();
    int s, e;
    s = e = 0;
    int ans = 0;
    if(str[0] == '<'){
        s++;
    }else{
        e++;
    }
    for(int i=1; len>i; i++){
        if(str[i] == '<'){
            if(str[i-1] == '>'){
                int temp = max(s, e);
                s--;
                e--;
                ans += (s*(s+1))/2 + (e*(e+1))/2;
                ans += temp;
                //cout << ans << endl;
                e = 0;
                s = 1;
            }else{
                s++;
            }
        }else{
            e++;
        }
    }int temp = max(s, e);
    s--;
    e--;
    ans += (s*(s+1))/2 + (e*(e+1))/2;
    ans += temp;
    //cout << ans << endl;
    e = 0;
    s = 1;
    cout << ans << endl;
}



Measured memory_bytes: 900
#ifndef __cplusplus
    cat << EOF
#endif
#include <bits/stdc++.h>
using namespace std;

#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()

template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if(lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if(lhs > rhs) { lhs = rhs; return 1; } return 0; }

constexpr int inf = 1 << 30;

int X, Y, Z, N, M, S, T;
int dist[300000];
vector<int> to[300000];
vector<pair<int, int>> edges;

int bfs(int st) {
    rep(i, X + Y + Z) dist[i] = inf;
    dist[st] = 0;
    queue<int> que;
    que.push(st);
    while(!que.empty()) {
        int v = que.front();
        que.pop();
        for(int u : to[v]) {
            if(chmin(dist[u], dist[v] + 1)) que.push(u);
        }
    }
    return max(dist[edges[T].first], dist[edges[T].second]);
}

int main() {

    cin >> X >> Y >> Z >> N >> M >> S >> T;
    --S; --T; T += N;
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        b += X;
        to[a].push_back(b);
        to[b].push_back(a);
        edges.push_back(make_pair(a, b));
    }
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        a += X;
        b += X + Y;
        to[a].push_back(b);
        to[b].push_back(a);
        edges.push_back(make_pair(a, b));
    }

    int ans = min(bfs(edges[S].first), bfs(edges[S].second));
    if(ans == inf) cout << "-1\n";
    else cout << ans << '\n';
    return 0;

}



Measured memory_bytes: 20088
a,b,c=map(int,input().split())
 
 
if (a+b+c-max(a,b,c))%2==0:
    print((max(a,b,c)*3-(a+b+c))//2)
else:
    print((max(a,b,c)*3+3-(a+b+c))//2)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
int ok[10][10];
int V[10];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>x>>y;
		ok[x-1][y-1]=1;
		ok[y-1][x-1]=1;
	}
	FOR(i,N) V[i]=i;
	
	int ret=0;
	do {
		if(V[0]!=0) continue;
		FOR(i,N-1) if(ok[V[i]][V[i+1]]==0) break;
		if(i==N-1) ret++;
		
	} while(next_permutation(V,V+N));
	
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#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>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin>>n;
    p p[n];
    rep(i,n){
        cin>>p[i].first;
    }
    rep(i,n){
        cin>>p[i].second;
    }
    int ans=-1e9;
    for(int bit=0;bit<(1<<n);bit++){
        int x=0,y=0;
        for(int i=0;i<n;i++){
            if(bit&(1<<i)){
                x+=p[i].first;
                y+=p[i].second;
            }
        }
        ans=max(ans,x-y);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
using namespace std;
using UL = unsigned int;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(UL i=0; i<n; i++)

UL to[3][6] = {
	{ 4, 0, 2, 3, 5, 1 },
	{ 2, 1, 5, 0, 4, 3 },
	{ 0, 2, 4, 1, 3, 5 }
};

UL C[6];
UL D[6];
UL X[64][6];

int main(){
	rep(i, 6) cin >> C[i];
	rep(i, 6) cin >> D[i];
	rep(i, 6) X[0][i] = C[i];
	rep(a1, 4){
		if (a1) rep(i, 6) X[a1 * 16][i] = X[a1 * 16 - 16][to[0][i]];
		rep(a2, 4){
			if (a2) rep(i, 6) X[a1 * 16 + a2 * 4][i] = X[a1 * 16 + a2 * 4 - 4][to[1][i]];
			rep(a3, 4){
				if (a3) rep(i, 6) X[a1 * 16 + a2 * 4 + a3][i] = X[a1 * 16 + a2 * 4 + a3 - 1][to[2][i]];
			}
		}
	}
	bool iden = false;
	rep(i, 64){
		bool ok = true;
		rep(j, 6) if (D[j] != X[i][j]) ok = false;
		if (ok) iden = true;
	}
	cout << (iden ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 3112
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var r = ReadLine().Split().Select(decimal.Parse).ToArray();
        var a = r[0];
        var b = r[1];
        var c = r[2];
        if (c - a - b < 0)
        {
            WriteLine("No");return;
        }
        if (4 * a * b < (a * a + b*b + c*c-2*a*c-2*b*c+2*a*b))
        {
            WriteLine("Yes");
        }
        else
        {
            WriteLine("No");
        }
    }
}


Measured memory_bytes: 28240
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e18;
using Graph = vector<vector<int>>;

signed main() {
  int L, R, A;
  cin >> L >> R >> A;
  int ans = 0;
  for( int i = L; i <= R; i++ ){
    if( i%A == 0 ) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }

struct UnionFind {
   vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

   UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
       for(int i = 0; i < N; i++) par[i] = i;
   }

   int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
       if (par[x] == x) return x;
       return par[x] = root(par[x]);
   }

   void unite(int x, int y) { // xとyの木を併合
       int rx = root(x); //xの根をrx
       int ry = root(y); //yの根をry
       if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
       par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
   }

   bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
       int rx = root(x);
       int ry = root(y);
       return rx == ry;
   }
};

int main(int argc, char const *argv[]) {
  int N,Q;
  cin >> N >> Q;
  vector<int> P(N);
  UnionFind tree(N);

  rep(i,N) cin >> P[i];

  int ans=0;
  rep(i,Q){
    int x,y;
    cin >> x >> y;
    x--,y--;
    tree.unite(x,y);
  }

  rep(i,N) if(tree.same(i,P[i]-1)) ans++;

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


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline void fastio () {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
}

#define whats(x) cerr << #x << " = " << (x) << "\n"; 

using LL = long long;
using LD = long double;

const LL INF = LLONG_MAX;
const LL MOD = static_cast<LL>(1e9+7);
const LL N = 1e6+1;

int main() {
	fastio();

	LL n, m, k;

	cin >> n >> m >> k;

	vector<LL> a(n), b(m);

	for (auto &e : a) {
		cin >> e;
	}

	for (auto &e : b) {
		cin >> e;
	}
	
	vector<LL> prea(n+1, 0), preb(m+1, 0);
	for (LL i = 1; i <= n; ++i) {
		prea[i] = prea[i-1]+a[i-1];
	}
	for (LL i = 1; i <= m; ++i) {
		preb[i] = preb[i-1] + b[i-1];
	}

	LL maxcnt = 0;
	for (LL i = 0; i <= n; ++i) {
		if (k >= prea[i]) {
			LL cnt = i;
			LL left = k - prea[i];

			auto ub = upper_bound(preb.begin(), preb.end(), left);
			if ((*(ub-1)) <= left) {
				cnt += (ub - preb.begin() - 1);
			}
			maxcnt = max(maxcnt, cnt);
		}
		else {
			break;
		}
	}

	cout << maxcnt << "\n";

}

Measured memory_bytes: 9528
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define sc(x) scanf("%d", &x)
#define sc2(x, y) scanf("%d%d", &x, &y)
#define sc3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define sc4(x, y, z, t) scanf("%d%d%d%d", &x, &y, &z, &t)
#define print(x) printf("%d ", x)
#define println(x) printf("%d\n", x)
#define println2(x, y) printf("%d %d\n", x, y)
#define println3(x, y, z) printf("%d %d %d\n", x, y, z)
#define println4(x, y, z, t) printf("%d %d %d %d\n", x, y, z, t)
#define mp make_pair
#define pb push_back
#define ft first
#define sd second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define endl '\n'                           // CommentInInteractive
#define DB(x) cerr << #x << " = " << x << endl

const ld eps = 1e-6;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;

void solve() {
    string s;
    cin >> s;
    cout << ((s[2] == s[3] && s[4] == s[5]) ? "Yes" : "No") << endl;
}

//#define FILES
//#define TIME

int main() {
    // Comment if use stdio
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

#ifdef FILES
    freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    auto start = chrono::high_resolution_clock::now();
    solve();
    auto stop = chrono::high_resolution_clock::now();

#ifdef TIME
    cerr << chrono::duration_cast <chrono::milliseconds> (stop - start).count() << " ms\n";
#endif
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
    int N;
int main(){
    cin>>N;

    cout<<(N<1200?"ABC":"ARC")<<endl;
    return 0;
}


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

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

}

Measured memory_bytes: 3588
a,b,c,k=(int(x) for x in input().split())

score=0

if a>=k:
     score=k
     print(score)
else:
    score+=a
    k-=a
    if b>=k :
        print(score)
    else:
        k-=b
        if c>=k and k>0:
            score-=k
            print(score)
        else:
            print(score)

Measured memory_bytes: 9200
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N, K = get_ints
X = get_ints

minus = []
plus = []
zero = nil

X.each do |x|
  if x < 0
    minus << -x
  elsif x > 0
    plus << x
  else
    zero = true
  end
end

k = zero ? K - 1 : K

if k == 0
  puts 0
else
  minus.reverse!

  min = 10 ** 32

  plus.each.with_index do |x, i|
    num = i + 1
    break if num >= k

    if minus.length >= k - num
      stock = x * 2 + minus[k-num-1]
      min = stock if stock < min
    end
  end
  if plus.length >= k
    min = plus[k-1] if plus[k-1] < min
  end

  minus.each.with_index do |x, i|
    num = i + 1
    break if num >= k

    if plus.length >= k-num
      stock = x * 2 + plus[k-num-1]
      min = stock if stock < min
    end
  end
  if minus.length >= k
    min = minus[k-1] if minus[k-1] < min
  end

  puts min
end


Measured memory_bytes: 22708
n = int(input())
x = list(map(int, input().split()))
ans = [0] * (n**2+1)
for k,v in enumerate(x):
  ans[v] = k+1
x = sorted([[v,k] for k,v in enumerate(x)])
now = 1
for k,v in x:
  num = v + 1
  while v:
    if ans[now]:
      if ans[now] == num:
        print("No")
        exit()
    else:
      ans[now] = num
      v -= 1
    now += 1
now2 = n ** 2
for k,v in reversed(x):
  num = v + 1
  quant = n - num
  while quant:
    if ans[now2]:
      if ans[now2] == num:
        print("No")
        exit()
    else:
      ans[now2] = num
      quant -= 1
    now2 -= 1
print("Yes")
print(*ans[1:])

Measured memory_bytes: 53744
data_num = int(input())
data = [int(n) for n in input().split(' ')]
data_len = len(data)

flag = True
i = 0
changed = 0

while flag:
    flag = False
    for j in range(data_len-1, i, -1):
        if data[j] < data[j-1]:
            data[j], data[j-1] = data[j-1], data[j]
            changed += 1
            flag = True
    i += 1
print(' '.join(str(i) for i in data))

print(changed)

Measured memory_bytes: 7736
var input= require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=input.split("\n");
var str="";
for(var i=0;i<Arr.length;i++){
var arr=Arr[i].split(" ");
var a=arr[0]-0;
var b=arr[1];
var c=arr[2]-0;
if(b==="+")str+=a+c;
if(b==="-")str+=a-c;
if(b==="*")str+=a*c;
if(b==="/")str+=Math.floor(a/c);
str+="\n";
}
console.log(str.trim());



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

int main(){
    int a;cin>>a;
    if(a==3||a==5||a==7)cout<<"YES";
    else cout<<"NO";
}

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

int MOD=1000000007;
struct edge {
    int to, cost;
};

int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}

auto factor(int n){
  map<int,int>res;
  for(int i=2;i*i<=n;i++){
      for(; n%i==0;n/=i) res[i]++;
  }
  if(n>1)res[n]++;
  return res;
}
////////////////////////////////////////////////////////////
signed main() {
  int n;
  cin>>n;
  int c[n],s[n],f[n];
  rep(i,n-1)cin>>c[i]>>s[i]>>f[i];
  rep(i,n-1){
    int x=s[i]+c[i];
    for(int j=i+1;j<n-1;j++){
      if(x-s[j]<0)x=s[j]+c[j];
      else if((x-s[j])%f[j]==0)x+=c[j];
      else x=f[j]-(x-s[j])%f[j]+x+c[j];
    }
    cout<<x<<endl;
  }
  cout<<0<<endl;
}


Measured memory_bytes: 3636
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
using ll = long long;

inline int lg(ll n) {
    return 64 - __builtin_clzll(n);
}

struct sparse_table {
    vector<vector<ll>> st;

    sparse_table(const vector<ll>& a) {
        const int w = lg(a.size());
        st.reserve(w);
        st.emplace_back(a);
        for (int k = 1; k < w; k++) {
            st.emplace_back(vector<ll>(a.size() - (1 << k) + 1));
            for (int i = 0; i < (int) a.size() - (1 << k) + 1; i++)
                st[k][i] = max(st[k - 1][i], st[k - 1][i + (1 << (k - 1))]);
        }
    }

    inline ll query(int l, int r) {
        if (l > r)
            return 0;
        int k = lg(r - l + 1) - 1;
        return max(st[k][l], st[k][r - (1 << k) + 1]);
    }
};

int main() {
#ifdef LOCAL
    freopen("in", "r", stdin);
    //    freopen("out", "w", stdout);
#endif
    //    ios::sync_with_stdio(0), cin.tie(0);
    ll n, c;
    scanf("%lld%lld", &n, &c);
    vector<ll> x(n), v(n), F(n), B(n);
    for (int i = 0; i < n; i++) {
        scanf("%lld%lld", &x[i], &v[i]);
    }

    F[0] = v[0];
    for (int i = 1; i < n; i++)
        F[i] = F[i - 1] + v[i];
    for (int i = 0; i < n; i++)
        F[i] -= x[i];

    B[0] = v[n - 1];
    for (int i = 1; i < n; i++)
        B[i] = B[i - 1] + v[n - i - 1];
    for (int i = 0; i < n; i++)
        B[i] -= (c - x[n - i - 1]);

    sparse_table fst(F), bst(B);

    ll ans = LLONG_MIN;
    for (int i = 0; i < n; i++) {
        ll cur = max(F[i], F[i] + bst.query(0, n - 2 - i) - x[i]);
        ans = max(ans, cur);
    }

    ll res = LLONG_MIN;
    for (int i = 0; i < n; i++) {
        ll cur = max(B[i], B[i] + fst.query(0, n - 2 - i) - (c - x[n - i - 1]));
        res = max(res, cur);
    }

    cout << max({0LL, res, ans}) << endl;

    return 0;
}


Measured memory_bytes: 28032
#include<stdio.h>
int main(){
	int n,m,i,j,k,l,o;
	int d[403];
	scanf("%d",&n);
	for(i=1;i<=2*n;i++)d[i]=i;
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%d",&k);
		int tmp[403],tmp2[403];
		if(!k){
			for(j=1;j<=n;j++){
				tmp[j]=d[j];
				tmp2[j]=d[j+n];
			}
			for(j=1,l=1;j<=2*n;j++){
				d[l++]=tmp[j];
				d[l++]=tmp2[j];
			}
		}
		else {
			l=2*n-k;
			for(j=1;j<=k || j<=l;j++){
				if(j<=k)tmp[j]=d[j];
				if(j<=l)d[j]=d[k+j];
			}
			for(j=l+1,l=1;j<=2*n;j++)d[j]=tmp[l++];
		}
	}
	for(j=1;j<=2*n;j++)printf("%d\n",d[j]);
	return 0;
}

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

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

  int N;
  cin >> N;
  if(N % 2 == 0){
    cout << fixed << setprecision(10);
    cout << 0.5 << endl;
  }
  else{
    cout << fixed << setprecision(10);
    cout << double((N+1)/2) / double(N) << endl;
  }
}

Measured memory_bytes: 256
s = list(input())
a = 0
b = 0
f = 0
for i in s:
    if f == 0:
        if i == "0":
            a += 1
        else:
            b += 1
        f = 1
    else:
        if i == "0":
            b += 1
        else:
            a += 1
        f = 0
            
print(min(a,b))

Measured memory_bytes: 9800
'use strict';
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim();
  var S = Number(inputs);
  var h = Math.floor(S/3600);
  var m = Math.floor((S-(h*3600))/60);
  var s = S%60;
  console.log([h,m,s].join(':'));
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15512
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b, c) = scan!(usize, usize, usize);
    if b - a == c - b {
        println!("YES")
    } else {
        println!("NO")
    }
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main() {
	ll N, A, B, h[100000];
	ll m = 0, key;
	cin >> N >> A >> B;
	REP(i, N) {
		cin >> h[i];
		if (m < h[i]) {
			m = h[i];
		}
	}

	ll left = 0, right = (m + B - 1) / B;
	key = right / 2;
	while (left + 1 != right) {
		ll s = 0;
		REP(i, N) {
			s += (max(h[i] - B * key, (ll)0) + A - B - 1) / (A - B);
		}
		if (s <= key) {
			right = key;
		}
		else {
			left = key;
		}
		key = (right + left) / 2;
	}

	cout << right << endl;

	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace Codeforces
{
	internal class Template
	{
		private void Solve()
		{
			var w = cin.NextInt();
			var a = cin.NextInt();
			var b = cin.NextInt();
			var aa = a + w;
			var bb = b + w;
			if (a <= bb & b <= aa)
			{
				Console.WriteLine(0);
				return;
			}
			Console.WriteLine(a - bb > 0 ? a - bb : b - aa);
		}

		private static readonly Scanner cin = new Scanner();

		private static void Main()
		{
#if DEBUG
			var inputText = File.ReadAllText(@"..\..\input.txt");
			var testCases = inputText.Split(new[] { "input" }, StringSplitOptions.RemoveEmptyEntries);
			var consoleOut = Console.Out;
			for (var i = 0; i < testCases.Length; i++)
			{
				var parts = testCases[i].Split(new[] { "output" }, StringSplitOptions.RemoveEmptyEntries);
				Console.SetIn(new StringReader(parts[0].Trim()));
				var stringWriter = new StringWriter();
				Console.SetOut(stringWriter);
				var sw = Stopwatch.StartNew();
				new Template().Solve();
				sw.Stop();
				var output = stringWriter.ToString();

				Console.SetOut(consoleOut);
				var color = ConsoleColor.Green;
				var status = "Passed";
				if (parts[1].Trim() != output.Trim())
				{
					color = ConsoleColor.Red;
					status = "Failed";
				}
				Console.ForegroundColor = color;
				Console.WriteLine("Test {0} {1} in {2}ms", i + 1, status, sw.ElapsedMilliseconds);
			}
			Console.ReadLine();
			Console.ReadKey();
#else
			new Template().Solve();
			Console.ReadLine();
#endif
		}
	}

	internal class Scanner
	{
		private string[] s = new string[0];
		private int i;
		private readonly char[] cs = { ' ' };

		public string NextString()
		{
			if (i < s.Length) return s[i++];
			var line = Console.ReadLine() ?? string.Empty;
			s = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 1;
			return s.First();
		}

		public double NextDouble()
		{
			return double.Parse(NextString());
		}

		public int NextInt()
		{
			return int.Parse(NextString());
		}

		public long NextLong()
		{
			return long.Parse(NextString());
		}
	}
}

Measured memory_bytes: 13268
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std ;

int a ;
string s ;

int main () {
	cin >> a >> s ;
	if(a >= 3200) {
		cout << s << endl ;
	}else {
		puts("red") ;
	}
	return 0 ; 
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static double[][] dp;

	static double rec(int x, int n, int m) {
		if (dp[x][n] != -1) return dp[x][n];
		if (n == 0) {
			if (x == 0) return dp[x][n] = 1;
			else return dp[x][n] = 0;
		}
		double res = 0;
		for (int i=1; i<=m; i++) {
			if (x - i >= 0)
				res += rec(x - i, n-1, m)/m;
		}
		return dp[x][n] = res;
	}

	static boolean solve() {
		int n = in.nextInt();
		int m = in.nextInt();
		int k = in.nextInt();
		if (n + m + k == 0) return false;

		dp = new double[n*m+1][n+1];
		for (int i=0; i<n*m+1; i++) {
			Arrays.fill(dp[i], -1);
		}

		double ans = 0;
		for (int i=1; i<=n*m; i++) {
			ans += Math.max(1, i-k)*rec(i, n, m);
		}
		out.printf("%.10f\n",ans);

		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 28356
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {

    ll l,r;
    cin>>l>>r;
    if(r-l>2019){
        fin(0);
        return 0;
    }
    ll ans=LLINF;
    for(ll i=l;i<r;i++){
        for(ll j=i+1;j<=r;j++){
            chmin(ans,i*j%2019);
        }
    }
    fin(ans);
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n],b,c[n-1];
    int sum=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> b;
        sum+=b;
    }
    for(int i=0;i<(n-1);i++){
        cin >> c[i];
    }
    for(int i=0;i<(n-1);i++){
        if((a[i]+1)==a[i+1]){
            sum+=c[a[i]-1];
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

ans = 0
flg = False
for i, a in enumerate(A, start=1):
    if i == a and flg:
        flg = False
    elif i == a:
        flg = True
        ans += 1
    else:
        flg = False

print(ans)


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

int main() {
	int x;
	int y;
	int i=1;
	for(i=1;;i++){
		cin >> x;
		cin >> y;
		if(x==0 && y==0) {
			break;
		}
		if(x>y){
			int a;
			a = x;
			x = y;
			y = a;
		}
		cout << x <<" "<< y << endl;
	}
	return 0;
}

Measured memory_bytes: 2996
#include <stdio.h>

int a[10010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	int q;
	scanf("%d",&q);
	int ans=0;
	while(q--){
		int t;
		scanf("%d",&t);
		int temp=0;
		for(int i=0;i<n;i++)temp|=a[i]==t;
		ans+=temp;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
const int dx[]={0,1,0,-1,1,-1,-1,1};
const int dy[]={-1,0,1,0,1,1,-1,-1};
const int INF = 1<<30;
const double EPS = 1e-15;
#define PB push_back
#define mk make_pair
#define fi first
#define se second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
typedef pair<int,int> Pii;
typedef pair<int,Pii> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll T[30];
int main(){
    ll a = 1;
    T[0] = a;
    int index = 1;
    while(a <= 1000000000){
        a*=2;
        T[index++] = a;
    }
    int len = index;
    int N;
    scanf("%d",&N);
    while(N--){
        ll s,d;
        int ans = 0;
        scanf("%lld%lld",&s,&d);
        while(s != d){
            for(int i = len-1;i >= 0; i--){
                if(s+T[i] <= d && s%T[i] == 0){
                    ans++;
                    s+=T[i];
                    break;
                }
            }    
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1188
if __name__ == '__main__':
    n=int(input())
    a=[int(input()) for i in range(n)]
    count = 1
    light_button_position=a[0]
    
    while light_button_position!=2 and count<n:
        count = count+1
        light_button_position = a[light_button_position-1]
        
    print(count if count<n else -1)

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

struct order{
	long long b;
	long long c;
};

int main(){
	int n, m;
	std::vector<long long> aList;
	std::vector<order> bcList;

	std::cin>>n>>m;

	aList.resize(n);
	bcList.resize(m);

	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	for(int i=0; i<m; i++)
		std::cin>>bcList[i].b>>bcList[i].c;

	std::sort(aList.begin(), aList.end(), [](const long long &x, const long long &y){return x<y;});
	std::sort(bcList.begin(), bcList.end(), [](const order &x, const order &y){return x.c>y.c;});

	int curPos=0;

	for(int i=0; i<m; i++){
		for(int j=0; j< bcList[i].b; j++){
			if(aList[curPos]< bcList[i].c && curPos< n){
				aList[curPos]= bcList[i].c;
				curPos++;
			}else{
				i= m;
				break;
			}
		}
	}

	long long sum=0;

	for(int i=0; i<n; i++)
		sum+= aList[i];

	std::cout<<sum<<std::endl;


	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define P pair<int,int>
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
	int a[3], cnt = 0;
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	sort(a, a + 3);
	while (a[0] < a[2] && a[1] < a[2]) {
		a[0]++, a[1]++;
		cnt++;
	}
	while (a[0] < a[1]) {
		a[0] += 2;
		cnt++;
	}
	if (a[0] > a[1]) {
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,x;
    cin >> N >> x;
    int a[N] = {};
    cin >> a[0];
    long long count=0;
    if(a[0] > x){
        count = a[0] - x;
        a[0] = x;
    }
    for(int i=1;i<N;i++){
        int A;
        cin >> A;
        if(a[i-1] + A > x){
            count +=  A + a[i-1] - x;
            a[i] = x - a[i-1] ;
        }else{
            a[i] = A;
        }
    }
    cout << count << endl;
    return 0;
} 

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

int main(){
      int n;cin >> n;
      set<char> s;
      for(int i = 0;i < n;i++){
            char c;cin >> c;
            s.insert(c);
      }
      if(s.size() == 3)cout << "Three";
      else cout << "Four";
}

Measured memory_bytes: 256