akhauriyash/Code-Regression huggingface dataset:
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=1e5+5;

ll f[N];

int main()
{ 

IOS;

ll n;cin>>n;

for(int i=1;i<=100;i++){
  for(int j=1;j<=100;j++){
    for(int k=1;k<=100;k++){
      ll y=(i+j)*(i+j)+(j+k)*(j+k)+(i+k)*(i+k);
      if(y%2==0){
        y/=2;
        f[y]++;
      }
    }
  }
}

for(int i=1;i<=n;i++){
cout<<f[i]<<endl;
}

return 0;
 
}



Measured memory_bytes: 4104
import sys
import math

H, W = map(int, raw_input().split())

while H > 0 or W > 0 :
    for y in xrange(H) :
        for x in xrange(W) :
            if (x + y) % 2 == 0 :
                sys.stdout.write("#")
            else :
                sys.stdout.write(".")

        print
    print

    H, W = map(int, raw_input().split())

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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll x,y;cin>>x>>y;
  if(x==1&&y==1)cout<<1000000<<endl;
  else{
    res=0;
    if(x<=3)res+=100000*(4-x);
    if(y<=3)res+=100000*(4-y);
    cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
while True:
  s=list(input())
  if s[0]=="-":
    break
    
  m=int(input())
  h=[int(input()) for i in range(m)] 
  t=[0]*len(s)
  move_cnt=sum(h)%len(s)
  
  for i in range(len(s)):
    t[i]=s[(i+move_cnt)%len(s)]
    
  print("".join(t))
  
  


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 

int A[200];

int main() {
    string S;
    cin >> S;
    int N = S.size();
    ll ans = 0;
    int x;
    int carry = 0;
    
    rep(i, N){
        x = S[N - 1 - i] - '0';
        //if (x == 5)
        //    fprintf(stderr, "%d, %d, %d\n", i, S[N - i - 1] - '0', S[N - i - 2] - '0');

        x += carry;
        if (x == 10){
          
            carry = 1;
            x = 0;
        } else if (x > 5 || (x == 5 && S[N - i - 2] - '0' >= 5)){
              //fprintf(stderr, "%d, x = %d, %d, %d\n", i, x, S[N - i - 1] - '0', S[N - i - 2] - '0');
            carry = 1;
            x = 10 - x;
        } else {
            carry = 0;
        }
        ans += x;
    }
    ans += carry;
    cout << ans;
    return 0;
}


Measured memory_bytes: 1412
def main():
    s = input()
    k = int(input())

    ans = [None for i in range(len(s))]
    for i in range(len(s)):
        if (ord('a')-ord(s[i])) % 26 <= k:
            ans[i] = "a"
            k -= (ord('a')-ord(s[i])) % 26
        else:
            ans[i] = s[i]

    if k > 0:
        ans[-1] = chr(ord('a')+(ord(ans[-1])-ord('a')+k) % 26)

    print("".join(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
long long INF=1000000000000000,ans=INF,cnt,um[201][201];
int n,m,R,r[8],a,b,c;
int main(){
	cin>>n>>m>>R;
	for(int i=0;i<R;i++)cin>>r[i];
	sort(r,r+R);
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)um[i][j]=INF;
	for(int i=1;i<=n;i++)um[i][i]=0;
	for(int i=0;i<m;i++){
		cin>>a>>b>>c;
		um[a][b]=um[b][a]=c;
	}
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)for(int k=1;k<=n;k++)um[j][k]=min(um[j][k],um[j][i]+um[i][k]);
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)for(int k=1;k<=n;k++)um[j][k]=min(um[j][k],um[j][i]+um[i][k]);
	do{
		cnt=0;
		for(int i=1;i<R;i++)cnt+=um[r[i-1]][r[i]];
		ans=min(ans,cnt);
	}while(next_permutation(r,r+R));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include<algorithm>

using namespace std;

int main() {
	int X=1;

	cin >> X;


	for (int A = -118; A < 120; A++) {
		for (int B = -119; B < 119; B++){
			if (X == pow(A, 5) - pow(B, 5)) {
				cout << A << " " << B;
				goto end;
			}
		}
	}
	end:
	return 0;
}

Measured memory_bytes: 4024
n,a=int(input()),sorted(list(map(int,input().split())))
i=n-1
ans=1;c=0
while i>0:
  if a[i-1]==a[i]:
    i-=1
    c+=1
    ans*=a[i]
    if c==2:print(ans);exit()
  i-=1
print(0)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+1;

int main(){
int n,arr[N],dp[N];    
cin>>n;
for(int i=1;i<=n;++i)
cin>>arr[i];

dp[0]=1e5;
dp[1]=0;

for(int i=2;i<=n;++i){
    dp[i]=abs(arr[i]-arr[i-1])+ dp[i-1];
    dp[i]=min(dp[i] , abs(arr[i]-arr[i-2]) + dp[i-2] );
}

cout<<dp[n];


return 0;    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds; 
using namespace std;
typedef long long ll;
int main()
{
    ll n,m,k;cin>>n>>m>>k;
  ll kk=min(m-1,k);
  cout<<(n*kk)/m;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <iostream>
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
 
#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rept(i,n) rep(i,0,n)
 
//int型を受け取ってその桁数を返す
int check_digits(int n,int m) {
	int digits = 0;
	while (n != 0) {
		n /= m;
		digits++;
	}
	return digits;
}
 
//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}
 
 
//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}
 
 
//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}
 
 
//入力された文字列が回文か判断してboolを返す
bool is_kaibun(string s) {
	string s_r(s.rbegin(), s.rend());
	return (s == s_r);
}
 
 
void yes() {cout << "Yes" << endl;}
void no() {cout << "No" << endl;}
 
 
 
 
//問題文を落ち着いて読む！
//型に注意！！
//出力例もちゃんと全部見る！！！！！
int main() {
	int k, sum = 0;
	cin >> k;
 
	int temp1, temp2;
	rep(i,1, k+1) {
		rep(j,1,k+1) {
			rep(m,1, k+1) {
				temp1 = gcd(i, j);
				temp2 = gcd(temp1, m);
				sum += temp2;
			}
		}
	}
 
	cout << sum << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    string s;
    cin>>s;
    ll n=s.size();
    bool ok=true;
    rep(i,n/2){
        if(s[i]!=s[n-1-i]) ok=false;
    }
    rep(i,n/2/2){
        if(s[i]!=s[n/2-1-i]) ok=false;
        
    }
    rep(i,n/2/2){
        if(s[n/2+1+i]!=s[n/2+n/2-i]) ok=false;
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;



}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    solve();


    return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN + 1];
int head,tail,n;

int min(int a,int b){
  if(a < b) return a;
  else return b;
}

void enqueue(P x){
  Q[tail] = x;
  if(tail == LEN) tail = 1;
  else tail++;
}

P dequeue(){
  P x;

  x = Q[head];
  if(head == LEN) head = 1;
  else head++;

  return x;
}

int main(){
  int elaps = 0,c,i,q;
  P u;

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

  for(i = 1;i <= n;i++){
    scanf("%s %d",Q[i].name,&Q[i].t);
  }

  head = 1;
  tail = n + 1;

  while(head != tail){
    u = dequeue();
    c = min(q,u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0){
      enqueue(u);
    }
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }

  return 0;
}



Measured memory_bytes: 11852
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans=0;
    for(int i=1;i<n;i++){
        string x=s.substr(0,i);
        string y=s.substr(i);
        int tmp=0;
        for(char c='a';c<='z';c++){
            bool left=false,right=false;
            for(int j=0;j<x.size();j++){
                if(c==x[j]) left=true;
            }
            for(int j=0;j<y.size();j++){
                if(c==y[j]) right=true;
            }
            if(left&&right) tmp++;
        }
        ans=max(ans,tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	string s;
	cin >> s;
	int ans = 0;
	if (s[0] == '1')ans++;
	if (s[1] == '1')ans++;
	if (s[2] == '1')ans++;
	cout << ans << endl;
	return 0;
}


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

int main(){
    int n, k;
    cin >> n;
    cin >> k;
    int ans = 1001001001;
    for(int bit = 0; bit < (1 << n); bit++){
        int coans = 1;
        for(int i = 0; i < n; i++){
            if(bit & (1 << i)){
                coans <<= 1;
            }else{
                coans += k;
            }
        }
        if(ans > coans) ans = coans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define pb push_back
const int maxn = 1000005;
int u[maxn];
int cur[maxn];
int need[maxn];
vector<pair<int,int> >e;
vector<int>g[maxn];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	while(cin >> n){
		int cont[n+5] = {};
		f(n)cin >> cont[i];
		sort(cont,cont+n);
		cout<<cont[n/2]-cont[n/2-1]<<endl;
	}
}

Measured memory_bytes: 25344
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007

int main()
{
	// ios_base::sync_with_stdio(false);
 //    cin.tie(NULL);
 //    cout.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll h[n],i,c=0;
    for(i=0;i<n;i++)
    {
    	cin>>h[i];
    	if(h[i]>=k)
    		c++;
    }
    cout<<c<<"\n";
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#define llint long long

using namespace std;

int N;
string s;
llint cnt[26], done[26];
stack<llint> stk[26];
llint a[200005];
vector<llint> vec;

llint bit[100005];

llint sum(int i){
	llint ret = 0;
	while(i > 0){
		ret += bit[i];
		i -= i&(-i);
	}
	return ret;
}

void add(int i, llint val){
	while(i <= N/2+1){
		bit[i] += val;
		i += i&(-i);
	}
}

int main(void)
{
	cin >> s;
	for(int i = 0; i < s.size(); i++) cnt[s[i] - 'a']++;
	N = s.size();
	
	bool flag = false;
	for(int i = 0; i < 26; i++){
		if(cnt[i]%2){
			if(flag){
				cout << -1 << endl;
				return 0;
			}
			flag = true;
		}
	}
	
	llint id = 1;
	for(int i = 0; i < s.size(); i++){
		int n = (int)(s[i]-'a');
		if(done[n] < cnt[n]/2){
			stk[n].push(id);
			a[i+1] = id;
			id++;
		}
		else{
			if(cnt[n]%2 && done[n] == cnt[n]/2) a[i+1] = -1;
			else{
				a[i+1] = stk[n].top();
				stk[n].pop();
			}
		}
		done[n]++;
	}
	for(int i = 1; i <= N; i++) if(a[i] == -1) a[i] = id;
	
	llint ans = 0, next = 1;
	for(int i = 1; i <= N; i++){
		if(a[i] == next){
			ans += i - next;
			next++;
		}
		else vec.push_back(a[i]);
	}
	reverse(vec.begin(), vec.end());
	
	for(int i = 0; i < vec.size(); i++){
		ans += (vec[i]-1) - sum(vec[i]);
		add(vec[i], 1);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 4480
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		TreeMap<Integer, Integer> hotels = new TreeMap<>();
		int[] arr = new int[n + 1];
		for (int i = 1; i <= n; i++) {
		    arr[i] = sc.nextInt();
		    hotels.put(arr[i], i);
		}
		hotels.put(0, 0);
		int length = sc.nextInt();
		int[][] matrix = new int[n + 1][31];
		for (int i = 0; i <= n; i++) {
		    matrix[i][0] = hotels.ceilingEntry(arr[i] - length).getValue();
		}
		for (int i = 1; i < 31; i++) {
		    for (int j = 0; j <= n; j++) {
		        matrix[j][i] = matrix[matrix[j][i - 1]][i - 1];
		    }
		}
		int q = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < q; i++) {
		    int days = 0;
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    int target = Math.min(a, b);
		    int current = Math.max(a, b);
		    for (int j = 30; j >= 0; j--) {
		        if (matrix[current][j] >= target) {
		            days += (1 << j);
		            current = matrix[current][j];
		        }
		        if (current == target) {
		            break;
		        }
		    }
		    if (current > target) {
		        days++;
		    }
		    sb.append(days).append("\n");
		}
		System.out.print(sb);
    }
}



Measured memory_bytes: 121788
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
const ll inf=(1e18);
const ll mod=1000000007;
double dp[4000][4000];
int main(){
int n;
cin>>n;
vector<double> 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<n;j++){
    if(dp[j][i]==0.0)continue;//０に収束してしまう場合がある(?)
   dp[j+1][i+1]+=(dp[j][i]*a[i]);
   dp[j][i+1]+=dp[j][i]*(1.0-a[i]);
}
}
int win=n/2+1;
double ans=0;
for(int i=n;i>=win;i--)ans+=dp[i][n];
printf("%.12f\n",ans);
}




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

using namespace std;

int main()
{
 int n, i;
 cin >> n;
 long double num, ans = 0.0;
 for(i = 0; i < n; i++)
 {
    cin >> num;
    ans += (1.0 / num);
 }
 ans = 1.0 / ans;
// cout << ans << endl;
printf("%.14llf\n", ans);
 return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
 
const int inf = int(1e9);
const int mod = 1e9 + 7;
const int N = 1e6 + 555;
const long double PI = acos(-1.0);

void solve()
{
	int n, k;
	cin >> n >> k;
	if(k == 1) cout << 0;
	else
	{
		n -= k;
		cout << abs(n + 1 - 1);
	}
}	


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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <math.h>
#include <time.h>
using namespace std;
int main() {
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define re register ll
#define F(x,y,z) for(re x=y;x<=z;x++)
#define FOR(x,y,z) for(re x=y;x>=z;x--)
typedef long long ll;
#define I inline void
#define IN inline ll
template<class D>I read(D &res){
	res=0;register D g=1;register char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')g=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
		res=(res<<3)+(res<<1)+(ch^48);
		ch=getchar();
	}
	res*=g;
}
IN max(ll x,ll y){return x>y?x:y;}
struct P{
	ll a,b,c,id;
	friend bool operator < (P x,P y){
		return x.c<y.c;
	}
}p[101000];
struct E{
	ll to,nt;
}e[202000];
#define T e[k].to
vector<ll>v[101000];
ll n,m,fa[101000],s[101000],f[101000],head[101000],X,Y,tot,vis[110000],pos[101000];
I D_1(int x,int fat){
	s[x]=p[x].b;
	for(auto k:v[x]){
		if(k==fat)continue;
		D_1(k,x);
		s[x]+=s[k];
	}
	f[x]=s[x]+p[x].c;
	for(auto k:v[x]){
		if(k==fat)continue;
		f[x]=min(f[x],s[x]-s[k]+max(f[k],p[x].c));
	}
}
IN find(ll x){
	return fa[x]==x?x:fa[x]=find(fa[x]);
}
int main(){
	read(n);read(m);
	F(i,1,n)read(p[i].a),read(p[i].b),p[i].c=max(p[i].a-p[i].b,0),p[i].id=i;
	sort(p+1,p+1+n);
	F(i,1,n)pos[p[i].id]=i;
	tot=-1;memset(head,-1,sizeof(head));
	F(i,1,m){
		read(X);read(Y);X=pos[X];Y=pos[Y];
		e[++tot].to=Y;
		e[tot].nt=head[X];
		head[X]=tot;
		e[++tot].to=X;
		e[tot].nt=head[Y];
		head[Y]=tot;
	}
	F(i,1,n)fa[i]=i;
	F(i,1,n){
		vis[i]=1;
		for(re k=head[i];k!=-1;k=e[k].nt){
			if(!vis[T])continue;
			re fat=find(T);
			if(fat!=i)fa[fat]=i,v[fat].emplace_back(i),v[i].emplace_back(fat);
		}
	}
	//system("pause");
	D_1(n,0);
	printf("%lld",f[n]);
	return 0;
}




Measured memory_bytes: 21248
def answer(n: int, l: []) -> str:
    return 'Yes' if l.pop(l.index(max(l))) < sum(l) else 'No'


def main():
    n = int(input())
    l = list(map(int, input().split()))
    print(answer(n, l))


if __name__ == '__main__':
    main()

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

int main() 
{
    
    int X;
    cin >> X;
    
    vector<bool>expo(X+1);
    expo[1] = 1;
    for (int i = 2; i <= X; i++) {
        int A = i * i;
        while (A <= X) {
            expo[A] = 1;
            A *= i;
        }
    }
    for (int i = X; i >= 1; i--) {
        if (expo[i]) {
            cout << i << endl;
            return 0;
        }
    }
}

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

using namespace std;

using u32 = uint32_t;
using u64 = uint64_t;
using i64 = int64_t;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= a; i--)
#define RF0(i,b) RFO(i,0,b)
#define F first
#define S second
#define ADD(a,b) (((u64)a + b)%MOD)
#define MUL(a,b) (((u64)a * b)%MOD)

constexpr int MOD = 998244353;

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

  int K;
  cin >> K;

  array<int, 32> arr{ 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

  cout << arr[K - 1];
}


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

ans = 0
i = 0
while i < N:
    if i+1 == P[i]:
        ans += 1
        if i < N-1 and i+2 == P[i+1]:
            i += 1
    i += 1
print(ans)

Measured memory_bytes: 13880
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int count = 0;
		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int[] S = new int[n];
		for (int i = 0; i < n; i++) {
			S[i] = scanner.nextInt();
		}

		int q = scanner.nextInt();
		int[] T = new int[q];
		for (int i = 0; i < q; i++) {
			T[i] = scanner.nextInt();
		}

		for (int i = 0; i < q; i++) {
			int index = T[i];
			int min = 0;
			int max = n - 1;
			int avg;
			while (true) {
				avg = (min + max) / 2;
				if (S[avg] == index) {
					count++;
					break;
				} else if (min > max) {
					break;
				} else {
					if (S[avg] < index) {
						min = avg + 1;
					} else {
						max = avg - 1;
					}
				}
			}
		}
		System.out.println(count);
		scanner.close();
	}
}
	

Measured memory_bytes: 80208
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
    cin>>a>>b;
    if(a<=0 && b>=0)
    {
        cout<<"Zero"<<endl;
        return 0;
    }
    if(a<0 && b<0)
    {
		int tims = abs(a)-abs(b)+1;
		if(tims%2==1)
			cout<<"Negative"<<endl;
		else
			cout<<"Positive"<<endl;
		}
		else
			cout<<"Positive"<<endl;
    return 0;
}


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

