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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

#define INF 1<<30

// graph by adjacency list
template <typename T>
struct Edge {
  int dst; T weight;
  Edge(int dst, T weight) : dst(dst), weight(weight) { }
  bool operator < (const Edge &e) const {
    return weight > e.weight;
  }
};

template <typename T>
struct Graph {
  int V;
  vector<vector<Edge<T>>> E;

  Graph(int V) : V(V) { E.resize(V); }

  void add_edge(int src, int dst, T weight) {
    E[src].push_back(Edge<T>(dst, weight));
  }
};

template <typename T>
struct ShortestPath {
  const Graph<T> g;
  vector<T> dist;
  vector<int> prev;

  ShortestPath(const Graph<T> g) : g(g) { dist.resize(g.V), prev.resize(g.V); }

  void bellman_ford(int start) {
    dist.assign(g.V, INF);
    dist[start] = 0;
    prev[start] = -1;
    while (true) {
      bool update = false;
      for (int i = 0; i < g.V; i++) {
	for (Edge<T> e : g.E[i]) {
	  if (dist[i] != INF && dist[i] + e.weight < dist[e.dst]) {
	    dist[e.dst] = dist[i] + e.weight;
	    prev[e.dst] = i;
	    update = true;
	  }
	}
      }
      if (!update) break;
    }
  }

  vector<int> build_path(int goal) {
    vector<int> path;
    for (int v = goal; v != -1; v = prev[v]) {
      path.push_back(v);
    }
    reverse(path.begin(), path.end());
    return path;
  }

  bool find_negative_loop(int start) {
    dist.assign(g.V, INF);
    dist[start] = 0;
    for (int i = 0; i < g.V; i++) {
      for (int j = 0; j < g.V; j++) {
	for (Edge<T> e : g.E[j]) {
	  if (dist[j] != INF && dist[j] + e.weight < dist[e.dst]) {
	    dist[e.dst] = dist[j] + e.weight;
	    if (i == g.V - 1) return true;
	  }
	}
      }
    }
    return false;
  }
};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int V, E, r; cin >> V >> E >> r;
  Graph<int> g(V);
  REP(_, E) {
    int s, t, d; cin >> s >> t >> d;
    g.add_edge(s, t, d);
  }
  ShortestPath<int> sp(g);
  if (sp.find_negative_loop(r)) {
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    REP(i, g.V) {
      if (sp.dist[i] == INF) {
	cout << "INF" << endl;
      } else {
	cout << sp.dist[i] << endl;
      }
    }
  }

  return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> c(n+1), a(n+1, 0);
	for(int i=1; i<=n; i++) cin >> c[i];
	
	int q;
	cin >> q;
	int ans = 0;
	for(int i=0; i<q; i++){
		int t,x,d;
		cin >> t >> x >> d;
		if(ans != 0) continue;
		if(t==1){
			if(a[x]+d > c[x]) ans = x;
			a[x] += d;
		}else{
			if(a[x] < d) ans = x;
			a[x] -= d;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3108
M, K = map(int, input().split())
if K >= 2**M:
    print(-1)
elif M == 0:
    print(0, 0)
elif M == 1:
    if K == 0:
        print("0 0 1 1")
    else:
        print(-1)
elif K==0:
    r = list(range(2**M))
    r += r[::-1]
    print(*r)
else:
    d = set()
    for i in range(2**M):
        p = tuple(sorted([i, i^K]))
        if p not in d:
            d.add(p)
    r = []
    while d:
        x,y = d.pop()
        z,w = d.pop()
        r += [x,y,z,w,y,x,w,z]
    print(*r)



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

int main()
{
	int H, W;
	cin >> H >> W;
	vector<string> S( H );
	for( int i = 0; i < H; i++ )  {
		cin >> S[i];
	}

	for( int i = 1; i <= H * 2; i++ )  {
		int ii = (i + 1) / 2 - 1;
		cout << S[ii] << endl;
	}
}


Measured memory_bytes: 3612
while True:
    L= int(input())
    if L== 0: break
    mn= [list(map(int, input().split())) for _ in range(12)]
    ans=c=0
    b= True
    for m, n in mn:
        ans+= m-n
        c+= 1
        if ans>= L:
            print(c)
            b= False
            break
    if b: print("NA")

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

const int MAX = 100001;
char p[MAX] = {0};

int main(){
	for(int i=2 ; i < MAX ; i++ ) p[i] = 1;
	for(int i=2 ; i*i < MAX ; i++ ){
		if( p[i] ){
			for(int j=i+i ; j < MAX ; j += i ){
				p[j] = 0;
			}
		}
	}
	
	int n;
	while( cin >> n , n ){
		int a, b;
		for(int i=2 ; i <= n ; i++ ){
			if( p[i-2] && p[i] ){
				a = i-2;
				b = i;
			}
		}
		cout << a << " " << b << endl;
	}
}

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

int main()
{
	int N;
	double ans;

	cin >> N;

	if(N%2 ==0){
		ans = (double)(N/2)/(double)N;
		cout << ans;
	}else{
		ans = (N/2+1)/(double)N;
		cout << ans;
	}
	cout << "\n";
}

Measured memory_bytes: 256
//Date : 16 - 06 - 18  //Author : Rishabh Paul

#include<bits/stdc++.h>
using namespace std;

// int main() {
// 	int a ,b;
// 	cin >> a >> b;
// 	if(min(a ,b) <= 8)	cout << "Yay!";
// 	else cout << ":(";
// 	return 0;
// }

 // int main() {
 // 	int d ,n;
 // 	cin >> d >> n;
 // 	int ans;
 // 	if(d == 0)	ans = 1;
 // 	else if(d == 1)	ans = 100;
 // 	else ans = 10000;
 // 	ans *= n;
 // 	cout << ans;
 // 	return 0;
 // }

int main() {
	int n ,ans = 0 ,x;
	cin >> n;
	while(n--) {
		cin >> x;
		while(x % 2 == 0 && x)	ans++ ,x /= 2;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var t = new Test();
            var list = new List<string>();
            t.MakeList(list);
            list.ForEach(ans => Console.WriteLine(ans));
        }

        public void MakeList(List<string> list)
        {
            var input = this.ParseIntList(this.ReadInput());
            if (input[0] == 0 && input[1] == 0)
            {
                return;
            }
            var min = 0;
            var max = 0;
            if (input[0] < input[1])
            {
                min = input[0];
                max = input[1];
            }
            else
            {
                min = input[1];
                max = input[0];
            }

            list.Add(min + " " + max);
            MakeList(list);
        }

        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public List<int> ParseIntList(string[] x)
        {
            var convertedList = new List<int>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(int.Parse(x[i]));
            }

            return convertedList;
        }
}
}


