akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

char S[ 10 ];

int main()
{
int i;

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

	cin >> S;

	for( i = 0; i < 3; i++ )
	{
		if( S[ i ] == S[ i + 1 ] )
		{
			cout << "Bad" << endl;

			return 0;
		}
	}

	cout << "Good" << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a_list = list(map(int, input().split()))

money = 1000
num = 0

for i in range(len(a_list)-1):
    if a_list[i] <= a_list[i+1]:
        num += money // a_list[i]
        money -= num * a_list[i]

        money += num * a_list[i+1]
        num = 0

print(money)


Measured memory_bytes: 9060
import std.stdio;
import std.range;
import std.conv;
import std.algorithm;
import std.array;
import std.string;


void main()
{
    int n, m, l;
    readf("%d %d %d\n", &n, &m, &l);
    long[][] A = new long[][n];
    long[][] B = new long[][m];
    for (int i = 0; i < n; i++)
    {
        A[i] = readln.strip.split(' ').map!(to!long).array;
    }
    for (int i = 0; i < m; i++)
    {
        B[i] = readln.strip.split(' ').map!(to!long).array;
    }
    for (int j = 0; j < n; j++)
    {
        auto a = new long[l];
        for (int i = 0; i < l; i++)
        {
            for (int k = 0; k < m; k++)
            {
                a[i] += A[j][k] * B[k][i];
            }
        }
        writeln(a.map!(to!string).join(" "));
    }
}



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

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

  int sum = 0;
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  
  cout << sum << endl;
}


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

int main() {
    string s;
    cin >> s;
    int flag = 0;
    int a = 0;
    int b = 0;
    for (int i = 0; i < s.length(); ++i) {
        if ( i%2 == 0 ) {
            if ( s[i] == 'R' || s[i] == 'U' || s[i] == 'D' ) {
                a++;
            } else {
                break;
            }
        } else {
            if ( s[i] == 'L' || s[i] == 'U' || s[i] == 'D' ) {
                b++;
            } else {
                break;
            }
        }

    }

    if ( a+b == s.length()) {
        flag = 1;
    }
    cout << (flag ? "Yes" : "No" ) << endl;
    return 0;
}


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

const int N = 111111;
int a[N];
int n;

int main() {
    ios::sync_with_stdio(false);
    cout.precision(10);
    cin >> n;
    int x = -1;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        x = max(x, a[i]);
    }
    int y = -1;
    for(int i = 1; i <= n; i++) {
        if(a[i] == x) continue;
        if(abs(x / 2 - a[i]) < abs(x / 2 - y)) {
            y = a[i];
        }
    }
    cout << x << " " << y << endl;
    return 0;
}

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

int main() {
  int ans;
  int a,b,AC,WA,TLE,RE;
  
  string e;
  AC=0;
  WA=0;
  RE=0;
  TLE=0;
  cin>>a;
  
  for(int i=0;i<a;i++){
  	cin>>e;
    if(e=="AC")AC++;
    if(e=="WA")WA++;
    if(e=="TLE")TLE++;
    if(e=="RE")RE++;
  }
    
  cout << "AC x " <<AC<< endl;
  cout << "WA x " <<WA<< endl;
  cout << "TLE x " <<TLE<< endl;
  cout << "RE x " <<RE<< endl;
}

Measured memory_bytes: 3596
x,y=map(int,input().split())

if (2*y-x)%3!=0 or (2*x-y)%3!=0 or 2*x-y<0 or 2*y-x<0:
    ans=0
else:
    a=(2*y-x)//3
    b=(2*x-y)//3
    n=a+b
    ans=1
    for i in range(min(a,b)):
        ans*=(n-i)
        ans%=(10**9+7)
        ans*=pow(i+1,10**9+5,10**9+7)
print(ans%(10**9+7))

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
    int x,y,wk;
	while(1)	{
		scanf("%d %d",&x,&y);
		if(x==0 && y==0)	break;
		if(x>y) {
			wk=x;
			x=y;
			y=wk;
		}
		printf("%d %d\n",x,y);
	}
	return 0;
}


