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

int main(){
    int64_t A, B, C;
    cin >> A >> B >> C;
    int64_t D = C-A-B;
    bool ok = (D > 0 && 4*A*B < D*D);
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {
  
  vector c(3, vector<int>(3));
  rep(i,3) rep(j,3) cin >> c[i][j];

  rep(k,101) {
    int a[3], b[3];
    a[0] = k;
    rep(j,3) b[j] = c[0][j] - a[0];
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];

    bool flag = true;
    rep(i,3) rep(j,3) {
      if (a[i] + b[j] != c[i][j]) flag = false;
    }
    if (flag) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N;
  cin >> N;
  map<string, long long> ans;
  ans["AC"] = 0;
  ans["WA"] = 0;
  ans["TLE"] = 0;
  ans["RE"] = 0;
  for(long long i = 0; i < N; i++){
    string s;
    cin >> s;
    ans[s]++;
  }
  cout << "AC" << " x " << ans["AC"] << endl;
  cout << "WA" << " x " << ans["WA"] << endl;
  cout << "TLE" << " x " << ans["TLE"] << endl;
  cout << "RE" << " x " << ans["RE"] << endl;
}

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

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	cout << ((N - 1 + K - 2) / (K - 1)) << endl;
	return 0;
}


Measured memory_bytes: 640
n = int(input())
p = list(map(int, input().split()))

i = 0
cnt = 0
while i < n:
    if i != n - 1:
        if p[i] == i + 1:
            tmp = p[i+1]
            p[i+1] = p[i]
            p[i] = tmp
            cnt += 1
    else:
        if p[i] == i + 1:
            tmp = p[i-1]
            p[i-1] = p[i]
            p[i] = tmp
            cnt += 1
    i += 1
print(cnt)

Measured memory_bytes: 52332
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
a = list(input())
a = set(a)
for ans in range(n,n+100000):
    tmp = str(ans)
    for i,t in enumerate(tmp):
        if t in a:
            break
    else:
        print(ans)
        break

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

using namespace std;

int n,m,dp[200009],ans;
vector<int>v[200002];

int dfs(int x){
  if(dp[x]!=-1)return dp[x];

  int res=0;
  for(int i=0;i<v[x].size();i++){
    res=max(res,dfs(v[x][i])+1);
  }
  return dp[x]=res;
}


int main(){
  memset(dp,-1,sizeof(dp));
  cin>>n>>m;
  while(m--){
    int x,y;
    cin>>x>>y; x--; y--;
    v[x].push_back(y);
  }
  while(n--) ans=max(ans,dfs(n));

  cout<<ans<<endl;
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
const int INF_INT = 2147483647;
const long long INF_LONG = 9223372036854775807;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
     
int main() {
  ll n, q;  cin >> n;
  map<ll, ll> map;
  ll sum=0;
  rep (i, n) {
    ll x;  cin >> x;
    if (!map.count(x)) map[x] = 0;
    map[x] += x;
    sum += x;
  }

  cin >> q;
  rep (i, q) {
    ll a, b;  cin >> a >> b;
    if (!map.count(a)) {
      cout << sum << endl;
      continue;
    }
    ll num = map[a] / a;
    sum -= map[a];
    map[a] = 0;
    map[b] += num * b;
    sum += num * b;

    cout << sum << endl;
  }
}

Measured memory_bytes: 8684
import Control.Monad

main :: IO ()
main = do
  s <- getLine
  ans <- fmap and $ forM [0..(length s)-1] $ \i -> return $ if even (i+1) then (s!!i) /= 'R' else (s!!i) /= 'L' 
  if ans then putStrLn "Yes" else putStrLn "No"

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	scanf(" %d %d %d %d",&a,&b,&c,&d);
	if(a*b>c*d){
		printf("%d",a*b);
	}else if(a*b<c*d){
		printf("%d",c*d);
	}
	else {
		printf("%d",a*b);
	}
	
}

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

#ifdef INPUT
#include <sstream>
stringstream input(R"(
45
tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir
)");
#define cin input
#endif

int main()
{
	int n;
	string s;
	cin >> n >> s;
	string a = "abcdefghijklmnopqrstuvwxyz";
	string flaga = "No";
	string flagb = "No";
	int max = 0;
	int count = 0;

	for (int i=1; i<n; i++)
	{
		for (int j=0; j<26; j++)
		{
			for (int k=0; k<i; k++)
			{
					if (s[k]==a[j])
						flaga="Yes";
			}

			for (int m=n-1; m>=i; m--)
			{
					if (s[m]==a[j])
						flagb="Yes";
			}

			if (flaga=="Yes" && flagb=="Yes")
				count++;

			flaga = "No";
			flagb = "No";
		}

		if(max < count)
			max = count;

		count = 0;
	}
	cout << max << endl;
}

Measured memory_bytes: 256
import sys
s=[list(map(int,e.split(',')))for e in sys.stdin]
for i in range(1,len(s)):
 k,l=s[i-1],len(s[i]);b=l>len(k)
 for j in range(l):s[i][j]+=max(k[(j-b)*(j>0):j-b+2])
print(*s[-1])


Measured memory_bytes: 5608
import queue

H,W,K = map(int,input().split())
x1,y1,x2,y2 = map(int,input().split())

li = [list(input()) for _ in range(H)]
cnt = [[10**10 for _ in range(W)] for _ in range(H)]
cnt2 = [[10**10 for _ in range(W)] for _ in range(H)]



xy = [[1,0], [0,1], [-1,0], [0,-1]]

