akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

int main()
{
	FAST;
	string s;
	cin >> s;
	ll l = s.length(), i;
	ll a = 0, bc = 0, ans = 0;
	fr(i,0,l)
	{
		if(s[i] == 'A')
		{
			if(bc == 0)
				a++;
			else
			{
				ans += (a*bc);
				bc = 0;
				a++;
			}
		}
		else if(s[i] == 'B')
		{
			if((i+1 < l)&&(s[i+1] == 'C'))
			{
				bc++;
				i++;
			}
			else 
			{
				if(bc != 0)
				{
					ans += a*bc;
					a = 0;
					bc = 0;
				}
				else 
					a = 0;
			}
		}
		else if(s[i] == 'C')
		{
			if(bc != 0)
			{
				ans += a*bc;
				a = 0;
				bc = 0;
			}
			else 
				a = 0;
		}
	}
	ans += a*bc;
	cout << ans;
}


Measured memory_bytes: 720
vec1 = []
vec2 = []

n, m = map(int, input().split())
for x in range(1, n+1):
    vec1.append(list(map(int, input().split())))

for y in range(m):
    vec2.append(int(input()))

for j in vec1:
    result = 0
    for w, z in zip(j, vec2):
        result += w * z
    print(result)



Measured memory_bytes: 6008
n=int(input())
num=list(map(int,input().split()))
ma=1000000000000000000
p=1
num.sort()
if num[0]==0:
    print(0)
elif num[-1]==1 and num[0]==1:
    print(1)
else:
    f=0
    for i in range(n-1,-1,-1):
        p*=num[i]
        if p>ma:
            f=1
            print(-1)
            break
    if f==0:
        print(p)



Measured memory_bytes: 22324
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(true){
    c -= b;
    if(c<=0){
      cout << "Yes\n";
      break;
    }
    a -= d;
    if(a<=0){
      cout << "No\n";
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3656
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		double b = 0;
		for (int i = 0; i < n; i++) {
			double a = sc.nextDouble();
			b += 1 / a;
		}
		System.out.println(1 / b);
	}
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;

const ll mod=1000000007;
const ll inf=1000000000000; 

#define rep(i,m,n) for(ll i=m;i<n;i++)


ll n,c;
vll x,v;

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

  cin >> n >> c;
  x.resize(n);
  v.resize(n);
  
  rep(i,0,n) cin >> x[i] >> v[i];
  
  vll fa(n+1,0),fb(n+1,0);
  rep(i,0,n) {
    fa[i+1]=fa[i]+v[i];
    fb[i+1]=fb[i]+v[n-1-i];
  }
  rep(i,0,n) {
    fa[i+1]-=x[i];
    fb[i+1]-=(c-x[n-1-i]);
  }
  
  vll ga(n+1),gb(n+1);
  ga=fa;
  gb=fb;
  rep(i,0,n){
    ga[i+1]-=x[i];
    gb[i+1]-=(c-x[n-1-i]);
  }
  rep(i,0,n){
   fa[i+1]=max(fa[i+1],fa[i]);
   fb[i+1]=max(fb[i+1],fb[i]); 
   ga[i+1]=max(ga[i+1],ga[i]); 
   gb[i+1]=max(gb[i+1],gb[i]);  
  }
  
  
  ll res=0;
  rep(b,0,n+1){
    res=max({res,gb[b]+fa[n-b],fb[b]+ga[n-b]});    
  }
  cout << res << endl;
  
  
 
  
}

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

