akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (double i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
typedef pair<double,double> P;
const int INF=1001001001;


int main(){
  ll n;
  cin>>n;
  if (n%2==1){
    cout<<0;
    return 0;
  }
  ll now=10;
  ll ans=0;
  while(now<=n){
    ll temp=n/now;
    ans+=temp;
    now*=5;
  }
  cout<<ans;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

#include <cmath>
#include <queue>
#include <stack>

using namespace std;

vector<char> alphaBet;

void makeAlphaBet() {
	alphaBet.clear();
	for (int i = 0; i < 26; ++i) {
		alphaBet.push_back('a' + i);
	}
	for (int i = 0; i < 26; ++i) {
		alphaBet.push_back('A' + i);
	}
	for (int i = 0; i < 10; ++i) {
		alphaBet.push_back('0' + i);
	}
	// for (int i = 0; i < 5; ++i) {
	// 	alphaBet.push_back('0' + i);
	// }
}

vector<string> f;
const int L = 128;
int totalL = 0;
int queryN = 0;
int maxQueryN = 850;

int makeQuery(string s) {
	cout << "? " << s << endl;
	int ans;
	cin >> ans;
	queryN += 1; 
	// if (queryN >= maxQueryN) {
	// 	for (;;);
	// }
	return ans;
}

void makeDecision(string s) {
	cout << "! " << s << endl;
}

void initF() {
	makeAlphaBet();
	int n = alphaBet.size();
	f = vector<string>(n);
	for (int i = 0; i < n; ++i) {
		f[i] = "";
	}
	totalL = 0;
	for (int i = 0; i < n; ++i) {
		string query = "";
		for (int j = 0; j < L; ++j) {
			query.push_back(alphaBet[i]);
		}
		int ans = makeQuery(query);
		f[i] = "";
		if (ans < L) {
			for (int j = 0; j < L - ans; ++j) {
				f[i].push_back(alphaBet[i]);
			}
		}
		totalL += (L - ans);
	}
}

string combine(string a, string b) {
	// cout << "combine " << a << " " << b << endl;
	if (a.length() == 0) {
		return b;
	}
	if (b.length() == 0) {
		return a;
	}
	int curA = 0, curB = 0;
	string res = "", tmp;
	int aL = a.length(), bL = b.length();
	while (curA < aL || curB < bL) {
		if (curA >= aL) {
			res.push_back(b[curB++]);
			continue;
		}
		if (curB >= bL) {
			res.push_back(a[curA++]);
			continue;
		}
		tmp = res + a[curA]; // + b.substr(curB);
		// tmp.push_back(a[curA]);
		// res.push_back(b[curB]);
		// tmp += b.substr(curB);
		// if (bL != b.length()) {
		// 	cout << "Error!" << endl;
		// }
		for (int i = curB; i < b.length(); ++i) {
			tmp.push_back(b[i]);
		}
		int ans = makeQuery(tmp);
		if (ans + (int)(tmp.size()) == totalL) {
			res.push_back(a[curA++]);
			continue;
		} else {
			res.push_back(b[curB++]);
			continue;
		}
	}
	return res;
}

string getF(int l, int r) {
	if (l == r) {
		return f[l];
	}
	int mid = (l + r) / 2;
	string left = getF(l, mid);
	string right = getF(mid + 1, r);
	return combine(left, right);
}

bool cmp(const string &a, const string &b) {
	return a.length() > b.length();
}

string combineF() {
	while (f.size() > 1) {
		sort(f.begin(), f.end(), cmp);
		if (f.back().empty()) {
			f.pop_back();
			continue;
		}
		int size = f.size();
		string a1 = f[size - 1];
		string a2 = f[size - 2];
		string a = combine(a1, a2);
		f.pop_back(); f.pop_back();
		f.push_back(a);
	}
	return f[0];
}

int main() {
	initF();
	// makeDecision(getF(0, alphaBet.size() - 1));
	// string res = combineF();
	string res = getF(0, alphaBet.size() - 1);
	cout << "! " << res << "\n";
	// cout << "! " << combineF() << endl;
	// return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <stack>
#include <list>

using namespace std;

int main(){

    list<int> S;
    stack<int> T;

    int n;
    cin >> n;
    int num;
    int cnt = 0;
    for(int i=0; i<n; i++){
        cin >> num;
        S.push_front(num);
    }

    int q;
    cin >> q;
    for(int i=0; i<q; i++){
        cin >> num;
        T.push(num);
    }

    int length = T.size();

    for(int i=0; i<length; i++){
        num = T.top(); T.pop();
        for(auto itr = S.begin(); itr != S.end(); itr++){
            if(*itr == num){
                S.erase(itr);
                cnt++;
                break;
            }
        }      
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3388
#include <stdio.h>

int main(){
   char op;
   int a, b, r;
   while(scanf("%d %c %d",&a,&op,&b)==3){
      if(op=='?') break;
      switch(op){
      case '+' :
         r=a+b; break;
      case '-' :
         r=a-b; break;
      case '*' :
         r=a*b; break;
      case '/' :
         r=a/b; break;
      }
      printf("%d\n",r);
   }
   return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define ggr getchar();getchar();return 0;
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
string a[114514];
signed main() {
	int n, cnta = 0, cntb = 0, cntc = 0, cntd = 0, cnte = 0, cntf = 0;
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n) {
		if (a[i][0] == 'M')cnta++;
		else if (a[i][0] == 'A')cntb++;
		else if (a[i][0] == 'R')cntc++;
		else if (a[i][0] == 'C')cntd++;
		else if (a[i][0] == 'H')cnte++;
	}
	cout << cnta * cntb*cntc + cnta * cntb*cntd + cnta * cntb*cnte + cnta * cntc*cntd + cnta * cntc*cnte + cnta * cntd*cnte + cntb * cntc*cntd + cntb * cntc*cnte + cntb * cntd*cnte + cntc * cntd*cnte << endl;
	ggr
}

Measured memory_bytes: 6272
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}



int main(){
	int n,x,y;
	cin >> n >> x >> y;
	x--;
	y--;
	vector<vector<int>> dist(n, vector<int>(n, 0));
	rep(i,n){
		rep(j,n){
			dist[i][j] = min({abs(i - j), abs(i - x) + 1 + abs(y - j), abs(j - x) + 1 + abs(y - i)});
		}
	}
	vector<int> ans(n,0);
	rep(i,n-1){
		rep2(j,i+1,n){
			ans[dist[i][j]]++;
		}
	}
	rep(i, n - 1) cout << ans[i + 1] << endl;

	return 0;
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>result(4,0);
  for(int i=0;i<N;i++){
    string s;
    cin>>s;
   if(s=="AC"){
     result.at(0)+=1;
   }else if(s=="WA"){
     result.at(1)+=1;
  }else if(s=="TLE"){
     result.at(2)+=1;
  }else if(s=="RE"){
     result.at(3)+=1;
   }
  }
  cout<<"AC x "<<result.at(0)<<endl;
  cout<<"WA x "<<result.at(1)<<endl;
  cout<<"TLE x "<<result.at(2)<<endl;
  cout<<"RE x "<<result.at(3)<<endl;
  
}

Measured memory_bytes: 3604
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];
        HashMap<Integer, Long> hashMap = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            a[i] = num;
            if(hashMap.containsKey(num)){
                hashMap.put(num, hashMap.get(num) + 1);
            } else {
                hashMap.put(num, 1L);
            }
        }

        long total = 0;
        for(Map.Entry<Integer, Long> entry : hashMap.entrySet()){
            total += (entry.getValue()*(entry.getValue()-1))/2;
        }

       // System.out.println(hashMap);
       // System.out.println(total);

        for (int num: a){
            System.out.println(total - (hashMap.get(num)) + 1);
        }

    }
}