q = queue.Queue()
q.put([x1-1,y1-1,0])
cnt[x1-1][y1-1] = 0

while not(q.empty()):
    mm = q.get()
    x = mm[0]
    y = mm[1]
    cst = mm[2]

    for i in range(4):
        # print(x,y)
        for j in range(1,K+1):
            nx = x+xy[i][0]*j
            ny = y+xy[i][1]*j
            # print(nx,ny)
            
            if nx>=0 and nx<H and ny>=0 and ny<W and li[nx][ny]==".":
                if cnt[nx][ny]!=10**10 and cnt[nx][ny]<cst+1:
                    break
                elif cnt[nx][ny]!=10**10:
                    continue
                else:
                    cnt[nx][ny] = cst + 1
                    q.put([nx,ny,cst+1])
            else:
                break

if cnt[x2-1][y2-1]==10**10:
    print(-1)
else:
    print(cnt[x2-1][y2-1])

# for i in range(H):
#     for j in range(W):
#         print("{:>10}".format(cnt[i][j]),end="")
#     print()





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

int main(){
  int n;
  int a[3];

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

  vector<int> can;
  for(int i=1;i*i<=a[0];i++){
    if(!(a[0]%i)){
      can.push_back(i);
      if(i*i!=a[0])can.push_back(a[0]/i);
    }
  }

  vector<int> ans;
  for(int i=1;i<n;i++){
    ans.clear();
    for(int j=0;j<can.size();j++){
      if(!(a[i]%can[j]))ans.push_back(can[j]);
    }
    can = ans;
  }

  sort(can.begin(),can.end());
  for(int i=0;i<can.size();i++)cout << can[i] << endl;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n, W;
    cin >> n >> W;
    vector<ll> w(n+1);
    vector<ll> v(n+1);
    for (int i = 1; i <= n; ++i) cin >> w[i] >> v[i];
    ll dp[n+10][W+10];
    REP(i,n+10) REP(j,W+10) dp[i][j] = 0;
    for (int i = 1; i <= n; ++i) for (int j = 0; j <= W; ++j) {
        if (j-w[i] < 0) dp[i][j] = dp[i-1][j];
        else dp[i][j] = max(dp[i-1][j-w[i]]+v[i], dp[i-1][j]);
    }
    cout << dp[n][W] << std::endl;
    return 0;
}

Measured memory_bytes: 86144
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

void f(string s, string t) {
  if(s>t) {
    cout << "GREATER" << endl;
  } 
  if(s<t) {
    cout << "LESS" << endl;
  }
  if(s == t) {
    cout << "EQUAL" << endl;
  }
}

void g(int a, int b) {
  if(a>b) {
    cout << "GREATER" << endl;
  }
  if(a<b) {
    cout << "LESS" << endl;
  }
}

int main() {
  string s, t;
  cin >> s >> t;
  int a = s.size();
  int b = t.size();
  if(a == b) {
    f(s, t);
  }
  else {
  g(a, b);    
  }
  return 0;
}

Measured memory_bytes: 256
// finish date: 2019/1/26

#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)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1000000007;
const long long INFll = 100000000000000000;


int main() {
    int H, N;
    cin >> H >> N;
    vi A(N);
    rep(i, N) cin >> A[i];
    int sum = 0;
    rep(i, N) sum += A[i];
    if (sum >= H) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


int main() {
    fio;
    
    ll n,m;cin>>n>>m;
    string temp1="",temp2="";
    
    for(ll i=0;i<n;i++){
        temp1+=to_string(m);
    }
    for(ll i=0;i<m;i++){
        temp2+=to_string(n);
    }
    
    if(temp1<temp2)
        cout<<temp1<<endl;
    else
        cout<<temp2;
    
    
	return 0;
}

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

using namespace std;
 
int main() {
	int ans = 0;
	int n;
	
	cin >> n;
	
	vector<int> ary_a(n);
	vector<int> ary_b(n);
	vector<int> ary_c(n-1);
	for(int i=0; i<n; i++){
		cin >> ary_a[i];
	}
	for(int i=0; i<n; i++){
		cin >> ary_b[i];
	}
	for(int i=0; i<n-1; i++){
		cin >> ary_c[i];
	}
	
	
	int old = 0;
	
	for(int i=0; i<n; i++){
		if(old!=0){
			if(old == ary_a[i]-1) ans += ary_c[old-1];
		}
		ans += ary_b[ary_a[i]-1];
		old = ary_a[i];
	}
	
	cout << ans;
	
	return 0;
}

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

int n;
vector<string> ans;

void dfs(string s,char c){
  vector<int> v;
  for(int i=0;i<n;i++)if(s[i]=='#')v.push_back(i);
  int A=v.size();
  if(!A)ans.push_back(s);
  else{
    s[v[0]]=c;
    for(int i=0;i<(1<<A-1);i++){
      string t=s;
      for(int j=0;j<A-1;j++)if((i>>j)&1)t[v[j+1]]=c;
      dfs(t,c+1);
    }
  }
}

int main(){
  cin>>n;
  dfs(string(n,'#'),'a');
  sort(ans.begin(),ans.end());
  for(string p:ans)cout<<p<<endl;
}


Measured memory_bytes: 7796
#include<bits/stdc++.h>
#define ll long long 
#define hell 1000000007 
#define F first
#define re 15000000
#define S second
#define pb push_back
#define all(a)  (a).begin(),(a).end()
#define rep(i,a,b) for(ll int i = a;i<b;i++)
#define pi 3.1415926536
#define Mod 998244353
using namespace std;
int main()
{
	int a,p;
	cin>>a>>p;
	cout<<(a*3+p)/2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N,K;
int x[222222];
int p,q,r;
vector<int>v;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>N>>K;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        x[a]++;
    }
    for(int i=0;i<222222;i++){
        if(x[i])
            v.push_back(x[i]);
    }
    sort(v.begin(),v.end());
    while(K--&&!v.empty()){
        N-=v.back();
        v.pop_back();
    }
    cout<<N;
}