int main() {
    string s; cin >> s;
    int N = s.size();
    string s1 = s.substr(0,(N-1)/2);
    string s2 = s.substr((N+3)/2-1,N-(N+3)/2+1);

    string s_rev = s;
    reverse(s_rev.begin(), s_rev.end());

    string s1_rev = s1;
    reverse(s1_rev.begin(), s1_rev.end());

    string s2_rev = s2;
    reverse(s2_rev.begin(), s2_rev.end());

    if(s==s_rev && s1==s1_rev && s2==s2_rev) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(",");
	//文字列から10進数に変換するときはparseIntを使います
	var a = input[0];
	var b = input[1];
	var c = input[2];
	//出力
	console.log('%s %s %s',a,b,c);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int P, Q, R;
    cin >> P >> Q >> R;
    int temp;
    if(P > Q){
        if(P > R) cout << R + Q  << endl;
        else cout << P + Q << endl;
    }else{
        if(Q > R) cout << P + R << endl;
        else cout << P + Q << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;
#define int LL

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 1e5 + 5, mod = 1e9 + 7;
int frac[MAXN], invfrac[MAXN], x[MAXN], S[MAXN];

inline LL qpow(LL a, LL k) {
  LL re = 1;
  for (; k; k >>= 1, a = a * a % mod)
    if (k & 1) re = re * a % mod;
  return re;
}
inline LL C(int n, int m) { return frac[n] * invfrac[m] % mod * invfrac[n - m] % mod; }

signed main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int n; cin >> n;
  frac[0] = 1;
  for (RI i = 1; i <= n; ++i) frac[i] = frac[i - 1] * i % mod;
  invfrac[n] = qpow(frac[n], mod - 2);
  for (RI i = n; i; --i) invfrac[i - 1] = invfrac[i] * i % mod;
  for (RI i = 1; i <= n; ++i)
    S[i] = (S[i - 1] + C(n - 1, i) * frac[n - 1 - i] % mod * frac[i - 1] % mod);
  for (RI i = 1; i <= n; ++i) cin >> x[i];
  int ans = 0;
  for (RI i = 1; i < n; ++i)
    ans = (ans + (x[i + 1] - x[i]) * S[i] % mod) % mod;
  cout << ans << endl;

  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 4352
#include<bits/stdc++.h>
 
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%lf",&x)
#define sl(x) scanf("%lld",&x)
#define pr(x) printf("%d\n",x)
#define prll(x) printf("%lld\n",x)
 
#define ll long long int
#define ull unsigned long long int
#define F first
#define S second
 
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define ii pair<int,int> 
#define pll pair<ll,ll> 
#define vi vector<int> 
#define vvi vector< vi > 
#define vl vector<long long int>
#define vvl vector< vl >
#define vii vector< ii >
#define vvii vector< vii >
#define priority_queue pq;
#define sz(a) ll((a).size()) 
#define pb push_back 
#define mp make_pair
 
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end() 
#define tr(i,c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ison(x,i) (((x) >> (i)) & 1)	//checks if ith bit is on
#define set0(x,i) (x & ~(1 << i))		//set ith bit in x to be zero
#define clr(a) memset(a,0,sizeof(a))
 
#define MOD 1000000007
#define INF 4000000000000000000
#define MAX 100000+5
using namespace std;

ll solve(ll h,ll w)
{
	ll ret=INF;
	if(w>=3)
		ret=(w%3)?h:0;
	//printf("%lld %lld\n",h,w);
	rep(i,1,w)
	{
		ll x=i*h,y=0,z=0;
		if(h%2)
		{
			y=(h/2)*(w-i);
			z=(h/2+1)*(w-i);
			ret=min(ret , max( abs(x-y) , max( abs(y-z) , abs(x-z) ) ));
		}
		else
		{
			y=(h/2)*(w-i);
			ret=min(ret,abs(x-y));
		}
		//printf("%lld %lld %lld %lld\n",i,x,y,z);
	}
	return ret;
}

int main()
{
	ll h,w;
	sl(h); sl(w);
	prll(min(solve(h,w),solve(w,h)));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
 
ll po(ll x) {
	ll res = 1;
	while (res < x)res *= 2;
	return res;
}
 
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
 
	int N;
	cin >> N;
	vector<ll>A(N);
	map<ll, int>mp;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		mp[A[i]]++;
	}
	sort(all(A));
	reverse(all(A));
 
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (mp[A[i]] == 0)continue;
		ll minbeki = po(A[i]+1);
		if (minbeki <= 2 * A[i]) {
			if (minbeki - A[i] == A[i]) {
				if (mp[A[i]] > 1) {
					ans++;
					mp[A[i]] -= 2;
				}
			}
			else {
				if (mp[minbeki - A[i]] > 0) {
					ans++;
					mp[minbeki-A[i]]--;
                  	mp[A[i]]--;
				}
			}
		}
	}
	puts(ans);
 
	return 0;
}