Measured memory_bytes: 2612
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{

    int n;
    string march = "MARCH";
    cin >> n;
    int a[5];
    REP(i, 5)
    {
        a[i] = 0;
    }
    REP(i, n)
    {
        string s;
        cin >> s;
        REP(j, 5)
        {
            if (march[j] == s[0])
            {
                //st[s[0]] += 1;
                a[j] += 1;
            }
        }
    }

    long long ans = 0;

    /* 
    REP(i, 5)
    {
        int num = a[i];
        if (a[i] >= 3)
        {
            ans += (long long)(num * (num - 1) * (num - 2) / 6);
        }
        REP(j, 5)
        {
            if (i == j)
                continue;

            ans += (long long)(a[j] * num * (num - 1) / 2);
        }
    }
*/

    for (int i = 0; i < 5; i++)
    {
        for (int j = i + 1; j < 5; j++)
        {
            for (int k = j + 1; k < 5; k++)
            {
                ans += (long long)a[i] * a[j] * a[k];
            }
        }
    }
    cout << ans << endl;
}


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

ans = 0
i = 1
while i <= N:
  if P[i] != i:
    i +=1
    continue
  else:
    ans += 1
    if P[i+1] != i:
      tmp_p = P[i]
      P[i] = P[i+1]
      P[i+1] = tmp_p
      i +=1
    else:
      tmp_p = P[i]
      P[i] = P[i-1]
      P[i-1] = tmp_p  
      i -= 1
print(ans)
#print(P)


Measured memory_bytes: 53228
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<int> factors(n+1, 1);
	for (int i = 2; i <= n; i++) {
		for (int j = i; j <= n; j += i) {
			factors[j]++;
		}
	}

	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += 1LL * i * factors[i];
	}

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


Measured memory_bytes: 41876
while True:
    M,T,P,R = map(int,input().split())
    if T == 0: break
    wrong = [[0 for i in range(P)] for j in range(T)]
    right = [0 for i in range(T)]
    pena = [0 for i in range(T)]
    for i in range(R):
        m,t,p,j = map(int,input().split())
        t,p = t-1,p-1
        if j == 0:
            right[t] += 1
            pena[t] += wrong[t][p] * 20 + m
        else:
            wrong[t][p] += 1
    result = []
    for t in range(T):
        result.append((-right[t], pena[t], -(t+1)))
    result.sort()
    ans = str(-result[0][2])
    for (r1,p1,t1),(r2,p2,t2) in zip(result, result[1:]):
        if r1 == r2 and p1 == p2:
            ans += '='
        else:
            ans += ','
        ans += str(-t2)
    print(ans)

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;
 
int main(){
	int n;
	cin >> n;
	vector<tuple<string,int,int>> p(n);
    string s;
	int x;	
	rep(i,n){
		cin >> s >> x;
		p[i] = make_tuple(s,-x,i);
	}
	
	sort(p.begin(),p.end());
  
	rep(i,n){
      string s;
      int x,y;
      tie(s,x,y)=p[i];
      cout<<y+1<<endl;
	}
	
return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  char a;
  cin>>a;
  a++;
  cout<<a<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;

void solve(){

    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    for(ll i = k; i<=n+1; i++){
        ll x,y;
        x = i*(i-1)/2;
        y = i * (2*n-i+1) / 2;
        ans = (ans + y-x+1)%MOD;
    }

    cout << ans << endl;

}

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


Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
using namespace std;
inline char nc() {
	static char buf[100000], *l = buf, *r = buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x) {
	x = 0; int f = 1, ch = nc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
	x *= f;
}
int A, B, C;
int main() {
//	freopen("testdata.in", "r", stdin);
	read(A), read(B), read(C);
	if(A * C <= B) printf("%d\n", C);
	else printf("%d\n", B / A);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;


int main() {
    int a,b;
    cin >> a >> b;
    
    if((a+b) % 2 != 0){
        cout << "IMPOSSIBLE" << endl;
    }
    else {
        cout << (a+b)/2 << endl;
    }
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

	static List<Integer> graph[];
	static int cnt[];
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), q = sc.nextInt();
		graph = new ArrayList[n];
		for(int i=0;i<n;i++) graph[i] = new ArrayList<>();
		for(int i=0;i<n-1;i++) {
			int a = sc.nextInt()-1, b = sc.nextInt()-1;
			graph[a].add(b);
			graph[b].add(a);
		}
		
		cnt = new int[n];
		for(int i=0;i<q;i++) {
			int p = sc.nextInt()-1, x = sc.nextInt();
			cnt[p] += x;
		}
		
		dfs(0, -1, 0);
		//出力
		//printは遅いので、1回だけで済むように、StringBuilderで解答の文字列を作る。
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<n;i++) {
			sb.append(cnt[i] + " ");
		}
		//出力
		System.out.println(sb.toString());
	}
	
	static void dfs(int v , int p, int x) {
		cnt[v] += x;
		x = cnt[v];
		
		for(int to:graph[v]) {
			if(to == p)continue;
			dfs(to, v, x);
		}
	}
	
}



