akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	string s,t;
	int k=0,m,n,i,j,count=0,min=0,flag=0;
	cin>>s>>t;
	m=s.size();
	n=t.size();
	for(i=0;i<m;i++)
	{
		if(m-i>=n)
		{
			count=0;
			for(j=0;j<n;j++)
			{
				if(t[j]!=s[i+j])
				{
					count++;
				}
			}
		}
		if(flag==0)
		{
			flag=1;
			min=count;
		}
		if(min>count)
			min=count;
	}
	cout<<min<<endl;
	return 0;
}

Measured memory_bytes: 3596
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nmx = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var query = new int[nmx[0]][];
            var result = long.MaxValue;
            for (var i = 0; i < nmx[0]; i++)
            {
                query[i] = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            }
          
            for (var bit = 0; bit < (1 << query.Length); bit++)
            {
                var scores = new int[nmx[1] + 1];
                for (var i = 0; i < nmx[0]; i++)
                {
                    if ((bit & (1 << i)) == 0) continue;
                    for (var j = 0; j < scores.Length; j++)
                    {
                        scores[j] += query[i][j];
                    };
                }

                var isValid = true;
                for (var i = 1; i < scores.Length; i++)
                {
                    if (scores[i] < nmx[2])
                    {
                        isValid = false;
                        break;
                    }
                }
                if (isValid) result = Math.Min(scores[0], result);
            }

            Console.WriteLine(result < long.MaxValue ? result : -1);
        }
    }
}


Measured memory_bytes: 28548
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = [None] * n
for i in range(n):
    a[i] = (i,int(input()))
    
a.sort(key=lambda x: x[1])
ans = 0
for i in range(n):
    if a[i][0]%2 != i%2:
        ans += 1
print(ans//2)

Measured memory_bytes: 47964
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdlib.h>
#include<set>
#include<math.h>
#include<iomanip>
#include<unordered_map>
#include<algorithm>

using namespace std;


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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main() {
    int a, b; cin >> a >> b;
    a--; b--;
    vector<string> s(100, string(100, '#'));
    for(int i=50; i<100; i++) {
        s[i] = string(100, '.');
    }

    for(int i=0; i<49; i+=2) {
        for(int j=0; j<100; j+=2) {
            if(a == 0) break;
            s[i][j] = '.';
            a--;
        }
    }
    for(int i=51; i<100; i+=2) {
        for(int j=0; j<100; j+=2) {
            if(b == 0) break;
            s[i][j] = '#';
            b--;
        }
    }
    cout << s.size() << " " << s[0].size() << endl;
    for(int i=0; i<100; i++) cout << s[i] << endl;

    return 0;
}

// EOF


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

int main()
{
    int a, b;
    char op;
    
    cin >> a >> op >> b;
    
    int ans;

    if (op == '+') ans = a + b;
    else ans = a - b;

    cout << ans << endl;

    return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  multiset<int> p;
  rep(i,n){
    int q;
    cin >> q;
    p.insert(q);
  }
  int a=0;
  rep(i,k){
    a += *p.begin();
    p.erase(p.begin());
  }
  printf("%d",a);
  return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var N = long.Parse(Console.ReadLine());
        var count = 0;
        for (long n = 1; n <= N; n += 2)
        {
            var primes = PrimeFactors(n).ToArray();
            var primeCounts = new int[N + 1];
            foreach (var prime in primes)
            {
                primeCounts[prime]++;
            }

            var sum = 1;
            foreach (var primeCount in primeCounts)
            {
                if (primeCount == 0)
                {
                    continue;
                }

                sum *= (primeCount + 1);
            }

            if (sum == 8)
            {
                count++;
            }
        }

        Console.WriteLine(count);
    }

    /**
     * 素因数分解
     * <see cref="https://qiita.com/y_miyoshi/items/da814d96e8890224aad3"/>
     */
    public static IEnumerable<long> PrimeFactors(long n)
    {
        long i = 2;
        long tmp = n;

        while (i * i <= n) //※1
        {
            if (tmp % i == 0)
            {
                tmp /= i;
                yield return i;
            }
            else
            {
                i++;
            }
        }
        if (tmp != 1) yield return tmp;//最後の素数も返す
    }

}



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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){
  
  int n;
  cin >> n;
  set<pair<int,int>> st;
  for(int i = 1;i <= n;i++){
    for(int j = i+1;j <= n;j++){
      st.insert(make_pair(j,i));
    }
  }
  if(n&1){
    for(int i = 1,j = n-1;i < j;i++,j--){
      st.erase(make_pair(j,i));
    }
  }else{
    for(int i = 1,j = n;i < j;i++,j--){
      st.erase(make_pair(j,i));
    }
  }
  cout << st.size() << "\n";
  for(auto iter = st.begin();iter != st.end();iter++){
    cout << (*iter).first << " " << (*iter).second << "\n";
  }




  return 0;
}