Measured memory_bytes: 26880
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BGoodDistance {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    bool check(int x) {
        for (int i = 1; i * i <= x; i++) {
            if (i * i == x) return true;
        }

        return false;
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N, D;
        cin >> N >> D;
        vector<vector<int>> X(N, vector<int>(D));
        REP(i, N) {
            REP(j, D) {
                cin >> X[i][j];
            }
        }

        int res = 0;
        REP(i, N) {
            FOR(j, i + 1, N - 1) {
                int d = 0;
                REP(k, D) {
                    d += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
                }
                if (check(d)) {
                    res++;
                }
            }
        }
        cout << res << endl;

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BGoodDistance solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  if(a < 6)
   cout << 0 << endl;
  else if (a < 13)
    cout << b / 2 << endl;
  else 
    cout << b << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var h1, h2, m1, m2, k int
	fmt.Scan(&h1, &m1, &h2, &m2, &k)
	begin := h1*60 + m1
	end := h2*60 + m2
	fmt.Println(end - begin - k)
}


Measured memory_bytes: 1752
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>

#define X first
#define Y second
#define PB push_back

using namespace std;

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

const int N = 305;

int n, m, k;
char s[N][N];
int sol[N][N];

int main(){
	scanf("%d%d%d", &n, &m, &k);
	for(int i = 0;i < n;i++)
		for(int j = 0;j < m;j++)
			scanf(" %c", &s[i][j]);
    int st = 0, ima = 0, cur = 0;
    for(int i = 0;i < n;i++){
		ima = 0;
		for(int j = 0;j < m;j++){
			if(s[i][j] == '#'){
				cur++;
				if(!ima)
					for(int jj = 0;jj < j;jj++)
						sol[i][jj] = cur;
				ima = 1;
			}
			if(ima)
				sol[i][j] = cur;
		}
		if(ima && !st){
			for(int ii = i - 1;ii >= 0;ii--)
				for(int j = 0;j < m;j++)
					sol[ii][j] = sol[ii + 1][j];
		}
		if(!ima && st){
			for(int j = 0;j < m;j++)
				sol[i][j] = sol[i - 1][j];
		}
		st |= ima;
    }
    for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			printf("%d ", sol[i][j]);
		}
		printf("\n");
    }
	return 0;
}


Measured memory_bytes: 1152
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()
	k := readInt()
	e := k / 2
	o := k - e
	println(e * o)
}

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


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

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
constexpr ll TEN(ll n){return n==0?1:10ll*TEN(n-1);}

constexpr ll inf = TEN(9)+5;
constexpr ll linf = 3*TEN(18);

const int mod = TEN(9)+7;

inline ll pow_mod(ll a, ll x, ll m)
{
    if (x == 0) return 1;
    ll res = pow_mod(a, x / 2, m);
    res *= res;
    res %= m;
    if (x % 2) {
        res *= a;
        res %= m;
    }
    return res;
}

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

    ll ans = pow_mod(10, N, mod) - 2*pow_mod(9, N, mod) + pow_mod(8, N, mod);

    while (ans < 0) ans += mod;
    while (ans >= mod) ans -= mod;

    cout << ans << endl;
}


Measured memory_bytes: 3632
import sys
from collections import defaultdict
input = sys.stdin.readline

 
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n = I()
d = defaultdict(int)
for i in range(n):
    temp = I()
    d[temp] += 1
ans = 0
for i in d.values():
    if i % 2 == 1:
        ans += 1
        
print(ans)

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

int main() {
	int N,x;
	cin >> N>>x;
	int S[110],count=0;
	for (int i = 0; i < N; i++)cin >> S[i];
	sort(S, S + N);

	for (int i = 0; i < N; i++) {
		x -= S[i];
		if (x < 0) break;
		count++;
	}
	if (x > 0)count -= 1;
	cout << count << endl;
}


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