Measured memory_bytes: 2168
#include<iostream>
#include<vector>
#include<string>

void field(std::vector<std::string>& f,int x,int y);

std::istream& input(std::vector<std::string>& vec){
	for(int i=0;i<12;i++){
		std::cin>>vec[i];
	}
	return std::cin;
}

int main(){
		std::vector<std::string> vec(12);
	while(input(vec)){

	
	int n=0;
	for(int i=0;i<12;i++){
		for(int j=0;j<12;j++){
			if(vec[i][j]=='1')field(vec,i,j),n++;
		}
	}
	std::cout<<n<<std::endl;
	}
	return 0;
}

void field(std::vector<std::string>& f,int x,int y){
	if(f[x][y]=='0')return ;
	f[x][y]='0';
	int sx=x-1,tx=x+1,sy=y-1,ty=y+1;
	if(sx>=0)field(f,sx,y);
	if(tx<12)field(f,tx,y);
	if(sy>=0)field(f,x,sy);
	if(ty<12)field(f,x,ty);
}

Measured memory_bytes: 1200
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var accumXor = new long[n + 1];
        var accumSum = new long[n + 1];
        for (int i = 0; i < n; i++)
        {
            accumSum[i + 1] = accumSum[i] + a[i];
            accumXor[i + 1] = accumXor[i] ^ a[i];
        }
        long res = 0;
        for (int i = 0; i < n; i++)
        {
            var valid = i + 1;
            var invalid = n + 1;
            while (invalid - valid > 1)
            {
                var mid = (invalid + valid) / 2;
                if (accumSum[mid] - accumSum[i] == (accumXor[mid] ^ accumXor[i])) valid = mid;
                else invalid = mid; 
            }
            res += valid - i;
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 33884
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int a,b,c;cin>>a>>b>>c;
    if(a==b&&b==c)cout<<"Yes";
    else cout<<"No";
}

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

int main(){
  int N,M; cin >> N >> M;
  vector<long long>H(N);
  for(int i=0;i<N;i++){
    cin >> H.at(i);
  }

  vector<bool>A(N,1);
  for(int i=0;i<M;i++){
    int a,b;
    cin >> a >> b;
    if(H.at(a-1)<H.at(b-1)){
      A.at(a-1)=0;
    }
    else if(H.at(a-1)>H.at(b-1)){
      A.at(b-1)=0;
    }
    else{
      A.at(a-1)=0;
      A.at(b-1)=0;
    }
  }

  int count=0;
  for(int i=0;i<N;i++){
    if(A.at(i)) count++;
  }
  cout << count << endl;
}


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

int main(){
  int i,j,n,t,h,w,a[20][20],p,m,ni,nj;
  string str;
  cin >> n;
  for(t=0;t<n;t++){
    if(t != 0) cout << endl;
    cin >> h >> w;
    for(i=0;i<h;i++){
      cin >> str;
      for(j=0;j<w;j++){
	if(str[j] == '^'){
	  a[i][j] = 0;
	  ni = i;
	  nj = j;
	  p = 0;
	}
	else if(str[j] == '<'){
	  a[i][j] = 0;
	  ni = i;
	  nj = j;
	  p = 1;
	}
	else if(str[j] == 'v'){
	  a[i][j] = 0;
	  ni = i;
	  nj = j;
	  p = 2;
	}
	else if(str[j] == '>'){
	  a[i][j] = 0;
	  ni = i;
	  nj = j;
	  p = 3;
	}
	else if(str[j] == '-') a[i][j] = 1;
	else if(str[j] == '*') a[i][j] = 2;
	else if(str[j] == '#') a[i][j] = 3;
	else a[i][j] = 0;
      }
    }

    cin >> m;
    cin >> str;
    for(i=0;i<m;i++){
      if(str[i] == 'U'){
	p = 0;
	if(ni > 0 && a[ni-1][nj] == 0) ni--;
      }
      else if(str[i] == 'D'){
	p = 2;
	if(ni < h - 1 && a[ni+1][nj] == 0) ni++;
      }
      else if(str[i] == 'L'){
	p = 1;
	if(nj > 0 && a[ni][nj-1] == 0) nj--;
      }
      else if(str[i] == 'R'){
	p = 3;
	if(nj < w - 1 && a[ni][nj+1] == 0) nj++;
      }
      else if(str[i] == 'S'){
	if(p == 0){
	  for(j=ni;j>=0;j--){
	    if(a[j][nj] == 2){
	      a[j][nj] = 0;
	      break;
	    }
	    else if(a[j][nj] == 3) break;
	  }
	}
	else if(p == 2){
	  for(j=ni;j<h;j++){
	    if(a[j][nj] == 2){
	      a[j][nj] = 0;
	      break;
	    }
	    else if(a[j][nj] == 3) break;
	  }
	}
	else if(p == 1){
	  for(j=nj;j>=0;j--){
	    if(a[ni][j] == 2){
	      a[ni][j] = 0;
	      break;
	    }
	    else if(a[ni][j] == 3) break;
	  }
	}
	else if(p == 3){
	  for(j=nj;j<w;j++){
	    if(a[ni][j] == 2){
	      a[ni][j] = 0;
	      break;
	    }
	    else if(a[ni][j] == 3) break;
	  }
	}
      }
    }

    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(ni == i && nj == j){
	  if(p == 0) cout << "^";
	  else if(p == 1) cout << "<";
	  else if(p == 2) cout << "v";
	  else if(p == 3) cout << ">";
	}
	else if(a[i][j] == 1) cout << "-";
	else if(a[i][j] == 2) cout << "*";
	else if(a[i][j] == 3) cout << "#";
	else cout << ".";
      }
      cout << endl;
    }

  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define FORl(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)
