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

int main(){
	int n,m ;
	cin >> n >> m ;
	if(n>=m) cout << 0 << endl ;
	else{
		vector<int> d(m-1) ;
		vector<int> x(m) ;
		for(int i=0;i<m;i++) cin >> x.at(i) ;
		sort(x.begin(),x.end()) ;
		for(int i=1;i<m;i++){
			d.at(i-1) = x.at(i)-x.at(i-1) ;
		}
		sort(d.begin(),d.end()) ;
		reverse(d.begin(),d.end()) ;
		int ans = x.at(m-1)-x.at(0) ;
		for(int i=0;i<n-1;i++){
			ans -= d.at(i) ;
		}
		cout << ans << endl ;
	}
}

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

int main() {
  int N, A, B;
  cin >> N;
  cin >> A >> B;
  int a, b = 0;
  vector<int> P(N);
  for(int i = 0; i < N; i++) {
    cin >> P.at(i);
  }
  for(int i = 0; i < N; i++) {
    if(P.at(i) <= A) {
      a++;
    }
  }
  for(int i = 0; i < N; i++) {
    if(P.at(i) >= B+1) {
      b++;
    }
  }
  cout << min(a,min(b,N-a-b)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int n; cin >> n;
    vector<pair<ll, ll>> a(n);
    rep(i, n) {
        ll x, y; cin >> x >> y;
        a[i] = {x, y};
    }
    ll mini = INT_MAX;
    ll maxa = INT_MAX * -1;
    ll ans = 0;
    rep(i, n) {
        chmin(mini, a[i].fi+a[i].se);
        chmax(maxa, a[i].fi+a[i].se);
    }
    ans = max(ans, maxa-mini);
    mini = INT_MAX;
    maxa = INT_MAX * -1;
    rep(i, n) {
        chmin(mini, a[i].fi-a[i].se);
        chmax(maxa, a[i].fi-a[i].se);
    }
    ans = max(ans, maxa-mini);
    cout << ans << endl;
}

Measured memory_bytes: 6428
#include<bits/stdc++.h>
#define ll long long
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main()
{
  int a[200]={1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000,114514};
  int x;
  cin >>x;
  rep(i,200){
    if(a[i]>x){printf("%d",a[i-1]);
               break;
              }
  }
}

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

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

ll N, X, L[100];

int main(){
    cin >> N >> X;
    for(int i=0;i<N;i++)    cin >> L[i];
    
    ll D = 0;
    ll ans = 0;
    while(D <= X){
        D = D + L[ans];
        ans++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

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

  std::string S;
  std::cin >> S;


  bool judge = false;
  if (S[2] == S[3] && S[4] == S[5]) {
    judge = true;
  }

  if (judge) print("Yes");
  else print("No");

  return 0;
}


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

signed main(){
	string s,t;
	cin >> s >> t;
	int cnt= 0;
	for (int i=0; i<s.size(); ++i){
		if(s[i] == t[i]) ++cnt;
	}
	cout << cnt;
	return 0;
}

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

int main () {
    int n, m, x;
    std::cin >> n >> m >> x;
    std::vector<int> a(m);
    for (int i = 0; i < m; i++) {
        std::cin >> a[i];
    }

    int ansa = 0;
    int ansb = 0;

    for (int i = 0; i < m; i++) {
        if(a[i] > 0 && a[i] < x) {
            ansa++;
        }

        if(a[i] > x && a[i] < n) {
            ansb++;
        }
    }

    std::cout << std::min(ansa, ansb) << "\n";
}

Measured memory_bytes: 256
N=int(input())

def ketasuu(N):
  N=str(N)
  return len(N)

ans=0
keta=ketasuu(N)

if keta%2==1:
  ans+=(N-10**(keta-1)+1)
  for i in range(0,keta-2,2):
    ans+=9*10**i
else:
  for i in range(0,keta-1,2):
    ans+=9*10**i

print(ans)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();

    if (B <= A) {
      System.out.println("delicious");
    } else if ((B - A) <= X) {
      System.out.println("safe");
    } else {
      System.out.println("dangerous");
    }

  }
}

Measured memory_bytes: 22732
import sys
N = int(raw_input())

d = dict()
for i in range(N):
    s = raw_input() 
    if d.get(tuple(sorted(list(s)))) is None:
        d[tuple(sorted(list(s)))] = 1
    else:
        d[tuple(sorted(list(s)))] += 1

#print d
ret = 0
for x in d.values():
    if x == 1:
        continue
    ret += (x * (x - 1)) / 2


print ret


Measured memory_bytes: 27068
while True:
    n = int(raw_input())
    if n == 0: break
 
    else:
        list = []
        for i in range(n):
            score = int(raw_input())
            list.append(score)
        list.sort();
        list.pop(0);
        list.pop();
        x = sum(list) / (n-2)
        print x

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

typedef long long ll;
typedef long double ld;

int main()
{

  int X,Y,Z;
  cin >> X >> Y >> Z;

  cout << Z << " " << X << " " << Y <<endl;
  

  return 0;
}


