akhauriyash/Code-Regression huggingface dataset:
"""

制約の小ささから見て全探索

"""

from itertools import product, accumulate
from bisect import *
import sys
input = sys.stdin.readline

H, W, K = map(int, input().split())
S = []
T = []
for i in range(H):
    S.append(list(map(int, input().strip())))
    T.append(list(accumulate([0] + S[-1])))

cnt_list = []
for a in product((0,1),repeat=H):
    past_a = a[0]
    T2 = [[0]*(W+1)]
    for i in range(H):
        if a[i] == past_a:
            for j, t in enumerate(T[i]):
                T2[-1][j] += t
        else:
            T2.append(T[i].copy())
        past_a = a[i]
    cnt = len(T2) - 1
    l = 0
    flg = False
    while True:
        temp = []
        for s in T2:
            temp.append(bisect_right(s[l+1:], K + s[l]) + l)
        if min(temp) == 0:
            flg = True
            break
        else:
            l = min(temp)
        if l >= W:
            break
        else:
            cnt += 1
    if not flg:
        cnt_list.append(cnt)

print(min(cnt_list))



Measured memory_bytes: 75056
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int add = 0;
		
		if(s.substring(0,1).equals("o")) {
			add += 100;
		}
		if(s.substring(1,2).equals("o")) {
			add += 100;
		}
		if(s.substring(2,3).equals("o")) {
			add += 100;
		}
		
		
		System.out.println(700 + add);
		
		sc.close();
	}
}

Measured memory_bytes: 23636
/*
       ()       ()()()()     ()        ()       ()        ()        ()
      ()()      ()     ()    ()()      ()      ()()       ()()      ()
     ()  ()     ()      ()   ()  ()    ()     ()  ()      ()  ()    ()
    ()()()()    ()      ()   ()    ()  ()    ()()()()     ()    ()  ()
   ()      ()   ()     ()    ()      ()()   ()      ()    ()      ()()
  ()        ()  ()()()()     ()        ()  ()        ()   ()        ()

*/
#include <bits/stdc++.h>
#define MOD 1e9+7
#define SIZE (int)1e5+5
#define all(x) x.begin(),x.end()

#define si(i)  scanf("%d",&i)
#define sf(f)  scanf("%f",&f)
#define pi(i)  printf("%d",i)
#define pd(d)  printf("%lf",d)
#define deb(x) cout<<#x<<" is "<<x<<"\n";
#define lb     lower_bound
#define ub     upper_bound
#define pb     push_back

#define IOfast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

int64_t exponentiation(int64_t base,int exp)
{
    if (exp == 0)
        return 1;

    if (exp == 1)
        return base;

    int64_t t = exponentiation(base, exp / 2);

    t = (t * t);

    if (exp % 2 == 0)
        return t;
    else
        return base * t;
}

int main()
{
  IOfast;
  

  int q=1;
  //cin>>q;
  //  memset(dp,-1,sizeof(dp));
  while(q--)
  {
    int n,k;
    cin>>n;
    int arr[n][3],value[n][3];
    
    memset(value,0,sizeof(value)); 
    
    for(int i=0;i<n;i++)
       cin>>arr[i][0]>>arr[i][1]>>arr[i][2]; 
    
    value[0][0] = arr[0][0];
    value[0][1] = arr[0][1];
    value[0][2] = arr[0][2];

    for(int i=1;i<n;i++)
    {
      value[i][0] = max(value[i-1][1],value[i-1][2])+ arr[i][0];
      value[i][1] = max(value[i-1][0],value[i-1][2])+ arr[i][1];
      value[i][2] = max(value[i-1][1],value[i-1][0])+ arr[i][2];
    }  
    cout<<max(value[n-1][0],max(value[n-1][1],value[n-1][2]));
  }
  
  return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>


#define INFTY 1000000001

int comp = 0;
int *L, *R;

void merge(int *A, const int left, const int mid, const int right) {
    int n1 = mid - left;
    int n2 = right - mid;

    for (int i = 0; i < n1; i++) {
        L[i] = A[left+i];
    }
    for (int i = 0; i < n2; i++) {
        R[i] = A[mid+i];
    }
    L[n1] = INFTY;
    R[n2] = INFTY;
    int i = 0;
    int j = 0;
    for (int k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i];
            i++;
            comp++;
        }
        else {
            A[k] = R[j];
            j++;
            comp++;
        }
    }
}

