akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 (a > b) { a = b; return 1; } return 0; }

char hand[100005];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    ll r, p, s;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    ll ans = 0;
    rep(i,n){
        if(t[i] == 'r'){
            if(i-k < 0 || hand[i-k] != 'p'){
                ans += p;
                hand[i] = 'p';
            }
            else hand[i] = '!';
        }
        else if(t[i] == 's'){
            if(i-k < 0 || hand[i-k] != 'r'){
                ans += r;
                hand[i] = 'r';
            }
            else hand[i] = '!';
        }
        else{
            if(i-k < 0 || hand[i-k] != 's'){
                ans += s;
                hand[i] = 's';
            }
            else hand[i] = '!';
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3864
n = int(input())
s = [int(input()) for i in range(n)]
s.sort()
if sum(s) % 10 != 0:
    print(sum(s))
else:
    for i in range(n):
        if s[i] % 10 != 0:
            print(sum(s)-s[i])
            exit()
    print(0)

Measured memory_bytes: 9124
#include<stdio.h>

void swap(int a[],int x,int y){
	int tmp;
	tmp=a[x];
	a[x]=a[y];
	a[y]=tmp;
	return;
}
int main(void){
	int w,n;
	int x[31],y[31],a[31];
	int i;

	for(i=0;i<31;i++){//ツ渉可甘コツ可サ
		x[i]=0;
		y[i]=0;
		a[i]=0;
	}
	scanf("%d",&w);
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d,%d",&x[i],&y[i]);
	}
	for(i=1;i<=w;i++){
		a[i]=i;
	}
	for(i=0;i<n;i++){
		swap(a,x[i],y[i]);
	}
	for(i=1;i<=w;i++)
		printf("%d\n",a[i]);

	return 0;
}

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

const int MAXN = 100001;
typedef long long ll;
#define f first
#define s second
const ll mod = 1e9+7;

vector<int> paths[MAXN];
ll dp[MAXN][2];

ll dfs(int cur, int par, int col){
    if (dp[cur][col]!=-1){
        return dp[cur][col];
    }
    ll res = 1, f = 0, temp;
    for (int i:paths[cur]){
        if (i==par) continue;
        temp = 0;
        f = 1;
        temp += dfs(i,cur,0);
        temp %= mod;
        if (!col){
            temp += dfs(i,cur,1);
            temp %= mod;
        }
        res = (res*temp)%mod;
    }
    if (!f) return dp[cur][col] = 1;
    return dp[cur][col] = res%mod;
}

int main(){
    memset(dp,-1,sizeof dp);
    int N,a,b;
    scanf("%d",&N);
    for (int i=0;i<N-1;i++){
        scanf("%d %d",&a,&b);
        a--;b--;
        paths[a].push_back(b);
        paths[b].push_back(a);
    }
    printf("%lld\n",(dfs(0,-1,0)+dfs(0,-1,1))%mod);
}

/*
3
1 2
2 3
*/

Measured memory_bytes: 15616
#include <stdio.h>

int main(void)
{
    int i, j;

    int n;
    scanf("%d", &n);

    float x[4], y[4];
    float slope1, slope2;

    for (i = 0; i < n; i++) {
        for (j = 0; j < 4; j++) {
            scanf("%f %f", &x[j], &y[j]);
        }
        slope1 = (y[1] - y[0]) / (x[1] - x[0]);
        slope2 = (y[3] - y[2]) / (x[3] - x[2]);

        if (slope1 == slope2) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }

    return (0);
}

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

using namespace std;
#define ll long long
#define db long double
#define all(a) a.begin(),a.end()
#define pb push_back
#define f(i,l,u) for(ll i=l;i<u;i++)
#define lb lower_bound
#define ub upper_bound
#define pii pair<ll,ll> 

unsigned long long fac[200001]; 
void powe(ll p)
{

    fac[0] = 1; 
    for (int i = 1; i <= 200001; i++) 
        fac[i] = (fac[i - 1] * i) % p; 

}

unsigned long long power(unsigned long long x, 
                         ll y, ll p) 
{ 
    unsigned long long res = 1; // Initialize result 
  
    x = x % p; // Update x if it is more than or 
    // equal to p 
  
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
unsigned long long modInverse(unsigned long long n, ll p) 
{ 
    return power(n, p - 2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
unsigned long long nCrModPFermat(unsigned long long n, 
                                 ll r, ll p) 
{ 
    // Base case 
    if (r == 0) 
        return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
  
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
} 
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    else
    return gcd(b,a%b);
}


int main() {
 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
ll t=1;
//cin>>t;
while(t--)
{

ll sum=0;

ll k;
cin>>k;
map<ll,ll> mp;

ll val=0;
ll flag=0;
ll temp;
if(k==7)

cout<<1;
else
{
    ll c=0;
    while(1)
    {
        c++;
val*=(10);
val%=k;
val+=(7)%k;
val%=k;
//cout<<"val = "<<val<<endl;
if(val==0) 
{
    flag=1;
    temp=c;
    break;
}
if(mp[val]==1)
{
    temp=-1;
    break;
}
mp[val]=1;
}
cout<<temp<<endl;
}
    
    
}




return 0;
}

Measured memory_bytes: 66088
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
// #include<unordered_map>
#include<set>
// #include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y, idx;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

template<typename T>
T minT(T a, T b) {
	if (a < b) return a;
	else return b;
}

template<typename T>
T maxT(T a, T b) {
	if (a > b) return a;
	else return b;
}

template<typename T>
T absT(T a) {
	if (a < 0) a *= -1;
	return a;
}

template<typename T>
T powT(T a, T x) {
	T res = 1;
	while (x > 0) {
		if (x & 1) res = res*a;
		a = a*a;
		x >>= 1;
	}
	return res;
}

ll StoLL(string str) {
	ll ret = 0, ini = 0;
	if (str[0] == '-') ini = 1;
	repi(i, ini, str.length()) {
		ret *= 10;
		ret += (ll)(str[i] - '0');
	}
	if (ini) ret *= -1;
	return ret;
}

///////////////////////////////////////////////////////////////////////////////////////

ll a[MAX_10p5 * 2], dp[MAX_10p5 * 2];
ll l, r, XOR, sum, ans;

int main() {
	ll N;
	cin >> N;
	repi(i, 0, N) {
		cin >> a[i];
	}

	XOR ^= a[r];
	sum += a[r];
	
	while (1) {
		if (r == N) {
			while (l < N - 1) {
				l++;
				dp[l] = dp[l - 1] - 1;
			}
			break;
		}
		if (XOR == sum) {
			dp[l]++;
			r++;
			XOR ^= a[r];
			sum += a[r];
		}
		else {
			XOR ^= a[l];
			sum -= a[l];
			l++;
			if (l > r) {
				r++;
				XOR ^= a[r];
				sum += a[r];
			}
			dp[l] = r - l;
		}
	}

	repi(i, 0, N) {
		ans += dp[i];
	}
	wrln(ans);

	return 0;
}


Measured memory_bytes: 3328
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var x = G;
		int N = x[0], X = x[1];
		x = G;
		var D = Abs(x[0] - X);
		foreach (var y in x.Skip(1)) D = GCD(D, y - X);
		WriteLine(D);
	}
	public static int GCD(int n, int m)
	{
		var a = Abs(n);
		var b = Abs(m);
		if (a < b) { var c = a; a = b; b = c; }
		while (b > 0)
		{
			var c = a % b;
			a = b;
			b = c;
		}
		return a;
	}
}


Measured memory_bytes: 21728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}