Measured memory_bytes: 256
import math
import itertools

N = int(input())
A = [list(map(int,input().split())) for i in range(N)]

ans = 0
for temp in itertools.permutations(A,N):
    distance = 0

    for i in range(0,N-1):
        distance +=  ((temp[i+1][0]-temp[i][0])**2 + (temp[i+1][1]-temp[i][1])**2)**0.5
    ans += distance

print(ans/math.factorial(N))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
const int N = 3005;
const long long mod = 1e9+7;
const int LIMIT = 1e6+17;
int n;
pair <int,int> coor[N];
long long dp[N];
long long g[LIMIT],rev[LIMIT];

long long binpow(int a,int x)
{
 
	long long res;
	if(x == 0) return 1;
	res = binpow(a,x/2) % mod;
	if(x % 2 == 0) return res*res % mod;
	else return ((a*res) % mod * res) % mod;
}
 
long long tohop(int k,int n)
{
	if(k < 0 || n < 0 || k > n) return 0;
	return (g[n] * rev[n-k] % mod) * rev[k] % mod;
}

void add(long long &x, long long y) { x = (x + y) % mod; }
void sub(long long &x, long long y) { x = (x - y + mod) % mod; }
void giaithua()
{
	g[0] = 1;
	for(int i=1;i<1e6+7;i++)
	{
		g[i] = ((g[i-1] % mod) * (i % mod)) % mod;
	}
	
	for(int i=0;i<1e6+7;i++)
	{
		rev[i] = binpow(g[i],mod-2);
	}
}

signed main()
{
 
	giaithua();
	
	int H,W;
	cin>>H>>W;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d",&coor[i].first,&coor[i].second);
	}
 
	sort(coor+1,coor+1+n);
	long long ans = 0;
	for(int i=1;i<=n;i++)
	{
		dp[i] = tohop(coor[i].first-1,coor[i].first+coor[i].second-2);
		for(int j=1;j<i;j++)
		{
			sub(dp[i],dp[j]*tohop(coor[i].second - coor[j].second,coor[i].first - coor[j].first+coor[i].second - coor[j].second) );
		}
		add(ans, dp[i]*tohop(W-coor[i].second,W+H-coor[i].second-coor[i].first) );
	}
 
	
	ans =( ( (tohop(W-1,H+W-2) - ans) % mod ) + mod*10 ) % mod;
	cout<<ans;
}

Measured memory_bytes: 15872
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
	return x*f;
}
const int N=233;
bool vis[N];
int main()
{
	for(int i=1;i<=9;i++)
		for(int j=1;j<=9;j++) vis[i*j]=1;
	int a=read();
	if(vis[a]) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 384
import collections
import math
import operator as op
from functools import reduce
from collections import Counter
import numpy as np
import math
import bisect
import heapq


MOD = 1000000007


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


def main():
    N = get_input()
    if "7" in N:
        print("Yes")
    else:
        print("No")




if __name__ == '__main__':
    main()


Measured memory_bytes: 27152
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 1e6+3;

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) cin >> a[i];
    vector<Int> b = a;
    sort(b.begin(), b.end());
    map<Int, Int> mp;
    Int sum = 0;
    for (Int i = 0; i < n; i+=2) {
        mp[a[i]]++;
        mp[b[i]]++;
        sum++;
    }
    Int cnt = 0;
    for (auto i : mp) {
        if (i.se == 2) cnt++;
    }
    dump(sum - cnt);
    return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MOD 1000000007
#define MAX_N 200001
#define mod(x) ((x % MOD) + MOD) % MOD

using namespace std;

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


int main() {
    int N;
    ll A[MAX_N];
    ll sum[MAX_N];
    cin >> N;
    sum[0] = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        sum[i + 1] = sum[i] + A[i];
    }
    
    sort(sum, sum + N + 1);
    
    ll ans = 0;
    
    ll cur = sum[0];
    ll seq = 1;
    for (int i = 1; i <= N; ++i) {
        
        if (sum[i] == cur) {
            seq++;
        } else {
            ans += seq * (seq - 1) / 2;
            cur = sum[i];
            seq = 1;
        }
    }
    ans += seq * (seq - 1) / 2;
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3328
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int d = in.nextInt();
        out.print("Christmas");
        for (int i = 25; i > d; i--) {
            out.print(" Eve");
        }
        out.println();
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

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

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

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

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

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

char s[1005][1005];
const int mod=1e9+7;

int main()
{
    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++)
        cin>>s[i];
    vector< vector<int> > dp(h,vector<int>(w));
    dp[0][0]=1;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            for(int r:{i,i+1})
            {
                int c=j;
                if(r==i)
                {
                    c=j+1;
                }
                if(r<h && c<w && s[r][c]=='.')
                {
                    dp[r][c]+=dp[i][j];
                    if(dp[r][c]>=mod)
                        dp[r][c]-=mod;
                }
            }
        }
    }
    cout<<dp[h-1][w-1];
}


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