void merge_sort(int *A, const int left, const int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        merge_sort(A, left, mid);
        merge_sort(A, mid, right);
        merge(A, left, mid, right);
    }
    return;
}

int main (void) {

    int n;

    scanf("%d", &n);
    int* A = new int[n];
    L = new int[n];
    R = new int[n];

    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    merge_sort(A, 0, n);

    for (int i = 0; i < n; i++) {
        printf("%d", A[i]);
        if (i == n-1) printf("\n");
        else printf(" ");
    }
    printf("%d\n", comp);
}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  string s, t;
  cin >> s >> t;
  sort(ALL(s));
  sort(ALL(t)); reverse(ALL(t));
  if (s < t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sc scanf
using namespace std;
const int N=2e5+5;
const int mod=1e9+7;
typedef unsigned long long ull;
typedef long long ll;
template <typename it>int o(it a){cout<<a<<endl;return 0;}
int n;
pair<int,int>p[N];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        sc("%d%d",&p[i].second,&p[i].first);
    }
    sort(p+1,p+1+n,[](pair<int,int>x,pair<int,int>y){
        if(x.first==y.first)return x.second<y.second;
        return x.first<y.first;
    });
    if(p[1].first<p[1].second)return o("No");
    if(n==1)return o("Yes");
    ll finsh=p[1].second;
    int cnt=1;
    for(int i=2;i<=n;i++){
        if(finsh+p[i].second<=p[i].first){
            finsh+=p[i].second;
            cnt++;
        }
        else break;
    }
    if(cnt^n||finsh>p[n].first)o("No");
    else o("Yes");
}

Measured memory_bytes: 1792
def main():
    import sys
    input = sys.stdin.readline
    N, T = map(int, input().split())
    ab = [list(map(int, input().split())) for i in range(N)]
    ab.sort(key=lambda x: x[0])
    t = ab[-1][0]
    dp = [-1 for i in range(T+t + 1)]
    dp[0] = 0
    for a, b in ab:
        for i in range(T+t, 0, -1):
            if i >= a:
                if dp[i-a] >= 0 and i - a < T:
                    dp[i] = max(dp[i], dp[i-a] + b)

    for i in range(1, T+t+1):
        dp[i] = max(dp[i], dp[i-1])
    ans = dp[-1]

    # print(dp)
    print(ans)


main()


Measured memory_bytes: 42096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	int n, m, c;
	cin >> n >> m >> c;
	vvi a(n, vi(m));
	vi b(m);
	rep(i, m)cin >> b[i];
	rep(i, n)rep(j, m)cin >> a[i][j];
	int ans = 0;
	rep(i, n) {
		int d = c;
		rep(j, m)d += a[i][j] * b[j];
		if (d > 0)ans++;
	}
	cout << ans << endl;

}

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

int main()
{
	int a, b; cin >> a >> b;
	for (int i = 0; i <= 21; ++i)
	{
		if ((a * i)-(i-1) >= b)
		{
			cout << i;
			return 0;
		}
	}
	
}


Measured memory_bytes: 256
def main():
    result = sub()
    print(result)


def sub():
    N = int(input())
    Vs = [int(i) for i in input().split()]
    Cs = [int(i) for i in input().split()]

    res = 0
    for i in range(N):
        profit = Vs[i] - Cs[i]
        if profit > 0:
            res = res + profit
    return res


if __name__ == '__main__':
    main()


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

typedef pair<int, int> P;

const int MAX_N = 100000;
const int MAX_V = 1000000000;

int N;
vector<int> X(MAX_N);
vector<int> L(MAX_N);
  
