akhauriyash/Code-Regression huggingface dataset:
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out = 0, fh = 1;
	char jp = getchar();
	while ((jp > '9' || jp < '0') && jp != '-')
		jp = getchar();
	if (jp == '-')
		fh = -1, jp = getchar();
	while (jp >= '0' && jp <= '9')
		out = out * 10 + jp - '0', jp = getchar();
	return out * fh;
}
const int N = 1e6 + 10;
char s[N];
int n, a[N];
int solve()
{
	int ans = 0;
	for (int i = 0; i < n; ++i)
		if (a[i] == 1)
			ans ^= ((n - 1) & i) == i;
	if (ans == 1)
		return 1;
	bool f = true;
	for (int i = 0; i < n; ++i)
		if (a[i] == 1)
			return 0;
		else
			f &= (!a[i]), a[i] >>= 1;
	if (f)
		return 0;
	return solve() * 2;
}
int main()
{
	n = read();
	scanf("%s", s);
	for (int i = 0; i < n; ++i)
		a[i] = s[i] - '1';
	printf("%d\n", solve());
	return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
const int MAX = (2e3)+2;

int n, m, q, a[MAX][MAX], r[MAX][MAX], d[MAX][MAX], v[MAX][MAX];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m >> q;
	for(int i = 1; i <= n; i++) {
		string s;
		cin >> s;
		for(int j = 1; j <= m; j++) a[i][j] = s[j-1] - '0';
	}
	for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) {
		v[i][j] = v[i-1][j] + v[i][j-1] - v[i-1][j-1] + a[i][j];
		r[i][j] = r[i-1][j] + r[i][j-1] - r[i-1][j-1] + a[i][j] * a[i][j+1];
		d[i][j] = d[i-1][j] + d[i][j-1] - d[i-1][j-1] + a[i][j] * a[i+1][j];
	}
	while(q--) {
		int x1, y1, x2,  y2;
		cin >> x1 >> y1 >> x2 >> y2;
		int resv = v[x2][y2] - v[x1-1][y2] - v[x2][y1-1] + v[x1-1][y1-1];
		int resr = r[x2][y2-1] - r[x1-1][y2-1] - r[x2][y1-1] + r[x1-1][y1-1];
		int resd = d[x2-1][y2] - d[x1-1][y2] - d[x2-1][y1-1] + d[x1-1][y1-1];
		cout << resv - resr - resd << endl;
	}
}


Measured memory_bytes: 64384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
 
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
#define int ll
#define pb push_back
#define pii pair<int,int>
#define ff first
#define ss second
const int MAX = 2e5+10;
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
vector<int> graph[MAX];
int n, arr[MAX];
int ans[MAX];
set<int> lis;

void dfs(int u, int par){
	ans[u] = ans[par];
	auto it = lis.lower_bound(arr[u]);
	int rem = -1;
	if (it != lis.end()){
		rem = *it;
		lis.erase(it);
	}
	lis.insert(arr[u]);
	ans[u] = lis.size();
	for(auto v:graph[u]){
		if (v == par)
			continue;
		dfs(v,u);
	}

	lis.erase(arr[u]);
	if (rem != -1)
		lis.insert(rem);
}


signed main(){

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


	#ifndef ONLINE_JUDGE
		time_t t1 = clock(), t2;
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
		// freopen("err.txt", "w", stderr);
	#endif



	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>arr[i];
	for(int i=0;i<n-1;i++){
		int u,v;
		cin>>u>>v;
		graph[u].pb(v);
		graph[v].pb(u);
	}

	dfs(1,0);
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<"\n";
	return 0;
}

Measured memory_bytes: 29616
#include<stdio.h>
#include<string.h>
#define INF 0x3f3f3f3f
int n,x,y;
int map[20][20];
int dis[100];

int main()
{
	while(~scanf("%d",&n)&&n)
	{
		for(int i=0;i<15;i++){
			for(int j=0;j<15;j++){
				if(i==j)map[i][j]=0;
				else map[i][j]=INF;
			}
		}
		int m=-1;
		for(int i=1;i<=n;i++){
			scanf("%d%d",&x,&y);
			m=x>m?x:m;
			m=y>m?y:m;
			scanf("%d",&map[x][y]);
			map[y][x]=map[x][y];
		}
		for(int k=0;k<=m;k++){
			for(int i=0;i<=m;i++){
				for(int j=0;j<=m;j++){
					if(map[i][j]>map[i][k]+map[k][j])
					map[i][j]=map[i][k]+map[k][j];
				}
			}
		}
		int min=INF;
		int id=-1;
		memset(dis,0,100);
		for(int i=0;i<=m;i++){
			for(int j=0;j<=m;j++){
				dis[i]+=map[i][j];
			}
			if(min>dis[i]){
				id=i;
				min=dis[i];
			}
		}
		printf("%d %d\n",id,min);
	}
	return 0;
} 
//


Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pf pop_front
#define mp make_pair
using namespace std;
#define int ll
#define mod 1000000007