int main(){
  long long int N, K, temp[2][110], uru = 0, xx, sum, ans = 0, y = 0;
  long long int hon, bou[16][10][10], temp3[100] = {};
  long long  int temp2[10][10] =
    {{1, 1, 1, 0, 1, 1, 1},//0
     {0, 0, 1, 0, 0, 1, 0},//1
     {1, 0, 1, 1, 1, 0, 1},
     {1, 0, 1, 1, 0, 1, 1},//3
     {0, 1, 1, 1, 0, 1, 0},
     {1, 1, 0, 1, 0, 1, 1},//5

     {1, 1, 0, 1, 1, 1, 1},
     {1, 0, 1, 0, 0, 1, 0},//7
     {1, 1, 1, 1, 1, 1, 1},
     {1, 1, 1, 1, 0, 1, 1},
    };

  int sugi[20][16] = {};
  int a, b;

  for(int i = 0; i <= 13; i++){
    for(int j = 0; j <= 9; j++){
      for(int k = 0; k <= 6; k++){
	bou[i][j][k] = temp2[j][k];
      }
    }
  }

  cin>>N;

  cin>>K;

  for(int i = 0; i < K; i++){
    cin>>a>>b;
    for(int k = 0; k <= 9; k++){
      bou[a][k][b] = 0;
    }
  }
  for(int i = 0; i<= 13; i++){
    for(int j = 0; j <= 9; j++){
      sum = 0;
       for(int k = 0; k <= 6; k++){
	 sum += bou[i][j][k];//cout<<bou[i][j][k]<<endl;
	
       }//cout<<sum<<endl<<endl;
        sugi[i][j] = sum;
    }
  }
  
  for(int l = 0; l <= 23; l++){
    for(int m = 0; m <= 59; m++){
      for(int n = 0; n <= 59; n++){
	temp3[sugi[8][l/10] +sugi[9][l%10] + sugi[10][m/10] + sugi[11][m%10] + sugi[12][n/10] + sugi[13][n%10]]++;
      }
    }
  }
  
  

  for(int i = 0; i < 10000; i++){
    uru = 0;
    if(i%4 == 0 && i%100 != 0) uru = 1;
    if(i%400 == 0) uru = 1;
    
    for(int j = 1; j <= 12; j++){
      
      if(j == 2){
	if(uru == 1) xx = 29;
	else xx = 28;
      }else if(j == 4 || j == 6 || j == 9 || j == 11){
	xx = 30;
      } else xx = 31;
      
      for(int k = 1; k <= xx; k++){
	hon = sugi[0][i/1000] + sugi[1][(i/100)%10] + sugi[2][(i/10)%10] + sugi[3][i%10]
	  + sugi[4][j/10] + sugi[5][j%10] + sugi[6][k/10] + sugi[7][k%10];
		
	if(hon <= N){
	  ans += temp3[N - hon];
	}
	       
      }
    }
  }

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



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
typedef long long LL;
const LL maxn(100005), mod(1e9 + 7);
LL Jc[maxn];
int a[N];

void calJc()    
{
    Jc[0] = Jc[1] = 1;
    for(LL i = 2; i < maxn; i++)
        Jc[i] = Jc[i - 1] * i % mod;
}

LL pow(LL a, LL n, LL p)    //??? a^n % p
{
    LL ans = 1;
    while(n)
    {
        if(n & 1) ans = ans * a % p;
        a = a * a % p;
        n >>= 1;
    }
    return ans;
}

LL niYuan(LL a, LL b)   //????????
{
    return pow(a, b - 2, b);
}

LL C(LL a, LL b)    //??C(a, b)
{
    return Jc[a] * niYuan(Jc[b], mod) % mod
        * niYuan(Jc[a - b], mod) % mod;
}
int main(){
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	calJc();
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);
	LL ans=0;
	for(int i=k;i<=n;i++){
		LL c=C(i-1,k-1);
		ans=(ans+c*a[i]%mod)%mod;
		ans=(ans-c*a[n-i+1]%mod+mod)%mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1408
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def main():
    A, B, C, D = inpl()
    takahashi = (C + B - 1) // B
    aoki = (A + D - 1) // D

    # print(takahashi, aoki)
    if takahashi <= aoki:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61688
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	if !sc.Scan() {
		panic(nil)
	}
	return sc.Text()
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

type sortRunes []rune

func (s sortRunes) Less(i, j int) bool {
	return s[i] < s[j]
}

func (s sortRunes) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s sortRunes) Len() int {
	return len(s)
}

func SortString(s string) string {
	r := []rune(s)
	sort.Sort(sortRunes(r))
	return string(r)
}

type sortStrings []string

func (s sortStrings) Less(i, j int) bool {
	return s[i] < s[j]
}

func (s sortStrings) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s sortStrings) Len() int {
	return len(s)
}

