akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Some Sums
            var line = ReadLine();
            int n = line[0];
            int a = line[1];
            int b = line[2];
            int sum = 0;

            for(int i = 1; i <= n; i++)
            {
                int digits = CalcDigitsSum(i);

                if (digits >= a && digits <= b)
                {
                    sum += i;
                }
            }

            Console.WriteLine(sum);
        }

        static int CalcDigitsSum(int n)
        {
            string s = n.ToString();
            int sum = 0;

            for(int i = 0; i < s.Length; i++)
            {
                var substring = s.Substring(i, 1);
                sum += int.Parse(substring);
            }

            return sum;
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

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

using namespace std;

#define ll 			long long
#define db			double
#define up(i,j,n)		for (int i = j; i <= n; i++)
#define down(i,j,n)	for (int i = j; i >= n; i--)
#define cadd(a,b)		a = add (a, b)
#define cpop(a,b)		a = pop (a, b)
#define cmul(a,b)		a = mul (a, b)
#define pr			pair<int, int>
#define fi			first
#define se			second
#define SZ(x)		(int)x.size()
#define bin(i)		(1 << (i))
#define Auto(i,node)	for (int i = LINK[node]; i; i = e[i].next)

template<typename T> inline bool cmax(T & x, T y){return y > x ? x = y, true : false;}
template<typename T> inline bool cmin(T & x, T y){return y < x ? x = y, true : false;}

const int MAXN = 2e5 + 5;

int N, c[MAXN];
char s[MAXN];
ll ans = 0;
deque<int> pos[26];
bool vis[MAXN];

inline int lowbit(int i){return i & (-i);}

void cg(int o, int v){
	for (int i = o; i <= N; i += lowbit(i)) c[i] += v;
}

int get(int o){
	int sum = 0;
	for (int i = o; i >= 1; i -= lowbit(i)) sum += c[i];
	return sum;
}

int main(){
	scanf("%s", s + 1);
	N = strlen(s + 1);
	up (i, 1, N) pos[s[i] - 'a'].push_back(i);
	int un = 0;
	up (i, 0, 25) if (SZ(pos[i]) % 2) un++;
	if (un > 1) {
		puts("-1");
		return 0;
	}
	int n = N >> 1, cur = 1, m = 0, key = -1;
	while (cur <= N && n--) {
		if (vis[cur]) {
			cur++;
			n++;
			continue;
		}
		m++;
		int le = cur, ri = pos[s[le] - 'a'].back(); pos[s[le] - 'a'].pop_back();
		int d = get(ri);
		if (le == ri) {
			key = m;
			cur++;
			n++;
			m--;
			continue;
		}
		ans += N - m + 1 - (ri - d);
		vis[le] = vis[ri] = 1;
		cg(ri, 1);
	}
	if (key != -1) {
		int mi = (N + 1) >> 1;
		ans += abs(mi - key);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define sz(x) ((int) x.size())
#define rd(type, ...) type __VA_ARGS__; sc(__VA_ARGS__)
#define rdv(type, v, n) vector<type> v(n); rep(__ii, 0, n) cin >> v[__ii]
#define rdm(type, v, h, w) vector<vector<type>>(h, vector<type>(w)) v; rep(__ii, 0, h) rep(__jj, 0, w) cin >> v[__ii][__jj]
#define min_value(type) numeric_limits<type>::min()
#define max_value(type) numeric_limits<type>::max()
typedef long long ll;
void solve();
signed main() {ios::sync_with_stdio(false); cin.tie(0);
  cout << fixed; cout.precision(12); solve(); return 0;}
template<typename T> void prv(vector<T> v) {rep(__ii, 0, sz(v)) {if (__ii) cout << ' '; cout << v[__ii];} cout << '\n';} 
template<typename T> void prm(vector<vector<T>> v) {rep(__ii, 0, sz(v)) {rep(__jj, 0, v[__ii].size()) {if (__jj) cout << ' '; cout << v[__ii][__jj];} cout << '\n';}}
template<typename T> void sc(T& x) {cin >> x;}
template<typename Head, typename... Tail> void sc(Head& head, Tail&... tail) {cin >> head; sc(tail...);}
template<typename T> void pr(const T& x) {cout << x << '\n';}
template<typename Head, typename... Tail> void pr(const Head& head, const Tail&... tail) {cout << head << ' '; pr(tail...);}
template<typename... T> void err(const T&... cod) {pr(cod...); exit(0);}

void solve() {
  rd(int, a, b);
  if (a > b) swap(a, b);
  int k = (a + b) / 2;
  if (b - k != k - a) err("IMPOSSIBLE");
  pr(k);
}

Measured memory_bytes: 892
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int x=sc.nextInt();
    int y=sc.nextInt();
    while(true){
      if(x>y){
        while(x>y) x=x-y;
      }else if(x<y){
        while(y>x) y=y-x;
      }else{
        break;
      }
    }
    System.out.println(x);
  }
}



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

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            string read = Console.ReadLine();
            int A1 = int.Parse(read.Split(' ')[0]);
            int B1 = int.Parse(read.Split(' ')[1]);
            int C1 = int.Parse(read.Split(' ')[2]);

            int A = Math.Min(A1, Math.Min(B1, C1));
            int C = Math.Max(A1, Math.Max(B1, C1));
            int B = A1 + B1 + C1 - A - C;
            int output = 0;

            if ((C - A) % 2 == 0)
            {
                output = (C - A) / 2;
                if ((C - B) % 2 == 0)
                {
                    output += (C - B) / 2;
                }
                else
                {
                    output += (C - B) / 2 + 2;
                }
            }
            else
            {
                output = (C - A) / 2;
                if ((C - B) % 2 == 0)
                {
                    output += (C - B) / 2 + 2;
                }
                else
                {
                    output += (C - 1 - B) / 2 + 1;
                }
            }
            Console.WriteLine(output);
        }

    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

