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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var nd = Console.ReadLine().Split()
                .Select(long.Parse).ToArray();
            long n = nd[0];
            long d = nd[1];

            int result = 0;
            for (int i = 0; i < n; i++)
            {
                var xy = Console.ReadLine().Split()
                .Select(long.Parse).ToArray();
                long x = xy[0];
                long y = xy[1];

                if (x * x + y * y <= d * d)
                    result++;
            }

            Console.WriteLine(result);

        }    
    }
}


Measured memory_bytes: 46960
package main

import (
	"bufio"
	"fmt"
	"os"
)

func isOdd(n int) bool { return n%2 != 0 }

var bw = bufio.NewWriter(os.Stdout)

func pln(a ...interface{}) { fmt.Fprintln(bw, a...) }
func flush()               { bw.Flush() }

func ask(q int) string {
	pln(q)
	flush()
	var s string
	fmt.Scan(&s)
	return s
}

func main() {
	var n int
	fmt.Scan(&n)
	mf := make([]string, n)

	l, r := 0, n-1
	if s := ask(l); s == "Vacant" {
		return
	} else {
		mf[l] = s
	}
	if s := ask(r); s == "Vacant" {
		return
	} else {
		mf[r] = s
	}

	for r-l > 0 {
		m := l + (r-l)/2
		if s := ask(m); s == "Vacant" {
			return
		} else {
			mf[m] = s
		}

		if isOdd(m - l + 1) {
			if mf[l] != mf[m] {
				r = m
			} else {
				l = m
			}
		} else {
			if mf[l] == mf[m] {
				r = m
			} else {
				l = m
			}
		}
	}
}


Measured memory_bytes: 1236
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
const double EPS = 1e-8;
#define Scan(a) int a;scanf("%d", &a);
#define ScanS(a) char a[500];scanf("%s", a);
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1LL)
#define bitset(a,b)      ( a |= (1LL << b))
#define bitunset(a,b)    (a &= ~(1LL << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, 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);
}

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