func SortStrings(s []string) []string {
	sort.Sort(sortStrings(s))
	return s
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	/*
		s := make([][]uint8, n)

		for i := range s {
			str := nextString()
			s[i] = make([]uint8, 10)
			for j := 0; j < 10; j++ {
				s[i][j] = str[i] - `a`[0]
			}
		}*/

	s := make([]string, n)

	for i := range s {
		s[i] = SortString(nextString())
	}
	debugf("%v\n", s)
	s = SortStrings(s)

	debugf("%v\n", s)

	prev := ""
	count := 0
	var ans uint64
	for i := range s {
		if prev != s[i] {
			prev = s[i]
			count = 0
		} else {
			count++
			ans += uint64(count)
		}
	}

	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,w,p=1;
  while(cin>>n>>w,n){
    int dp[n+1]={},a[n],s;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)dp[i]=1e9;
    for(int i=0;i<n;i++){
      s=0;
      for(int j=i;j<n;j++){
        s+=a[j];
        if(j!=n-1)dp[j+1]=min(dp[j+1],dp[i]+abs(s-w));
        else dp[j+1]=min(dp[j+1],dp[i]+max(0,s-w));
      }
    }
    cout<<"Case "<<p++<<": "<<dp[n]<<endl;
  }
}

Measured memory_bytes: 3080
#include <stdio.h>

