akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
  string a;
  cin >> a;
  int i = 0;
  
  if (a.at(0) == '1') {
    i++;
  }
    if (a.at(1) == '1') {
    i++;
  }
    if (a.at(2) == '1') {
    i++;
  }
  cout << i << endl;
}


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

int main() {
  long n,ans=0;
  cin >> n;
  vector<long> a(n);
  for(long i=0;i<n;i++) cin >> a[i];
  for(long i=0;i<n;i+=2) {
    if(a[i]%2==1) ans++;
  }
  cout << ans << endl;
}

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

int main() {
	string s;
	cin>>s;
	string s1="SUNMONTUEWEDTHUFRISAT";
	int c=0;
	for(int i=0; i<s1.length(); i++) {
	    for(int j=0; j<3; j++) {
	        if(s[j]!=s1[i+j]) {
	            c=0;
	            break;
	        }
	        c++;
	    }
	    if(c==3) {
	        int x = (i+1)/3;
	        int ans = 7 - x;
	        cout<<ans;
	        break;
	    }
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace hitachi2020_b
{
  class Program
  {
    static void Main(string[] args)
    {
      var A = CIn.ReadInt();
      var B = CIn.ReadInt();
      var M = CIn.ReadInt();

      var a = CIn.ReadIntArray(A);
      var b = CIn.ReadIntArray(B);

      var ans = a.Min() + b.Min();

      for (int i = 0; i < M; i++)
      {
        var x = CIn.ReadInt() - 1;
        var y = CIn.ReadInt() - 1;
        var c = CIn.ReadInt();

        ans = Math.Min(ans, a[x] + b[y] - c);
      }

      Console.WriteLine(ans);
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 35804
#include<bits/stdc++.h>
using namespace std;
 
int main () {
  int n,m;
  cin >>n>>m;

  int ans =0;
  int n1 = (n*(n-1))/2;
  int n2 = (m*(m-1))/2;

  ans =n1+n2;
  if(n == 0){
    cout <<n2<<endl;;
  }else if(m==0){
    cout<<n1<<endl;
  }else{
  cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
n,k = map(int, input().split())
p=list(map(float, input().split()))

for i in range(len(p)):
    p[i] = (1+p[i]) / 2
    
max = 0

for i in range(k):
    max += p[i]
tmp = max

for i in range(n-k):
    tmp = tmp - p[i] + p[i+k]
    if max < tmp: max = tmp
print(max)

Measured memory_bytes: 71792
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll a, b, c;
  cin>>a>>b>>c;
  if(c-a-b>=0 && 4*a*b<(c-a-b)*(c-a-b)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3596
n, m = map(int, input().split())

if (n == 1) & (m == 1):
    print(1)
elif (n == 1) | (m == 1):
    print(max([n, m]) - 2)
elif (n == 2) | (m == 2):
    print(0)
else:
    print((n - 2) * (m - 2))


Measured memory_bytes: 2940
n = int(input())
jpy = 0
btc = 0
for i in range(n):
    x, u = map(str, input().split())
    if u == 'JPY':
        x = int(x)
        jpy += x
    else:
        x = float(x)
        btc += x
print(jpy + btc*380000.0)

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  
  vector<pair<int, int>> x;
  if (n % 2 == 0) {
    int keep = n - 2, keep2 = keep / 2, keep3 = (keep2 + 1) / 2;
    for (int i = 1; i <= keep3; i++) {
      x.emplace_back(make_pair(i, keep3 * 2 - i + 1));
    }
    int dis = keep2;
    if (dis % 2 == 1) dis--;
    for (int i = 1; i <= keep2; i++) {
      int j = n - i + 1;
      x.emplace_back(make_pair(j, j - dis));
      dis -= 2;
    }
  }
  else {
    for (int i = n / 2; i > 0; i--) {
      x.emplace_back(make_pair(i, n - i));
    }
  }
  
  for (int i = 0; i < m; i++) cout << x.at(i).first << " " << x.at(i).second << '\n';
}

Measured memory_bytes: 4252
class dice:

    def __init__(self, numlist):
        self._men = {"T": numlist[0],
                     "B": numlist[5],
                     "N": numlist[4],
                     "S": numlist[1],
                     "W": numlist[3],
                     "E": numlist[2]}

    def roll(self, direction):
        t = dict(self._men)

        if direction == "N":
            self._men["T"] = t["S"]
            self._men["B"] = t["N"]
            self._men["N"] = t["T"]
            self._men["S"] = t["B"]
        elif direction == "S":
            self._men["T"] = t["N"]
            self._men["B"] = t["S"]
            self._men["S"] = t["T"]
            self._men["N"] = t["B"]
        elif direction == "W":
            self._men["T"] = t["E"]
            self._men["B"] = t["W"]
            self._men["W"] = t["T"]
            self._men["E"] = t["B"]
        elif direction == "E":
            self._men["T"] = t["W"]
            self._men["B"] = t["E"]
            self._men["W"] = t["B"]
            self._men["E"] = t["T"]


    def clock(self):
        t = dict(self._men)
        self._men["E"] = t["N"]
        self._men["N"] = t["W"]
        self._men["W"] = t["S"]
        self._men["S"] = t["E"]


    def simpleequal(self, d2):
        if self._men == d2._men:
            return True
        else:
            return False


    def equal(self, d2):
        for _ in range(4):
            d2.roll("N")

            for _ in range(4):
                d2.clock()
                if self.simpleequal(d2):
                    return True

        d2.roll("E")
        for _ in range(4):
            d2.clock()
            if self.simpleequal(d2):
                return True


        d2.roll("E")
        d2.roll("E")
        for _ in range(4):
            d2.clock()
            if self.simpleequal(d2):
                return True



    def gettop(self):
        return self._men["T"]

def decode():
    n = int(input())
    nlists = []
    for _ in range(n):
        numlist = [int(x) for x in input().split()]
        nlists.append(numlist)

    return n, nlists


def isunique(dices):
    for i in range(n-1):
        for j in range(i+1, n):
            if dices[i].equal(dices[j]):
                return False
    return True


if __name__ == '__main__':

    n, nlists = decode()
    dices = []
    for numlist in nlists:
        dices.append(dice(numlist))

    if isunique(dices):
        print("Yes")
    else:
        print("No")


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;
vector<long long>prime;
//status unsolved
long long  beki(long long  b, long long e)
{
    long long m=mod;
    long long ans = 1;

    while (e > 0) {
       if ((e & 1) == 1) ans = (ans * b) % m;
       e >>= 1;
       b = (b * b) % m;
    }

    return ans;
}
void prepare(long long k){

    for(long long  i=2;i<=k;i++){
        prime.emplace_back(i);
    }
    for(int i=0;i<prime.size();i++){
        long long now=prime[i];
        for(int l=i+1;l<prime.size();l++){
            if(prime[l]%now==0){
                prime.erase(prime.begin()+l);
            }
        }
    }
    return;

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

    long long ans=0;
    prepare(k);
    /*
    rep(i,prime.size())cout<<prime[i]<<" ";
    cout<<endl;
    return 0;
    */
    int en=prime.size();
    //ans+=(beki(n,en)-en)%mod;
    //long long p=beki(k,n);
    long long cnt[100010];

    for(long long i=k;i>=1;i--){

        
        long long multi=floor((double)k/i);
        
        //gcdがiの倍数になる組み合わせ
        long long total=beki(multi,n);

        for(int l=2;l*i<=k;l++){
            total-=cnt[l*i];
            //total%=mod;
            if(total<0)total+=mod;
        }
        cnt[i]=total;
        //cout<<i<<" "<<cnt[i]<<endl;
        ans+=cnt[i]*i;
        if(ans>mod)ans%=mod;
    }
    
    cout<<ans<<endl;
    return 0;

}
/*
10149456

10813692

297711102

742202979
*/


Measured memory_bytes: 4860
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;++i)
	{
		cin>>a[i];
	}
	int cnt2=0,cnt4=0;
	for(int i=0;i<n;++i)
	{
	if(!(a[i]%4))
		cnt4++;
	else if(!(a[i]%2))
		cnt2++;
	}
	cnt2/=2;
	if(cnt2+cnt4>=n/2)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 640
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;
#define U(v) cerr << #v << ": " << (v) << endl

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    string sa = "Alice";
    string ba = "Borys";
    for (int i = 0; i < 1000; ++i) {
        bool l = false;
        bool r = false;
        if (a - 1 >= 1 && a - 1 != b)
            l = true;
        if (a + 1 <= n && a + 1 != b)
            r = true;
        if (!l && !r) {
            cout << ba << endl;
            return 0;
        } else if (l && r) {
            if (a < b) {
                ++a;
            } else {
                --a;
            }
        } else if (l) {
            --a;
        } else if (r) {
            ++a;
        }
        swap(a, b);
        swap(sa, ba);
    }
    cout << "Draw" << endl;
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
const int nmax = 1000;
const int vmax = 1000000;
vvint a(nmax,vint(nmax,0));
vvint chd(vmax);
vvint id(nmax,vint(nmax,0));
vint np(vmax,0);
vint dp(vmax);
int to_id(int x, int y){
    if(x>=y){
        swap(x,y);
    }
    return id[x][y];
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    REP(i,n){
        REP(j,n-1){
            cin >> a[i][j];
            a[i][j]--;
        }
    }
    int v=0;
    REP(i,n){
        for(int j=i+1;j<n;j++){
            id[i][j]=v;
            v++;
        }
    }
    REP(i,n){
        int pre;
        pre = to_id(i,a[i][0]);
        for(int j=1;j<n-1;++j){
            int now = to_id(i,a[i][j]);
            np[now]++;
            chd[pre].pb(now);
            pre = now;
        }
    }
    queue<int> q;
    REP(i,v){
        if(np[i]==0){
            q.push(i);
            dp[i]=1;
        }
    }
    
    while(!q.empty()){
        int now = q.front();
        q.pop();
        for(int i : chd[now]){
            dp[i] = max(dp[i],dp[now]+1);
            np[i]--;
            if(np[i]==0){
                q.push(i);
            }
        }
    }

    int ans = 0;
    REP(i,v){
        if(np[i]>0){
            puts("-1");
            return 0;
        }
        ans = max(ans,dp[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 55040
T=input()
for i in range(2**3):
  t=''
  for j in range(4):
    t+=T[j]
    if ((i>>j)&1):
      t+='+'
    else:
      if j!=3:
        t+='-'
  if eval(t)==7:
    print(t+"=7")
    break

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

int main() {
  int N;
  scanf("%d", &N);

  vector<int> height(N+1, 0);
  vector<int> cost(N+1, 0);

  for (int i = 1; i <= N; i++) {
    scanf("%d", &height.at(i));
  }

  for (int i = 2; i <= N; i++) {
    cost.at(i) = cost.at(i-1) + abs( height.at(i) - height.at(i-1) );
    if (i > 2) cost.at(i) = min( cost.at(i), cost.at(i-2) + abs( height.at(i) - height.at(i-2) ) );
  }

  printf("%d\n", cost.at(N));
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int A[N];
  int ans = 0;
  for(int i = 0; i < N; i++) cin >> A[i];

  for(int i = 0; i < N; i++) {
    ans += A[i] - 1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
var
  s: ansistring;
begin
  readln(s);
  if s = 'SUN' then writeln(7)
  else if s = 'MON' then writeln(6)
  else if s = 'TUE' then writeln(5)
  else if s = 'WED' then writeln(4)
  else if s = 'THU' then writeln(3)
  else if s = 'FRI' then writeln(2)
  else writeln(1);
end.

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<vector>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std;


int main() {
	long long int N;
	cin >> N;
	long long int cnt = 0;
	for (long long int i = 1;; i++) {
		for (long long int j = N / i; j > N / (i + 1); j--) {
			if (N / j == N % j) {
				cnt = cnt + j;
			}
			else if (i * j + i < N)
				break;
		}
		if (N < (i + 1) * i + i)
			break;
	}
	
	cout << cnt;
	return 0;
}


Measured memory_bytes: 384
import java.util.*;

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

        for(int a=0;a<=N;a++){
            for(int b=0;b<=N-a;b++){
                int c=N-a-b;
                int total=a*10000+b*5000+c*1000;
                if(total==Y){
                    System.out.println(a+" "+b+" "+c);
                    return;
                }
            }
        }
        System.out.println("-1 -1 -1");
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<int> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}

    set<int> tt;
    int ans = 0;
    rep(i, n){
        if (a[i] >= 3200){
            ans++;
        } else {
            tt.insert(a[i]/400);
        }
    }

    cout << max((int)tt.size(), 1) << " "<< tt.size() + ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r1(i, n) for (int i=0;i<n;i++)
#define r2(i, n) for (int i=0;i<n;i+=2)
#define intc(n) int n; cin >> n;
#define ll long long
#define llc(n) ll n; cin >> n;
using namespace std;
int main() {
  intc(n);
  vector<ll> a(n);
  r1(i, n) cin >>a.at(i);
  sort(a.begin(), a.end());
  string s="YES";
  r1(i, n-1) {
    if(a.at(i)==a.at(i+1)) {
      s="NO";
      break;
    }
  }
  cout << s << endl;
}

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

int main(){
string S,T;
  cin>>S;
  cin>>T;
  int i,flag = 0;
  if(T.size() == S.size() + 1){
  for(i=0;i<S.size();i++){
  	if(S[i] != T[i])
    	flag = 1;
  	}
    if(flag == 1)
      cout<<"No"<<endl;
    else
      cout<<"Yes"<<endl;
  }
  else
    cout<<"No"<<endl;
    
return 0;
}

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

#define lli long long int
#define FOR(i,n) for(i = 0; i < n; i++)
#define ALL(arr) arr.begin(),arr.end()
#define PI acos(-1)

using namespace std;

void solve()
{
    lli n,i,a,b,c;
    cin >> n ;
    lli ans = 0;
    ans += (n/500) * 1000;
    n = n%500;
    ans += (n/5) * 5;
    cout << ans << endl;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <fstream>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define ll long long

template<class T> inline bool chmin(T & a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

int main() {
	int n;

	cin >> n;
	vector<int> h(n);
	vector<int> dp(n);
	rep(i, n) {
		cin >> h[i];
	}

	//ループ 1～n
	for(int i=1;i<n;++i) {
		dp[i] = INT_MAX;
		chmin(dp[i], dp[i-1] + abs(h[i - 1] - h[i]));
		if (i>1) chmin(dp[i], dp[i-2] + abs(h[i - 2] - h[i]));
	}

	//答え
	cout << dp[n-1] << endl;
}


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int 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 dp[3333];

signed main() {

    string s;
    cin >> s;

    int cur = 0;
    dp[cur] = 1;
    ll d = 1;
    ll ans = 0;
    for(int i = s.size() - 1; i >= 0; i--) {
        cur += d * (s[i] - '0');
        cur %= 2019;
        ans += dp[cur];
        dp[cur]++;
        d = d*10%2019;
    }

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



Measured memory_bytes: 3752
class Node:
    def __init__(self, node_id, left_child, right_child):
        self.node_id = node_id
        self.parent = -1
        self.sibling = -1
        self.degree = 0
        self.depth = 0
        self.height = 0
        self.node_type = ''

        self.left_child = left_child
        self.right_child = right_child
        

def binarytrees():
    def input_node_list():
        n = int(input())

        for i in range(n):
            node_id, left_child, right_child = list(map(int, input().split()))

            node = Node(node_id, left_child, right_child)
            node_list.append(node)

        node_list.sort(key = lambda node: node.node_id)

    def calc_parent_sibling_degree():
        if node.left_child != -1:
            node_list[node.left_child].parent = node.node_id
            node_list[node.left_child].sibling = node.right_child
            node.degree += 1

        if node.right_child != -1:
            node_list[node.right_child].parent = node.node_id
            node_list[node.right_child].sibling = node.left_child
            node.degree += 1

    def calc_depth(node_id):
        if  node_list[node_id].parent == -1:
            return 0
        else:
            return calc_depth(node_list[node_id].parent) + 1

    def calc_height(node_id):
        if not node_list[node_id].degree:
            return 0
        else:
            return max(calc_height(node_list[node_id].left_child),
                calc_height(node_list[node_id].right_child)) + 1

    def calc_node_type():
        if node.depth == 0:
            node.node_type = 'root'
        elif node.height == 0:
            node.node_type = 'leaf'
        else:
            node.node_type = 'internal node'

    def show_node_info():
        print('node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'
            .format(node.node_id, node.parent, node.sibling,
            node.degree, node.depth, node.height, node.node_type))

    node_list = []
    input_node_list()

    for node in node_list:
        calc_parent_sibling_degree()

    for node in node_list:
        node.depth = calc_depth(node.node_id)
        node.height = calc_height(node.node_id)

        calc_node_type()

        show_node_info()


if __name__ == '__main__':
    binarytrees()

Measured memory_bytes: 7784
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define ff first
#define ss second
#define dd double
#define mod 1000000007

template<class K,class other=null_type,class cmp=less<K>> using ordered_set=tree<K,other,
cmp, rb_tree_tag, tree_order_statistics_node_update>;

inline ll md(ll x){
    return x<mod?x:x%mod;
}

ll power(ll x, ll y){
    if(y==0){
        return 1;
    }
    ll x_=power(x,y/2);
    if(y & 1){
        return md(md(x_*x_)*md(x));
    }
    else{
        return md(x_*x_);
    }
}

ll mod_inverse(ll x){
    return power(x,mod-2);
}
const ll N=1e6+1;
ll spf[N];

void prime(){
    for(ll i=1;i<=N;i++){
        spf[i]=i;
    }
    for(ll i=4;i<=N;i+=2){
        spf[i]=2;
    }
    for(ll i=2;i*i<=N;i++){
        if(spf[i]==i){
            for(ll j=i*i;j<=N;j+=i){
                if(spf[j]==j){
                    spf[j]=i;
                }
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    prime();
    ll n;
    cin>>n;
    ll arr[n];
    REP(i,n){
        cin>>arr[i];
    }
    ll x=arr[0];
    FOR(i,1,n){
        x=__gcd(x,arr[i]);
    }
    if(x!=1){
        cout<<"not coprime"<<endl;
    }
    else{
        map<ll,ll> m;
        ll flag=1;
        REP(i,n){
            ll x=arr[i];
            while(x>1){
                ll y=spf[x];
                if(m[y]!=0 && m[y]!=i){
                    flag=0;
                    break;
                }
                else{
                    m[y]=i;
                }
                x/=y;
            }
            if(!flag){
                break;
            }
        }
        if(!flag){
            cout<<"setwise coprime"<<endl;
        }
        else{
            cout<<"pairwise coprime"<<endl;
        }
    }
}


Measured memory_bytes: 19276
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N; cin>>N;
    set<int>A;
    for(int i=0;i<N;i++) {
        int tmp; cin>>tmp;
        A.insert(tmp);
    }
    if(A.size()==N){
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }
    return 0;
}


Measured memory_bytes: 9728
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation
#include<complex>
#include<math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep2(i, j, n) for (int i = j; i < (int)(n); i++)

int main() {
	int N, M;
	cin >> N >> M;
	int c = 0;
	rep(i, M) {
		int a;
		cin >> a;
		c += a;
	}
	if (c > N) {
		cout << "-1" << endl;
	}
	else {
		cout << N - c << endl;
	}
}


Measured memory_bytes: 3192
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main() {
	int x;
	cin >> x;
	rep(i, x) {
		if (100 * i <= x && x <= 105 * i) {
			cout << '1' << endl;
			return 0;
		}
	}
	cout << '0' << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
const int INF = 1001001001;

int main()
{
    int k; cin >> k;
    k %= 10;
    if (k == 3) cout << "bon" << endl;
    else if(k == 0 || k == 6 || k == 8 ||k == 1) cout << "pon" << endl;
    else cout << "hon" << endl;


}

/*
Ctrl+@
g++ a.cpp
./a.out
*/

Measured memory_bytes: 3592
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
CS = Counter(S)
v = 0
ans = []
for i  in CS.values():
  v = max(v,i)
for j,k in CS.items():
  if v == k:
    ans.append(j)
ans.sort()
print(*ans,sep="\n")


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

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

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

#define MAX 100010
int N,M,C,l[MAX], c[MAX], w[MAX];
struct Data {
  int color, weight;
  bool operator < ( const Data &data ) const {
    if( weight != data.weight ) return weight < data.weight;
    return color < data.color;
  }
};

int main() {
  cin >> N >> M >> C;
  rep(i,C) cin >> l[i];
  priority_queue<Data> Q;
  rep(i,N) {
    cin >> c[i] >> w[i];
    --c[i];
    Q.push((Data){c[i],w[i]});
  }
  int score = 0;
  while( M > 0 && !Q.empty() ) {
    Data d = Q.top(); Q.pop();
    if( l[d.color] > 0 ) {
      l[d.color]--;
      --M;
      score += d.weight;
    }
  }
  cout << score << endl;
  compute();
  return 0;
}


Measured memory_bytes: 4844
import collections
n = int(input())
a = list(map(int,input().split()))
ls = [a[0]]
for i in range(1,n):
    ls.append(a[i]+ls[i-1])
    
ans = 0
ans += ls.count(0)
c = collections.Counter(ls)
c = (c.most_common())
i = 0
while True:
  if i == len(c):
    break
  else:
    ans += c[i][1]*(c[i][1]-1)/2
  i += 1
    
print(round(ans))


Measured memory_bytes: 116932
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int red = sc.nextInt();
        int green = sc.nextInt();
        int blue = sc.nextInt();
        int k = sc.nextInt();
        for (int i = 0; i < k; i++) {
            if(red >= green) green *= 2;
            else if( green >= blue) blue *= 2;
        }
        if(red < green && green < blue) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 35820
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;
typedef pair<int, int> pii;

class MinimumCostFlow {
	struct edge {
		int to, cap, cost, rev;
		edge(int to_, int cap_, int cost_, int rev_)
			: to(to_), cap(cap_), cost(cost_), rev(rev_) {}
	};
	int V;
	vector<vector<edge>> G;
	vector<int> h, dist, prevv, preve;
public:
	MinimumCostFlow(int _V) : V(_V), G(_V), h(_V), dist(_V), prevv(_V), preve(_V) {}
	void add(int from, int to, int cap, int cost) {
		G[from].push_back(edge(to, cap, cost, G[to].size()));
		G[to].push_back(edge(from, 0, -cost, G[from].size() - 1));
	}

	int calc(int s, int t, int f) {
		int res = 0;
		fill(h.begin(), h.end(), 0);
		while (f > 0) {
			priority_queue<pii, vector<pii>, greater<pii>> que;
			fill(dist.begin(), dist.end(), INF);
			dist[s] = 0;
			que.push(pii(0, s));
			while (!que.empty()) {
				pii p = que.top(); que.pop();
				int v = p.second;
				if (dist[v] < p.first) continue;
				for (size_t i = 0; i < G[v].size(); i++) {
					edge &e = G[v][i];
					if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
						dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
						prevv[e.to] = v;
						preve[e.to] = i;
						que.push(pii(dist[e.to], e.to));
					}
				}
			}
			if (dist[t] == INF) return -1;
			for (int v = 0; v < V; v++)
				h[v] += dist[v];
			int d = f;
			for (int v = t; v != s; v = prevv[v]) {
				d = min(d, G[prevv[v]][preve[v]].cap);
			}
			f -= d;
			res += d * h[t];
			for (int v = t; v != s; v = prevv[v]) {
				edge &e = G[prevv[v]][preve[v]];
				e.cap -= d;
				G[v][e.rev].cap += d;
			}
		}
		return res;
	}

};
int main()
{
	int V, E, F;
	cin >> V >> E >> F;
	MinimumCostFlow mcf(V);
	for (int i = 0, u, v, c, d; i < E; i++) {
		cin >> u >> v >> c >> d;
		mcf.add(u, v, c, d);
	}
	cout << mcf.calc(0, V - 1, F) << endl;
	return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    int64_t x; cin>>x;
    vector<int64_t> A(N);
    rep(i,0,N) cin>>A.at(i);

    int64_t ans=0;
    rep(i,1,N){
        int64_t sum=A.at(i-1)+A.at(i);
        if(sum>x){
            ans+=sum-x;
            A.at(i)-=min(A.at(i),sum-x);
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define rep2(i,x,n) for(int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k; 
ll INF = 10000000000000000;



int main(){
    int N;
    cin >>N;
    vi a(N+1),b(N+1),c(N+1);
    rep1(i,N+1) cin >>a[i]>>b[i]>>c[i];
    vvi dp(N+1,vi(3,0));    
    rep1(i,N+1){
        dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1] = max(dp[i-1][2],dp[i-1][0])+b[i];
        dp[i][2] = max(dp[i-1][0],dp[i-1][1])+c[i];
    }
    cout <<max(max(dp[N][0],dp[N][1]),dp[N][2])<<endl;
}


Measured memory_bytes: 6912
a,b,c,d = map(int,input().split())
r1 = a//d
if a%d==0:
  pass
else:
  r1 += 1
r2 = c//b
if c%b==0:
  pass
else:
  r2 += 1
if r1>=r2:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9076
#include<cmath>
#include<cstdio>
int Q;
long long a,b,c;
int Solve() {
	if(a>b)
		c=a,a=b,b=c;
	if(a==b||a==b-1) return 2*a-2;
	c=sqrt(a*b);
	if(c*c==a*b) c--;
	if(c*(c+1)<a*b)
		return 2*c-1;
	else return 2*c-2;
}

int main() {
	scanf("%d",&Q);
	for(int i=1;i<=Q;i++) {
		scanf("%lld %lld",&a,&b);
		printf("%d\n",Solve());
	}
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n, m,a,b,maxv=0;
	scanf("%d", &n);
	scanf("%d", &m);
	maxv = m;
	for (int i = 0; i < n; i++){
		scanf("%d %d", &a, &b);
		m = m - b + a;
		if (m < 0){
			maxv = 0;
			break;
		}
		maxv = max(maxv, m);
	}
	cout << maxv << endl;
}

Measured memory_bytes: 3220
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

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

    int n, a = 0, i = 0;
    cin >> n;
    while(true){
        if(n >= 2){
            n = n/2;
            i++;
        }else{
            break;
        }
    }
    int ans = 1;
    for(int j = 0; j < i; j++){
        ans *= 2;
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int i, n, F[100];
	scanf("%d", &n);
	F[0] = 1, F[1] = 1;
	for (i = 2; i <= n; i++) {
		F[i] = F[i-1] + F[i-2];
	}
	printf("%d\n", F[n]);
	
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

//head
char g1[51][51];
char g2[51][51];
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	int n, m;
  	cin >> n >> m;
  	for(int i = 0; i < n; i++){
  		cin >> g1[i];
  	}
  	for(int i = 0; i < m; i++) cin >> g2[i];
  	bool can = false;
  	for(int i = 0; i < n; i++){ // starting pixel
  		for(int j = 0; j < n; j++){
  			if(i + m -1 >= n || j+m-1 >= n) continue;
  			bool matches = true;
  			for(int k = 0; k < m; k++){
  				for(int l = 0; l < m; l++){
  					if(g1[i+k][j+l] != g2[k][l]){
  						matches = false;
  					}
  				}
  			}
  			if(matches){ 
  				cout << "Yes" << endl;
  				return 0;
  			}
  		}
  	}
  	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
n,m,x,y = map(int,input().split())
x_L = list(map(int,input().split()))
y_L = list(map(int,input().split()))

L = []
for i in range(x+1,y+1):
    falg = True
    if max(x_L) < i and min(y_L) >= i:
        print("No War")
        exit()

print("War")

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

int main(){
    int n, k;
    cin >> n >> k;
    
    vector<int> dict(n, 0);
    
    rep(i, k){
        int d;
        cin >> d;
        rep(j, d){
            int a;
            cin >> a;
            dict[a-1]++;
        }
    }
    
    int ans = 0;
    rep(i, n){
        if(dict[i]==0)ans++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  
  vector<int>A(N);
  vector<int>B(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i) >> B.at(i);
  }
  
  vector<pair<long long,long long>>p(N);
  for (int i = 0; i < N; i++) {
    p.at(i).first = A.at(i);
    p.at(i).second = B.at(i);
  }
  sort(p.begin(), p.end());
  
  int count = 0;
  long long cost = 0;
  for (int i = 0; i < N; i++) {
    if (count + p.at(i).second <= M){
      cost += p.at(i).first * p.at(i).second;
      count += p.at(i).second;
    }
    else {
      cost += p.at(i).first * (M-count);
      count += M-count;
    }
    if (count == M){
      cout << cost << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 5624
#include<iostream>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  int c=-1;
  for(int i=1; i<=M; i++){
    if(N-i+1-i<=N/2 && N%2==0){
      c=i;
      break;
    }
    cout<<i<<" "<<N-i+1<<endl;
  }
  if(c!=-1){
    for(int i=c; i<=M; i++){
      cout<<i<<" "<<N-i<<endl;
    }
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
    int n,l;
    cin>>n>>l;
    int sum=0;bool flag=true;
    for(int i=0;i<n;i++){
        if(flag&&i+l==0){
        flag=false;continue;
        }
        sum+=i+l;
    }
    if(flag&&l<0){
        sum-=n+l-1;
    }
    else if(flag&&l>0){
        sum-=l;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
long long sum;
void fa(long long n)
{
    if(n >= 5)
    {
        sum += n / 5;
        return fa(n/5);
    }
    else return;
}
int main()
{
    long long  n;
    scanf("%lld",&n);
    if(n % 2) printf("0\n");
    else
    {
        fa( n / 2);
        printf("%lld",sum);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	while(1)
	{
		int a,b;
		cin >> a >> b;
		if(a==0&&b==0)break;

		rep(i,a)
		{
			rep(j,b)
			{
				if((i+j)%2==0)
				{
					cout<<'#';
				}
				else
				{
					cout<<'.';
				}
				
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3088
function bomb(y,x,sum){
   YX[y][x]=sum;
   if(y==yx.length-1){
      max=Math.max(max,sum);
   }else if((yx.length-1)/2>y){
      if(YX[y+1][x]<sum+yx[y+1][x])bomb(y+1,x,sum+yx[y+1][x]);
      if(YX[y+1][x+1]<sum+yx[y+1][x+1])bomb(y+1,x+1,sum+yx[y+1][x+1]);      
   }else if((yx.length-1)/2<=y){
      if(x-1>=0){
         if(YX[y+1][x-1]<sum+yx[y+1][x-1])bomb(y+1,x-1,sum+yx[y+1][x-1]);
      }
      if(x<yx[y].length-1){
         if(YX[y+1][x]<sum+yx[y+1][x])bomb(y+1,x,sum+yx[y+1][x]);
      }
   }
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var yx=[];
var YX=[];
Arr.forEach(function(v){
   var x=v.split(",").map(Number);
   var X=x.map(function(v){return 0;});
   yx.push(x);
   YX.push(X);
});
var max=0;
bomb(0,0,yx[0][0]);
console.log(max);

Measured memory_bytes: 8740
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
typedef long long ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<string> NN(N), MM(M);
    rep(i, N) cin >> NN[i];
    rep(i, M) cin >> MM[i];

    //縦幅を合わせる
    for (int i = 0; i <= N - M; i++)
    {
        //横幅を合わせる
        for (int j = 0; j <= N - M; j++)
        {
            //探索部分
            int flag = 1;
            for (int k = 0; k < M; k++)
            {
                string cut = NN[i + k].substr(j, M);
                if (MM[k] != cut)
                {
                    //一致しなかった時の動作
                    flag = 0;
                }
            }
            if (flag)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
// *st.find_by_order(index), 0-based
// order_of_key(e)

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int L,R,d; cin>>L>>R>>d;
	int ret=0;
	for (int i=L; i<=R; i++)
		if(i%d==0)
			ret++;
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const ll N = 2e5+2e4 ;
string s ; 
ll ans, w;
int main ()
{
	cin >> s ;
	for(int i = 0 ; i < s.size() ; i ++){
		if(s[i] == 'W'){
			w ++ ;
			ans += i+1 ;
		}
	}
	ans -= ((w*(w+1))/2) ;
	cout << ans ;
}


Measured memory_bytes: 640
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,x,y,z;
double d,e,f;
string s,t;
//

signed main() {
  RAPID;
  IN2(a,b);
  if(a>=13) OUT(b);
  else if(a>=6) OUT(b/2);
  else OUT(0);
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
template <class T>
T GCD(T a, T b)
{
    T r;
    while (a)
        r = b, b = a, a = r % a;
    return b;
}
template <class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<ll> vl;
#define ERASE(x) x.erase(unique(ALL(x)), x.end()); // erase same elements
#define VEC(type, c, n)     \
    std::vector<type> c(n); \
    for (auto &i : c)       \
        std::cin >> i;

// input
#define INIT                          \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define VAR(type, ...) \
    type __VA_ARGS__;  \
    MACRO_VAR_Scan(__VA_ARGS__);

// output
template <typename T>
void MACRO_OUT(const T t) { std::cout << t; }

#define OUT(...) MACRO_OUT(__VA_ARGS__);
#define SP std::cout << " ";
#define TAB std::cout << "\t";
#define BR std::cout << "\n";
#define ENDL std::cout << std::endl;

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define yes() printf("yes\n")
#define no() printf("no\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
    cout << a;
    ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
    cout << a << ' ';
}

ll ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b, c, d, n;
int x, y;
int sum;
char ch;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// cout << (conditon ? (result:  == 1 ): (==0)) << endl; <- output result of if
// long long 型が表せる値の上限はおよそ 9 × 10＾18 です．
int main()
{
    INIT;
    int k;
    cin >> n >> k;
    vi p(n);
    rep(i, n)
    {
        cin >> p[i];
    }
    sort(ALL(p));
    FORD(i, n, n - k + 1)
    {
        ans += p[i - 1];
    }
    pr(ans);
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if (a==b && b==c){
    cout << 1 << endl;
  }
  else if (a==b || b==c || a==c){
    cout << 2 << endl;
  }
  else {
    cout << 3 << endl;
  }
}
  

Measured memory_bytes: 3572
f=lambda:[*map(int,input().split())]
h,w=f()
r=range(10)
c=[f() for _ in r]
C=[0]*10
for _ in range(h):
  for i in f():
    if i>=0: C[i]+=1
for k in r:
  for i in r:
    for j in r:
      c[i][j]=min(c[i][j],c[i][k]+c[k][j])
print(sum(c[i][1]*C[i] for i in r))

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

int main() {
	string s;
	cin >> s;

	int cnt_0 = 0, cnt_1 = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') cnt_0++;
		else cnt_1++;
	}

	cout << (cnt_0 <= cnt_1 ? 2 * cnt_0 : 2 * cnt_1) << endl;

	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

#define N 200010

int ans,n,p[N],dp[N];
bool mark[N];

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&p[i]);
	memset(mark,true,sizeof(mark));
	for (int i=1;i<=n;i++){
		mark[p[i]] = false;
		if (mark[p[i]+1]) dp[p[i]+1] = dp[p[i]] +1;
	}
	ans = 0;
	for (int i=1;i<=n;i++) ans = max(ans,dp[i]);
	printf("%d",n-ans-1);
	return 0;
}

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

#define mod 998244353

long long dp[300001];

int a[300001];

int N;

long long f(int i) {
    stack<int> st;
    
    for(int i = 0; i < N; i++) {
        if(st.size() > 0) {
            if(st.top() % 2 == a[i] % 2) {
                st.pop();
            }else st.push(a[i]);
        }else st.push(a[i]);
    }
    long long cnt = 0;
    while(!st.empty()) {
        if(st.top() % 2) cnt++;
        st.pop();
    }
    return cnt;

}


int main() {
    // oh hi mark
    int a,b; cin >> a >> b;
    cout << a * (long long) b / __gcd(a, b)<< endl;
    return 0;
}


Measured memory_bytes: 256