int main() {
  int n; cin >> n;
  vector<int> x(n);
  vector<int> len(n);
  for (int i = 0; i < n; i++) cin >> x[i] >> len[i];
  
  vector<pair<int, int>> ran(n);
  for (int i = 0; i < n; i++) {
    ran[i].first = x[i] + len[i];
    ran[i].second = x[i] - len[i];
  }
  
  sort(ran.begin(), ran.end());
  
  int ans = 0;
  int cur = -MAX_V;
  for (int i = 0; i < n; i++) {
    if (cur <= ran[i].second) {
      ans++;
      cur = ran[i].first;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 5540
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T>
T pow_ (T x, T n, T M){
    uint64_t u = 1, xx = x;
    while (n > 0){
        if (n&1) u = u * xx % M;
        xx = xx * xx % M;
        n >>= 1;
    }
    return static_cast<T>(u);
};

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }



template <class T> class Factorial {
    T mod;
    vector<uint64_t> facts, factinv;

public:
    Factorial(int n, T mod) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)), mod(mod) {
        facts[0] = 1;
        for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*i % mod;
        factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod));
        for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * (i+1) % mod;
    }

    T fact(int k) const {
        if(k >= 0) return static_cast<T>(facts[k]);
        else return static_cast<T>(factinv[-k]);
    }

    T operator[](const int &k) const {
        if(k >= 0) return static_cast<T>(facts[k]);
        else return static_cast<T>(factinv[-k]);
    }

    T C(int p, int q) const {
        if(q < 0 || p < q) return 0;
        return static_cast<T>(facts[p]*  factinv[q] % mod * factinv[p-q] % mod);
    }

    T P(int p, int q) const {
        if(q < 0 || p < q) return 0;
        return static_cast<T>((facts[p] * factinv[p-q]) % mod);
    }

    T H(int p, int q) const {
        if(p < 0 || q < 0) return 0;
        return static_cast<T>(q == 0 ? 1 : C(p+q-1, q));
    }
};