Measured memory_bytes: 512
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] c = new int[n-1];
        int result = 0;
        for(int i = 0;i<n;i++){
            a[i] = sc.nextInt();
        }
        for(int i = 0;i<n;i++){
            result += sc.nextInt();
        }
        for(int i = 0;i<(n-1);i++){
            c[i] = sc.nextInt();
        }for(int i = 1;i<n;i++){
            if(a[i] - a[i-1] == 1){
                result += c[a[i-1]-1];
            }
        }
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 20948
c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())
ma1 = max(c11, c12, c13) + 1
ma2 = max(c21, c22, c23) + 1
ma3 = max(c31, c32, c33) + 1
mb1 = max(c11, c21, c31) + 1
mb2 = max(c12, c22, c32) + 1
mb3 = max(c13, c23, c33) + 1
for a1 in range(ma1):
    for b1 in range(mb1):
        if a1 + b1 != c11:
            continue
        for a2 in range(ma2):
            if a2 + b1 != c21:
                continue
            for b2 in range(mb2):
                if a1 + b2 != c12 or a2 + b2 != c22:
                    continue
                for a3 in range(ma3):
                    if a3 + b1 != c31 or a3 + b2 != c32:
                        continue
                    for b3 in range(mb3):
                        if a1 + b3 != c13 or a2 + b3 != c23 or a3 + b3 != c33:
                            continue
                        print('Yes')
                        exit()
print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


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

	ll n;
	cin >> n;
	vector<P> ans;
	set<P> did;
	ll no = n;
	if(no%2==0)no++;
	FOR(i,1,n+1){
		FOR(j,1,n+1){
			if(i<j && (i+j!=no))ans.push_back({i,j});
		}
	}
	cout << ans.size() << endl;
	for(auto x:ans){
		cout << x.first << " " << x.second << endl;
	}
}

Measured memory_bytes: 512
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll

void solve() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) return;
		vector<int> inputs;
		REP(i, n) {
			string s;
			cin >> s;
			if (s == "x") {
				inputs.push_back(-1e18);
			}
			else {
				inputs.push_back(stoll(s));
			}
		}
		int now_min = 1e18;
		int now_max = -1e18;
		REP(i, inputs.size()) {
			if (inputs[i] == -1e18) {
				if (i % 2 == 1) {
					if (i - 1 >= 0 && inputs[i - 1] != -1e18) {
						now_max = max(now_max, inputs[i - 1] + 1);
					}
					if (i + 1 < inputs.size() && inputs[i + 1] != -1e18) {
						now_max = max(now_max, inputs[i + 1] + 1);
					}
				}
				else {
					if (i - 1 >= 0 && inputs[i - 1] != -1e18) {
						now_min = min(now_min, inputs[i - 1] - 1);
					}
					if (i + 1 < inputs.size() && inputs[i + 1] != -1e18) {
						now_min = min(now_min, inputs[i + 1] - 1);
					}
				}
			}
		}

		for (int i = 1; i < inputs.size(); ++i) {
			if (inputs[i - 1] == inputs[i]) {
				now_max = 2e18;
			}
			if (i % 2 == 0) {
				if (inputs[i] != -1e18 && inputs[i - 1] != -1e18) {
					if (inputs[i - 1] <= inputs[i]) {
						now_max = 2e18;
					}
				}
			}
			else {
				if (inputs[i] != -1e18 && inputs[i - 1] != -1e18) {
					if (inputs[i - 1] >= inputs[i]) {
						now_max = 2e18;
					}
				}
			}
		}
		if (now_min != now_max) {
			if (now_max < now_min) {
				cout << "ambiguous" << endl;
			}
			else {
				cout << "none" << endl;
			}
		}
		else {
			cout << now_min << endl;
		}
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3152
#include<iostream>
#include<vector>
#include<iterator>
#include<algorithm>
#include<cmath>
#include<functional>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<string>
#include<numeric>
//#include<bits/stdc++.h>
using namespace std;

