akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;

void solve() {
	int n; cin >> n;
	int a; cin >> a;
	int b; cin >> b;
	vector<string> check_num;
	for (int i = 1; i <= n; ++i) {
		check_num.push_back(to_string(i));
	}
	int sum = 0;
	int ans = 0;
	for (unsigned int i = 0; i < check_num.size(); ++i) {
		int sum = 0;
		string tmp = check_num[i];
		for (unsigned int j = 0; j < tmp.length(); ++j) {
			sum += (tmp[j] - '0');
		}
		if (sum < a || sum > b) {
			continue;
		}	
		ans += (i + 1);	
	}
	cout << ans << endl;
	return;
}

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

Measured memory_bytes: 768
n, W = map(int, input().split())
w, v = [], []
for _ in range(n):
    a, b = map(int, input().split())
    w.append(a)
    v.append(b)

dp = [[0 for _ in range(W+1)] for _ in range(n+1)]
for i in range(1, n+1):
    for j in range(0, W+1):
        if j - w[i-1] >= 0:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1])
        else:
            dp[i][j] = dp[i-1][j]

print(dp[n][W])

Measured memory_bytes: 171784
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, p;
    string s;
    cin >> n >> p >> s;
    ll ans = 0;
    if (p == 2) {
        REP(i, n) if ((int)(s[i] - '0')
% 2 == 0) ans += i + 1;
        cout << ans << endl;
        return;
    } else if (p == 5) {
        REP(i, n) if ((int)(s[i] - '0')
% 5 == 0) ans += i + 1;
        cout << ans << endl;
        return;
    }
    vi r(n);
    int d = 1;
    r[n - 1] = (int)(s[n - 1] - '0') % p;
    for (int i = n - 2; i >= 0; i--) {
        d = (d * 10) % p;
        r[i] = (r[i + 1] + (int)(s[i] - '0') * d) % p;
    }
    // printv(r);
    map<int, ll> m;
    m[0]++;
    for (auto q : r) m[q]++;
    for (auto e : m) if (e.second > 1) ans += e.second * (e.second - 1) / 2;
    cout << ans << endl;
}


Measured memory_bytes: 1812
#define DEBUG 0
/**
 * File    : A.cpp
 * Author  : Kazune Takahashi
 * Created : 2019/9/7 20:25:19
 * Powered by Visual Studio Code
 */
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
using ll = long long;
class mint
{
public:
  static ll MOD;
  ll x;
  mint() : x(0) {}
  mint(ll x) : x(x % MOD) {}
  mint operator-() const { return x ? MOD - x : 0; }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= MOD)
    {
      x -= MOD;
    }
    return *this;
  }
  mint &operator-=(const mint &a) { return *this += -a; }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator/=(const mint &a)
  {
    mint b{a};
    return *this *= b.power(MOD - 2);
  }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
  const mint power(ll N)
  {
    if (N == 0)
    {
      return 1;
    }
    else if (N % 2 == 1)
    {
      return *this * power(N - 1);
    }
    else
    {
      mint half = power(N / 2);
      return half * half;
    }
  }
};
ll mint::MOD = 1e9 + 7;
istream &operator>>(istream &stream, mint &a) { return stream >> a.x; }
ostream &operator<<(ostream &stream, const mint &a) { return stream << a.x; }
class combination
{
public:
  vector<mint> inv, fact, factinv;
  static int MAX_SIZE;
  combination() : inv(MAX_SIZE), fact(MAX_SIZE), factinv(MAX_SIZE)
  {
    inv[1] = 1;
    for (auto i = 2; i < MAX_SIZE; i++)
    {
      inv[i] = (-inv[mint::MOD % i]) * (mint::MOD / i);
    }
    fact[0] = factinv[0] = 1;
    for (auto i = 1; i < MAX_SIZE; i++)
    {
      fact[i] = mint(i) * fact[i - 1];
      factinv[i] = inv[i] * factinv[i - 1];
    }
  }
  mint operator()(int n, int k)
  {
    if (n >= 0 && k >= 0 && n - k >= 0)
    {
      return fact[n] * factinv[k] * factinv[n - k];
    }
    return 0;
  }
};
int combination::MAX_SIZE = 3000010;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
// constexpr double epsilon = 1e-10;
// constexpr ll infty = 1000000000000000LL;
// constexpr int dx[4] = {1, 0, -1, 0};
// constexpr int dy[4] = {0, 1, 0, -1};
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}
void No()
{
  cout << "No" << endl;
  exit(0);
}