int main(){
	int a,b; cin >> a >> b;
	if(a <6) b=0;
	else if(a < 13) b/=2;
	cout << b << endl;
}

Measured memory_bytes: 3588
#include<cstdio>

int main(void){
    while(true){
        int n, x;
        int i, j, k;
        int ans = 0;

        scanf("%d %d", &n, &x);
        if(n == 0 && x == 0)    break;


        for(i = 1; i <= n; i++){
            for(j = i + 1; j <= n; j++){
                for(k = j + 1; k <= n; k++){
                    if(x == i + j + k){
                        ans++;
                    }
                }
            }
        }

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

    return 0;
}

Measured memory_bytes: 1028
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
          　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
    char c;
    str = "";
    scanf("%c", &c);
    if (c == '\n')scanf("%c", &c);
    while (c != '\n' && c != -1 && c != ' ') {
        str += c;
        scanf("%c", &c);
    }
}

void scanc(char& str) {
    char c;
    scanf("%c", &c);
    if (c == -1)return;
    while (c == '\n') {
        scanf("%c", &c);
    }
    str = c;
}

double acot(double x) {
    return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

    string s;
    scans(s);
    printf("%c%c%c\n", s[0], s[1], s[2]);

    Please AC;
}


Measured memory_bytes: 3800
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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 (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI A(N);
	REP(i, N)cin >> A[i];
	int ans = INF;

	eREP(i, 100) {
		int cnt = 0;
		REP(j, N) {
			cnt += (A[j] - i)*(A[j] - i);
		}
		chmin(ans, cnt);
	}



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



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

say = []
word = input()
say.append(word)
ans = 'Yes'

for i in range(n-1):
    word = input()
    if word in say:
        ans = 'No'

    elif word[0] != say[-1][-1]:
        ans = 'No'

    else:
        say.append(word)

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	while(cin>>n,n){
		string s[n];
		int num[n];
		rep(i,n)cin>>s[i];
		rep(i,n)num[i]=s[i].size();
		rep(i,n){
			int check=0,sum=0;
			for(int j=i;sum<=31;j++){
				sum+=num[j];
				if(sum==5)check|=1;
				else if(sum==12)check|=(1<<1);
				else if(sum==17)check|=(1<<2);
				else if(sum==24)check|=(1<<3);
				else if(sum==31)check|=(1<<4);
			}
			if(check==(31)){
				cout<<i+1<<endl;
				break;
			}
		}
	}
	return 0;

}

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