/*

5
1 1 2 1 2

counter =>  key      value
             1   ->    3
             2   ->    2

long total = 0

total += 3;
total = 3
total += 1;
total = 4;

1st ball is 1
remaining balls 1 2 1 2
print => total - (hashMap.get(1)) + 1
            4 - 3 + 1 = 2
            
3rd ball is 2 
remaining balls 1 1 1 2
            total - hashMap.get(2) + 1
            4 - 2 + 1 = 3
            
          
 */

Measured memory_bytes: 110296
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  string str;
  cin>>str;
  int n;
  n = (int)(str.length());
  int kaisu1,kaisu2;
  kaisu1 = kaisu2 = 0;
  for(int i = 0; i < n; i++) {
    if (i%2 == 0 && str[i] != '0') kaisu1++;
    if (i%2 != 0 && str[i] != '1') kaisu1++;
  }
  for(int i = 0; i < n; i++) {
    if (i%2 == 0 && str[i] != '1') kaisu2++;
    if (i%2 != 0 && str[i] != '0') kaisu2++;
  }
  if (kaisu1 < kaisu2) cout<<kaisu1<<endl;
  else cout<<kaisu2<<endl;
  return 0;
}

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

//.define
// #define FILE_IN_OUT
#define RET(_x)                       return cout << (_x) << '\n', 0;
#define all(_obj)                     std::begin(_obj), std::end(_obj)
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define ceilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define has(_obj, _val)               ((_obj).find(_val) != (_obj).end())
#define sz(_obj)                      static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)                     std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)                     {}
#endif
#define endl "\n"
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
vector<int> gr[100000];
bool used[100000];
vector<int> topSort;
int dp[100000];

void Dfs(int from) {
    used[from] = true;
    for (int to : gr[from]) {
        if (!used[to]) {
            Dfs(to);
        }
    }
    topSort.push_back(from);
}

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n, m;
    cin >> n >> m;
    loop(m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        gr[a].push_back(b);
    }
    loop(n) {
        Dfs(i);
    }
    int ans = 0;
    for (int v : topSort) {
        for (int to : gr[v]) {
            dp[v] = max(dp[to] + 1, dp[v]);
            ans = max(dp[v], ans);
        }
    }
    cout << ans << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}