int main()
{
  int N;
  cin >> N;
  cout << N * N * N << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int[] c = new int[26];
		for(int i = 0; i < 26; i++) {
			c[i] = sc.nextInt();
		}
		int[][] s = new int[d][26];
		for(int i = 0; i < d; i++) {
			for(int j = 0; j < 26; j++) {
				s[i][j] = sc.nextInt();
			}
		}
		int[] lastDay = new int[26];
		for(int i = 0; i < 26; i++) {
			lastDay[i] = 0;
		}
		long max = 0;
		for(int i = 0; i < d; i++) {
			int t = sc.nextInt()-1;
			max += s[i][t];
			lastDay[t] = i+1;
			for(int j = 0; j < 26; j++) {
				if(j != t) {
					max -= c[j] * (i+1-lastDay[j]);
				}
			}
			System.out.println(max);
		}
	}
}


Measured memory_bytes: 46896
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define BUF_SIZE 15

int comp(const void* a, const void* b) {
  return *(int*)a - *(int*)b;
}

int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, fp)) return 0;

  int arr[3];
  sscanf(line, "%d %d %d", &arr[0], &arr[1], &arr[2]);

  qsort(arr, 3, sizeof(int), comp);
  int res = 0;
  int mod = (arr[1]-arr[0])&1;
  // 2 6 3
  // 5 6 6
  res += arr[2] - arr[1];
  // (6-5)/2 + plus 2;
  res += (arr[2] - (arr[0]+res))/2 + mod*2;

  printf("%d\n", res);

  return 0;
}

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

#define N 200050
#define mod 1000000007
#define ll long long

ll dp1[N],dp2[N];

int n,arr[N];
vector<int>vc;

int main()
{
    scanf("%d",&n);
    arr[0]=-1;
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&arr[i]);
        if(arr[i]!=arr[i-1]) vc.push_back(arr[i]);
    }
    n=vc.size();
    dp1[n+1]=1;
    for(int i=n; i>=1; i--)
    {
        int x=vc[i-1];
        dp1[i]=dp1[i+1];
        dp1[i]%=mod;
        dp1[i]+=dp2[x];
        dp1[i]%=mod;
        dp2[x]+=dp1[i+1];
        dp2[x]%=mod;
    }
    printf("%lld\n",dp1[1]);

}


Measured memory_bytes: 5108
# E - Product of Arithmetic Progression

import sys
input = sys.stdin.buffer.readline

Q = int(input())
MOD = 10**6 + 3

# a//b (MOD p)
def div_mod(a, b, p=MOD):
    return (a * pow(b, p-2, p)) % p

factorial_memo = [1, 1]
for i in range(2, MOD):
    factorial_memo.append((factorial_memo[-1] * i) % MOD)

def factorial(x, p=MOD):
    if x < p:
        return factorial_memo[x]
    else:
        return 0


for _ in range(Q):
    x, d, n = map(int, input().split())
    if x == 0 and d == 0:
        print(0)
    elif x == 0:
        ans = factorial(n-1)
        ans *= pow(d, n-1, MOD)
        ans %= MOD
        print(ans)
    elif d == 0:
        print(pow(x, n, MOD))
    else:
        ans = pow(d, n, MOD)
        x_divided_by_d = div_mod(x, d, MOD)
        ans *= factorial(x_divided_by_d + (n-1))
        ans %= MOD
        ans = div_mod(ans, factorial(x_divided_by_d - 1), MOD)
        print(ans)

Measured memory_bytes: 45416
#include<iostream>
#define repr(i,n) for(int i=1;i<=n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long 
using namespace std;

int main()
{
	int l,r,d;
	cin>>l>>r>>d;
	int res=0;
	
	for(int i=l;i<=r;i++)
	if(i%d==0)res++;
	cout<<res<<"\n";
	return 0;
 } 