Measured memory_bytes: 18128
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/

#include <bits/stdc++.h>
using namespace std;

/* see https://github.com/pllk/cphb/
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
    tree_order_statistics_node_update> indexed_set;
 **/

typedef long long ll;
#define endl "\n"
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

//typedef __int128 lll;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    cini(n);
    cinai(v, n);

    sort(v.begin(), v.end());
    double ans=v[0];
    for(int i=1; i<n; i++) {
        ans=(ans+v[i])/2;
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 256
// Delete the dynamically allocated memory
 
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define pr              pair<long long,long long>
#define mp(a,b)         make_pair(a,b)
#define vr              vector<long long>
#define mod1            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define fill(a,b)       memset(a, b, sizeof(a))
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)
ll power(ll base, ll exp) {
    ll res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base);
       base=(base*base);
       exp/=2;
    }
    return res;
}
int main()
{
	ll l,r,d;
	cin>>l>>r>>d;
	ll v1=r/d;
	ll v2=(l-1)/d;
	cout<<abs(v1-v2)<<"\n";
	return 0;
}

Measured memory_bytes: 3628
import math

def pr8(a):
	print("{:.10}".format(a[0]),end=" ")
	print("{:.10}".format(a[1]))

def koch(n,p1,p2):
	if n==0:
		return
	s=[0 for i in range(2)]
	t=[0 for i in range(2)]
	u=[0 for i in range(2)]
	
	s[0]=(2*p1[0]+1*p2[0])/3
	s[1]=(2*p1[1]+1*p2[1])/3
	t[0]=(1*p1[0]+2*p2[0])/3
	t[1]=(1*p1[1]+2*p2[1])/3
	
	rad=math.radians(60)
	
	u[0]=(t[0]-s[0])*math.cos(rad)-(t[1]-s[1])*math.sin(rad)+s[0]
	u[1]=(t[0]-s[0])*math.sin(rad)+(t[1]-s[1])*math.cos(rad)+s[1]
	
	koch(n-1,p1,s)
	#pr8(s)
	print(*s)	
	koch(n-1,s,u)
	#pr8(u)
	print(*u)
	koch(n-1,u,t)
	#pr8(t)
	print(*t)
	koch(n-1,t,p2)
	
n=int(input())
p1=[0,0]
p2=[100,0]

print(*p1)
koch(n,p1,p2)
print(*p2)


Measured memory_bytes: 5796
#include <iostream>
using namespace std;
typedef unsigned long long u64;
#include <queue>