Measured memory_bytes: 9204
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        k: usize,
        s: String,
    };
    if s.len() <= k {
        println!("{}", s);
        return;
    }
    println!("{}...", &s[..k]);
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y,z,temp1,temp2;
    cin>>x>>y>>z;
    temp1=x;
    x=y;
    y=temp1;
    temp2=x;
    x=z;
    z=temp2;
    cout<<x<<" "<<y<<" "<<z<<endl;
    return 0;
}



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

int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A,A+N);
    cout << A[N-1] - A[0] << endl;
}


Measured memory_bytes: 256
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#define rp(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)

typedef long long ll;


using namespace std;


int main(){
    int a,b;
    cin>>a>>b;;
    
    cout<<a*b<<" "<<2*a+2*b<<endl;


    return 0;
};

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

using namespace std;

int main() {
    int h, w;
    while (true) {
        cin >> h >> w;
        if (h == 0 && w == 0) return 0;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3104
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *a,const void *b){
	return *(int *)b-*(int *)a;
}
int main(void){
	int t,i,a=0,b=0;
	for(i=0;i<4;i++){
		scanf("%d",&t);
		a+=t;
	}
	for(i=0;i<4;i++){
		scanf("%d",&t);
		b+=t;
	}
	printf("%d\n",a>b?a:b);
    return 0;
}
	

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

int main(){
    int A[4];
    cin >> A[1] >> A[2] >> A[3];
    int tmp,ans;
    for(int i=1; i<=2; i++){
        for(int j=i+1; j<=3; j++){
            if(A[i]<A[j]){
                tmp=A[i];
                A[i]=A[j];
                A[j]=tmp;

            }
        }
    }
    ans=A[1]-A[3];
    
cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
	int n;
	cin >> n;
	vector<lli> num(256, 0);
	for(int i=0; i<n; i++){
		string s;
		cin >> s;
		num[s[0]]++;
	}
	lli ans = 0;
	vector<int> per{'M','A','R','C','H'};
	sort(per.begin(), per.end());
	do{
		ans += num[per[0]] *num[per[1]] *num[per[2]];
	}while(next_permutation(per.begin(), per.end()));
	cout << ans/(2*3*2) << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
bin_n = bin(n)
ranges = []

def base_minus2(m, i, s):
    tmp = s
    if i == 1:
        return tmp + str(m%2)
    for j in range(i-1, -1, -1):

        if m >= ranges[j-1][0] and m <= ranges[j-1][1]:
            tmp += "1"
            return base_minus2(m-(-2)**j, j, tmp)
        else:
            if j == 0:
                return tmp + str(m%2)
            else:
                tmp += "0"


if n == 0:
    print("0")
elif n == 1:
    print("1")
else:
    for i in range(1, 60):
        min_r = sum([(-2)**j for j in range(1, i, 2)]) + (-2)**i
        max_r = sum([(-2)**j for j in range(0, i, 2)]) + (-2)**i
        ranges.append([min_r, max_r])

    result = base_minus2(n, 60, "")
    print(result.lstrip("0"))


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring> 
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i<=b;i--)
using namespace std;
const int mo=1e9+7;
int read()
{
	char ch;
	while (ch=getchar(),ch!='#' && ch!='.');
	return ch=='#';
}
const int N=600;
int a[N][N],ok[N];
int main()
{
	int n;
	scanf("%d",&n);
	fo(i,1,n)
	{
		fo(j,1,n) a[i][j]=read(),a[i][0]+=a[i][j];
	}
	int x=0,y=0,mx=0;
	fo(i,1,n)
	{
		int num=0;
		fo(j,1,n) num+=a[i][j];
		if (num==n) x++;
		mx=max(mx,num);
		fo(j,1,n) if (a[i][j]) ok[j]=1;
	}
	fo(i,1,n)
	{
		int num=0;
		fo(j,1,n) num+=a[j][i];
		if (num==n) y++;
	}
	if (x) printf("%d",n-y); else
	if (mx==0) printf("-1"); else
	{
		int ans=n*n;
		fo(i,1,n)
		//if (ok[i]) 
		ans=min(ans,n-a[i][0]+(ok[i]==0));
		ans+=n-y;
		printf("%d",ans);
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, N1, f;
  cin >> N;
  N1 = N;
  f =0;

  while(N1 >= 1){
    f += N1 % 10;
    N1 /= 10;
  }
  if( N%f == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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





#define INF INT_MAX/2
int N, M;
int D[105][105];
bool C[1010];
int DD[1010];
map<pair<int, int>, int> MM;
bool done[105][105];
void dfs(int from, int to) {
	if (done[from][to]) return;
	done[from][to] = true;

	rep(i, 0, N) if(i != from && i != to){
		if (D[from][i] + D[i][to] == D[from][to]) {
			if (D[from][i] == DD[MM[make_pair(from, i)]]) {
				C[MM[make_pair(from, i)]] = true;
			}
			if (D[i][to] == DD[MM[make_pair(i, to)]]) {
				C[MM[make_pair(i, to)]] = true;
			}
			dfs(i, to);
		}
	}
}
//-----------------------------------------------------------------
int main() {
	cin >> N >> M;
	rep(i, 0, N) rep(j, 0, N) D[i][j] = INF;
	rep(i, 0, N) D[i][i] = 0;
	DD[0] = INF;
	rep(i, 0, M) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		D[a][b] = D[b][a] = c;
		MM[make_pair(a, b)] = i + 1;
		MM[make_pair(b, a)] = i + 1;
		DD[i + 1] = c;
	}

	rep(k, 0, N) rep(i, 0, N) rep(j, 0, N)
		D[i][j] = min(D[i][j], D[i][k] + D[k][j]);

	rep(i, 0, N) rep(j, i + 1, N) {
		if (D[i][j] == DD[MM[make_pair(i, j)]]) {
			C[MM[make_pair(i, j)]] = true;
		}
		dfs(i, j);
	}

	int ans = 0;
	rep(i, 1, M + 1) if (!C[i]) {
		ans++;
	}
	cout << ans << endl;
}

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

const int mod = 1000000007;
struct mint
{
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
};
struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};
int n,a,b,c;
mint solve(){
    combination c(2*n);
    mint ans=0;
    rep(i,n){
        mint pk1=c(n+i-1,i)*(mint(a)/(a+b)).pow(n)*(mint(b)/(a+b)).pow(i);
        mint pk2=c(n+i-1,i)*(mint(b)/(a+b)).pow(n)*(mint(a)/(a+b)).pow(i);
        ans+=(pk1+pk2)*(n+i)*100/(a+b);
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n>>a>>b>>c;
    cout<<solve().x<<endl;
    return 0;
}

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

int main() 
{
    string N;
    cin>>N;

    vector<int> Ns;
    auto lim=N.size();
    for (size_t i = 0; i < lim; i++)
    {
        Ns.push_back(std::move(static_cast<int>(N[i])-48));
    }
    auto sum = accumulate(Ns.begin(),Ns.end(),0L);
    if(sum%9L==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 4516
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
typedef long long int ll;
typedef unsigned long long int ull;
#define mod 1000000007
#define x first
#define y second
#define codec ios_base::sync_with_stdio(false);cin.tie(NULL);
typedef vector<int> vi;
typedef vector<long long int> vl;
#define deb cout<<"Heelo"<<endl;
typedef pair<int, int> pi;
int main()
{
    string a;
    cin>>a;
    int l=a.length()-1;
    if(a[l]=='s')
    a+="es";
    else a+="s";
    cout<<a;

}

Measured memory_bytes: 3596
//AcFreak

#include<bits/stdc++.h>
#define lint long long int 
#define mp make_pair
#define pb push_back
#define pii pair<int,int >
using namespace std;

int main()
{
      lint n;
      cin>>n;
      
      lint tt=n;
      
      lint sn=0;
      while(tt!=0)
      {
            sn+=(tt%10);
            tt/=10;
      }
      
      if(n%sn ==0)
      cout<<"Yes"<<endl;
      else
      cout<<"No"<<endl;
      return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <string>
using namespace std;

typedef pair<int,int> P;

int main(){
	int n;
	while( scanf("%d", &n), n ){
		priority_queue<P, vector<P>, greater<P> > q;
		
		for(int i=0 ; i < n ; i++ ){
			int h1, m1, s1, h2, m2, s2;
			scanf("%d:%d:%d", &h1, &m1, &s1);
			scanf("%d:%d:%d", &h2, &m2, &s2);
			int t1 = h1 * 60 * 60 + m1 * 60 + s1;
			int t2 = h2 * 60 * 60 + m2 * 60 + s2;
			q.push( P(t1, +1) );
			q.push( P(t2, -1) );
		}
		int ans = 0, cnt = 0;
		while( !q.empty() ){
			P p = q.top(); q.pop();
			if( p.second == -1 ){
				cnt--;
			}else{
				cnt++;
				ans = max(ans, cnt);
			}
		}
		printf("%d\n", ans);
	}
}

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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

	int ans = INT_MAX;
	for(int i = 0;i <= s.size()-t.size();i++){
		int tmp = 0;
		for(int j = 0;j < t.size();j++){
			if(s[i+j] != t[j]) tmp++;
		}
		chmin(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

ll modmul(ll a,ll b,ll mod){
    return a%mod * (b%mod) %mod;
}

ll modpow(ll a,ll b,ll mod){
    if(b==0) return 1;
    else if(b%2==0) return modpow(modmul(a,a,mod),b/2,mod);
    else return modmul(modpow(a,b-1,mod),a,mod);
}

ll moddiv(ll a,ll b,ll mod){
    return a%mod * modpow(b,mod-2,mod) %mod;
}

int main(void)
{
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n){
        int v; cin>>v;
        v--;
        a[i]=v;
    }
    ll tmp=0,cnt=0;
    while(true){
        if(tmp==1){
            cout<<cnt<<endl;
            break;
        }
        if(cnt>=n){
            cout<<"-1"<<endl;
            break;
        }
        cnt++;
        tmp=a[tmp];
    }
    return 0;
}


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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }

string s, t;

vector<vector<int>> dp(3010, vector<int>(3010, 0));

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

    cin >> s;
    cin >> t;

    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < t.size(); j++) {
            if (s.at(i) == t.at(j)) dp.at(i + 1).at(j + 1) = dp[i][j] + 1;
            if (dp.at(i + 1).at(j + 1) < dp.at(i).at(j + 1)) chmax(dp.at(i + 1).at(j + 1), dp.at(i).at(j + 1));
            if (dp.at(i + 1).at(j + 1) < dp.at(i + 1).at(j)) chmax(dp.at(i + 1).at(j + 1), dp.at(i + 1).at(j));
        }
    }

    string ans;

    int i = s.size();
    int j = t.size();

    while (i > 0 && j > 0) {
        if (dp.at(i).at(j) == dp.at(i - 1).at(j)) i--;
        else if (dp.at(i).at(j) == dp.at(i).at(j - 1)) j--;
        else {
            ans += s.at(i - 1);
            i--; j--;
        }
    }

    reverse(ALL(ans));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 35712
#include<bits/stdc++.h>
//#pragma GCC optimize("trapv")
#define I inline void 

using namespace std ; 
using ll = long long ; 
using ld = long double ; 
	
const int N = 5e2 + 7 , mod = 1e9 + 7 ; 

// How interesting!
	
int n , m , k ; 
string s[N] ; 
int ans[N][N] ; 
int pre[N][N] ; 
ll a[N] ; 
	
int main(){	
	ios_base::sync_with_stdio(0) ; 
	cin.tie(0) ; 

	cin >> n >> m >> k ; 
	for(int i = 0 ;i < n;i++){
		cin >> s[i] ; 
		s[i]+='#' ; 
		for(int j = 0 ;j <= m;j++){
			pre[i][j] = (s[i][j] == '#') ; 
			if(j)pre[i][j]+=pre[i][j-1] ; 
		}

	}
	int ix = 1 ; 
	for(int i = 0 ;i < n;i++){
	      if(ans[i][0])
	            continue ; 
		int l = 0 ; 
		int acc = 0 ; 
		for(int j = 0 ;j <= m; j++){
			if(s[i][j] == '#'){
				acc++ ; 
			}
			bool ex = 0 ; 
			if(ans[i][j] && !acc){ l = j + 1 ; continue ; }
			if(ans[i][j] && acc)
			      ex = 1; 
			if(acc == 2 || ex){
				for(int r = l ; r< j ; r++){
					ans[i][r] = ix ; 
				}

				for(int cur = i + 1; cur < n ; cur++){
					if(pre[cur][m-1]== 0){

						for(int r = l ; r < j ; r++){
							ans[cur][r] = ix ; 
						}
					}
					else break ; 
				}
                        l = j; 
                        acc = 1 - ex ; 
				ix++ ;
			}
			else if(ans[i][j]){
			      l = j + 1; 
			}

		}
	}
	for(int i = n - 2 ;i >= 0 ; i--){
	      for(int j = 0 ;j < m; j++){
	            if(!ans[i][j]){
	                  ans[i][j] = ans[i+1][j] ; 
	            }
	      }
	}
      for(int i = 0 ;i< n;i++){
            for(int j = 0 ;j < m; j++){
                  cout<< ans[i][j] <<" " ; 
            }
            cout<<"\n"  ; 
      }
      
	return 0 ; 
	
}

Measured memory_bytes: 5028
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define MP make_pair
#define ls (o << 1)
#define rs (o << 1 | 1)
#define mid ((L + R) >> 1)
#define eps (1e-5)
using namespace std;
typedef long long LL;
const LL mod = 1e9 + 7;
int n, m;
typedef pair<int, int> PII;
char s[100050];
int main() {
    scanf("%s", s);
    auto len = strlen(s);
    if (s[0] != s[len - 1] && len % 2 == 0) {
        puts("Second");
        return 0;
    }
    if (s[0] != s[len - 1] && len % 2 == 1) {
        puts("First");
        return 0;
    }
    printf("%s\n", len & 1 ? "Second" : "First");
    return 0;
}
//苏子曰：“客亦知夫（fú）水与月乎？逝者如斯[36]，而未尝往也；盈虚者如彼[37]，而卒[38]莫消长(zhǎng)也。盖将自其变者而观之，则天地曾（zēng）不能以一瞬；自其不变者而观之，则物与我皆无尽也，而又何羡乎！且夫（fú）天地之间，物各有主，苟（gǒu）非吾之所有，虽一毫而莫取。惟江上之清风，与山间之明月，耳得之而为声，目遇之而成色，取之无禁，用之不竭，是造物者之无尽藏[39]（zàng）也，而吾与子之所共适[40]。”
//客喜而笑，洗盏(zhǎn)更（gēng）酌[41]（zhuó）。肴（yáo）核既尽[42]，杯盘狼籍。相与枕藉[43]（jiè）乎舟中，不知东方之既白[44]

Measured memory_bytes: 512
import java.util.*;

class Main{
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int numbers[] = new int[n];
    int i = n;
    int j = 0;
    int k = 0;
    while (i>=1) {
      j = sc.nextInt();
      numbers[i-1] = j;
      i--;
    }
    while (k<=n-2) {
      System.out.print(numbers[k]+ " ");
      k++;
    }
    System.out.print(numbers[n-1]);
    System.out.println();
  }
}



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

int main() {
    string s;
    cin >> s;
    while ( 1 ) {
        s.pop_back();
        if ( s.substr(0,s.size()/2)==s.substr(s.size()/2) ) {
            break;
        }
    }
    cout << s.size() << '\n';
    return 0;
}


Measured memory_bytes: 3572
#PythonだとTLEする
N, K = map(int, input().split())
X = [0] * N
Y = [0] * N
for i in range(N):
    x, y = map(int, input().split())
    X[i] = x
    Y[i] = y

def count(x_min, x_max, y_min, y_max):
    cnt = 0
    for i in range(N):
        if x_min <= X[i] <= x_max and y_min <= Y[i] <= y_max:
            cnt += 1
    return cnt

ans = 10 ** 20
for i in range(N):
    for j in range(N):
        for k in range(N):
            for l in range(N):
                # print ('i, j , k, l = ', i, j, k, l)
                if X[i] < X[j] and Y[k] < Y[l]:
                    if count(X[i], X[j], Y[k], Y[l]) >= K:
                        # print ('A')
                        ans = min(ans, (X[j] - X[i]) * (Y[l] - Y[k]))
print (ans)



Measured memory_bytes: 50524
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    int n, p;
    scan(n, p);

    auto w = new int[](n);
    auto b = new int[](n);

    foreach (i ; 0 .. n) {
        scan(w[i], b[i]);
    }

    auto f = new long[](n);

    foreach (i ; 0 .. n) {
        f[i] = 1L * (100 - p) * w[i] + 1L * p * b[i];
    }

    f.sort!"a > b"();

    long v;
    long bs = b.sum(0L);

    foreach (i ; 0 .. n) {
        v += f[i];

        if (v >= 1L * p * bs) {
            writeln(i + 1);
            return;
        }
    }
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 4732
#include<cstdio>
#include<iostream>
using namespace std;
int a[201],b[201];
int main()
{
	int i,j,n,m,k,p=1;
	cin>>n;
	for(i=1;i<=2*n;i++)a[i]=i;
	cin>>m;
	for(i=1;i<=m;i++)
	{
		cin>>k;
		p=1;
		if(k==0)
		{
			if(i%2!=0)
			{
				for(j=1;j<=n;j++)
			    {
				b[p]=a[j];
				p++;
				b[p]=a[j+n];
				p++;
			    }
			}
			else if(i%2==0)
			{
				for(j=1;j<=n;j++)
			    {
				a[p]=b[j];
				p++;
				a[p]=b[j+n];
				p++;
			    }
			}
		}
		else 
		{
		    if(i%2!=0)
		    {
		    	for(j=k+1;j<=2*n;j++)
		    	{
		    		b[p]=a[j];
		    		p++;
				}
				for(j=1;j<=k;j++)
				{
					b[p]=a[j];
					p++;
				}
			}
			else if(i%2==0)
		    {
		    	for(j=k+1;j<=2*n;j++)
		    	{
		    		a[p]=b[j];
		    		p++;
				}
				for(j=1;j<=k;j++)
				{
					a[p]=b[j];
					p++;
				}
			}
		}
	}
	for(i=1;i<=2*n;i++)
	{
		if(m%2==0)cout<<a[i]<<endl;
		else cout<<b[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793238462
typedef long long ll;
typedef long double db;
ll p1[500005],p2[500005],mod=1e9+7;
ll C(ll a,ll b){return (p1[a]%mod*p2[b]%mod*p2[a-b]%mod)%mod;}//a大
ll qpow(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 main(){
    ll n,m;cin>>n>>m;
    p1[0]=1;p2[0]=1;
    for(ll i=1;i<=m;i++){
        p1[i]=(p1[i-1]%mod*i%mod)%mod;
        p2[i]=qpow(p1[i],mod-2);
    }
    ll t=(C(m,n)%mod*p1[n]%mod)%mod,ans=t%mod*t%mod;
    for(ll i=1;i<=n;i++){
        ll p=(t%mod*C(n,i)%mod*C(m-i,n-i)%mod*p1[n-i]%mod)%mod;
        if(i%2==1) ans=((ans-p)%mod+mod)%mod;
        else ans=(ans%mod+p%mod)%mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11408
n, k = map(int, input().split())

e = []
for i in range(1, n):
    e.append((n, i))
    # 点nを中心としたウニグラフ

cnt_pair = (n - 1) * (n - 2) // 2
to_rm = cnt_pair - k
if to_rm < 0:
    print(-1)
    exit()
elif to_rm == 0:
    print(len(e))
    for ee in e:
        print(*ee)
    exit()

for i in range(1, n - 1):
    for j in range(i + 1, n):
        e.append((i, j))
        to_rm -= 1
        if to_rm == 0:
            break
    else:
        continue
    break

print(len(e))
for ee in e:
    print(*ee)


Measured memory_bytes: 4000
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	int ans = -1;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			int tmp = a[i] * a[j];
			string s = to_string(tmp);
			int k;
			for (k = 1; k < s.size(); ++k)
				if (s[k - 1] + 1 != s[k]) break;
			if (k == s.size()) ans = max(ans, tmp);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define PI 3.14159265358979

using namespace std;

int main(void){
  int a, b;
  cin >> a >> b;

  cout << max(0, a - 2 * b) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<iostream>
#include<string>
#include<set>
#include<queue>
#include<random>
//#include<unordered_set>

using namespace std;

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> st;*/

#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#define pb push_back
#define ld long double

mt19937 rnd(51);

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vector<int> a;
	for (int i = 0; i < n; i++){
        int p;
        cin >> p;
        if (a.size() == 0){
            a.pb(p);
        }
        else{
            if (a.back() >= p){
                a.pb(p);
            }
            else{
                int l = -1, r = a.size();
                while(r - l > 1){
                    int mid = (r + l) / 2;
                    if (a[mid] < p){
                        r = mid;
                    }
                    else{
                        l = mid;
                    }
                }
                a[r] = p;
            }
        }
	}
	cout << a.size() << endl;
	return 0;
}


Measured memory_bytes: 892
#include <stdio.h>

int main()
{
	int N, R;
	scanf ("%d %d", &N, &R);
	
	if (N < 10)
	{
		printf ("%d", R + (100*(10 - N)));
	}
	else
	{
		printf ("%d", R);
	}
	
	return 0;
}

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

using namespace std;

#pragma GCC optimize("O3")
static const auto __ = [] {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return nullptr;
}();

double solve(int N) {
  double P[N + 1];
  double Q[N + 1];
  for (int i {1}; i <= N; ++i) {
    cin >> P[i];
    Q[i] = 1 - P[i];
  }
  double DP[N + 1][N + 1];
  DP[0][0] = DP[0][1] = 1;
  for (int t {1}; t <= N; ++t) {
    DP[t][0] = Q[t] * DP[t - 1][0];
    for (int h {1}; h < t; ++h) {
      DP[t][h] = Q[t] * DP[t - 1][h] + P[t] * DP[t - 1][h - 1];
    }
    DP[t][t] = P[t] * DP[t - 1][t - 1];
  }
  return accumulate(DP[N] + (N / 2 + 1), DP[N] + N + 1, 0.0);
}

int main(int argc, char* argv[]) {
  int N;
  cin >> N;
  cout << setprecision(9) << solve(N) << '\n';
  return 0;
}


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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 16;
const int maxpowN = 1 << 16;
const ll inf = 1e16;

int n;
ll val[maxpowN];
ll dp[maxpowN], a[maxN][maxN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for0(i, n)
    {
        for0(j, n)
        {
            cin >> a[i][j];
        }
    }
    for0(mask, 1 << n)
    {
        for0(i, n)
        {
            if (mask >> i & 1)
            {
                for0(j, i)
                {
                    if (mask >> j & 1)
                    {
                        val[mask] += a[i][j];
                    }
                }
            }
        }
    }
    fill (dp, dp + (1 << n), -inf);
    dp[0] = 0;
    for0(mask, 1 << n)
    {
        dp[mask] = val[mask];
        for (int sub = mask; sub; sub = (sub - 1) & mask)
        {
            uax(dp[mask], dp[sub] + val[mask ^ sub]);
        }
    }
    cout << dp[(1 << n) - 1];
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <cmath>

int main()
{
    int64_t N_;
    std::cin >> N_;
    std::vector<int64_t> arr;
    if (N_ == 1)
        std::cout << 0;
    else
    {
        int64_t N = N_;

        int64_t limit = std::sqrt(N) + 1;

        for (int i = 2; i <= limit; ++i)
        {
            if (i > N)
                break;

            if (N % i == 0)
            {
                int64_t count = 0;
                while (N % i == 0)
                {
                    ++count;
                    N /= i;
                }
                arr.emplace_back(count);
            }
        }

        if (N > limit)
            arr.emplace_back(1);

        int64_t sum = 0;
        for (unsigned i = 0; i < arr.size(); ++i)
        {
            int64_t j = 1;
            while (1)
            {
                arr[i] -= j;
                if (arr[i] < 0)
                    break;
                ++j;
                ++sum;
            }
        }

        std::cout << sum;
    }
}

Measured memory_bytes: 3704
#include <cstdio>
#include <vector>
int main(){
	int n;
	std::vector<int> v;
	while(scanf("%d\n", &n)+1){
		if(n){
			v.push_back(n);
		}else{
			printf("%d\n", v.back());
			v.pop_back();
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, n, a) for(int i = a; i < n; ++i)

int main(void) {
  int n, i, j, max = 0, now = 0;
  scanf("%d", &n);
  int r[n], d[n];
  d[0] = 0;
  rep(i, n) {
    scanf("%d", &r[i]);
    if(i) d[i] = r[i] - r[i - 1];
  }
  rep(i, n) {
    now += d[i];
    if(now < 0) now = 0;
    if(now > max) max = now;
  }
  if(!max) {
    max = -10e9 - 7;
    repi(i, n, 1) {
      if(max < d[i]) max = d[i];
    }
  }
  printf("%d\n", max);
  return 0;
}


Measured memory_bytes: 4272
#include <stdio.h>

int main(void){
    int w,h;

    scanf("%d %d", &h, &w);
    while (w!=0 || h!=0){
        for (int i=0; i<h; i++){
            for (int j=0; j<w; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
        scanf("%d %d", &h, &w);
    }
    return 0;
}

Measured memory_bytes: 1000
#include<stdio.h>
#include<string.h>
#include<algorithm>
//#include<iostream>
using namespace std;

int n;
#define maxn 200011
char s[maxn];int cnt[30];
#define LL long long
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	for (int i=1;i<=n;i++) cnt[s[i]-'a'+1]++;
	LL ans=1ll*n*(n-1)/2;
	for (int i=1;i<=26;i++) ans-=1ll*cnt[i]*(cnt[i]-1)/2;
	printf("%lld\n",ans+1);
	return 0;
}

Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	n := len(s)
	c := 0
	ans := 0
	for i := 0; i < n; i++ {
		if s[n-i-1] == 'B' {
			ans += i - c
			c++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,e) for(ll i=0;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;
ll i;

int main(){
    ll X,Y,Z;
    cin>>X>>Y>>Z;
    cout<<Z<<" "<<X<<" "<<Y<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}

const int mod=998244353;


int dp[3005][3005];

signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;
    int a[n+2];
    int tot=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        tot+=a[i];
    }
    int z=n*(n+1)/2;
    if(tot%z)
        cout<<"NO";
    else
    {
        z=tot/z;
        int temp=z;
        int diff;
        // cout<<z<<'\n';
        a[n+1]=a[1];
        for(int i=2;i<=n+1;i++)
        {   
            diff=a[i-1]-a[i]+z;
            // cout<<diff<<'\n';
            if(diff<0)
            {
                cout<<"NO";
                return 0;
            }
            if(diff%n)
            {
                cout<<"NO";
                return 0;
            }
            // cout<<diff/n<<'\n';
            temp-=diff/n;
        }

        if(temp)
            cout<<"NO";
        else
        {
            cout<<"YES";
        }
        
    }
    


} 
    
 

Measured memory_bytes: 4336
#include <bits/stdc++.h>
std::string s[3];
int p[3];
int len[3];
int k = 0;

int main() {
    for (int i = 0; i < 3; ++i) std::cin >> s[i], len[i] = s[i].size();
    while (1) {
        if (p[k] == len[k]) {
            printf("%c\n", k + 'A');
            break;
        }
        k = s[k][p[k]++] - 'a';
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp  make_pair
#define pb  push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
void c_p_c(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void solve(){
    int n;
    cin>>n;
    int a[n];
    rep(i,0,n){
        cin>>a[i];
    }
    sort(a,a+n);
    int c=0;
    rep(i,0,n){
        rep(j,i+1,n){
            rep(k,j+1,n){
                if(a[i]+a[j]>a[k] and a[i]+a[k]>a[j] and a[j]+a[k]>a[i] and a[i]!=a[j] and a[j]!=a[k] and a[i]!=a[k]){
                    c++;
                }
            }
        }
    }
    cout<<c<<endl;
}
int32_t main(){
    c_p_c();
    int t;
    t=1;
    //cin>>t;
    while(t--){
       solve(); 
    }
	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define unique(a)       sort((a).begin(), a.end()), (a).erase(unique((a).begin(), (a).end()),(a).end())
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"

using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;

LL gcd(LL a, LL b)
{
	if (!a)return b; return gcd(b%a, a);
}
double intlog(double base, double x) {
	return (double)((double)log(x) / (double)log(base));
}

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	cout << max(0, c - (a - b)) << endl;
}













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

int g(int a,int b){
  int n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

int main(){
  int i,j;ll cnt=0;
  int n;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)cin>>a[i];
  cnt=a[0];
  for(i=1;i<n;i++)cnt=g(cnt,a[i]);
  cout<<cnt;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll K, A, B;
    cin >> K >> A >> B;

    ll ans = 1;
    while (K > 0) {
        if (ans >= A) {
            if (B - A >= 3 && K > 1) {
                K -= 2;
                ans += B - A;
            }
            else {
                K--;
                ans++;
            }
        }
        else {
            ans++;
            K--;
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll qw(ll x,ll y){ll res = 1;while(y){if(y & 1) res *= x;x = x * x;y >>= 1;}return res;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
ll n,k;
int a[maxn],st;
bool vis[maxn];
vector<int> v;
void dfs(int x){
	if(vis[x]){
		st = x;
		return;
	}
	vis[x] = 1;
	v.pb(x);
	dfs(a[x]);
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	rep(i,1,n) cin >> a[i];
	dfs(1);
	ll sz = v.size();
	int hd = 0;
	for(int i = 0;i < sz;i++){
		if(v[i] == st){
			hd = i;
			break;
		}
	}
//	cout << st << endl;
	ll m = (k - hd) % (sz - hd);
//	cout << m << endl;
	if(k < hd) cout << v[k] << endl;
	else cout << v[hd + m] << endl;
	return 0;
}
//do smt instead of nothing! never give up!


Measured memory_bytes: 11128