int n,m;
int ans[1000][1000];
string s[1000];
void initialize()
{
	for(int i=0;i<m;i++)
		for(int j=0;j<n;j++)
			ans[i][j]=-1;
}

int dfs(int x,int y)
{
	if(ans[x][y]!=-1)
		return ans[x][y];
	//cout<<x<<' '<<y<<endl;
	if(s[y][x]=='#')
	{
		ans[x][y]=0;
		return 0;
	}
	if(x==m-1 && y==n-1)
	{
		ans[x][y]=1;
		return 1;
	}
	if(x==m-1)
	{
		ans[x][y]=dfs(x,y+1);
		return ans[x][y];
	}
	if(y==n-1)
	{
		ans[x][y]=dfs(x+1,y);
		return ans[x][y];
	}
	ans[x][y]=(dfs(x+1,y)+dfs(x,y+1))%mod;
	return ans[x][y];
}


signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	
	cin>>n>>m;
	initialize();
	for(int i=0;i<n;i++)
		cin>>s[i];
	cout<<dfs(0,0)<<endl;

}

Measured memory_bytes: 9216
def solve(node,edge,g)
  v = []
  h = []
  search(g,1,v,h,node)
end

def search(g,c,v,h,s)
  sum = 0
  v << c
  h << c
  ne = false
  g[c].each do |n|
    next if v.include?(n)
    ne = true
    sum += search(g,n,v.dup,h.dup,s)
  end
  if ne == false
    sum += 1 if h.size == s
  end
  return sum
end

def main
  node,edge = gets.split.map(&:to_i)
  g = Hash.new {|h,k| h[k] = []}
  edge.times do
    a,b = gets.split.map(&:to_i)
    g[a] << b
    g[b] << a
  end
  puts solve(node,edge,g)
end

main


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

int main(){
    int n, i;
    long long k, c = 0;
    cin >> n >> k;
    pair<int, int> p[n];
    for(i=0; i<n; i++){
        cin >> p[i].first >> p[i].second;
    }
    sort(p, p+n);
    i = 0;
    while(p[i].second < k){
        k -= p[i].second;
        i++;
    }
    cout << p[i].first;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	string S;  
	cin >> S; 
	int L = S.size(); 
	string ans = "No"; 
	for(int i = 0; i < L - 1; i++){
		if(S.at(i) == 'A' && S.at(i+1) == 'C') ans = "Yes"; 
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <unordered_map>
#define inputarr(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define prllarr(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" ";
#define pb push_back
#define ll long long
#define mod 1000000007
#define foi ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define in(n) scanf("%lld",&n);
#define in2(x,y) scanf("%lld %lld",&(x),&(y));
#define in3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z));
#define out(n) printf("%lld\n",n);
#define out2(x,y) printf("%lld %lld\n",x,y);
#define test(t)  ll t; in(t);while(t--)
#define set(arr,n,s) for(ll i=0;i<n;i++){arr[i]=s;}


/*error-----
convert every int to long long eg-1LL
create array with proper analysis of problem constrain
check mod also
*/
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1){res=(res*x)%p;} y=y>>1;x=(x*x)%p;}return res;}
ll modInverse(ll a,ll p){return power(a,p-2,p);}//used with feemat little

ll gcd(ll x,ll y){if(x==0 || y==0){return max(y,x);}return gcd(y%x,x);}
ll gcdExtended(ll a,ll b,ll &x,ll &y){if(a==0){x=0;y=1;return b;}ll x1,y1;ll gcd = gcdExtended(b%a,a,x1,y1);x=y1-(b/a)*x1;y=x1;return gcd;}//o(log(b))

//ll ncr(ll n,ll r,ll p){if(r==0){return 1;}return ((((fact[n]* inv[r]) % p) * inv[n-r]) % p);}
ll dp[100001];
int main()
{
	ll n,w;
	in2(n,w)
	for(ll i=0;i<n;i++)
	{
		ll we,val;
		in2(we,val);
		for(ll j=100000;j>=we;j--)
		{
			dp[j]=max(dp[j-we]+val,dp[j]);
		}
		

	}
	cout<<dp[w]<<endl;
}
	



	

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  vector<int> count(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    count.at(A.at(i) - 1)++;
  }
  
  sort(count.begin(), count.end());
  reverse(count.begin(), count.end());
  int ans = 0;
  for(int i = 0; i < K; i++){
    ans += count.at(i);
  }
  
  cout << N - ans <<endl;
  
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll N; cin >> N;

    ll ans = N-1;
    for (ll i = 2; i <= sqrt(N)+1; ++i) {
        if (N%i) continue;
        ll j = N/i;
        ans = min(ans, i+j-2);
    }
    cout << ans;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
    int n,d,x; cin >> n >> d >> x;
    int rel = 0;
    rep(i, n){
        int a; cin >> a;
        for(int j=1; j <= d; j += a){
            rel++;
        }
    }
    cout << rel + x << endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+5,M=2e6+5,MOD=1e9+7,OO=1e9;

