akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ADoubleHelix solver = new ADoubleHelix();
        solver.solve(1, in, out);
        out.close();
    }

    static class ADoubleHelix {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            String answer = null;
            if (s.equals("A")) {
                answer = "T";
            } else if (s.equals("T")) {
                answer = "A";
            } else if (s.equals("C")) {
                answer = "G";
            } else if (s.equals("G")) {
                answer = "C";
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 21332
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int C[26]{};

int main() {
  string S;
  cin >> S;
  int N = S.size();
  if (N < 26) {
    for (int i = 0; i < N; ++i) {
      ++C[S[i] - 'a'];
    }
    for (int i = 0; i < 26; ++i) {
      if (C[i] == 0) {
        S += i + 'a';
        printf("%s\n", S.c_str());
        return 0;
      }
    }
  } else {
    vector<char> V{S[N - 1]};
    int i = N - 2;
    while (i >= 0) {
      for (int j = 0; j < V.size(); ++j) {
        if (S[i] < V[j]) {
          S = S.substr(0, i);
          S += V[j];
          printf("%s\n", S.c_str());
          return 0;
        }
      }
      V.push_back(S[i--]);
      sort(V.begin(), V.end());
    }
    printf("-1\n");
  }
}

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

int main() {
    long long N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    long long diff = B - A;
    long long l = -(N - 1) * D;
    long long r = -(N - 1) * C;
    for(int i=0; i<N-1; ++i) {
        if(diff >= l && diff <= r) {
            cout << "YES" << endl;
            return 0;
        } else {
            l += C + D;
            r += C + D;
        }
    }

    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int x[60];
long long dp[60][60][60 * 60];

int main(int argc, char const *argv[])
{
	int n, A;
	cin >> n >> A;

	int max_cost = 0;
	for(int i = 1; i <= n; i++) {
		cin >> x[i];
		max_cost += x[i];
	}
	dp[0][0][0] = 1;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j <= n; j++) {
			for(int k = 0; k <= max_cost; k++) {
				dp[i][j][k] += dp[i - 1][j][k];
				if(x[i] <= k and j > 0) dp[i][j][k] += dp[i - 1][j - 1][k - x[i]];
			}
		}
	}
	long long ans = 0;
	for(int i = 1; i <= n; i++) {
		if((i * A) > max_cost) break;
		ans += dp[n][i][i * A];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 60160
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
int divr[maxn];
/*ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}*/
void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
 
 
 
 
 














int main()
{
     int n;
     cin>>n;
     int a[n];
     for(int i=0;i<n;i++)cin>>a[i];
     map<int,int> mp;
     ll ct=0;
     for(int i=0;i<n;i++)
     {
          ct+=1LL*mp[i+1-a[i]];
          mp[i+1+a[i]]++;
     }cout<<ct;
     
}



















 
 
 
 
 

















Measured memory_bytes: 21272
n,m=map(int, input().split())
a=[list(map(int, input().split())) for _ in range(m)]
c=[0]*-~n
id={}
for p,y in sorted(a,key=lambda x:x[1]):
    c[p]+=1
    id[y]=format(p,"06")+format(c[p],"06")
for _,y in a:
    print(id[y])

Measured memory_bytes: 43860
import java.util.Scanner;

public class Main {

	private static Scanner sc;

	public static void main(String[] args){
		sc = new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			int x=sc.nextInt();
			int a=0;
			if(n==0&&x==0)break;
			for(int i=1;i<=n-2;i++){
				for(int j=i+1;j<=n-1;j++){
					for(int k=j+1;k<=n;k++){
						if(i+j+k==x){
							a=a+1;
							break;
						}
					}
				}
			}
			System.out.println(a);
		}
	}
}

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

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

    int a, b;

    int ans_a, ans_b;
    bool res = false;
    for (int a=-118; a<=119; ++a) {
        for (int b=-119; b<=118; ++b) {
            if (pow(a, 5) - pow(b, 5) != X) continue;
            ans_a = a;
            ans_b = b;
            res = true;
            break;
        }
        if (res == true) break;
    }
    cout << ans_a << " " << ans_b << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <algorithm>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

typedef long long ll;
const int mod = 1e9 + 7;
const int N = 70010;

int a[N], hu[N], tp[N];
int n, m, maxn;
ll f[20][N], fac[N], inv[N], ans;

bool cmp(int x, int y) {return x > y;}

ll pow(ll a, int b)
{
    ll ans = 1;
    for(; b; b >>= 1)
    {
        if (b & 1) ans = ans * a % mod;
        a = a * a % mod;
    }
    return ans;
}

ll C(int x, int y)
{
    if (x < y) return 0;
    return fac[x] * inv[y] % mod * inv[x - y] % mod;
}

int main()
{
    scanf("%d%d", &n, &m); maxn = (1 << n) - 1;

    fac[0] = 1; FOR(i, 1, maxn + 1) fac[i] = fac[i - 1] * i % mod;
    inv[maxn + 1] = pow(fac[maxn + 1], mod - 2); for(int i = maxn; ~i; --i) inv[i] = inv[i + 1] * (i + 1) % mod;

    FOR(i, 1, maxn) hu[i] = hu[i >> 1] * 2 + (i & 1);
    FOR(i, 1, maxn) tp[i] = (tp[i >> 1] + (i & 1)) & 1;

    FOR(i, 1, m) scanf("%d", &a[i]);
    sort(a + 1, a + m + 1, cmp);

    f[0][0] = 1;
    FOR(i, 1, m) FOR(j, 0, maxn)
    {
        f[i][j] = f[i - 1][j];
        FOR(k, 0, n - 1) if ((1 << k) & j)
            (f[i][j] += f[i - 1][j ^ (1 << k)] * C((1 << n) - hu[j ^ (1 << k)] - a[i], (1 << k) - 1) % mod * fac[1 << k]) %= mod;
    }
    
    FOR(i, 0, maxn) (ans += (tp[i] ? -1 : 1) * f[m][i] * fac[(1 << n) - hu[i] - 1] % mod + mod) %= mod;
    printf("%lld\n", ans * (1LL << n) % mod);

    return 0;
}


Measured memory_bytes: 12160
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<algorithm>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> data(n);
	for (int i = 0; i < n; i++)
		cin >> data[i];
	sort(data.begin(), data.end());
	int count = 0;
	rep(i,n)
		rep(j,n)
		rep(k, n) {
		if (k > j && j > i && data[i] !=data[j]&& data[j] != data[k] && data[i] != data[k] && data[i] + data[j] > data[k])
			count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3612
a,b,c,k = map(int,input().split())
count = 0
kaisuu = 0
if k <= a :
    print(k) 
else :
    count += a
    if (k - a) <= b :
        print(a)
    else :
        maina = k - a - b
        count -= maina
        print(count)    
    


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //2019 = 3*673
    string S; cin >> S;
    int N = S.length();
    int pow10[N+1] = {1};
    for(int i = 1; i <= N; i++){
        pow10[i] = pow10[i-1]*10 % 2019;
    }
    int md[N+1] = {};
    for(int i = N-1; i >= 0; i--){
        md[i] = (md[i+1] + (S[i]-'0')*pow10[(N-1)-i]) % 2019;
    }
    map<int, ll> mp;
    rep(i, N+1) mp[md[i]]++;
    //rep(i, N+1) cout << md[i] << " "; cout << endl;
    ll ans = 0;
    rep(i, 2020){
        ll num = mp[i];
        ans += num*(num-1)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5264
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    int N;
    int a[214514];
    int now=0;
    cin >> N;
    REP(i,N){cin >> a[i];}
    if(N%2==0){
        REP(i,N/2){
            cout << a[N-2*i-1];
            if(now!=N-1)cout << " ";
            now++;
        }
        REP(i,N/2){
            cout << a[2*i];
            if(now!=N-1)cout << " ";
            now++;
        }
    }else{
        REP(i,N/2){
            cout << a[N-2*i-1];
            if(now!=N-1)cout << " ";
            now++;
        }
        cout << a[0] << " ";
        REP(i,N/2){
            cout << a[2*i+1];
            if(now!=N-1)cout << " ";
            now++;
        }
    }
    cout << endl;

return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#define ll long long
using namespace std;

ll gcd(ll a,ll b){
      ll t = a%b;
      while(t > 0){
            a = b;
            b = t;
            t  = a%b;
      }
      return b;
}

int main(){
      ll A,B,ans=1;
      cin >> A >> B;
      
      ll N = gcd(A,B);
      for(ll i = 2;i*i <= N;i++){
            if(N%i == 0){
                  ans++;
                  while(N%i==0)N/=i;
            }
      }
      if(N > 1)ans++;
      cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  long long hito,a,b;
  cin >> hito >> a >> b;
  long long kotae = 0;
  long long hayai = 0;
  hayai = 9000000000000000000;
  if((b - a) % 2 == 0){
      kotae = (b - a) / 2;
  }
  else{
      if(a - 1 <= hito - b){
        kotae = a + (b - a - 1) / 2; 
      }
    else{
    	kotae = hito - b + 1 + (b - a - 1) / 2;  	
    }
  }
  cout << kotae << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)
 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace std;
 
int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   ll arr[n];
   rep(n)
        cin>>arr[i];
   sort(arr,arr+n);
   bool pos = 1;
   for(ll i=1;i<n;i++)
        if(arr[i] == arr[i-1])
            pos = 0;
   if(pos)
        cout<<"YES\n";
   else cout<<"NO\n";        
   
   return 0;        
}  

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
 
int main(){
  ll N,D;
  cin>>N>>D;
  
  ll d=2*D+1;
  ll ans;
  if(N%d==0){
    ans=N/d;
  }
  else{
    ans=(N-(N%d))/d+1;
  }
  
  cout<<ans<<endl;
}
    
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int main(){
	ll x,y;cin>>x>>y;
	puts(abs(x-y)<=1?"Brown":"Alice"); 
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int a[n+1];
    for(int i = 0; i < n; i++)cin >> a[i];
    sort(a,a+n);
    double half = (a[0]+a[1])/2.0;
    //cout << half << endl;
    for(int i = 2; i < n; i++){
        half = (half + (double)a[i]) / 2.0;
    }
    cout << half << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int num; //number
int t;   //target
int f;   //flag(MSB)

//max=4^shisu
void keta(int max){
  
  if(num>=max){
    t=num/max;      //Target Print
    printf("%d",t);
    num-=t*max;     //Subtraction
    f=1;        //MSB already check
  }
  else{
    if(f){ //No MSB Filter
      printf("0");
    }
  }
}

int main(void){

  for(;;){
    scanf("%d",&num);
    if(num==-1)
      break;
    f=0;      //Flag Init

    //Keta Method Call
    keta(262144);
    keta(65536);
    keta(16384);
    keta(4096);
    keta(1024);
    keta(256);
    keta(64);
    keta(16);
    keta(4);
    
    printf("%d\n",num);  //LSB Print
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	public static void main(String[] args) {

		// 入力
		Scanner sc = new Scanner(System.in);
		
		// 数値
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int k = sc.nextInt();
		
		int max = a;
		if (b > max) {
			max = b;
		}
		if (c > max) {
			max = c;
		}
		
		int x = max;
		for (int i = 0; i < k; i++) {
			x = x*2;
		}

		int ans = x + a + b + c - max;

		// 出力
		System.out.println(ans);

		sc.close();

	}
}

Measured memory_bytes: 20820
n=int(input())
arr=list(map(int,input().strip().split()))
arr.sort()
maxi=arr[-1]
booll=[True]*(maxi+1)
r=0
for i in range(n-1):
    a=arr[i]
    if(booll[a]==True):
        for j in range(a,maxi+1,a):
            booll[j]=False
        if(a<arr[i+1]):
            r=r+1
if(booll[arr[n-1]]==True):
    r=r+1
print(r)    


Measured memory_bytes: 32392
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
typedef long long LL;
const int e[40]={0,1,1,2,2,2,3,3,3,3,4,4,4,4,4,5,5,5,5,5,
                 5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8};
const int pr[12]={2,3,5,7,11,13,17,19,23,29,31,37};
const LL UnUseMethod=4759123141;
LL count[2]={0};
LL IN(void)
{
  LL x=0;short f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
LL GCD(LL a,const LL b){return !b?a:GCD(b,a%b);}
LL Mult(LL x,LL y,const LL mod){LL z=x*y-(LL)((long double)x/mod*y+1e-8)*mod;return z<0?z+mod:z;}
LL BinaryModularPower(LL base,LL pow,const LL mod)
{
  LL x=1;
  while(pow){if(pow&1){x=Mult(x,base,mod);}base=Mult(base,base,mod);pow>>=1;}
  return x;
}
void Exp(LL x,const LL y){count[1]=0;while(!(x%y)){count[1]++;x/=y;}count[0]=x;return;}
int MillerRabin(const LL a)
{
  if(a==2)return 1;
  if(a%2==0||a==1)return 0;
  LL u=a-1,t=0,p=1;
  while(!(u&1)){u>>=1;t++;}
  for(int i=0;i<12;++i)
  {
    p=pr[i]%a;
    if(!p)return 1;
    LL x=BinaryModularPower(p,u,a);
    if(x==1)continue;
    for(int j=0;x!=a-1&&j<t;j++)
    {
      x=Mult(x,x,a);
      if(x==1)return 0;
    }
    if(x==a-1)continue;
    return 0;
  }
  return 1;
}
LL PollardRho(const LL n,const LL c)
{
  LL d,i=1,k=2,x=rand()%(n-1)+1,y=x;
  while(1)
  {
    i++;
    x=(Mult(x,x,n)+c)%n;
    d=GCD((y-x+n)%n,n);
    if(1LL<d&&d<n){return d;}
    if(y==x){return n;}
    if(i==k){y=x;k<<=1;}
  }
}
signed main(void)
{
  srand((unsigned int)time(NULL));
  LL a=0,p=1,q=-1,N=IN();
  if(N<=1)return puts("0"),0;
  Exp(N,2);a=e[count[1]];N=count[0];
  Exp(N,3);a+=e[count[1]];N=count[0];
  while(q*q<=UnUseMethod)
  {
    p+=6,q+=6;
    Exp(N,p);a+=e[count[1]];N=count[0];
    Exp(N,q);a+=e[count[1]];N=count[0];
  }
  if(N<=UnUseMethod){if(N>1){a++;}return printf("%lld\n",a),0;}
  if(MillerRabin(N)){a++;return printf("%lld\n",a),0;}
  while(N>=UnUseMethod)
  {
    p=PollardRho(N,0);
    while(!MillerRabin(p))p=PollardRho(p,p);
    Exp(N,p);a+=e[count[1]];N=count[0];
  }
  if(MillerRabin(N)){a++;}return printf("%lld\n",a),0;
}

Measured memory_bytes: 1608
#include <iostream>

using namespace std;

int main(void){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  while(true){
    C = C - B;
    if(C <= 0){
      cout << "Yes" << endl;
      return 0;
    }
    A = A - D;
    if(A <= 0){
      cout << "No" << endl;
      return 0;
    }
  }
  return 0;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    vector<ll> a(N);

    REP(i,N) cin >> a[i];

    ll sum = 0;
    ll ans = 0;
    REP(i,N) {
        if(a[i]!=0){
            sum += a[i];
        } else {
            ans += sum / 2;
            sum = 0;
        }
    }
    if(sum != 0) ans += sum / 2;

    pl(ans)

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main(){

	int N, M, P;
	int X, ok, sum;

	while (1){

		cin >> N >> M >> P;
		if (N == 0 && M == 0 && P == 0) break;

		sum = 0, ok = 0;
		for (int i = 1; i <= N; i++){
			cin >> X;
			sum += X;
			if (i == M) ok += X;
		}

		if (ok == 0) cout << "0" << endl;
		else cout << (sum*(100-P)) / ok << endl;
	}

	return 0;

}

Measured memory_bytes: 1160
N = int(input())
a = [list(map(int, input().split())) for _ in range(N)]

table = [a[0]]
def dp(n, i):
  for j in range(len(table), n+1):
    table.append([0]*3)
    for k in range(3):
      h = [table[j-1][l]+a[j][k] for l in range(3) if k != l]
      table[j][k] = max(h)
  return table[n][i]

print(max([dp(N-1, i) for i in range(3)]))

Measured memory_bytes: 47380
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll func(ll st, ll en, vector<vector<ll>>&dp, vector<ll>&arr){
    if(st>en)return 0;
    if(dp[st][en]!=-1){
        return dp[st][en];
    }
    dp[st][en] = max(arr[st]+ min(func(st+2, en, dp, arr), func(st+1, en-1, dp, arr)), arr[en] + min(func(st+1, en-1, dp, arr), func(st, en-2, dp, arr)));
    return dp[st][en];
}

int main(){
    ll t;
    t = 1;
    while(t--){
        ll n;
        cin>>n;
        ll sum = 0;
        vector<ll>arr(n, 0);
        for(ll i =0 ; i < n ; i++){
            cin>>arr[i];
            sum+=arr[i];
        }
        vector<vector<ll>>dp(n, vector<ll>(n, -1));
        cout<<func(0, n-1, dp, arr)+func(0, n-1, dp, arr)-sum<<endl;
    }
}

Measured memory_bytes: 70912
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
const int N=4e5+100;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
char s[N];
int nxt[N];
LL ans[26],cnt[1000][26],len[1000];
//每次会把串SS变成STST，其中T为S的最小周期
//如果T是S的约数，那么最后的串为STTTTTTTT的形式，可以直接计算
//如果T不是S的约数，那么串会变成 S T ST STS 这样的斐波那契形式
inline void solve(int n,int v,LL m) {
	int i,t;
	if (n%v) {
		memset(cnt,0,416);
		len[0]=v;
		for (i=1;i<=v;i++) cnt[0][s[i]-'a']++;
		len[1]=n;
		for (i=1;i<=n;i++) cnt[1][s[i]-'a']++;
		for (i=2;(len[i]=len[i-1]+len[i-2])<=m;i++)
			for (t=0;t<26;t++) cnt[i][t]=cnt[i-1][t]+cnt[i-2][t];
		while (i--)
			if (m>=len[i])
				for (t=0,m-=len[i];t<26;t++) ans[t]+=cnt[i][t];
		for (i=1;i<=m;i++) ans[s[i]-'a']++;
	} else {
		for (i=1;i<=n&&i<=m;i++)
			ans[s[i]-'a']++;
		if (m<=n) return;
		m-=n;
		for (i=1;i<=v;i++)
			ans[s[i]-'a']+=m/v+(m%v>=i);
	}
}
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1)/2,i,k,v;LL l,r;cin>>l>>r;
	for (i=2,k=0;i<=n;i++) {
		while (k&&s[k+1]!=s[i]) k=nxt[k];
		nxt[i]=k+=s[k+1]==s[i];
	}
	v=n-nxt[n];
	solve(n,v,l-1);
	for (i=0;i<26;i++) ans[i]*=-1;
	solve(n,v,r);
	for (i=0;i<26;i++)
		cout<<ans[i]<<" ";
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    int t;
    if(a == c)
    t = abs(b - d);
    // else if(a > c){
    //     if(b >= d)
    //     t = (24 - (a - c))*60 + (b - d);
    //     else
    //     t = (24 - ((a - 1) - c))*60 + 60 - (d - b);
    // }
    else if( c > a){
        if(d >= b)
        t = (c -a)*60 + d -b;
        else
        t = (c - 1 - a)*60 + 60 - (b - d);
    }
    cout << t - e ;
}









Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>

using namespace std;

int main(){
    string S;
    cin>>S;
    int win=0;
    for(int i=0;i<S.size();i++){
        if(S[i]=='o') win++;
    }
    int rest=15-S.size();
    if(win+rest>=8) cout<< "YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int A,B,C,N;
  cin >> A >> B >> C >> N;
  int count = 0;
  for(int i=0;i<A+1;i++)
  {
    for(int j=0;j<B+1;j++)
    {
      for(int k=0;k<C+1;k++)
      {
        if(500*i+100*j+50*k==N)
        {
          count++;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

bitset<2020> win[2020];
bitset<2020> dp[2][2020];
signed main() {
    int N; scanf("%d", &N);
    
    for(int i=0; i<N; i++) {
        for(int j=0; j<i; j++) {
            char c; scanf(" %c", &c);
            bool p = c - '0';
            win[i][j] = p;
            win[j][i] = !p;
        }
    }

    for(int i=0; i<N; i++) dp[0][i][i] = dp[1][i][i] = true;
    for(int d=1; d<N; d++) {
        for(int i=0; i<N-d; i++) {
            int j = i + d;
            bool f1 = (dp[0][j] & dp[1][i+1] & win[i])._Find_next(i  ) <= j;
            bool f2 = (dp[1][i] & dp[0][j-1] & win[j])._Find_next(i-1) <= j-1;
            dp[0][j][i] = f1, dp[1][i][j] = f2;
        }
    }

    int ans = 0;
    for(int i=0; i<N; i++) ans += (dp[0][N-1][i] & dp[1][0][i]);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ctoi(x) x-'0'
#define pshb(a) cin >> x;a.push_back(x)
#define fr(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false);
using namespace std;
ll dp[100100] ;
int main()
{ll cnt =0 , n ;
    string s ;
    cin>>n>>s ;

    for (int i = 0 ; i< n ; i++)
    {
        if (s.substr(i,3)=="ABC")cnt++ ;
    }
    cout<<cnt ;
}




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

int main(){
  int N,cnt = 0,i = 0;
  string S;
  cin >> N >> S;
  
  while(N-2 > i ){
  	if(S.at(i) == 'A'){
    	if(S.at(i+1) == 'B'){
        	if(S.at(i+2)== 'C'){
            	cnt++;
              	i += 2;
            }
        }
    }
    i++;
  }
  
  cout << cnt << endl;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

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

const ll L = 1e5+5;

void solve()
{
    ll k = nxt(), n = nxt();

    basic_string <ll> a(n, 0);
    generate(all(a), nxt);

    ll ans = 1e15;

    for(ll i=n; i<2*n; i++)
    {
        a += (a[i-n] + k);
    }

    for(ll i=0; i<n; i++)
    {
        ans = min(ans, a[i+n-1] - a[i]);
    }

    cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 4864
from sys import stdin


def x_plus_y(x, y):
    return x+y


def max_x_y(x, y):
    return x if(x < y) else y


N, A, B = [int(x) for x in stdin.readline().rstrip().split()]
sumAB = x_plus_y(A, B)
res = N - sumAB
Max = max_x_y(A, B)
Min = 0

resMin = None
resMax = None

for i in range(Min, Max+1):
    bar = res + i
    if(bar >= 0 and resMin is None):
        resMin = i
    if (bar >= 0):
        resMax = i

print(resMax, resMin)


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

bool ans=true;

int main(){
  int n;
  cin>>n;
  int s=0,x=0,y=0;
  
  for(int i=0;i<n;i++){
    int t,nx,ny;
    cin>>t>>nx>>ny;
    int d=t-s;
    int w=abs(nx-x)+abs(ny-y);
    if(d%2!=w%2 || w>d){
      ans=false;
    }
    s=t;
    x=nx;
    y=ny;
  }
  cout<< (ans?"Yes":"No") <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#define N 3456
template<typename T> inline void read(T &x) {
	x = 0; char c = getchar();
	while (!isdigit(c)) c = getchar();
	while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
}
using namespace std;
int n, l;
int t[N];
const double PI = 3.141592653589793238462643383;
int main() {
	read(n), read(l);
	for (int i = 1; i <= n; ++i)	read(t[i]);
	double ansx = 0, ansy = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			double x = cos(PI * (t[i] + t[j]) / l), y = sin(PI * (t[i] + t[j]) / l);
			ansx += x * (n - (j - i + 1));
			ansy += y * (n - (j - i + 1));
			x = cos(PI + PI * (t[i] + t[j]) / l), y = sin(PI + PI * (t[i] + t[j]) / l);
			ansx += x * (j - i - 1);
			ansy += y * (j - i - 1);
		}
	}
	ansx /= (1ll * n * (n - 1) * (n - 2) / 6);
	ansy /= (1ll * n * (n - 1) * (n - 2) / 6);
	printf("%.10lf %.10lf\n", ansx, ansy);
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 4001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

// MOD確認

int main(){
    double R;
    cin >> R;
    cout << setprecision(25) << fixed;
    cout << 2 * PI * R << endl;
}


Measured memory_bytes: 3780
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

struct dish {
	int A, B;
	bool operator < (const dish& b) {
		return A < b.A;
	}
};
dish D[3010];
int dp[3010][3010];
int main()
{
	int N, T;
	cin >> N >> T;
	for (int i = 0; i < N; i++) cin >> D[i].A >> D[i].B;
	sort(D, D + N);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= T; j++) dp[i + 1][j] = dp[i][j];
		for (int j = 0; j < T; j++) {
			int t = min(T, j + D[i].A);
			dp[i + 1][t] = max(dp[i + 1][t], dp[i][j] + D[i].B);
		}
	}
	/*for (int i = 1; i <= N; i++) {
		cout << i << "-------------------" << endl;
		for (int j = 0; j <= T; j++) {
			cout << dp[i][j] << endl;
		}
	}*/
	cout << dp[N][T] << endl;
}

Measured memory_bytes: 38864
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(1,n-1):
    if min(p[i-1],p[i],p[i+1]) != p[i] and max(p[i-1],p[i],p[i+1]) != p[i]:
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include <math.h>
main(){
	long double n,k,a=0.0;
	scanf("%Lf%Lf",&n,&k);
	if(k==1)a=n;
	for(int i=1;i<(k<n+1?k:n+1);i++)a+=(powl(0.5,ceill(log2l(k/i))));
	if(k<n)a+=n-k+1;
	a/=n;
	printf("%.10Lf",a);
}


Measured memory_bytes: 512
fun main(args: Array<String>) {
    abc109b()
}

fun abc109b() {
    val n = readLine()!!.toInt()
    val words = (1..n).map { readLine()!! }

    val duplicated = words.groupBy { it }.let { it.maxBy { it.value.size }!!.let { it.value.size > 1 } }

    val isShiritori = (0 until n - 1).all {
        words[it].last() == words[it + 1].first()
    }

    val answer = if (!duplicated && isShiritori) "Yes" else "No"

    println(answer)
}

Measured memory_bytes: 33488
import  numpy as np

s = input()
x = [int(str) for str in list(s)]
a0 = [0]
a1 = [1]

for i, v in enumerate(x):
    if i == 0:
        continue
    else:
        if a0[i-1] == 0:
            a0.append(1)
        else:
            a0.append(0)

        if a1[i-1] == 0:
            a1.append(1)
        else:
            a1.append(0)

x = np.array(x)
a0 = np.array(a0)
a1 = np.array(a1)

num_a0 = np.sum(x != a0)
num_a1 = np.sum(x != a1)

print(min(num_a0, num_a1))


Measured memory_bytes: 16212
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}


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

    int ans = 0;
    int cnt = 0;
    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }
    for (int i = 1; i <= n; i++) {
        int tmp = 0;
        if (i % 2 == 0) {
            int j = i;
            while (true) {
                j /= 2;
                tmp++;
                if (j % 2 == 1)
                    break;
            }
        }
        if (tmp > cnt) {
            ans = i;
            cnt = tmp;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,ans,x;
void read(int &x)
{
    int f=1;x=0;char s=getchar();
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    x*=f;
}
int PD(int x)
{
	int count=0;
    while(x){
        if(x&1){
            return count; 
        }
        count++; 
        x>>=1; 
    }
    return count; 
}
int main()
{
	read(n);
	for(int i=1;i<=n;i++)
	{read(x);
		ans+=PD(x);
	}
	printf("%d",ans);
}


Measured memory_bytes: 128
n,a,b,c,d=map(int,input().split())
a-=1
b-=1
c-=1
d-=1

temp=str(input())
maxim=max(a,b)
minim=min(a,b)
if temp[maxim:d+2].count("...")!=0 or temp[maxim+1]==temp[maxim+2]=="." or temp[maxim+1]==temp[maxim-1]==".":
    flag=1
else:
    flag=0
    
s=list(temp)
s[a]="A"
s[b]="B"
s[c]="C"
s[d]="D"

mac=max(c,d)
ans=1

for i in range(minim,mac):
    if s[i]==s[i+1]=="#":
        ans=0

if c<d and ans==1:
    ans=1
elif c>d and ans==1:
    if flag==1:
        ans=1
    elif s[d-1]=="#" or s[d+1]=="#":
        ans=0
    else:
        ans=1
                
if ans==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 5044
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f5

#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

int dx[] = { -1, 0, 1, 0, -1, -1, 1, 1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};


int main() {

	int l, r, d; cin >> l >> r >> d;
	int q1 = r / d;
	int q2 = (l - 1) / d;

	cout << q1 - q2;

	return 0;
}

Measured memory_bytes: 3196
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
inline int read(){
	int sum = 0, t = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){ if(ch == '-') t = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9'){ sum = sum * 10 + ch - '0'; ch = getchar(); }
	return sum * t;
}

int D;
ll pw[20], sum[20], ans;

vector<ll>A;

ll dfs(int x, ll val){
	if(x == A.size()) return !val;
	if(val < -sum[x] * 9 || val > sum[x] * 9) return 0;
	ll res = 0;
	for(int i = 0; i <= 9; i++){
		int t = 9 - i + (x != 0);
		res += dfs(x + 1, val - i * A[x]) * t;
	}
	for(int i = 1; i <= 9; i++){
		int t = 10 - i;
		res += dfs(x + 1, val + i * A[x]) * t;
	}
	return res;
}

int main(){
	pw[0] = 1;
	for(int i = 1; i < 19; i++)  pw[i] = pw[i - 1] * 10;
	D = read();
	for(int i = 2; i <= 18; i++){
		A.clear();
		for(int j = i - 1, k = 0; j > k; j--, k++)
			A.push_back(pw[j] - pw[k]);
		sum[A.size()] = 0;
		for(int j = A.size() - 1; ~j ; j--)
			sum[j] = sum[j + 1] + A[j];
		ll res = dfs(0, D);
		if(i & 1) res *= 10;
		ans += res;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

struct UnionFind {
	vector<int>d;
	UnionFind(int n = 0) :d(n, -1) {}//コンストラクタ(全部根でサイズは1(根は負))
	int find(int x) {
		if (d[x] < 0)return x;//今根なら頂点番号を返す
		return  d[x] = find(d[x]);//親についてfindする(経路縮約ver）
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);//両方を根に変える
		if (x == y)return false;//一致するならfalse
		if (-d[x] < -d[y])swap(x, y);//xの方がサイズが大きくなるようにする
		d[x] += d[y];//xにyをくっつける
		d[y] = x;
		return  true;
	}
	bool same(int x, int y) { return find(x) == find(y); }//同じ集合の属しているか
	int size(int x) { return -d[find(x)]; }//サイズを返す
};


const int mod = 1000000007;

int main() {
	int n, m;
	cin >> n >> m;
	//vector<int>a(n), b(n);
	//vector<vector<int>>c(n);
	//set<P>s;
	UnionFind uf(n);
	rep(i, m) {
		int a,b;
		cin >> a >> b;
		a--; b--;
		uf.unite(a, b);
	}
	int ans(0);
	rep(i, n) {
		int k = uf.size(i);
		ans = max(ans, k);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 4036
import java.util.Scanner;
class Main{    
    int a,b;      
    public void yatary() {        
        Scanner sc = new Scanner(System.in);        
        a =sc.nextInt(); 
        b =sc.nextInt(); 
        if(a < b){
            System.out.println("a < b");
       }else if(a > b){
            System.out.println("a > b");
       }else{
            System.out.println("a == b");
       }   
    } 
    public static void main(String[] args){  
        new Main().yatary();   
    }
}

Measured memory_bytes: 17348
n, m, k = map(int, input().split())
mod = 998244353

N = 10 ** 6

#逆元テーブル
inv_t = [0]+[1]
for i in range(2, N):
  inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]

#階乗計算
kai = [1, 1]
rev_kai = [1, inv_t[1]]
for i in range(2, N):
	kai.append(kai[-1] * i % mod)
	rev_kai.append(rev_kai[-1] * inv_t[i] % mod)

# コンビネーション計算
def cmb(n, r):
	return kai[n] * rev_kai[r] * rev_kai[n-r] % mod

base = m
ans = 0

for i in range(n-1):
    base = base * (m-1) % mod

for i in range(0, k+1):
    if i == n-1:
        base = m
    ans += base * cmb(n-1, n-1-i)
    ans %= mod
    base = base * inv_t[m-1] % mod

# if m == 1 and k > n-1:
#     print(1)
# else:
print(ans)


Measured memory_bytes: 127672
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int n=0;
vector<int> a(n);
int main(){
    cin>>n;
    a.resize(n);
    rep(i,n)cin>>a.at(i);
    sort(a.begin(),a.end());
    int now=0;
    int pointer=0,kind=0;
    vector<vector<int>>count;
    while(pointer<n){
        if(now!=a.at(pointer)){
            now=a.at(pointer);
            count.resize(kind+1);
            count[kind].resize(2);
            count.at(kind).at(0)=now;
        }
        while((pointer<n)&&(now==a.at(pointer))){
            count.at(kind).at(1)++;
            pointer++;
        }
        kind++;
    }
int64_t remove=0;
rep(i,kind){
    if(count.at(i).at(0)>count.at(i).at(1)){
       remove+=count.at(i).at(1);
    }
    else if(count.at(i).at(0)<count.at(i).at(1)){
       remove+= count.at(i).at(1)-count.at(i).at(0);
    }
    else{
        continue;
        }
    }
    cout<<remove<<endl;
    return 0;
}


Measured memory_bytes: 6324
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

// d*t<=m ??¨???????????§???t
int f(int d,int m) {
    int t=1;
    while(d*t<=m) t++;

    t--;
    // printf("%d * %d <= %d\n",d,t,m);
    return t*d;
}
int n,m;
int a[10004];
int times[10004];
void solve() {
    rep(i,n) cin>>a[i];
    times[0] = f(a[0],m);
    int min_time = times[0];
    
    rep(i,n) if(i) {
        int t=f(a[i],min_time)+a[i];
        if(m<t) {
            t=f(a[i],m);
        }
        times[i] = t;
        min_time = min(min_time,t);
    }
    min_time = *min_element(times,times+n);
    int cnt=0;
    rep(i,n) if(min_time==times[i]) {
        cnt++;
    }
    // rep(i,n) cout<<i<<" : "<<times[i]<<endl;
    if(cnt>1) {
        int t=-1;
        rep(i,n) if(min_time==times[i]) {
            // printf("%d %d\n",min_time, i);
            if(t==-1 || a[i]<a[t]) {
                t=i;
            }
        }
        int cnt2=0;
        rep(i,n) if(a[t]==a[i]) cnt2++;
        if(cnt2==1) cout<<t+1<<endl;
        else cout<<n<<endl;
    }
    else {
        int t=find(times,times+n,min_time)-times;
        cout<<t+1<<endl;
    }
}
int main() {
    while(cin>>n>>m) {
        if(n+m==0) break;
        solve();
    }
    return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int N, M; cin >> N >> M;
  dsu ds(N);
  REP(i, M) {
    ll a, b; cin >> a >> b; a--; b--;
    ds.merge(a, b);
  }
  ll ans = ds.groups().size();
  cout << ans - 1 << endl;
}

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

#define ll long long
#define ld long double
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c,d,e,f;
    cin >> a >> b >>  c >> d >> e >> f;
    ll answ1 = 0;
    ll answ2 = 0;
    ld answ3 = 0;
    for (ll ia = 0 ; ia <= f/100 + 1; ia++)
        for (ll ib = 0 ; ib <= f/100 + 1; ib++)
            if (ia*a*100 + ib*b*100 <= f)
            for (ll ic = 0 ; ic <= f - (ia*a*100 + ib*b*100) + 1; ic++)
                for (ll id = 0 ; id <= f - (ia*a*100 + ib*b*100) + 1 ; id++){
                    ll wa = ia*a*100 + ib*b*100;
                    ll s = ic*c + id*d;
                    if (wa + s <= f)
                    if (100*s <= wa*e){
                        if ((ld)s/(ld)wa*100 > answ3){
                            answ3 = 100*(ld)s/(ld)wa;
                            answ1 = wa;
                            answ2 = s;
                        }
                    }
                }
    answ1 += answ2;
    if (answ1 == 0){
        cout << 100*a << " " << 0 << endl;
    } else
    cout << answ1 << " " << answ2 << endl;
    return 0;
}

Measured memory_bytes: 256