#define ll long long

using namespace std;

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

int main() {
	ll a, b;
	cin >> a >> b;
	cout << a * b / gcd(a, b) << endl;
	return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.par = [0] * n
        self.chi = [0] * n
        for i in range(n):
            self.par[i] = i
            self.chi[i] = 1
        self.max_child = 1
    def root(self, x):
        if self.par[x] == x:
            return x
        rx = self.root(self.par[x])
        self.par[x] = rx
        #if self.chi[x] < self.chi[rx]:
        #    self.chi[x] = self.chi[rx]
        return self.par[x]
    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return
        #print("rx = ", rx, "ry = ", ry)
        #print("self.chi[rx] = ", self.chi[rx])
        #print("self.chi[ry] = ", self.chi[ry])
        self.par[rx] = ry
        self.chi[ry] += self.chi[rx]
        if self.max_child < self.chi[ry]:
            self.max_child = self.chi[ry]
    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

n, m = map(int, input().split())

u = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    u.unite(a-1, b-1)
    #print("self.par[", a-1, "] = ", u.par[a-1])
    #print("self.par[", b-1, "] = ", u.par[b-1])
    #print("self.chi[", a-1, "] = ", u.chi[a-1])
    #print("self.chi[", b-1, "] = ", u.chi[b-1])
    

print(u.max_child)
#for i in range(n):
#    print(u.par[i])

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

int main() {
	int N, i, o, r;
	double x;
	o = 0;
	cin >> N;
	for (i = 1; i <= N;i++) {
		r = i % 2;
		if (r == 1) 
			o++;
		x = o / (double)N;
	}
	cout << fixed << setprecision(10)<< x << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

ll ans = INF;
int d, g;
int p[10] = { 0 }, c[10] = { 0 };
bool s[10] = { 0 };

void solve(ll i = 0, ll score = 0, ll subans = 0) {
	if (i == d) {
		ll rest = g - score;
		if (rest > 0) {
			for (int k = d - 1; k >= 0; k--) {
				ll pbp = 100 * (k+1);
				if (!s[k] && pbp*(p[k] - 1) >= rest) {
					if (rest%pbp == 0) {
						score = g;
						subans += rest / pbp;
					}
					else {
						score += pbp * (rest / pbp + 1);
						subans += rest / pbp + 1;
					}
					break;
				}
			}
		}

		if(score>=g)ans = min(subans, ans);
	}
	else {
		int subscore = score;
		score += 100 * (i + 1)*p[i] + c[i]; subans += p[i]; s[i] = true;
		solve(i + 1, score, subans);
		score = subscore; subans -= p[i]; s[i] = false;
		solve(i + 1, score, subans);
	}

	return;
}

int main() {

	cin >> d >> g;

	rep(i, 0, d) {
		cin >> p[i] >> c[i];
	}

	solve();

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

ll rep_pow(ll a, ll b){//繰り返し2乗法
    if(b==0) return 1;
    else if(b%2==0){
        ll memo = rep_pow(a, b/2);
        return memo*memo%mod;
    }else{
        return rep_pow(a, b-1)*a%mod;
    }
}

ll nCr(ll n, ll r){//mod逆元使ったnCr
    ll ret=1;
    rep(i,r){
        ret *= n-i;//分子
        ret %= mod;
        ret *=rep_pow(r-i, mod-2);//mod逆元によりr!で割ると同値
        ret %= mod;
    }
    return ret;
}
ll gcd(ll a, ll b){ if(b==0) return a; return gcd(b, a%b);}

int counter(int x){
    if(x==0) return 0;
    return counter(x>>1)+(x&1);
}


int main(){
    fast_io

    int n,k;
    cin>>n>>k;
    int ans=0;
    if(k==1) ans=0;
    else ans=n-k;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int  ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(n);
	LL mincap = LONG_MAX;
	rep(i, 0, 5)	mincap = min(mincap, scanLong());
	LL groups = (n / mincap) + (n%mincap != 0);
	LL ans = 5 + (groups - 1);
	pll(ans); nl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char c = sc.next().charAt(0);
        String alpabet = "abcdefghijklmnopqrstuvwxyz";
        ArrayList<Character> list = new ArrayList<>(26);
        for (int i = 0; i < 26; i++) {
            list.add(alpabet.charAt(i));
        }
        System.out.println(list.get(list.indexOf(c) + 1));
        sc.close();
    }

}


Measured memory_bytes: 35468
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <cstring>

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

using namespace std;
typedef long long ll;


int main(){
    int N,K;
    cin>>N>>K;
    int P[N];
    ll C[N];
    rep(i,N){cin>>P[i];--P[i];}
    //rep(i,N){cout<<P[i]<<" ";}
    cout<<endl;
    rep(i,N){cin>>C[i];}
    //rep(i,N){cout<<C[i]<<" ";}
    cout<<endl;
    
    ll ans=-1e18;
    rep(sz,N){
        int np=P[sz];
        ll tot=C[np];
        vector<int> s;
        s.push_back(np);
        while(1){
            np=P[np];
            tot+=C[np];
            s.push_back(np);
            if(np==sz){
                break;
            }
        }
        
      
        size_t n=s.size();
        ll t=0;
        rep(i,n){
           
            t+=C[s[i]];
            
            
            if(i+1>K)break;
            ll now=t;
            //cout<<"tot:"<<tot<<endl;
            if(tot>0){
                ll e=(K-(i+1))/n;
                now+=e*tot;
                
            }
             ans=max(ans,now);
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;

struct mov{
    int x, y;
    int to_x, to_y;
};

int main(){
    int H, W;
    int a[500][500];
    vector<mov> ans;
    int cnt = 0;
    cin >> H >> W;
    for(int i = 0; i <H; i++){
        for(int j = 0; j < W; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i <H; i++){
        if(i%2 == 0){
            for(int j = 0; j < W-1; j++){
                if(a[i][j]%2 == 1){
                    ans.push_back((mov){i, j, i, j+1});
                    a[i][j+1]++;
                }
            }
            if(i != H-1){
                if(a[i][W-1]%2 == 1){
                    ans.push_back((mov){i, W-1, i+1, W-1});
                    a[i+1][W-1]++;
                }
            }
        }else{
            for(int j = W-1; j > 0; j--){
                if(a[i][j]%2 == 1){
                    ans.push_back((mov){i, j, i, j-1});
                    a[i][j-1]++;
                }
            }
            if(i != H-1){
                if(a[i][0]%2 == 1){
                    ans.push_back((mov){i, 0, i+1, 0});
                    a[i+1][0]++;
                }
            }
        }
    }
    cout << ans.size() << endl;
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i].x+1 << ' ' << ans[i].y+1 << ' ' << ans[i].to_x+1 << ' ' << ans[i].to_y+1 << endl;
    }
}

Measured memory_bytes: 5104
#include <iostream>
#include <string>

#define MAX 101
#define WIN 3
#define DROW 1

using namespace std;

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

  string T; // Taro
  string H; // Hanako
  int T_point = 0;
  int H_point = 0;

  for(int i=0; i<N; ++i){
    cin >> T >> H;

    if(T.compare(H) == 0){ // same
      T_point += DROW;
      H_point += DROW;
    }
    else if(T.compare(H) > 0){
      T_point += WIN;
    }
    else H_point += WIN;
  }

  cout << T_point << " " << H_point << endl;
  return 0;
}


Measured memory_bytes: 3164
const fs = require('fs')
const cin = fs.readFileSync('/dev/stdin', 'utf8');



var a = [];
for (var i = 0; i < cin.length; ++i){
    switch(cin[i]){
        case '0':
            a.push('0'); break;
        case '1':
            a.push('1'); break;
        case 'B':
            if (a.length > 0)
                a.pop();
            break;
    }
}
console.log(a.join(''));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
int n,a[10005];
double s;
double av;
int main()
{
    while (0<1)
    {
        n=s=0;
        scanf("%d",&n);
        if (n==0) return 0;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            s+=a[i];
        }
        av=(double)s/n;
        s=0;
        for(int i=1;i<=n;i++)
            s+=(a[i]-av)*(a[i]-av);
        double p=(double)s/n;
        printf("%f\n",sqrt(p));
    }
}



Measured memory_bytes: 3236
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.HashSet;
import java.util.Set;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int n = Integer.parseInt(reader.readLine());
        for (int i = 0; i < n; i++) {
            String line = reader.readLine();
            Set<String> fours = new HashSet<String>();
            for (String word : line.split(" ")) {
                if (word.length() == 4) {
                    fours.add(word);
                }
            }
            for (int a : alphas) {
                for (int b = 0; b < 26; b++) {
                    if (fours.contains(encode("that", a, b))
                            || fours.contains(encode("this", a, b))) {
                        out.println(decode(line, a, b));
                        break;
                    }
                }
            }
        }
    }

    private static final String encode(String s, int a, int b) {
        StringBuilder sb = new StringBuilder();
        for (char ch : s.toCharArray()) {
            if (ch >= 'a' && ch <= 'z') {
                sb.append((char) ((a * (ch - 'a') + b) % 26 + 'a'));
            } else {
                sb.append(ch);
            }
        }
        return sb.toString();
    }

    private static final String decode(String s, int a, int b) {
        StringBuilder sb = new StringBuilder();
        for (char ch : s.toCharArray()) {
            if (ch >= 'a' && ch <= 'z') {
                int x = ((ch - 'a') - b + 26) % 26;
                while (x % a != 0) {
                    x += 26;
                }
                sb.append((char) (x / a + 'a'));
            } else {
                sb.append(ch);
            }
        }
        return sb.toString();
    }

    private static final int[] alphas = { 1, 3, 5, 7, 9, 11, 15, 17, 19, 21,
            23, 25 };
}