u64 comb(u64 a, u64 b){
  u64 v[a+1][a+1];
  for(int i = 0;i <=a; i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(int k = 1;k <= a;k++){
    for(int j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
  return v[a][b];
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a, b;
  cin >> n >> a >> b;
  priority_queue< u64 > v;
  for (int i = 0; i < n; ++i) {
    u64 vi;
    cin >> vi;
    v.push(vi);
  }
  u64 now=0, sum=0;
  int nowcnt=0, cnt=0, samecnt=0, overcnt=0;

  while (!v.empty()) {
    u64 vi = v.top();
    sum+=vi;
    v.pop();
    if (vi == now) {
      nowcnt++;
    } else {
      overcnt+= nowcnt;
      nowcnt = 1;
    }
    cnt++;
    now = vi;
    if (cnt==a) {
      samecnt=nowcnt;
      while (!v.empty() && v.top() == now) {
        samecnt++;
        v.pop();
      }
      break;
    }
  }
  double ave = sum * 1.0 / cnt;
  u64 sets = 0;
  if (overcnt==0) {
    for (int i = a; i <= min(b, samecnt); ++i) {
      u64 k = comb(samecnt, i);
      sets += k;
    }
  } else {
    sets += comb(samecnt, a-overcnt);
  }
  cout.precision(20);
  cout << fixed << ave << endl << sets << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b,c,x,y,z,aa[100010],ab[100010],ac[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1000][1000];
vector<ll> va,vb,vc;

int main(){
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0')aa[i]=0;
        if(s[i]=='1')aa[i]=1;
        if(s[i]=='B')aa[i]=-1;
    }
    sa="";
    for(int i=0;i<s.size();i++){
        if(aa[i]==0)sa+="0";
        if(aa[i]==1)sa+="1";
        if(aa[i]==-1){
            if(sa.size())sa.pop_back();
        }
    }
    C sa E;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX(x,y)	((x)>(y)?(x):(y))
#define MAX3(x,y,z)	((x)>(MAX(y,z)) ? (x):(MAX(y,z)))

int main(){
    int n, ans=0, l[100+1]={0};
    scanf("%d",&n);
    for(int i=0; i<n; i++){ scanf("%d", &l[i]); }

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if( l[i]==l[j] ){ continue; }
            for(int k=0; k<n; k++){
                if( l[i]==l[k] || l[j]==l[k] ){ continue; }
                if( ((l[i]+l[j]+l[k]) - MAX3(l[i],l[j],l[k])) <= MAX3(l[i],l[j],l[k]) ){ continue; }
                ans++;
            }
        }
    }
    printf("%d\n",ans/6);
    return 0;
}

Measured memory_bytes: 1732
/*
██╗  ██╗ █████╗ ██████╗ ███████╗███████╗███╗   ███╗        ██╗  ██╗██╗  ██╗ █████╗ ██╗     ███████╗██████╗
██║ ██╔╝██╔══██╗██╔══██╗██╔════╝██╔════╝████╗ ████║        ██║ ██╔╝██║  ██║██╔══██╗██║     ██╔════╝██╔══██╗
█████╔╝ ███████║██████╔╝█████╗  █████╗  ██╔████╔██║        █████╔╝ ███████║███████║██║     █████╗  ██║  ██║
██╔═██╗ ██╔══██║██╔══██╗██╔══╝  ██╔══╝  ██║╚██╔╝██║        ██╔═██╗ ██╔══██║██╔══██║██║     ██╔══╝  ██║  ██║
██║  ██╗██║  ██║██║  ██║███████╗███████╗██║ ╚═╝ ██║███████╗██║  ██╗██║  ██║██║  ██║███████╗███████╗██████╔╝
╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═╝     ╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═════╝
				Believe in yourself ,( try and try and then try ), You can do it  
*/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#define endl "\n"
#define Ceil(x,y) ((x+y-1)/y)
#define clr(arr, x) memset(arr, x, sizeof arr)
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define rt(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define OO 0x3f3f3f3f3f3f3f3fLL
const int oo = 0x3f3f3f3f, mod = 1e9 + 7;
using namespace std;
typedef long long ll;
int dx[] { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[] { 0, 0, 1, -1, 1, -1, 1, -1 };
void K_K(){ 
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
	K_K();
	int n, k;
	cin >> n >> k;
	set<int>st;
	for (int i = 1; i <= n; i++)
		st.insert(i);
	while (k--){
		cin >> n;
		for (int i = 0; i < n; i++){
			int x;
			cin >> x;
			if (st.find(x) != st.end())
				st.erase(x);
		}
	}
	cout << sz(st);
}

Measured memory_bytes: 3592
#define USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<cmath>                    
using namespace std;
int main(){
    
    int a,b,d,r;
    double f;
    
    cin>>a>>b;
    d=a/b;
    r=a%b;
    f=double(a)/b;
     cout <<fixed <<d<<" "<<r<<" "<<setprecision(6)<<f<<endl;



	 return 0;
}
 


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

int main()
{
    int s[2], u;
    for(int k = 0; k < 2; k++) {
        s[k] = 0;
        for(int i = 0; i < 4; i++) {
            cin >> u;
            s[k] += u;
        }
    }

    cout << max(s[0], s[1]) << endl;
        
        
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
  using namespace std;
  int main(void){
      // Your code here
      long long A,B,C,D;
      int turn = 0;
      cin >> A >> B >> C >> D;
 	while(A>0&&C>0){
 		A -= D;
 		C -= B;
 	}
 	if(C<=0)cout << "Yes";
 	else if(A<=0)cout << "No"; 
  }

Measured memory_bytes: 3636
from math import ceil


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    ng = 0
    ok = 10 ** 9 + 7
    while ok - ng > 1:
        mid = (ok + ng) // 2
        cnt = 0
        for i in range(n):
            cnt += (a[i] - 1) // mid
        if cnt <= k:
            ok = mid
        else:
            ng = mid
    print(ceil(ok) if k > 0 else a[-1])


if __name__ == '__main__':
    main()



Measured memory_bytes: 30924
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a1 = sc.nextInt();
        int a2 = sc.nextInt();
        int a3 = sc.nextInt();
        if (a1 + a2 + a3 >= 22) {
            System.out.println("bust");
            return;
        }
        System.out.println("win");
    }
 
}

Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define pr_arr(name, a, b) \
  for (int i = (a); i < (b); i++) { \
    for (int j = (a); j < (b); j++) {\
      if (j > (a)) printf(" "); \
      printf("%lld", name[i][j]); \
    }\
    printf("\n");\
  }\

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

int ans;
int A1, A2, A3; 

int main(void) {
    scanf("%d %d %d", &A1, &A2, &A3);

   

  
  if(A1+A2+A3>=22) puts("bust");
  else puts("win");

	return 0;
}


Measured memory_bytes: 384
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<u64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut ans = 1u64;
    for i in 0..n {
        ans = ans.saturating_mul(a[i]);
    }
    if ans > 10u64.pow(18) {
        println!("-1")
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 4748
#include<bits/stdc++.h>
#define mxn 1000010
#define db double
#define LL long long
#define ldb long double
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
#define x1 faqx1
#define y1 faqy1
#define x2 faqx2
#define y2 faqy2
using namespace std;
const int mod=1e9+7;
int n,ans,cnt[2][64];
LL x,sl,fh;
LL rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
	n=rd();LL x;
	for(int i=1;i<=n;++i)
	{
		x=rd();
		for(int j=0;j<60;++j,x>>=1) cnt[x&1][j]++;
	}
	x=1;
	for(int i=0;i<60;++i,x=x*2%mod) ans=(ans+x*cnt[0][i]%mod*cnt[1][i])%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;
  int m=(h2-h1)*60+(m2-m1);
  cout<<m-k<<endl;
  return 0;
}

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

int main(int argc, char *argv[])
{
  int r, c, mult;
  
  while(cin >> r >> c, r){
    //int chair[r][c] = {{0}};
    mult = r*c;
    mult = mult % 2;
    if(mult==0) {
      cout << "yes" << endl;
    }
    else {
      cout << "no" << endl;
    }
  }
      
  return 0;
}

Measured memory_bytes: 3088
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

struct edge {
  int to, cost;
};

vector<edge> g[100000];

ll dfs(int idx, int parent, ll k, ll bros, ll grand) {
  ll ret = 1;
  ll nchildren = g[idx].size();
  if (parent >= 0) nchildren--;
  // cout << idx << ":" << parent << ":" << nchildren << endl;
  nchildren--;
  for (edge &e : g[idx]) {
    if (e.to == parent) continue;
    ret = ret * dfs(e.to, idx, k, nchildren--, (parent >= 0)) % MOD;
  }
  ll colors = k - bros - grand;
  // cout << k << "," << bros << "," << grand << "," << colors << endl;
  if (parent >= 0) colors--;
  return (ret * colors) % MOD;
}

int main() {
  //
  ll n, k;
  cin >> n >> k;
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back((edge){b, 1});
    g[b].push_back((edge){a, 1});
    // cout << a << "," << b << endl;
  }
  cout << dfs(0, -1, k, 0, 0) << endl;
  return 0;
}


Measured memory_bytes: 13952
alp=[chr(i) for i in range(97,123)]
n=int(input())

for i in range(1,12):
    if n>26**i:
        n-=26**i
    else:
        keta=i
        break
#その桁数の名前のなかでn番目
n-=1
lst=[]
#このnを26進数で表し、0~25にa~zをあてはめる
for i in range(keta):
    p,n=divmod(n,26**(keta-i-1))
    lst.append(alp[p])
    
print("".join(lst))

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
const ll INF=1000000000000001;
int main() {
	string s,t;
	int ans=0;
	cin >>s>>t;
	int mx,mx2,na;
	mx2=t.length();
	na=s.length();
	na-=mx2;
//	cout<<na<<endl;
	rep(i,na+1){
		mx=t.length();
		rep(j,t.length()){
//			cout <<"s="<<s[i+j]<< " t="<<t[j]<<endl;
			if (s[i+j]==t[j]) mx--;
		}
		mx2=min(mx,mx2);
	}
	ans=mx2;
	cout <<ans<<endl;
	return 0;
}


Measured memory_bytes: 3624
import java.io.*;
  
public class Main {
  
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder str = new StringBuilder();
        String[] data;
        int x, y;
        while (true) {
            data = br.readLine().split(" ");
            x = Integer.parseInt(data[0]);
            y = Integer.parseInt(data[1]);
            if (x == 0 && y == 0) {
                break;
            }
            if (x < y) {
                str.append(data[0]).append(" ").append(data[1]).append("\n");
            } else {
                str.append(data[1]).append(" ").append(data[0]).append("\n");
            }
        }
        System.out.print(str);
    }
}

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

int main() {
 int n;
 cin >> n;
 string s[n];
 rep(i,n) cin >> s[i];

 map<string,int> ans;

 rep(i,n){
   string ss =s[i]; 
   ans[ss] +=1;
 }

 int maxv=0;
 for(auto p:ans){
   maxv = max(maxv,p.second);
 }

 for(auto p:ans){
   if(p.second==maxv){
     cout << p.first << endl;
   }
 }




  
}

Measured memory_bytes: 27904
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    var sum = 0L
    for (i in 1..n) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i
        }
    }
    println(sum)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 34380
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;