int main() {
    int N;
    cin >> N;
    set<int> UniqueD;
    rep(i, N) {
        int tmp;
        cin >> tmp;
        UniqueD.insert(tmp);
    }

    cout << UniqueD.size() << endl;

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define endl            "\n"
#define forn(i,x,n)     for(int i=x; i<n; i++)
#define forit(it, m)    for(decltype(m)::iterator it = m.begin(); it!=m.end(); ++it)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void zeus()
{
    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
}

int fast_pow(long long base, long long n, long long M)
{
    if (n == 0)
        return 1;
    if (n == 1)
        return base;
    long long halfn = fast_pow(base, n / 2, M);
    if (n % 2 == 0)
        return ( halfn * halfn ) % M;
    else
        return ( ( ( halfn * halfn ) % M ) * base ) % M;
}

int findMMI_fermat(int n, int M)
{
    return fast_pow(n, M - 2, M);
}

int32_t main() {

    zeus();

    int a, b, c, d;

    cin >> a >> b >> c >> d;
    int count = 0;
    while (a > 0 && c > 0) {
        if (count % 2 == 0) {
            c = c - b;
        }
        else {
            a = a - d;
        }
        count++;
    }

    if (a <= 0) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}




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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	IOS;
	int n;
	cin >> n;
	vi a(n);
	rep(i,n) cin >> a[i];
	int ans = 0;
	rep(i,n) rep(j,n){
		if(i == j) continue;
		ans = max(ans,abs(a[i]-a[j]));
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std ;

#define ll long long

// int a[] = { 8, 15, 3, 7 };
vector <ll> a(30001) ;

ll dp[3001][3001] ;

ll rec (int i , int j) {
	if (i > j) return 0 ;
	if (dp[i][j] != -1)return dp[i][j] ;
	return dp[i][j] =  max (a[i] + min(rec(i + 2, j) , rec(i + 1, j - 1)) , a[j] + min(rec(i , j - 2) , rec(i + 1, j - 1)) ) ;
}

int main () {
	memset(dp, -1, sizeof(dp)) ;
	int n ;
	cin >> n ;
	ll sum = 0 ;
	for (int i = 0 ; i < n; i++) {
		cin >> a[i] ;
		sum += a[i] ;
	}
	ll x = rec(0, n - 1) ;
	ll y = sum - x ;
	cout << x - y  ;
	return 0 ;
}

Measured memory_bytes: 74108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
const double PI= acos(-1.0);
const int M = 1e5+7;
/*
int head[M],cnt;
void init(){cnt=0,memset(head,0,sizeof(head));}
struct EDGE{int to,nxt,val;}ee[M*2];
void add(int x,int y,int z){ee[++cnt].nxt=head[x],ee[cnt].to=y,ee[cnt].val=z,head[x]=cnt;}
*/
char a[2100],b[2100],c[2100];
bool ab[M],bc[M],ac[M];
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	cin>>a>>b>>c;
  	int la=strlen(a),lb=strlen(b),lc=strlen(c);
  	for(int i=0;i<la;i++)
	  	for(int j=0;j<lb;j++)
	  		if(!(a[i]==b[j]||a[i]=='?'||b[j]=='?'))
			    ab[i-j+10000]=true;//a的i和b的j字符对上时，ab相对位置为i-j ，是否能匹配
	for(int i=0;i<lb;i++)
	  	for(int j=0;j<lc;j++)
	  		if(!(b[i]==c[j]||b[i]=='?'||c[j]=='?'))
			    bc[i-j+10000]=true;//b的i和c的j字符对上时，bc相对位置为i-j ，是否能匹配
	for(int i=0;i<la;i++)
	  	for(int j=0;j<lc;j++)
	  		if(!(a[i]==c[j]||a[i]=='?'||c[j]=='?'))
			    ac[i-j+10000]=true;//a的i和c的j字符对上时，ac相对位置为i-j ，是否能匹配
	int mi=1e9;
	for(int i=-4000;i<=4000;i++)
	for(int j=-4000;j<=4000;j++)
	{
		//a-i  , b-0 , c-j
		if(!ab[10000-i]&&!bc[j+10000]&&!ac[j-i+10000])
		{
			int l=min(i,min(0,j));
			int r=max(i+la,max(lb,j+lc));
		//	if(r-l<=10)cout<<i<<" "<<j<<endl;
			mi=min(mi,r-l); 
		}
	}
	cout<<mi<<endl;
	return 0;
}

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

using namespace std;

int main() {
	int n, *s;
	double m, a, aa;
	while (1) {
		cin >> n;
		if (n == 0)
			break;

		s = new int[n];
		m = a = aa = 0;
		for (int i = 0; i < n; i++) {
			cin >> s[i];
			m += s[i];
		}
		m /= n;
		for (int i = 0; i < n; i++)
			aa += pow(s[i] - m, 2);
		aa /= n;
		a = sqrt(aa);
		printf("%.8f\n", a);
		delete[] s;
	}
	return 0;
}

Measured memory_bytes: 1224
/* author : akshatjai258 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define int ll
#define mod int(1e9 + 7)
#define inf int(1e9)
#define endl "\n"
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define fi first
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define memf(a) memset(a, false, sizeof(a))
#define all(v) v.begin(), v.end()
#define se second
#define mp make_pair
#define pb push_back
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
#define ps(x, y) fixed << setprecision(y) << x
void prep()
{
	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*/
}
int32_t main()
{
	prep();
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
q = int(input())
lr = []
for i in range(q):
    lr.append(list(map(int, input().split())))


def binarySearch(alist, item):
    first = 0
    last = len(alist) - 1
    found = False
    while first <= last and not found:
        midpoint = (first + last) // 2
        if alist[midpoint] == item:
            found = True
        else:
            if item < alist[midpoint]:
                last = midpoint - 1
            else:
                first = midpoint + 1
    return found


def is_prime(num):
    i = 2
    while i ** 2 <= num:
        if num % i == 0:
            return False
        i += 1
    return True


primes = []
for i in range(2, 10 ** 5 + 1):
    if is_prime(i):
        primes.append(i)

like_2017 = []
for i in range(len(primes)):
    if binarySearch(primes, primes[i] * 2 - 1):
        like_2017.append(2 * primes[i] - 1)

count = [0 for _ in range(10 ** 5)]
for like in like_2017:
    count[like] += 1
for i in range(len(count) - 1):
    count[i + 1] += count[i]
for i in range(q):
    print(count[lr[i][1]] - count[lr[i][0]-1])


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

bool islower(char c)
{
  return (c>='a' && c<='z');
}

bool isupper(char c)
{
  return (c>='A' && c<='Z');
}

char to_upper(char c)
{
  return c-0x20;
}

char to_lower(char c)
{
  return c+0x20;
}

int main()
{
  while(true)
  {
    string s;
    cin>>s;
    if(s[0]=='0') return 0;
    int ans=0;
    for (int i = 0; i < s.size(); ++i)
    {
      ans+=s[i]-'0';
    }
    cout<<ans<<endl;
  }
}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug cout<<"Reached\n";

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

int main()
{    
    

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

    li n,m;

    cin>>n>>m;

    vector<vi> graph(n+1);

    li h[n+1];

    f(i,1,n)
    {
        cin>>h[i];
    }

    f(i,0,m-1)
    {
        li u,v;

        cin>>u>>v;

        graph[u].PB(v);
        graph[v].PB(u);
    }

    li ans=0;

    f(i,1,n)
    {
        li flag=1,tp=h[i];

        for(li v:graph[i])
        {
            if(h[v]>=tp)
            {
                flag=0;
            }
        }

        if(flag)
            ans++;
    }

    cout<<ans;

    return 0;
}

Measured memory_bytes: 9716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N,M; cin >> N >> M;
    vector<vector<int>> S(M);
    for (int i=0;i<M;i++){
        int k; cin >> k;
        S[i].resize(k);
        for (int j=0;j<k;j++){
            cin >> S[i][j];
            --S[i][j];
        }
    }
    vector<int> P(M);
    for (int i=0;i<M;i++) cin >> P[i];

    int res = 0;
    for (int bit=0;bit<(1<<N);bit++){
        bool can=true;
        for (int j=0;j<M;j++){
            int cnt=0;
            for (int id:S[j]){
                if (bit&(1<<id)) ++cnt;
            }
            if (cnt%2 != P[j]) can = false;
        }
        if (can) res++;
    }
    cout << res << endl;
    return 0;
}

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