std::vector<int> g[9];
int n,m;
int ans = 0;
void dfs(int u,set<int>s){
	s.insert(u);
	if(sz(s)==n)ans++;
	for(auto v : g[u]){
		if(!s.count(v)){
			dfs(v,s);
		}
	}
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();


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

	for(int i=0,x,y;i<m;i++){
		scanf("%d %d",&x,&y);
		g[x].pb(y);
		g[y].pb(x);
	}
	set<int>s;
	dfs(1,s);
	printf("%d\n",ans );
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n,k;
  cin >> n >> k;
  if(k==1){ cout<<0<<endl; return 0;}
  cout << n-k << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
	int q=0;char ch=' ';
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q;
}
typedef long long LL;
const int N=200005;
int n,top,L[N],R[N],a[N],st[N];LL ans;
int main()
{
	n=read();
	for(RI i=1;i<=n;++i) a[i]=read();
	for(RI i=1;i<=n;++i) {
		while(top&&a[st[top]]>a[i]) --top;
		L[i]=(top?st[top]+1:1),st[++top]=i;
	}
	top=0;
	for(RI i=n;i>=1;--i) {
		while(top&&a[st[top]]>a[i]) --top;
		R[i]=(top?st[top]-1:n),st[++top]=i;
	}
	for(RI i=1;i<=n;++i) ans+=1LL*(i-L[i]+1)*(R[i]-i+1)*a[i];
	printf("%lld\n",ans);
	return 0;
}

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


Measured memory_bytes: 11212
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mod=1000000007;
int main()
{
	int n,i,j,k;
	cin>>n>>k;
	int h[n],dp[n];
	for(i=0;i<n;i++)
	cin>>h[i];
	dp[0]=0;
	for(i=1;i<n;i++)
	{
		dp[i]=INT_MAX;
		for(j=1;j<=k;j++)
		{
			if(i<j) break;
			dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		}
	}
	cout<<dp[n-1];
	return 0;
}

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

int n, m;
vector<vector<int>> e;
vector<char> v;
int c, b;

void dfs(int i, int d) {
    v[i] = d;
    c++;
    d ^= 3;
    for (int j : e[i]) {
        if (v[j]) b |= v[j] ^ d; else dfs(j, d);
    }
}

int main() {
    cin >> n >> m;
    v = vector<char>(n);
    e = vector<vector<int>>(n);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        e[u].push_back(v);
        e[v].push_back(u);
    }

    int64_t k[3] = {};
    for (int i = 0; i < n; i++) {
        if (v[i]) continue;
        c = b = 0;
        dfs(i, 1);
        k[(c > 1) + (b != 0)]++;
    }

    k[2] += k[1];
    int64_t r = k[0] * (n * 2 - k[0]) + k[2] * k[2] + k[1] * k[1];

    cout << r << endl;

    return 0;
}


Measured memory_bytes: 8704
package main

import (
	"fmt"
)

func Solve(a, b, c int) bool {
	if a < b {
		return a < c && c < b
	}
	return a > c && c > b
}