int main()
{
	long n,a,b;
	long num;

	scanf("%ld", &n);
	scanf("%ld", &a);
	scanf("%ld", &b);

	
	if ((b-a)%2 ==0) {
		num = (b-a)/2;
	}
	else {
		if (n -b > a-1) {
			num = a - 1;
			num++;
			
			b -= num;
			a = 1;
			num += (b - a) / 2;
		}
		else {
			num = n-b;
			num++;

			a += num;
			b = n;
			num += (b - a) / 2;

		}

		
	}
	

	printf("%ld", num);
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define mp(a, b) make_pair(a, b)
#define lowbit(x) (x & (-x))
#define ls (rt << 1)
#define rs (rt << 1 | 1)
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 100 + 10;
int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if(a == b && a != c)
	{
		puts("Yes"); 
		return 0;
	}
	if(a == c && a != b)
	{
		puts("Yes"); 
		return 0;
	}
	if(b == c && a != b)
	{
		puts("Yes"); 
		return 0;
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
const ll mod=1e9+7;

const int N=1e5+1;
ll n,m;
vector<ll> a[N],b[N],c[N],d[N];
map<ll,ll> pos;
ll dp[N][2][2], par[N];


ll dfs(ll v, ll color, ll already_black, ll p=-1){
    if(dp[v][color][already_black]!=-1)
        return dp[v][color][already_black];
    par[v]=p;
    ll ans=1;
    vector<ll> k;
    for(ll u: a[v]){
        if(u==p) continue;
        ll add=0;
        if(color==1)
            add=(dfs(u,0,1,v)+dfs(u,1,1,v))%m;
        else{
            if(already_black==0) add=dfs(u,1,1,v);
            add=(add+dfs(u,0,already_black,v))%m;
        }
        if(color==1){
            pos[u]=k.size();
            k.pb(add);
        }
        ans=(ans*add)%m;
    }
    int nk=k.size();
    if(color==1 && nk!=0){
        d[v].assign(nk,1);
        b[v].assign(nk,1);
        c[v].assign(nk,1);
        b[v][0]=k[0];
        for(int i=1;i<nk;i++)
            b[v][i]=(b[v][i-1]*k[i])%m;
        c[v][nk-1]=k[nk-1];
        for(int i=nk-2;i>=0;i--)
            c[v][i]=(c[v][i+1]*k[i])%m;
        d[v].assign(nk,1);
        if(nk>1) d[v][0]=c[v][1], d[v][nk-1]=b[v][nk-2];
        for(int i=1;i<nk-1;i++)
            d[v][i]=(b[v][i-1]*c[v][i+1])%m;
    }
    return dp[v][color][already_black]=ans;
}

void dfs1(ll v, ll prevmul, ll p=-1){
    ll mul;
    if(p==-1) mul=0;
    else mul=(d[p][pos[v]]*(prevmul+1))%m;
    dp[v][1][1]=(dp[v][1][1]*(mul+1))%m;
    for(ll u: a[v]){
        if(u==p) continue;
        dfs1(u,mul,v);
    }
}


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();
    
    cin>>n>>m;
    for(int i=0;i<n-1;i++){
        ll u,v;
        cin>>u>>v; u--,v--;
        a[u].pb(v);
        a[v].pb(u);
    }
    memset(dp,-1,sizeof(dp));
    dfs(0,1,1), dfs(0,0,0);
    ll prevmul=0;
    dfs1(0,0);
    cout<<dp[0][1][1]<<"\n";
    for(ll i=1;i<n;i++)
        cout<<dp[i][1][1]<<"\n";

    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}

Measured memory_bytes: 48300
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
int main() {
	long long int a, b, c,k;
	cin >> a >> b >> c>>k;
	if (k % 2 == 1) {
		cout << b - a << endl;
	}
	else {
		cout << a - b << endl;;
	}

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<bool> vb;

const int MAXN = 3005;

ll diff[MAXN][MAXN]={0};
ll A[MAXN];
int n;

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

    cin >> n;

    for(int i=0; i<n; i++)
        cin >> A[i];

    for(int i=n-1; i>=0; i--){
        for(int j=i; j<n; j++){
            diff[i][j] = max(A[i]-diff[i+1][j], A[j]-diff[i][j-1]);
        }
    }

    cout << diff[0][n-1] << '\n';

    return 0;
}



Measured memory_bytes: 49796
#include <iostream>
#include <map>
#include <string>

using namespace std; // std::map~, std::cout~とかを省略する為

int main() {
    map<string, int> dict; // 文字列と出現回数の辞書作成

    int n; cin >> n; // 下for文のループ回数
    for (string x; n--; dict[x]++) { // 辞書内の文字列xに対応する出現回数を+1する
        cin >> x; // 文字列 x 入力
    }
    cout << dict.size() << endl;
}

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

typedef long long ll;
#define rep(i, s, n) for(ll i=s;i<n;i++)
#define repeq(i,s,n) for(ll i=s;i<=n;i++)
#define MOD 10e9+7

void max_self(ll& a, ll b) { a=a>b?a:b; }
void min_self(ll& a, ll b) { a=a<b?a:b; }

using namespace std;

ll t, a, k;
ll temp;

int main() {
    cin >> t >> a >> k;

    ll temp_t = t;

    t = max(0LL, t-k);
    k = max(k-temp_t, 0LL);
    a = max(a-k, 0LL);

    cout << t << ' ' << a << endl;
    
    return 0;
}

Measured memory_bytes: 256
def prepare(n, mod, x)
  dp = Array.new(n, 1)
  return [0, 0, dp] if mod == 0
  score = 0
  (1 ... n).each do |i|
    dp[i] = (dp[i - 1] * 2) % mod
  end
  (1 .. n).each do |i|
    score += dp[n - i] if x[i - 1] == '1'
  end
  [mod, score, dp]
end

def f(x)
  for i in 0 .. 100
    return i if x == 0
    popcount = 32.times.count{|j| x[j] > 0 }
    x %= popcount
  end
end

N = gets.to_i
X = gets.chomp
popcount = X.count('1')
mod1, score1, dp1 = prepare(N, popcount + 1, X)
mod2, score2, dp2 = prepare(N, popcount - 1, X)

ans = (1 .. N).map do |i|
  if X[i - 1] == '0'
    f((score1 + dp1[N - i]) % mod1) + 1
  elsif popcount == 1
    0
  else
    f((score2 - dp2[N - i]) % mod2) + 1
  end
end
puts ans


Measured memory_bytes: 19688
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V) for (auto v : (V)) cout << v << " "
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template < class T > using vec = std::vector< T >;
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N,C;
  cin >> N>>C;
  vec<vec<int>>D(C,vec<int>(C));
  vec<vec<int>>a(3,vec<int>(C,0));
  vec<vec<int>>cost(3,vec<int>(C));
 // vec<vec<int>>c(N,vec<int>(N));
  REP(i,C){
    REP(j,C){
      cin>>D[i][j];
    }
  }
  REP(i,N){
    REP(j,N){
      int p;
      cin>>p;
      p--;
      a[(i+j+2)%3][p]++;
    }
  }
  //コスト計算
  REP(i,3){
    REP(j,C){
      int val=0;
      REP(k,C){
        val+=a[i][k]*D[k][j];
      }
      cost[i][j]=val;
    }
    //PRINTALL(cost[i]);
  }
  //print("\n");
  int minWrong=INF;
  REP(i,C){
    REP(j,C){
      if (i==j)continue;
      REP(k,C){
        if (j==k)continue;
        if (i==k)continue;
       // cout <<i<<" "<<j<<" "<<k<<" "<<"\n";
        chmin(minWrong,cost[0][i]+cost[1][j]+cost[2][k]);
      }
    }
  }
  print(minWrong);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/container/flat_map.hpp>

int main(){
    using namespace std;
    size_t N, M;
    cin >> N >> M;
    if(M & 1)return 0 & puts("-1");
    vector<vector<unsigned long>> edge(N);
    for(unsigned long i = 0, a, b; i < M; ++i){
        cin >> a >> b;
        edge[--a].push_back(--b);
        edge[b].push_back(a);
    }
    vector<unsigned long> b(N), vis(N), dep(N);
    unordered_set<unsigned long> st;
    [rec = [&b, &edge, &st, &vis, &dep](auto f, auto now, auto prev, auto d) -> unsigned long{
        vis[now] = 1;
        dep[now] = ++d;
        for(const auto& i : edge[now])if(vis[i]){
                if(dep[i] < d && i != prev){
                    b[now] ^= 1;
                    cout << now + 1 << " " << i + 1 << endl;
                }
            }else f(f, i, now, d);
        auto ret = b[now];
        if(now != prev){
            cout << (b[now] ? now : prev) + 1 << " " << (b[now] ? prev : now) + 1 << endl;
            (b[now] ? b[now] : b[prev]) ^= 1;
        }
        return ret;
    }](auto start){rec(rec, start, start, 0UL);}(0);
    for(const auto& i : b)assert(!i);
    return 0;
}