// NOTE TO SELF // try to simplyfy the problem

#define rep(i,a,n) for (int i = a; i <= n; i++)

#define ll long long int

//const int mod=1000000007;
using namespace std;
 
/*int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
*/




int main()
{

    ll n,w;
    cin>>n>>w;
    
    ll wt[n],val[n];
    
    for(ll i=0;i<n;i++)
        cin>>wt[i]>>val[i];
    
    
    ll dp[n+1][w+1];
    
    
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=w;j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else if(wt[i-1]<=j)
                dp[i][j]= max( dp[i-1][j], val[i-1]+dp[i-1][j-wt[i-1]]);
            else
                dp[i][j]=dp[i-1][j];
            
        }
        
    }
    
    cout<<dp[n][w]<<endl;
    
    
    

}


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

using namespace std;

#define INF 1000000000
#define INFLL 0x3f3f3f3f3f3f3f3fLL 
#define EPS 10e-9
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define st first
#define nd second
#define sz(v) int(v.size())
#define all(X) (X).begin(), (X).end()
#define FOR(I, A, B) for(int I = A; I < B; I++)
#define RFOR(I, A, B) for(int I = A; I >= B; I--)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<iii> viii;
typedef vector<ll> vll;

int PD[100005][3];
int arr[100005][3];
int n;

int pd(int i, int a){
	if(i == n) return 0;
	int &mem = PD[i][a];
	if(mem != -1){
		return mem;
	}
	mem = 0;
	FOR(j, 0, 3){
		if(j == a) continue;
		mem = max(mem, arr[i][j] + pd(i+1, j));
	}
	return mem;
}