int main() {
	int n;
	ll k;
	cin >> n >> k;
	vector<pii> s(n);
	ll ksum[31] = {}, same[32] = {};
	ll zsum = 0;
	vector<int> ons;
	ons.push_back(-1);
	REP(i, 31) {
		if (bitcheck(k, i))
			ons.push_back(i);
	}

	REP(i, n) {
		scanf("%d %d", &s[i].first, &s[i].second);
	}
	ll ans = 0;
	REP(i, ons.size()) {
		ll cur = 0;
		REP(j, n) {
			bool f = 1;
			rep(l, ons[i], 30) {
				
				bool c = bitcheck(k, l);
				if(ons[i] != -1)
				if (l == ons[i])
					c = 0;

				if (!c && bitcheck(s[j].first, l)) {
					f = 0;
					break;
				}
			}
			if (f)
				cur += s[j].second;
		}
		ans = max(ans, cur);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
<?php
  fscanf(STDIN, "%d", $n);
  $array = explode(' ', trim(fgets(STDIN)));
  $i=1;
  $count=0;
  foreach($array as $value){
    if($value == $i){
      $i++;
    }else{
      $count++;
    }
  }
  if($count == count($array)){
    echo -1;
  }else{
    echo $count;
  }

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

#define ll long long

ll n;
set<ll> st;

vector<ll> divisor(ll n){
	vector<ll> res;
	for (ll i=1;i*i<=n;i++){
		if (n%i==0){
			res.push_back(i);
			if (n/i!=i) res.push_back(n/i);
		}
	}
	return res;
}

void solve(ll n,ll m){
	vector<ll> v=divisor(n);
	for (ll i=0;i<v.size();i++){
		ll k=v[i];
		if (k==1) continue;
		ll d=m;
		while (d>=k){
			if (d%k==0) d/=k;
			else break;
		}
		d%=k;
		if (d==1) st.insert(k);
	}
}

int main(){
	cin>>n;
	solve(n,n);
	solve(n-1,n);
	cout<<st.size()<<endl;
	return 0;
}

Measured memory_bytes: 384
/*           pmaik
    ░▒▓█►─═ Maneesh ═─◄█▓▒░


          ( •̪●)
        ███████]▄▄▄▄▄▄▄▄▃  ▃  ▃ 
    ▂▄▅█████████▅▄▃▂
   [███████████████████]
  ...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤......  */

#include<bits/stdc++.h>
using namespace std;
#define inf() ifstream cin("in00.txt")
#define onf() ofstream cout("out00.txt")
#define ll long long int
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<ll,ll>
#define fi first
#define se second
#define M 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);

ll isprime[1000001];
void sieve()
{
    ll i,j,k;
    isprime[0]=isprime[1]=1;
    for(i=2;i<=sqrt(1000000);i++)
    {
        if(!isprime[i])
        {
            for(j=2*i;j<=1000000;j+=i)
            {
                isprime[j]=1;
            }
        }
    }
}

ll modInverse(ll a, ll m) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    {  
        ll q = a / m; 
        ll t = m;  
        m = a % m; a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }  
    if(x<0) 
       x+=m0; 
    return x; 
}

ll mod(ll x, ll n)
{
    if(n==0)
        return 1;
    if(n%2==0)
    {
        ll y=mod(x, n/2);
        return ((y%M)*(y%M))%M;
    }
    else
    {
        return ((x%M)*(mod(x, (n-1))%M))%M;
    }
}

int main()
{
    fastio;
    ll n;
    cin>>n;
    ll a[n],i,j,k,res=0;
    for(i=0; i<n; i++)
        cin>>a[i];

    set<vector<ll>>st;

    for(i=0; i<n; i++)
    {
        for(j=i+1; j<n; j++)
        {
            for(k=j+1; k<n; k++)
            {
                if(a[i]!=a[j] && a[i]!=a[k] && a[j]!=a[k] &&  a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[j]+a[k]>a[i])
                {
                    // cout<<a[i]<<" "<<a[j]<<" "<<a[k]<<endl;
                    /*vector<ll>v;
                    v.pb(a[i]);
                    v.pb(a[j]);
                    v.pb(a[k]);
                    sort(v.begin(), v.end());

                    ll l1=st.size();
                    st.insert(v);
                    ll l2=st.size();

                    if(l1!=l2)*/
                        res++;
                }
            }
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
 
int main()
{
    int y, x;
    while (1) {
        cin >> y >> x;
        if (y == 0 && x == 0)break;
        for (size_t i = 0; i < y; i++)
        {
            if (i == 0||i==y-1) {
                for (size_t i = 0; i < x; i++)
                {
                    cout << '#';
                }
            }
            else {
                for (size_t i = 0; i < x; i++)
                {
                    if(i==0||i==x-1){ cout << '#'; }
                    else { cout << '.'; }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
	long long int N;
	cin >> N;
	vector<long long int>A(N), B(N);
	for( size_t i = 0; i < N; i++ ){
		cin >> A[i];
	}
	long long int sumB = 0;
	for( size_t i = 0; i < N; i++ ){
		cin >> B[i];
		sumB += B[i];
	}
	sumB += A[0];
	long long int ans = sumB;
	for( size_t i = 1; i < N; i++ ){
		sumB += A[i];
		sumB -= B[i - 1];
		ans = max(ans, sumB);
	}
	cout << ans << endl;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n;
vector<tuple<string, int, int>> sps;

bool cmp(const tuple<string, int, int> &a, const tuple<string, int, int> &b) {
  string str_a = get<0>(a);
  string str_b = get<0>(b);

  int pnt_a = get<1>(a);
  int pnt_b = get<1>(b);

  if (str_a == str_b) {
    return pnt_a > pnt_b;
  }
  else {
    return str_a < str_b;
  }
}

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 1; i <= n; ++i) {
    string s;
    int p;

    cin >> s;
    scanf("%d", &p);

    sps.push_back(make_tuple(s, p, i));
  }

  sort(sps.begin(), sps.end(), cmp);

  for (auto &e: sps) {
    printf("%d\n", get<2>(e));
  }

  return 0;
}


Measured memory_bytes: 256
def main():
    s = input()
    cr = 0
    cp = 0
    score = 0
    for c in s:
        if c == 'g':
            if cr > cp:
                score += 1
                cp += 1
            else:
                cr += 1
        else:
            if cr > cp:
                cp += 1
            else:
                cr += 1
                score -= 1
    print(score)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 67548
n,k=map(int,input().split())
h=[0]*n
for i in range(n):
    h[i]=int(input())

h=sorted(h)
d=h[k-1]-h[0]
ans=d
for i in range(n-k):
    d=h[k+i]-h[i+1]
    if d<ans:
        ans=d

print(ans)

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

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include "cstdio"
using namespace std;
#define LL long long
#define mod 29
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int flag=1;
        int a=n%10;
        int b=n/10%10;
        int c=n/100%10;
        int d=n/1000;
        //cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
        if((a==b&&b==c)||(b==c&&b==d))
        {
            puts("Yes");
        }
        else{
            puts("No");
        }
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("-Ofast")

#include <bits/stdc++.h>

using namespace std;

signed main(){
    int n;
    cin >> n;
    int* a = new int[n];
    for (int i = 0;i < n;++i) cin >> a[i];

    int* b = new int[n]; // 実際に割り当てていくための配列
    for (int i = 0;i < n;++i) b[i] = 0;
    /*
        i=n,n-1,...2,1の順に
            1. b[2*i-1],b[3*i-1],...の和を求め、
            2. a[i-1]の条件に一致するようにb[i-1]を定める
        を繰り返す.
     */
    for (int i = n;i > 0;--i){
        /* 上記の1 */
        int sum = 0;
        for (int j = 2 * i - 1;j < n;j += i){
            sum += b[j];
        }
        /* 上記の2 */
        if ((sum ^ a[i - 1]) & 1){ // sumとa[i-1]の偶奇が不一致なら
            b[i - 1] = 1;
        }
    }

    cout << accumulate(b,b + n,0) << endl;
    for (int i = 0;i < n;++i)
        if (b[i])
            cout << i + 1 << " ";
    cout << endl;

    delete[] a;
    delete[] b;
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; 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 ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;
const ll INF = 10e9;

int N, A, B, C;
vector<int> L;

int dfs(int cur, int a, int b, int c) {
    if(cur==N) {
        if(!a || !b || !c) return INF;
        return abs(a-A) + abs(b-B) + abs(c-C);
    }
    int res = dfs(cur+1, a, b, c);
    res = min(res, dfs(cur+1, a+L[cur], b, c) + (a ? 10 : 0));
    res = min(res, dfs(cur+1, a, b+L[cur], c) + (b ? 10 : 0));
    res = min(res, dfs(cur+1, a, b, c+L[cur]) + (c ? 10 : 0));
    return res;
}

int main() {
    cin >> N >> A >> B >> C;
    REP(i,N) {
        int tmp; cin >> tmp;
        L.emplace_back(tmp);
    }
    cout << dfs(0,0,0,0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<functional>
using namespace std;
#define INF 1e15
#define MOD 1000000007
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define END system("PAUSE");return 0
int n, k, a[111111], b[111111], c[111111], s[222222], x[222222];
signed main() {
	cin >> n >> k;
	rep(i, n)cin >> a[i] >> b[i] >> c[i];
	for (int i = 1; i <= k; i++) {
		rep(j, 222222)x[j] = 0;
		rep(j, n)if (c[j] == i)x[a[j] * 2 - 1]++, x[b[j] * 2]--;
		rep(j, 222222)if (j)x[j] += x[j - 1];
		rep(j, 222222)s[j] += (x[j]>0);
	}
	int ans = 0;
	rep(j, 222222)ans = max(ans, s[j]);
	cout << ans << endl;
	END;
}


Measured memory_bytes: 6264
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        char[] alp = "abcdefghijklmnopqrstuvwxyz".toCharArray();
        char[] s = sc.next().toCharArray();
        int n = s.length;
        StringBuilder sb = new StringBuilder();
        int k = sc.nextInt();
        for(int i = 0; i < n; i++){
            if(i == n-1){
                sb.append(alp[(s[i]-'a'+k)%26]);
            }else if(s[i] == 'a'){
                sb.append("a");    
            }else if(26-(s[i] - 'a') <= k){
                k -= 26-(s[i]-'a');
                sb.append("a");
            }else{
                sb.append(s[i]);
            }
        }
        System.out.println(sb.toString());
    }

}


class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 29460
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxx = 1010;
int c[maxx][maxx];

int lcs(char s1[],char s2[]) {
	int m = strlen(s1), n = strlen(s2);
	for (int i = 1; i <= m; i++)
		c[i][0] = 0;
	for (int i = 1; i <= n; i++)
		c[0][i] = 0;

	for (int i = 0; i < m; i++) {
		for (int j = 0; j < n; j++) {
			if (s1[i] == s2[j])
				c[i+1][j+1] = c[i][j] + 1;
			else
				c[i+1][j+1] = max(c[i][j+1], c[i + 1][j]);
		}
	}
	return c[m][n];
}
int main()
{
	char s1[maxx], s2[maxx];
	int t;
	scanf("%d", &t);
	for (int i = 0; i < t; i++) {
		scanf("%s %s", s1, s2);
		printf("%d\n",lcs(s1,s2));
	}

	return 0;
}

Measured memory_bytes: 7140
i = list(map(int, input().split())) 

A = i[0]
B = i[1]
T = i[2]

timeElapsed = 0
limit = T + 0.5
biscuitCount = 0 #ビスケットの生成回数（A秒後、2A秒後…毎インクリメントする）

for i in range(1, T+1):
    if(A*i <= limit):
        biscuitCount+=1
    else:
        break

print(biscuitCount * B)

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

int n,m,ans;
string s,t;

int main() {
	cin >> s >> t;
	n = s.length();
	m = t.length();
	ans = INT_MAX;
	for( int i = 0 ; i <= n-m ; i++ ) {
		int cnt = 0;
		for( int j = 0 ; j < m ; j++ )
			cnt += s[i+j] != t[j];
		ans = min(ans,cnt);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3772
def calcdistance(N, K, x) : 
  sum = 0
  for i in range(N) : 
    sum += 2 * min(x[i] - 0, K - x[i])
  return sum

N = int(input())
K = int(input())
x = list(map(int, input().split()))

print(calcdistance(N, K, x))

Measured memory_bytes: 3060
//****************************//
/**********  main *************/
//****************************//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <math.h> 

using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i, n) for (i = 0; i < n; i++)
#define FOR(i, a, b) for (i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())

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

int main()
{

    std::cin.tie(0);

    string s,t;
    cin >> s >> t;

    int slength = s.length();
    int tlength = t.length();
    bool length , judge=true;

    if((slength + 1) == tlength){
        length = true;
    }

    for(int i=0;i<slength;i++){
        if(s[i]!=t[i]) judge=false;
    }

    if(length==true && judge == true){
        cout << "Yes" << endl;
        return 0;
    }

    cout <<"No" << endl;
    return 0;

}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;
  cin >> k;
  vector<unsigned long long> vec = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  int i = 0;
  while (vec.size() < k) {
    if (vec.at(i) % 10 == 0) {
      unsigned long long x = vec.at(i)*10;
      vec.push_back(x);
      vec.push_back(x+1);
    }
    else if (vec.at(i) % 10 == 9) {
      unsigned long long y = vec.at(i)*10 + vec.at(i)%10;
      vec.push_back(y-1);
      vec.push_back(y);
    }
    else {
      unsigned long long z = vec.at(i)*10 + vec.at(i)%10;
      vec.push_back(z-1);
      vec.push_back(z);
      vec.push_back(z+1);
    }
    i++;
  }
  cout << vec.at(k-1) << endl;
}

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

#define ll long long
#define ar array

int main() {

    ios::sync_with_stdio(false);
    
  	int a, b, c, k, d;
  	
  	cin >> a >> b >> c >> k;
  	
  	d=max(max(a,b),c);
  	
  	for(int i=0;i<k;i++){
  		d=d*2;
	  }
  	
  	cout << a+b+c-max(max(a,b),c)+d <<endl;
  	
  	
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

lis=sorted(LI())
count=0
while lis[0]+2<lis[2]:
    lis[0]+=2
    count+=1
while lis[1]+2<lis[2]:
    lis[1]+=2
    count+=1
#print(count)
#print(lis)
u=lis[0]
for i in range(3):
    lis[i]-=u
#print(lis)
ad=3
if lis==[0,0,0]:
    ad=0
elif lis==[0,0,1]:
    ad=1
elif lis==[0,1,1]:
    ad=2
elif lis==[0,1,2]:
    ad=3
elif lis==[0,0,2]:
    ad=2
elif lis==[0,2,2]:
    ad=1
print(count+ad)

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

inline void chmin(ll &x, ll y) {
	if (x >= y) x = y;
}

const int MN = 5010;
const ll INF = 1e18;

int N;
ll A[MN];
vi g[MN];
int u[MN];
vector<ll> dp[MN][2][2];
int sz[MN];

void dfs(int v, int par) {
	sz[v] = 1;
	int c = 0;

	for (int to : g[v]) if (to != par) {
		dfs(to, v);
		sz[v] += sz[to];
	}

	int p = 0, q = 1;

	rep(t, 2) {
		rep(k, 2) {
			dp[v][t][k].resize(sz[v] + 1);
			rep(j, sz[v] + 1) {
				dp[v][t][k][j] = INF;
			}
		}
	}

	dp[v][0][A[v] < 0][0] = A[v];

	for (int to : g[v]) if (to != par) {
		rep(j, sz[v] + 1) rep(k, 2) dp[v][q][k][j] = INF;

		for (int i = 0; i <= c; ++i) {
			rep(f, 2) if (dp[v][p][f][i] != INF) {	
				for (int j = 0; j <= sz[to]; ++j) {
					rep(k, 2) if (dp[to][u[to]][k][j] != INF) {
						chmin(dp[v][q][f | k][i + j], dp[v][p][f][i] + dp[to][u[to]][k][j]);
						if (k == 0 || dp[to][u[to]][k][j] < 0) {
							chmin(dp[v][q][f][i + j + 1], dp[v][p][f][i]);
						}
					}
				}
			}
		}

		c += sz[to];
		swap(p, q);
	}

	u[v] = p;
}

int main() {
	cin >> N;
	rep(i, N) cin >> A[i];
	rep(i, N-1) {
		int a, b; cin >> a >> b;
		--a; --b;
		g[a].pb(b); g[b].pb(a);
	}
	dfs(0, -1);

	int ans = N;

	rep(j, MN) {
		if (dp[0][u[0]][0][j] != INF) {
			ans = j;
			break;
		}
		if (dp[0][u[0]][1][j] < 0) {
			ans = j;
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 327424
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    int n,k; cin >> n >> k;
    string s; cin >> s;
    k--;
    if(s[k]=='A') s[k] = 'a';
    if(s[k]=='B') s[k] = 'b';
    if(s[k]=='C') s[k] = 'c';
    cout << s << '\n';
    
}


Measured memory_bytes: 3596
#include <stdio.h>

int	main(void)
{
	unsigned int	A, B;
	unsigned int	sum;

	scanf("%u %u", &A, &B);
	if (A == B)
		printf("IMPOSSIBLE\n");
sum = A + B;
	if (sum % 2 == 0)
		printf("%d\n", sum / 2);
	else
		printf("IMPOSSIBLE\n");
	return (0);
}


Measured memory_bytes: 1660
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()
#define pb push_back

typedef long long ll;
const int inf = 1e9 + 7;
//const ll infll = 1 << 60;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

// 型による変数のオーバーフローに気をつけろ！！
// 悩んだら図やグラフを書け！！悩む前から書け！！

int n, a, b, c;
vector<int> l;

int dfs(int sum,int anum, int bnum, int cnum) {
	//cout << sum  << " " << anum << " " << bnum << " " << cnum<< endl;
	if (sum == n) {
		if (min(anum, bnum) == 0 || cnum == 0) return inf;
		return abs(a - anum) + abs(b - bnum) + abs(c - cnum) - 30;
	}

	int goNothing = dfs(sum + 1, anum, bnum, cnum);
	int goA = dfs(sum + 1, anum + l[sum], bnum, cnum) + 10;
	int goB = dfs(sum + 1, anum, bnum + l[sum], cnum) + 10;
	int goC = dfs(sum + 1, anum, bnum, cnum + l[sum]) + 10;

	int m = min(goNothing, goA);
	m = min(m, goB);
	//cout << m << endl;
	return min(m, goC);
}

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

	//int a, b, c;
	cin >> n >> a >> b >> c;
	rep(i, n) {
		int temp;
		cin >> temp;
		l.push_back(temp);
	}

	// 全探索する
	int ans = dfs(0, 0, 0, 0);
	cout << ans << endl;

	
	return 0;
}

Measured memory_bytes: 384
import math
import itertools
import collections
import bisect
import heapq

def IN(): return int(input())
def sIN(): return input()
def MAP(): return map(int,input().split())
def LMAP(): return list(map(int,input().split()))
def TATE(n): return [input() for i in range(n)]

n = IN()
a = LMAP()
ans = []
yama1 = 0

for i in range(n):
  if i%2 == 0:
    yama1 += a[i]
  else:
    yama1 += a[i]*(-1)
    
ans.append(yama1)

for i in range(1,n):
  ans.append(2*a[i-1] - ans[i-1])
  
print(*ans)

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n, l;
	cin >> n >> l;
	vector<string> s(n);
	rep(i, n) cin >> s[i];

	set<string> st;
	map<string, int> m;
	rep(i, n){
		st.insert(s[i]);
		m[s[i]]++;
	}

	for(auto t : st){
		rep(i, m[t]){
			cout << t;
		}
	}
	cout << endl;
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;
    int len = (int)s.length();
    vector<int> r(26), rp(26);
    rep(i, 26){
        r[i] = -1;
        rp[i] = -1;
    }
    
    rep(i, len){
        int si = s[i] - 97;
        int ti = t[i] - 97;
        if(r[si] == -1) r[si] = ti;
        else if(r[si] != ti){
            cout << "No" << el;
            return 0;
        }
        if(rp[ti] == -1) rp[ti] = si;
        else if(rp[ti] != si){
            cout << "No" << el;
            return 0;
        }
    }
    cout << "Yes" << el;
}


Measured memory_bytes: 776
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
a=Counter(a)
v=list(a.values())
if len(v)>3:
    print("No")
elif len(v)==1:
    if a[0]>0:
        print("Yes")
    else:
        print("No")
elif n%3!=0:
    print("No")
elif len(v)==2:
    if a[0]==n//3:
        print("Yes")
    else:
        print("No")
else:
    if v==[n//3,n//3,n//3]:
        aa=list(a.keys())
        if aa[0]^aa[1]==aa[2] or aa[0]^aa[2]==aa[1] or aa[1]^aa[2]==aa[0]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

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

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for (int a = 1; a < n; a++) {
        ans += (n - 1) / a;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
#define MAX_M 100000
const int INF = 1e9;
#define PI 3.141592653589793
int main(){
  int long long s;
  cin>>s;
  if(s<pow(10,9)){
    cout<<0<<" "<<0<<" "<<s<<" "<<0<<" "<<0<<" "<<1<<endl;
    exit(0);
  }
  int en=pow(10,9);
  int long long y=(en-(s+en)%en)%en;
  int long long x=(s+y)/en;
  cout<<0<<" "<<0<<" "<<en<<" "<<1<<" "<<y<<" "<<x<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define vl vector<long long>
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
/******************************define**********************************/

const int RANGE = 50;
/*****************************functions********************************/
long long ans[RANGE];
/****************************main function*****************************/
int main(void){
    long long k;cin >> k;
    ll n = k/RANGE;
    k %= RANGE;
    for(int i = 0;i < RANGE;i++) ans[i] = i;
    for(int i = 0;i < RANGE;i++) ans[i] += n;
    for(int i = 0;i < k;i++){
        ans[i] += RANGE;
        for(int j = 0;j < RANGE;j++){
            if(j == i) continue;
            else ans[j] -= 1;
        }
    }
    printf("%d\n",RANGE);
    for(int i = 0;i < RANGE;i++) cout << ans[i] << " ";
  	cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template <typename T> inline
#define USE2(T, U) template <typename T, typename U> inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
 
template<typename T> using vec = std::vector<T>;
template<typename T> using withi = std::pair<T, int>;
using ll = long long;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE2(T,U=withi<T>)vec<U>zipi(const vec<T>&x,int s=0){int N=x.size();vec<U>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  string dir;
  while (cin >> dir, dir != "#") {
    ll nume = 0, deno = 1;
    vector<int> north;
    for (int i = 0; i < dir.size(); i += 4) {
      char d = dir[i];
      if (d == 'n') {
        north.push_back(1);
        i++;
      } else {
        north.push_back(0);
      }
    }
    reverse(ALL(north));
    rep(i, north.size()) {
      if (i == 0) {
        if (north[i]) {
          nume = 0;
        } else {
          nume = 90;
        }
      } else {
        nume *= 2;
        deno *= 2;
        if (north[i]) {
          nume -= 90;
        } else {
          nume += 90;
        }
      }
    }
    ll gcd = __gcd(nume, deno);
    nume /= gcd;
    deno /= gcd;
    if (deno == 1) {
      cout << nume << endl;
    } else {
      cout << nume << "/" << deno << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  bool judge = true;
  map<int, int> cond;
  for(int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if(s == 0 && c == 0 && N >= 2) {
      judge = false;
      break;
    }
    else if(!cond.count(s)) {
      cond[s] = c;
    }
    else if(cond.count(s) && c != cond.at(s)) {
      judge = false;
      break;
    }
  }
  if (!judge) {
    cout << -1 << endl;
  }
  else if (N >= 2) {
    for(int i = 0; i < N; i++) {
      if(cond.count(i)) {
        cout << cond.at(i);
      }
      else if(i == 0) {
        cout << 1;
      }
      else{
        cout << 0;
      }
    }
    cout << "" << endl;
  }
  else {
    if(cond.count(0)) {
      cout << cond.at(0) << endl;
    }
    else {
      cout << 0 << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll k;
	cin>>k;
	ll now=0;
	for(int i=1;i<=k;i++){
		now=now*10+7;
		now%=k;
		if(now==0){
			cout<<i;
			return 0;
		}
	}
	cout<<-1;
	return 0;
}


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

template <ll mod> class modint
{
private:
    ll x;
public:
    modint(ll a = 0) : x(a % mod) {}
    modint& operator+=(const modint rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint& operator-=(const modint rhs) {
        if ((x += mod - rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint& operator*=(const modint rhs) {
        (x *= rhs.x) %= mod;
        return *this;
    }
    modint& operator/=(const modint rhs) {
        ll exp = mod - 2;
        while (exp) {
            if (exp % 2) *this *= rhs;
            rhs *= rhs; exp /= 2;
        }
        return *this;
    }
    modint operator+(const modint rhs) const {return modint(*this) += rhs;}
    modint operator-(const modint rhs) const {return modint(*this) -= rhs;}
    modint operator*(const modint rhs) const {return modint(*this) *= rhs;}
    modint operator/(const modint rhs) const {return modint(*this) /= rhs;}
    friend ostream& operator<<(ostream& os, const modint<mod>& m) {
        os << m.x;
        return os;
    }
};
using mint = modint<1000000007>;

int main()
{
    int N, M;
    cin >> N >> M;
    
    //i段目が踏めるかどうか
    vector<bool> can_step(N, true);
    for (int i = 0; i < M; i++)
    {
        int a;
        cin >> a;
        can_step[a] = false;
    }
 
    vector<mint> dp(N + 1, 0);
    dp[0] = 1;
 
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j <= min(i + 2, N); j++)
        {
            if (can_step[j])
            {
                dp[j] += dp[i];
            }
        }
    }
 
    cout << dp[N] << endl;   
    return 0;
}

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

int main(){
  string a,b,c,d,e;
  int f,g,h,i,j;
  cin>>a>>f;
  for(int k=0;k<f;k++){
    cin>>b>>g>>h;
    if(b=="print"){
      cout <<a.substr(g,h-g+1)<<endl;
    }else if(b=="reverse"){
      c=a.substr(g,h-g+1);
	e=c;
	for(int q=0;q<h-g+1;q++){
		c[q]=e[e.length()-q-1];}
      for(int l=g;l<=h;l++){
	a[l]=c[l-g];
      }
    }else if(b=="replace"){
      cin>>d;
      i=g;
      for(int l=g;l<=h;l++){
	a[l]=d[l-i];
      }
    }
   }
  return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
#define ll long long
#define ld long double
#define ms(a,v) memset(a,v,sizeof a)
#define pii pair<int, int>
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor
 *
 * */
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n; scanf("%d", &n);
	double d, ans=0.00000;
	for (int i=0; i<n; ++i){
		scanf("%lf", &d);
		ans+= 1.000000/d;
	}
	printf("%.6lf", 1.000000/ans);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

#include <bits/stdc++.h>


using namespace std;

#define INPUT_INT(valName) int valName; cin >> valName
#define INPUT_LLINT(valName) long long int valName; cin >> valName;
#define INPUT_STR(valName) string valName; cin >> valName;
#define INPUT_LINE(valName) string valName; getline(cin,s);
#define INPUT_VECTOR_INT(valName, N) vector<int> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }
#define INPUT_VECTOR_DOUBLE(valName, N) vector<double> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }

#define OUTPUT(A) cout << (A) << endl;
#define OUTPUT2(A, B) cout << (A) << " " << (B) << endl;
#define OUTPUT3(A, B, C) cout << (A) << " " << (B) << " " << (C) << endl;

#define REP(valName, N) for(int valName = 0; valName < N; ++valName)

vector<string> split(const string& str, char delimiter) {
	vector<string> ret;
	string tmp = "";
	for (auto c : str) {
		if (c != delimiter) {
			tmp.push_back(c);
		} else {
			ret.push_back(tmp);
			tmp = "";
		}
	}
	ret.push_back(tmp);
	return ret;
}

template <typename T> void sortAsc(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> void sortDesc(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }

template <typename T> void insert(vector<T>& dest, const vector<T>& src) { copy(src.begin(), src.end(), back_inserter(dest)); }

template <long long int MOD> long long int mod_inv(long long int a) {
	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;
	return u;
}

template <long long int MOD> long long int mod_add(long long int a, long long int b) {
	return (a + b) % MOD;
}

template <long long int MOD> long long int mod_sum(long long int a, long long int b) {
	return (a - b) % MOD;
}

template <long long int MOD> long long int mod_mul(long long int a, long long int b) {
	return (a % MOD) * (b % MOD) % MOD;
}

template <long long int MOD> long long int mod_mul(long long int a, long long int b, long long int c) {
	return mod_mul<MOD>(a, mod_mul<MOD>(b, c));
}

template <long long int MOD> long long int mod_div(long long int a, long long int b) {
	return (a % MOD) * mod_inv<MOD>(b) % MOD;
}


//------------------------------------------------------------------------------------------------------------------------------


int main() {

	INPUT_STR(S);
	INPUT_STR(T);

	int n = 0;
	for (int i = 0; i < 3; ++i) {
		if (S[i] == T[i]) ++n;
	}

	OUTPUT(n);

	return 0;
}

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

int main(void){
  string s;
  cin >> s;
  int min = 999;
  for(int i = 0; i <s.length()-2; i++){
    string t = s.substr(i,3);
    min = min < abs(753-stoi(t)) ? min : abs(753-stoi(t));    
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

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

const long double pi = 3.141592653589793;

#define debug(x) cerr << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

int main() {

    //freopen("input07.txt","r",stdin);
    //freopen("output_file_name.txt","w",stdout);

    ll n;cin>>n;
    ll A[n], sum = 0;
    rep(i, n) {
        cin>>A[i];
        sum += A[i];
    }

    if(sum % (n*(n+1)/2) != 0) {
        cout<<"NO";
        return 0;
    }

    ll k = sum / (n*(n+1)/2);

    rep(i, n) {
        ll d = A[i]-A[(n+i-1)%n];
        //debug(d);
        if((k-d)%n != 0 or (k-d) < 0) {
            cout<<"NO";
            return 0;
        }
    }

    cout<<"YES";

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    for (int i = 0; i <= 20000; i++) {
        if (i * 2 / 25 == a && i / 10 == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC76 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

n = int(input())
t = list(map(int,input().split()))
v = list(map(int,input().split()))

st = sum(t)
maxv = [0]
for i in range(n):
    maxv[-1] = min(maxv[-1],v[i])
    for _ in range(2*t[i]):
        maxv.append(v[i])
maxv[-1] = 0
for i in range(1,2*st+1):
    maxv[i] = min(maxv[i],maxv[i-1] + 0.5)
for i in range(2*st)[::-1]:
    maxv[i] = min(maxv[i],maxv[i+1] + 0.5)
ans = 0
for i in range(2*st):
    ans += (maxv[i] + maxv[i+1])*0.5 / 2
print(ans)


Measured memory_bytes: 41840
#include <iostream>

int main()
{
	int a, b, k;
	std::cin >> a >> b >> k;
	for( int i = a; i <= b; i++ ) {
		if( i < a + k or b - k < i ) {
			std::cout << i << std::endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll x,y,res;
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
} 
int main()
{
	x=read(),y=read();
	cout<<min(x%y,(y-(x%y))%y)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>

int main() {
    long long int n, t, max = 0;
    std::cin >> n;
    std::vector<long long> arr;
    for (long long int i = 0; i < n; i++) {
        std::cin >> t;
        arr.push_back(t);
        if (t > max) max = t;
    }

    long long int diff = max + 1, r;
    for (long long int i = 0; i < n; i++) {
        if (arr[i] == max) continue;
        t = std::abs(max - 2 * arr[i]);
        if (diff > t) {
            diff = t;
            r = arr[i];
        }
    }

    std::cout << max << " " << r << std::endl;

    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
#define int long long
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// 解説AC
struct UnionFind {
    vector<int> par;

    UnionFind (int n) : par (n, -1) {} //親は-1

    int root (int x) {
        if (par[x] < 0) return x; //自身が親
        else
            return par[x] = root (par[x]); //再帰
    }

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

    void merge (int x, int y) {
        x = root (x);
        y = root (y);
        if (x == y) return; //既に同じ根
        // xとyのサイズの大きいほうにまとめたい
        if (size (x) < size (y)) swap (x, y);
        par[x] += par[y]; //根のparは-(要素数)になる
        par[y] = x;       //親を更新
        return;
    }

    int size (int x) { return -par[root (x)]; }
};

signed main() {
    int n, m;
    cin >> n >> m;
    int p[n];
    rep (i, 0, n) {
        cin >> p[i];
        --p[i];
    }
    int x[m], y[m];
    UnionFind tree (n);
    rep (i, 0, m) {
        cin >> x[i] >> y[i];
        tree.merge (--x[i], --y[i]);
    }
    int ans = 0;
    rep (i, 0, n) {
        if (tree.same (i, p[i])) ans++;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 6336
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
int a, b;

//解法
void solve() {

	if (b >= a) {
		cout << a;
	}
	else {
		cout << a - 1;
	}

	return;
}

int main() {
	//入力
	cin >> a >> b;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
using System.Linq;
using System.Collections.Generic;
using System;

public class Katana
{
    public long a { get; set; }
    public long b { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var katanas = new List<Katana>();
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var h = long.Parse(line[1]);
        for (int i = 0; i < n; i++)
        {
            string[] line2 = Console.ReadLine().Trim().Split(' ');
            var a = long.Parse(line2[0]);
            var b = long.Parse(line2[1]);
            katanas.Add(new Katana { a = a, b = b });
        }
        var amax = katanas.Max(x => x.a);
        var count = 1;
        foreach (var x in katanas.Where(y => y.b > amax).OrderByDescending(y =>y.b))
        {
            h -= x.b;
            if (h <= 0) { Console.WriteLine(count); goto end; }
            count++;
        }
        var ret = h / amax;
        if (h % amax != 0) ret++;
        Console.WriteLine(ret + count -1);
        end:;
    }
}

Measured memory_bytes: 27336
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;

int main()
{
  int n;
  cin>>n;
  
  int hieght[n+1];
  int dp[n+1]={0};
  
  for(int i=1;i<=n;++i)
  {
    cin>>hieght[i];
  }
  dp[1]=0;
  for(int i=2;i<=n;++i)
  {
      ll a,b;
    
      a=abs(hieght[i]-hieght[i-1])+dp[i-1];
      
      b=i==2? INT_MAX:abs(hieght[i]-hieght[i-2])+dp[i-2];
       
       dp[i]=min(a,b);
  }
  
  cout<<dp[n]<<endl;
    return 0;
}
             

Measured memory_bytes: 4292
function main(input){
    let i = 0;
    let x = input.split('\n').map(Number);
    while(x[i] !== 0){
    console.log('Case ' + (i+1) + ': ' + x[i] );
    i += 1;
    }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 22548
object Main extends App {

  val mod = 1000000007L

  def mul(a: Long, b: Long): Long = {
    ((a % mod) * (b % mod)) % mod
  }

  def add(a: Long, b: Long): Long = {
    (a + b) % mod
  }


  val Array(n, m) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  var a = Array.fill(n + 3)(0)

  (1 to m).foreach { _ =>
    val aa = scala.io.StdIn.readLine.toInt
    a(aa) = -99
  }
  a(0) = 1
  //println(a.deep)

  (0 to n).foreach { i =>
    val cnt = a(i)
    if (cnt != -99) {
      if (a(i + 1) != -99) {
        a(i + 1) = add(a(i + 1), cnt).toInt
      }
      if (a(i + 2) != -99) {
        a(i + 2) = add(a(i + 2), cnt).toInt
      }
    }
  }

 // println(a.deep)
  println(a(n))
}

Measured memory_bytes: 35748
#include <cstdio>

int main() {
    int n, k, a, b;
    scanf("%d%d%d%d", &n, &k, &a, &b);

    int ans = 0;
    for (int i = 1; i <= n; i++)
        if (i <= k) ans += a;
        else ans += b;

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

    return 0;
}


Measured memory_bytes: 128
import itertools
import numpy as np
N,M,X=map(int,input().split())
ls = np.array([np.array(list(map(int,input().split()))) for i in range(N)])
# print(ls)
mn = -1
for i in range(1,1+N):
  for v in itertools.combinations(ls, i):
    #print(v)
    ln = len(v)
    ans = 0
    for k in range(ln):
      ans+=v[k]
    # print(ans)
    if np.count_nonzero(ans[1:] >= X) ==M:
      if mn == -1:
        mn = ans[0]
      else:
        mn = min(mn,ans[0])
    
print(mn)

Measured memory_bytes: 27276