func main() {
	n := 3
	a := make([]int, n)
	args := make([]interface{}, len(a))
	for i := 0; i < len(a); i++ {
		args[i] = &a[i]
	}
	fmt.Scan(args...)
	result := Solve(a[0], a[1], a[2])
	if result {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m,c,d;
string s;
vi v;

void solve(){
	cin >> a >> b >> c >> d;
	cout << max({1ll*d*b,1ll*a*c,1ll*a*d,1ll*b*c});
}

int main(){

	int t= 1;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3632
using System;
using System.Linq;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string[] input = Console.ReadLine().Split(' ');
		int[] X = new int[N];
		for(var i = 0; i < N; i++){
		    X[i] = int.Parse(input[i]);
		}

		GetResult(N, X);
	}
	
	static void GetResult(int N, int[] X){
	    var sum = 0;
	    int min = int.MaxValue;
	    int zMax = 0;
	    int zMin = int.MaxValue;
	    foreach(var x in X){
	        zMax = Math.Max(x, zMax);
	        zMin = Math.Min(x, zMin);
	    }
	    for(var i = zMin; i <= zMax; i++){
	        sum = 0;
	        for(var k = 0; k < N; k++){
	            sum += (int)Math.Pow(X[k] - i, 2);
	            if(sum > min) break;
	        }
	        min = Math.Min(min, sum);
	    }
	    Console.WriteLine(min);
	}
}

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

using namespace std;



typedef long long ll;

int x, y, z;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << "\n";
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    long long A, B, C;
    cin >> A >> B >> C;

    if(A%2 == 0 or B%2 == 0 or C%2 == 0) cout << 0 << endl;
    else{
        vector<long long> tmp = {A, B, C};
        sort(tmp.begin(), tmp.end());
        cout << tmp[0] * tmp[1] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h> 
int main(void) 
{  
int a[10000], min, max, n, i;  
long long sum = 0; 
 scanf("%d", &n); 
 for(i = 0; i < n; i++)
{  
 scanf("%d", &a[i]);   
sum += a[i]; 
 }  max = min = a[0];  
for(i = 1; i < n; i++)
{   if(a[i] > max){ 
  max = a[i];   }  
 if(a[i] < min)
{  
  min = a[i];
    }
  }
  printf("%d %d %lld\n", min, max, sum); 
 return 0;
 }

Measured memory_bytes: 636
N, K = map(int, input().split())

def mul(a, b):
    return ((a % P) * (b % P)) % P
 
def div(x, y):
    return mul(x, pow(y, P-2, P))
 
def comb(n, r):
    r = min(r, n - r)
    
    x = 1
    for i in range(n, n - r, -1):
        x = (x * i) % P
        
    y = 1
    for i in range(1, r+1):
        y = (y * i) % P
    return div(x, y)

P = 10 ** 9 + 7

for i in range(1, K+1):
    if i > N - K + 1:
        print(0)
    else:
        print(mul(comb(N-K+1, i), comb(K-1, i-1)))

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include<queue>
#include <sstream>
#include <set>
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
using namespace std;
int main(){
    int N;
    cin >> N;

    vector<int> time(100000),x(100000),y(100000);
    time[0] = 0, x[0] = 0, y[0] = 0;

    REP(i,N){
        cin >> time[i] >> x[i] >> y[i];
    }
    bool fl = true;
    REP(i,N){
        int dist = abs(x[i]-x[i+1]) + abs(y[i]-y[i+1]);
        int T = abs(time[i]-time[i+1]);

        if(dist > T) fl = false;
        if(T%2 != dist%2) fl =false;
    }

    if(fl) cout << "Yes" <<endl;
    else cout << "No" <<endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define endl enjoy_codeforces
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    int n,m;std::cin>>n>>m;
    int N=(1<<n)-1,M=(1<<m)-1;
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            int I=0;for(int k=i+1;!(k&1);k>>=1)I++;
            int J=0;for(int k=j+1;!(k&1);k>>=1)J++;
            std::cout<<(I+J==std::max(n,m)?0:1);
        }
        std::cout<<'\n';
    }
}


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

using namespace std;

int main(){
  string str;
  string pattern1;
  string pattern2;
  
  int count1=0;
  int count0=0;
  
  cin >> str;
  
  for(int i=0;i<str.size();i++){
    /* 1から始まるパターンを検証 */
    if(i%2 == 0){
    	if(str[i] == '1'){
    		count1++; 	
    	}
      	else{
    		count0++; 	
    	}
    }
    else {
    	if(str[i] == '0'){
      		count1++;
        }
      	else{
      		count0++;
        }
   	 }
  }
  cout << min(count1,count0) << endl;
}
      


Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

int main() {
  long long n, m;

  cin >> n >> m;
  vector<long long> h(n + 1);
  vector<long long> ma(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
    ma[i] = 0;
  }
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    ma[a] = max(ma[a], h[b]);
    ma[b] = max(ma[b], h[a]);
  }

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (ma[i] < h[i]) ans++;
  }
  cout << ans << endl;

  return 0;
}

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

namespace AtCoder.Question
{
    public class QuestionB
    {
        public static void Main(string[] args)
        {
            var (a, v) = ReadHelper.ReadValue<long, long>();
            var (b, w) = ReadHelper.ReadValue<long, long>();
            var t = ReadHelper.ReadValue<long>();
            if (v <= w)
            {
                Console.WriteLine("NO");
                return;
            }
            var distance = Math.Abs(b - a);
            var diff = v - w;
            Console.WriteLine(diff * t >= distance ? "YES" : "NO");
        }

        static class ReadHelper
        {
            internal static T ReadValue<T>()
            {
                return (T)Convert.ChangeType(Console.ReadLine(), typeof(T));
            }
            internal static (T1, T2) ReadValue<T1, T2>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)));
            }
            internal static (T1, T2, T3) ReadValue<T1, T2, T3>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)));
            }
            internal static (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)), (T4)Convert.ChangeType(input[3], typeof(T4)));
            }
            internal static T[] ReadValues<T>()
            {
                var input = Console.ReadLine().Split(' ');
                return input.Select(x => (T)Convert.ChangeType(x, typeof(T))).ToArray();
            }
        }

        static class MathAlgorithm
        {
            internal static bool IsPrime(long n)
            {
                if (n == 2) return true;
                if (n < 2 || n % 2 == 0) return false;
                var sqrt = Math.Sqrt(n);
                for (int i = 3; i <= sqrt; i += 2) if (n % i == 0) return false;
                return true;
            }
            internal static IEnumerable<long> EnumeratePrimes(long n)
            {
                var i = 2L;
                while (i * i <= n)
                {
                    if (n % i == 0)
                    {
                        n /= i;
                        yield return i;
                    }
                    else
                    {
                        i += i == 2 ? 1 : 2;
                    }
                }
                if (n != 1) yield return n;
            }
        }
    }
}