int main() {
    int n, MOD;
    cin >> n >> MOD;
    auto S = make_v(n+1, n+1, 0LL);
    S[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            (S[i][j] += S[i-1][j]*(j+1)) %= MOD;
            if(j) (S[i][j] += S[i-1][j-1]) %= MOD;
        }
    }
    vector<ll> po(n+1), poo(n*n+1);
    po[0] = 2, poo[0] = 1;
    for (int i = 0; i < n; ++i) {
        po[i+1] = po[i]*po[i]%MOD;
    }
    for (int i = 0; i < n*n; ++i) {
        poo[i+1] = poo[i]*2%MOD;
    }
    Factorial<ll> f(n, MOD);
    ll ans = po[n];
    for (int i = 1; i <= n; ++i) {
        ll r = (i&1 ? MOD-1: 1)*f.C(n, i)%MOD*po[n-i]%MOD;
        ll rr = 0;
        for (int j = 0; j <= i; ++j) {
            (rr += S[i][j]*poo[j*(n-i)]) %= MOD;
        }
        (ans += r*rr) %= MOD;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 141056
#include <stdio.h>

int main(void) {
    int h, n, a[100000], sum = 0;
    int i, err;

    err = scanf("%d", &h);
    err = scanf("%d", &n);

    for (i = 0; i < n; i++) {
        err = scanf("%d", &a[i]);
        sum += a[i];
    }

    if (sum >= h) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
	int main()
{
	int H, W, i, j;
	scanf("%d %d", &H, &W);
	while(H != 0 && W != 0){
		for(i = 0; i < H; i++){
			for(j = 0 ; j < W; j++){
				if(i % 2 == 0){
					if(j % 2 == 0){
						printf("#");
					}else{
						printf(".");
					}
				}else if(i % 2 == 1){
					if(j % 2 == 0){
						printf(".");
					}else{
						printf("#");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
		scanf("%d %d", &H, &W);
	}
	return 0;
}

Measured memory_bytes: 572
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a := intScanner()
	b := intScanner()
	if a%2 == b%2 {
		fmt.Println((a + b) / 2)
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}


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

Measured memory_bytes: 21844
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
# sys.setrecursionlimit(2*pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


def calc(x):
    return ((a * x) // b) - (a * (x // b))


a, b, n = sp()
low, high = 1, n
answer, index = -inf, 0
while low <= high:
    mid = (low + high) // 2
    temp = calc(mid)
    if temp > answer:
        answer = temp
        low = mid + 1
    else:
        high = mid - 1
if n > pow(10, 7):
    for i in range(1, pow(10, 5)):
        answer = max(answer, calc(i))
    for i in range(n, n-pow(10, 5)-1, -1):
        answer = max(answer, calc(i))
out(answer)


Measured memory_bytes: 71704
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		adjmatrix = new int[n+1][n+1];
//		issearched = new boolean[n+1];
		d = new int[n+1];
		f = new int[n+1];

		for (int i=0; i < n; i++) {
			String[] list = br.readLine().split(" ");
			int u = Integer.parseInt(list[0]);
			int k = Integer.parseInt(list[1]);
			adjmatrix[u][0] = u;
			for (int j=0; j < k; j++) {
				int vi = Integer.parseInt(list[j+2]);
				adjmatrix[u][vi] = 1;
			}
		}
//		search(adjmatrix[1]);
//		System.out.println(Arrays.toString(adjmatrix[2]));
		for (int i=1; i <= n; i++) {
			search(adjmatrix[i]);
		}
		for (int i=1; i <= n; i++) {
			System.out.println(i + " " + d[i] + " " + f[i]);
		}
	}

	static int time = 0; // ??????

	static int[] d; // ??????i???????????????????????? d[i]

	static int[] f; // ??????i??????????????¢?´¢???????????? f[i]

	static int[][] adjmatrix; // ??£??\??????

//	static boolean[] issearched;

	// adjmatrix[i] = adjlist : ?????????????????¨?????£??\?????????
	// adjlist[0] = u : ????????£??\??????????????¨??????????????????
	// adjlist[i] (i=1,2,...,n) : ?????????????????????
	// ??????i??????????????\?¶????????????????????????????????????¨??????
	// adjlist[i] = 0 ????????°???????????¨????????????
	// adjlist[i] = 1 ????????°???????????¨?????????
	public static void search(int[] adjlist) {
		int u = adjlist[0];
//		issearched[u] = true;
		if (d[u] != 0) return; // ???????????¢?´¢??????????????°??????????????????
		/*
		 * ??????u?????????????????¢?´¢????????°????????????????????\???
		 * ?????????+1????????????????????¨???????????¨???
		 * ??£??\?????????????????¢?´¢????????????
		 */
		time++;
		d[u] = time;

		int n = adjlist.length - 1;
		for (int i=1; i <= n; i++) {
			if (adjlist[i] == 1) {
				search(adjmatrix[i]);
			}
		}
		/*
		 * ??£??\??????????????¨???????????????????????¨????????¢?´¢??????????????????
		 * ?????????+1????????¢?´¢??????????????¨???????????????????????????????????????
		 */
		time++;
		f[u] = time;
	}
}

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

int main(){
    int N,M;
    int L,R;
    int lmin=0,lmax=100000;
    int ans=0;
    cin >> N>>M;
    for(int i = 0;i < M;i++){
        cin >>L>>R;

        if(lmin<L)lmin=L;
        if(R<lmax)lmax=R;

    }
    ans=lmax-lmin+1;
    if(lmax<lmin)ans=0;
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int N = 0, Nq = 0;
    int i = 0, j = 0;
    int num = 0, digit = 1;

    scanf("%d", &N);
    Nq = N;

    for(i = 0; Nq != 0; i++){
        Nq = Nq/10;
    }

    if(i%2 == 0){
        for(j = 1; j <= i/2; j++){
            num += 9*digit;
            digit = 100*digit;
        }
    }else{
        for(j = 1; j <= i/2; j++){
            num += 9*digit;
            digit = 100*digit;
        }
        digit = 1;
        for(j = 1; j < i; j++){
            digit = 10*digit;
        }
        num += N - digit + 1;
    }
    printf("%d", num);
    return 0;

}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1e9 + 7;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy*/
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
string s;
signed main() {
	cin >> s;
	int ans = 0;
	for (int i = 0; i < s.size() - i - 1; i++) {
		if (s[i] != s[s.size() - i - 1]) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 888
#include <iostream>
#define MOD 1000000007
using namespace std;

int main() {
  long long N;
  cin >> N;
  long long A[N];
  for (long long i = 0; i < N; i++) cin >> A[i];
  
  long long pow_2[61];
  for (long long i = 0; i < 61; i++){
    if (i == 0) pow_2[i] = 1;
    else {
      pow_2[i] = pow_2[i - 1] * 2;
    }
  }
  
  long long count[61];
  long long count2[61];
  for (long long i = 0; i < 61; i++) count[i] = count2[i] = 0;
  
  for (long long i = 0; i < N; i++){
    for (long long j = 0; j < 61; j++){
      if (pow_2[60 - j] > A[i]) count[60 - j]++;
      else {
        count2[60 - j]++;
        A[i] -= pow_2[60 - j];
      }
    }
  }
  
  long long res = 0;
  for (long long i = 0; i < 61; i++){
    long long a = pow_2[i];
    a %= MOD;
    a *= (count[i] * count2[i]) % MOD;
    a %= MOD;
    res += a;
    res %= MOD;
  }
  
  cout << res << endl;
}

Measured memory_bytes: 5948
import java.io.*;

public class Main{
  public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line=null;
        while((line=br.readLine())!=null){
        	String[] array=line.split(" ");
        	int sum=Integer.parseInt(array[0])+Integer.parseInt(array[1]);
        	System.out.println(String.valueOf(sum).length());
        }
    }
}

Measured memory_bytes: 24048
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7; 

#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 out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF_INT (1<<30)
#define INF_LL (1ll<<62)

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

ll N,K,ans=0;

ll mod = 1000000007;
//---------------------------------------------------------------------------------------------------
ll f[101010], rf[101010];
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    repi(i, 1, 101010) f[i] = (f[i - 1] * i) % mod;
    repi(i, 0, 101010) rf[i] = inv(f[i]);
}
//---------------------------------------------------------------------------------------------------
ll C(ll n, ll k) {
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % mod;

    return (a * bc) % mod;
}

int main(){
    cin>>N>>K;
    ll A[N];
    ll l=0,r=N-1,nn=N-1;
    init();
    rep(i,N){
        cin>>A[i];
    }
    K--;
    sort(A,A+N,greater<ll>());
    while(nn>=K){
        ans=(ans+(C(nn,K)*((A[l]-A[r]+MOD)%MOD))%MOD)%MOD;
        l++;
        r--;
        nn--;
    }
    if(ans<0)out(ans+MOD);
    else out(ans%MOD);


    
    
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 
  
typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k, p;
string s, t;
ld w;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> k;
	cout << max({n+k,n-k,n*k});
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3648
// Problem: C - Connect Cities
// Contest: AtCoder - ACL Beginner Contest
// URL: https://atcoder.jp/contests/abl/tasks/abl_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
 
using namespace std;
#define int long long
#define ll long long
const int N = 1e5+5;
const int mod = 1e9;
#define ld long double
#define PI 3.14159265358979323846
#pragma GCC optimize("-O2")
const int INF = 10000000;

int getIInput() {
	cout.flush();
	#ifdef LOCAL
	return generateLocalInputOrAnythingYouWant();
	#else
	int x;
	cin>>x;
	return x;
	#endif
}

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(9);
}
 
//3. Structure or classes
//3. Ends here
 
//1. Data structures declaration here
//1. Ends here
 
//2. Extra Functions here
int n,m;
vector<int>adj[N];
bool vis[N];
void dfs(int node){
	vis[node]=1;
	for(auto i:adj[node]){
		if(vis[i]==1)continue;
		dfs(i);
	}
}
//2. Ends here
 
 
void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}
 
 
 
void solve()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int x,y;
		cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(vis[i]==1)continue;
		cnt++;
		dfs(i);
	}
	
	cout<<cnt-1<<"\n";
    return;
}
// how r u bro

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

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    ll ans;
    ans = min(a+b,b+c);
    ans = min(ans, a+c);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * https://abc067.contest.atcoder.jp/tasks/arc078_b
 */
public class Main {
	
	final static int BLACK=1;
	final static int WHITE=2;

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		Node[] nodes = new Node[N];
		for(int i=0; i<N; i++) nodes[i] = new Node(i);
		for(int i=0; i<N-1; i++){
			Node a = nodes[Integer.parseInt(sc.next())-1];
			Node b = nodes[Integer.parseInt(sc.next())-1];
			a.neighbor.add(b);
			b.neighbor.add(a);
		}
		sc.close();
		
		nodes[0].start = true;
		nodes[N-1].goal = true;
		int commonSize = dfs1(nodes[0],null)-1;
		Node optBlackNode = dfs2(nodes[0], commonSize/2 + commonSize%2, null, BLACK);
		Node optWhiteNode = dfs2(nodes[N-1], commonSize/2, null, WHITE);
		
		//System.out.println(optBlackNode.id);
		//System.out.println(optWhiteNode.id);
		
		
		int blackSize = dfs3(optBlackNode, null, WHITE);
		int whiteSize = dfs3(optWhiteNode,null, BLACK);
		
		//System.out.println(blackSize);
		//System.out.println(whiteSize);
		
		String ans = blackSize > whiteSize ? "Fennec" : "Snuke";
		System.out.println(ans);
		
	}

	private static int dfs3(Node node, Node parent, int opsColor) {
		int count = 1;
		for(Node n:node.neighbor){
			if(n==parent) continue;
			if(n.color == opsColor ) continue;
			count += dfs3(n,node,opsColor);
		}
		return count;
	}
	
	private static Node dfs2(Node node, int count, Node parent, int color) {
		if(count==0){
			node.color = color;
			return node;
		}
		for(Node n:node.neighbor){
			if(n==parent) continue;
			if(n.common){
				return dfs2(n,count-1,node,color);
			}
		}
		return null;
	}

	private static int dfs1(Node node, Node parent) {
		if(node.goal){
			return 0;
		}
		int size = -1;
		for(Node n:node.neighbor){
			if(n==parent) continue;
			int s = dfs1(n,node);
			if(s>=0){
				size = s+1;
				if(!n.goal && !n.start) n.common = true; 
				break;
			}
		}
		return size;
	}

	static class Node{
		int id;
		Set<Node> neighbor = new HashSet<>();
		boolean goal = false;
		boolean start = false;
		boolean common = false;
		int color = -1;
		Node(int id){
			this.id = id;
		}
	}

}


Measured memory_bytes: 98012
#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>;
#define chmax(x, y) { x = max(x, y); }
#define chmin(x, y) { x = min(x, y); }

int main() {
    string s;
    cin >> s;
    int size = s.size();
    int sum = 0;
    rep(i, size){
        sum += s.at(i) - '0';
    }
    if(sum % 9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3728
# 逆に公倍数を引く。B-A+1-(Cの倍数の数+Dの倍数の数-CとDの公倍数の数)
a, b, c, d = map(int, input().split())


def gcd(x, y):
    if x > y:
        return gcd(y, x)
    while x > 0:
        x, y = y % x, x
    return y


def lcm(x, y):
    return (x * y) // gcd(x, y)


aa = (a - 1) - ((a - 1) // c + (a - 1) // d - (a - 1) // lcm(c, d))
bb = b - (b // c + b // d - b // lcm(c, d))
print(bb-aa)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;

int main(){
    ll N;
    cin>>N;
    vll a(N);
    for(int i=0;i<N;i++) cin>>a[i];
    
    ll A=1;
    ll ans=0;
    for(int i=0;i<N;i++){
        if(a[i]==A){
            A++;
        }
        else{
            ans++;
        }
    }
    //printf("ans,A=%d,%d\n",ans,A);
    if(N-ans==A-1 && A!=1) cout<<ans<<endl;
    else cout<<-1<<endl;
    
    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define finp ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
long long int n,q,h,s,d,ans;
int main()
{
    finp;
    cin>>q>>h>>s>>d>>n;
    s=min(4*q,s);
    s=min(2*h,s);
    if(n%2==0)
        ans=min(n*s,(n/2)*d);
    else
        ans=min(n*s,(n/2)*d+s);
    cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
# abc162_a.py
# https://atcoder.jp/contests/abc162/tasks/abc162_a

# A - Lucky 7 /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# 3桁の整数 N が与えられます。N のいずれかの桁に数字の 7は含まれますか？
# 含まれるなら Yes を、含まれないなら No を出力してください。

# 制約
#     100≤N≤999

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N

# 出力
# Nのいずれかの桁に 7が含まれるなら Yes を、含まれないなら No を出力せよ。

# 入力例 1
# 117

# 出力例 1
# Yes

# 117は 1 の位が 7です。

# 入力例 2
# 123

# 出力例 2
# No

# 123は 7を含みません。

# 入力例 3
# 777

# 出力例 3
# Yes


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    if '7' in str(N):
        result = 'Yes'
    else:
        result = 'No'

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['117']
        lines_export = ['Yes']
    if pattern == 2:
        lines_input = ['123']
        lines_export = ['No']
    if pattern == 3:
        lines_input = ['777']
        lines_export = ['Yes']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<62;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    ll N,K; cin >> N >> K;
    vector<ll> w(N), d(N);
    REP(i,N) cin >> w[i] >> d[i];
    ll mx = 0; REP(i,N) chmax(mx, w[i]);

    ll l = 0, r = mx+(1e+9)*K, p = (l+r)/2;
    while(r-l > 1){
        ll tmp = 0;
        REP(i,N){
            if(p < w[i]) continue;
            tmp += (p-w[i])/d[i]+1;
        }
        if(tmp < K) l = p;
        else r = p;
        p = (l+r)/2;
    }
    ll ans = r;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#define Lens 10005
#define Inf 1<<22

using namespace std;
vector<pair<int, int> > adj[Lens];
int N;
char c[Lens];
int d[Lens];

void dijkstra()
{
	d[0] = 0;
	priority_queue<pair<int, int> > PQ;
	PQ.push(make_pair(0, 0));
	while (!PQ.empty())
	{
		pair<int, int> t = PQ.top();
		PQ.pop();
		int u = t.second;
		c[u] = 'b';
		if (d[u] < -t.first) continue;
		for (int i = 0; i < adj[u].size(); i++)
		{
			int tmp = adj[u][i].first;
			if (c[tmp] == 'w'&&d[tmp] > d[u] + adj[u][i].second)
			{
				d[tmp] = d[u] + adj[u][i].second;
				PQ.push(make_pair(-d[tmp],tmp));
		//		cout << tmp << "  " << d[tmp] << endl;
			}
		}

	}
}

int main()
{

	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int k, n;
		cin >> k >> n;
		c[k] = 'w';
		d[k] = Inf;
		for (int j = 0; j < n; j++)
		{
			int v, tw;
			cin >> v >> tw;
			adj[k].push_back(make_pair(v, tw));
		}

	}
	dijkstra();
	for (int i = 0; i < N; i++)
	{
		cout << i << ' ' << d[i] << endl;;
	}
	return 0;
}


Measured memory_bytes: 8028
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
bool a[500][500] = {};
char c[500][500];
bool search(int x,int w,int h,int y) {
	if (x < 0 || x >= w || y < 0 || y >= h) {
		return false;

	}
	else if (c[y][x] == '#') {
		return false;
	}
	if (a[y][x] == true) {
		return false;
	}
	if (c[y][x] == 'g') {
		return true;
	}
	a[y][x] = true;
	if (search(x + 1, w, h, y) || search(x - 1, w, h, y) || search(x, w, h, y + 1) || search(x, w, h, y - 1)) {
		return true;
	}
	else {
		return false;
	}

}

//小文字=大文字+32
int main() {
	int n, d;
	cin >> n >> d;
	vector<vector<int>>x(n,vector<int>(d));
	ll tmp;
	rep(i, n) {
		rep(j, d) {
			cin >> x[i][j];
		}
	}
	ll ans=0;
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			tmp = 0;
			rep(k, d) {
				tmp += pow(x[i][k] - x[j][k], 2);
			}
			if (pow(tmp, 0.5) ==(ll)pow(tmp, 0.5)) {
				ans++;
			}
		}
	}
	cout << ans;
}
	



Measured memory_bytes: 4024
s=str(input())
def solve(s):
  while (s!=""):
    if s[-5:] in ["dream","erase"]:
      s=s[:-5]
    elif s[-7:]=="dreamer":
      s=s[:-7]
    elif s[-6:]=="eraser":
      s=s[:-6]
    else:
      return "NO"
  return "YES"
print(solve(s))

Measured memory_bytes: 3316
import math
a, b, x = list(map(int, input().split()))
xx = x / a
if xx <= a * b / 2:
    print(90 - math.atan(2 * xx / b ** 2) * 180 / math.pi)
else:
    print(-math.atan(2 * (xx - a * b) / a ** 2) * 180 / math.pi)

Measured memory_bytes: 3060
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = Seq.fill(4)(sc.nextInt())
    println(
      if(n.sortBy(c => c) == Seq(1,4,7,9)) "YES" else "NO"
    )
  }
}

Measured memory_bytes: 25408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String w=br.readLine();
		w=w.toLowerCase();
		int cnt=0;
		int sw=0;
		int ln=0;
		while(sw==0){
			ln++;
			String str=br.readLine();
			if(str.equals("END_OF_TEXT")){ sw=1;break;}
			str=str.toLowerCase();
			String[] t=str.split(" ");
			for(int i=0;i<t.length;i++){
				if(t[i].equals(w))	{cnt++;}
			}
		}
		System.out.println(cnt);
		
	}

}