using namespace std;
int main () {
  int r;
  scanf("%d", &r);
  printf("%.6Lf\n", (long double)2.0 * pi * r);
  return 0;
}

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

string s;

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


Measured memory_bytes: 512
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,Classes;
var
  h,w,i,j,count,x,y,m,n,c,a,b,min,r,g,max:Integer;
  s:array of integer;
  s1,s2,s3:string;
  sw:char;
  tf:Boolean;
  nyu:TStringList;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(n);

    min:=1000;
    max:=0;
    for i := 0 to n - 1 do begin
      Read(a);
      min:=(min+a-abs(min-a))div 2;
      max:=(max+a+abs(max-a))div 2;
    end;
    //Writeln;
    Writeln(max-min);
    Readln;
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n, q = ril()
s = rs()
ls = rils(q)
acc = [0] * n
for i in range(1, n):
    if s[i - 1:i + 1] == 'AC':
        acc[i] = acc[i - 1] + 1
    else:
        acc[i] = acc[i - 1]
for l, r in ls:
    print(acc[r - 1] - acc[l - 1])

Measured memory_bytes: 30708
#include<stdio.h>

bool FindByBinarySearch(int x, int A[], int left, int right) {
    int mid = (left + right) / 2;
    if (x == A[mid]) return true;
    if (x >= A[left] && x < A[mid]) return FindByBinarySearch(x, A, left, mid);
    if (x > A[mid] && x <= A[right]) return FindByBinarySearch(x, A, mid+1, right);

    return false;
}

int main() {
    int n, q, S[100000], T[50000];
    int C = 0;

    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &S[i]);
    }

    scanf("%d", &q);
    for (int i = 0; i < q; ++i) {
        scanf("%d", &T[i]);
    }

    for (int i = 0; i < q; ++i) {
        if (FindByBinarySearch(T[i], S, 0, n-1)) {
            ++C;
        }
    }

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

    return 0;
}

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

using namespace std;

#define MAX_V 514
#define INF (1LL<<58)
typedef long long ll;

struct Edge {
    ll to, cap, rev;
    Edge(ll to, ll cap, ll rev) :
        to(to), cap(cap), rev(rev) {}
};

vector<Edge> G[MAX_V];
ll level[MAX_V], iter[MAX_V];

void add_edge(int from, int to, ll cap)
{
    G[from].push_back(Edge(to, cap, G[to].size()));
    G[to].push_back(Edge(from, 0, G[from].size()-1));
}

void bfs(int s)
{
    memset(level, -1, sizeof(level));
    queue<int> Q;
    level[s] = 0;
    Q.push(s);
    while (!Q.empty()) {
	int v = Q.front(); Q.pop();
	for (int i = 0; i < (int)G[v].size(); i++) {
	    Edge &e = G[v][i];
	    if (e.cap > 0 && level[e.to] < 0) {
		level[e.to] = level[v] + 1;
		Q.push(e.to);
	    }
	}
    }
}

ll dfs(int v, int t, ll f)
{
    if (v == t) return f;
    for (ll &i = iter[v]; i < (ll)G[v].size(); i++) {
	Edge &e = G[v][i];
	if (e.cap > 0 && level[v] < level[e.to]) {
	    ll d = dfs(e.to, t, min(f, e.cap));
	    if (d > 0) {
		e.cap -= d;
		G[e.to][e.rev].cap += d;
		return d;
	    }
	}
    }
    return 0;
}

ll max_flow(int s, int t)
{
    ll flow = 0;
    for (;;) {
	bfs(s);
	if (level[t] < 0) return flow;
	memset(iter, 0, sizeof(iter));
	ll f;
	while ((f = dfs(s, t, INF)) > 0) {
	    flow += f;
	}
    }
}

void init()
{
    for (ll i = 0; i < MAX_V; i++) {
        G[i].clear();
    }
}

int main()
{
    map<string, int> w = {
        {"Monday", 0},
        {"Tuesday", 1},
        {"Wednesday", 2},
        {"Thursday", 3},
        {"Friday", 4},
        {"Saturday", 5},
        {"Sunday", 6}
    };
       
    ll N, W;
    while (cin >> N >> W, N) {
        init();
        ll t, c, sum = 0;
        int S = N + 7, T = S + 1;
        for (int i = 0; i < N; i++) {
            cin >> t >> c;
            sum += t;
            add_edge(S, i, t);
            for (int j = 0; j < c; j++) {
                string s;
                cin >> s;                
                add_edge(i, N + w[s], INF);
            }            
        }
        for (int i = 0; i < 7; i++) {
            add_edge(N + i, T, W);
        }

        if (sum > 7*W) {
            cout << "No" << endl;
            continue;
        }
        cout << (max_flow(S, T) >= sum ? "Yes" : "No") << endl;
    }
    return 0;
}

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

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc int t; cin >> t; while(t--)
#define sz(x) (int)(x).size()
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

