akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
    int tapn,num,tap=1;
    scanf("%d %d",&tapn,&num);
    if (num==1)
    {
        printf("%d",0);
    }else if(tapn >= num)
    {
        printf("%d",tap);
    }else
    {
        int c = num - tapn;
        int d;
        if (c % (tapn-1)==0)
        {
            d=c/(tapn-1);
        }else
        {
            d=c/(tapn-1)+1;
        }
        tap += d;
    
        printf("%d\n",tap);
    }
}

Measured memory_bytes: 1724
#include <cstdio>

const int DEBT = 100000;

int main(int argc, char *argv[]) {
	int week;
	double sumDebt = static_cast<double>(DEBT);
	fscanf(stdin, "%d", &week);
	
	for (int i = 0; i < week; i++) {
		sumDebt += sumDebt * 0.05;
		sumDebt = static_cast<int>(sumDebt);
		int hasu = static_cast<int>(sumDebt) % 1000;
		if (hasu > 0) {
			sumDebt = sumDebt - hasu + 1000;
		}
		//printf("%d week is %.3f\n", i, sumDebt);
	}
	printf("%d\n", static_cast<int>(sumDebt));
	return 0;
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

int main() {
    int n;
    cin >> n;
    vector<ll> numbers(n);
    rep(i, n) cin >> numbers[i];
    vector<ll> abss = numbers;
    rep(i, n) abss[i] = abs(numbers[i]);
    sort(abss.rbegin(), abss.rend());

    int m_count = 0;
    for (ll l : numbers) if (l < 0) m_count++;
    if (m_count % 2 == 0) {
        cout << accumulate(abss.begin(), abss.end(), 0ll) << endl;
        ret();
    }

    ll ans = accumulate(abss.begin(), abss.end() - 1, 0ll);
    ans -= abss.back();
    cout << ans << endl;

}

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

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

	if(n%2){
		cout<<0<<endl;
		return 0;
	}
	
	long long ans=0;
	
	long long tmp=10;
	while(tmp<=n){
		ans+=n/tmp;
		tmp*=5;
	}
	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

char cps[4][2][3]={
	{"#.",  //-d
	 "##"},
	{".#",  //-d
	 ".."},
	{"..",  //+d
	 "#."},
	{"##",  //+d
	 ".#"}
};

int h,w;
char s[605][605];
typedef pair<double,int> dip;
vector<dip> ps;

int main(void){
	scanf("%d%d",&h,&w);
	ireg(y,1,h)scanf("%s",s[y]+1);
	reg(y,0,h+1)s[y][0]=s[y][w+1]='.';
	reg(x,0,w+1)s[0][x]=s[h+1][x]='.';
	
	reg(y,0,h){
		reg(x,0,w){
			rep(k,4){
				bool mc=true;
				rep(p,2)rep(q,2){
					if(s[y+p][x+q]!=cps[k][p][q])mc=false;
				}
				if(mc){
					double r=atan2(y,x);
					int a;
					if(k<2)a=-1;
					else a=1;
					if(k<2)r-=1e-6;
					else r+=1e-6;
					ps.push_back(dip(r,a));
					//printf("%d %d %lf %d\n",x,y,r,a);
					break;
				}
			}
		}
	}
	
	sort(ps.begin(),ps.end());
	int ans=0,ns=1;
	rep(i,ps.size()){
		//printf("%lf %d\n",ps[i].fir,ps[i].sec);
		ns+=ps[i].sec;
		ans=max(ans,ns);
	}
	printf("%d\n",ans);
	
	return 0;
}

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

using namespace std;
#define INF 1000007
#define MOD 1000000007
#define maxn 101
#define maxh 1001
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
const int dx[4] = {0, 1, -1, 0}, dy[4] = {1, 0, 0, -1};
typedef std::pair<int, int> P;
#define int long long
#define double long double
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

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

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

int a, b;

void f(int x) {
    while (x) {
        a++;
        b = x;
        x /= 10;
    }
}

signed main() {
    int N, K;
    cin >> N >> K;
    double ans = 0;
    double now = 0;
    vector<double> p(N);
    rep(i, N) {
        double P;
        cin >> P;
        double np = (1 + P) / 2;
        if(i > 0)p[i] = np + p[i-1];
        else p[i] = np;
    }
    ans = p[K-1];
    rep(i,N-K){
        now = p[i+K] - p[i];
        ans = max(ans,now);
    }
    cout << fixed << setprecision(20) << ans << endl;
}



Measured memory_bytes: 6412
fun main(args:Array<String>) {
    val n = readLine()!!.toInt()
    val candies = (1..2).map { readLine()!!.split(" ").map { it.toInt() }}
    val ans = (0 until n).map { candies[0].take(it+1).sum() + candies[1].drop(it).sum() }.max()
    println(ans!!)
}

Measured memory_bytes: 38240
#include <stdio.h>
#include <string.h>

#define MAX 10

int main()
{
  char s[MAX + 1];
  int i, c_number, c_count = 0;
  
  memset(s, '\0', sizeof(s));

  scanf("%s", s);

  if (s[0] != 'A') {
    printf("WA\n");
    return 0;
  }

  for (i = 2; i <= strlen(s) - 2; i++) {
    if (s[i] == 'C') {
      c_number = i;
      c_count++;
    }
  }

  if (c_count != 1) {
    printf("WA\n");
    return 0;
  }

  for (i = 1; i < strlen(s); i++) {
    if (i == c_number) continue;
    if (s[i] < 'a' || 'z' < s[i]) {
      printf("WA\n");
      return 0;
    }
  }

  printf("AC\n");
  return 0;
}


Measured memory_bytes: 128
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";



int main(void){
  int N, Z, W;
  cin >> N >> Z >> W;
  int a[N];
  rep(i, N) cin >> a[i]; 
  //cout << abs(-1) << endl;
  //cout <<"a[N-1]: " <<  a[N-1] << ", a[N-2]: " <<a[N-2] << endl;
  
  int max_ans1 = abs(a[N-1] - a[N-2]);
  int max_ans2 = abs(a[N-1] - W);
  if (N== 1){
    cout << max_ans2 << endl;
  } else{
   	cout << max(max_ans1, max_ans2) << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#define rs register short
#define ri register int
using namespace std;

typedef long long LL;
const int N = 1e5 + 5;

LL prime[N], sqr[N], cub[N];
int tot = 0;
bool notp[N];
map <LL, int> mp;
map <LL, LL> oppo;

inline void find_primes() {
  for (int i = 2; i < N; i ++) {
    if (!notp[i]) prime[++ tot] = i, sqr[tot] = prime[tot] * prime[tot], cub[tot] = sqr[tot] * prime[tot];
    for (int j = 1; j <= tot; j ++) {
      if (prime[j] * i >= N) break;
      notp[prime[j] * i] = 1;
      if (i % prime[j] == 0) break;
    }
  }
}

inline bool iscube(LL x) {
  LL t = pow(x, 1.0 / 3) + 0.5;
  return t * t * t == x;
}

inline bool issqr(LL x) {
  LL t = sqrt(x) + 0.5;
  return t * t == x;
}

int main() {
  find_primes();
  int n, ans = 0, p, cnt;
  LL x, Dec, Inc;
  scanf("%d", &n);
  for (ri i = 1; i <= n; i ++) {
    scanf("%lld", &x);
    if (iscube(x)) {ans = 1; continue;}
    Dec = Inc = 1;
    for (rs j = 1; cub[j] <= x; j ++)
      if (x % prime[j] == 0) {
	cnt = 0;
	while (x % prime[j] == 0) {
	  x /= prime[j];
	  cnt ++;
	}
	cnt %= 3;
	if (cnt == 0) continue;
	if (cnt == 1) Dec *= prime[j], Inc *= sqr[j];
	else Dec *= sqr[j], Inc *= prime[j];
      }
    if (issqr(x)) Inc *= (LL)(sqrt(x) + 0.5), Dec *= x;
    else Inc *= x * x, Dec *= x;
    mp[Dec] ++;
    oppo[Dec] = Inc;
  }
  LL o;
  map <LL, int> :: iterator tmp;
  for (map <LL, int> :: iterator it = mp.begin(); it != mp.end(); it ++) {
    o = oppo[it -> first];
    tmp = mp.find(o);
    if (tmp != mp.end()) {
      ans += max(it -> second, tmp -> second);
      mp.erase(tmp);
    }
    else ans += it -> second;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 13440
import math
a,b,x = map(int,input().split())
s1 = a * b**2 / (x+x)
s2 = (2*(a*a*b - x)) / (a**3)
s1 = math.degrees(math.atan(s1))
s2 = math.degrees(math.atan(s2))
if x+x < a*a*b:
    print(s1)
else:
    print(s2)

Measured memory_bytes: 62424
n = int(input())
apartment = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
for _ in range(n):
    b, f, r, v = map(int, input().split())
    apartment[b-1][f-1][r-1] += v
for b in range(4):
    if(b != 0):
        print('#' * 20)
    for f in range(3):
        print(' ' + ' '.join(map(str, apartment[b][f])))



Measured memory_bytes: 5612
n = gets.to_i
left = 1
right = n
while right - left > 1
  mid = left + (right - left) / 2
  if mid * (mid+1) / 2 >= n
    right = mid
  else
    left = mid
  end
end
sum = 0
ans = []
while right > 0 && sum != n
  if n - sum >= right
    ans << right
    sum += right
  end
  right -= 1
end
puts ans

Measured memory_bytes: 14292
#include <cstdio>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <tuple>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int ll;
using namespace std;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;



int main()
{

    string s;
    cin >> s;

    int ans = 0;

    REP(i,s.length())
    {
        if(s[i] == 'p')
        {
            ans--;
        }
    }

    cout << ans + s.length()/2 << endl;

   return 0 ;

}


Measured memory_bytes: 512
#N=int(input())
#N,K = map(int,input().split())
N=int(input())
#A = list(map(int,input().split()))
#S=str(input())
N=str(N)
N=int(N[-1])
if N==2 or N==4 or N==5 or N==7 or N==9:
    print('hon')
elif N==0 or N==1 or N==6 or N==8:
    print('pon')
else:
    print('bon')


Measured memory_bytes: 9108
// aribon2-2_i
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define ALL(x) x.begin(), x.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define CHAR2INT(c) (c - '0')
#define COUT(x) cout << x << endl
#define COUT_2DARR(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }

int mod_pow(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[8]={ 1, 0, -1, 0, -1, 1, -1, 1};
int dy[8]={ 0, 1, 0, -1, -1, -1, 1, 1};

struct PreMain {PreMain(){std::cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;


int main() {
#ifdef LOCAL
    std::ifstream in("../arg.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    ull X,Y;
    cin >> X >> Y;

    int ans;
    for(ans=0;X<=Y;X*=2,ans++){}

    COUT(ans);

    return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
ans = 'Yes'
for i in range(1, n):
    if h[i] > h[i-1]:
        h[i] -= 1
    elif h[i] == h[i-1]:
        pass
    else:
        ans = 'No'
        break
print(ans)        

Measured memory_bytes: 14396
s=input()
n=len(s)

ans = 0

for bit in range(1 << (n - 1)):
  f = s[0]

  for i in range(n - 1):
    if bit & (1 << i):
      f += '+'
    f += s[i + 1]

  ans += sum(map(int, f.split("+")))

print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    int right = 0;
    ll sum = 0, xOR = 0;
    ll res = 0;
    for(int left = 0; left < N; left++) {
        while(right < N && ((xOR ^ A[right]) == sum + A[right])) {
            xOR ^= A[right];
            sum += A[right];
            right++;
        }
        res += (right - left);
        if(left == right) {
            xOR ^= A[right];
            sum += A[right];
            right++;
        }

        xOR ^= A[left];
        sum -= A[left];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int gcd(int x, int y){
	return x<y?gcd(y, x):y?gcd(y, x-y):x;
}

int main(void){
	int x, y;
	
	while (scanf("%d%d", &x, &y)!=EOF){
		printf("%d\n", gcd(x, y));
	}
	
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int main(){
	int n; cin >> n;
	int sum = 0;
	set<int> s;
	rep(i, n){
		int a; cin >> a;
		sum ^= a;
		s.insert(__builtin_popcount(a ^ (a - 1)));
	}
	int cnt = 0;
	while(sum){
		int x = 32 - __builtin_clz(sum);
		if(!s.count(x)){
			cout << -1 << endl;
			return 0;
		}
		cnt++;
		sum ^= (1ll << x) - 1;
	}
	cout << cnt << endl;
	
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, m, k;
  cin >> n >> m >> k;
  
  
  rep(i, n+1) rep(j, m+1) {
    if(i*j + (n-i)*(m-j) == k) {cout << "Yes" << newl; return 0;}
  }
  cout << "No" << newl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
 int main(){
   int l=0,lm=0;
string s;
   cin>>s;
   for(int i=0;i<s.size();i++){
   if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
     l++;
   }else{
     lm=max(l,lm);
     l=0;
   }
   }
     cout<<max(lm,l)<<endl;;
 }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <queue>
#include <cstdio>

using namespace std;

int main(){
    long a, b, c, k, ans=0;
    cin >> a >> b >> c >> k;
    ans = min(k, a);
    k -= a;
    if(k > 0){
        k -= b;
        if(k > 0){
            ans -= k;
        }
    }

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


Measured memory_bytes: 3596
A, B, C, X, Y = map(int, input().split())
ans = 0
if A + B <= 2*C:
    ans = A*X + B*Y
else:
    ans += 2*C*min(X, Y)
    if X >= Y:
        ans += min(A, 2*C) * (X-Y)
    else:
        ans += min(B, 2*C) * (Y-X)

print (ans)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){
    float a,b,s,i,t=20,a1=0.08,a2=0.1;
    cin>>a>>b;
    s=b*20;
    for(i=0;i<=s;i++){
    if((int)(i*a1)==a&&(int)(i*a2)==b){cout<<i;return 0;}
    }cout<<"-1";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

int main() {
	ll N, M, ans = 0;
	cin >> N >> M;

	if (N * 2 <= M) {
		ans += N + (M - N * 2) / 4;
	}
	else {
		ans += M / 2;
	}

	cout << ans;
	
	return 0;
}

Measured memory_bytes: 3640
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }

int main(void) {
	int N;
	cin >> N;
	for (int i = 0; i <= N / 4; ++i) {
		for (int j = 0; j <= N / 7; ++j) {
			if (4 * i + 7 * j == N) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

int main()
{
    int n;
    cin>>n;
    getchar();
    while(n!=0){
        string str;
        getline(cin,str);
        for(int i=0;i<str.length();i++){
            if(str[i]=='H' && str[i+1]=='o' && str[i+2]=='s' && str[i+3]=='h' && str[i+4]=='i' && str[i+5]=='n' && str[i+6]=='o'){
                str[i+6]='a';
                i += 6;
            }
        }
        cout<<str<<endl;
        n--;
    }
    return 0;
}

Measured memory_bytes: 1208
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

#define int long long

signed main() {
	int a, b, x;
	cin >> a >> b >> x;
	int ans=0;
	ans = b / x;
	ans -= a / x;
	if (a%x == 0)ans++;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int maxx=-1;
    int minn=n;
    for(int i=1;i<=m;i++){
        int x,y;
        cin>>x>>y;
        if(maxx<x) maxx=x;
        if(minn>y) minn=y;
    }
    if(minn-maxx>=0) cout<<minn-maxx+1<<endl;
    else cout<<0<<endl;
    return 0;
}


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

int main() {
  int a, b, c, k;
  bool first = true;
  while (1) {
    scanf("%d %d", &a, &b);
    if (!a && !b) break;
    if (!first) puts("");
    else first = false;
    k = a;
    while (k%4) ++k;
    c = 0;
    for (; k<=b; k+=4) {
      if (k%400 && !(k%100)) continue;
      printf("%d\n", k);
      ++c;
    }
    if (!c) printf("NA\n");
  }

  return 0;
}

Measured memory_bytes: 1040
#include<stdio.h>
int main()
{
    int i,j,s;
    for(i=1; i<=9; i++)
    {
        for(j=1; j<=9; j++)
        {
            s=i*j;
            printf("%dx%d=%d\n", i,j,s);
        }
    }
    return 0;

}



Measured memory_bytes: 2036
import math

A, B, H, M = map(int, input().split())
tan = 30 * H + (30 * (M / 60))
tyo = 6 * M
kakudo = abs(tan - tyo)

ans = pow(A, 2) + pow(B, 2) - 2 * A * B * math.cos(math.radians(kakudo))
print(pow(ans, 0.5))

Measured memory_bytes: 62688
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <functional>
#define MOD 1000000007

int i,j,k;

struct edge {
    int to;
    int cost;
};

typedef long long ll;
using namespace std;
using P = pair<int, int>;

bool compare_by_b(pair<int,pair<string,int>> a, pair<int,pair<string,int>> b) {
    if(a.second.first != b.second.first){
        return a.second.first < b.second.first;
    }else{
    return a.second.second > b.second.second;
    }
}

int main(void) {
    ll w,h;
    cin >> w >> h;
    ll x,y;
    cin >> x >> y;
    printf("%.6lf %d\n",((double)(w*h))/2.0,(int)(x+x==w&&y+y==h));
    //cout << (double)(w*h/2) << (int)(x+x==w&&y+y==h) <<endl;
    return 0;
    
}


Measured memory_bytes: 256
//AGC 007-A
#define _USE_MATH_DEFINES
 
#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <numeric>
#include <string>
#include <map>
#include <sstream>
using namespace std;
 
 int main(){
 	int N, x, a[100000];
 	long ans = 0;
 	cin >> N >> x;
 	for (int i = 0; i < N; i++){
 		cin >> a[i];
 		if(a[i] > x) {
 			ans += a[i] - x;
 			a[i] = x;
 		}
 	}
 	for (int i = 0; i < N - 1; i++){
 		if(a[i]+a[i+1] > x){
 			ans += a[i] + a[i+1] - x;
 			a[i+1] -= a[i] + a[i+1] - x;
 		}
 	}
 	cout << ans << endl;
 }

Measured memory_bytes: 640
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, q) = (v[0], v[1]);
    let mut constructions = vec![];
    for i in 0..n {
        let v = read_vec::<i64>();
        let (s, t, x) = (v[0], v[1], v[2]);
        constructions.push((s - x, x, t - x));
    }

    let mut d = vec![];
    for i in 0..q {
        d.push(read::<i64>());
    }

    constructions.sort();
    let mut constructions = constructions.into_iter().collect::<VecDeque<_>>();
    let mut awares = BinaryHeap::new();
    for d in d {
        while !constructions.is_empty() && d >= constructions[0].0 {
            let (_, x, t) = constructions.pop_front().unwrap();
            awares.push((-x, t));
        }
        while !awares.is_empty() && d >= awares.peek().unwrap().1 {
            awares.pop();
        }
        if awares.is_empty() {
            println!("-1");
        } else {
            println!("{}", -awares.peek().unwrap().0);
        }
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 12948
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
 ll X;
  cin >>X;
  
  
  ll A=X/1000;
  ll B=X/100-A*10;
   ll C=X/10-A*100-B*10;
   ll D=X-A*1000-B*100-C*10;
  
  
 
 
  
if(A+B+C+D==7) {
  cout<<A<<'+'<<B<<'+'<<C<<'+'<<D<<'='<<7<<endl;
  return 0;
}
  
  if(A+ B+ C- D==7) {
  cout<<A<<'+'<< B<<'+'<< C<<'-'<< D<<'='<<7<<endl;
  return 0;
}
  if(A+ B- C+ D==7) {
  cout<<A<<'+'<< B<<'-'<< C<<'+'<< D<<'='<<7<<endl;
  return 0;
}
  if(A+ B- C- D==7) {
  cout<<A<<'+'<< B<<'-'<< C<<'-'<< D<<'='<<7<<endl;
  return 0;
}
  if(A- B+ C+ D==7) {
  cout<<A<<'-'<< B<<'+'<< C<<'+'<< D<<'='<<7<<endl;
  return 0;
}
  if(A- B+ C- D==7) {
  cout<<A<<'-'<< B<<'+'<< C<<'-'<< D<<'='<<7<<endl;
  return 0;
}
  if(A- B- C+ D==7) {
  cout<<A<<'-'<< B<<'-'<< C<<'+'<< D<<'='<<7<<endl;
  return 0;
}
  if(A- B- C- D==7) {
  cout<<A<<'-'<< B<<'-'<< C<<'-'<< D<<'='<<7<<endl;
  return 0;
}
}
 

Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
for j in range(n):
    ans = 0
    for k in range(m):
        if ab[k][0] == j + 1:
            ans += 1
        elif ab[k][1] == j + 1:
            ans += 1
    print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long  int n,d=0;
    scanf("%lld",&n);
    long long int a[n+3],b[n+3];
    for(int i=0;i<=n;i++)
        scanf("%lld",&a[i]);
   for(int i=0;i<n;i++)
        scanf("%lld",&b[i]);
   for(int i=0;i<n;i++)
   {
       if(a[i]+a[i+1]>=b[i])
        {d+=b[i];
        if(a[i]<b[i])
        {
           a[i+1]=a[i]+a[i+1]-b[i];
        }
        
        }
       else if(a[i]+a[i+1]<b[i])
       {
           d+=a[i]+a[i+1];
            a[i+1]=0;
       }

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



Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
 
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
   
using namespace std;
   
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
   
static const double EPS = 1e-8;
   
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int main(){
  double target_temperature;
  int upper_bound;
  int temperature[2];
  int base_volume[2];
  while(~scanf("%lf %d",
               &target_temperature,
               &upper_bound)){
    scanf("%d %d",&temperature[0],&temperature[1]);
    scanf("%d %d",&base_volume[0],&base_volume[1]);
    
    double diff = numeric_limits<double>::max();
    for(int multiply_a = 0; multiply_a <= upper_bound; multiply_a++){
      for(int multiply_b = 0; multiply_b <= upper_bound; multiply_b++){
        int volume_a = multiply_a * base_volume[0];
        int volume_b = multiply_b * base_volume[1];
        if(volume_a + volume_b <= 0) continue;
        if(volume_a + volume_b > upper_bound) continue;
        double mix_temperature
          = (double)(temperature[0] * volume_a + temperature[1] * volume_b)/(double)(volume_a + volume_b);
        diff = min(diff,abs(target_temperature - mix_temperature));
      }
    }

    printf("%5lf\n",diff);
  }
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
typedef vector<int> vi;
typedef long long int ll;

int main(){
  ll N,sum=0;
  cin >> N;
  vector<ll> A(N);
  rep(i,N)
    cin >> A.at(i);
  map<ll,ll> ball;
  map<ll,ll> cb;
  rep(i,N){
    if(ball.count(A.at(i))){
      ++ball.at(A.at(i));
    }else{
      ball[A.at(i)] = 1;
    }
  }
  for(auto p : ball){
    auto v = p.second;
    if(v<=1){
      continue;
    }else{
      sum += (v*(v-1)/2);
    }
  }
  rep(i,N){
    ll n = (ball.at(A.at(i)));
    ll cnt = (n*(n-1)/2);
    --n;
    cnt -= (n*(n-1)/2);
    cout << sum - cnt << endl;
  }
}


Measured memory_bytes: 11776
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		int a[] = new int[n + 1];
		int b[] = new int[n];

		String str[] = br.readLine().split(" ");

		for (int i = 0; i < n + 1; i++) {
			a[i] = Integer.parseInt(str[i]);
		}

		str = br.readLine().split(" ");

		for (int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(str[i]);
		}

		long ans = 0;
		for (int i = 0; i < n; i++) {
			int temp = Math.min(a[i], b[i]);
			a[i] -= temp;
			b[i] -= temp;
			ans += temp;
			
			temp = Math.min(a[i + 1], b[i]);
			a[i + 1] -= temp;
			b[i] -= temp;
			ans += temp;
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 56516
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int x;
    int a[101];
    cin>>n;
    cin>>x;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    int ans=0;
    for(int i=0;i<n;i++){
        if(i==n-1 && x!=a[i]){
            break;
        }
        else if(x<a[i]) break;
        else x-=a[i];
        ans++;
    }
    
    cout<<ans<<endl;
    
    return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int n;
    cin >> n;
    map<int, int> a;
    int tmp;
    rep(i, n)
    {
        cin >> tmp;
        a[tmp]++;
    }
    int q;
    cin >> q;
    int b, c;
    ll cnt = 0;
    pair<int, int> p;
    for (auto itr = a.begin(); itr != a.end(); itr++)
    {
        p = *itr;
        cnt += p.first * p.second;
    }
    ll support;
    rep(i, q)
    {
        cin >> b >> c;
        tmp = a[b];
        a[c] += tmp;
        a[b] -= tmp;
        support = (c - b);
        support *= tmp;
        cnt += support;
        cout << cnt << endl;
        }
    return 0;
}

Measured memory_bytes: 8028
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, -1, 0, 1, 1, 1, -1, -1};
const int L = 1010;
const int N = 1000000;
int grid[L][L];
void init(){
  int l = 1;
  int x = L / 2;
  int y = L / 2;
  int r = 0;
  int rest = 1;
  for(int y = 0; y < L; y++) {
    for(int x = 0; x < L; x++){
      grid[y][x] = INF;
    }
  }
  for(int i = 1; i <= N; i++){
    assert(grid[y][x] == INF);
    grid[y][x] = i;
    x += dx[r];
    y += dy[r];
    rest--;
    if(rest == 0){
      r = (r + 1) % 4;
      if(r % 2 == 0) l++;
      rest = l;
    }
  }
}

bool prime[N + 1] = {};
void make_prime(){
  for(int i = 2; i <= N; i++) prime[i] = true;
  for(int i = 2; i <= N; i++) if(prime[i]){
    for(int j = 2 * i; j <= N; j += i){
      prime[j] = false;
    }
  }
}


int main(){
  init();
  make_prime();
  int max_n, st;
  while(cin >> max_n >> st && max_n){
    static int dp[L][L];
    for(int y = 0; y < L ; y++){
      for(int x = 0; x < L; x++){
        if(grid[y][x] == st) dp[y][x] = prime[ grid[y][x] ];
        else                 dp[y][x] = -INF;
      }
    }
    int ans1 = 0;
    int ans2 = 0;
    for(int y = 1; y < L; y++){
      for(int x = 0; x < L; x++) if(grid[y][x] <= max_n){
        for(int dx = -1; dx <= 1; dx++)if(x + dx >= 0 && x + dx < L){
          dp[y][x] = max(dp[y][x], dp[y - 1][x + dx] + prime[ grid[y][x] ]);
          if(dp[y][x] > ans1 && dp[y][x] > 0 && prime[ grid[y][x] ]){
            ans1 = dp[y][x];
            ans2 = grid[y][x];
          }else if(dp[y][x] == ans1 && dp[y][x] > 0 && prime[ grid[y][x] ]){
            ans2 = max(ans2, grid[y][x]);
          }
        }
      }
    }
    printf("%d %d\n", ans1, ans2);
  }
  return 0;
}

Measured memory_bytes: 10088
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int n,x;
int m[100000];

int main(){
  cin>>n>>x;
  rep(i,n){
    cin>>m[i];
    x-=m[i];
  }
  sort(m,m+n);
  
  cout<<n+x/m[0]<<endl;

  return 0;
}



Measured memory_bytes: 256
from heapq import heapify,heappop,heappush
n = int(input())
a = list(map(int,input().split()))
if max(a) > 0 and min(a) < 0:
  hp = []
  hn = []
  heapify(hp)
  heapify(hn)
  ans = 0
  for i in range(n):
    if a[i] >= 0:
      heappush(hp,a[i])
      ans += a[i]
    else:
      ans -= a[i]
      heappush(hn,a[i])
  print(ans)
  while hp and hn:
    p = heappop(hp)
    q = heappop(hn)
    if hn:
      print(p,q)
      heappush(hp,p-q)
    elif hp:
      print(q,p)
      heappush(hn,q-p)
    else:
      print(p,q)
elif min(a) >= 0:
  ans = sum(a)-2*min(a)
  print(ans)
  heapify(a)
  while a:
    p = heappop(a)
    if a:
      q = heappop(a)
      if a:
        print(p,q)
        heappush(a,p-q)
      else:
        print(q,p)
    else:
      break
elif max(a) <= 0:
  ans = -sum(a)+2*max(a)
  a = [-a[i] for i in range(n)]
  heapify(a)
  print(ans)
  while a:
    p = heappop(a)
    if a:
      q = heappop(a)
      if a:
        print(-p,-q)
        heappush(a,p-q)
      else:
        print(-p,-q)
    else:
      break

Measured memory_bytes: 14484
#include <iostream>
#include <cstdio>
#include <cstring>
#define MAX_L 12
using namespace std;
int fdx[] = {0, 1, 0, -1};
int fdy[] = {1, 0, -1, 0};
char table[MAX_L][MAX_L];

void dfs(int y, int x) {
    if(x < 0 || x >= MAX_L || y < 0 || y >= MAX_L || table[y][x] == '0') return;
    table[y][x] = '0'; //海で塗りつぶす
    for(int r = 0; r < 4; r++) {
        dfs(y + fdy[r], x + fdx[r]);
    }
    return;
}

int main(void) {
    while(true) {
        
        for(int r = 0; r < 12; r++) {
            if(scanf("%s", table[r]) == EOF) return(0);
        }
        int count = 0;
        for(int r = 0; r < MAX_L; r++) {
            for(int c = 0; c < MAX_L; c++) {
                if(table[r][c] == '1') {
                    dfs(r, c); count++;
                }
            }
        }
        cout << count << endl;
    }
    return(0);
}

Measured memory_bytes: 1156
//#include <bits/stdc++.h>
//
//using namespace std;
//
//int main() {
//    int n,k;
//    while(cin >> n >> k){
//            if(n % k) cout << 1 << endl;
//    else cout << 0 << endl;
////        cout << n / k - n % k << endl;
//    }
//    return 0;
//}

//
//#include <bits/stdc++.h>
//
//using namespace std;
//
//const int maxn = 200000;
//bool vis[maxn];
//int main() {
//    int n;
//    while(cin >> n) {
//        memset(vis,0,sizeof(vis));
//        for(int i = 0; i < 100; i++) {
//            int sum = i * 4;
//            for(int j = 0; j < 100; j++) {
//                sum += j * 7;
//                vis[sum] = 1;
//            }
//        }
//    if(vis[n]) printf("Yes\n");
//    else printf("No\n");
//    }
//    return 0;
//}



//
//
//#include <bits/stdc++.h>
//
//using namespace std;
//
//const int maxn = 200000;
//bool vis[maxn];
//long long s[maxn];
//long long n;
//
//int main() {
//    int n;
//    while(cin >> n) {
//        string ans = "";
////        if(n == 0) cout << 0 << endl;
//        while(n) {
//            int m = n;
//            int x = abs(n) % 2;
//            char c = x + '0';
//            ans += c ;
//            n /= -2;
//            if(m < 0 && abs(m) & 1)
//                n++;
//        }
//        reverse(ans.begin(),ans.end());
//        cout << ans << endl;
//    }
//    return 0;
//}
//






#include <bits/stdc++.h>

using namespace std;

const int maxn = 200000;
bool vis[maxn];
long long s[maxn];
long long n;

int main() {
    int n;
 string str;
 while(cin >> str){
    int len = str.size();
    for(int i = 0;i < len;i++){
        if(str[i] == '9') cout << 1 ;
        else cout << 9 ;
    } 
    cout << endl;
 }
    return 0;
}







//#include <bits/stdc++.h>
//
//using namespace std;
//
//const int maxn = 200000;
//map<long long,long long>mm;
//int n;
//long long m;
//int main() {
//    while(cin >> n >> m) {
//        long long num,sum = 0,ans = 0;
//        mm.clear();
//        mm[0]++;
//        for(int i = 1; i <= n; i++) {
//            cin >> num;
//            sum += num;
//            sum %= m;
//            ans += mm[sum];
//            mm[sum]++;
////            cout << sum <<"   " << ans << endl;
//        }
//        cout << ans << endl;
//    }
//    return 0;
//}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>

using namespace std;

int main(void) {
    int N, Q;
    string str;
    cin >> N >> Q; cin >> str;

    // 先にキャッシュを作る
    // これまで出てきたACの数を記憶する
    vector<int> AC_count(N+1, 0);
    int count = 0;
    for (int i = 0; i < N; i++) {
        if (str[i] == 'A' && str[i+1] == 'C') {
            count++;
        }
        AC_count[i+1] = count;
    }

    for (int q = 0; q < Q; q++){
        int l, r;
        cin >> l >> r;

        int ans = AC_count[r-1] - AC_count[l-1];
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long int a, b, x, count = 0, z, v, m;

    cin >> a >> b >> x;

    z = a/x;
    v = b/x;

    m = v - z;

    if(a % x == 0)
    {
        m++;
    }

    cout << m;
}


Measured memory_bytes: 3616
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

//変数
ll N;
string S;
vector<int> vec(3);

ll ans = 0;

//解法
void solve() {

	if (vec[0] == vec[1] && vec[1] == vec[2]) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return;
}

int main() {

	//入力
	rep(i, 3) {
		cin >> vec[i];
	}

	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = []
b = []
result = []
sum = 0

for i in range(n):
   mat = list(map(int, input().split()))
   a.append(mat)
   mat = []

for j in range(m):
    b.append(int(input()))

#print(a)
#print(b)

for k in range(n):
    for l in range(m):
        sum += a[k][l] * b[l]
    result.append(sum)
    sum = 0

for i in range(len(result)):
    print(result[i])


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

int main() {
    int n;
    cin >> n;
    vector<double> x(n+1),y(n+1);
    rep(i,n) cin >> x[i] >> y[i];
    vector<int> v(n);
    double cnt=0.0;
    for(int i = 0;i < n;i++) v[i]=i;
    double dis=0.0;
do{
    rep(i,n){
        //cout << v[i];
        if(i==n-1) break;
        dis+=sqrt(((x[v[i]]-x[v[i+1]])*(x[v[i]]-x[v[i+1]]))+((y[v[i]]-y[v[i+1]])*(y[v[i]]-y[v[i+1]])));
        //cout << dis << endl; 
    }
    //cout << dis << endl; 
    

cnt++;
//cout << endl;
}while(next_permutation(v.begin(),v.end()));

//cout << cnt << " " << dis << endl;
double ave;
ave = dis/cnt;
cout << fixed << setprecision(10) << ave << endl;
}



Measured memory_bytes: 3772
#include <stdio.h>
#include <string.h>

#define N 2000
void LCS(char[],char[]);

int main(int argc,char *argv[]){
  int i,n;
  char a[N],b[N];

  scanf("%d",&n);
  for(i=0; i<n; i++)
    {
      scanf("%s",a);
      scanf("%s",b);
      LCS(a,b);


    }
  return 0;



}
void LCS(char A[], char B[])
{
  int i,j,m,n;

    m = strlen(A);
    n = strlen(B);
    int a[m+1][n+1];

    for(i=0; i<=m; i++){
      for(j=0; j<=n; j++){
        a[i][j] = 0;
      }
    }

    for(i = 1; i <= m; i++){
      for(j = 1; j <= n; j++){
    if(A[i-1] == B[j-1])
      a[i][j] = a[i-1][j-1] + 1;
    else if(a[i-1][j] >= a[i][j-1])
      a[i][j] = a[i-1][j];
    else a[i][j] = a[i][j-1];
      }
    }
    printf("%d\n",a[m][n]);

}



Measured memory_bytes: 5688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

int main(){
    int n, m;
    bool flag = true;
    cin >> n >> m;
    int A[100010] = {0}, B[100010] = {0};
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        A[a-1]++;
        A[b-1]--;
    }
    for(int i = 0; i < n; i++) A[i+1] += A[i];
    for(int i = 0; i <= n; i++) if(A[i] % 2 != 0) flag = false;
    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

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

		int D = sc.nextInt();
		int N = sc.nextInt();

		if (D == 0 && N != 100) {
			System.out.println(N);
		} else if (D == 0 && N == 100){
			System.out.println(N + 1);
		} else if (D == 1 && N != 100){
			System.out.println(N * 100);
		} else if (D == 1 && N == 100){
			System.out.println((N + 1)* 100);
		} else if (D == 2 && N != 100){
			System.out.println(N * 10000);
		} else if (D == 2 && N == 100){
			System.out.println((N + 1)* 10000);
		}

	}
}

Measured memory_bytes: 23764
#include<cstdio>
#include<vector>
#include<queue>
typedef long long ll;
using namespace std;
vector<int> g[100000];
priority_queue<ll,vector<ll>,greater<ll> > q;
int n,m,x,y,visit[100000],cnt;
ll a[100000];

ll dfs(int x,int y,ll z){
    if(z>a[x]){
        q.push(z);
        z=a[x];
    }
    else{
        q.push(a[x]);
    }
    visit[x]=1;
    for(int i=0;i<g[x].size();i++){
        if(g[x][i]!=y){
            z=dfs(g[x][i],x,z);
        }
    }
    return z;
}

int main(){
    ll ans=0;
    scanf("%d %d",&n,&m);
    if(n<2*(n-1-m)){
        printf("Impossible\n");
        return 0;
    }
    else if(n-1==m){
        printf("0\n");
        return 0;
    }
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    for(int i=0;i<m;i++){
        scanf("%d %d",&x,&y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i=0;i<n;i++){
        if(visit[i]==0){
            ans+=dfs(i,-1,10000000000);
            cnt++;
        }
    }
    while(2*(n-1)>2*m+cnt){
        ans+=q.top();
        q.pop();
        cnt++;
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 8060
import sys
from fractions import gcd

N = int(sys.stdin.readline().strip())
A = list(map(int, sys.stdin.readline().strip().split()))
A.sort()

# i番目を書き換えたgcdでは左からi-1番目までと、
# 右からi+1番目までのgcdのgcd

l = [0 for _ in range(N+1)]
tmp = 0
for i in range(N):
	tmp = gcd(tmp, A[i])
	l[i+1] = tmp

r = [0 for _ in range(N+1)]
A = A[::-1]
tmp = 0
for i in range(N):
	tmp = gcd(tmp, A[i])
	r[N-i-1] = tmp
 
m = [gcd(l[i], r[i+1]) for i in range(N)]
print(max(m))

Measured memory_bytes: 16148
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
	int a, b;
	cin >> a>> b;
	if (b%a == 0)
		cout << a + b << endl;
	else
		cout << b - a << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


set<int> SET;

int main(){

	int num_query;
	scanf("%d",&num_query);

	int command,x;

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d %d",&command,&x);

		if(command == 0){

			SET.insert(x);
			printf("%lld\n",SET.size());

		}else if(command == 1){

			if(SET.count(x) > 0){

				printf("1\n");
			}else{

				printf("0\n");
			}
		}else{

			SET.erase(x);
		}
	}

	return 0;
}




Measured memory_bytes: 12588
package main

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

var sc = bufio.NewScanner(os.Stdin)

// 1行読み込み
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

// 読み込みをint型へキャスト
func nextInt() int {
	sc.Scan()
	num, err := strconv.Atoi(sc.Text())
	if(err != nil) {
		panic(err)
	}
	return num
}

// 読み込みをfloat型へキャスト
func nextFloat() float64 {
	sc.Scan()
	num, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return num
}

func main() {
	// scannerの挙動を改行区切り → 空白区切りに変更
	sc.Split(bufio.ScanWords)
	num := strings.Split(nextLine(), "")

	last_str, _ := strconv.Atoi(num[len(num) - 1])

	if last_str == 3 {
		fmt.Println("bon")
	} else if last_str == 0 || last_str == 1 || last_str == 6 || last_str == 8 {
		fmt.Println("pon")
	} else {
		fmt.Println("hon")
	}
}

Measured memory_bytes: 1772
#include<iostream>
#include<numeric>
#include<vector>
using namespace std;
int main(){
	long long N,ans; cin>>N;

	vector<long long> ret;
	for(long long i=1;i*i<=N;i++){
		if(N%i==0){
			ret.push_back(i);
			if(i!=1 && i*i!=N){
				ret.push_back(N/i);
			}
		}
	}

	ans = 1e+12;
	for(long long i=0;i<ret.size();i++){
		long long tmp = N/ret[i]+ret[i];
		if(tmp<ans){
			ans = tmp;
		}
	}

	cout<<ans-2<<endl;
}


Measured memory_bytes: 384