int gcd(int x,int y){
    if(y == 0) return x;
    return gcd(y,x%y);
}

signed main() {
  int N, X; 
  cin >> N >> X;

  cout << (N-gcd(N, X))*3 << endl;


  return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> x(n);
	vector<int> y(n);
	for (int i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> y[i];
	}

	long double p1 = 0;
	for (int i = 0; i < n; i++)
	{
		p1 += fabs(x[i] - y[i]);
	}
	cout << fixed << p1 << endl;

	long double p2 = 0;
	for (int i = 0; i < n; i++)
	{
		p2 += pow(fabs(x[i] - y[i]), 2);
	}
	p2 = sqrt(p2);
	cout << fixed << p2 << endl;

	long double p3 = 0;
	for (int i = 0; i < n; i++)
	{
		p3 += pow(fabs(x[i] - y[i]), 3);
	}
	p3 = pow(p3, 1.0/3);
	cout << fixed << p3 << endl;

	vector<long double > dist(n);
	for (int i = 0; i < n; i++)
	{
		dist[i] = fabs(x[i] - y[i]);
	}

	long double maxele = *max_element(dist.begin(), dist.end());

	cout << maxele << endl;

	return 0;
}

Measured memory_bytes: 3596
import sys
import numpy as np

def input():
	return sys.stdin.readline().rstrip()
def main():
	N, D = (map(int, input().split()))
	if N % (D * 2 + 1) == 0:
		ans = 0
	else:
		ans = 1
	ans = ans + N//(D * 2 + 1)
	print(ans)
if __name__ == '__main__':
	main()

Measured memory_bytes: 21516
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
//DEBUG 
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define all(v) (v).begin(), (v).end()
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define pb push_back
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 998244353;
int t,n,m,k,x,y;
 
 
int32_t main()
{
    IOS;
    cin>>x>>y;
    int d;
    cin>>d;
    cout<<y/d-(x-1)/d<<ln;
}


Measured memory_bytes: 3644
import sys
M, D = [int(i) for i in sys.stdin.readline().split()]
cnt = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        if d < 10:
            continue
        d = str(d)
        d_10 = int(d[0])
        d_1 = int(d[1])
        if d_1 >= 2 and d_10 >= 2 and m == d_1 * d_10:
            cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
using namespace std;
string a[10];
int ans[10];
int main(){
	int n;
	while(true){
	cin>>n;
	if(n==0)
		break;
	for(int i=0;i<n;i++){
		cin>>a[i];
		int z;
		ans[i]=0;
		for(int j=0;j<n-1;j++){
			cin>>z;
			if(z==0)
				ans[i]+=100;
			if(z==2)
				ans[i]++;
		}
	}
	for(int i=0;i<n-1;i++){
		for(int j=n-1;j>i;j--){
			if(ans[j]>ans[j-1]){
				int tmp=ans[j];
				ans[j]=ans[j-1];
				ans[j-1]=tmp;
				string ttmp=a[j];
				a[j]=a[j-1];
				a[j-1]=ttmp;
			}
		}
	}
	for(int i=0;i<n;i++)
		cout<<a[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

#define POS(i, j) ((i) * bit + (j))

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  i32 *x = (i32 *) calloc (n + 1, sizeof (i32));
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi32, x + i);
  }
  i32 l;
  scanf ("%" SCNi32, &l);
  x[n] = x[n - 1] + l;
  i32 bit = 0;
  while ((1 << bit) < n + 1) bit++;
  i32 *dp = (i32 *) calloc ((n + 1) * bit, sizeof (i32));
  for (i32 i = 0, j = 0; i <= n; ++i) {
    while (j <= n && x[j] - x[i] <= l) j++;
    dp[POS(i, 0)] = j - 1;
  }
  for (i32 k = 1; k < bit; ++k) {
    for (i32 i = 0; i <= n; ++i) {
      i32 a = dp[POS(i, k - 1)];
      dp[POS(i, k)] = dp[POS(a, k - 1)];
    }
  }
  i32 q;
  scanf ("%" SCNi32, &q);
  while (q--) {
    i32 a, b;
    scanf ("%" SCNi32 "%" SCNi32, &a, &b);
    a--;
    b--;
    if (a > b) {
      i32 s = b;
      b = a;
      a = s;
    }
    i32 ans = 0;
    i32 j = bit - 1;
    while (a < b) {
      while (j > 0 && dp[POS(a, j)] > b) --j;
      ans += 1 << j;
      a = dp[POS(a, j)];
    }
    printf ("%" PRIi32 "\n", ans);
  }
}

