akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, a, n) for(ll i = a; i < (ll)(n); ++i)
#define repr(i, a, n) for(ll i = n - 1; (ll)a <= i; --i)
#define ENDL '\n'
typedef pair<int, int> Pi;
typedef pair<ll, ll> PL;
constexpr ll mod = 1000000007;  // 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 + 99);
const ld PI = acos((ld)-1);
const vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
template <typename T, typename U> inline bool chmin(T& t, const U& u) {
  if(t > u) {
    t = u;
    return 1;
  }
  return 0;
}
template <typename T, typename U> inline bool chmax(T& t, const U& u) {
  if(t < u) {
    t = u;
    return 1;
  }
  return 0;
}
template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

template <typename T, typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(; n; n >>= 1) {
    if(n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template <typename T, typename Y>
ostream& operator<<(ostream& os, const pair<T, Y>& p) {
  return os << "{" << p.fs << "," << p.sc << "}";
}
template <typename T> ostream& operator<<(ostream& os, const V<T>& v) {
  os << "{";
  for(auto e : v) os << e << ",";
  return os << "}";
}
template <typename... Args> void debug(Args&... args) {
  for(auto const& x : {args...}) { cerr << x << ' '; }
  cerr << ENDL;
}

signed main() {
  cin.tie(0);
  cerr.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, k;
  cin >> n >> k;

  V<ll> p(n), c(n);
  rep(i, 0, n) {
    cin >> p[i];
    --p[i];
  }

  rep(i, 0, n) cin >> c[i];

  ll ans = -LINF;
  rep(i, 0, n) {
    V<bool> used(n, false);
    V<ll> cost(1, 0);
    ll tmp = 0, now = i;
    used[now] = true;

    while(1) {
      if(used[p[now]]) {
        tmp += c[p[now]];
        cost.eb(tmp);
        break;
      }

      tmp += c[p[now]];
      cost.eb(tmp);

      used[p[now]] = true;

      now = p[now];
    }

    ll t = siz(cost) - 1;
    
    rep(j,1,min(t+1,k+1))chmax(ans,cost[j]);

    if(k<t)continue;

    rep(j, 0, t) {
      if(j <= k % t && !(k/t==0 && j==0)) {
        chmax(ans, tmp * (k / t) + cost[j]);
      } else 
        chmax(ans, tmp * ((k / t) - 1) + cost[j]);
    }
  }
  cout << ans << ENDL;
}
//! ( . _ . ) !
// CHECK overflow,vector_size,what to output?

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k, ans;

int main() {
    cin >> n;
    // Write a program that prints Christmas if
    //D
    //=
    //25
    //, Christmas Eve if
    //D
    //=
    //24
    //, Christmas Eve Eve if
    //D
    //=
    //23
    // and Christmas Eve Eve Eve if
    //D
    //=
    //22
    //.
    if (n == 25)
        cout << "Christmas" << endl;
    else if (n == 24)
        cout << "Christmas Eve" << endl;
    else if (n == 23)
        cout << "Christmas Eve Eve" << endl;
    else if (n == 22)
        cout << "Christmas Eve Eve Eve" << endl;
    return 0;
}


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

long long int getSub(long long int a, long long int b, long long int c){
    long long int red, blue;
    red = ((a/2)+(a%2)) * b * c;
    blue = a/2 * b * c;
    return abs(red-blue);
}

int main(){
    long long int a, b, c;
    cin >> a >> b >> c;
    long long int min  = getSub(a,b,c);
    min = getSub(b,a,c) < min ? getSub(b,a,c) : min; 
    min = getSub(c,a,b) < min ? getSub(c,a,b) : min;
    
    cout << min << endl;
}

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

int n;
double memo[303][303][303];

double rec(int a, int b, int c) {
    if(a == 0 && b == 0 && c == 0) return 0;
    if(memo[a][b][c]) return memo[a][b][c];

    double ret = 0;

    if(a) ret += rec(a-1, b, c) * a;
    if(b) ret += rec(a+1, b-1, c) * b;
    if(c) ret += rec(a, b+1, c-1) * c;
    ret += n;
    ret /= (double) (a + b + c);

    return memo[a][b][c] = ret;
}

int main() {
    cin >> n;
    int A[4] = {0};
    rep(i, n) {
        int a;
        cin >> a;
        A[a]++;
    }
    cout << fixed << setprecision(10) << rec(A[1], A[2], A[3]) << endl;
    return 0;
}

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

 class Main {
	public static void main(String[] args) {
		
		FastScanner s = new FastScanner();
		
		int n = s.nextInt();
		int m = s.nextInt();
		
		int l = 0, r = Integer.MAX_VALUE;
		
		for(int i = 0;i<m;i++)
		{
			int x = s.nextInt();
			int y = s.nextInt();
			
			l = Math.max(l, x);
			r = Math.min(r, y);
		}
		
		int ans = 0;
		if(l<=r)
			ans = (r-l+1);
		
		System.out.println(ans);
		
	}

static   class FastScanner {
		
	    private InputStream mIs;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner() {
			this(System.in);
		}

		public FastScanner(InputStream is) {
			mIs = is;
		}

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = mIs.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public String nextString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		
		}	

	}

}


Measured memory_bytes: 23124
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>
#include <iomanip>
#include <limits>

using namespace std;
using ll = long long;
const ll res = 1000000007;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main() {
	ll x, m=100,ans=0;
	cin >> x;
	while (m < x) {
		ans++;
		m = ll(m * 1.01);
		if (m >= x)
			cout << ans << endl;
	}
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;
    if(s == u) a--;
    if(t == u) b--;
    cout << a << " " << b;
}

Measured memory_bytes: 256
n = int(input())
ss =[input() for _ in range(n)]
m=int(input())
tt = [input() for _ in range(m)]

sss=list(set(ss))
nums = [0] * (len(sss)+1)
for i,s in enumerate(sss):
    nums[i]=ss.count(s) - tt.count(s)
print(max(nums))

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

const int maxn = 3002;
int dp[maxn][maxn];
pair <int, int> par[maxn][maxn];

int main() {
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < t.size(); j++) {
			if (s[i] == t[j]) {
				dp[i + 1][j + 1] = dp[i][j] + 1;
				par[i + 1][j + 1] = make_pair(i, j);
				continue;
			}
			if (dp[i][j + 1] >= dp[i + 1][j]) {
				dp[i + 1][j + 1] = dp[i][j + 1];
				par[i + 1][j + 1] = par[i][j + 1];
			}
			else {
				dp[i + 1][j + 1] = dp[i + 1][j];
				par[i + 1][j + 1] = par[i + 1][j];
			}
		}
	}
	string ans = "";
	int l = s.size(), r = t.size(), k;
	for (int i = 0; i < dp[s.size()][t.size()]; i++) {
		k = par[l][r].first, r = par[l][r].second, l = k;
		ans += s[l];
	}
	reverse(ans.begin(), ans.end());
	cout << ans;
}