Measured memory_bytes: 17060
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime> 
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int MOD = 1e9 + 7;

int mul(int a, int b) {
	return 1LL * a * b % MOD;
}

int add(int a, int b) {
	return (a + b) % MOD;
}

int sub(int a, int b) {
	return (a - b + MOD) % MOD;
}

int binpow(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

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

	int n;
	cin >> n;
	int ans = binpow(10, n);
	{
		int c = 0;
		for (int i = 0; i < n; i++) {
			c = add(c, mul(binpow(8, i), binpow(9, n - 1 - i)));
		}
		c = mul(c, 2);
		ans = sub(ans, c);
	}
	ans = sub(ans, binpow(8, n));
	cout << ans << '\n';
}

Measured memory_bytes: 3196
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,m;
int fav[330][330];
int ma;
int cnt[330];
int rem[330];
int ans=0x3f3f3f3f;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)scanf("%d",&fav[i][j]);
	rem[0]=1;
	for(int t=1;t<=m;++t)
	{
		memset(cnt,0,sizeof(cnt));
		ma=0;
		for(int i=1;i<=n;++i)
		{
			while(rem[fav[i][fav[i][0]]]&&fav[i][0]<m)fav[i][0]++;
//			cout<<fav[i][0]<<" ";
			cnt[fav[i][fav[i][0]]]++;
			if(cnt[fav[i][fav[i][0]]]>cnt[ma])ma=fav[i][fav[i][0]];
		}
		ans=min(ans,cnt[ma]);
		rem[ma]=1;
//		cout<<endl;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
# coding: utf-8
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
KS = [lr() for _ in range(M)]
P = lr()
answer = 0
for pattern in itertools.product([0, 1], repeat=N):
    bl = True
    for i in range(M):
        if sum(pattern[x-1] for x in KS[i][1:]) % 2 != P[i]:
            bl = False
            break
    if bl:
        answer += 1

print(answer)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		long n = sc.nextLong();
		long m = n - 1;
		long res = ((1 + m) * m)/2;
		System.out.println(res);
	}

    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 22996
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <bitset>
#include <list>
#include <iomanip>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
#define all(s) s.begin(),s.end()
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;
bool pairCompare(const P& firstElof,const P& secondElof){
    return firstElof.second>secondElof.second;
}
string A="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string a="abcdefghijklmnopqrstuvwxyz";
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n,m;cin>>n>>m;
    ll a[n];
    vector<pair<ll,ll>> card(m);
    rep(i,0,n)cin>>a[i];
    rep(i,0,m)cin>>card[i].first>>card[i].second;
    sort(a,a+n);
    sort(all(card),pairCompare);
    //rep(i,0,n)cout<<a[i]<<" ";
    //cout<<endl;
    //rep(i,0,m)cout<<card[i].second<<" ";
    //cout<<endl;
    ll now=0;
    ll l=0;
    ll ans=0;
    rep(i,0,n){
        if(a[i]>card[l].second)break;
        a[i]=card[l].second;
        card[l].first--;
        if(card[l].first==0)l++;
        if(l==m)break;
    }
    //rep(i,0,n)cout<<a[i]<<" ";
    //cout<<endl;
    rep(i,0,n){
        ans+=a[i];
        //cout<<ans<<" ";
    }
    //cout<<endl;
    cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp);
void ipgraph(int m);
//void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
vector<int>adj[100005];
int dp[100005];
bool vis[100005];
int in_degree[100005];
void dfs(int src){
    vis[src]=true;    
    for(auto it:adj[src]){
        dp[it]=max(dp[it],dp[src]+1);
        --in_degree[it];
        if(in_degree[it]==0)dfs(it);
        }



}





int main(){
ios_base::sync_with_stdio(0);
ll int t,n,i,j,k,m;
t=1;
while(t--){
    cin>>n>>m;
    fo(i,m){
        int u,v;
        cin>>u>>v;
        //u--;
        //v--;
        adj[u].pb(v);
        in_degree[v]++;
}
//memset(dp,-1,sizeof dp);
int res=0,ans=0;
Fo(i,1,n+1){
//vector<int>vis(n,0);
res=0;
if(!vis[i]&&in_degree[i]==0)
dfs(i);



}
ans=*max_element(dp,dp+n+1);

    cout<<ans;
}

}


Measured memory_bytes: 14512