int main (void) {
  run ();
  return 0;
}


Measured memory_bytes: 7808
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::cmp;
use std::f64::consts;

fn main() {
    let n: i32 = read();
    let m: usize = read();

    let mut vec: Vec<(i32, i32, i32)> = (0..m).map(|i| (read(), read(), i as i32)).collect();

    vec.sort_by_key(|key| key.1);

    let mut map: HashMap<i32, i32> = HashMap::new();
    let mut ans: Vec<(i32, i32, i32)> = Vec::new();

    for mut v in vec.iter() {
        let mut count = 0;
        if map.contains_key(&v.0) {
            count = map.get(&v.0).unwrap()+1;
            map.insert(v.0, count);
            ans.push((v.0, count, v.2));
        } else {
            count = 1;
            map.insert(v.0, count);
            ans.push((v.0, count, v.2));
        }
    }

    ans.sort_by_key(|key| key.2);

    for i in ans {
        println!("{:06}{:06}", i.0, i.1);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


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

judge = True
w = input()

word_list = [w]
count = 0

while judge and count < N-1:
    w = input()
    if w[0] == word_list[count][-1] and not(w in word_list):
        count += 1
        word_list.append(w)
    else:
        judge = False
        break

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

Measured memory_bytes: 3064
#include <stdio.h>
#define N 1000000

int main(){
  int A[N] , G[100];
  int num, i, j, k, cnt, m, v;
  scanf("%d", &num);
  for(i = 0; i < num; i++){
    scanf("%d", &A[i]);
  }
  
  cnt = 1;
  j = 1;
  while(1){ 
    if(cnt > num/5.0){
      break;
    }
    cnt = cnt*3 + 1;
    j++;
  }
  m = j;
  j = 0;
  for(i = cnt; i > 0; i=i/3){
    G[j] = i;
    j++;
  }
    cnt = 0;
    
  for(k = 0; k < m; k++){
    for(i = G[k]; i < num; i++){
      v = A[i];
      j = i - G[k];
      while(j >= 0 && A[j] > v){
	A[j+G[k]] = A[j];
	j = j - G[k];
	cnt++;
      }
      A[j+G[k]] = v;
    }
    
  }
  printf("%d\n", m);
  for(i = 0; i < m; i++){
    printf("%d ", G[i]);
  }
  printf("\n%d\n", cnt);
  for(i = 0; i < num; i++){
    printf("%d\n", A[i]);
  }
  return 0;
}



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, Q;
    cin >> N >> Q;
    vector<tuple<bool, ll, vector<ll>>> A(N);
    rep(i, N - 1) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        get<2>(A[a]).push_back(b);
        get<2>(A[b]).push_back(a);
    }
    rep(i, Q) {
        ll p, x;
        cin >> p >> x;
        get<1>(A[p - 1]) += x;
    }
    stack<ll> st;
    st.push(0);
    while(!st.empty()) {
        ll current = st.top();
        st.pop();
        get<0>(A[current]) = true;
        iter(j, get<2>(A[current])) {
            if(!get<0>(A[j])) {
                get<1>(A[j]) += get<1>(A[current]);
                st.push(j);
            }
        }
    }
    iter(i, A) cout << get<1>(i) << endl;
    return 0;
}


Measured memory_bytes: 20556
#include<stdio.h>
#include<string.h>
#define N 100000000 
  
char c[14];
int x[N];
int n;
   
int a(void);
int b(char);
void insert(void);
int find(void);
   
int main(){
char str[7];
int i;
   
 scanf("%d",&n);
 for(i=0;i<n;i++){
   scanf("%s%s",str,c);
   if(str[0]=='i'){
     insert();
   }
   else if(str[0]=='f'){
     if(find())printf("yes\n");
     else printf("no\n");
   }
 } 
 return 0;
}
  
int a(void){
  int x=0,i,k=1;
  for(i=0;i<strlen(c);i++){
    x+=k*(b(c[i]));
    k*=5;
  }
  return x;
}
   
int b(char c){
   
  if(c=='A'){
    return 1;
  }
  else if(c=='C'){
    return 2;
  }
  else if(c=='G'){
    return 3;
  }
  else return 4;
   
}
  
void insert(){
  x[a()]=1;
}
int find(){
    int key =a();
       
    if(x[key]){
   return 1;
    }
    else return 0;
} 

Measured memory_bytes: 19524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9

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; }

int N;
ll h[100010];

ll dp[100010];