template<typename T> istream& operator>>(istream &is, vector<T> &v) { for(auto &it : v) is >> it; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep = ""; for(const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << "\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

const int N = 1e3+5;

void solve(){
    string s, t;
    cin >> s >> t;
    int n = sz(s), m = sz(t);

    int mn = m;
    for(int i = 0; i+m-1 < n; ++i){
        int ch = 0;
        for(int j = 0; j < m; ++j){
            if(s[i+j] != t[j]){
                ch++;
            }
        }
        mn = min(mn, ch);
    }

    cout << mn << "\n";
}

int main()
{
    Fast;
    //louisfghbvc{
        solve();
    //}
    return 0;
}


Measured memory_bytes: 3620
package main

import (
	"fmt"
)

func main() {
	var m1, d1, m2, d2 int
	fmt.Scanf("%d %d", &m1, &d1)
	fmt.Scanf("%d %d", &m2, &d2)
	if d2 == 1 {
		fmt.Println("1")
	} else {
		fmt.Println("0")
	}
}


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

#define ALL(a)  (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

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

#define CLEAR(a) memset((a), 0, sizeof(a))

inline int toInt(string s) { int x; istringstream iss(s); iss >> x; return x; }
template<class T> inline string toString(T x) { ostringstream oss; oss <<x ; return oss.str(); }
template<class T> inline T sqr(T x) { return x * x; }

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

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

int main(int argc, char *argv[]) {
    string s;
    cin >> s;
    int n = s.size();

    bool ac = true;
    if (s[0] != 'A') ac = false;
    else {
        int pos = -1;
        for (int i = 2; i <= n - 2; i++) {
            if (s[i] == 'C') {
                if (pos == -1) pos = i;
                else {
                    ac = false;
                    break;
                }
            }
        }
        if (pos == -1) ac = false;
        if (ac) {
            for (int i = 0; i < n; i++) {
                if (i == 0 || i == pos) continue;
                if ('A' <= s[i] && s[i] <= 'Z') {
                    ac = false;
                    break;
                }
            }
        }
    }

    if (ac) cout << "AC\n"; else cout << "WA\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

bool f(int i, int d) {
  int c = 0;

  while (i % 100 == 0) {
    i /= 100;
    c++;
  }
  if (c == d) {
    return true;
  } else {
    return false;
  }
}

int main() {
  int d, n;
  cin >> d >> n;
  int cnt = 0;
  for (int i = 1; ; i++) {
    if (f(i, d)) cnt++;
    if (cnt == n) {
      cout << i << endl;
      return 0;
    }
  }
}


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

int paper[11][11]={0};
int dx[3][14]={{0,-1,0,1,0},
               {-1,0,1,-1,0,1,-1,0,1},
               {0,-1,0,1,-2,-1,0,1,2,-1,0,1,0}};
int dy[3][14]={{1,0,0,0,-1},
               {1,1,1,0,0,0,-1,-1,-1},
               {2,1,1,1,0,0,0,0,0,-1,-1,-1,-2}};
int size[3]={5,9,13};

int main(){
    int x, y, s;
    while(scanf("%d,%d,%d",&x,&y,&s) != EOF){
        for(int i=0;i<size[s-1];++i){
            if(x+dx[s-1][i] >= 0 && x+dx[s-1][i] < 10
                    && y+dy[s-1][i] >= 0 && y+dy[s-1][i] < 10){
                paper[y+dy[s-1][i]][x+dx[s-1][i]]++;
            }
        }
    }
    int white=0, maxi=0;
    for(int i=0;i<10;++i){
        for(int j=0;j<10;++j){
            if(paper[i][j] == 0)white++;
            maxi = max(maxi, paper[i][j]);
        }
    }
    cout << white << endl << maxi << endl;

    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,st,en) for(i=st;i<=en;i++)
#define repv(i,en,st) for(i=en;i>=st;i--)
#define fout cout<<fixed<<setprecision(7)
#define bi(n) __builtin_popcount(n)
#define bil(n) __builtin_popcountll(n)


typedef long long ll;
typedef pair<int,int> pii;
const int N = 100010;
ll mod = 1e9+7;
ll fmod(ll b,ll exp){
    ll res =1;
    while(exp){if(exp&1ll)res=(res*b)%mod;
    b =(b*b)%mod;exp/=2ll;
    }
    return res;
}

int A[N];
int gcd(int a,int b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1,n,i,j;
    int x;
    cin>>n>>x;
    fr(i,n)cin>>A[i];
    sort(A,A+n);
    int ans = 0;
    int ind = lower_bound(A,A+n,x)-A;
    rep(i,1,ind-1)ans = gcd(ans,(A[i]-A[i-1]));
    rep(i,ind,n-2)
        ans= gcd(ans,(A[i+1]-A[i]));


    if(ind>0)ans = gcd(ans,gcd(ans,x-A[ind-1]));
    if(ind<n)ans = gcd(ans,A[ind]-x);
    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <queue>
using namespace std;

int main(void){
    int n,q,x,y;
    cin>>n>>q;
    queue<int> Q[n];
    while(q--){
        cin>>x;
        if(x==0){
            cin>>x>>y;
            Q[x].push(y);
        }else if(x==1){
            cin>>x;
            if(Q[x].size()!=0) cout<<Q[x].front()<<endl;
        }else{
            cin>>x;
            if(Q[x].size()!=0)Q[x].pop();
        }
    }
}


Measured memory_bytes: 4448
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <map>
using namespace std;

typedef long long ll;
const int MAXN = 36 + 10;
int N;
char S[MAXN];
map<pair<string, string>, ll> mp;
ll ans;

int main() {
	register int s, i;
	scanf("%d%s", &N, S);
	for(s = 0; s < (1 << N); ++s) {
		string s1, s2;
		for(i = 0; i < N; ++i)
			if(s >> i & 1)
				s1.push_back(S[i]);
			else
				s2.push_back(S[i]);
		++mp[make_pair(s1, s2)];
	}
	for(s = 0; s < (1 << N); ++s) {
		string s1, s2;
		for(i = N - 1; ~i; --i)
			if(s >> i & 1)
				s2.push_back(S[N + i]);
			else
				s1.push_back(S[N + i]);
		ans += mp[make_pair(s1, s2)];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 91904
N, Y = map(int, input().split())

res = [-1] * 3

for x in range(0, N + 1):
	if 10000 * x > Y:
		break; 
	for y in range(0, N - x + 1):
		if 10000 * x + 5000 * y > Y:
			break;
		remain = Y - 10000 * x - 5000 * y
		if remain < 0:
			break
		if x + y > N:
			break
		z = remain // 1000
		if x + y + z == N and 10000 * x + 5000 * y + 1000 * z == Y:
			res[0],res[1],res[2] = x, y, z
			break

print(" ".join(map(str,res)))

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main(){
    string s;
    while(getline(cin,s) && s[0]!='0'){
        long sum=0;
        F(i,0,s.size()){
            sum+=s[i]-'0';
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3212
from sys import stdin


def main():
    readline = stdin.readline
    readline()
    A = tuple(map(int, readline().split()))
    B = tuple(map(int, readline().split()))
    pre = A[0]
    ans = 0
    for a, b in zip(A[1:], B):
        tmp1 = pre if pre < b else b
        b -= tmp1
        tmp2 = a if a < b else b
        ans += tmp1 + tmp2
        pre = a - tmp2
    print(ans)
    return


main()


Measured memory_bytes: 19376
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i=0; i<n; i++) arr[i] = sc.nextInt();

        int[] l = new int[n+1];
        int[] r = new int[n+1];

        l[0] = 0;
        r[n] = 0;

        for (int i=0; i<n; i++) {
            l[i+1] = gcd(arr[i], l[i]);
        }

        for (int j=n-1; 0<=j; j--) {
            r[j] = gcd(arr[j], r[j+1]);
        }

        int ret = 0;

        for (int i=0; i<n; i++) {
            ret = Math.max(ret, gcd(l[i], r[i+1]));
        }
        ret = Math.max(ret, l[n]);

        for (int i=0; i<n+1; i++) {
//            System.out.print(l[i] + " ");
        }
//        System.out.println();
        for (int i=0; i<n+1; i++) {
//            System.out.print(r[i] + " ");
        }
        System.out.println(ret);


    }

    int gcd(int m, int n) {
        if (n == 0) return m;
        return gcd(n, m%n);
    }


}



Measured memory_bytes: 50188
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string st1,st2;
    long long i,ln,op=0;

    cin>>st1;
    cin>>st2;

    for(i=0;i<st1.size();i++){
        if(st1[i]!=st2[i]){
            op++;
        }
    }
    cout<<op<<endl;

}


Measured memory_bytes: 3916
#include<stdio.h>

int gcd(int x, int y);

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

int gcd(int x, int y)
{
    
    int r, temp;
    
    if(x<y)
    {
        temp = x;
        x = y;
        y = temp;
        
    }
    
    r = x%y;
    
    while(r!=0)
    {
        x=y;
        y=r;
        r=x%y;
    }
    
    return y;
}


Measured memory_bytes: 2080
n = int(input())
sum_n = (1/2)*n*(n+1)
sum_3 = (1/2)*(n//3)*(n//3+1)*3
sum_5 = (1/2)*(n//5)*(n//5+1)*5
sum_15 = (1/2)*(n//15)*(n//15+1)*15
print(str(int(sum_n+sum_15-sum_3-sum_5)))

Measured memory_bytes: 61728
#include<iostream>
#include<cstring>
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        int dp[n][n];
        memset(dp, 0, sizeof(dp));
        char mat[n][n];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                cin >> mat[i][j];
            }
        }
        
        for(int i = 0; i < n; i++){
            if(mat[0][i] == '.')    dp[0][i] = 1;
            if(mat[i][0] == '.')    dp[i][0] = 1;
        }
        
        for(int i = 1; i < n; i++){
            for(int j = 1; j < n; j++){
                if(mat[i][j] == '.')
                    dp[i][j] = 1 + min(dp[i-1][j-1], min(dp[i-1][j], dp[i][j-1]));
            }
        }
        
        int ans = 0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                ans = max(ans, dp[i][j]);
            }
        }
        
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 7892
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}

ll p[MAX+10];

void eratos() {
  ll i, j;
  for(i=0; i<=MAX; i++) p[i]=1;
  
  p[0]=p[1]=0;
  for(i=2; i*i<=MAX; i++) {
    if(p[i]==0) continue;
    for(j=i+i; j<=MAX; j+=i) {
      p[j]=0;
    }
  }
  
  
}


int main(void) {
  ll x;
  cin >> x;
  ll i;
  eratos();
  for(i=x; i<=MAX; i++) {
    if(p[i]) {
      pt(i);
      return 0;
    }
  }
  
  
}


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

int main(){
	
	int N , x ;
	
	cin >> N ;
	for( int c=1 ; c<=N ; c++ ){
		cin >> x ;
		
		printf("Case %d:\n",c) ;
		
		for( int i=0 ; i<10 ; i++ ){
			x *= x ;
			x /= 100 ;
			int tmp = 0 , p = 1 ;
			for( int k=0 ; k<4 ; k++ ){
				tmp += ( x%10 ) * p ;
				x /= 10 ;
				p *= 10 ;
			}
			x = tmp ;
			cout << x << endl ;
		}
	}
	
return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int a,b,c; cin >>a>>b>>c;
	if(a<b&&b<c) cout << "Yes"<<endl;
	else cout << "No"<< endl;
	

}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Mx 200001
#define inf 1e15
const L MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a,b,a1,a2,a3,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,
q,q1,q2,q3,q4,r,s,t,u,v,x,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id1,id2,id3,id4,lim;

//double rat;
L A[205],B[205];
char str[10];

int main()
{
	mx=0;
    scanf("%s",str);
    l=strlen(str);
    for(L i=0;i<l;i++){
    	c=0;
    	for(L j=i;j<l;j++){
    		if(str[j]=='R')c++;
    		else break;
    	}
    	mx=max(c,mx);
    }
    printf("%lld\n",mx);
    return 0;
}
/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, n) cin >> l[i];
  sort(l.begin(), l.end());

  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int a = l[i];
      int b = l[j];
      auto ite1 = upper_bound(l.begin() + j, l.end(), abs(a - b));
      int id1 = distance(l.begin(), ite1);
      auto ite2 = lower_bound(l.begin() + j, l.end(), a + b);
      int id2 = distance(l.begin(), ite2);
      int num = id2 - id1 - 1;
      ans += num;
    }
  }

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

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    set<int> *pos = new set<int>[26];
    rep(i, n) pos[s[i] - 'a'].insert(i);
    int q;
    cin >> q;
    rep(k, q)
    {
        int t;
        cin >> t;
        if( t == 1 )
        {
            int i;
            char c;
            cin >> i >> c;
            i--;
            if( s[i] != c )
            {
                pos[s[i] - 'a'].erase(pos[s[i] - 'a'].find(i));
                pos[c - 'a'].insert(i);
                s[i] = c;
            } 
        }
        else
        {
            int l, r;
            cin >> l >> r;
            int ans = 0;
            l--; r--;
            rep(j, 26)
            {
                auto itr = pos[j].lower_bound(l);
                if( itr != pos[j].end() && *itr <= r ) ans++;
            }
            cout << ans << endl;
        }
        
    }
}

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