int main(){
	int n;
  	cin >> n;
	auto h = vector<int>(istream_iterator<int>(cin),istream_iterator<int>());
	auto num = vector<int>(n,0);
	
  	for (int i = 0; i < n; i++)
	{
		for (int j = i+1; j < n; j++)
		{
          	if(h[i] <= h[j]){
            	num[j]++;
            }
		}
	}
	
	int count =1;
	for (int i = 1; i < n; i++)
	{
      if(num[i] == i){
        	count++;
      }
	}
	cout << count;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef tuple<int, int, int, int> t4;
typedef pair<ll, ll> PL;
typedef long double ldouble;

void solve(){
	int n, a[20], k; scanf("%d%d", &n, &k);
	rep(i, n)scanf("%d", a+i);
	ll ans = 1e18;
	rep(i, 1<<n)if(__builtin_popcount(i) == k){
		ll cnt = 0, mx = -1;
		for(int j=0;j<n;j++){
			if(1<<j&i){
				if(mx >= a[j])cnt += mx - a[j] + 1, ++mx;
				else mx = a[j];
			}
			else mx = max(mx, (ll)a[j]);
		}
		ans = min(ans, cnt);
	}
	printf("%lld\n", ans);
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		//printf("Case #%d: ", tc);
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
   
int main(){
    int n,b;
    cin >> n >> b;
    for (int i = 1;i < n;i++){
        long long a;
        cin >> a;

        int c = a % b;
        while (c != 0){
            a = b;
            b = c;
            c = a % b;
        }

        if (b == 1) break;
    }

    cout << b << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int N, a[100000], count = 0, halfcount = 0;
    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        scanf("%d", &a[i]);
    }
    for(int i = 0; i < N; i++){
        if(a[i] % 4 == 0) count++;
        else if(a[i] % 2 == 0) halfcount++;
    }
    count += (halfcount / 2);
    if((N / 2) <= (count)) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(){
    int N;
    scanf("%d",&N);
    if(N<=9){
        printf("%d",N);
        return 0;
    }
    if(N<=99){
        printf("9");
        return 0;
    }
    if(N<=999){
        printf("%d",N-90);
        return 0;
    }
    if(N<=9999){
        printf("%d",909);
        return 0;
    }
    if(N<=99999){
        printf("%d",N-9090);
        return 0;
    }
    printf("90909");
}

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

int dp[100500];
int a[100050];

int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }

    dp[0]=1;
    for(int i=1;i<=k;i++){
        for(int j=0;j<n && !dp[i] && a[j]<=i;j++){
            if(i-a[j]==0 || !dp[i-a[j]])  dp[i]=1;
        }
    }

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

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;


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

    vector<int> vec(n);
    int tmp;
    rep(i,n-1){
        cin >> tmp;
        tmp--;
        vec[tmp]++;
    }

    rep(i,n){
        cout << vec[i] << endl;
    }

    return 0;
}

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

int main()
{
  int n; cin >> n;
  vector<string> s(n);
  rep(i, n)
  {
    string str;
    cin >> str;
    s[i] = str;
  }
  sort(s.begin(), s.end());

  int maximum = 1;
  vector<string> ans(1);
  ans[0] = s[0];
  int count = 1;
  int i = 1;
  while (i < n)
  {
    if (s[i] == s[i - 1])
      count++;
    else
      count = 1;
    if (count == maximum)
      ans.push_back(s[i]);
    else if (count > maximum)
    {
      if (s[i] != ans[0])
      {
        ans.clear();
        ans.push_back(s[i]);
      }
      maximum = count;
    }
    i++;
  }
  for (auto p : ans)
    cout << p << endl;
}


Measured memory_bytes: 15988
#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 ll long long
typedef pair<int , int > pii;
#define MOD 1000000007
#define MOD1 998244353
#define ff first
#define ss second
#define bn cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define sz(a) int((a).size())
#define o(a) cout << a
#define MAX6 1000006
#define int ll
#define all(x) x.begin(), x.end()
#define ppii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define viii vector<ppii>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define MAX5 300005
#define MAX7 10000007
#define rep(i,a,b)  for (__typeof((b)) i=(a);i<=(b);i++)
#define nrep(i,b,a)  for (__typeof((b)) i=(b);i>=(a);i--)
#define mem(a) memset(a,0,sizeof(a))
#define memneg(a) memset(a,-1,sizeof(a))
//#define se second
#define LN 14
#define LIM 22
#define MAX_ALPHA 26
const long long INF64 = 1e18;
const ll INF = 1e9;
const double PI = acos(-1);
#define ld long double
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
inline void max_self(ll &a, ll b)
{
  a = max(a,b);
}
 
inline void min_self(ll &a,ll b)
{
  a = min(a,b);
}
 