int main(){
  long double L; cin>>L;
  cout<<setprecision(15);
  cout<<(L/3)*(L/3)*(L/3)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=200005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

int N,A[MAXN],F[MAXN];
int C(int X){
	return X*(X-1)/2;
}
main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	FOR(i,1,N){
		cin>>A[i];
		F[A[i]]++;
	}
	int ans=0;
	FOR(i,1,N) ans+=C(F[i]);
	FOR(i,1,N){
		int t=ans;
		int cnt=F[A[i]]-1;
		cout<<t-cnt<<"\n";
	}
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
const int MAXN=100010,P=1000000007;
int n,a,s[MAXN],ans;
int main () {
	scanf("%d",&n);
	ans=1;
	for (int i=1;i<=n;i++) {
		scanf("%d",&a);
		if (a==0) {
			ans=(1ll*ans*(3-s[0]))%P;
		} else {
			if (s[a]>=s[a-1]) {printf("0\n");return 0;}
			ans=(1ll*ans*(s[a-1]-s[a]))%P;
		}
		s[a]++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;



int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int right_e = 0;
    int left_w = 0;
    reps(i,1,n){
        if(s[i]=='E'){
            right_e++;
        }
    }
    int ans = 1000000;
    rep(i,n-1){
        ans = min(ans,right_e+left_w);
        if(s[i]=='W'){
            left_w++;
        }
        if(s[i+1]=='E'){
            right_e--;
        }
    }
    ans = min(ans,right_e+left_w);
    cout << ans;
}

Measured memory_bytes: 900
N=int(input())
XY=[[list(map(int,input().split())) for i in range(int(input()))] for j in range(N)]

ans=0
for i in range(2**N):
  table =list( format(i,"b").zfill(N)[::-1] )
  f=1
  for j,l in enumerate(XY):
    if table[j]=="1":
      for xy in l:
        x=xy[0]-1
        y=xy[1]
        if table[x]!=str(y):
          f=0
          break
    if f==0:
      break
  if f:
    ans=max(ans,table.count("1"))
print(ans)

Measured memory_bytes: 46940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

ll mod=1e9+7;

ll modpow(ll a, ll p) {
  ll ret=1;
  while(p>0) {
    if(p&1) ret=(ret*a)%mod;
    a=(a*a)%mod;
    p>>=1;
  }
  return ret;
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b) {
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  u%=mod; if(u<0) u+=mod;
  return u;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,a,b;cin>>n>>a>>b;
  ll tot=modpow(2,n)-1;if(tot<0) tot+=mod;
  ll aval=1,bval=1,adiv=1,bdiv=1;
  for(ll i=n;i>n-a;--i) aval=(aval*i)%mod;
  for(ll i=1;i<=a;++i) adiv=(adiv*i)%mod;
  for(ll i=n;i>n-b;--i) bval=(bval*i)%mod;
  for(ll i=1;i<=b;++i) bdiv=(bdiv*i)%mod;
  ll anum=(aval*modinv(adiv))%mod;
  ll bnum=(bval*modinv(bdiv))%mod;
  ll ans=tot-anum-bnum;
  while(ans<0) ans+=mod;
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 500000
#define SENTINEL 2000000000

int L[250002], R[250002],count = 0, A[MAX],n;

void merge(int, int, int);
void mergeSort(int, int);

int main(){
  int i;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }
  mergeSort(0, n);
  for(i = 0; i < n - 1 ; i++){
    printf("%d ",A[i]);
  }
  printf("%d", A[n - 1]);
  printf("\n");
  printf("%d\n",count);
  return 0;
}


void mergeSort(int left, int right){
  int mid;
  
  if(left+1 < right){
    mid =(left + right) / 2;
    mergeSort(left, mid);
    mergeSort(mid, right);
    merge(left, mid, right);
  }
}
void merge(int left, int mid, int right){
  int n1,n2,i,j,k;

  n1 = mid - left;
  n2 = right - mid;

  for(i = 0; i < n1; i++){
    L[i] = A[left+i];
  }

  for(i = 0; i < n2; i++){
    R[i] = A[mid+i];
  }
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;

  i = 0;
  j = 0;

for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
      count++;
    }
    else{
      A[k] = R[j];
      j++;
      count++;
    }
  }
}