int main(int argc, char* argv[]) {

	int A,B,C,X, ans = 0;

	cin >> A;
	cin >> B;
	cin >> C;
	cin >> X;

	for (int i = 0; i <= A; i++) {
		for (int j = 0; j <= B; j++) {
			for (int k = 0; k <= C; k++) {
				if(500*i+100*j+50*k==X){
					ans++;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;

}



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

#define F first 
#define S second 
#define MAX 1000003

typedef long long ll; 
const int mod = 1000000007;

int prime[MAX]; 
unordered_map<int, int> max_map; 

// Function to return a^n 
int power(int a, int n) 
{ 
  if (n == 0) 
    return 1; 
  int p = power(a, n / 2) % mod; 
  p = (p * p) % mod; 
  if (n & 1) 
    p = (p * a) % mod; 
  return p; 
} 

// Function to find the smallest prime factors 
// of numbers upto MAX 
void sieve() 
{ 
  prime[0] = prime[1] = 1; 
  for (int i = 2; i < MAX; i++) { 
    if (prime[i] == 0) { 
      for (int j = i * 2; j < MAX; j += i) { 
        if (prime[j] == 0) { 
          prime[j] = i; 
        } 
      } 
      prime[i] = i; 
    } 
  } 
} 

// Function to return the LCM modulo M 
ll lcmModuloM(const int* ar, int n) 
{ 

  for (int i = 0; i < n; i++) { 
    int num = ar[i]; 
    unordered_map<int, int> temp; 

    // Temp stores mapping of prime factor to 
    // its power for the current element 
    while (num > 1) { 

      // Factor is the smallest prime factor of num 
      int factor = prime[num]; 

      // Increase count of factor in temp 
      temp[factor]++; 

      // Reduce num by its prime factor 
      num /= factor; 
    } 

    for (auto it : temp) { 

      // Store the highest power of every prime 
      // found till now in a new map max_map 
      max_map[it.first] = max(max_map[it.first], it.second); 
    } 
  } 

  ll ans = 1; 

  for (auto it : max_map) { 

    // LCM is product of primes to their highest powers modulo M 
    ans = (ans * power(it.F, it.S)) % mod; 
  } 

  return ans; 
}

template <ll Modulus> class modint {
  using u64 = ll;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

signed main(){
  using mint = modint<mod>;
  sieve();
  int n;
  mint l=1,r=0;
  cin>>n;
  int a[10010];
  for(int i=0;i<n;++i)cin>>a[i];
  l=lcmModuloM(a,n);
  for(int i=0;i<n;++i)r+=l/a[i];
  return cout<<r.value(),0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

template<typename T>
bool SuffixErase(T &v,size_t suf){
  if(suf > v.size()) return false;
  for(auto it = v.begin(); it != v.end();){
    if(distance(v.begin(),it) == suf){
      v.erase(it);
      return true;
    }
    else{
      ++it;
    }
  }
  return false;
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}
  int n,k;
vector<char> v(10);
bool check(string s){
  rep(i,k){
    if(find(all(s),v[i]) != s.end()){
      return false;
    }
  }
  return true;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  rep(i,k){
    cin >> v[i];
  }
  REP(i,n,inf){
    if(check(to_string(i))){
      cout << i << endl;
      return  0;
    }
  }
  return 0;
}



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

int main(int argc, const char * argv[]) {
    string a, b, c;
    char x;
    
    cin >> a >> b >> c;
    
    x = a[0]-32;
    cout << x;
    
    x = b[0]-32;
    cout << x;
    
    x = c[0]-32;
    cout << x;
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T>using vv = vector<vector<T>>; template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

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

    write((N + 2 * D + 1 - 1) / (2 * D + 1));
}

Measured memory_bytes: 256
#include <iostream>


int a, b, c = 0, d = 0, e = 0, g;
int  max1[999], m1[999], max2[999], m2[999], f = 1000000000, kekka;
bool End = false;
int main()
{
	std::cin >> a >> b;
	for(int i = 1; i <= 999; i++)
	{
		c += i;
		if(a < c)
		{
			d += 1;
			m1[d] = d;
			max1[d] = c - a;
		}

		if(b < c)
		{
			e += 1;
			m2[e] = e;
			max2[e] = c - b;
		}
	}
	for(int i = 1; i <= d; i++)
	{
		for(int j = 1; j <= e; j++)
		{
			if(max1[i] == max2[j])
			{
				g = m2[j] - m1[i];
				if(g < f)
				{
					kekka = max1[i];
				}
			}
		}
	}
	std::cout << kekka << std::endl;
}

Measured memory_bytes: 256
n = input()
x = len(n)

if x == 1:
  print(int(n))
else:
  if int(n[0]) < int((int(n) + 1) / int("1"+"0"*(x-1))):
    print(int(n[0]) + 9 * (x - 1))
  else:
    print(int(n[0]) - 1 + 9 * (x - 1))

Measured memory_bytes: 3060
from bisect import bisect_left,bisect_right,insort_left
dict = {}
keytbl = []
cnt = 0
q = int(input())
for i in range(q):
    a = list(input().split())
    ki = int(a[1])
    if a[0] == "0":
        if ki not in dict:
            dict[ki] =1
            cnt += 1
            insort_left(keytbl,ki)
        elif dict[ki] == 0:
            dict[ki] = 1
            cnt += 1
        print(cnt)
    elif a[0] == "1":print(dict[ki] if ki in dict else 0)
    elif a[0] == "2":
        if ki in dict:
            cnt -= dict[ki]
            dict[ki] =0
    else:
        L = bisect_left(keytbl,int(a[1]))
        R = bisect_right(keytbl,int(a[2]),L)
        for j in range(L,R):
            if dict[keytbl[j]] == 1:print(keytbl[j])



Measured memory_bytes: 27680
N = int(input())
a = list(map(int, input().split()))
ans = 0
cnt = 0
while 1:
    for i in range(N):
        if a[i] % 2 == 0:
            ans += 1
            a[i] //= 2
        else:
            cnt += 1
    if cnt == N:
        break
    else:
        cnt = 0
print(ans)

Measured memory_bytes: 4148
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll N;
    ll answer = 0;
    
    cin >> N;

    if (N < 10){
        answer = N + 1;
    }else if (N < 100){
        answer = 10;
    }else if (N < 1000){
        answer = 10;
        answer += N - 99;
    }else if (N < 10000){
        answer = 10 + 900;
    }else if (N < 100000){
        answer = 910;
        answer += N - 9999;
    }else if (N == 100000){
        answer = 910 + 99999 - 9999;
    }

    cout << answer - 1 << endl;
    

    return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int sum = 0;
    rep(i, n) sum += a[i];
    bitset<2000*2000+1> s("1");
    rep(i, n) s = (s | s << a[i]);
    int ans = (sum + 1) / 2;
    while (s[ans] == 0) ++ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<cmath>
#include <bitset>
using namespace std;

int main(){
    int n,m;cin >> n >> m;
    int dp[m+1][5000];
    for(int i=0;i<=m;i++){
        dp[i][0] = 0;
        for(int j=1;j<5000;j++){
            dp[i][j] = 1000000007;
        }
    }
    int d[m];
    for(int i=0;i<m;i++){
        d[i] = 0;
    }
    int a[m];
    for(int i=0;i<m;i++){
        cin >> a[i];
        int b;cin >> b;
        for(int j=0;j<b;j++){
            int c;cin >> c;
            d[i] += pow(2,c-1);
        }
    }
    #if D
    for(int i=0;i<m;i++){
        cout <<i << " " <<  bitset<sizeof(int)*CHAR_BIT>(d[i]) << endl;
        //cout << bitset<sizeof(int)*CHAR_BIT>(0|d[i]) << endl;
    }
    
    #endif
    int ma = pow(2,n)-1;
    for(int i=1;i<=m;i++){

        for(int j=0;j<=ma;j++){
            dp[i][j] = dp[i-1][j];
        }
        for(int j=0;j<=ma;j++){
            dp[i][j|d[i-1]] = min(dp[i][j|d[i-1]],min(dp[i-1][j|d[i-1]],dp[i-1][j] + a[i-1]));
        }

        #if D
        for(int j=0;j<=ma;j++){
            cout << i << " " <<bitset<sizeof(int)*CHAR_BIT>(j) << " " << dp[i][j] << endl;
        }
        #endif
    }
    if(dp[m][ma] == 1000000007){
        cout << -1 << endl;
    }
    else{
        cout << dp[m][ma] << endl;
    }
    return 0;
}

Measured memory_bytes: 19840
/*He who forgives and acknowledges himself... that is what it truly means to be strong!*/
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
#include <list>
#include <deque>
#include <bitset>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <sstream>
#include <complex>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <climits>
#include <utility>
#include <ctime>
#include <tuple>
#include <fstream>
#define T int test_case; scanf("%d",&test_case); while(test_case--)
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORD(i,a,n) for(i=a;i>=n;i--)
#define FORS(i,a) for(i=0;a[i];i++)
#define si(x) scanf("%d",&x)
#define sc(x) cin>>x
#define sd(x) scanf("%lf",&x)
#define sll(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define prs(x) printf("%d ",x)
#define pls(x) printf("%lld ",x)
#define pc(x) printf("%c",x)
#define pi(x) printf("%d\n",x)
#define pd(x) cout.precision(10),cout<<fixed<<x<<endl;
#define pll(x) printf("%lld\n",x)
#define ps(x) printf("%s\n",x)
#define M 1000000007
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define pb push_back
#define fr first
#define se second
#define in insert
#define er erase
#define pii pair<int, int>
#define plll pair<long long, long long>
#define tr(x,it) for(auto it : x)
#define INF 1ll<<60
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230
#define bs(x,lo,hi,mid) cout<<x<<" "<<lo<<" "<<hi<<" "<<mid<<endl;
using namespace std;
ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n&1) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n&1) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
vector<int> prime;
bool primee[10000000];
void primegen(ll x) { for(ll i=2;i*i<=x;i++) if(!primee[i]) for(ll j=i*i;j<=x;j+=i) primee[j]=true; for(ll i=2;i<=x;i++) if(!primee[i]) prime.push_back(i);}

int check(ll x)
{
	int z=0;
	while(x>0)
	{
		x=x/10;
		z++;
	}
	return z;
}
int main()
{
   ll n,i;
   sll(n);
   int mx=0;
   for(i=1;i*i<=n;i++)
   {
   	if(n%i==0)
   		mx=max(check(i),check(n/i));
   }
   pi(mx);
   return 0;
}


Measured memory_bytes: 256
K, A, B=map(int, input().split())

if A+2>=B or A+1>K:
  print(K+1)
else:
  nokori=K-A-1
  rep=nokori//2
  ans=(1+rep)*B-rep*A
  if nokori%2==1:
    ans+=1
  print(ans)
  

Measured memory_bytes: 2940
//ITP 1_10_A
#include <iostream>
#include<cmath>

//ctudio

using namespace std;

//lf==line feed
//0.8lf?

int main()
{
    double x1,x2,y1,y2,val,val2;
    cin >> x1 >> y1 >> x2 >> y2;
    val=((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1));
    val2 = sqrt(val);
    
    printf("%0.8lf\n",val2);
    
    return 0;
}



Measured memory_bytes: 3204
typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;

int main() {
    ll l,r,d;
    std::cin >> l>>r>>d;
    ll ans = 0;
    for (int i = l; i <= r; i++) {
        if(i%d==0)ans++;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <math.h>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;

ll gcd(ll m, ll n) {
  ll tmp;
  while (m % n != 0) {
    tmp = n;
    n = m % n;
    m = tmp;
  }
  return n;
}

ll lcm(ll m, ll n) {
  return m * n / gcd(m, n);
}

int main() {
  const ll N = 100000;
  ll n, m;
  ll a[N];
  ll b[N];

  cin >> n >> m;
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i] / 2;
  }

  ll lcm_all = b[0];
  for (ll i = 1; i < n; i++) {
    lcm_all = lcm(lcm_all, b[i]);
  }

  for (ll i = 0; i < n; i++) {
    if ((lcm_all / b[i]) % 2 == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  if (m < lcm_all) {
    cout << 0 << endl;
    return 0;
  }
  cout << (m - lcm_all) / (lcm_all * 2) + 1 << endl;
}


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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    vector<ll> h(n);
    for(i = 0; i < n; i++) {
        cin >> h[i];
    }
    ll ret = 0, tmp = 0, now = h[0];
    for(i = 1; i < n; i++) {
        if(h[i] <= now) {
            tmp++;
        } else {
            ret = max(ret, tmp);
            tmp = 0;
        }
        now = h[i];
    }
    ret = max(ret,tmp);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        FastReader in  = new FastReader(); 
        Solver s = new Solver();
        int t = 1;
        while(t-- > 0) s.solve(in, out);
        out.close();
    }

    static class Solver {
        public void solve(FastReader in, PrintWriter out) throws IOException {
            // solve
            int n=in.nextInt();
            int[] a=new int[n];
            for(int i=0;i<n;i++) a[i]=in.nextInt();
            int[] dp=new int[n];
            Arrays.fill(dp, Integer.MAX_VALUE);
            dp[0]=0;
            for(int i=1;i<n;i++){
                if(i-1>=0) dp[i]=Math.min(dp[i], dp[i-1]+Math.abs(a[i]-a[i-1]));
                if(i-2>=0) dp[i]=Math.min(dp[i], dp[i-2]+Math.abs(a[i]-a[i-2]));
            }
            out.println(dp[n-1]);
        } 
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 31712
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N; cin >> N;
  vector<double> a(N); REP(i, N) cin >> a[i];

  double avg = (double)accumulate(ALL(a), 0)/N;
  double diff = 1<<30;
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    if (diff > abs(a[i] - avg)) {
      diff = abs(a[i] - avg);
      ans = i;
    }
  }

  cout << ans << endl;
}

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

int main() {
	int n;
	cin >> n;
	ll arr[n];
	cin >> arr[0];
	ll ans = arr[0];
	for (int i = 1 ; i< n;  i++){
		cin >> arr[i];
		ans = __gcd(arr[i] , ans);
	}
	cout << ans << endl;
}


Measured memory_bytes: 4372
#include <stdio.h>
int main(void){
    int d,n;
    scanf("%d",&d);
    int m[10010];
    for(int i=0;i<=10000;i++)
    {
        m[i]=0;
    }
    for(int i=1;i<100;i++)
        {for(int j=1;j<=i;j++)
            {for(int k=1;k<=j;k++)
            {n=i*i+j*j+k*k+i*j+j*k+k*i;
                if(n<=10000)
                    {
                        if(i==j&&j==k)
                            {m[n]++;}
                        else {
                            if(i==j||j==k)
                        {
                            m[n]=m[n]+3;
                        }
                        else m[n]=m[n]+6;
                        }   
                        
                    }
            }
        }
    }
    for(int i=1;i<=d;i++)
    {
     printf("%d\n",m[i]) ;  
    }
    
}

Measured memory_bytes: 1716
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

int main() {
  ll n;
  cin>>n;
  ll distance=INF;
  rep2(a,1,ceil(sqrt(n))+1){
if(n%a==0){
 ll currentdistance=a+n/a-2;
  if(currentdistance<distance) distance=currentdistance;
}
  }
    cout<<distance<<endl;
return 0;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    string s;
    cin >> s;

    int64_t m = s.size();

    vector a(1, 0L);
    int64_t t = 0;
    for (auto c : s) {
        if (c == '0') {
            a.push_back(t);
        } else {
            ++t;
        }
    }
    a.push_back(t);

    int64_t k;
    cin >> k;
    k = min(k, a.back());

    int64_t n = a.size();

    constexpr auto M = 998244353L;

    vector dp(vector(k + 1, vector(a.back() + 1, 0L)));
    int64_t mk = 0;
    dp[0][0] = 1;
    for (auto i : irange(0L, n - 1)) {
        for (auto j : irange(mk, -1L, -1L)) {
            for (auto c : irange(0L, a.back() - a[i + 1] + 1)) {
                for (auto b : irange(c + 1, min(c - j + k + 1, c + a[i + 1] - a[i] + 1))) {
                    auto w = j + b - c;
                    mk = max(mk, w);
                    dp[w][c] += dp[j][b];
                    if (dp[w][c] >= M) {
                        dp[w][c] -= M;
                    }
                }
            }

            for (auto c : irange(1L, a.back() - a[i + 1] + 1)) {
                dp[j][c] += dp[j][c - 1];
                if (dp[j][c] >= M) {
                    dp[j][c] -= M;
                }
            }
        }
    }

    int64_t ans = 0;
    for (auto i : irange(0L, k + 1)) {
        ans += dp[i][0];
        if (ans >= M) {
            ans -= M;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3920
fn main() {
    let n = read::<u32>();
    println!("{}", n / 3);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
N, Q = map(int, input().split())
S = list(input())
lr_list = [0] * Q

a_list = []
for i in range(len(S)):
    if S[i] == "A" and i != len(S) - 1:
        if S[i + 1] == "C":
            S[i]="a"

ti=[0]*N

for i in range(1,N):
    if S[i-1]=="a":
        ti[i]=ti[i-1]+1
    else:
        ti[i]=ti[i-1]

for i in range(Q):
    l,r= list(map(int, input().split()))
    print(ti[r-1]-ti[l-1])



Measured memory_bytes: 9504