inline void add_self(ll &a, ll b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
inline void sub_self(ll &a, ll b) {
  a -= b;
  if (a < 0) a += MOD;
}
 
inline int mul(int a, int b) {
  return (int) ((long long) a * b % MOD);
}
 
 
ll gcd(ll a,ll b)
{
  if(b == 0)
    return a;
  else 
    return gcd(b, a%b);
}
 
 
int countDigits(int x)
{
  int cnt = 0;
  while(x)
  {
    x /= 10;
    cnt++;
  }
  return cnt;
}
 
 
ll binExpo(ll a,ll b)
{
  ll res = 1;
  while(b)
  {
    if(b&1)
      res = (res * a)%MOD;
    a = (a * a)%MOD;
    b /= 2;
  }
  return res%MOD;
}
 
int sum(int a) {
    int result = 0;
    while (a > 0) {
        result += a % 10;
        a /= 10;
    }
    return result;
}

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int n, w;
  cin>>n>>w;
  vector<int > weight(n), value(n);
  rep(i, 0, n-1)
    cin>>weight[i]>>value[i];

  int sum_value = 0;
  rep(i, 0, n-1)
    sum_value += value[i];
  vector<int > dp(sum_value + 1, INF64);
  dp[0] = 0;
  rep(item, 0, n-1)
  {
    for(int value_already = sum_value - value[item];value_already >= 0;value_already--)
    {
      min_self(dp[value_already + value[item]], dp[value_already] + weight[item]);
    }
  }
  int ans = 0;
  rep(i, 0, sum_value)
  {
    if(dp[i] <= w)
    {
      ans = max(ans, i);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;


int main()
{
    int n;
    string s;
    int k;
    cin >> n >> s >> k;
    k--;
    for (int i = 0; i < n; ++i)
        cout << (s[i] == s[k] ? s[i] : '*');
}


Measured memory_bytes: 256
def solve():
    MOD = 10**9 + 7

    N = int(input())
    Ss = input()

    N2 = 2*N
    LRs = [0] * N2
    numL = 0
    for i, S in enumerate(Ss):
        if numL == 0:
            if S == 'W':
                return 0
            LRs[i] = 'L'
            numL += 1
        else:
            if S == 'W':
                if numL % 2:
                    LRs[i] = 'L'
                    numL += 1
                else:
                    LRs[i] = 'R'
                    numL -= 1
            else:
                if numL % 2:
                    LRs[i] = 'R'
                    numL -= 1
                else:
                    LRs[i] = 'L'
                    numL += 1
#    print(LRs)

    ans = 1
    numL = 0
    for LR in LRs:
        if LR == 'L':
            numL += 1
        else:
            if numL <= 0:
                return 0
            ans *= numL
            ans %= MOD
            numL -= 1
#    print(ans)

    if numL != 0:
        return 0

    fact = 1
    for i in range(1, N+1):
        fact = (fact*i) % MOD

    return ans*fact%MOD


ans = solve()
print(ans)


Measured memory_bytes: 46704
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <iomanip>
#include <math.h>
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define endl '\n'
#define EPS 1e-9
#define PI acos(-1)
 
using ll = long long;
using pll = pair<ll,ll>;
using ii = pair<int,int>;
using iii = pair<pair<int,int>,int>;
using viii = vector<iii>;
using vi = vector<int>;
using vii = vector<ii>;
using vll = vector<ll>;
using ui = unsigned int;


int main() {
    ofstream out("output.txt");
    ios_base::sync_with_stdio(false);

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

    return 0;
}   


Measured memory_bytes: 256
#include  <iostream>

int main(){
int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int count = 1;
    b != a ? count++ : 0;
    c != a && c != b ? count++ : 0;
    
    printf("%d\n", count);
return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
    public static void main(String[] args) throws IOException
    {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
        a = 0;b = 0;c=0;d=0;e=0;e=0;f=0;g=0;h=0;i=0;j=0;k=0;l=0;m=0;n=0;o=0;p=0;
        q=0;r=0;s=0;t=0;u=0;v=0;w=0;x=0;y=0;z=0;

        String line = new String();
        while((line = reader.readLine())!=null){
            int len = line.length();
            for(int num =0;num < len;num++){
                String ch = line.toLowerCase();
                char ch2 = ch.charAt(num);

                if(ch2 =='a')a++;
                else if(ch2 =='b')b++;
                else if(ch2 =='c')c++;
                else if(ch2 =='d')d++;
                else if(ch2 =='e')e++;
                else if(ch2 =='f')f++;
                else if(ch2 =='g')g++;
                else if(ch2=='h')h++;
                else if(ch2 =='i')i++;
                else if(ch2 =='j')j++;
                else if(ch2 =='k')k++;
                else if(ch2=='l')l++;
                else if(ch2=='m')m++;
                else if(ch2=='n')n++;
                else if(ch2=='o')o++;
                else if(ch2=='p')p++;
                else if(ch2=='q')q++;
                else if(ch2=='r') r++;
                else if(ch2=='s') s++;
                else if(ch2=='t') t++;
                else if(ch2=='u') u++;
                else if(ch2=='v') v++;
                else if(ch2=='w') w++;
                else if(ch2=='x') x++;
                else if(ch2=='y') y++;
                else if(ch2=='z') z++;
                


            }
        }
        System.out.println("a : "+a);
        System.out.println("b : "+b);
        System.out.println("c : "+c);
        System.out.println("d : "+d);
        System.out.println("e : "+e);
        System.out.println("f : "+f);
        System.out.println("g : "+g);
        System.out.println("h : "+h);
        System.out.println("i : "+i);
        System.out.println("j : "+j);
        System.out.println("k : "+k);
        System.out.println("l : "+l);
        System.out.println("m : "+m);
        System.out.println("n : "+n);
        System.out.println("o : "+o);
        System.out.println("p : "+p);
        System.out.println("q : "+q);
        System.out.println("r : "+r);
        System.out.println("s : "+s);
        System.out.println("t : "+t);
        System.out.println("u : "+u);
        System.out.println("v : "+v);
        System.out.println("w : "+w);
        System.out.println("x : "+x);
        System.out.println("y : "+y);
        System.out.println("z : "+z);

        }
    }





Measured memory_bytes: 28652
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;

vector<int> a;

int main()
{
	int n; scanf("%d", &n);
	a.resize(n);
	for(int i = 0; i< n; i++)
	{
		scanf("%d", &a[i]);
		a[i] -= i+1;
	}
	sort(a.begin(), a.end());
	int det = n%2?a[n/2]:(a[n/2-1]+a[n/2])/2;
	ll res = 0;
	for(int i = 0; i< n; i++)
	{
		res += abs(det-a[i]);
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define MAX (1 << 29)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  int ct = 1;
  FOR(i, N - 1) if (S[i] != S[i + 1]) ct++;
  ct = max(1, ct - 2 * K);
  print(N - ct);
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int x;

signed main() {
	cin >> x;
	for (int i = 360;; i += 360) {
		if (i%x == 0) {
			cout << i / x << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

long long gcd(long long a, long long b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
	int K; cin >> K;
	long long ans = 0;
	for (int i = 1; i <= K; ++i)
		for (int j = 1; j <= K; ++j)
			for (int k = 1; k <= K; ++k)
				ans += gcd(i, gcd(j, k));
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3624
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        mut s: String,
        t: String,
    }
    println!(
        "{}",
        if (0..s.len())
            .map(|i| s[i..].to_string() + &s[0..i] == t)
            .any(|b| b)
        {
            "Yes"
        } else {
            "No"
        }
    );
}


Measured memory_bytes: 2172
#include <cstdio>
const int Maxn=1000;
char s[Maxn+5];
int main(){
	int n=0;
	scanf("%s",s+1);
	while(s[++n]!='\0');
	n--;
	if(s[n]=='s'){
		n+=2;
		s[n-1]='e';
		s[n]='s';
	}
	else{
		n++;
		s[n]='s';
	}
	puts(s+1);
	return 0;
}


Measured memory_bytes: 1644
#include <cstdio>

using namespace std;

int main() {
  char s[10001];
  while (scanf("%s", s) == 1) {
    int JOI = 0, IOI = 0;
    for (int i = 0; s[i+2]; i++)
      if (s[i] == 'J' && s[i+1] == 'O' && s[i+2] == 'I')
        JOI++;
      else if (s[i] == 'I' && s[i+1] == 'O' && s[i+2] == 'I')
        IOI++;
    printf("%d\n%d\n", JOI, IOI);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int N;
  cin >> N ;
  int sum = 0;
  string str = std::to_string(N);
  
  for(int i = 1 ; i <= N ; i++){
    
    string str = std::to_string(i);
    
    if( str.size() %2 == 1 ){
      sum++;
    }
    
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 384
using System;
using System.Linq;

namespace AGC031A
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            long[] longs = Console.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
            long N = longs[0];
            string S = Console.ReadLine();

            int[] chars = new int[26];
            for (int i = 0; i < N; i++)
            {
                chars[S[i] - 'a']++;
            }

            long ans = 1;
            long BIG = 1000000007;

            for (int i = 0; i < 26; i++)
            {
                ans = ans * (chars[i] + 1) % BIG;
            }

            Console.WriteLine(ans - 1);
        }
    }
}

Measured memory_bytes: 13268
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}

const int mod = 1e9+7;
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
int T;
int n;
ll a[211];
char s[211];
ll v[64];
void add(ll x)
{
	for (int j=63; j>=0; j--)
	{
		if ((x>>j)&1)
		{
			if (!v[j])
			{
				v[j] = x;
				return;
			}
			else x ^= v[j];
		}
	}
}
bool query(ll x)
{
	for (int j=63; j>=0; j--)
	{
		if ((x>>j)&1)
		{
			if (!v[j]) return false;
			else x ^= v[j];
		}
	}
	return true;
}
int main()
{
	geti(T);
	while (T--)
	{
		memset(v, 0, sizeof(v));
		geti(n);
		for (int i=1; i<=n; i++) geti(a[i]);
		for (int i=1; i<=n; i++) s[i] = getreal();
		bool flag = false;
		for (int i=n; i>=1; i--)
		{
			if (s[i]=='0')
			{
				add(a[i]);
			}
			else
			{
				if (!query(a[i]))
				{
					flag = true;
					puts("1");
					break;
				}
			}
		}
		if (!flag) puts("0");
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

const ll M = 1e9 + 7;
const int N = 100100;

ll d[N], df[N], kek[N];

void update(int l, int r, ll x) {
    d[l] += x;
    d[r + 1] -= x + r - l;
    ++df[l];
    --df[r];
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (i && a[i] < a[i - 1]) {
            ll t = (a[i - 1] - a[i] + m - 1) / m;
            a[i] += t * m;
        }
    }
    ll s = a[n - 1] - a[0];
    for (int i = 0; i + 1 < n; ++i) {
        if (a[i + 1] - a[i] < 2) {
            continue;
        }
        int l = (a[i] + 2) % m;
        int r = (a[i + 1]) % m;
        if (!l) {
            l += m;
        }
        if (!r) {
            r += m;
        }
        if (l > r) {
            update(l, m, 1);
            update(1, r, m - l + 2);
        } else {
            update(l, r, 1);
        }
    }
    ll ans = s;
    ll tmp = 0;
    for (int i = 1; i <= m; ++i) {
        tmp += df[i - 1];
        d[i] += tmp;
    }
    for (int i = 1; i <= m; ++i) {
        kek[i] = kek[i - 1] + d[i];
    }
    for (int i = 1; i <= m; ++i) {
        ans = min(ans, s - kek[i]);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3328
import java.util.*;
import java.lang.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long ans = Long.MAX_VALUE;
        long n, k;
        long[] x = new long[100005];

        n = sc.nextLong();
        k = sc.nextLong();
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextLong();
        }

        for (int i = 0; i < n - k + 1; i++) {
            int l = i;
            int r = i + (int)k - 1;
            long tmp = x[r] - x[l];

            if (x[l] < 0 && x[r] > 0) {
                tmp += Math.min(x[r], Math.abs(x[l]));
            }
            else if (x[l] > 0) {
                tmp += x[l];
            }
            else if (x[r] < 0) {
                tmp += Math.abs(x[r]);
            }

            ans = Math.min(ans, tmp);
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 52076
n=int(input())
ans=[0 for _ in range(10001)]

for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      v=x*x+y*y+z*z+x*y+y*z+z*x
      if v<10001:
        ans[v]+=1

for i in range(n):
  print(ans[i+1])

Measured memory_bytes: 9036
import math
X, Y = map(int, input().split())
if X > Y:
  X, Y = Y, X

if ((2*X-Y) % 3 != 0) or (2*X-Y < 0):
  print(0)
  exit()
A = (2*X-Y)//3
B = Y-X+A
N = A+B
nu = 1
de = 1
for i in range(B+1, N+1):
  nu = (nu * i) % (10 ** 9 + 7)
for i in range(1, A+1):
  de = (de * i) % (10 ** 9 + 7)
  
print((nu * pow(de, -1, 10 ** 9 + 7) ) % (10 ** 9 + 7))

Measured memory_bytes: 9124
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;
int main() {
    list<char> v;
    string s;
    char ch; int t,u,q,k=1;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        v.push_back(s[i]);
    }
    cin >> q;
    for (int i=0; i<q;i++){
        cin >> t;
        if (t == 1) k++;
        else {
            cin >> u >> ch;
            if ((u +k)%2==1) v.push_back(ch);
            else v.push_front(ch);
        }   
        
    }
    if (k % 2 == 0) reverse(v.begin(), v.end());
    while(!(v.empty())){
        printf("%c", v.front()); v.pop_front();
    }
    printf("\n");
}

Measured memory_bytes: 9984
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;


int main(){
  int n;
  cin >> n;
  ll m = 0, a = 0, r = 0, c = 0, h = 0;
  rep(i, n){
    string s;
    cin >> s;
    if (s[0] == 'M') m++;
    else if (s[0] == 'A') a++;
    else if (s[0] == 'R') r++;
    else if (s[0] == 'C') c++;
    else if (s[0] == 'H') h++;
  }

  ll ans = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h;
  cout << ans << endl;

}

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

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

  int mini;
  cin >> mini;
  int maxi=0;
  vector<int> A(N);
  A[0] = 0;
  for (int i=1; i<N; i++) {
     cin >> A[i];
    if (mini > A[i]) mini = A[i];
    A[i] -= mini;
    if (maxi < A[i]) maxi = A[i];
  }

  int ans=0;
  for (int i=0; i<N; i++) {
    if (maxi == A[i]) ans++;
  }

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
const ll MAX_N=2e5;

ll N;
ll cnt[MAX_N];
int main(){
	cin.tie(0);
	cin.sync_with_stdio(false);
	cin>>N;
	ll ans=0;
	REP(i,N){
		ll a;
		cin>>a;
		if(i-a>=0){
			ans+=cnt[i-a];
		}
		if(i+a<N){
			cnt[i+a]++;
		}
	}
	cout<<ans<<endl;
}


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

int main()
{
	
	string s;
	cin >> s;
	
	if (s[2] == s[3] && s[4] == s[5])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
	
}

Measured memory_bytes: 256
i=lambda:map(int,input().split());n,m=i();l=[0,1]+[0]*n;c=[0]+[1]*n
for _ in[0]*m:x,y=i();l[y]|=l[x];c[y]+=1;c[x]-=1;l[x]=c[x]and l[x]
print(sum(c[i]and l[i]for i in range(n+1)))

Measured memory_bytes: 53976
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int mod = 1e9+7;
int32_t main(){
	int n;
	cin>>n;
	int dp[n+1];
	memset(dp,0,sizeof(dp));
	dp[0]=1;
	for(int amount = 1; amount <= n;amount++){
		for(int coin = 3 ;coin<=amount;coin++){
			dp[amount]=(dp[amount]%mod + dp[amount-coin]%mod)%mod;
		}
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main() {
  int n,x,cnt;
  while(cin >> n >> x&&n||x) {
    cnt=0;
    for(int i=1;i<=n-2;i++){
      for(int j=i+1;j<=n-1;j++){
        for(int k=j+1;k<=n;k++){
          if(i+j+k==x) cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {-1, 0, 1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string a, b, c;
    cin >> n >> a >> b >> c;
    
    int cnt = 0;
    rep(i, n){
        int tmp_diff = 0;
        
        if(a[i] == b[i]){
            if(b[i] == c[i]){
                if(a[i] == c[i]){
                    //全部同じ
                    tmp_diff = 0;
                }else{
                    //あり得ない
                    tmp_diff = 100;
                    cout << "error1" << endl;
                }
            }else{
                if(a[i] == c[i]){
                    //あり得ない
                    tmp_diff = 100;
                    cout << "error2" << endl;
                }else{
                    //cだけ違う
                    tmp_diff = 1;
                }
            }
        }else{
            if(b[i] == c[i]){
                if(a[i] == c[i]){
                    //あり得ない
                    tmp_diff = 100;
                    cout << "error3" << endl;
                }else{
                    //aだけ違う
                    tmp_diff = 1;
                }
            }else{
                if(a[i] == c[i]){
                    //bだけ違う
                    tmp_diff = 1;
                }else{
                    //全部違う
                    tmp_diff = 2;
                }
            }
        }
        
        cnt += tmp_diff;
    }
    cout << cnt << endl;
}

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

vector<double> p;
vector<double> q;
vector<double> psum;
vector<double> qsum;
double memo[502][502];

double dfs( int l, int r )
{
	if( memo[l][r] >= 0 ) return memo[l][r];
	if( l == r ) return memo[l][r] = 0;
	double res = DBL_MAX;
	double total = psum[r] - psum[l] + qsum[r] - qsum[l - 1];
	for( int x = l + 1; x <= r; x++ ) {
		double left = psum[x - 1] - psum[l] + qsum[x - 1] - qsum[l - 1];
		double right = total - left - p[x - 2];
		double w = (dfs( l, x - 1 ) + 1) * left / total + (dfs( x, r ) + 1) * right / total;
		res = min( res, w );
	}
	memo[l][r] = res;
	return res;
}

int main()
{
	int n;
	cin >> n;
	p = vector<double>( n );
	for( int i = 0; i < n; i++ ) cin >> p[i];
	q = vector<double>( n + 1 );
	for( int i = 0; i < n + 1; i++ ) cin >> q[i];

	memset( memo, -1, sizeof( memo ) );
	psum = vector<double>( n + 2 );
	for( int i = 2; i < n + 2; i++ ) psum[i] = psum[i - 1] + p[i - 2];
	qsum = vector<double>( n + 2 );
	for( int i = 1; i < n + 2; i++ ) qsum[i] = qsum[i - 1] + q[i - 1];
	double ans = dfs( 1, n + 1 ) + 1;

	cout << fixed << setprecision(8) << ans << endl;
}



Measured memory_bytes: 5320
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    for(;;){
        int H,W; cin >> H >> W;
        if(H==0 && W==0) break;
        rep(i,H){
            rep(i,W){
                cout << '#'; 
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


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

using namespace std;

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

typedef long long ll;
typedef long double ld;

const ll Inf = 1e18;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

ll modpower(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll modinv(ll a, ll mod) {
    return modpower(a, mod - 2, mod);
}

ll largeCOM(ll n, ll r, ll mod) {
    ll u = 1, d = 1;
    rep (i, r) {
        u = (u * (n - i)) % mod;
        d = (d * (r - i)) % mod;
    }
    return u * modinv(d, mod) % mod;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    ll n;
    int a, b;
    cin >> n >> a >> b;
    ll res = (modpower(2, n, MOD) - 1) % MOD;
    res -= largeCOM(n, a, MOD);
    if (res < 0) res += MOD;
    res -= largeCOM(n, b, MOD);
    if (res < 0) res += MOD;
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 256
a, b, c = map(int, input().split())
d = 0
if a > b :
    d = a
    a = b
    b = d
if a > c :
    d = a
    a = c
    c = d
if b > c :
    d = b
    b = c
    c = d
print(a, b, c)


Measured memory_bytes: 5596
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 16:22:00 2020

@author: neb0123
"""

import itertools

def solution(A,n,m,k):
	cnt = 0
	for i in range(n+1):
		R = list(itertools.combinations(range(n),i))
		for row in R:
			for j in range(m+1):
				C = list(itertools.combinations(range(m),j))
				for column in C:
					B = [A[i][:] for i in range(n)]
					s = 0
					for r in row:
						B[r] = ['.' for _ in range(m)]
					for c in column:
						for ro in range(n):
							B[ro][c] = '.'
					for r in B:
						for p in r:
							if p == '#':
								s += 1
					if s == k:
						cnt += 1
	return cnt


if __name__ == "__main__":
	n,m,k = map(int, input().split(' '))
	A = []
	for _ in range(n):
		A.append(list(input()))
	print(solution(A,n,m,k))


Measured memory_bytes: 9276
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int n;
string S[512];
vector<int>G[32];

int dfs(int p, int d){
  if(d>26) return 0;
  for(auto g:G[p]){
    if(!dfs(g, d+1)) return 0;
  }
  return 1;
}

int solve()
{
  rep(i, 26) G[31].push_back(i);
  rep(i, n-1){
    //    cout << i << endl;
    int p = 0;
    string s=S[i], t = S[i+1];
    while(1){
      if(s[p] == '\0') break;
      if(t[p] == '\0') return 0;
      if(s[p] != t[p]){
	if(find(begin(G[s[p]-'a']), end(G[s[p]-'a']), t[p]-'a')
	   == end(G[s[p]-'a']))
	   G[s[p]-'a'].push_back(t[p]-'a');
	break;
      }
      p++;
    }
  }
  return dfs(31, 0);
}

int main()
{
  while(1){
    cin >> n;
    if(n == 0) return 0;
    rep(i, 32) G[i].clear();

    rep(i, n) cin >> S[i];

    cout << (solve()?"yes\n":"no\n");
  }
  return 0;
}

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

int main(void){
  int Q,A,Qn[4],An[4],h,b;

  while(1){

    h = b = 0;
    cin >> Q >> A;
    if( Q == 0 && A == 0 ) break;

    Qn[0] = (Q/1000)%10;
    Qn[1] = (Q/100)%10; 
    Qn[2] = (Q/10)%10; 
    Qn[3] = Q%10;

    An[0] = (A/1000)%10;
    An[1] = (A/100)%10; 
    An[2] = (A/10)%10; 
    An[3] = A%10;

    if( Q == A ) h = 4;
    else{
      for( int i = 0 ; i < 4 ; i++ ){
	for( int j = 0 ; j < 4 ; j++ ){
	  if( Qn[i] == An[j] && i == j ) h++;
	  else if( Qn[i] == An[j] && i != j ) b++;
	}
      }
    } 
 

    cout << h <<" "<< b << endl;

  }

  return 0;
}

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

int main(){
  int n,q;
	cin >> n;
	vector<int> v(n);
	r(i,n) cin >>v.at(i);
  cin >> q;
  while(q--){
    int b, e, k, count = 0;
    cin >> b >> e >> k;
    for(int i = b; i < e; i++){
      if(v.at(i) == k) count++;
    }
    cout << count << endl;
  }
  
}


Measured memory_bytes: 3112
#include <stdio.h>
#include <iostream>
#include <map>
using namespace std;
map<int,int> a[200010];
map<int,int>::iterator it;
int main(){
	int n,m,p,i,x,y,now,ans;
	scanf("%d %d %d",&n,&m,&p);
	for(i=1;i<=p;i++){
		scanf("%d %d",&x,&y);
		a[y][x]=1;
	}
	now=1;i=1;ans=n;
	while(i<=n&&now<=m){
		i++;
		it=a[now].lower_bound(i);
		if(it!=a[now].end()) ans=min(ans,it->first-1);
		if(a[now+1][i]==0) now++;
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 26368