int main(){
    int N,K; cin>>N>>K;
    for(int i=0;i<N;i++) cin>>h[i];
    
    for(int i=0;i<100010;++i) dp[i]=INF;
    
    dp[0]=0;
    
    for(int i=0;i<N;i++){
        for(int j=1;j<=K;j++){
            chmin(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }
    }
    
    cout<<dp[N-1]<<endl;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-

def func_a():
  argv = input().split(" ")
  A = int(argv[0]) if int(argv[0]) >= 1 else 0
  B = int(argv[1]) if int(argv[1]) <= 20 else 0

  if A * B == 0:
    pass
  else:
    if B % A == 0:
      print(A + B)
    else:
      print(B - A)


if __name__ == "__main__":
  func_a()


Measured memory_bytes: 2940
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest119-C
#  TODO https://atcoder.jp/contests/abc119/tasks/abc119_c

# Copy Editrial　Comment

N,A,B,C = map(int,input().strip().split(' '))
l =[]
for _ in range(0,N,+1):
	banbooLength = int(input().strip())
	l.append(banbooLength)
INF = 10 ** 9

def solveAlgorithm(cursol,aBanboo,bBanboo,cBanboo):
	if cursol==N :
		nowMin = min(aBanboo,bBanboo,cBanboo)
		if nowMin > 0 :
			# 1本目の竹を設定するのにも10コストかかるのでその分減らす
			addAndminusMagic = (abs(aBanboo-A)-10)+(abs(bBanboo-B)-10)+(abs(cBanboo-C)-10)
			return addAndminusMagic
		else:
			return INF
	# cursol+1 Banboo No Select  (No Magic Cost)
	return0 = solveAlgorithm(cursol+1,aBanboo,bBanboo,cBanboo)
	# cursol+1 Banboo A Select and leash magic
	return1 = solveAlgorithm(cursol+1,aBanboo+l[cursol],bBanboo,cBanboo)+10
	# cursol+1 Banboo B Select and leash magic
	return2 = solveAlgorithm(cursol+1,aBanboo,bBanboo+l[cursol],cBanboo)+10
	# cursol+1 Banboo C Select and leash magic
	return3 = solveAlgorithm(cursol+1,aBanboo,bBanboo,cBanboo+l[cursol])+10
	minReturn = min(return0,return1,return2,return3)
	return minReturn

solution = solveAlgorithm(0,0,0,0)
print("{}".format(solution))


Measured memory_bytes: 3064
class Node
  attr_accessor :parent, :size
  def initialize(n)
    @parent = n
    @size = 1
  end
end

class UnionFindTree
  attr_accessor :nodes
  def initialize(n)
    @nodes = (0..n).map { |i| Node.new(i) }
  end

  def find(x)
    return x if @nodes[x].parent == x
    @nodes[x].parent = find(@nodes[x].parent)
  end

  def unite(a, b)
    pa = find(a)
    pb = find(b)
    return if pa == pb

    if @nodes[pa].size < @nodes[pb].size
      @nodes[pa].parent = pb
    else
      @nodes[pb].parent = pa
    end

    tmp = @nodes[pa].size + @nodes[pb].size
    @nodes[pa].size = tmp
    @nodes[pb].size = tmp

  end

  def same?(a, b)
    find(a) == find(b)
  end

  def size(x)
    return @nodes[find(x)].size
  end

end

n, m = gets.split.map(&:to_i)

edge = []

0.upto(m-1) do |i|
  edge[i] = gets.split.map(&:to_i)
end

ans = 0

#辺iが橋かを判定する
0.upto(m-1) do |i|
  uft = UnionFindTree.new(n)
  0.upto(m-1) do |j|
    next if j==i
    uft.unite(edge[j][0], edge[j][1])
  end
  ans += 1 if uft.size(1) < n
end

puts ans


Measured memory_bytes: 1916
// C - 100 to 105
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	int x;
	cin >> x;
	vector<int> dp(x + 1);
	dp[0] = 1;
	for (int i = 0; i <= x; i++) {
		if (dp[i] == 0) continue;
		for (int j = 100; j <= 105; j++)
			for (int k = i + j; k <= x; k += j) dp[k] = 1;
	}
	cout << dp[x] << endl;
	return 0;
}


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

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

    int n, t;
    cin >> n >> t;
    
    int mini = 1e9;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        if(t >= b){
            mini = min(mini, a);
        }
    }

    if(mini == 1e9) cout << "TLE" << endl;
    else cout << mini << endl;

    return 0;
}

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

int main()
{
    int n, i, c=0;
    std::vector<int> v;
    cin >> n;
    while(cin >> i) v.push_back(i);
    while(1) {
        for(i=0; i<n; i++){
            if(v[i] % 2 == 1) {
                cout << c << endl;
                return 0;
            }
            v[i] = v[i] / 2;
        }
        c++;
    }
}


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

#define REP(i,n) for(int i=0;i<n;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 EPS (1e-7)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;