int d,l,r;

signed main()
{
	cin>>l>>r>>d;
	
	if (l%d!=0)  l=l+(d-l%d);
	r=(r/d)*d;
	
	cout<<((r-l)/d)+1<<endl;
	
	return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
using namespace std;
int primepref[100001];
int q, l, r;
int main() {
	for (int i = 2; i <= 100000; i++)
		primepref[i] = 1;
	for (int i = 2; i < 100000; i++) {
		for (int j = i * 2; j <= 100000; j += i) {
			primepref[j] = 0;
		}
	}
	for (int i = 2; i <= 100000; i++) {
		if (primepref[i] == 1 && primepref[(i + 1) / 2] == 0)
			primepref[i] = -1;
	}
	for (int i = 2; i <= 100000; i++) {
		primepref[i] = (primepref[i] == 1 ? 1: 0);
		primepref[i] += (primepref[i - 1]);
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> l >> r;
		cout << primepref[r] - primepref[l - 1] << '\n';
	}
}


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

typedef long long lint;
typedef pair<int, int> pii;

const int INF = 2e9;
const int MOD = 1e9+7;
const int MAX = 1e5+10;
const lint LNF = 2e18;

int n, m;
priority_queue<int> Q;

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

	cin>>n>>m;
	for(int i=1,x; i<=n; i++) cin>>x, Q.push(x);
	while(m--){
		int x=Q.top(); Q.pop();
		Q.push(x/2);
	}
	lint s = 0, x;
	while(!Q.empty()) x=Q.top(),Q.pop(),s+=x;
	cout<<s<<'\n';

	return 0;
}