Measured memory_bytes: 3196
#include<iostream>
#include<cstdio>
typedef long long ll;
const int N=2e5+5;
ll abs(ll x) {
    return x>0?x:-x;
}
int n;ll a[N];
int main() {
    scanf("%d",&n);ll ans=1e18;
    int l=1,r=3;
    for(int i=1;i<=n;i++) scanf("%lld",a+i),a[i]+=a[i-1];
    for(int i=2;i+2<=n;i++) {
        while(l+1<i&&abs(a[i]-a[l]*2)>=abs(a[i]-a[l+1]*2)) ++l;
        while(r+1<n&&abs(a[n]-a[i]-(a[r]-a[i])*2)>=abs(a[n]-a[i]-(a[r+1]-a[i])*2)) ++r;
        ans=std::min(ans,std::max(std::max(a[l],a[i]-a[l]),std::max(a[r]-a[i],a[n]-a[r]))-std::min(std::min(a[l],a[i]-a[l]),std::min(a[r]-a[i],a[n]-a[r])));
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
	int A;
	int flag1=0,flag2=0;
	for(int i=0;i<3;i++){
		cin>>A;
		if(A==5)
			flag1++;
		if(A==7)
			flag2++;
	}
	if(flag1==2&&flag2==1)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef unsigned long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const double EPS = 1e-6;
const int MAX = 300 + 47;

int A[MAX];
double DP[1 << 7][MAX][MAX];


int main()
{
    int n, c;
    cin >> n >> c;
    FOR(i, 0, n)
        cin >> A[i];
    int tot = n * c;
    int mx = 1 << (n-1);
    sort(A, A + n);
    reverse(A, A+ n);
    reverse(A+1, A + n);
    double ans = 0;
    int k = 0;
    do
    {
        FOR(_msk, 0, mx)
        {
            int msk  = 2 * _msk + 1;
            FOR(i, 0, tot)
                FOR(j, 0, tot+1)
                    DP[msk][i][j] = 0;
        }
        
        DP[1][0][A[0] * n] = 1;

        FOR(_msk, 0, mx)
        {
            int msk = 2 * _msk + 1;
            FOR(i, 0, tot)
                FOR(j, i, tot+1)
                {
                    double val = DP[msk][i][j];
                    if (i < j)DP[msk][i+1][j] += val;
                    int arc = i % n;
                    if (msk & (1<<arc)) continue;
                    int nmsk  = msk | (1 << arc);
                    int jj = max(j, A[arc] * n + i);
                    jj = min(jj, tot);
                    val /= c;
                    DP[nmsk][i][jj] += val;
                }
        }
        ans += DP[2 * mx - 1][tot - 1][tot];
        
        k++;
    } while(next_permutation(A +1 , A + n - 1 + 1));
    ans /= k;
    cout << fixed << setprecision(11) << ans << endl;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define PI 3.1415926535

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

   int max_val = 0;
   rep(i, n.size()) max_val += (n.at(i) - '0');

   int ans = n.at(0) - '1'; //一引いた数
   for (int i = 1; i < n.size(); i++)
      ans += 9;
   ans = max(ans, max_val);

   cout << ans << endl;

   return 0;
}


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

void z_func(const string &p,vector<int> &z)
{
	int n=p.size();
	z.assign(n,0);
	for(int l=0,r=0,i=1;i<n;i++)
		if(r>=i && z[i-l]<r-i+1)
			z[i]=z[i-l];
		else
		{
			if(i>r)
				r=i;
			for(l=i;r<n && p[r-l]==p[r];)
				r++;
			z[i]=r-l;
			r--;
		}
}

int find(const string &s,const string &t)
{
	int m=t.size();
	string r=t+"|"+s;
	vector<int> z;
	z_func(r,z);
	vector<int> dp(z.size()+1);
	for(int i=m; i < z.size(); i++)
		if(z[i] == m) dp[i+m]= dp[i]+1;
	return *max_element(dp.begin(),dp.end());
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s,t;
	cin>>s>>t;
	string r=s;
	while(r.size()<=(s.size()+t.size()) * 2)
		r+=s;
	int ans=find(r,t);
	if(find(r+r,t)!= ans)
		ans=-1;
	cout<<ans<<endl;
	return 0;
}

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

void solve()
{
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] != t[i])
        {
            ans++;
        }
    }
    cout << ans << endl;
}

int main()
{
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


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

int main() {
    int r, c;
    cin >> r >> c;

    int last_row[c] = {};
    for (int i = 0; i < r; i++) {
        int row_sum = 0;
        for (int j = 0; j < c; j++) {
            int x;
            cin >> x;
            row_sum += x;
            last_row[j] += x;
            cout << x;
            if (j == c-1) {
                cout << " " << row_sum;
                cout << endl;
            } else {
                cout << " ";
            }
        }
    }
    int sum = 0;
    for (int i = 0; i < c; i++) {
        sum += last_row[i];
        cout << last_row[i];
        if (i == c-1) {
            cout << " " << sum;
            cout << endl;
        } else {
            cout << " ";
        }
    }
}


Measured memory_bytes: 3092
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int  a,b,c;
	cin>>a>>b>>c;
	if (a < b && b < c)
	cout <<"Yes"<<endl;
	else
	cout <<"No"<<endl;
	
	return 0;
	
	 
}




Measured memory_bytes: 3076
from collections import defaultdict
from collections import deque
n , m = map(int , input().split())
g = defaultdict(list)
for i in range(m):
	u , v = map(int , input().split())
	g[u].append(v)
	g[v].append(u)
#print(g)
visited = [False]*(n+1)
a = [10**10]*(n+1)
q = deque()
q.append(1)
while q:
	node = q.popleft()
	visited[node] = True
	for ele in g[node]:
		if not visited[ele]:
			if a[ele] != 10**10: 
				continue
			a[ele] = node
			q.append(ele)
#print(ans)
#print(a)
print("Yes")
for i in a[2:]:
	print(i)


Measured memory_bytes: 39956
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