Measured memory_bytes: 27532
def f(n, t, arr)
  total, _ = arr.inject([0, 0]){|(total, last), now|
    # p [t, now, last, total]
    [total + [t, now + t - last].min, now + t]
  }
  total
end

N, T = gets.split.take(2).map(&:to_i)
Arr = gets.split.take(N).map(&:to_i)
# p N, T, Arr

puts f(N, T, Arr)


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

long long nCr[51][51];

void init(){
	nCr[0][0] = 1;
	for(int i=1; i <= 50; i++){
		nCr[i][0] = nCr[i][i] = 1;
		for(int j=1; j < i; j++){
			nCr[i][j] = nCr[i-1][j-1] + nCr[i-1][j];
		}
	}
}

class Solution {
public:
	void solve() {
		init();
		int n, a, b;
		cin >> n >> a >> b;
		vector<long long> v(n, 0);
		for(int i=0; i<n; i++)cin >> v[i];
		sort(v.begin(), v.end(), greater<long long>());
		long long ret = 0;
		double ret1 = 0.0;
		for(int i = 0; i < a; i++)ret1 += v[i];
		cout << setprecision(12) << ret1/a << endl;
		if(v[0] != v[a-1])b = a;
		for(int i=a-1; i<b; i++){
			if(i!=a-1 && v[i] != v[0])break;
			int cnt = 0, cnt2 = 0;
			for(int j=0; j < n; j++){
				if(v[i] == v[j])cnt++;
				if(v[i] < v[j])cnt2++;
			}
				ret += nCr[cnt][i+1-cnt2];
		}
		cout << ret << "\n";
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

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

int main(){
    int w,h;    cin>>w>>h;
    char c; cin>>c;

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i==0||i==h-1){
                if(j==0||j==w-1)cout<<'+';
                else cout<<'-';
            }else{
                if(i==h/2&&j==w/2)cout<<c;
                else{
                    if(j==0||j==w-1)cout<<'|';
                    else cout<<'.';
                }
            }
            if(j==w-1)cout<<endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <vector>

using namespace std;

int main(void) {

	int N, weight, S1 = 0, S2 = 0, sum = 0, min = 100 * 100;
	vector<int> W;

	cin >> N;

	for (int i = 0; i < N; ++i) {
		cin >> weight;
		W.push_back(weight);
		sum += weight;
	}

	S1 = sum;

	for (int T = 0; T < N; ++T) {
		S1 -= W[T];
		S2 += W[T];
		if (abs(S1 - S2) < min) {
			min = abs(S1 - S2);
		}
	}

	cout << min << endl;
}

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

int main() {
  char s;
  map<char, int> data;
  while (cin >> s) data[s]++;
  bool ans = true;
  for (auto x : data) if (x.second%2 == 1) ans = false;
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
// Problem : C - Skill Up
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Muallif: Azimjon Mehmonali o'g'li

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define sqr(x) (x) * (x)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define rALL(a) a.rbegin(), a.rend()
#define SORT(a) sort(ALL(a))
#define sc scanf
#define pr printf
#define xatop(a) cerr << #a << " = " << a << endl;
#define jsatr debug(__LINE__)
#define INF 1000000000
#define mod 1000000007

int main() {
	int n, m, x;
	cin >> n >> m >> x;

	int c[n], a[n][m];
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		for (int j = 0; j < m; j++)
			cin >> a[i][j];
	}

	int al[m];
	int kq, kqs;
	int yi = 0;
	kq = INF;
	for (int i = 1; i <= (1 << n); i++) {
		memset(al, 0, sizeof(al));
		yi = 0;
		for (int j = 0; j < n; j++) {
			if (i & (1 << j)) {
				yi += c[j];
				for (int k = 0; k < m; k++) {
					al[k] += a[j][k];
				}
			}
		}

		bool ham = true;
		for (int l = 0; l < m; l++) {
			ham = al[l] >= x;
			if (!ham)
				break;
		}

		if (ham) {
			if (yi < kq) {
				kq = yi;
				kqs = i;
			}
		}
	}

	if (kq == INF)
		cout << -1 << endl;
	else {
		cout << kq << endl;
	}

	return 0;
}


Measured memory_bytes: 3596
N = int(input())
_N = N
c = 0
for i in range(17):
    _N //=10
    if _N>0:
        c +=1
    else:
        break
ma = 0
for i in range(11):
    v = i*10**c-1
    if v<0:
        continue
    if v>N:
        continue
    if ma<v:
        ma = v
_ma = ma
s = 0
for i in range(17):
    s+=_ma%10
    _ma //=10
print (s)

Measured memory_bytes: 3064
#include <cstdio>

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

Measured memory_bytes: 128
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
 
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		Main m = new Main();
		m.input();
		m.solve();
		m.output();
	}
	/*
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	/*/
	InputUtil in = new InputUtil();
	PrintWriter out = new PrintWriter(System.out);
	//*/
	int N = 0;
	int A = 0;
	int B = 0;
	int ans = 0;
	public void input() throws IOException {
		/*
		S = br.readLine();
		/*/
		N = in.nextInt();
		A = in.nextInt();
		B = in.nextInt();
	}
 