Measured memory_bytes: 892
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int a,b,c;
    cin>>a>>b>>c;
    if((a*a+b*b==c*c)||(b*b+c*c==a*a)||(c*c+a*a==b*b)){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
  return 0;   
}
  

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

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

//Tのmaxが10**18だからlong longを使っている
using ll=long long;

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

ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  //a*b/gだとoverflow
  return a/g*b;
}

int main(){
  int n;
  cin>>n;
  ll ans=1LL;

  REP(i,n){
    ll T;
    cin>>T;
    //入力の度に計算する
    ans=lcm(ans,T);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

data=[]
n,k=map(int,input().split())
for i in range(n):
    a,b=map(int,input().split())
    data.append((a,b))
data.sort()
for di in data:
    if di[1]>=k:
        print(di[0])
        exit()
    else:
        k-=di[1]

Measured memory_bytes: 47836
fun computeTriangleArea(a: Double, b: Double, c: Double): Double {
    val  s = (a + b + c) / 2.0
    return Math.sqrt(s * (s - a) * (s - b) * (s - c))
}


fun computeTriangleHeight(a: Double, area: Double): Double {
    return 2 * area / a
}


fun main(args: Array<String>) {
    val (a, b, angle) = readLine()!!.split(" ").map(String::toDouble)
    val c = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle)))
    val area = computeTriangleArea(a, b, c)
    val length = a + b + c
    val height = computeTriangleHeight(a, area)
    println("$area")
    println("$length")
    println("$height")
}



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