int main() {
  int N;
  string S;
  cin >> N >> S;
  // f : 場所 
  // s : その場所より前にある'M'の個数
  vector<int> Df;
  vector<int> Cf;
  vector<int> Ds;
  vector<int> Cs;
  int Mcnt = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'D') {
      Df.push_back(i);
      Ds.push_back(Mcnt);
    } else if (S[i] == 'C') {
      Cf.push_back(i);
      Cs.push_back(Mcnt);
    } else if (S[i] == 'M') {
      Mcnt++;
    }
  }

  int Dsz = Df.size();
  int Csz = Cf.size();
  BIT<ll> bit(Csz);

  for (int i = 0; i < Csz; i++) {
    bit.add(i,Cs[i]);
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int k;
    cin >> k;
    ll ans = 0;
    for (int i = 0; i < Dsz; i++) {
      ll l = lower_bound(Cf.begin(),Cf.end(),Df[i]) - Cf.begin();
      ll r = lower_bound(Cf.begin(),Cf.end(),Df[i]+k) - Cf.begin() - 1;
      ll res = bit.sum(l,r+1);
      res -= Ds[i] * (r - l + 1);
      ans += res;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 21072
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[10001],dp[100][100];

int main(){
  cin >> n;
  m = n/50;
  l = n%50;
  print(50);
  for(ll i = m,j = 1;j <= 50;i++,j++){
    if(j <= 50-l)cout << i << " ";
    else cout << i+1 << " ";
  }
  puts("");
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<iostream>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <cstring>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <sstream>
#include <map>
#include <unordered_map>
#include <vector> 
#include <bitset>
#include <cctype>
#include <set>
#include <stack>
#include <queue>
#include <fstream>
#include <numeric>
#include <random>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAXN = 300005;
const int MAXM = 50005;
const int MOD = 1e9+7;

#define MP make_pair
#define INF 0x3f3f3f3f
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mst(X,Y) memset(X,Y,sizeof(X)) 
#define rep(i, a, n) for (int i=(a); i<=(n); i++)
#define per(i, a, n) for (int i=(a); i>=(n); i--)
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) { cerr << " " << to_string(H);    debug_out(T...);}


struct Node{
    int cr;
    int val;
    bool operator< (const Node& x)const 
    {
        return val > x.val;
    }
};
int r[MAXN];
int c[MAXN];
map<pii,int> mp;
int main()
{closeSync;
#ifdef DEBUG
	//freopen("C:/Users/86159/Desktop/a2.in.txt", "r", stdin);
	//freopen("C:/Users/86159/Desktop/output.txt", "w", stdout);
#endif
	//clock_t c1 = clock();
    int h,w,k;
    cin>>h>>w>>k;
    rep (i,1,k)
    {   
        int hh,ww;
        cin>>hh>>ww;
        mp[MP(hh,ww)]++;
        r[hh]++,c[ww]++;
    }
    vector<Node> vr;
    vector<Node> vc;
    rep (i,1,h)
        if (r[i])
            vr.push_back({i,r[i]});
    rep (i,1,w)
        if (c[i])
            vc.push_back({i,c[i]});
    sort(vr.begin(),vr.end());
    sort(vc.begin(),vc.end());
    int endr = vr.size() - 1,endc = vc.size() - 1;
    int tick1 = 1,tick2 = 1;
    while (tick1<=endr && vr[tick1].val == vr[tick1-1].val)
        tick1++;
    while (tick2<=endc && vc[tick2].val == vc[tick2-1].val)
        tick2++;
    int ans = -1;
    rep (i,0,tick1-1)
    {
        Node cur = vr[i];
        rep (j,0,tick2-1)
        {
            ans = max(ans,   cur.val + vc[j].val - mp[MP(cur.cr,vc[j].cr)]  );
            if (!mp[MP(cur.cr,vc[j].cr)])
                break;
        }
    }
    cout<<ans<<endl;

    //cerr << "Time:" << clock() - c1 << "ms" <<endl;
    return 0;
}

Measured memory_bytes: 47728
/*{{{*/
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>

typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORR(i,a,b) for(ll i=b-1;i>=a;i--)

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;
/*}}}*/

int main() {
  ll h1,m1,h2,m2,k;
  stringstream ss;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  ll timel = 60 * h2 + m2;
  ll timef = 60 * h1 + m1;
  ll ans = timel - timef - k;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e9;
const long double PI=acos(-1);



void solve(int T){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int tmp=a[i]+a[j];
            auto it=lower_bound(a.begin(),a.end(),tmp);
            int tmp2=it-a.begin();
            //cout<<tmp2-j<<" ";
            ans+=max(0,tmp2-j-1);
        }
    }
    cout<<ans<<"\n";
}

int main() {
    //fastio

    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;

#define fr first
#define sc second
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)

vector<P> ret;

void pos(int i){
	for(int j=0;j<i;j++){
		ret.push_back(P(j+1,0));
	}
	ret.push_back(P(i,1));
	ret.push_back(P(i+1,1));
	ret.push_back(P(i+1,0));
	ret.push_back(P(i,0));
	for(int j=i-1;j>=0;j--){
		ret.push_back(P(j,0));
	}
}
void neg(int i){
	for(int j=0;j<i;j++){
		ret.push_back(P(j+1,0));
	}
	ret.push_back(P(i+1,0));
	ret.push_back(P(i+1,1));
	ret.push_back(P(i,1));
	ret.push_back(P(i,0));
	for(int j=i-1;j>=0;j--){
		ret.push_back(P(j,0));
	}
}

vector<P> f(vector<P> vec,int t){
	int cnt[300]={};
	for(int i=0;i<vec.size();i++){
		cnt[vec[i].sc]++;
	}
	int MIN=100;
	int id=-1;
	for(int i=0;i<300;i++){
		if(cnt[i]==0)continue;
		if(MIN>cnt[i]){
			MIN=cnt[i];
			id=i;
		}
	}
	//cerr<<"id="<<id<<endl;
	vector<P> ret;
	for(int i=0;i<vec.size();i++){
		if(vec[i].sc!=id)ret.push_back(vec[i]);
		else {
			if(vec[i].fr==1){
				ret.push_back(P(1,id));
				ret.push_back(P(1,t));
				ret.push_back(P(-1,id));
				ret.push_back(P(-1,t));
			}
			else {
				ret.push_back(P(1,t));
				ret.push_back(P(1,id));
				ret.push_back(P(-1,t));
				ret.push_back(P(-1,id));
			}
		}
	}
	return ret;
}

bool zero(vector<P> vec, int x){
	stack<P> st;
	for(P p: vec){
		if((x>>p.sc)&1){
			if(st.size()==0){
				st.push(p);
				continue;
			}
			P q=st.top();
			if(q.sc==p.sc&&p.fr+q.fr==0)st.pop();
			else st.push(p);
		}
	}
	return st.size()==0;
}

int main(){
	int n;
	string s;
	cin>>n>>s;
	
	int a[300];
	for(int i=0;i<(1<<n);i++)a[i]=s[i]-'0';
	
	bool used[300];
	memset(used,0,sizeof used);
	
	int b[300];
	for(int i=0;i<300;i++)b[i]=1;
	
	for(int x=1;x<(1<<n);x++){
		used[x]=true;
		for(int y=0;y<x;y++){
			if((x&y)==y)if(used[y])used[x]=false;
		}
		for(int y=0;y<(1<<n);y++){
			if((x&y)==x)if(a[y]==1)used[x]=false;
		}
		if(used[x]){
			for(int y=0;y<(1<<n);y++){
				if((x&y)==x)b[y]=0;
			}
		}
	}
	
	bool ok=true;
	for(int i=0;i<(1<<n);i++)ok&=a[i]==b[i];
	if(!ok){
		puts("Impossible");
		return 0;
	}
	vector<P> vv;
	/*for(int x=0;x<(1<<n);x++){
		if(!used[x])continue;
		if(vv.size()==0){
			vv.push_back(P(1,x));
		}
		else{
			vv=f(vv,x);
		}
	}*/
	vector<P> vec[300];
	ret.push_back(P(0,0));
	for(int x=0;x<(1<<n);x++){
		if(!used[x])continue;
		if(zero(vv,x)){
			int cnt=0;
			int c[10];
			for(int i=0;i<n;i++){
				if((x>>i)&1)c[cnt++]=i;
			}
			vec[x].push_back(P(1,c[0]));
			for(int i=1;i<cnt;i++)vec[x]=f(vec[x],c[i]);
			vv.insert(vv.end(),vec[x].begin(),vec[x].end());
		}
	}
	for(P p: vv){
		if(p.fr==1)pos(p.sc);
		else neg(p.sc);
	}
	
	/*vector<P> ret2;
	for(P p: ret){
		if(ret2.size()>=2&&ret2[ret2.size()-2]==p)ret2.pop_back();
		else ret2.push_back(p);
	}
	ret=ret2;*/
	
	assert(ret.size()<=250000);
	
	puts("Possible");
	printf("%d\n",(int)(ret.size())-1);
	for(int i=0;i<ret.size();i++){
		printf("%d %d\n",ret[i].fr,ret[i].sc);
	}
}

Measured memory_bytes: 640
MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))