Measured memory_bytes: 105856
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    
    ll N;
    cin >> N;
    vector<ll> V(N);
    ll sum = 0, k;
    rep(i,0,N){
        cin >> V[i];
        sum += V[i];
    }
    if(sum % (N * (N+1) / 2)){
        cout << "NO" << endl;
        return 0;
    }
    k = sum / (N * (N+1) / 2);
    ll cnt = 0;
    rep(i,0,N){
        ll dif = V[(i+1)%N] - V[i];
        //cout << dif << " ";
        if((k - dif) % N || k < dif){
            cout << "NO" << endl;
            return 0;
        }
        cnt += (k - dif) / N;
    }
    //cout << endl;
    //cout << k << " " << cnt << endl;
    if(k != cnt)cout << "NO" << endl;
    else cout << "YES" << endl;
    
    /*
    int N,K;
    cin >> N >> K;
    vector<int> V(N);
    rep(i,0,K){
        int t;
        cin >> t;
        rep(j,0,N){
            V[(j+t) % N] += j + 1;
        }
    }
    rep(i,0,N)cout << V[i] << " \n"[i==N-1];
    */
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(){
   int l,r,d,n,i;

   scanf("%d %d %d",&l,&r,&d);
   for (i=d;i<l;i+=d) ;
   for (n=0;l<=i && i<=r;i+=d) n++;
   printf("%d\n",n);
   return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    int tmp;
    for (int j = 0; j < d; j++) {
      cin >> tmp;
      A[tmp-1]++;
    }
  }

  int ans = N;
  for (int i = 0; i < N; i++) {
    if(A[i] > 0) {
      ans--;
    }
  }
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 3624
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,K = map(int, read().split())

mo = 1000000007

ans = 0

for i in range(K,N+2):
    mi = i*(i+1)/2
    ma = i*(i+1)/2 + i * (N+1-i)
    ans += ma - mi + 1
    ans %= mo
    ans = int(ans)