string s;
int main(){
	cin>>s;
	s[3]='8';
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import random
import math
import time
import bisect
from functools import lru_cache
import itertools

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    start_time = time.time()
    D = int(input())
    c = [int(a) for a in input().split()]
    s = [
        [int(a) for a in input().split()]
        for _ in range(D)
    ]

    def calc_score(t):
        score = 0
        last = [0] * len(c)
        res = []

        for d, ti in enumerate(t):
            sdi = s[d][ti - 1]
            score += sdi
            last[ti - 1] = d + 1
            for i, ci in enumerate(c):
                score -= ci * ((d + 1) - last[i])
            res.append(score)
        return res

    def calc_score_diff(t, di, qi):
        old_q = t[di - 1]
        last_old_q_date = 0
        for i in range(di - 2, -1, -1):
            if t[i] == old_q:
                last_old_q_date = i + 1
                break
        next_old_q_date = D + 1
        for i in range(di, D):
            if t[i] == old_q:
                next_old_q_date = i + 1
                break

        old_d_last = di - last_old_q_date
        old_d_next = next_old_q_date - di
        old_diff = old_d_next * old_d_last * c[old_q - 1]

        new_q = qi
        last_new_q_date = 0
        for i in range(di - 2, -1, -1):
            if t[i] == new_q:
                last_new_q_date = i + 1
                break
        next_new_q_date = D + 1
        for i in range(di, D):
            if t[i] == new_q:
                next_new_q_date = i + 1
                break

        new_d_last = di - last_new_q_date
        new_d_next = next_new_q_date - di
        new_diff = new_d_next * new_d_last * c[new_q - 1]

        old_score = s[di - 1][old_q - 1]
        new_score = s[di - 1][new_q - 1]
        return new_diff - old_diff + new_score - old_score

    t = [1] * D
    score = calc_score(t)[-1]
    while True:
        elapsed_time = time.time() - start_time
        if elapsed_time > 1.7:
            break

        di = random.randint(1, D)
        qi = random.randint(1, len(c))
        diff = calc_score_diff(t, di, qi)
        if diff > 0:
            score += diff
            print(score, file=sys.stderr)
            t[di - 1] = qi
        else:
            print('no', file=sys.stderr)
    for ti in t:
        print(ti)


if __name__ == "__main__":
    main()


Measured memory_bytes: 117232
/*
    B - Judge Status Summary
    https://atcoder.jp/contests/abc173/tasks/abc173_b
*/

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

#define ll long long // 10 ^ 18
#define forn(i, s, n) for (int i = s; i < n; i++)
#define whilen(val, n) while(n-- && cin >> val)
#define r_1(v) cin >> v
#define r_2(v1, v2) cin >> v1 >> v2

int main() {
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    int N;
    int AC = 0, WA = 0, TLE = 0, RE = 0;
    string s;
    r_1(N);
    forn(i, 0, N) {
        r_1(s);
        if (s == "AC") AC++;
        else if (s == "WA") WA++;
        else if (s == "TLE") TLE++;
        else RE++;
    }
    cout << "AC x " + to_string(AC) << "\n" << "WA x " + to_string(WA) << "\n" << "TLE x " + to_string(TLE) << "\n" << "RE x " + to_string(RE) << "\n";
    return 0;
}

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

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int A = inputLongArray[0];
            int B = inputLongArray[1];
            int K = inputLongArray[2];
            string outStr1 = "";
            string outStr2 = "";
            bool endFlg = false;
            
            //下限からチェック
            for (int i=0; i < K; ++i) {
                //上限値を超えた場合は後半処理は無しで終了させる
                if(A + i > B) {
                    endFlg = true;
                    break;
                }
                outStr1 += (A+i).ToString() + "\n";
            }

            if(endFlg == false) {
                for (int i = K-1; i >= 0; --i) {
                    if(outStr1.Contains((B - i).ToString()) == false){
                        outStr2 += (B - i).ToString() + "\n";
                    }
                }
            }

            Console.WriteLine(outStr1 + outStr2);
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    ll res = s.rfind('Z') - s.find('A') + 1;
    cout << res;
    cout << endl;
    return 0;
}




Measured memory_bytes: 720
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    k = II()
    ans = 0
    lis = []
    i = 0
    tmp = 1
    while len(s) > i + 1:
        if s[i] == s[i + 1]:
            tmp += 1
        else:
            lis.append((s[i], tmp))
            tmp = 1
        i += 1
    lis.append((s[i], tmp))
    if lis[0][0] == lis[-1][0]:
        if len(lis) == 1:
            ans += k * lis[0][1] // 2
            print(ans)
            return
        ans -= (lis[0][1] // 2 + lis[-1][1] // 2) * (k - 1)
        ans += (lis[0][1] + lis[-1][1]) // 2 * (k - 1)
    for _, b in lis:
        ans += b // 2 * k
    print(ans)
    

    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


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


char ss[200010];
ll record[10010];
ll res=0;
int main(){
    int n,p,k=0,d=1;

    scanf("%d%d%s",&n,&p,ss);

    if(p==2||p==5){
        for(ll i=0;i<n;i++)
            if((ss[i]-'0')%p==0)
                res+=i+1;
    }
    else{
        record[0]=1;
        for(ll i=n-1;i>=0;i--){
            k+=(ss[i]-'0')*d;
            k%=p;
            res+=record[k];
            record[k]++;
            d=d*10%p;
        }
    }
    printf("%lld",res);
}


Measured memory_bytes: 512
#include <iostream>
#define MAX 101

using namespace std;


int main()
{
	int matrix[MAX][MAX] = {0};
	int n;
	cin >> n;
	
	for (int i = 0; i < n; i++)
	{
		int u, k, v;
		cin >> u >> k;
		for (int j = 0; j < k; j++)
		{
			cin >> v;
			matrix[u][v] = 1;			
		}
	}
	
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if(j) cout << ' ';
			cout << matrix[i+1][j+1];		
		}
		cout << endl;
	}
} 