Measured memory_bytes: 22528
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
   string w;
   cin  >> w ;
   int n=w.size();
   set<char> chk;
   rep(i,n){
       if(chk.count(w.at(i))){
           chk.erase(w.at(i));
       }
       else{
           chk.insert(w.at(i));
       }
   }
   if(chk.size()==0)cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 3628
find _ [] = 0
find s r =
  let s' = take (length s) r
  in
    if s' == s
    then 1
    else find s (drop 1 r)

ans s r =
  let ls = length s
      lr = length r
      d  = take (ls+lr) $ cycle r
  in
    find s d

main = do
  s <- getLine
  _ <- getLine
  c <- getContents
  let i = lines c
      o = sum $ map (ans s) i
  print o



Measured memory_bytes: 3992
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(int i = 1 ; i <= 10000; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int t = 0;
			if(x > y) {
				t = x;
				x = y;
				y = t;
			}
			if(x == 0 && y == 0) {
				break;
			}
			System.out.println(x + " " + y);
		}
	}
}

Measured memory_bytes: 35012
#include<cstdio>
using namespace std;
typedef long long ll;

ll a, b, n, x, y, dp[20][20];

int main() {
  while (scanf("%lld%lld", &a, &b), a) {
    a--, b--;
    for (ll i = 0; i <= a; i++) for (ll j = 0; j <= b; j++) dp[i][j] = 0;
    dp[0][0] = 1;
    scanf("%lld", &n);
    for (ll i = 0; i < n; i++) scanf("%lld%lld", &x, &y), dp[x-1][y-1] = -1;
    for (ll i = 0; i <= a; i++) for (ll j = 0; j <= b; j++) {
      if (dp[i][j] == -1) {
        dp[i][j] = 0;
        continue;
      }
      if (i != 0) dp[i][j] += dp[i-1][j];
      if (j != 0) dp[i][j] += dp[i][j-1];
    }
    printf("%lld\n", dp[a][b]);
  }
}



Measured memory_bytes: 2656
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define IREP(i, v) for(auto i = (v).begin(); i != (v).end(); ++i)
#define IRREP(i, v) for(auto i = (v).rbegin(); i != (v).rend(); ++i)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const ll LINF = 1000000000000000000; // 1e18
const double EPS = 1E-10;

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