print(ans)


Measured memory_bytes: 9192
#include <iostream>
#include<string>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define MAX_B 1001001
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL
int main(){
    ll n,c,k;
    cin>>n>>c>>k;
    int t[n];rep(i,n)cin>>t[i];
    sort(t,t+n);
    int res=0;
    int i=0;
    while(i<n){
        int start=i;
        while(i<n && i-start<c && t[i]-t[start]<=k)i++;
        res++;
    }
    cout<<res<<endl;
}

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

int main()
{
  ll a,b,c;
  cin >> a>> b>>c;
  ll d= c-b-a;
  if(d>0&&d*d>4*a*b){
    cout << "Yes"<<endl;
  }else{
    cout << "No"<<endl;
  }
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-

if __name__ == "__main__":
    X, Y = list(map(int, input().split()))

    #implements
    # X*2*n < Y を満たす最大のnは？
    ans = 1
    while True:
        X = X*2
        if X > Y:
            break
        ans += 1
    print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n,a,b;
	string str="54321012345678";
	cin>>n;
	rep(x,0,n){
		string ans="";
		cin>>a>>b;
		if(a<b){
			rep(i,a,b+1){
				if(ans!="") ans+=" ";
				ans=ans+(char)('0'+i);
			}
		}else if(a<=5){
			repb(i,a,b){
				if(ans!="") ans+=" ";
				ans=ans+(char)('0'+i);
			}
		}else{
			rep(i,a,10){
				if(ans!="") ans+=" ";
				ans=ans+(char)('0'+i);
			}
			rep(i,0,str.size()){
				if(ans!="") ans+=" ";
				ans=ans+str[i];
				if(str[i]==('0'+b)) break;
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1208
chr = "a"
alpha = []
26.times do
  alpha << chr
  chr = chr.next
end
sample = ["the", "this", "that"]
while code = gets
  chr = "a"
  plane = code.chomp!
  while sample & plane.split(/\W+/) == []
    plane = code.split(//).map{|c|
      if c =~ /\w+/
        alpha[(c.ord + chr.ord) % 26]
      else
        c
      end
    }.join
    chr = chr.next
  end
  puts plane
end

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

int a,b, sockets=1;

void addstrip(){
    sockets+=(a-1);
}

int main(){
    std::cin>>a>>b;
    int count=0;
    while(sockets<b){
        addstrip();
        count++;
    }    
    std::cout<<count;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define mp make_pair
#define ins insert
#define sz size
#define whoami(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); whi(_it, args); }

void whi(istream_iterator<string> it) { cerr<<"\n"; }

template<typename T, typename... Args>
void whi(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<" "<<a<<" "; whi(++it, args...); }

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;
const ll INF = 4e18;

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

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	char c;
	cin>>c;
	if(c >= 'A' && c <= 'Z')
	cout<<"A\n";
	else cout<<"a\n";
	return;	
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

main(){
  stack<int> S1;
  stack<pair<int, int> > S2;
  char ch;
  int sum = 0;
  for ( int i = 0; cin >> ch; i++ ){
    if ( ch == '\\' ) S1.push(i);
    else if ( ch == '/' && S1.size() > 0 ){
      int l = S1.top(); S1.pop();
      sum += i - l;
      int a = i - l;
      while( S2.size() > 0 && S2.top().first > l ){
        a += S2.top().second; S2.pop();
      }
      S2.push(make_pair(l, a));
    }
  }

  vector<int> ans;
  //  int t = 0;
  while( S2.size() > 0 ) { ans.push_back(S2.top().second); S2.pop();}
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for ( int i = 0; i < ans.size(); i++ ){
    cout << " ";
    //    t += ans[i];
    cout << ans[i];
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 3236
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
int dyy[]={0,-1,0,1};
int dxx[]={-1,0,1,0};

int main(){
    string s;
    cin>>s;
    bool can=true;
    if(s[0]!='A')can=false;
    int cnt=0;
    rep(i,1,s.size()){
        if(s[i]=='C'){
            cnt++;
        }
    }
    int cnt2=0;
    rep(i,1,s.size()){
    if( isupper( s[i] ) != 0 )cnt2++;
    }
    if(cnt2!=1)can=false;
    if(cnt!=1)can=false;
    if(s[1]=='C' || s[s.size()-1]=='C')can=false;
    if(can)cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
    return 0;
}

Measured memory_bytes: 256
import math

def main():
    N = int(input())
    ans = N
    for i in range(1, int(math.sqrt(N)) + 1):
        if N % i != 0:
            continue
        j = N // i
        d = (i - 1) + (j - 1)
        if d < ans:
            ans = d
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63400
N, M, X = map(int,input().split())
C = [list(map(int,input().split())) for x in range(N)] 
#最初だけ金額なことに注意
skill = [0]*M
flag = [0]*M    #スキルが身についてるかのフラグ
saisyou = 10**7
for p in range(2**N):
    for q in range(N):
        if p >> q & 1:      #q+1冊目の本について
            money += C[q][0]
            for r in range(M):  #各スキルの理解度追加
                skill[r] += C[q][r+1]
    for s in range(M):
        if skill[s] >= X:
            flag[s] = 1
    if 0 not in flag and money < saisyou:
        saisyou = money
    money = 0
    skill = [0]*M
    flag = [0]*M
if saisyou == 10**7:
    saisyou = -1
print(saisyou)





Measured memory_bytes: 9216
import java.util.Arrays;
import java.util.Scanner;
 
 
public class Main {
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num = Integer.parseInt(scanner.nextLine());
 
        Dice[] dices = new Dice[num];
        boolean flag = true;
 
        loop: for (int i = 0; i < num; i++) {
            dices[i] = new Dice(scanner.nextLine());
            for (int j = 0; j < i; j++) {
                /*System.out.println(Arrays.toString(dices[i].a) + " -> "
                        + Arrays.toString(dices[j].a));*/
                if (dices[i].equals(dices[j])) {
                    flag = false;
                    break loop;
                }
            }
        }
        System.out.println(flag ? "Yes" : "No");
    }
}
 
class Dice {
    int[] a = new int[6];
 
    Dice(String s) {
        String[] b = s.split(" ");
        for (int i = 0; i < 6; i++) {
            a[i] = Integer.parseInt(b[i]);
        }
    }
 
    public void roll(char c) {
        int temp;
        switch (c) {
        case 'E':
            temp = a[0];
            a[0] = a[3];
            a[3] = a[5];
            a[5] = a[2];
            a[2] = temp;
            break;
        case 'N':
            temp = a[0];
            a[0] = a[1];
            a[1] = a[5];
            a[5] = a[4];
            a[4] = temp;
            break;
        case 'W':
            temp = a[0];
            a[0] = a[2];
            a[2] = a[5];
            a[5] = a[3];
            a[3] = temp;
            break;
        default:
            temp = a[0];
            a[0] = a[4];
            a[4] = a[5];
            a[5] = a[1];
            a[1] = temp;
            break;
        }
    }
 
    public boolean equals(Dice d) {
        char[] c = { 'E', 'E', 'E', 'N', 'W', 'W', 'W', 'S' };
        boolean flag = false;
        loop: for (int i = 0; i < 24; i++) {
            /*System.out.println(Arrays.toString(a) + "========"
                    + Arrays.toString(d.a));*/
            if (Arrays.equals(a, d.a)) {
                flag = true;
                break loop;
            }
            d.roll(c[i % 8]);
        }
        return flag;
    }
}


Measured memory_bytes: 27764
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		long N = sc.nextLong();
		
		long ans = (1+(N-1)) * (N-1) / 2;
		
		out.println(ans);
		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private String join(String delimiter, int[] a) {
		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < a.length; i++) {
			sb.append(a[i]);
			sb.append(delimiter);
		}
		return sb.substring(0, Math.max(sb.length() - delimiter.length(), 0));
	}

	@SuppressWarnings("unused")
	private String join(String delimiter, long[] a) {
		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < a.length; i++) {
			sb.append(a[i]);
			sb.append(delimiter);
		}
		return sb.substring(0, Math.max(sb.length() - delimiter.length(), 0));
	}

	@SuppressWarnings("unused")
	private int max(int[] arr) {
		if(arr == null || arr.length == 0) {
			throw new IllegalArgumentException(Arrays.toString(arr));
		}

		int candidate = arr[0];
		for(int i=1;i<arr.length;i++) {
			candidate = candidate > arr[i] ? candidate : arr[i];
		}
		return candidate;
	}

	@SuppressWarnings("unused")
	private long max(long[] arr) {
		if(arr == null || arr.length == 0) {
			throw new IllegalArgumentException(Arrays.toString(arr));
		}

		long candidate = arr[0];
		for(int i=1;i<arr.length;i++) {
			candidate = candidate > arr[i] ? candidate : arr[i];
		}
		return candidate;
	}

	@SuppressWarnings("unused")
	private int min(int[] arr) {
		if(arr == null || arr.length == 0) {
			throw new IllegalArgumentException(Arrays.toString(arr));
		}

		int candidate = arr[0];
		for(int i=1;i<arr.length;i++) {
			candidate = candidate < arr[i] ? candidate : arr[i];
		}
		return candidate;
	}

	@SuppressWarnings("unused")
	private long min(long[] arr) {
		if(arr == null || arr.length == 0) {
			throw new IllegalArgumentException(Arrays.toString(arr));
		}

		long candidate = arr[0];
		for(int i=1;i<arr.length;i++) {
			candidate = candidate < arr[i] ? candidate : arr[i];
		}
		return candidate;
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}

	@SuppressWarnings("unused")
	private long[] nextLongArray(Scanner sc, int n) {
		long[] result = new long[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextLong();
		}
		return result;
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray1origin(Scanner sc, int n) {
		int[] result = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 23764
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int f[120000];
int n;
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++ ) {
		f[i] = f[i/10] + i%10;
	}
	int ans = 0x3f3f3f3f;
	for(int i = 1; i < n; i ++ ) {
		ans = min(ans, f[i] + f[n-i]);
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <cstdlib>  // abs() for integer
#include <cmath>
#include <bitset>
#include <iomanip>

using namespace std;


int main(void) {
    int N;
    cin >>N;
    vector<double> A(N);
    
    for (int i=0;i<N;i++){
        cin >> A[i];
    }
    double B=0;
    for  (int j=0;j<N;j++){
        B = B + 1.0000000000/A[j];
}
double answer;
answer = 1.0000000000/B;
    cout << answer<<setprecision(10);
}

Measured memory_bytes: 256
from math import log2
from bisect import bisect_right
n, m = map(int, input().split())
a = [int(ai) for ai in input().split()]
a.sort()
b = [log2(ai) for ai in a]
ma = int(b[-1])
c = 0
tmp = 0
for t in range(-1, ma+1)[::-1]:
  i = bisect_right(b, t)
  d = n - i
  if c + d <= m:
    c += d
    for j in range(i, n):
      a[j] = a[j] / 2.0
  else:
    a.sort(reverse=True)
    for j in range(m-c):
      a[j] = a[j] / 2.0
    break
print(sum([int(ai) for ai in a]))


Measured memory_bytes: 14156
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = 1; i <= (n); i++)
#define DREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define SREP(i,s,t) for(int i = s; i < t; i++)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back



/* do your best */

int main() {
   
  lint n; cin >> n;
  vector<lint> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  int num = 1;
  for(int i = 0; i < n; i++) {
    if(num == a[i]) {
      ans++;
      num++;
    }
  }

  if(ans == 0) {
    cout << -1 << endl;
    return 0;
  }
  cout << n - ans << endl;
  return 0;
}


Measured memory_bytes: 1792
a=[list(input())for i in range(3)]
p=["a","b","c"]
h=["A","B","C"]
k=len(a[0])
c=0
r=[]
while k>0:
    t=a[:]
    r.append(c)
    c=p.index(t[c][0])
    a[r[-1]].pop(0)
    k=len(a[c])
print(h[c])

Measured memory_bytes: 3064
import re
import sys
s = input()
while True:
    if s[-5:] in ['dream', 'erase']:
        s = s[0:-5]
    elif s[-6:] in ['eraser']:
        s = s[0:-6]
    elif s[-7:] in ['dreamer']:
        s = s[0:-7]
    else:
        if s == '':
            print('YES')
            sys.exit()
        else:
            print("NO")
            sys.exit()


Measured memory_bytes: 3444
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
 
#define pb push_back
#define mp make_pair

typedef long long ll; 

#define fi first
#define se second
 
#define all(x) (x).begin(), (x).end()
 
using namespace std;             
//using namespace __gnu_pbds;
 
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int INF = (int)1e10;

int n, k, h[100500], dp[100500];

void solve() {       
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = abs(h[1] - h[2]);
    for (int i = 3; i <= n; i++) {
        dp[i] = INF;
    //    dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
        for (int j = 1; j <= k; j++) {
            dp[i] = min(dp[i], dp[max(1, i - j)] + abs(h[max(1, i - j)] - h[i]));
        }
    }
    cout << dp[n];
}           
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int tt = 1;
 
    while (tt--) {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#define int long long
#define INF 1e+18
using namespace std;

string op[100010];

signed main(){
	int n,a[100010],imos[100010] = {},sum = 0,ma = -INF;
	cin >> n;
	for(int i = 0;i < n;i++){
		if(i) cin >> op[i];
		else op[i] = "+";
		cin >> a[i];
		imos[i + 1] = imos[i] + a[i];
	}
	for(int i = 0;i < n;i++){
		if(op[i] == "-"){
			int pos = i + 1,tmp = -a[i];
			while(op[pos] == "+" && pos < n) tmp -= a[pos++];
			ma = max(ma,sum + tmp + imos[n] - imos[pos]);
			sum -= a[i];
		}else sum += a[i];
	}
	cout << max(ma,sum) << endl;
	return 0;
}

Measured memory_bytes: 7296
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define DEBUG(X) cerr<<__LINE__<<" "<<#X<<": "<<X<<endl;
#define sci(x) int x;scanf("%d",&x);
#define scii(x, y) int x,y;scanf("%d%d",&x,&y);
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define int long long
int solve() {
  sci(N); scii(A,B);
  if (A>B)
    return 0;
  if (N==1) {
    if (A!=B) return 0;
    else return 1;
  }

  if (A==B) return 1;

  return (N-2)*(B-A)+1;
}

signed main() {
  printf("%lld\n",solve());
}

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

class Main
{
    public static void main (String args[]) throws IOException         //?????????
    {
        InputStreamReader is = new InputStreamReader(System.in);       //?????????
        BufferedReader br = new BufferedReader(is);                    //?????????
        Scanner sc = new Scanner(System.in);

        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        int tmp_x = x;
        int tmp_y = y;

        if(x > W/2){
            tmp_x = W - x;
        }
        if(y > H/2){
            tmp_y = H - y;
        }
        if((tmp_y < r) || (tmp_x < r)){
            System.out.println("No");
        }
        else{
            System.out.println("Yes");
        }
    }
}
    

Measured memory_bytes: 26372
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
string s;
cin >> s;
if (s[s.size() - 1] == 's') cout << s << "es" << endl;
else
    cout << s << "s" << endl;
}

Measured memory_bytes: 3624
import java.util.*;
import java.math.*;

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

      Scanner sc = new Scanner(System.in);
    
      int N = sc.nextInt();
      
      String S = String.valueOf(N);
      
      if(S.contains("9")){
          System.out.println("Yes");
          return;
      }else{
          System.out.println("No");          
          return;
      }
      
   }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int m,n,i,j,k;
    j=k=0;
    scanf("%d%d",&n,&m);
    if(m == n)
        {
            if(m==0)
                m=1;
            for(i=0;i<m;i++)
                printf("%d",n);
        }
    else
        {
            if(m<n)
                j=n,k=m;
            else
                j=m,k=n;
            for(i=0;i<j;i++)
                printf("%d",k);
        }
    return 0;
}


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

int main() {
    int N,K;
    cin >> N >> K;
    set<int>set;
    for(int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for(int i = 0; i < d; i++) {
            int A;
            cin >> A;
            set.insert(A);
        }
    }
    cout << N-set.size() << endl;
} 


Measured memory_bytes: 3604
#include <stdio.h>

int main(void){
  int N,a;
  
  a=scanf("%d",&N);
  
  if(a!=1){
    printf("正しく入力されていません\n");
  }
  
  if(N%2==0){
    printf("%d\n",N/2);
  }
  else{
    printf("%d\n",N/2+1);
  }
return 0;
}
  

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

ll solve(string S) {
    int N = S.size();
    reverse(S.begin(), S.end());
    ll cnt = 0;
    while (true) {
        ll prev = cnt;
        rep(i,N-1) {
            if (S[i] == 'W' && S[i+1] == 'B') {
                swap(S[i], S[i+1]);
                cnt++;
                printf("%s\n", S.c_str());
            }
        }
        if (cnt == prev) break;
    }
    return cnt;
}

ll solve2(string S) {
    int N = S.size();
    ll cnt = 0, cn2 = 0;
    rep(i,N) if (S[i] == 'W') cnt++; else break;
    for (int i = N - 1; i >= 0; i--) if (S[i] == 'B') cn2++; else break;
    N -= cnt + cn2;
    S = S.substr(cnt, N);
    int s = 0;
    reverse(S.begin(), S.end());
    cnt = 0;
    rep(i,N) {
        if (S[i] == 'W') {
            cnt += N-1 -s -i;
            s++;
        }
    }
    return cnt;
}

int main() {
    string S; cin >> S;
    cout << solve2(S) << endl;
}


Measured memory_bytes: 3920
N,M = map(int,input().split())
Ls = []
Lp = []
for i in range(N):
    a,b = map(int,input().split())
    Ls.append([a,b])
for m in range(M):
    c,d = map(int,input().split())
    Lp.append([c,d])
for i in range(N):
    dis = []
    for m in range(M):
        dis.append(abs(Ls[i][0]-Lp[m][0])+abs(Ls[i][1]-Lp[m][1]))
    print(dis.index(min(dis))+1)

Measured memory_bytes: 3064
// ABC44-C.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <vector>
using namespace std;

int main()
{
	int n, a;
	cin >> n >> a;
	vector<int> x(n);
	for (size_t i = 0; i < n; ++i) cin >> x[i];
	auto dp = vector<vector<vector<long long>>>(n+1);
	for (size_t i = 0; i < n + 1; i++) {
		dp[i] = vector<vector<long long>>(n+1);

		for (size_t j = 0; j < n + 1; j++) {
			dp[i][j] = vector<long long>(n * a + 1);
			for (size_t k = 0; k < n * a + 1; k++) {
				dp[i][j][k] = 0;
			}
		}
	}
	dp[0][0][0] = 1;
	for (size_t i = 1; i < n+1; i++)
	{
		for (size_t j = 0; j < n+1; j++)
		{
			for (size_t k = 0; k < n * a + 1; k++)
			{
				if (k < x[i-1])
					dp[i][j][k] = dp[i - 1][j][k];
				else if (j >= 1 && k >= x[i-1]) 
					dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i-1]];
				else if(j != 0 || k != 0) dp[i][j][k] = 0;
			}
		}
	}
	long long sum = 0;
	for (size_t i = 1; i < n + 1; i++)
	{
		sum += dp[n][i][i * a];
	}
	cout << sum << endl;
    return 0;
}



Measured memory_bytes: 51200
#include <stdio.h>

int main(void)
{
	int n = 0;
	int m = 0;
	int x = 0;
	int y = 0;
	int c = 0;
	int i = 0;
	int j = 0;
	int a1 = 0;
	int b1 = 0;

	unsigned int A[100][100];
	unsigned int b[100];


	scanf("%d %d", &n, &m);

	for(i = 0; i < 100; i++)
	{
		for(j = 0; j < 100; j++)
		{
			A[i][j] = 0;
			b[j] = 0;
		}
	}

	for(i = 0; i < n; i++)
	{
		for(j = 0; j < m; j++)
		{
			scanf("%d", &x);
			A[i][j] = x;
		}
	}

	for(i = 0; i < m; i++)
	{
		scanf("%d", &y);
		b[i] = y;
	}

	for(i = 0; i < n; i++)
	{
		for(j = 0; j < m; j++)
		{
			a1 = A[i][j];
			b1 = b[j];
			c += a1 * b1;
			a1 = 0;
			b1 = 0;
		}
		printf("%d\n", c);
		c = 0;
	}

	return 0;
}

Measured memory_bytes: 640
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long
 
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
 
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
 
 
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
 
#define MOD 998244353
 
ll dp[3001][3001];
 
int main(){
    std::ios::sync_with_stdio(false);
    int n, s;
    cin >> n >> s;
    int a[n] = {};
    for(int i=0;i<n;++i)
    {
      cin >> a[i];
    }
    dp[0][0] = 1;
    for(int i=0;i<n;++i)
    {
      for(int j=0;j<=s;++j)
      {
        int add = 0;
        if(j - a[i] >= 0)
        {
          add = dp[i][j -a[i]];
        } 
        dp[i+1][j] = (dp[i][j] * 2 + add) % MOD;
      }
    }
    cout << dp[n][s] << endl;
}

Measured memory_bytes: 73936
n = input()
a = list(map(int, input().split()))
max = 0
target = a[0]
c = 0
for i in range(1, len(a)):
    if target >= a[i]:
        c += 1
    else:
        c = 0
    if max < c:
        max = c
    target = a[i]
print(max)

Measured memory_bytes: 14224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(In));
        }

        public T Min<T>(params T[] a)
        {
            if (a.Length == 0) return default(T);

            T min = a[0];
            for (int i = 1; i < a.Length; i++)
            {
                if ((dynamic)min > (dynamic)a[i]) min = a[i];
            }
            return min;
        }

        public T Max<T>(params T[] a)
        {
            if (a.Length == 0) return default(T);

            T max = a[0];
            for (int i = 1; i < a.Length; i++)
            {
                if ((dynamic)max < (dynamic)a[i]) max = a[i];
            }
            return max;
        }
        public T Lcm<T>(T a, T b)
        {
            return (dynamic)a * (dynamic)b / Gcd((dynamic)a, (dynamic)b);
        }

        public T Gcd<T>(T a, T b)
        {
            if ((dynamic)a < (dynamic)b)
                return Gcd(b, a);
            while ((dynamic)b != 0)
            {
                var remainder = (dynamic)a % (dynamic)b;
                a = b;
                b = remainder;
            }
            return a;
        }

        public void Solve(ConsoleInput input)
        {
            var n = input.ReadLong;
            var a = input.ReadLongArray(n);

            var ans = a[0];
            for (var i = 1; i < n; i++)
            {
                ans = Gcd(ans, a[i]);
            }
            WriteLine($"{ans}");

            //Solve(input);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private readonly char _separator;
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            _separator = separator;
            _stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 37900
#include <bits/stdc++.h>
 
using namespace std;
 
int N,M,K;
map<int,int> mp;
 
void make(int n,int sum){
    if(N == n){
	if(sum-K <= 0){
	    mp[1]++;
	}else{
	    mp[sum-K]++;
	}
	return;
    }
    for(int i = 0 ; i < M ; i++){
	make(n+1,sum+i+1);
    }
}
 
int main(){
    while(cin >> N >> M >> K, N){
	mp.clear();
	make(0,0);
	double ans = 0;
	map<int,int>::iterator it;
	for(it = mp.begin() ; it != mp.end() ; ++it){
	    ans += ((double)it->second/pow((double)M,N))*it->first;
	}
	printf("%.8f\n",ans);
    }
    return 0;
}

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

using namespace std;

int n;

typedef long long LL;

LL a[20][20];

const int maxn = (1 << 16) + 5;
LL sum[maxn];
LL dp[maxn];

int main(){
    cin >> n;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            scanf("%lld", &a[i][j]);
        }
    }
    for(int i = 0;i < (1 << n);i++){
        for(int j = 0;j < n;j++){
            for(int k = j + 1;k < n;k++){
                if(a[j][k] == 0)
                    continue;
                if(i & (1 << j)){
                    if(i & (1 << k)){
                        sum[i] += a[j][k];
                    }
                }
            }
        }
    }
    for(int S = 1;S < (1 << n);S++){
        dp[S] = sum[S];
        for(int i = S;i > 0; i = (i - 1) & S){
            dp[S] = max(dp[S], dp[i] + dp[S ^ i]); 
        }
    }
    cout << dp[(1 << n) - 1] << endl;
    return 0;
}


Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0006
{
    public class Program

    {
        public static void Main(string[] args)
        {
            string line = ReadSt();
            char[] res = line.Reverse().ToArray();
            Console.WriteLine(string.Join("",res));
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  std::string s;
  std::cin >> s;
  std::string a[] = {"SS", "SW", "WS", "WW"};

  const auto same = [](auto i) {
    if (i == 'S') {
      return 'S';
    } else {
      return 'W';
    }
  };
  const auto rev = [](auto i) {
    if (i == 'S') {
      return 'W';
    } else {
      return 'S';
    }
  };


  for (int64_t i = 1; i < n; i++) {
    for (auto &j : a) {
      if (s[i] == 'o' && j[i] == 'S') {
        j.push_back(same(j[i - 1]));
      } else if (s[i] == 'o') {
        j.push_back(rev(j[i - 1]));
      } else if (j[i] == 'S') {
        j.push_back(rev(j[i - 1]));
      } else {
        j.push_back(same(j[i - 1]));
      }
    }
  }

  for (auto &j : a) {
    if (j.front() == j.back()) {
      j.pop_back();
      if ((((j.front() == 'S' && s.front() == 'o')
        || (j.front() == 'W' && s.front() == 'x')) && j[1] == j.back()) ||
        (((j.front() == 'S' && s.front() == 'x')
        || (j.front() == 'W' && s.front() == 'o')) && j[1] != j.back())) {
        std::cout << j << std::endl;
        return 0;
      }
    }
  }
  std::cout << -1 << std::endl;
  return 0;
}


Measured memory_bytes: 1152