Measured memory_bytes: 5760
def main():
    A, B, N = map(int, input().split())

    x = min(B - 1, N)

    ans = (A * x // B) - A * (x // B)
    print(ans)


if __name__ == '__main__':
    main()

# editorial
# f(x)=(A * x // B) - A * (x // B)
# f(x+B)==f(x)
# 周期性があるので
# 0<=x<Bの場合を考えればよい
# (A * x // B)は広義単調増加
# A * (x // B) == 0
# 定義域で最大のx=min(B-1,N)のとき最大になる


Measured memory_bytes: 9100
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <set>

using namespace std;

template<typename T>inline T get(){T x;cin>>x;return x;}

int main()
{
    int n = get<int>();
    vector<pair<int,int>> task(n);
    for (int i = 0; i < n; i++) {
        task[i].first = get<int>();
        task[i].second = get<int>();
    }

    sort(task.begin(), task.end(),
         [](auto& a, auto& b) { return a.second < b.second; });

    int t = 0;
    for (int i = 0; i < n; i++) {
        t += task[i].first;
        if (t > task[i].second)
            goto No;
    }
    cout << "Yes" << endl;
    return 0;
No:
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

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;}

template<typename Monoid>
struct SegmentTree {
    using F = function<Monoid(Monoid, Monoid)>;
    vector<Monoid> data;
    int n;
    const F f;
    const Monoid M;
    SegmentTree(int x, const F f, const Monoid &M) : f(f), M(M) {
        n = 1;
        while(n<x) n <<= 1;
        data.resize(2*n,M);
    }
    void set(int k, const Monoid &p) {
        data[k+n] = p;
    }
    void build() {
        for(int k = n-1; k > 0; --k) {
            data[k] = f(data[2*k + 0], data[2*k + 1]);
        }
    }
    void update(int k, const Monoid &p) {
        k += n;
        data[k] = p;
        while (k >>= 1) {
            data[k] = f(data[k*2], data[k*2 + 1]);
        }
    }
    Monoid query(int a, int b) {
        Monoid L = M, R = M;
        for(a += n, b += n; a<b; a >>= 1, b >>= 1) {
            if(a&1) L = f(L, data[a++]);
            if(b&1) R = f(data[--b], R);
        }
        return f(L,R);
    }
    Monoid operator[](const int &k) const {
        return data[k+n];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    vector<int> p(n);
    SegmentTree<int> segmin(n, [](int a,int b){return min(a,b);}, INT_MAX);
    SegmentTree<int> segmax(n, [](int a,int b){return max(a,b);}, INT_MIN);
    REP(i,n) {
        cin >> p[i];
        segmin.update(i,p[i]);
        segmax.update(i,p[i]);
    }
    vector<int> cnt(n);
    REP(i,n-1) {
        cnt[i+1] = cnt[i] + (p[i]>p[i+1]);
    }
    int ans = 1;
    bool flag = (cnt[k-1]-cnt[0]>0);
    REP(i,n-k) {
        int x = segmin.query(i,i+k+1);
        int y = segmax.query(i,i+k+1);
        if((flag || cnt[i+k]-cnt[i+1]>0) && (p[i]!=x || p[i+k]!=y)) {
            if(cnt[i+k]-cnt[i+1]==0) flag = false;
            ++ ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5888
#include<stdio.h>
int main() {
  double a, b, c, d, e, f;
  while (scanf("%lg %lg %lg %lg %lg %lg", &a, &b, &c, &d, &e, &f) != EOF) {
    printf("%.3f %.3f\n", 0.0005 <= (c * e - b * f) / (a * e - b * d) || (c * e - b * f) / (a * e - b * d) <= -0.0005 ? (c * e - b * f) / (a * e - b * d) : 0, 0.0005 <= (c * d - a * f) / (b * d - a * e) || (c * d - a * f) / (b * d - a * e) <= -0.0005 ? (c * d - a * f) / (b * d - a * e) : 0);
  }
  return 0;
}

Measured memory_bytes: 652
# coding: utf-8

# 識別する関数
def func(num):
    num = int(num)
    if 400 <= num and num <= 599:
        return 8
    elif 600 <= num and num <= 799:
        return 7
    elif 800 <= num and num <= 999:
        return 6
    elif 1000 <= num and num <= 1199:
        return 5
    elif 1200 <= num and num <= 1399:
        return 4
    elif 1400 <= num and num <= 1599:
        return 3
    elif 1600 <= num and num <= 1799:
        return 2
    else:
        return 1


if __name__ == "__main__":
    num = input()
    print(func(num))


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

int main() {
    string S,T;
    cin>>S>>T;
    if(T.substr(0, T.size()-1) == S){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int main() {
    int64_t n, a, b;
    cin >> n >> a >> b;
    vector<int64_t> x(n);
    for (auto& e : x) cin >> e;

    int64_t ans = 0;
    for (int i = 0; i+1 < n; i++) ans += min((x[i+1]-x[i])*a, b);
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cmath>

using namespace std;

int main() {
    int MAX = 2147483647;
    int n = 0;
    cin >> n;
    int k = 0;
    cin >> k;
    int dp[n] = {};
    dp[0] = 0;
    int h[n] = {};
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }
    dp[1] = abs(h[0]-h[1]);
    for(int i = 2; i < n; i++) {
        int tempMin = MAX - 1;
        for(int j = 1; j <= min(k, i); j++) {
            int t = (dp[i-j] + abs(h[i]-h[i-j]));
            tempMin = min(tempMin, t);
        }
        dp[i] = tempMin;
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main() {

	string s;
	cin >> s;
	unordered_map<char, ll> a;
	for (char c : s) {
		++a[c];
	}
	ll ans = (ll)s.length() * ((ll)s.length() - 1) / 2;
	for (auto aa : a) {
		ans -= aa.second * (aa.second - 1) / 2;
	}
	printf("%lld\n", ans + 1);
	Please AC;
}


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

using namespace std;

string a;

int main() {
   cin>>a;
   if(a=="SAT")
       cout<<"1";
   if(a=="SUN")
       cout<<"7";
   if(a=="MON")
       cout<<"6";
       if(a=="TUE")
           cout<<"5";
       if(a=="WED")
           cout<<"4";
       if(a=="THU")
           cout<<"3";
       if(a=="FRI")
           cout<<"2";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	int k,x;
	cin >> k >> x;
	for (int i = x - k + 1; i <= x + k - 1 - 1; ++i) {
		cout << i << ' ';
	}
	cout << x + k - 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int in(){int x; scanf("%d",&x); return x;}
static const int MAX = 10;


int main(){
  int N = in(), L[MAX], count = 0;
  rep(i, N) L[i] = in();
  sort(L, L+N);

  rep(i, N-1) count += L[i]; 
  cout << (L[N-1] < count ? "Yes" : "No") << endl;
}

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

#define _ << ": " <<
#define watch1(var1) cerr << (#var1) _ var1 << '\n'
#define watch2(var1, var2) cerr << (#var1) _ var1 << ", " << (#var2) _ var2 << '\n'
#define watch3(var1, var2, var3) cerr << (#var1) _ var1 << ", " << (#var2) _ var2 << ", " << (#var3) _ var3 << '\n'
#define wloop(size, arr) cerr << (#arr) << ": "; for (int i = 0; i < int(size); i++) cerr << arr[i] << " \n"[i+1 == int(size)]

template<typename... Args>
void read(Args&... args) { ((cin >> args), ...); }

template<typename... Args>
void show(Args... args) { ((cout << args << " "), ...); }

#define ll long long
#define ints(a...) int a; read(a)
#define IN(a) for (auto &it : a) cin >> it

ll dp[101][100001];

void solve() {
    ints(n, cap);
    vector<array<int, 2>> v(n + 1);
    for (int i = 1; i <= n; i++) read(v[i][0], v[i][1]);
    
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= cap; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j >= v[i][0]) { 
                dp[i][j] = max(dp[i][j], v[i][1] + dp[i - 1][j - v[i][0]]);
            }
        }
    }

    show(dp[n][cap]);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1; 
    // cin >> T;
    while (T--) solve();
    return 0;
}

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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	int N, M, A[1000], B[1000]; cin >> N >> M;
	map<int, int> mpa, mpb;
	REP(i, N){
		cin >> A[i];
		if(mpa.count(A[i])){
			cout << 0 << ln; return 0;
		}
		mpa[A[i]] = i;
	}
	REP(i, M){
		cin >> B[i];
		if(mpb.count(B[i])){
			cout << 0 << ln; return 0;
		}
		mpb[B[i]] = i;
	}

	lnt ans = 1;
	int cnta = 0, cntb = 0;
	for(int num = N*M; num > 0; num--){
		bool exista = mpa.count(num), existb = mpb.count(num);
		if(exista and existb){
			cnta++; cntb++;
		} else if(exista){
			ans *= cntb; ans %= MOD;
			cnta++;
		} else if(existb){
			ans *= cnta; ans %= MOD;
			cntb++;
		} else {
			ans *= (cnta*cntb - (N*M - num)); ans %= MOD;
		}
		if(ans == 0){
			cout << 0 << ln; return 0;
		}
	}
	cout << ans << ln;
}


Measured memory_bytes: 384
import java.util.*;

class Main{
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		Long iix = sc.nextLong();
		Long iit = sc.nextLong();
		if(iix<=iit){
			System.out.println(0);
		}
		else{
			System.out.println(iix-iit);
		}
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define Cin cin>>a;

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main(void){
double n, k;
	cin >> n >> k;
	double ans=0.00000000000;
	for(double i=1.0000000000; i<=n; i++) {
		double tmp = i;
		double count = 0.00000000000;
		while (tmp < k) {
			tmp *= 2.0000000000000;
			count++;
		}
		//cout << count << endl;
		ans += pow(2.00000000000, -count);
		//cout << ans << endl;
	}
	ans /= n;
	cout <<setprecision(15)<< ans << endl;
}


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

int main(){
    int n;
    cin >> n;
    string s[n];
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    sort(s,s+n);
    int m;
    cin >> m;
    string t[m];
    for(int i = 0; i < m; i++){
        cin >> t[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        int x = 0;
        string p = s[i];
        for(int j = 0; j < n; j++){
            if(p == s[j]){
                x++;
            }
        }
        for(int j = 0; j < m; j++){
            if(p == t[j]){
                x--;
            }
        }
        ans = max(ans,x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;
int main() {
	int e;
	while(cin >> e && e > 0){
		int min_sum = 100000;
		for(int i = 0; i*i*i <= e; i++)
		{
			int j = sqrt(e - i*i*i);
			int k = e - i*i*i - j*j;
			int temp = i + j + k;
			min_sum = min(temp, min_sum);
		}
		cout << min_sum << endl; 
	}	
}


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

int main() {
   int N, M;
   cin >> N >> M;
   map<int, int> mp;
   for (int i = 0; i < M; i++) {
      int a, b;
      cin >> a >> b;
      if (a > b) swap(a, b);
      if (a == 1) mp[b]++;
      if (b == N) mp[a]++;
   }

   for (auto x : mp) {
      if (x.second >= 2) {
         puts("POSSIBLE");
         return 0;
      }
   }

   puts("IMPOSSIBLE");

   return 0;
}

Measured memory_bytes: 9600
#include<stdio.h>
int main()
{
  int a,b,c,i,r=0;
  scanf("%d%d%d",&a,&b,&c);
  if(a>b)
    {
      i=b;
      b=a;
      a=i;
    }
  for(i=a; i<=b; i++)
    {
      if(c%i==0) r+=1;
    }
  printf("%d\n",r);
  return 0;
}

		   

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	int k;
	while(cin >> k)
	{
		long long sum = 0;
		for(int a=1; a<=k; a++)
		{
			for(int b=1; b<=k; b++)
			{
				for(int c=1; c<=k; c++)
				{
					sum += __gcd(a,__gcd(b,c));
				}
			}
		}
		cout << sum << '\n';
	}
}


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

typedef pair<int, int> ii;

vector<int> c[1000005];
vector<ii> EdgeList[1000005];

int cnt = 1;
vector<int> AdjList[1000005];
vector<int> AdjList2[100005];

vector<int> correct[1000005];

bool visited[100005];
bool visitedC[1000005];

int dist[1000005];

void settle(int company){
    for(ii uv: EdgeList[company]){
        AdjList2[uv.first].push_back(uv.second);
        AdjList2[uv.second].push_back(uv.first);
    }

    for(int i: c[company]){
        visited[i] = false;
    }

    for(int i: c[company]){
        if(!visited[i]){
            correct[i].push_back(cnt);
            AdjList[cnt].push_back(i);
            queue<int> q;
            visited[i] = true;
            q.push(i);
            while(!q.empty()){
                int u = q.front(); q.pop();
                for(int v: AdjList2[u]){
                    if(!visited[v]){
                        visited[v] = true;
                        correct[v].push_back(cnt);
                        AdjList[cnt].push_back(v);
                        q.push(v);
                    }
                }
            }
            cnt++;
        }
    }

    for(int i: c[company]){
        AdjList2[i].clear();
        visited[i] = false;
    }
}

int main(){
    int N, M;
    scanf("%d%d", &N, &M);

    for(int i = 0; i < M; i ++){
        int p, q, r;
        scanf("%d%d%d", &p, &q, &r);
        EdgeList[r].push_back(ii(p, q));
        c[r].push_back(p);
        c[r].push_back(q);
    }

    for(int i = 1; i <= 1000000; i ++){
        settle(i);
    }

    /*for(int i = 1; i <= N; i ++){
        for(int j = 0; j < (int)correct[i].size(); j ++){
            for(int k = j+1; k < (int)correct[i].size(); k ++){
                AdjList[correct[i][j]].push_back(correct[i][k]);
                AdjList[correct[i][k]].push_back(correct[i][j]);
            }
        }
    }*/

    memset(dist, -1, sizeof(dist));
    queue<int> q;
    dist[1] = 0;
    q.push(1);

    while(!q.empty()){
        int u = q.front(); q.pop();
        for(int k: correct[u]){
            if(visitedC[k]){continue;}
            visitedC[k] = true;
            for(int v: AdjList[k]){
                if(dist[v] == -1){
                    dist[v] = dist[u]+1;
                    q.push(v);
                }
            }
        }
    }

    printf("%d", dist[N]);
    return 0;
}

Measured memory_bytes: 126328