Measured memory_bytes: 222460
primes = [0, 0] + [1]*9999999
for i in range(2, 3163):
    if primes[i]:
        for j in range(i*i, 10000001, i):
            primes[j] = 0
 
while True:
    n = int(input())
    if n == 0:
        break
    for i in range(5, n+1)[::-1]:
        if primes[i] and primes[i-2] and primes[i-6] and primes[i-8]:
            print(i)
            break

Measured memory_bytes: 163428
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    ll A, B;
    char op;
    cin >> A >> op >> B;

    if (op == '+') {
        cout << A + B << endl;
    } else if (op == '-') {
        cout << A - B << endl;
    }
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc104/tasks/abc104_a

#include <iostream>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int a;
  string r;

  cin >> a;

  r = a < 1200 ? "ABC" : a < 2800 ? "ARC" : "AGC";

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  string s; cin >> s;
  int n = s.size();
  reverse(ALL(s));
  map<int, int> mp;
  int cur = 0;
  mp[cur]++;
  lint mul = 1;
  for (int i = 0; i < n; i++) {
    int num = (int)(s[i] - '0');
    num *= mul;
    num %= MOD;
    cur += num;
    cur %= 2019;
    mp[cur]++;
    // cerr << "cur = " << cur << endl;
    mul *= 10;
    mul %= 2019;
  }

  lint ans = 0;
  for (int i = 0; i < 2019; i++) {
    lint cnt = mp[i];
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gi(){
    char ch=getchar(); int x=0,q=0;
    while(ch<'0'||ch>'9') q=ch=='-'?1:q,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return q?-x:x;
}
int n,a,b,c,d,s;
ll l,r;
int main(){
    cin>>n>>a>>b>>c>>d,s=b-a;
    int flag=0;
    for (int i=0; i<n; ++i){
	l=1ll*i*c-1ll*(n-1-i)*d;
	r=1ll*i*d-1ll*(n-1-i)*c;
	if (l<=s&&s<=r) flag=1;
    }
    puts(flag?"YES":"NO");
    return 0;
}


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

struct StSeq
{
  int m_nBgn;
  int m_nEnd;

  StSeq() : m_nBgn(0), m_nEnd(0)
  { }
};

void fnInput(vector<vector<int>>& rvvnAdjcy, vector<StSeq>& rvoDFSrch)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  rvvnAdjcy.resize(nMaxSiz + 1, vector<int>(nMaxSiz + 1, 0));
  for (int i = 0; i < nMaxSiz; ++i)
  {
    int nx, nSecSiz;
    cin >> nx >> nSecSiz;
    for (int j = 0; j < nSecSiz; ++j)
    {
      int ny;
      cin >> ny;
      rvvnAdjcy[nx][ny] = 1;
    }
  }
  StSeq oSeq;
  rvoDFSrch.resize(nMaxSiz + 1, oSeq);
}

void fnDepthFirstSearch(const vector<vector<int>>& cnrvvnAdjcy, vector<StSeq>& rvoDFSrch, int nx)
{
  static int stnCnt = 0;

  if (rvoDFSrch[nx].m_nBgn)  return;
  rvoDFSrch[nx].m_nBgn = ++stnCnt;

  for (int ny = 1; ny < cnrvvnAdjcy.size(); ++ny)
    if (cnrvvnAdjcy[nx][ny] == 1  &&
        nx != ny               )
      fnDepthFirstSearch(cnrvvnAdjcy, rvoDFSrch, ny);

  rvoDFSrch[nx].m_nEnd = ++stnCnt;
}