Measured memory_bytes: 10000
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

class UnionFind {
  public:
    UnionFind(ll n) {
      rank.resize(n);
      parent.resize(n);
      sizes.resize(n);
      for (ll i=0; i<n; i++) rank[i] = 0, parent[i] = i, sizes[i] = 1;
    }

    bool same(ll x, ll y) {
      return root(x) == root(y);
    }

    void unite(ll x, ll y) {
      x = root(x), y = root(y);
      if (x == y) return;
      if (rank[x] < rank[y]) swap(x, y);
      else if (rank[x] == rank[y]) rank[x]++;
      parent[y] = x;
      sizes.at(x) += sizes.at(y);
    }

    long long size(ll x) {
      return sizes.at(root(x));
    }

  private:
    vector<ll> rank;
    vector<ll> parent;
    vector<long long> sizes;

    ll root(ll x) {
      if (x != parent[x]) {
        parent[x] = root(parent[x]);
      }

      return parent[x];
    }
};

template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
int main() {
  int n,m; cin >> n >> m;
  UnionFind uf(n);
  loop(i,0,m) {
    int a,b; cin >> a >> b;
    a--;b--;
    uf.unite(a, b);
  }

  ll ans = 0;
  loop(i,0,n) {
    chmax(ans, uf.size(i));
  }
  cout << ans << endl;

  return 0;
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int a = ri() - 1, b = ri() - 1, c = ri() - 1, d = ri() - 1;
	std::string s;
	std::cin >> s;
	
	if (c == d) {
		std::cout << "No" << std::endl;
		return 0;
	} else if (c < d) {
		bool res = true;
		for (int i = a; i < d; i++) if (s[i] == '#' && s[i + 1] == '#') {
			res = false;
			break;
		}
		if (res) std::cout << "Yes" << std::endl;
		else std::cout << "No" << std::endl;
	} else {
		bool res = false;
		for (int i = b; i <= d; i++) {
			if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
				res = true;
				break;
			}
		}
		for (int i = a; i < c; i++) if (s[i] == '#' && s[i + 1] == '#') {
			res = false;
			break;
		}
		if (res) std::cout << "Yes" << std::endl;
		else std::cout << "No" << std::endl;
		
	}
	
	return 0;
}


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