void Main()
{
    int n, a;
    cin >> n;
    int b[n] = {0};
    for (size_t i = 0; i < n-1; i++)
    {
        cin >> a;
        b[a-1] += 1;
    }
    
    for (size_t i = 0; i < n; i++){
        cout << b[i] << endl;
    }
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


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

B = []
for k in range(N):
    B.append(A[k]-k-1)
B = sorted(B)

if N%2 == 0:
    b = (B[N//2]+B[-1+N//2])//2
else:
    b = B[N//2]

ans = 0
for k in range(N):
    ans += abs(A[k]-b-k-1)

print(ans)

Measured memory_bytes: 101332
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 2e5;
const int posp[4] = {3, 2, 1, 0}, negp[4] = {1, 0, 3, 2}, parp[4] = {2, 3, 0, 1};
const bool post[4] = {1, 1, 0, 0}, negt[4] = {0, 1, 1, 0}, part[4] = {1, 1, 0, 0};

int n, x[N + 1], y[N + 1], u[N + 1], id[256], ans = 0x7fffffff;
char c;
vector<int> pos[4][N * 2 + 1], neg[4][N * 2 + 1], par[4][N + 1];
vector<int>::iterator it;

int main(){
	id['U'] = 0, id['R'] = 1, id['D'] = 2, id['L'] = 3;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%d%d %c", x + i, y + i, &c);
		u[i] = id[c];
		if(u[i] == 0 || u[i] == 2)
			par[u[i]][x[i]].push_back(y[i]);
		else par[u[i]][y[i]].push_back(x[i]);
		pos[u[i]][N + y[i] - x[i]].push_back(x[i]);
		neg[u[i]][x[i] + y[i]].push_back(x[i]);
	}
	for(int i = 0; i < 4; i++)
		for(int j = 0; j <= N; j++)
			sort(par[i][j].begin(), par[i][j].end());
	for(int i = 0; i < 4; i++)
		for(int j = N * 2; ~j; j--){
			sort(pos[i][j].begin(), pos[i][j].end());
			sort(neg[i][j].begin(), neg[i][j].end());
		}
	for(int i = 1; i <= n; i++){
		if(u[i] == 0 || u[i] == 2){
			if(part[u[i]]){
				if(par[parp[u[i]]][x[i]].size() && par[parp[u[i]]][x[i]].back() > y[i])
					ans = min(ans, *lower_bound(par[parp[u[i]]][x[i]].begin(), par[parp[u[i]]][x[i]].end(), y[i]) - y[i]);
			}else if(par[parp[u[i]]][x[i]].size() && par[parp[u[i]]][x[i]].front() < y[i])
				ans = min(ans, y[i] - *--lower_bound(par[parp[u[i]]][x[i]].begin(), par[parp[u[i]]][x[i]].end(), y[i]));
		}else{
			if(part[u[i]]){
				if(par[parp[u[i]]][y[i]].size() && par[parp[u[i]]][y[i]].back() > x[i])
					ans = min(ans, *lower_bound(par[parp[u[i]]][y[i]].begin(), par[parp[u[i]]][y[i]].end(), x[i]) - x[i]);
			}else if(par[parp[u[i]]][y[i]].size() && par[parp[u[i]]][y[i]].front() < x[i])
				ans = min(ans, x[i] - *--lower_bound(par[parp[u[i]]][y[i]].begin(), par[parp[u[i]]][y[i]].end(), x[i]));
		}
		if(post[u[i]]){
			if(pos[posp[u[i]]][N + y[i] - x[i]].size() && pos[posp[u[i]]][N + y[i] - x[i]].back() > x[i])
				ans = min(ans, (*lower_bound(pos[posp[u[i]]][N + y[i] - x[i]].begin(), pos[posp[u[i]]][N + y[i] - x[i]].end(), x[i]) - x[i]) * 2);
		}else if(pos[posp[u[i]]][N + y[i] - x[i]].size() && pos[posp[u[i]]][N + y[i] - x[i]].front() < x[i])
			ans = min(ans, (x[i] - *--lower_bound(pos[posp[u[i]]][N + y[i] - x[i]].begin(), pos[posp[u[i]]][N + y[i] - x[i]].end(), x[i])) * 2);
		if(negt[u[i]]){
			if(neg[negp[u[i]]][x[i] + y[i]].size() && neg[negp[u[i]]][x[i] + y[i]].back() > x[i])
				ans = min(ans, (*lower_bound(neg[negp[u[i]]][x[i] + y[i]].begin(), neg[negp[u[i]]][x[i] + y[i]].end(), x[i]) - x[i]) * 2);
		}else if(neg[negp[u[i]]][x[i] + y[i]].size() && neg[negp[u[i]]][x[i] + y[i]].front() < x[i])
			ans = min(ans, (x[i] - *--lower_bound(neg[negp[u[i]]][x[i] + y[i]].begin(), neg[negp[u[i]]][x[i] + y[i]].end(), x[i])) * 2);
	}
	if(ans == 0x7fffffff) printf("SAFE");
	else printf("%d", ans * 5);
	return 0;
}

Measured memory_bytes: 117888
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let mut ans = 0;
    for A in 1..=N {
        for B in 1..=N {
            if A * B >= N {
                break;
            }
            ans += 1;
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 2140