	public void solve() throws IOException {
		ans  = Math.min(A*N, B);
	}
	
	
	public void output() {
		out.println(ans);
		out.flush();
	}
}
 
 
//*
class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }
 
	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}
 
	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}
}
//*/


Measured memory_bytes: 21076
#coding: utf-8

s = input().split(" ")
a = int(s[0])
b = int(s[1])
c = int(s[2])
x = int(s[3])
y = int(s[4])

out = 0
if x > y:
    mx = (x - y , "a")
    my = y
else:
    mx = (y - x , "b")
    my = x

cc = min([a+b, c*2])
for i in range(my):
    out += cc
if mx[1] == "a":
    if cc > a:
        out += a * mx[0]
    else:
        out += cc * mx[0]
else:
    if cc > b:
        out += b * mx[0]
    else:
        out += cc * mx[0]

print(out)

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

int main() {
 	int n, f = 0;
  	cin >> n;
  	while(n != 0) {
      	if((n % 10) == 7)
          	f = 1;
      	n /= 10;
    }
  	cout << ((f == 1) ? ("Yes") : ("No")) << endl;
  	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  int N;  cin>>N;
  vector<ll> v(N), v2(N);
  rep(i,0,N) cin>>v[i], v2[i]=v[i];
  int negative = 0;
  ll sum = 0;
  rep(i,0,N){
    sum += abs(v[i]);
    if(v[i]<0) negative++;
  }
  ll mi = INF;
  if(negative%2==1){
    rep(i,0,N) chmin(mi, abs(v[i]));
    sum -= mi*2;
  }
  cout << sum << endl;
  return 0;
}


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

using namespace std;

const int mod = 1e9 + 7;

int add() { return 0; }
template<typename... M> int add(int a, M... b) {
  int x = add(b...);
  return a + x - mod * (a + x >= mod);
}

int mul() { return 1; }
template<typename... M> int mul(int a, M... b) {
  return int(1ll * a * mul(b...) % mod);
}

int pwr(int a, long long x) {
  return (x ? mul(pwr(mul(a, a), x >> 1), (x & 1 ? a : 1)) : 1);
}

int dvd(int a, int b) {
  return mul(a, pwr(b, mod - 2));
}

int sub(int a, int b) {
  return a - b + mod * (a < b);
}

void inc(int& a, int b) {
  a = add(a, b);
}

void dec(int& a, int b) {
  a = sub(a, b);
}

int n, k;
map<int, int> calc;

int get(int i) {
  if (calc.count(i)) {
    return calc[i];
  }
  if (i == 1) {
    return 1;
  }
  int tot = pwr(i, n);
  for (int j = 2; j <= i; ++j) {
    dec(tot, get(i / j));
  }
  return calc[i] = tot;
}

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

  cin >> n >> k;
  int ans = 0;
  for (int i = k; i >= 1; --i) {
    inc(ans, mul(i, get(k / i)));
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 3684
#include<iostream>
#include<stdio.h>
using namespace std;

int main() {
	double a, b, c, d, e, f, A ,B, C, x, y;
	while(cin >> a >> b >> c >> d >> e >> f){
		A=a*e-b*d;
		B=c*d-a*f;
		C=c*e-b*f;
		x=C/A;
		y=(-1)*B/A;
		if(x== -0) x=0;
		if(y== -0) y=0;
		printf("%.3f %.3f\n", x, y);
	}
	return 0;
}

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

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		for (int i = 0; i < n; i++) {
			BigInteger a = new BigInteger(scanner.next());
			BigInteger b = new BigInteger(scanner.next());
			BigInteger c = a.add(b);
			System.out.println(c.toString().length() > 80 ? "overflow" : c);
		}
	}
}

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


int N;
int A[210];

int main() {
	cin >>N;
	for(int i=0;i<N;++i)cin>>A[i];
    
    int res =0;
    
    //ここからwhileを入れて、出来た数をresに加えていく作業
    
    while(true){
    	bool exist_odd=false; //exist_oddが変数名で、これから「奇数が出来たらtrueが入ります」って書きます
        for(int k=0;k<N;++k){
        	if(A[k]%2 != 0)exist_odd = true; //if文が奇数判定です。
        }
            if(exist_odd) break; //奇数があったのでbreakします。
            
            //ここからはループを回すための、「偶数があったら割る」を書きます。
            for(int j = 0;j<N;++j){
            	A[j] /= 2;
            }
            ++res; //resに1を加えます。
        }
        cout << res << endl;
    }

Measured memory_bytes: 256
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!

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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;

// ------------------------------------------------------------------------------------------------

ll n, x;

ll f(ll l, ll w) {
    if (w == 0) {
        return -l;
    }
    return 2 * (l / w) * w + f(w, l % w);
}

void func() {
    cin >> n >> x;
    cout << n + f(n - x, x) << endl;
}