n_bit = max(a).bit_length()
b = [(1 << j) % MOD for j in range(n_bit)]

ans = 0
bit = [0] * n_bit
for i in range(n):
    for j in range(n_bit):
        if (a[i] >> j) & 1:
            ans += b[j] * (i - bit[j])
            bit[j] += 1
        else:
            ans += b[j] * bit[j]
        ans %= MOD

print(ans)


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

int main()
{
  int n, k, div = 0, ans = 0;
  cin >> n >> k;
  
  vector<int> num(n, 0);
  for (int i = 0; i < n; i++)
  {
    int t;
    cin >> t;
    if (num[t - 1] == 0) div++;
    num[t - 1]++;
  }

  sort(num.begin(), num.end());

  for (auto i : num)
  {
    if (div <= k) break;

    if (i != 0)
    {
      ans += i;
      div--;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
import heapq
from itertools import groupby, islice

s = input()
n = int(input())

def substrings_starting_at(i):
  return (s[i:j+1] for j in range(i, len(s)))

gens = [substrings_starting_at(i) for i in range(len(s))]
sm = heapq.merge(*gens)
res, _ = next(islice(groupby(sm), n-1, n))
print(res)

Measured memory_bytes: 8044
#import<bits/stdc++.h>
using namespace std;
int i,j,k,m,n,s,w[100005];
main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	cout<<(n-1)/m+1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;

vector<pair<ll,ll>> prime_factorize(ll N){
    vector<pair<ll,ll>> res;
    for(ll i=2;i*i<=N;i++){
        if(N%i!=0) continue;
        ll ex=0;
        while(N%i==0){
            ex++;
            N/=i;
        }
        res.push_back({i,ex});
    }
    if(N!=1)res.push_back({N,1});
    return res;
}

int main() {
    ll n,p;
    cin >> n >> p;
    vector<pair<ll,ll>>num=prime_factorize(p);
    ll ans=1;
    for(auto x:num){
        ll ex=x.second;
        while(ex>=n){
            ans*=x.first;
            ex-=n;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
// 166 A

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>

using namespace std;

int main(){
    string str;
    cin >>str;
    if(str == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3596
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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 main(void){
    int N,K; cin >> N >> K;
    ll x[N],y[N],maxy=0; REP(i,N){cin >> x[i] >> y[i];}
    vector<pair<ll,int>> vx, tmpy;
    REP(i,N){
        vx.push_back(pair<ll,int>(x[i],i));
        tmpy.push_back(pair<ll,int>(y[i],i));
    }
    SORT(vx); SORT(tmpy);
    ll ans = (vx[N-1].first-vx[0].first)*(tmpy[N-1].first-tmpy[0].first);
    REP(i,N-K+1)FOR(j,i+K-1,N){
        vector<ll> vy;
        FOR(k,i,j+1) vy.push_back(y[vx[k].second]);
        SORT(vy);
        int ny = j-i+1;
        ll yoko=vx[j].first-vx[i].first;
        REP(a,ny-K+1){
            ll tate = vy[a+K-1]-vy[a];
            chmin(ans, tate*yoko);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926

typedef long long int ll;

//ll num[ten52];
//ll num[10][10];

int main(void)
{
    long long int sum=0,range=0,ceiling;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=0,money;
    long long int a,a1=0,a2=0,a3=0,ar,as,at1;
    char c;
    a=a1=a2=a3=0;
    //vector <int> v;
    //float f,g,h;
    //int c,d,big=0;
    string s,s1,s2;
    cin>>s;
    a=s.size();
    for(i=0;i<a;i++) cout<<'x';
    return 0;
}





Measured memory_bytes: 256
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


# sys.setrecursionlimit(10**5)


def main():
    h, a = geta(int)

    print((h + a - 1) // a)


if __name__ == "__main__":
    main()

Measured memory_bytes: 38256
N = int(input())
max_cnt = 0
ans = 0
for n in range(1, N+1):
    cnt = 0
    for div in range(0, 7):
        if n % 2**div == 0:
            cnt += 1
    if cnt > max_cnt:
        max_cnt = cnt
        ans = n
print(ans)

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

using namespace std;

int main(){
	int N,K;
	cin>>N>>K;
    vector <int>L(N);
    for(int i=0 ; i<N ; i++){
        cin>>L[i];
    }
	int sum=0;
	int count=0;
	
	sort(L.begin(),L.end());
	for(int i=L.size()-1 ; ; i--){
		sum+=L[i];
		count+=1;
		if(count==K)break;
	}
	cout<<sum<<"\n";
	
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<int> order(N+1);

    for (int i = 1; i <= N; i++){
        int A;
        cin >> A;
        order[A] = i;
    }

    for (int i = 1; i <= N; i++){
        cout << order[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <limits.h>
using namespace std;

int main()
{
    int x,y;
    cin >> x >> y;
   
    for(int i=0; i<=x; i++){
        int kame = i;
        int turu = x - i;
        int ans = kame*4 + turu*2;
        if(ans == y){
            cout <<"Yes" << endl;
            return 0;
        }
    }
    cout <<"No" << endl;
    return 0;
}

Measured memory_bytes: 3632
import sys
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np

def main():
	ans=0
	n=II()

	for i in range(1,n+1):
		ans+=i*(n+1-i)
	for _ in range(n-1):
		a,b=MI()
		if a>b:
			a,b=b,a
		ans-=a*(n+1-b)
	print(ans)



if __name__ == "__main__":
	main()


Measured memory_bytes: 68504
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
class Pair implements Comparable<Pair>
{
	int n;
	int dis;
	public Pair(int x,int d)
	{
		this.n=x;
		this.dis=d;
	}
	public int compareTo(Pair p)
	{
		if(this.dis>p.dis)
			return 1;
		else if(this.dis<p.dis)
			return -1;
		return 0;
	}
}
public class Main{
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}                                              
		return ans;
	} 
    public static void main(String[] args) throws Exception {
        br = new BufferedReader(new InputStreamReader(System.in));
        int[] ar=split();
        int n=ar[0];
        int d=ar[1];
        int ans=0;
        for(int i=0;i<n;i++)
        {
        	String[] cmd=br.readLine().split(" ");
        	long x=Long.valueOf(cmd[0]);
        	long y=Long.valueOf(cmd[1]);
        	long z=x*x+y*y;
        	double f=Math.sqrt(z);
        	if(f<=d)
        		ans++;
        }
        System.out.println(ans);
    }
}


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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define dbg(x) std::cerr<<#x<<" = " << (x) << std::endl
#define pnl(x) std::cout << x << "\n"

typedef	std::vector<int>	vi;
typedef std::pair<int,int>	ii;
typedef std::vector<std::string>	vs;
typedef std::vector<ii>	vii;
typedef std::vector<long long>	vl;
typedef	long long ll;


const int	NB_D = 4;
const int	DY[] = {-1, 1, 0, 0};
const int	DX[] = {0, 0, -1, 1};

struct Train
{
	int	c, s, f;
};

int		main(void)
{
	std::ios_base::sync_with_stdio(false);
	int	N;
	std::cin >> N;
	std::vector<Train> 	a(N - 1);
	for (auto& v : a)
		std::cin >> v.c >> v.s >> v.f;
	
	for (int i(0); i < N - 1; ++i)
	{
		int	cur = a[i].c + a[i].s;
		for (int k(i + 1); k < N - 1; ++k)
		{
			while (cur < a[k].s or cur % a[k].f != 0)
				++cur;
			cur += a[k].c;
		}
		pnl(cur);
	}
	pnl(0);
}



Measured memory_bytes: 256
// E - Yutori
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	int N,K,C; string S;
	cin>>N>>K>>C>>S;

	vector<int> L(N,-1), R(N,-1);

	int l_c, r_c, l_pos, r_pos;
	l_c = r_c = l_pos = r_pos = 0;

	rep(l, N){
		if(l_c > 0) l_c--;
		else{
			if(S[l] == 'o'){ L[l_pos++] = l; l_c = C; }
		}

		if(r_c > 0) r_c--;
		else{
			int r = N - l - 1;
			if(S[r] == 'o'){ R[r_pos++] = r; r_c = C; }
		}
	}

	reverse(R.begin(), R.begin() + r_pos);

	if(l_pos > K) return 0; // 働ける日に余裕があると、その日に必ず働く必要がない
	rep(i, l_pos) if(L[i] == R[i]) cout<< L[i] + 1 <<endl;
}

Measured memory_bytes: 3332
// https://atcoder.jp/contests/code-festival-2017-quala/tasks/code_festival_2017_quala_a
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    puts(regex_search(s, regex("^YAKI.*")) ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define mod 1000000007
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll ,ll> pii;
const int dx[]={-1,1,0,0};
const int dy[]={0,0,-1,1};
vi v[2*100005];
int ans=0;
int vis[2*100005];
void dfs(int s)
{
	vis[s]=true;
	ans++;
	for(auto i:v[s])
	{
		if(!vis[i])
		{
			dfs(i);
		}
	}
}
void solve()
{
	int n,m;
	cin>>n>>m;
	forn(i,m)
	{
		int a,b;
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	int mx=0;
	fora(i,1,n)
	{
		ans=0;
		if(!vis[i])
		{
			dfs(i);
		}
		mx=max(ans,mx);
	}
	cout<<mx<<endl;
	
}
int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int t=1;
  //  cin>>t;
    while(t--)
	solve();
    return 0;
}


Measured memory_bytes: 21572
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>

int main()
{
    char s[201];
    scanf("%s", s);
    int i, j, lens_ini = strlen(s), count;
    for (i=lens_ini - 1; i>=2; i--)
    {
        s[i] = '\0';
        if (strlen(s) % 2 == 0) {
            count = 0;
            for (j=0; j<=(strlen(s)/2)-1; j++)
            {
                if (s[j] == s[j + strlen(s)/2]) count ++;
            }
            if (count == strlen(s)/2) break;
        }
    }
    printf("%d\n", count*2);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
#include<string>
#include<strstream>
#include<sstream>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<set>
long long mod = 10e18;
long long is(int n)
{
	if (n == 0)
		return 2;
	if (n == 1)
		return 1;
	return (is(n - 1) + is(n - 2));
}
int main()
{
	int n, k; cin >> n >> k; int j = 1;
	j += j;
	for (int i = 2; i <= n; ++i)
	{
		if (j < k)
		{
			j += j;
		}
		else
			j += k;
	}
	cout << j;
	
}

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	int sum=0;
	vector<int> a(n);
	for (int i=0; i<n; i++)
		cin>>a[i], sum+=a[i];
	int ret=-1, best=INT_MAX;
	for (int i=0; i<n; i++) {
		int cur=abs(a[i]*n-sum);
		if(best>cur) best=cur, ret=i;
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    while(1) {
        int H,W;
        std::cin >> H >> W;

        if (H == 0 && W == 0){
            break;
            }

        for (int j = 0; j < H; j++) {
            for (int i = 0; i < W; i++) {
                std::cout << "#";
                if (i == W - 1) {
                    std::cout << std::endl;
                }
            }
        }

        std::cout << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define ppb pop_back
using namespace std;

int n,w;
vector<pair<int,int> >v;
ll dp[101][100001],ans=0;
ll solve()
{
	
	for (int i=0;i<=n;i++)
	{
		for (int j=0;j<=100000;j++) 
		{
			if (j==0) dp[i][j]=0; else
			if (i==0) dp[i][j]=1e18; else
			if (v[i-1].second<=j) dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i-1].second]+1ll*v[i-1].first); else
			dp[i][j]=dp[i-1][j];
			if (dp[i][j]<=w) ans=max(ans,1ll*j);
		}
	}
	return ans;
}
int main()
{
	ios::sync_with_stdio(false);
	
	cin>>n>>w;
	int a,b;
	for (int i=0;i<n;i++)
	{
		cin>>a>>b;
		v.pb(mk(a,b));
		//dp[i+1][b]=a;
	}
	
	cout<<solve();
	return 0;
}

Measured memory_bytes: 79232
#include<stdio.h>

int main(){

  int H,W,t,y;
  while(1){
    scanf("%d%d",&H,&W);
    if(H==0 && W==0)break;
    for(t=0;t<H;t++){
      for(y=0;y<W;y++){
       printf("#");
      }
	printf("\n");
      }
    printf("\n");
  }
    return 0;
  }

Measured memory_bytes: 572
#include<stdio.h>

int abs(int n){
  if(n < 0) n *= -1;
  return n;
}
int main(void){
  int x, a, b;

  scanf("%d %d %d", &x, &a, &b);

  if(abs(a-x) < abs(b-x)) printf("A");
  else printf("B");

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;++i)
    cin>>a[i];
    sort(a,a+n,greater<int>());
    int s=a[0],j=0;
    for(int i=1;i<n-1;++i)
    {
        s+=a[(i+1)/2];
    }
    cout<<s;

}

Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


// initialization
const int MAX = int(2e3)+10;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// binom mod MOD
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  // initialize
  COMinit();

  rep2(i, 1, k+1) {
    ll ans = COM(n-k+1, i) * COM(k-1, i-1);
    ans %= MOD;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a); i >= (b); --i)
#define sz(a) int((a).size())
#define pconent(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef long double ld;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ost;
const ll MOD =  1e13;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(v) (cout<<#v<<" = "<<v<<endl)
#define endln (cout<<endl)
template <class T> inline void dbv(T a) {  for(auto x : a){ cout<<x<<", " ;} cout<<endl;}
using namespace std;
void output(ll tx)
{
	ll n,p;
	cin>>n>>p;
	if(n==1)
	{
		cout<<p<<endl;
		return;
	}
	ll ans = 1;
	FOR(x,1,((ll)pow(5*p,1/((ld)n))+1))
	{
		ll div = fpow(x,n);
		if(p%div==0)
		{
			ans = max(ans,(ll)x);
		}
	}
	cout<<ans<<endl;
}
int main()
{
    ll t = 1;
    // cin>>t;
    FOR(i,0,t)
    {
    	// cout<<"Case #"<<(i+1)<<": ";
        output(i+1);
    }
    return 0;
}

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

const int maxn=1e5+7;
ll a[maxn];
int n;

vector<pair<ll,ll > >vec[1005];

ll dp[maxn];

int main (){
    int n,m;cin>>n>>m;
    cout<<n%m<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n, a, b;
    cin>>n>>a>>b;
    int times = n / (a + b);
    n %= (a + b);
    int ans = times * a;
    if(n > a) ans += a;
    else ans += n;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256