int main(){
	scanf("%d", &n);
	FOR(i, 0, n){
		FOR(j, 0, 3){
			scanf("%d", &arr[i][j]);
		}
	}
	memset(PD, -1, sizeof PD);
	int ans = 0;
	FOR(i, 0, 3){
		ans = max(ans, pd(0, i));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 10368
/*
ID: computerbox --> Huseyn Hajiyev
LANG: C++
TASK: target_mode_on
*/
#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define _CRT_SECURE_NO_WARNINGS
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#define FAST_READ ios_base::sync_with_stdio(0);
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
#define MAXN 2000
//cin.ignore (7777, '\n');

using namespace std;

#define debug(args...)(Debugger()) , args
class Debugger
{
  public:
  Debugger(const std::string& _separator=", ") :
  first(true),separator(_separator){}
  template<typename ObjectType>
  Debugger& operator,(const ObjectType& v)
  {
        if(!first)cerr<<separator;
        cerr<<v;
        first=false;
        return *this;
  }
  ~Debugger() {cerr<<endl;}      
  private:
    bool first;
    string separator;
};
 
template <typename T1, typename T2>
inline ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
   return os<<"("<<p.first<<", "<<p.second<<")";
}
template<typename T>
inline ostream &operator<<(ostream & os,const vector<T>& v)
{
    bool first=true;
    os<<"[";
    for(unsigned ll i=0;i<v.size();i++)
    {
        if(!first)os<<", ";
        os<<v[i];
        first=false;
    }
        return os<<"]";
}
template<typename T>
inline ostream &operator<<(ostream & os,const set<T>&v)
{
    bool first=true;
    os<<"[";
    for(typename set<T>::const_iterator ii=v.begin();ii!=v.end();++ii)
    {
        if(!first)os<<", ";
        os<<*ii;
        first=false;
    }
    return os<<"]";
}
template<typename T1, typename T2>
inline ostream &operator<<(ostream & os,const map<T1, T2>&v)
{
        bool first=true;
        os<<"[";
        for(typename map<T1,T2>::const_iterator ii=v.begin(); ii!=v.end();++ii)
        {
            if(!first)os<<", ";
            os<<*ii;
            first=false;
        }
        return os<<"]";
}

ll n;
int main(){
FAST_READ;
//cin.tie(0);
cin>>n;
ll cet=n/2;
ll necet=n-cet;
cout<<necet*cet<<endl;







return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
ll pow1(ll a, ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
		{
			ans=ans*a;
		}
		a=a*a;
		b=b>>1;
	}
	return ans;
}
int dp[100005];
int main()
{
	int n,k,i,j;
	cin>>n>>k;
	int a[n+1];
	for(i=1;i<=n;i++)
		cin>>a[i];
	for(i=1;i<=k;i++)
	{
		for(j=1;j<=n;j++)
			if(a[j]>i)
				continue;
			else if(!dp[i-a[j]])
			{
				dp[i] = 1;
				break;
			}
	}
	if(dp[k])
		cout<<"First"<<endl;
	else
		cout<<"Second"<<endl;
	return 0;
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

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

int main(){
  int n;
  string s;
  vector <string> v;

  scanf("%d",&n);

  REP (i, n) {
    cin >> s;
    v.push_back(s);
  }

  string now = v.at(0);
  FOR (i, 1, n) {
    bool check[51] = {0};
    REP (j, int(now.size())) {
      REP (k, int(v.at(i).size())) {
        if (now.at(j) == v.at(i).at(k) && check[j] == 0) {
          v.at(i).erase(k, 1);
          check[j] = 1;
        }
      }
    }
    RREP (k, int(now.size())) {
      if (check[k] == 0) {
        now.erase(k, 1);
      }
    }
  }
  sort(now.begin(), now.end());
  cout << now << "\n";

}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    string s;
    cin >> s;
    ll n = s.length();
    ll dp[n][4];
    if (s[0] == 'A') {
        dp[0][0] = 1;
        dp[0][1] = 1;
        dp[0][2] = 0;
        dp[0][3] = 0;
    } else if (s[0] == 'B' || s[0] == 'C') {
        dp[0][0] = 1;
        dp[0][1] = 0;
        dp[0][2] = 0;
        dp[0][3] = 0;
    } else {
        dp[0][0] = 3;
        dp[0][1] = 1;
        dp[0][2] = 0;
        dp[0][3] = 0;
    }

    repd(i, 1, n) {
        if (s[i] == 'A') {
            dp[i][0] = dp[i - 1][0];
            dp[i][1] = dp[i - 1][1] + dp[i - 1][0];
            dp[i][2] = dp[i - 1][2];
            dp[i][3] = dp[i - 1][3];
        }
        if (s[i] == 'B') {
            dp[i][0] = dp[i - 1][0];
            dp[i][1] = dp[i - 1][1];
            dp[i][2] = dp[i - 1][2] + dp[i - 1][1];
            dp[i][3] = dp[i - 1][3];
        }
        if (s[i] == 'C') {
            dp[i][0] = dp[i - 1][0];
            dp[i][1] = dp[i - 1][1];
            dp[i][2] = dp[i - 1][2];
            dp[i][3] = dp[i - 1][3] + dp[i - 1][2];
        }
        if (s[i] == '?') {
            dp[i][0] = dp[i - 1][0] * 3;
            dp[i][1] = dp[i - 1][1] * 3 + dp[i - 1][0];
            dp[i][2] = dp[i - 1][2] * 3 + dp[i - 1][1];
            dp[i][3] = dp[i - 1][3] * 3 + dp[i - 1][2];
        }
        rep(j, 4) { dp[i][j] %= mod; }
    }

    cout << dp[n - 1][3] << endl;
    return 0;
}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

struct UnionFind {
  vi32 par;
  UnionFind(int n) {
    par = vi32(n + 1);
    iota(all(par), 0);
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    par[x] = y;
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
};

void solve() {
  int N, K, L;
  cin >> N >> K >> L;
  auto uf1 = UnionFind(N);
  auto uf2 = UnionFind(N);
  rep(i, K) {
    int p, q;
    cin >> p >> q;
    uf1.unite(p, q);
  }
  rep(i, L) {
    int r, s;
    cin >> r >> s;
    uf2.unite(r, s);
  }
  using P = pair<int, int>;
  map<P, int> ma;
  reps(i, N) {
    ma[P(uf1.root(i), uf2.root(i))]++;
  }
  vi32 ans(N);
  reps(i, N) {
    ans[i - 1] = ma[P(uf1.root(i), uf2.root(i))];
  }
  cout << ans << '\n';
}


Measured memory_bytes: 14336
#include <cstdio>
#include <numeric>
 
int const N = 1000001;
 
int spf[N], u[N], s[17], d, i, j, k;
char const* r = "pairwise";
 
int main() {
    while (++i < N) spf[i] = i;
    for (i = 2; i * i < N; i++)
        for (j = i * i; j < N; j += i)
            if (spf[j] == j) spf[j] = i;
    for (scanf("%*d"); ~scanf("%d", &j); k = 0) {
        d = std::gcd(d, j);
        for (; j > 1; j /= i)
            if (u[s[k++] = i = spf[j]]) r = "setwise";
        while(k--) u[s[k]] = 1;
    }
    printf("%s coprime\n", d > 1 ? "not" : r);
    return 0;
}


Measured memory_bytes: 9508
#include<iostream>
using namespace std;
int main()
{
	int H, W, i, k;
	while(1)
	{	
		cin >> H >> W;
		if ( H == 0 && W == 0 )break;
		else
		{	
			for ( i = 0; i < H; i++)
			{
				for ( k = 0; k < W; k++)
				{
					cout << "#";
				}
				cout << endl;
			}
		}
		cout << endl;
	}
	return 0;
} 

Measured memory_bytes: 1152
import java.util.*;

public class Main {

  private static void solve(String X, int N) {
    char[] A = X.toCharArray();
    int bitCnt = 0;
    for (char c : A) {
      if (c == '1') {
        bitCnt++;
      }
    }
    if (bitCnt == 0) {
      for (int i = 0; i < N; i++) {
        System.out.println(1);
      }
    } else {
      int[] pow1 = new int[N];
      int[] pow0 = new int[N];
      pow1[0] = 1;
      pow0[0] = 1;
      for (int i = 1; i < N; i++) {
        pow1[i] = (2 * pow1[i - 1]) % (bitCnt + 1);
        if (bitCnt == 1) continue;
        pow0[i] = (2 * pow0[i - 1]) % (bitCnt - 1);
      }
      int sum1 = 0;
      int sum0 = 0;
      for (int i = 0; i < N; i++) {
        if (A[i] == '1') {
          sum1 = (sum1 + pow1[N - 1 - i]) % (bitCnt + 1);
          if (bitCnt == 1) continue;
          sum0 = (sum0 + pow0[N - 1 - i]) % (bitCnt - 1);
        }
      }
      for (int i = 0; i < N; i++) {
        if (A[i] == '1') {
          if (bitCnt == 1) {
            System.out.println(0); // val % 1 = 0
            continue;
          }
          int val = (sum0 - pow0[N - 1 - i] + (bitCnt - 1)) % (bitCnt - 1);
          System.out.println(getStepsCnt(val));
        } else {
          int val = (sum1 + pow1[N - 1 - i]) % (bitCnt + 1);
          System.out.println(getStepsCnt(val));
        }
      }
    }
  }

  private static int getStepsCnt(int val) {
    int cnt = 1;
    while (val > 0) {
      val = val % Integer.bitCount(val);
      cnt++;
    }
    return cnt;
  }

  public static void main(String[] args) {
    int N = scanner.nextInt();
    String X = scanner.next();
    solve(X, N);
  }

  private static final Scanner scanner = new Scanner(System.in);
}


Measured memory_bytes: 61548
#include <iostream>
using namespace std;
typedef long long ll;
ll n,cnt=2,ans;
int main(void){
    cin>>n;
    if(n%2==1){
        cout<<0<<endl;
        return 0;
    }
    while(n/5>=cnt){
        cnt*=5;
        ans+=n/cnt;
    }
    cout<<ans<<endl;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  cout << (a[1] - a[0]) / 2 + ((a[1] - a[0]) % 2) * 2 + (a[2] - a[1]) << '\n';
  return 0;
}


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

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

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size(), c = 0;
  REP(i, n) {
    if(s.at(i) != t.at(i)) c++;
  }
  cout << c << endl;
}

Measured memory_bytes: 3920
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
using namespace std;


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

  return 0;
}