int main() {
    fast_io; cout.precision(32);
    ll t = 1; // cin >> t;
    for (ll i = 1; i <= t; i++) {
        func();
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b,c;
char op;
while(1){
scanf("%d %c %d",&a,&op,&b);
if(op=='?'){
break;
}
else if(op=='-'){
c=a-b;
printf("%d\n",c);
}
else if(op=='+'){
c=a+b;
printf("%d\n",c);
}
else if(op=='*'){
c=a*b;
printf("%d\n",c);
}
else if(op=='/'){
c=a/b;
printf("%d\n",c);
}
}
return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9+5)
#define INFLL ((LL)4e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
#define SIZE 3
using namespace std;

class board{
public:
	vector<vector<int>> data;
	int ncost;
	int hcost;
	PII zpoint;

	int culonecost(int i, int j){
		if(data[i][j]==0){
			return abs(SIZE-1-i) + abs(SIZE-1-j);
		}
		int x = (data[i][j]-1)%SIZE;
		int y = (data[i][j]-1)/SIZE;
		return abs(i-y) + abs(j-x);
	}

	void setup(){
		hcost = 0;
		REP(i, SIZE){
			REP(j, SIZE){
				hcost+=culonecost(i, j);
				if(data[i][j]==0){
					zpoint=PII(i, j);
				}
			}
		}
	}

	board(vector<vector<int>> d){
		REP(i, SIZE){
			REP(j, SIZE){
				data[i][j]=d[i][j];
			}
		}
		hcost = 0;
		setup();
	}

	board(){
		data.resize(SIZE, vector<int>(SIZE));
	}

	void swap(int i, int j, int k, int l){
		hcost -= culonecost(i, j);
		hcost -= culonecost(k, l);
		std::swap(data[i][j], data[k][l]);
		hcost += culonecost(i, j);
		hcost += culonecost(k, l);
		if(data[i][j]==0){
			zpoint=PII(i, j);
		}else{
			zpoint=PII(k, l);
		}
	}

	bool onboard(int i, int j){
		return 0<=i&&0<=j&&i<SIZE&&j<SIZE;
	}
	
};

int mx[]={1, 0, -1, 0}, my[]={0, 1, 0, -1};

bool func(board &boa, int time, int lx, int ly){
	if(boa.hcost - boa.culonecost(boa.zpoint.first, boa.zpoint.second) > time * 1)return false;
	if(boa.hcost==0)return true;
	bool res = false;
	REP(i, 4){
		int y = boa.zpoint.first;
		int x = boa.zpoint.second;
		int ny = y + my[i];
		int nx = x + mx[i];
		if(lx==nx&&ly==ny)continue;
		if(!boa.onboard(ny, nx))continue;
		boa.swap(y, x, ny, nx);
		res |= func(boa, time-1, x, y);
		boa.swap(y, x, ny, nx);
		if(res)return true;
	}
	return res;
}


int main(){
	board boa;
	REP(i, SIZE)
		REP(j, SIZE)cin>>boa.data[i][j];
	boa.setup();
	REP(i, 1000){
		if(func(boa, i, -1, -1)){
			cout << i << endl;
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 3164
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////



int main(){
	int n,k;
	C2(n,k);
	
	long long ans = 0;
	
	if(k == 0 ){
		ans += double(n-1)/2*(2+(n-2));
	}
	else{
		ans += double(n-k)/2*(2+(n-k-1));
	}
	

	int tate = n;
	int nagasa = 1;
	rep(i,0,n+1){
		//cout << "ans:" << ans << " i:" << i << endl;
		int num = (tate-i) / nagasa;
		int s = nagasa-k;
		


		if(s >= 0){
			ans += num*s;

			//cout << "ans:" << ans << " i:" << i << endl;

			if( (tate-i)%nagasa != 0 ){
				int aaa = (tate-i)%nagasa - k;
				if(aaa > 0 )
					ans += aaa;
			}
		}

		//cout << "ans:" << ans << " i:" << i << endl;

		nagasa++;
	}

	P(ans);
	ret 0;
}

Measured memory_bytes: 256
import bisect
n, m, p = map(int, raw_input().split())
d = []
for i in xrange(m):
    inp = int(raw_input())
    d.append((inp - p + n) % n)
d.sort()
ans = min(d[-1], n-d[0])
for i in xrange(m-1):
    ans = min(ans, d[i] + (d[i] + n-d[i+1]))
for i in xrange(m-1):
    ans = min(ans, (n-d[i+1]) + (n-d[i+1] + d[i]))
print ans*100

Measured memory_bytes: 4704
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'

int main(){

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

    ll k; cin >>k;
    string s = string(1000000, '7');

    ll ans = -1, r = 0;
    for(int i = 0; i<s.length(); i++){
        r = ((r*10)%k + 7)%k;
        if(!r){
            ans = i+1;
            break;
        }
    }

    cout <<ans <<endl;

    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

ll H; ll table[1000];
void input()
{
    cin>>H;
    return;
}

void solve()
{
    int rank=1;
    while(H>=2){
        ++rank;
        H/=2;
    }
    table[1]=1;
    rrep(i,2,1000) table[i]=2*table[i-1]+1; 
    cout<<table[rank]<<endl;
    return;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

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

int x;
bool absol(const int p, const int q) {return abs(p-(double)x/2)<abs(q-(double)x/2); }

int main(void){
    int N; cin >> N;
    vector<int> a(N);

    for(int i=0; i<N; i++) cin >> a[i];
    sort(a.begin(), a.end());

    x = a[a.size()-1];
    a.pop_back();

    sort(a.begin(), a.end(), absol);

    int y = a[0];

    printf("%d %d\n", x, y);
}

Measured memory_bytes: 640
fn main() {
	use std::io::Read;
	let mut s = String::new();
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let _: usize = s.by_ref().next().unwrap().parse().unwrap();
	let ans = s.map(|s| s.parse::<i64>().unwrap()).fold(1i64, |r, a| r.saturating_mul(a));
	println!("{}", if ans > 1000000000000000000 { -1 } else { ans });
}


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

const string YES = "YES";
const string NO = "NO";

void solve(long long X) {
  if (X == 7 || X == 5 || X == 3)
    cout << "YES" << endl;
  else
    cout << NO << endl;
}

int main() {
  long long X;
  scanf("%lld", &X);
  solve(X);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <bitset>
#include <functional>
#include <type_traits>
#include <queue>
#include <stack>
#include <array>
#include <random>
#include <utility>
#include <cstdlib>
#include <ctime>

using namespace std;

#define rep(i, n) for (int i; i < (int)n; i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin; i < (int)end; i++)

int main()
{
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    string divide[4] = {"dream", "dreamer", "erase", "eraser"};
    for (int i = 0; i < 4; i++)
    {
        reverse(divide[i].begin(), divide[i].end());
    }

    bool check_all = true;
    for (int j=0; j < S.size(); )
    {
        bool check = false;
        for (int i=0; i < 4; i++)
        {
            string s = divide[i];
            if (s == S.substr(j, s.size()))
            {
                j += s.size();
                check=true;
            }
        }
        if(!check){
            check_all=false;
            break;
        }
    }

    if (check_all)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
}


Measured memory_bytes: 512
#include <stdio.h>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int,int> pi;
#define F first
#define S second
#define MP make_pair
int main(){
    int n,w,l,r,now;
    bool f;
    priority_queue<pi,vector<pi>,greater<pi>>pq;
    while(true){
        scanf("%d",&n);
        if(n==0)return 0;
        while(n--){
            scanf("%d%d%d",&w,&l,&r);
            pq.push(MP(l,w));
            pq.push(MP(r,-w));
        }
        f=true;
        now=0;
        while(!pq.empty()){
            l=pq.top().F;
            now+=pq.top().S;
            pq.pop();
            while(!pq.empty()){
                if(l==pq.top().F){
                    now+=pq.top().S;
                    pq.pop();
                }
                else break;
            }
            if(now>150)f=false;
        }
        if(f)printf("OK\n");
        else printf("NG\n");
        
    }
}


Measured memory_bytes: 2524
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    string s;
    cin >> s;
    regex re("A.+Z");
    smatch match;
    if(regex_search(s, match, re)){
        cout << match.str().size() << endl;
    }
    return 0;
}

Measured memory_bytes: 88324
Imports System.Collections
Imports System.Collections.Generic
Imports System.Linq
Imports System.xml
Imports System.xml.Linq

Module Module1
	public sub main()

		dim N as integer = convert.toint32(Console.ReadLine())
		dim A as string() = Console.ReadLine().split(" ")
		dim joshi as integer()
    	redim joshi (N-1)
   
		for i as integer = 0 to A.count - 1
    dim index as integer = A(i) -1
    		joshi(index) = joshi(index) + 1
		next
		
		for each output as integer in joshi
			console.writeLine(output.tostring)
		next
		
	  
	end sub 
End Module

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

#define PI 4*atan(1)
#define INF 1e8

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

int main(){
  unsigned long long N, A, B;
  cin >> N >> A >> B;
  vector<int> X(N);
  for(int i = 0; i < N; i++){
    cin >> X[i];
  }
  unsigned long long ans = 0;
  for(int i = 1; i < N; i++){
    if((X[i] - X[i - 1]) * A < B)ans += (X[i] - X[i - 1]) * A;
    else ans += B;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
{-# LANGUAGE OverloadedStrings #-}
import Data.Char
import Data.List
import Control.Monad
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  [n,a,b] <- parseLine <$> BS.getLine
  BS.putStrLn . BS.pack . show $ solve n a b
  where
     parseLine = unfoldr (BS.readInt . BS.dropWhile isSpace)


solve :: Int -> Int -> Int -> Int
solve _ 0 _ = 0
solve n a b = let (d,m) = n `divMod` (a+b) in d * a + (min m a)

Measured memory_bytes: 380