#define pb push_back
#define fi first
#define SZ(x) (int((x).size()))
#define se second
#define ll long long
#define pq priority_queue
#define MP make_pair
#define pii pair<int,int>
#define mod 998244353
#define inf 0x3f3f3f3f
#define debug(x) cerr<<#x<<"="<<x<<'\n'
#define rep(i, a, b) for (int i=a; i<(b); i++)

const int maxn=2e5+10;

int n;
int a[maxn];
map<int,int>mp;

int main(){
    std::ios::sync_with_stdio(false);
    cin>>n;
    rep(i,0,n) cin>>a[i];
    ll ans=0;
    rep(i,0,n) {
    	ans+=(ll)mp[i-a[i]];
    	mp[i+a[i]]++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 21368
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();
		int X = 0;
		int Y = 0;

			if (A >= B) {
				X = A;
				if (A-1 >= B) {
					Y = A-1;
				}else {
					Y = B;
				}
			} else if (A < B) {
				X = B;
				if (B-1 >= A) {
					Y = B-1;
				}else {
					Y = A;
				}
			}
		System.out.println(X+Y);
	}
}

Measured memory_bytes: 23124
#include <stdio.h>

int main(void){
    int a,b,n,count = 0,check;
    scanf("%d %d %d",&n,&a,&b);
    for (int i = 0; i < n + 1; ++i) {
        check = 0;
        check += ((i/10000)%10);
        check += ((i/1000)%10);
        check += ((i/100)%10);
        check += ((i/10)%10);
        check += ((i/1)%10);
        if (a <= check && b >= check)count += i;
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 1704
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;


main()
{
  bool used[8] = {0};
  int cnt = 0;
  int n;

  cin >> n;

  while( n-- ) {
    int a; cin >> a;    
    if( 1 <= a && a <= 399 ) used[0] = true;
    else if( 400 <= a && a <= 799 ) used[1] = true;
    else if( 800 <= a && a <= 1199 ) used[2] = true;
    else if( 1200 <= a && a <= 1599 ) used[3] = true;
    else if( 1600 <= a && a <= 1999 ) used[4] = true;
    else if( 2000 <= a && a <= 2399 ) used[5] = true;
    else if( 2400 <= a && a <= 2799 ) used[6] = true;
    else if( 2800 <= a && a <= 3199 ) used[7] = true;
    else cnt++;
  }

  int ans = 0;
  Rep(i, 8) if( used[i] ) ans++;

  if( cnt ) {
    if( !used[7] ) {
      cout << ans + 1 << " ";
    } else {
      cout << ans << " ";
    }
  } else {
    cout << ans << " ";
  }


  ans = 0;
  Rep(i, 8) if( used[i] ) ans++;

  cout << ans + cnt << endl;
}


Measured memory_bytes: 256
from decimal import *
A, B = input().split()
A = Decimal(A)
B = Decimal(B)
print((A * B) * Decimal(100) // Decimal(100))

# A = 10**15
# B = 9.99
# for i in range(0, 10):
#     # _B = i / 100
#     _B = Decimal(i) / Decimal(100)
#     print('_B', _B)
#     print(A * _B, int(A * _B))

#     print('Decimal', Decimal(10**15) * _B)


Measured memory_bytes: 9876
import java.util.*;
import java.io.*;

class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    int[][] c = new int[10][10];
    for(int i = 0; i < 10; i++) {
      for(int j = 0; j < 10; j++) {
        c[i][j] = sc.nextInt();
      } 
    }
    int[][] paths = new int[10][10];
    for(int i = 0; i < 10; i++) {
      for(int j = 0; j < 10; j++) {
        paths[i][j] = c[i][j];
      }
    }
    for(int k = 0; k < 10; k++) {
      for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
          paths[i][j] = Math.min(paths[i][j], paths[i][k]+paths[k][j]);
        }
      }
    }
    
    int sum = 0;
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
        int curr = sc.nextInt();
        if(curr != -1 && curr != 1){
          sum += paths[curr][1];
        }
      }
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 44252
#include<bits/stdc++.h>
#define MAXN 100005
using namespace std;
int k,a[MAXN];
int main()
{
    scanf("%d",&k);
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&a[i]);
    }

    long long remmin=2,remmax=2;
    for(int i=k;i>=1&&remmin<=remmax;i--)
    {
        if(remmin%a[i]==0)
        {
            remmin=remmin;
        }
        else
        {
            remmin=remmin/a[i]*a[i]+a[i];
        }
        remmax=(remmax/a[i]+1)*a[i]-1;
    }
    if(remmin<=remmax)
    {
        printf("%lld %lld\n",remmin,remmax);
    }
    else
    {
        printf("-1\n");
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600
#define MOD 1000000007

int main(){
  int n;
  cin>>n;
  vector<int> vec(n);
  rep(i,n) cin>>vec[i];

  vector<long> a(n, 0);
  a[0]=1;
  long cnt=1;
  repl(i,1,n){
    a[i] = (cnt+1)*(a[i-1])%MOD;
    if(vec[i]>=2*cnt+1) cnt++;
  }
  cout << a[n-1] << endl;

  return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		double A=(double)a;
		double B=(double)b;
		System.out.printf("%d %d %f",a/b,a%b,A/B);
		
	}
}