Measured memory_bytes: 3152
#include <iostream>

using namespace std;
int main(){
	int i,j,a[5],k;
	for(i=0;i<5;i++) cin >> a[i];
	cin >> k;
	for(i=0;i<5;i++){
		for(j=i+1;j<5;j++){
			if(a[j] - a[i]>k){
				cout << ":(" << endl;
				return 0;
			}
		}
	}
	cout << "Yay!" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64 = int64_t;

int main()
{
    size_t K;
    cin >> K;

    i64 x;
    queue<i64> q;
    for (int i = 1; i < 10; i++) {
        q.push(i);
    }

    for (size_t i = 0; i < K; i++) {
        x = q.front();
        q.pop();

        if (x % 10 != 0) {
            q.push(10 * x + (x % 10) - 1);
        }
        q.push(10 * x + x % 10);
        if (x % 10 != 9) {
            q.push(10 * x + (x % 10) + 1);
        }
    }

    cout << x << endl;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(){

	int n;
	cin>>n;
	if(n==4||n==2||n==1){
	
		cout<<4;
		return 0;
	}
	int j=1;
	while(n!=4){
	
		if(n%2==0){
		
			n/=2;
		}
		else{
		
			n*=3;
			n++;
		}
		j++;
	}

	cout<<j+3;
}


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

void DFS(ll x, int n, int& ans)
{
  if (n<x) return;
  
  string tmp = to_string(x);
  map<char, int> mp;
  
  for (int i=0; i<tmp.size(); i++) {
    if (mp.count(tmp[i])) {
      mp[tmp[i]]++;
    }
    else mp[tmp[i]] = 1;
  }
  if (mp.size() == 3) ans++;
  
  DFS(x*10+3, n, ans);
  DFS(x*10+5, n, ans);
  DFS(x*10+7, n, ans);
}

int main(){
  int n, ans=0;
  cin >> n;
  vector<int>a;
  DFS(0, n, ans);
 
  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <functional>
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
// constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------



int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int ans = 0;
  string S;
  cin >> S;
  int cnt = 0;
  for(int i=0; i<3; i++){
    if(S[i] == 'R'){
      cnt++;
    }else{
      cnt = 0;
    }
    chmax(ans,cnt);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3644
S=str(input())
letter="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
condition1 = S[0]=='A'
condition2 = len([1 for x in S[2:len(S)-1] if x=="C"]) == 1
count=0
for i in range(len(S)):
  if len([1 for x in letter if x==S[i]]) == 1:
    count = count + 1
condition3 = count == 2
if condition1 & condition2 & condition3:
  print('AC')
else:
  print('WA')


Measured memory_bytes: 3060
program k_dmc
  implicit none
  integer :: n, q, k(75), i, j
  integer(8) :: d, m, dm, dmc
  character(1000000) :: s
  k = 0
  read(*,*) n
  read(*,*) s
  read(*,*) q
  read(*,*) k(1:q)
  s = trim(adjustl(s))
  do j = 1, q
    d = 0_8
    m = 0_8
    dm = 0_8
    dmc = 0_8
    do i = 1, k(j)-1
      select case(s(i:i))
      case("D")
        d = d+1_8
      case("M")
        m = m+1_8
        dm = dm+d
      case("C")
        dmc = dmc+dm
      end select
    end do
    do i = k(j), n
      select case(s(i:i))
      case("D")
        d = d+1_8
      case("M")
        m = m+1_8
        dm = dm+d
      case("C")
        dmc = dmc+dm
      end select
      select case(s(i-k(j)+1:i-k(j)+1))
      case("D")
        d = d-1_8
        dm = dm-m
      case("M")
        m = m-1_8
      end select
    end do
    write(*,'(i0)') dmc
  end do
  stop
end program k_dmc

Measured memory_bytes: 5256
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
//#define for(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define print(x) std::cout << x << std::endl;

using namespace std;

typedef long long ll;

template<class T, class U> std::string replace(std::string s, const T& target, const U& replacement, bool replace_first = 0, bool replace_empty = 0);
bool isContain(int value, int under, int top);
vector<int> range(int x);

int main(void) {
	//Program Start

	ll N;
	cin >> N;

	vector<ll> Cityed(5);
	rep(i,5) cin >> Cityed[i];

	ll min = Cityed[0];
	ll min_index = 0;

	for(int i = 1;i < 5;i++) {
		if(min > Cityed[i]) {
			min = Cityed[i];
			min_index = i;
		}
	}

	ll bias = (N % min == 0) ? 0 : 1;

	cout << ((N / min) + bias + 4) << endl;


ProgramEndPointLabel:;

	//Program End
	//system("pause");

	return 0;
}


vector<int> range(int y) {
	vector<int> result(y);
	for (int i = 0; i < y; i++)
		result[i] = i;
	return result;
}

bool isContain(int value, int under, int top) {
	if (under <= value && value <= top) return true;
	return false;
}

template<class T, class U> std::string replace(std::string s, const T& target, const U& replacement, bool replace_first, bool replace_empty) {
	using S = std::string;
	using C = std::string::value_type;
	using N = std::string::size_type;
	struct {
		auto len(const S& s) { return s.size(); }
		auto len(const C* p) { return std::char_traits<C>::length(p); }
		auto len(const C  c) { return 1; }
		auto sub(S* s, const S& t, N pos, N len) { s->replace(pos, len, t); }
		auto sub(S* s, const C* t, N pos, N len) { s->replace(pos, len, t); }
		auto sub(S* s, const C  t, N pos, N len) { s->replace(pos, len, 1, t); }
		auto ins(S* s, const S& t, N pos) { s->insert(pos, t); }
		auto ins(S* s, const C* t, N pos) { s->insert(pos, t); }
		auto ins(S* s, const C  t, N pos) { s->insert(pos, 1, t); }
	} util;

	N target_length = util.len(target);
	N replacement_length = util.len(replacement);
	if (target_length == 0) {
		if (!replace_empty || replacement_length == 0) return s;
		N n = s.size() + replacement_length * (1 + s.size());
		s.reserve(!replace_first ? n : s.size() + replacement_length);
		for (N i = 0; i < n; i += 1 + replacement_length) {
			util.ins(&s, replacement, i);
			if (replace_first) break;
		}
		return s;
	}

	N pos = 0;
	while ((pos = s.find(target, pos)) != std::string::npos) {
		util.sub(&s, replacement, pos, target_length);
		if (replace_first) return s;
		pos += replacement_length;
	}
	return s;
}


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

int main() {
  int a,b,k;
  cin >> k;
  cin >> a >> b;
  for (int i = a; i <= b; ++i){
    if (i%k == 0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

template <typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n = 0) : n(n), d(n + 1) {}
  void add(int i, T x = 1) {
    for(i++; i <= n; i += i & -i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for(i++; i; i -= i & -i) {
      x += d[i];
    }
    return x;
  }
};

int main() {
  ll n, q;
  cin >> n >> q;
  vl c(n), last(5e5 + 10, -1);
  rep(i, n) cin >> c[i];
  vector<pair<P, ll>> p(q);
  rep(i, q) {
    ll l, r;
    cin >> l >> r;
    l--;
    r--;
    p[i] = {{r, l}, i};
  }
  sort(all(p));
  BIT<ll> b(n + 10);
  vl ans(q);
  ll k = 0;
  rep(i, q) {
    ll l = p[i].first.second;
    ll r = p[i].first.first;
    ll j = p[i].second;
    for(; k <= r; k++) {
      ll now = last[c[k]];
      last[c[k]] = k;
      if(now >= 0) b.add(now, -1);
      b.add(k, 1);
    }
    ans[j] = b.sum(r);
    if(l > 0) ans[j] -= b.sum(l - 1);
  }
  rep(i, q) cout << ans[i] << '\n';
}

Measured memory_bytes: 31064
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    long long n,a,b;
    cin >> n >> a >> b;
    long long ans;
    if(a>b){
        ans = 0;
    }else if(n==1&&a==b){
        ans = 1;
    }else if(n==1&&a!=b){
        ans =0;
    }else{
        ans = (b-a)*(n-2)+1;
    }
    cout << ans << endl;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

ll N, M, d;

signed main() {
  cin >> N >> M >> d;

  ll p = 0;
  if (d == 0) {
    p += N;
  } else {
    p += (N-d); // 増加する側
    p += (N-d); // 減少する側
  }
  double ans = (1.0 * p / (N*N)) * (M-1);
  printf("%.10f\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int W, H, N;
  cin >> W >> H >> N;
  vector<int> x(N);
  vector<int> y(N);
  vector<int> a(N);
  int A, B, C, D;
  A = 0;
  B = W;
  C = 0;
  D = H;
  
  for(int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> a[i];
    
    if (a[i] == 1 && x[i] >= A) {
    A = x[i];
    }
    else if(a[i] == 2 && x[i] <= B) {
    B = x[i];
    }
    else if(a[i] == 3 && y[i] >= C) {
    C = y[i];
    }
    else if(a[i] == 4 && y[i] <= D) {
    D = y[i];
    }
  }
  if (B >= A && D >= C) {
    cout << (B - A) * (D - C) << endl;
  }
  else {
    cout << 0 << endl;
  }
}
  

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

int main(){
  int total_applicants;
  int working_duration;
  while(~scanf("%d %d",
               &total_applicants,
               &working_duration)){
    if(total_applicants == 0) break;

    vector<int> problems;
    for(int applicant_idx = 0; applicant_idx < total_applicants; applicant_idx++){
      int difficulty;
      scanf("%d",&difficulty);
      problems.push_back(difficulty);
    }

    int min_time = INF;
    int times[1001];
    for(int applicant_idx = 0; applicant_idx < total_applicants; applicant_idx++){
      times[applicant_idx] = problems[applicant_idx] * (working_duration/problems[applicant_idx]);
      min_time = min(times[applicant_idx],min_time);
    }

    for(int applicant_idx = 1; applicant_idx < total_applicants; applicant_idx++){

      for(int multiply=0; multiply <= working_duration/problems[applicant_idx]; multiply++){
        bool isok = true;
        int time = problems[applicant_idx] * multiply;
        for(int prev = 0; prev < applicant_idx; prev++){
          if(time == times[prev]
             && problems[applicant_idx] < problems[prev]){
            isok = false;
            break;
          }
          if(time < times[prev]){
            isok = false;
            break;
          }
        }
        
        if(isok){
          times[applicant_idx] = time;
          min_time = min(time,min_time);
          break;
        }
      }
    }

    int count = 0;
    int res;
    int min_diffculty = INF;

    for(int applicant_idx = 0; applicant_idx < total_applicants; applicant_idx++){
      if(min_time == times[applicant_idx]){
        if(min_diffculty > problems[applicant_idx]){
          count = 1;
          res = applicant_idx + 1;
          min_diffculty = problems[applicant_idx];
        }
        else if(min_diffculty == problems[applicant_idx]){
          count++;
        }
      }
    }

    printf("%d\n",count > 1 ? total_applicants : res);
  }
}

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

int main()
{
    
    int person[4][3][10];
    for (int b = 0; b < 4;b++)
    {
        for (int f = 0; f < 3;f++)
        {
            for (int r = 0; r < 10; r++)
            {
                person[b][f][r] = 0;
            }
        }
    }

    int n;
    cin >> n;

    for (int i = 0; i < n; i++)
        {
            int b, f, r, v;
            cin >> b >> f >> r >> v;
            person[b-1][f-1][r-1] += v;
        }

    for (int b = 0; b < 4;b++)
    {
        for (int f = 0; f < 3;f++)
        {
            for (int r = 0; r < 10; r++)
            {
                cout << " " << person[b][f][r];
            }
            cout << endl;
        }
        if(b != 3)
        cout << "####################" << endl;
    }
    return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

// void str_connect(char *x, char *y)
// {
//     int y_len = strlen(y);

//     int i;
//     for (i = 0; i < y_len; i++)
//     {
//         x[i + y_len] = y[i];
//     }
// }

bool is_same(char *x, char *y, int y_len)
{
    for (int i = 0; i < y_len; i++)
    {
        if (x[i] != y[i])
        {
            return false;
        }
    }
    return true;
}

bool str_same(char *haystack, char *needle) //xの文字列中にyが含まれるか判定
{
    while (*haystack) //haystackの先頭を指すポインタ
    {
        if (is_same(haystack, needle, strlen(needle)))
        {
            return true;
        }
        haystack++;
    }
    return false;
    // int i;
    // for (i = 0; i < strlen(haystack); i++)
    // {
    //     if (is_same(haystack + i, needle, strlen(needle)))
    //     {
    //         return true;
    //     }
    // }
    // return false;
    // if (is_same(x2, x, y_len))
    // {
    //     return true;
    // }
    // return false;
}

int main(void)
{
    char s[202]; //後にs2と連結するので最多文字数の倍の領域を確保しておく
    char p[101];

    scanf("%s %s", s, p);

    int s_len = strlen(s);

    char s2[s_len];
    strcpy(s2, s); //s2にsをコピー
    strcat(s, s2); //sとs2を連結

    if (str_same(s, p)) //sとs2を連結した文字列の中にpが含まれるか判定
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 2144
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def init_kaijo(MAX, MOD):
    kaijo = [0] * MAX
    kaijo[0] = 1
    for i in range(1, len(kaijo)):
        kaijo[i] = kaijo[i-1] * i % MOD
    return kaijo

MOD = 10**9+7
kaijo = init_kaijo(500000, MOD)

def inv(x, MOD):
    return pow(x, MOD-2, MOD)

def nPk(n, k, MOD):
    return kaijo[n] * inv(kaijo[n-k], MOD) % MOD

def nCk(n, k, MOD):
    return nPk(n,k, MOD) * inv(kaijo[k], MOD)

def nHk(n, k, MOD):
    return nCk(n+k-1, k, MOD)

n,k,*aaa = get_all_int()
aaa.sort()

if k == 1:
    print(0)
    exit()

ans = 0

for i,a in enumerate(aaa):
    uppers = n-(i+1)
    bottoms = i

    if bottoms >= k-1:
        ans += a * nCk(bottoms, k-1, MOD) % MOD
    if uppers >= k-1:
        ans -= a * nCk(uppers, k-1, MOD) % MOD

print(ans % MOD)


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



int main() {
    int a, b;
    cin >> a >> b;
    
    for (int i=2; i<1000000; i++) {
        int tax8 = floor(i * 0.08);
        int tax10 = floor(i * 0.1);
        if (tax8==a && tax10==b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    
    return 0;
}


Measured memory_bytes: 256