// EOF

Measured memory_bytes: 2988
#include <iostream>
#include <string>

using namespace std;

int const NMAX = 1e5;
int v[1 + NMAX];

int main() {

  int n, pos = 1, p = 1e9, ans = 1e9;
  string bigG;
  cin >> n;
  if(n <= 100 * (n / 100) + 10 * (n / 100) + 1 * (n / 100)){
    cout << 100 * (n / 100) + 10 * (n / 100) + 1 * (n / 100);
  }else{
    cout << 100 * (n / 100 + 1) + 10 * (n / 100 + 1) + 1 * (n / 100 + 1);
  }
  return 0;
}


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

using namespace std;

int main()
{
    int n, a[100];
    cin >> n;

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

    int diff = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(i == j) continue;
            diff = max(diff, abs(a[i]-a[j]));
        }
    }

    cout << diff << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
 #include<algorithm>
 #include<cmath>
 #include<iomanip>
 #include<cstring>
 #include<cmath>
 #include<map>
 #include<vector>
 #include<sstream>
 #include<queue>
using namespace std;

typedef long long ll;
const ll maxn=1e18;

char ch[10];

int main()
{
    ll a;
    cin>>a;
    
   
    cin>>ch;
    
    ll c=(ch[0]-'0')*100+(ch[2]-'0')*10+(ch[3]-'0');
    
    cout<<a*c/100;
    
}

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