Measured memory_bytes: 26424
/*
 * @Author: Kaizyn
 * @Date: 2020-04-04 20:42:22
 * @LastEditTime: 2020-04-04 20:46:22
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const int N = 1e2+7;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;

int n, m;
int a[N];

inline void solve()
{
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    int sum = 0, cnt = 0;
    for (int i = 1; i <= n; ++i) sum += a[i];
    sum = (sum+4*m-1)/(4*m);
    for (int i = 1; i <= n; ++i) {
        if (a[i] >= sum) ++cnt;
    }
    cout << (cnt >= m ? "Yes" : "No") << endl;
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int testcase = 1;
    // cin >> testcase;
    for (int i = 1; i <= testcase; ++i) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

d = [[10**10]*N for _ in range(N)]

m = {}

for _ in range(M):
    a, b, c = map(int, input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c
    m[(a-1, b-1)] = c

for k in range(N):
    for i in range(N):
        for j in range(N):
            if d[i][k] + d[k][j] < d[i][j]:
                d[i][j] = d[i][k] + d[k][j]

ans = 0

for e in m:
    a, b = e
    if d[a][b] < m[e]:
        ans += 1

print(ans)

Measured memory_bytes: 41964
n, x = [int(x) for x in input().split()]

boxes = [int(x) for x in input().split()]

index = 0
count = 0

while index < len(boxes):
    if boxes[index] == x:
        if index + 1 < len(boxes):
            count += boxes[index + 1]
            boxes[index + 1] = 0
        index += 2
    elif boxes[index] > x:
        count += boxes[index] - x
        boxes[index] = x
        if index + 1 < len(boxes):
            count += boxes[index + 1]
            boxes[index + 1] = 0
        index += 2
    else:
        if index + 1 < len(boxes):
            if boxes[index] + boxes[index + 1] > x:
                diff = boxes[index] + boxes[index + 1] - x
                boxes[index + 1] = boxes[index + 1] - diff
                count += diff
        index += 1
print(count)


Measured memory_bytes: 14468
import java.util.*;

public class Main {

    static int MOD = 1000000007;
    public static void main(String[] args) {

        long ans=0;
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        ArrayList<Long> nums = new ArrayList<>();
        for(int i=0;i<Math.pow(2,s.length()-1);i++){
            boolean[] bit = new boolean[s.length()-1];
            int temp = i;
            for(int j=0;j<s.length()-1;j++){
                bit[j]=temp%2==1;
                temp=temp>>1;
            }

            String num = ""+s.charAt(0);
            for(int j=0;j<s.length()-1;j++){
                if(bit[j]){
                    nums.add(Long.parseLong(num));
                    //System.out.print(num+" ");
                    num=""+s.charAt(j+1);
                }else{
                    num+=s.charAt(j+1);
                }
            }
            nums.add(Long.parseLong(num));
            //System.out.println();
        }

        for(Long k:nums){
            //System.out.println(ans);
            ans+=k;
        }


        System.out.println(ans);
    }

}


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

int getSignal( char a )
{
    if( a == '1' )
        return 5;
    else if( a == '7' || a == '9' )
        return 8;
    else
        return 6;
}

int main()
{
    string s;
    char a[10][8] = { {}, {'\'',',','.','!','?'}, {'a','b','c','A','B','C'}, {'d','e','f','D','E','F'}, {'g','h','i','G','H','I'},
                        {'j','k','l','J','K','L'}, {'m','n','o','M','N','O'}, {'p','q','r','s','P','Q','R','S'}, 
                        {'t','u','v','T','U','V'}, {'w','x','y','z','W','X','Y','Z'} };

    while( cin >> s )
    {
        string str = "";
        for( int i = 0; i < s.size(); i++ )
        {
            str += s[i];
            if( s[i] != s[i+1] && s[i] != '0' )
                str += '0';
        }
        s = str;

        int target = -1, zero = 0;
        for( int i = 0; i < s.size(); i++ )
        {
            if( s[i] == '0' )
            {
                if( target != -1 )
                    cout << a[s[i-1]-'0'][target];
                
                int space = 0, j = i + 1;
                while( s[j] == '0' )
                {
                    space++;
                    j++;
                    i++;
                }
                for( int k = 0; k < space - 1; k++ )
                    cout << " ";
                target = -1;
            }
            else
                target = ( target + 1 ) % getSignal(s[i]);
        }
        cout << endl;
    }
    return 0;
}


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

int main() {
  vector<int> v(3);
  for (int i = 0; i < 3; i++) cin >> v[i];

  sort(v.begin(), v.end());
  cout << v[2] * 10 + v[1] + v[0] << endl;
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    
    for l in buf.lines() {
        let s: Vec<&str> = l.split(' ').collect();
        let a: i32 = s[0].parse().unwrap();
        let b: i32 = s[1].parse().unwrap();
        let c: i32 = s[2].parse().unwrap();
        
        let d = divisors(a, b, c);
        println!("{}", d);
    }
}

fn divisors(a: i32, b: i32, c: i32) -> i32 {
    let mut len = 0;
    for i in a..(b+1) {
        if c % i == 0 {
            len += 1;
        }
    }
    len
}


Measured memory_bytes: 5032
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
struct UnionFind{
    vector<int> par;
    vector<int> dep;
    
    UnionFind(int siz){
        par.assign(siz,0);
        dep.assign(siz,0);
        for(int i=0;i<siz;i++){
            par[i]=i;
        }
    };

    int find(int x){
        if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
    }

    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y){
            return;
        }
        if(dep[x]<dep[y]){
            par[x]=y;
        }else{
            par[y]=x;
            if(dep[x]==dep[y]){
                dep[x]++;
            }
        }
    }

    bool same(int x,int y){
        return find(x)==find(y);
    }
};
struct edge{int from,to;ll cost;};

bool comp(const edge& e1,const edge& e2){
	return e1.cost<e2.cost;
}

struct edge2{int to;ll cost;};
vector<edge2> G[4010];

edge es[400010];
ll s[4010][4010];
void dfs(int now,int p,int st,ll ma){
	for(auto e:G[now]){
		if(e.to==p)continue;
		s[st][e.to]=max(ma,e.cost);
		dfs(e.to,now,st,max(ma,e.cost));
	}
}
	
int main(){
	int n,m,q;cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b,c;cin>>a>>b>>c;a--;b--;
		es[i]={a,b,c};
	}
	sort(es,es+m,comp);
	UnionFind uf(n+1);
	ll ans=0;
	for(int i=0;i<m;i++){
		edge e=es[i];
		if(!uf.same(e.from,e.to)){
			uf.unite(e.from,e.to);
			G[e.from].push_back({e.to,e.cost});
			G[e.to].push_back({e.from,e.cost});
			ans+=e.cost;
		}
	}
	for(int i=0;i<n;i++){
		dfs(i,-1,i,0);
	}
	cin>>q;
	while(q--){
		int a,b;cin>>a>>b;a--;b--;
		cout<<ans-s[a][b]<<endl;
	}
		
    return 0;
}


Measured memory_bytes: 133632
# ARC069D - Menagerie (ABC055D)
def check(a: int, b: int) -> list:
    ret, cur, prev = [], a, b
    for i in S:
        ret += [cur]
        if cur ^ (i == "o"):
            prev, cur = cur, prev ^ 1  # both neighbors are different
        else:
            prev, cur = cur, prev  # both are the same
    flg = cur == a and prev == b  # check the consistency of input and result
    return ret if flg else []


def main():
    global S
    N = int(input())
    S = input().rstrip()
    for a in range(2):
        for b in range(2):
            ans = check(a, b)
            if ans:
                print("".join("S" if i else "W" for i in ans), sep="")
                return
    print(-1)


if __name__ == "__main__":
    main()

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
constexpr long long MOD(long long in) {
	return in % mod;
}

int n;
ll a[100005], l;
int main()
{
	std::cin >> n >> l;

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

	bool ok = false;
	int w = 0;
	for (int i = 0; i < n - 1; i++)
		if (a[i] + a[i + 1] >= l) {
			ok = true;
			w = i;
			break;
		}

	if (ok) {
		std::cout << "Possible" << std::endl;

		w++;
		for (int i = 1; i < w; i++)
			std::cout << i << std::endl;
		for (int i = n - 1; i > w; i--)
			std::cout << i << std::endl;
		std::cout << w << std::endl;
	}
	else
		std::cout << "Impossible" << std::endl;
	return 0;
}


Measured memory_bytes: 1536
import java.io.*;

public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true){
            String[] str = br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[2]);
            if(str[1].equals("?")){
                break;
            }else if( str[1].equals("+") ){
                System.out.println(a + b);

            }else if( str[1].equals("-") ){
                System.out.println(a - b);

            }else if( str[1].equals("*") ){
                System.out.println(a * b);

            }else if( str[1].equals("/") ){
                System.out.println(a / b);
            }
        }



    }
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int mod = 1e9+7;

long long binpow(long long b, long long e) {
  if (!e) return 1;
  if (e&1) return b*binpow(b, e-1)%mod;
  return binpow(b*b%mod, e/2);
}

void solve() {
  long long n; scanf("%lld", &n);
  printf("%lld", (binpow(10, n)-binpow(9, n)*2%mod+binpow(8, n) + mod) % mod);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3820
using System;
using System.Linq;
using System.Text;

public class AtCoder_158_D
{
    public static void Main()
    {
        string s = Console.ReadLine();
        int q = int.Parse(Console.ReadLine());

        StringBuilder fsb = new StringBuilder();
        StringBuilder bsb = new StringBuilder();

        bool isReverse = false;
        bsb.Append(s);

        for (int i = 0; i < q; i++)
        {
            string[] query = Console.ReadLine().Split(' ').ToArray();
            if (query[0] == "1")
            {
                isReverse = !isReverse;
                continue;
            }
            // 先頭に追加
            if (query[1] == "1")
            {
                if (isReverse)
                {
                    bsb.Append(query[2]);
                }
                else
                {
                    fsb.Append(query[2]);
                }
                continue;
            }
            // 末尾に追加
            if (isReverse)
            {
                fsb.Append(query[2]);
            }
            else
            {
                bsb.Append(query[2]);
            }
        }

        if (isReverse)
        {
            Console.Write(Reverse(bsb.ToString()));
            Console.WriteLine(fsb.ToString());
        }
        else
        {
            Console.Write(Reverse(fsb.ToString()));
            Console.WriteLine(bsb.ToString());
        }
    }

    public static string Reverse( string s )
    {
        char[] charArray = s.ToCharArray();
        Array.Reverse( charArray );
        return new string( charArray );
    }
}


Measured memory_bytes: 17832