void fnResult(const vector<StSeq>& cnrvoDFSrch)
{
  for (int i = 1; i < cnrvoDFSrch.size(); ++i)
    cout << i <<  " " << cnrvoDFSrch[i].m_nBgn << " " << cnrvoDFSrch[i].m_nEnd << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<vector<int>> vvnAdjcy;
  vector<StSeq> voDFSrch;

  fnInput(vvnAdjcy, voDFSrch);
  for (int nx = 1; nx < voDFSrch.size(); ++nx)
    fnDepthFirstSearch(vvnAdjcy, voDFSrch, nx);
  fnResult(voDFSrch);

  return 0;
}

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

int abs(int a){
  int ans;
  ans = (a<0) ? -a : a;
  return ans;
}

int main() {
 int N,D;
 cin >> N >> D;

 int aa[D*N]; int l;
  for(int i=0; i<D*N; i++){
   cin >> l;
   aa[i] = l;
  }

 int dsum = 0; int k; int ans = 0;
  for(int a=0; a<N-1; a++){
   for(int b=a+1; b<N; b++){
     dsum = 0;
    for(int i=0; i<D; i++){
     dsum += abs(aa[i+a*D] - aa[i+b*D]) * abs(aa[i+a*D] - aa[i+b*D]);
    }
    k = 0;
    while(k*k<=dsum){
      if(k*k == dsum){
        ans++;
        break;
      }
      k++;
    }
   }
  }
cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
count=0

def is_prime(x):
    if x<=1:
        return False
    if x==2:
        return True
    if x>=3:
        for i in range(2,int(x**0.5)+1):
            if x%i==0:
                return False
    return True

for k in range(n):
    x=int(input())
    if is_prime(x):
        count+=1
print(count)


Measured memory_bytes: 5704
N = int(input())
A = list(map(int, input().split()))

x = []
x1 = 0
for i in range(N):
    x1 += ((-1)**i)*A[i]
x.append(x1)

for j in range(N-1):
    y = 2 * A[j] - x[j]
    x.append(y)

x = [str(z) for z in x]
x = ' '.join(x)
print(x)

Measured memory_bytes: 18120
#include <stdio.h>
int Fibonacci(int );
int F[45];
int main()
{
	int n,i;
	for(i=0;i<45;i++) F[i] = 0;
	F[0] = F[1] = 1;
	scanf("%d",&n);
	printf("%d\n",Fibonacci(n));
	return 0;
}

int Fibonacci(int n)
{
	int ans;
	if(F[n] != 0) return F[n];
	else 
	{
		ans = Fibonacci(n-1) + Fibonacci(n-2);
		F[n] = ans;
		return ans;
	}
}

Measured memory_bytes: 596
N, M = map(int, input().split())

ids = [0 for i in range(N + 2)]
for i in range(M):
  L, R = map(int, input().split())
  ids[L] += 1
  ids[R+1] -= 1

prev = 0
cnt = 0 
for i in ids:
  prev = i + prev
  if prev == M:
    cnt += 1
print(cnt)



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

int main(){
  int w,i,ww,wi,iw,k=0;
  cin>>w;
  for(i=1;i<w;i=i*3);
  while(i!=0){
    ww=abs(w);
    wi=abs(w+i);
    iw=abs(w-i);
    if( ww > wi ){
      w+=i;
      cout<<"-";
      i/=3;
      k++;
    }else if( ww > iw ){
      w-=i;
      cout<<"+";
      i/=3;
      k++;
    }else if(k!=0){
      cout<<"0";
      i/=3;
    }else {
      i/=3;
    }
  }
  cout<<endl;
  return 0;
}

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

int main(){
    int a, b, res = -1;
    cin >> a >> b;
    for(int i=1; i<=100000; i++){
        if(floor((double)i*0.08) == a && floor((double)i*0.1) == b){
            res = i;
            break;
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	static int[] sos = new int[1000000];
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		long x = scan.nextLong();
		while(!isPrime(x)) {
			x++;
		}
		System.out.println(x);
	}
	public static boolean isPrime(long num) {
	    if (num < 2)
	    	return false;
	    else if (num == 2)
	    	return true;
	    else if (num % 2 == 0)
	    	return false;

	    double sqrtNum = Math.sqrt(num);
	    for (long i = 3; i <= sqrtNum; i += 2){
	        if (num % i == 0){
	            return false;
	        }
	    }
	    return true;
	}
}

Measured memory_bytes: 27732
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#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 srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 2500005;

ll sa[MAX_N],sb[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll m,n,u1,v1,u2,v2;
    cin >> m >> n >> u1 >> v1 >> u2 >> v2;
    vl a(m),b(n);
    rep(i,m){
        a[i] = u1;
        u1 = (u1*58+v1) % (n+1);
    }
    rep(i,n){
        b[i] = u2;
        u2 = (u2*58+v2) % (m+1);
    }
    sort(all(a)),sort(all(b));
    rep(i,m){
        sa[i+1] = sa[i] + a[i];
    }
    rep(i,n){
        sb[i+1] = sb[i] + b[i];
    }
    ll ans = (1LL << 60);
    rep(i,m+1){
        int cnt = upper_bound(all(b),i) - b.begin();
        cmn(ans,sa[m-i]+i*(n-cnt)+sb[cnt]);
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 81044
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999
#define MAX_V 100

struct edge{int to,cost;};
vector<edge> G[MAX_V];
int d[MAX_V];

int dijkstra(int s,int V){
    priority_queue< pii,vector<pii>,greater<pii> > que;
    rep(i,MAX_V)d[i]=INF;
    d[s]=0;
    que.push(pii(0,s));
    
    while(que.size()){
        pii p=que.top();
        que.pop();
        
        int v=p.second;
        if(d[v]<p.first)continue;
        
        rep(i,G[v].size()){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(pii(d[e.to],e.to));
            }
        }
    }
    return d[V];
}


int main(){
    int n,m;
    cin>>n>>m;
    rep(i,m){
        int a,b,c,d;
        char ch;
        cin>>a>>ch>>b>>ch>>c>>ch>>d;
        a--,b--;
        G[a].pb(edge{b,c});
        G[b].pb(edge{a,d});
    }
    int x1,x2,y1,y2;
    char ch;
    cin>>x1>>ch>>x2>>ch>>y1>>ch>>y2;
    x1--,x2--;
    cout<<y1-(dijkstra(x1,x2)+dijkstra(x2,x1)+y2)<<endl;
}

Measured memory_bytes: 3144
N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = sorted(A)
B = sorted(B)
C = sorted(C)

A.insert(0, -100000000000)
A.append(1000000000000)
C.insert(0, -100000000000)
C.append(1000000000000)


total= 0
for b in B:
    # search A
    l = 0
    r = N + 1
    while r - l > 1:
        m = (l + r) // 2
        if A[m] < b:
            l = m
        else:
            r = m

    a_count = l

    # search C
    l = 0
    r = N + 1
    while r - l > 1:
        m = (l + r) // 2
        if C[m] > b:
            r = m
        else:
            l = m

    c_count = N + 1 - r

    total += a_count * c_count

print(total)

Measured memory_bytes: 22496
PROGRAM TAX
 IMPLICIT NONE
 INTEGER::N,max,a,b,X
 INTRINSIC INT
 READ(*,*)N
 max=N
 b=0
 
 DO X=1, max
  a=int(X*1.08)
  IF(a == N)THEN
  b=X
  END IF
 END DO
 IF(b > 0)THEN
  WRITE(*,*)b
 ELSE
  WRITE(*,*)":("
 END IF
 
END PROGRAM TAX


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 2e18;

void bfs(int s, vector<int> adj[], vector<int>& nneigh) 
{ 
    int V = nneigh.size();
    bool *visited = new bool[V]; 
    for(int i = 0; i < V; i++) 
        visited[i] = false; 
    list<int> queue; 
    visited[s] = true; 
    queue.push_back(s); 
  
    while(!queue.empty()) 
    { 
        s = queue.front(); 
        queue.pop_front(); 
        for(int i=0; i<adj[s].size(); i++)
        { 
            if (!visited[adj[s][i]]) 
            { 
                nneigh[adj[s][i]] = s;
                visited[adj[s][i]] = true; 
                queue.push_back(adj[s][i]); 
            } 
        } 
    } 
} 


int32_t main(){
	int n, m;
	cin >> n >> m;
	vector<int> adj[n];
	while(m--){
		int a, b;
		cin >> a >> b;
		adj[a-1].push_back(b-1); 
    	adj[b-1].push_back(a-1); 
	}
	vector<int> nneigh(n, -1);
    bfs(0, adj, nneigh);
	string res = "YES";
	for(int i=1; i<n; i++){
	    if(nneigh[i] == -1){
	        res = "NO";
	        break;
	    }
	}
	if(res == "YES"){
	    cout << "Yes" << "\n";
	    for(int i=1; i<n; i++){
	        cout << nneigh[i]+1 << "\n";
	    }
	} else {
	    cout << "No" << "\n";
	}
}

Measured memory_bytes: 14952
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 998244353;

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

  LL A, B, C;
  cin >> A >> B >> C;
  if(A%2==0||B%2==0||C%2==0){
    cout << 0 << endl;
  }else{
    cout << min({A * B, B * C, A * C}) << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            long N = IO.RLong;

            long ans = 0;

            for (int i = 1; i <= N; i++)
            {
                ans += i * g(N / i);
            }
            WriteLine(ans);
        }
        static long g(long n)
        {
            return n * (n + 1) / 2;
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 17632
#include <cstdio>

int main()
{
    int A, B;
    scanf("%d%d", &A, &B);
    int ans = 0;
    for (int i = 0; i < 2; i++)
    {
        if (A < B)
        {
            ans += B;
            B--;
        }
        else
        {
            ans += A;
            A--;
        }
    }

    printf("%d\n", ans);
}

Measured memory_bytes: 128
#include<stdio.h>

int main()
{
  int a,b,x;
  scanf("%d%d%d",&x,&a,&b);
  {
      if(x-a>=0)
       a=x-a;
      else a=a-x;
      if(x-b>=0)
        b=x-b;
      else
        b=b-x;
      if(a<=b)
        printf("A\n");
      else printf("B\n");
  }
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    ll x, n;
    cin >> x >> n;
    vi p(n);
    REP(i, n) cin >> p[i];

    ll ans = 100000;
    ll dif = 100000;
    FOR(i, -10000, 10001) {
        if (find(ALL(p), i) == p.end()) {
            if (abs(x-i) < dif) {
                dif = abs(x-i);
                ans = i;
            }
        }
    }

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


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

#define int long long
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define reps(i, n) for (int (i) = 1; (i) <= (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL << (n))
typedef vector<int> vint;
typedef pair<int, int> pint;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct SetUp {
    SetUp() {
        cout << fixed << setprecision(20);
        cerr << fixed << setprecision(20);
    };
} setUp;

int H, W;
bool board[1100000];
signed main() {
    cin >> H >> W;
    deque<pint> q;
    rep(i, H) {
        string A;
        cin >> A;
        rep(j, W) {
            board[i * W + j] = A[j] == '#';
            if (board[i * W + j]) { q.push_front({i * W + j, 0}); }
        }
    }

    int ans = 0;
    while (!q.empty()) {
        cerr << endl;
        int cur = q.front().first;
        int dist = q.front().second;
        q.pop_front();
        int cy = cur / W, cx = cur % W;
        chmax(ans, dist);
        rep(i, 4) {
            int ny = cy + DY[i], nx = cx + DX[i];
            if (ny < 0 || ny >= H || nx < 0 || nx >= W) { continue; }
            if (board[ny * W + nx]) { continue; }
            board[ny * W + nx] = true;
            q.push_back({ny * W + nx, dist + 1});
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 17596
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[100005], finv[100005], inv[100005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge>>G;

int main() {
	char c, ans;
	cin >> c;
	switch (c) {
	case 'A':
		ans = 'T';
		break;
	case 'T':
		ans = 'A';
		break;
	case 'C':
		ans = 'G';
		break;
	case 'G':
		ans = 'C';
		break;
	}
	cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

#define out(ans) cout << ans << endl
#define in(n) cin >> n
#define floop(i, N) for (ll i = 0; i < N; i++)
#define floop1(i, N) for (ll i = 1; i <= N; i++)
#define floopi(i, j, N) for (ll j = i + 1; j < N; j++)

constexpr ll inf = 1e18;

void solve();

int main()
{
    solve();
}

void solve()
{
    int n, m;
    in(n);
    map<string, vector<int>> mp;
    int u = 0;
    floop(i, n)
    {
        string s;
        in(s);
        mp[s].push_back(1);
    }
    in(m);
    floop(i, m)
    {
        string s;
        in(s);
        mp[s].push_back(-1);
    }
    int ans = 0;
    for (auto it : mp)
    {
        auto v = it.second;
        int tmp = 0;
        floop(i, v.size())
        {
            tmp += v[i];
        }
        ans = max(ans, tmp);
    }
    out(ans);
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

    rep(i, n / 100 + 1)
    {
        int res = n - 100 * i;
        if (0 <= res && res <= 5 * i)
        {
            puts("1");
            return 0;
        }
        if (res < 0)
        {
            break;
        }
    }

    puts("0");
    return 0;
}


Measured memory_bytes: 3604
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	min := 1
	max := N
	for i := 0; i < M; i++ {
		lr := scanNums(2)

		//範囲外
		if lr[1] < min || max < lr[0] {
			fmt.Println(0)
			return
		}

		if min < lr[0] {
			min = lr[0]
		}
		if lr[1] < max {
			max = lr[1]
		}
	}
	fmt.Println(max - min + 1)

}

func scanNums(length int) (nums []int) {
	var num int
	for i := 0; i < length; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 7556
# Author: cr4zjh0bp
# Created: Sat Mar 28 11:53:27 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

s = ns()

flag = True
if s[2] != s[3]:
    flag = False
if s[4] != s[5]:
    flag = False

print("Yes" if flag else "No")

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

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

using namespace std;

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

    int n, k, ans = 0; cin >> n >> k;
    int array[n]; REPI(i, n) cin >> array[i];

    REPI(i, n)
        if(array[i] >= k) ans++;

    cout << ans;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>

using namespace std;


int main()
{
  long long N;
  map<int, char> mokuji;
  for(int i=1;i<=26;i++){
    mokuji[i] = 96+i;
  }
  string ans;
  cin >> N;
  
  
  int i = 0;
  while(N>26){
    bool kurisage = false;
    int kurai = N%26;
    if(kurai!=0){//z以外
      ans.push_back(mokuji[kurai]);
    } else{
        ans.push_back(mokuji[26]);
      kurisage = true;
    }
    N = N/26;
    if(kurisage) N--;
  }
  ans.push_back(mokuji[N]);
  reverse(ans.begin(), ans.end());
cout<< ans<<endl;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;

int main() {
  ll n, m;
  cin >> n >> m;
  if (n*2 >= m) dump(m/2);
  else dump(n+(m-n*2)/4);
  return 0;
}


Measured memory_bytes: 256
// package app;

import java.util.Arrays;
import java.util.Objects;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

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

        final String S = sc.next();

        // final long N = sc.nextLong();
        // final long A = sc.nextLong();
        // final long B = sc.nextLong();
        // final String s = sc.next();
        // final String b = sc.next();

        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < S.length(); i++) {
            sb.append('x');
        }

        System.out.println(sb.toString());

        // System.out.println(A <= X && A + B >= X ? "YES" : "NO");

    }
}

Measured memory_bytes: 23124
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

int w,h;
string in[50];
bool vis[50][50];

void solve(){
  rep(i,h)cin>>in[i];
  int bn=0,wn=0;

  rep(i,h)rep(j,w){
    if(in[i][j]!='.')continue;
    queue<PI> q;
    q.push(mp(i,j));
    bool bl=0,wh=0;
    memset(vis,0,sizeof(vis));
    while(!q.empty()){
      int cx=q.front().F,cy=q.front().S;
      q.pop();
      if(vis[cx][cy])continue;
      vis[cx][cy]=true;
      rep(k,4){
        int nx=cx+dx[k],ny=cy+dy[k];
        if(0>nx || nx>=h ||
           0>ny || ny>=w ||
           vis[nx][ny])continue;
        if(in[nx][ny]=='B'){
          bl=true;
          continue;
        }
        if(in[nx][ny]=='W'){
            wh=true;
            continue;
        }
        q.push(mp(nx,ny));
      }
    }

    char ch;
    if(bl && wh)ch=' ';
    else if(bl)ch='b';
    else if(wh)ch='w';
    else ch=' ';
    q=queue<PI>();
    q.push(mp(i,j));
    memset(vis,0,sizeof(vis));
    while(!q.empty()){
      int cx=q.front().F,cy=q.front().S;
      q.pop();
      if(vis[cx][cy])continue;
      in[cx][cy]=ch;
      vis[cx][cy]=true;
      rep(k,4){
        int nx=cx+dx[k],ny=cy+dy[k];
        if(0>nx || nx>=h ||
           0>ny || ny>=w ||
           vis[nx][ny] || in[nx][ny]!='.')continue;
        q.push(mp(nx,ny));
      }      
    }
  }
  rep(i,h)rep(j,w){
    if(in[i][j]=='b')++bn;
    else if(in[i][j]=='w')++wn;
  }
  cout<<bn<<' '<<wn<<endl;
}

main(){
  while(cin>>w>>h,w)
    solve();
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1001001001
#define LINF (1LL << 62)
using namespace std;
using ll = long long;
using P = pair<int, int>;

void solv() {
    string s;
    cin >> s;
    int len = s.size();
    rep(i, len / 2) {
        if (s[i] != s[len - i - 1]) {
            cout << "No" << endl;
            return;
        }
    }
    int center = len / 2;
    rep(i, center / 2) {
        if (s[i] != s[center-i-1]) {
            cout << "No" << endl;
            return;
        }
    }
    int diff = len - (len + 3) / 2;
    int start = (len + 3) / 2 -1;
    for (int i = 0; i < diff / 2; i++) {
        if (s[i + start] != s[len-i-1]) {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

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

Measured memory_bytes: 256
S = input()
N = int(S.split(' ')[0])
A = int(S.split(' ')[1])
B = int(S.split(' ')[2])
 
b_count = (N // (A+B)) * A
rem = N % (A+B)
b_count = b_count + min(rem, A)
print(b_count)

Measured memory_bytes: 3188
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

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

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)

ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll n=nxt(),k=nxt();
    vc<ll> v(n);
    generate(all(v),nxt);
    ll x[n]={0};
    rep(a,0,k)
    {
        ll b=nxt()-1,c=nxt()-1;
        x[b]=max(x[b],v[c]);
        x[c]=max(x[c],v[b]);
    } 
    ll ans=0;
    rep(a,0,n)
        if(v[a]>x[a])
            ans++;
    cout<<ans<<endl;
	printclock;
	return 0;
}

Measured memory_bytes: 4764
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


pair<int, int> past;
string s;
signed main() {
  int N; 
  cin >> N;

  cout << 0 << endl;
  cin >> s;
  if(s == "Vacant") return 0;
  if(s == "Male") past = {0, 0};
  else past = {0, 1};

  int ri = 0;
  int le = N+1;
  while(1){
    int now = (ri+le)/2;
    cout << now << endl;
    cin >> s;
    if(s == "Vacant") return 0;

    bool flag = false;
    if(abs(past.first-now)%2 == 0){
      if(s == "Male" && past.second == 0) flag = true;
      if(s == "Female" && past.second == 1) flag = true;
    }else{
      if(s == "Male" && past.second == 1) flag = true;
      if(s == "Female" && past.second == 0) flag = true;
    }

    if(flag) ri = now;
    else le = now;
  }


  return 0;
}

Measured memory_bytes: 852
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const K = parseInt(arg[0].split(" ")[1]);
    
    let answer = 0;
    
    for(let i=1; i<=N; i++) {
        let temp;
        let x = 1 / N;
        
        if(i >= K) {
            answer += x * 1;
        } else {
            let j = 0;
            
            while(i * Math.pow(2, j) < K) {
                j++;
            }
            
            let y = Math.pow((1 / 2), j);
            answer += x * y;
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 9932
import heapq as hq
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
a.sort()
for i in range(n):
    a[i][1]*=-1
b=[]
hq.heapify(b)
ans,i=0,0
for k in range(m-1,-1,-1):
    while i<n and a[i][0]+k<=m:
        hq.heappush(b,a[i][1])
        i+=1
    if b:
        ans-=hq.heappop(b)
print(ans)

Measured memory_bytes: 28524