using namespace std;

int main()
{
	int N, A; vector<int> C;

	while (true)
	{
		cin >> N;

		if (N == 0) { break; }

		C = vector<int>(10, 0);

		for (int i = 0; i < N; i++)
		{
			cin >> A;

			C[A]++;
		}

		for (int i = 0; i < 10; i++)
		{
			if (C[i] == 0)
			{
				cout << '-' << endl;
			}
			else
			{
				for (int j = 0; j < C[i]; j++)
				{
					cout << '*';
				}

				cout << endl;
			}
		}
	}

	return 0;
}

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

using namespace std;

#define LL long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",&x)
#define rep(i,a,b) for(int i = a ; i <= b ; i++)
#define per(i,a,b) for(int i = b ; i >= a ; i--)
#define mem(a) memset(a,0,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const LL INF = 5e18;
const int mod = 1e4 + 7;
const int maxn = 2e5 + 7;

int n;

void dfs(string s,char ch) {
    if(s.size() == n) {
        cout << s << endl;
        return ;
    } else {
        for(char i = 'a' ; i <= ch ; i++) {
            dfs(s + i , (i == ch ? (ch + 1) : ch));
        }
    }
}

int main() {
    while(~sd(n)) {
        dfs("",'a');
    }
    return 0;
}


Measured memory_bytes: 1536