int main(){
    int n, m, d; cin >> n >> m >> d;
    double ans;
    if(d){
        ans = 2.0 * (m - 1) * (n - d) / n / n;
    }else{
        ans = (m - 1) / (double)n;
    }
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define ll long long

int main(void){
    int N;
    vector<int> color(3);
    cin>>color.at(0)>>color.at(1)>>color.at(2)>>N;
    sort(color.begin(),color.end());
    int ans=0;

    int maxi=N/color.at(2);
    for(int i=0;i<=maxi;i++){
        int M=N-i*color.at(2);
        int mid=M/color.at(1);
        for(int j=0;j<=mid;j++){
            int FINAL=M-j*color.at(1);
            if(FINAL%color.at(0)==0) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int h, w, K; cin >> h >> w >> K;
    vi ok(1 << (w-1), true);
    rep(i, 1 << (w-1)){
    	rep(j, w - 2){
    		if(((i >> j) & 1) and ((i >> (j+1)) & 1)){
    			ok[i] = false;
    			break;
    		}
    	}
    }

    vector<vll> dp(h + 1, vll(w));
    dp[0][0] = 1LL;

    rep(i, h){
    	rep(j, w){
    		int cur = dp[i][j];
    		if(cur == 0LL) continue;
    		rep(l, 1 << (w-1)){
    			if(not ok[l]) continue;
    			ll nj = j;
    			if(j >= 1 and ((l >> (j-1)) & 1)) nj = j - 1;
    			else if(j < w-1 and ((l >> j) & 1)) nj = j + 1;

    			ll& nxt = dp[i+1][nj];
    			nxt = ADD(nxt, cur, mod);
    		}
    	}
    }

    cout << dp[h][K-1] << endl;

    return 0;
}


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

int main(){
  int n;
  string s;
  cin >> n >> s;
  queue<char> data;
  for(int i = 0; i < s.size(); i++){
    data.push(s.at(i));
  }
  int count = 1;
  char a, b;
  for(int i = 0; i < s.size(); i++){
    if(i == 0){
      a = data.front();
      data.pop();
      continue;
    }
    b = data.front();
    if(a != b){
      count++;
      a = b;
      data.pop();
    }
    else{
      data.pop();
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<cmath>
#include<math.h>
using namespace std;

int main(){
	int a,b,C;
	cin>>a>>b>>C;
	double S=a*b/2*sin(C*M_PI/180);
	double L=a+b+sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(C*M_PI/180));
	double h=b*sin(C*M_PI/180);
	cout<<fixed;
	cout<<setprecision(5)<<S<<endl;
	cout<<setprecision(5)<<L<<endl;
	cout<<setprecision(5)<<h<<endl;
}


Measured memory_bytes: 3588
use std::io;


fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn check(num:&i64,A:i64,B:i64) -> bool {
    let n:Vec<i64> =num.to_string().split("").filter(|x|x != &"").map(|x|x.parse::<i64>().unwrap()).collect::<Vec<i64>>();
    let sum:i64 = n.iter().sum();
    if A <= sum && sum <= B {
        return true
    }else{
        return false
    }
}

fn main() {
    let s = read_line().split_whitespace().map(|x|x.parse::<i64>().unwrap()).collect::<Vec<i64>>();
    let N = s[0];
    let A = s[1];
    let B = s[2];
    
    let mut sum:i64 = 0;

    for i in 1..(N+1) {
        if check(&i,A,B) {
            sum+=i
        }
    }

    println!("{}",sum);
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define M 32769

int main(void){

  int i,j;
  int n;
  char a[M];
  int count;

  // a = (char *)malloc(sizeof(char)*M);

  for(i=2;i<M;i++)a[i] = 1;
  a[0]=0;
  a[1]=0;

  i=2;
  while(i<M){
    for(j=2*i;j<M;j+=i)a[j] = 0;
    while(!a[++i]);
  }

  while(1){
    scanf("%d",&n);
    if(n==0)break;
    count = 0;

    for(i=1;i<=n/2;i++)if(a[i] && a[n-i])count++;

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

  return 0;
}

Measured memory_bytes: 0
/*
* @Author: _dp95
* @Date:   2020-04-04 10:02:09
*/
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 22 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

int ar[MAX][MAX] ;
int n ;
unordered_map<int,int>dp ;

int sol( int mask ){
    int ind = bitcount( mask ) ;
    if( ind == n )
        return 1 ;
    if( dp.find(mask) != dp.end() )
        return dp[mask] ;
    int &ans = dp[mask] = 0 ;
    for( int i = 0 ; i < n ; i++ ){
        if( (mask&(1<<i)) or!(ar[ind][i] ) )
            continue ;
        ans += sol(mask|(1<<i)); 
        if( ans >= MOD )
            ans %= MOD ;
    }
    return ans ;
}

signed main( ){
  timesaver ;
  cin >> n ;
  for( int i = 0 ; i < n ; i++ )
    for( int j = 0 ; j < n ; j++ )
        cin >> ar[i][j] ;
  cout << sol( 0 ) << nl ;
}

Measured memory_bytes: 82512
#include <bits/stdc++.h>
using namespace std;
struct fastio { fastio () { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } _io;
template<class T, class U> bool chmax(T& a, const U &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> bool chmin(T& a, const U &b) { if (a > b) { a = b; return 1; } return 0; }

constexpr size_t D = 365;
constexpr size_t type = 26;
constexpr int INF = (1 << 30);

array<int, type> c, last;
array<array<int, type>, D> s;
array<int, D> contest;

void input () {
	int buff;
	cin >> buff;
	for (int i = 0; i < type; i++) {
		cin >> c[i];
		last[i] = 0;
	}
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < type; j++) {
			cin >> s[i][j];
		}
	}
	for (int i = 0; i < D; i++) {
		cin >> contest[i];
		contest[i]--;
	}
}

int score (int day, int idx) {
	int ans = s[day][idx];
	for (int i = 0; i < type; i++) {
		ans -= c[i] * (day + 1 - last[i]);
	}
	return ans;
}

int main() {
	input();
	int ans = 0;
	for (int i = 0; i < D; i++) {
		const int &id = contest[i];
		last[id] = i + 1;
		ans += score(i, id);
		cout << ans << '\n';
	}
	
	return 0;
}

Measured memory_bytes: 3624
class BIT():
    def __init__(self,n):
        self.BIT=[0]*(n+1)
        self.num=n

    def query(self,idx):
        res_sum = 0
        while idx > 0:
            res_sum += self.BIT[idx]
            idx -= idx&(-idx)
        return res_sum

    #Ai += x O(logN)
    def update(self,idx,x):
        while idx <= self.num:
            self.BIT[idx] += x
            idx += idx&(-idx)
        return

import sys

input=sys.stdin.readline

N,Q=map(int,input().split())
c=list(map(int,input().split()))
query=[]
for i in range(Q):
    l,r=map(int,input().split())
    query.append((l,r,i))

query.sort(key=lambda x:-x[1])
ans=[0]*Q
last=[0 for i in range(N)]
B=BIT(N)
for i in range(N):
    val=c[i]-1
    if last[val]!=0:
        B.update(last[val],-1)
    last[val]=i+1
    B.update(i+1,1)
    while query and query[-1][1]==i+1:
        l,r,id=query.pop()
        res=B.query(r)-B.query(l-1)
        ans[id]=res

for i in range(Q):
    print(ans[i])


Measured memory_bytes: 191028
/**< 🤣🤣🤣 */
#include<bits/stdc++.h>
using namespace  std ;
typedef long long  ll;
typedef pair<ll, ll> Pll;
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define deb(X) cout << (X) << endl
#define ASH(X) cout << (X) << " "
#define all(x) x.begin(),x.end()
#define deb1(x) cout << #x << " " << x << endl;
#define deb2(x,y) cout << #x << " " << x << " " << #y << " " << y << endl;
#define deb3(x,y,z) cout << #x << " " << x << " " << #y << " " << y << #z << " " << z << endl;
#define FOR(I,A,B) for(ll I = (A); I <= (B); I++)
#define RFOR(I,B,A) for(ll I = (B); I >=(A); I--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define SORT(c) (sort(c.begin(),c.end()))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASES int ___T; cin >> ___T; for(int cs=1;cs<=___T;cs++)
#define FAST()  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
template<typename T>T gcd(T x, T y){if(y==0)return x;else return gcd(y,x%y);}
ll fx[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll fy[] = {0, 1, 1, 1, 0, -1, -1, -1};
const ll INF = 1e18;
const int mod = 1e9+7;
const int inf = 1e9;
const int mx = 32000;
vector<ll>a1,b1,c1;
map<ll,ll>m1,m2,m3;
bool isPrime[mx];

ll POWER(ll y,ll z){ll res=1;while(z){if(z%2==1){res=(res*y)%mod;}y=(y*y)%mod;z>>=1LL;}return res;}
void sieve(){for(ll i=2; i<=mx; i++)isPrime[i]=true;for(ll i=3; i<=mx; i+=2){if(isPrime[i]==true)
{for(ll J=i*i; J<=mx; J+=i)isPrime[J]=false;}}}

/************************************************/

void Execute()
{
      ll n, nb, val, q, a, b, c, l, r, d, x, y, p, m;
      cin >> n;
      x = n;

      y = 1+n+(n*n);

      deb(x*y);

}

int32_t main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("atomm.txt", "r", stdin);
    //#endif

    FAST();
  //  CASES
  //  {
       Execute();
        //cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "sec \n";
  //  }
}
/**< 🤣🤣🤣 */


Measured memory_bytes: 3644
N, X, M = map(int, input().split())
D = [-1]*M
A = [X]
for i in range(M):
    if D[X]>=0: break
    D[X] = i
    X = X * X % M    
    A.append(X)

st = D[X]
loop = A[st:-1]

if N<=st:
    ans = sum(A[:N])
else:
    Nl = N-st
    ans = sum(A[:st]) + sum(loop)*(Nl//len(loop)) + sum(loop[:Nl%len(loop)])
print(ans)


Measured memory_bytes: 14084
"use strict";

const main = arg => {

    const input = arg.trim()
    const rev_input = input.split('').reverse().join('')

    const N = (input.length - 1) / 2

    const front_ss = input.substr(0, N);
    const rev_front_ss = front_ss.split('').reverse().join('')

    const back_ss = input.substr(N + 1, N);
    const rev_back_ss = back_ss.split('').reverse().join('')

    if (input == rev_input && front_ss == rev_front_ss && back_ss == rev_back_ss) {
        console.log("Yes");
    } else {
        console.log("No");
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29508
#include<stdio.h>
int main(){
  int i,d[40]={1,1,2};
  for(i=3;i<31;i++)d[i]=d[i-1]+d[i-2]+d[i-3];
  while(scanf("%d",&i),i)printf("%d\n",(d[i]-1)/3650+1);
  return 0;
}

Measured memory_bytes: 600
from collections import Counter # 重複個数のカウント: Counter(num_list)
import itertools

def main():
    n = int(input())
    str_list = [input()[0] for _ in range(n)]

    str_count = Counter(str_list)

    ans = 0

    seq = ['M', 'A', 'R', 'C', 'H']

    for l in list(itertools.combinations(seq,3)):
        ans += str_count[l[0]] * str_count[l[1]] * str_count[l[2]]

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 52440
def solve():
    mod = 10**9+7
    L = input()
    N = len(L)
    dp = [0]*2
    dp[0] = 1
    dp[1] = 2
    for i in range(1, N):
        if L[i]=='0':
            dp[0], dp[1]=dp[0]*3, dp[1]
        else:
            dp[0], dp[1]=dp[0]*3+dp[1], dp[1]*2
    print((dp[0]+dp[1])%mod)
solve()


Measured memory_bytes: 45916
N = int(input())
S = list(map(int, input().split()))
INF = float('inf')

S.sort()

parents = [S[-1]]
S[-1] = INF

for _ in range(N):
    checking = 2
    parents.sort(reverse=True)
    for i in parents[:]:
        while True:
            if S[-checking] < i:
                parents.append(S[-checking])
                S[-checking] = INF
                break
            else:
                checking += 1
            if checking == 2 ** N + 1:
                print('No')
                exit()
else:
    print('Yes')

Measured memory_bytes: 34408