akhauriyash/Code-Regression huggingface dataset:
h, w = map(int, input().split())

sq = [input() for _ in range(h)]
up = [[0] * (w + 2) for _ in range(h + 2)]
down = [[0] * (w + 2) for _ in range(h + 2)]
left = [[0] * (w + 2) for _ in range(h + 2)]
right = [[0] * (w + 2) for _ in range(h + 2)]

ans = 0

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if sq[i - 1][j - 1] == '#':
            left[i][j] = 0
            up[i][j] = 0
        else:
            left[i][j] = left[i][j - 1] + 1
            up[i][j] = up[i - 1][j] + 1
for _i in range(h, 0, -1):
    for _j in range(w, 0, -1):
        if sq[_i - 1][_j - 1] == '#':
            right[_i][_j] = 0
            down[_i][_j] = 0
        else:
            right[_i][_j] = right[_i][_j + 1] + 1
            down[_i][_j] = down[_i + 1][_j] + 1

            temp = up[_i][_j] + down[_i][_j] + left[_i][_j] + right[_i][_j] 
            if temp > ans:
                ans = temp

print(ans - 3)


Measured memory_bytes: 178564
package main

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

var sc = bufio.NewScanner(os.Stdin)
var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func main() {
	s := readLine()
	s = strings.Replace(s, " ", "", -1)

	if strings.Count(s, "7") == 1 && strings.Count(s, "5") == 2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}

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

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		line, isPrefix, err := rdr.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
const int INF = 1e9;
const long long LINF = 1e18;


int main(){
  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  int ans = 0;
  map<int,int> T;
  T[X] = A;
  T[Y] = B;
  if(A+B <= 2*C) ans = A*X + B*Y;
  else{
    ans = min(min(X,Y)*C*2 + (max(X,Y) - min(X,Y))*T[max(X,Y)],max(X,Y)*C*2);
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
fun main(args: Array<String>) = yorukatsu15a()

fun yorukatsu15a() {
    val (n, l) = readLine()!!.split(' ').map { it.toInt() }

    val answer = (l until l + n).sum() - (l until l + n).minBy { Math.abs(it) }!!

    println(answer)
}


Measured memory_bytes: 38452
N, M, X = list(map(int, input().split()))
A_list = list(map(int, input().split()))

to_0_cost = len([A for A in A_list if A < X])
to_N_cost = len([A for A in A_list if A > X])

ans = min(to_0_cost, to_N_cost)

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main()
{
    int c=0,i=0,k,d,n=0,x,s[10010];
    cin>>x>>k;
    while(k--){
        cin>>d;
        n+=d;
        while(d--){
            cin>>s[i++];
        }
    }
    sort(s,s+n);
    c=0;
    for(i=0;i<n;i++){
        if(s[i]!=s[i+1]) c++;
    }
    cout<<x-c<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll dep(ll a,ll b){
	if(b==0){
		return a;
	}
	return dep(b,a%b);
}
int main() {
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=n;j++){
			for(ll k=1;k<=n;k++){
				ll now=dep(max(i,j),min(j,i));
				now=dep(max(now,k),min(k,now));
				ans+=now;
			}
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3596
s = input()
n = len(s)
k = int(input())
dp = [[[0 for _ in range(2)] for _ in range(k + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1
for a in range(n):
    for b in range(k + 1):
        for c in range(2):
            nd = int(s[a])
            for d in range(10):
                na, nb, nc = a + 1, b, c
                if d != 0:
                    nb += 1
                if nb > k:
                    break
                if nc == 0:
                    if d < nd:
                        nc = 1
                    if d > nd:
                        break
                dp[na][nb][nc] += dp[a][b][c]
print(sum(dp[-1][-1]))


Measured memory_bytes: 3064
# coding: utf-8
from itertools import permutations
from math import sqrt

def calc(x1, y1, x2, y2):
    return sqrt((x1-x2)**2 + (y1-y2)**2)

N = int(input())
X, Y = [], []
for i in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

ans = 0
for i in permutations(range(N)):
    for j in range(len(i)-1):
        ans += calc(X[i[j]], Y[i[j]], X[i[j+1]], Y[i[j+1]])

print(ans / len(list(permutations(range(N)))))

Measured memory_bytes: 7972
// import chie template :) {{{
import std.stdio,
       std.algorithm,
       std.array,
       std.string,
       std.math,
       std.conv,
       std.range,
       std.container,
       std.bigint,
       std.ascii;
// }}}
// tbh.scanner {{{
class Scanner {
  import std.stdio;
  import std.conv : to;
  import std.array : split;
  import std.string : chomp;

  private File file;
  private dchar[][] str;
  private uint idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  private dchar[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    dchar[] s;
    while (s.length == 0) {
      s = file.readln.chomp.to!(dchar[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(uint len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  int n, a, b;
  n = cin.next!int;
  a = cin.next!int;
  b = cin.next!int;
  writeln((a + b) & 1 ? "Borys" : "Alice");
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=201000;
int x;
char s[N];
void gao(int y) {
	rep(i,0,y) s[i]=')';
	rep(i,0,y) s[i+y]='(';
	s[y]=')'; s[y-(y*(y+1)/2-x)]='(';
	puts(s);
}
int main() {
	scanf("%d",&x);
	for (int i=1;i<=100000;i++) if (i*(i+1)/2>=x) {
		gao(i);
		return 0;
	}
}

Measured memory_bytes: 2748
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

template<class T>
void print(const T &value) {
    std::cout << value << std::endl;
}

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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

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

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    ll N;
    int ans = 100;
    cin >> N;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i != 0) { continue; }
        ll j = N / i;
        int digit = 0;
        while (j > 0) {
            j /= 10;
            digit++;
        }
        ans = min(ans, digit);
    }
    print(ans);
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;


int n;
int dfs(int val,int flag,int ans){
    if(val > n) return ans;
    if(flag == 7) ans++;
    if(val > 100000000) return ans;
    ans=dfs(10*val+3,flag|1,ans);
    ans=dfs(10*val+5,flag|2,ans);
    ans=dfs(10*val+7,flag|4,ans);
    return ans;
}

int main(){
    scanf("%d", &n);
    printf("%d", dfs(0,0,0));
}


Measured memory_bytes: 1736
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
    string[] nums = new string[2*n];
    bool check = true;
    int answer = 0;
		for(int i = 0; i < n; i++)
    {
      nums[i] = Console.ReadLine();
      nums[n+i] = nums[i];
    }

    for(int i = 0; i < n; i++)
    {
      check = true;
      for(int j = 0; j < n-1; j++)
      {
        for(int k = j+1; k < n; k++)
        {
          if(nums[j+i][k] != nums[k+i][j]) check = false;
        }
      }
      if(check) answer += n;
    }

		Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。
	}
}

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

typedef long long int int64;

void run(void){
  int n,a,b,c,d;
  scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
  int i;
  for(i=0;i<n;i++){
    int64 max=a+(int64)(n-1-i)*d-(int64)i*c;
    int64 min=a+(int64)(n-1-i)*c-(int64)i*d;
    if(min<=b && b<=max){
      puts("YES");
      return;
    }
  }
  puts("NO");
}

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

Measured memory_bytes: 128
// 写経　of ぺぺ
#include <bits/stdc++.h>

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

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

	ll x = 0, s = 0;
	int l = 0, r = 0;
	ll ans = 0;
	for(; l < n; ++l){
		while(r < n && (x^a[r]) == (s+a[r])){
			x^=a[r];
			s+=a[r];
			r++;
		}
		ans += r-l;
		x ^= a[l];
		s -=a[l];
	}
	cout << ans << endl;
}


Measured memory_bytes: 4840
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,m = [int(i) for i in readline().split()]

x = m
y = m+1
if n%2==1:
    for i in range(m):
        print(x-i,y+i)
else:
    num = 0
    while 1+num*2 < n//2 and num < m:
        print(x-num,y+num)
        num += 1
    while num < m:
        print(x-num,y+num+1)
        num += 1


Measured memory_bytes: 9280
#include<stdio.h>

int main(void){
  int a,b,c ,Stac;
  scanf("%d %d %d", &a, &b, &c);
  if(a>b) {Stac=a; a=b; b=Stac;}
  if(b>c) {Stac=b; b=c; c=Stac;}
  if(a>b) {Stac=a; a=b; b=Stac;}
  printf("%d %d %d\n", a, b, c);
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <complex>

using Real = long double;
using Point = std::complex<Real>;
using Segment = std::pair<Point, Point>;

const Real PI = acos(-1);
const Real EPS = 1e-10;

std::istream& operator>>(std::istream& is, Point& p) {
    Real x, y;
    is >> x >> y;
    p = Point(x, y);
    return is;
}

inline int compare(Real a, Real b) {
    if (std::abs(a - b) < EPS) return 0;
    return a - b > 0 ? 1 : -1;
}

inline Real dist(Point a, Point b) {
    return std::abs(a - b);
}

inline Real dot(Point x, Point y) {
    return std::real(std::conj(x) * (y));
}


using namespace std;

int main() {
    int N;
    Real r, theta;
    cin >> N >> r >> theta;
    theta *= PI / 180;

    vector<Point> ps(N);
    for (auto& p : ps) cin >> p;

    vector<vector<Real>> d(N * N, vector<Real>(N * N, 1e50));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i == j) continue;
            for (int k = 0; k < N; ++k) {
                if (j == k) continue;

                Real costheta = dot(ps[j] - ps[i], ps[k] - ps[j]) / (dist(ps[j], ps[i]) * dist(ps[k], ps[j]));
                if (costheta < -1) costheta += EPS;
                if (costheta > 1) costheta -= EPS;
                if (compare(acos(costheta), theta) > 0) continue;

                d[i * N + j][j * N + k] = dist(ps[j], ps[k]);
            }
        }
    }

    vector<vector<Real>> dp(N * N, vector<Real>(10001, 1e100));
    // dp[i][j][n] = 直前i、今jにいて、既にk箇所訪れたときの最短距離

    for (int i = 1; i < N; ++i) {
        dp[i][1] = dist(ps[0], ps[i]);
    }

    for (int n = 1; n < 10000; ++n) {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                if (i == j) continue;
                for (int k = 0; k < N; ++k) {
                    if (j == k) continue;

                    dp[j * N + k][n + 1] = min(dp[j * N + k][n + 1], dp[i * N + j][n] + d[i * N + j][j * N + k]);
                }
            }
        }
    }

    int ans = 0;
    for (int v = 0; v < N * N; ++v) {
        for (int n = 0; n <= 10000; ++n) {
            if (compare(dp[v][n], r) <= 0) ans = max(ans, n);
        }
    }

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



Measured memory_bytes: 69816
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    ll a[4];
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    sort(a,a+4);
    if(a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) cout << "YES" << endl;
    else cout << "NO" << endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
double dp[100010];
double ans[100010];
double er(double x, int exp) 
{
     if( exp==0 )
     {
          return 1.0;
     }
     double ret = er(x, exp>>1);
     ret = (ret*ret);
     if( exp & 1 ) {
          ret = (ret*x);
     }
     return ret;
}
void init(){
	memset(dp,0.0,sizeof(dp));
	dp[0]=0;
	for(int i=1;i<=100000;i++){
		dp[i]+=1-dp[i-1];
		for(int j=i+1;j<=100000 && j<i+20;j++){
			dp[j]+=(1-dp[i-1])*er(0.5,(j-i+1)*(j-i)/2);
		}
		//cout<<i<<" "<<dp[i]<<endl;
	}
	memset(ans,0.0,sizeof(ans));
	ans[1]=1.0;
	for(int i=2;i<=100000;i++){
		ans[i]=ans[i-1]+dp[i];
	}
}
int main(){
	int i,j;
	init();
	while(scanf("%d",&n) && n){
		printf("%.8lf\n",ans[n]);
	}
}

Measured memory_bytes: 2780
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;
static class Extensions
{
    public static int ToInt(this string s) => int.Parse(s);
    public static long ToLong(this string s) => long.Parse(s);
    public static char ToChar(this string s) => char.Parse(s);
    public static double ToDouble(this string s) => double.Parse(s);
    public static int[] ToIntArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToInt()).ToArray();
    public static long[] ToLongArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToLong()).ToArray();
    public static double[] ToDoubleArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToDouble()).ToArray();
    public static Queue<T> ToQueue<T>(this IEnumerable<T> seq) => new Queue<T>(seq);
    public static Stack<T> ToStack<T>(this IEnumerable<T> seq) => new Stack<T>(seq);
}

class Program
{
    static string[] ReadLines(int n) => Enumerable.Range(0, n).Select(s => Console.ReadLine()).ToArray();

    static void Main()
    {
        int[] nl = Console.ReadLine().ToIntArray();
        int N = nl[0];
        int L = nl[1];

        int origin = (L - 1) * N + Enumerable.Range(1, N).Sum();

        int currentDif = int.MaxValue;
        int currentAns = 0;

        for(int i = 1; i <= N; i++)
        {
            int xx = origin - (L + i - 1);
            var dif = Math.Abs(xx - origin);
            if (currentDif > dif)
            {
                currentDif = dif;
                currentAns = xx;
            }
        }

        Console.WriteLine(currentAns);
    }
}

Measured memory_bytes: 13396
#include <stdio.h>
#include <math.h>

double distance(double, double, double, double);

int main() {
    double x1, y1, x2, y2, ans;

    scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);

    ans = distance(x1, y1, x2, y2);

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

    return 0;
}


double distance(double x1, double y1, double x2, double y2) {
    double l, xx, yy;

    xx = (x1 - x2) * (x1 - x2);
    yy = (y1 - y2) * (y1 - y2);

    l = sqrt(xx + yy);

    return l;
}



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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N=0;
    string S,T;
    cin >> S>>T;

    REP(i,S.size()){
        if(!(S.at(i)==T.at(i))){
            N++;
        }
    }
    cout << N << endl;

}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int n = s.size();
    int cntB = 0;
    ll ans = 0;
    rep(i, n) {
        if (s[i] == 'B') cntB++;
        else ans += cntB;
    }
    cout << ans << endl;
}

Measured memory_bytes: 720
using System;
using System.Linq;

namespace atcoder
{
    public class atcoder
    {
        public static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int x1 = input[0], y1 = input[1], x2 = input[2], y2 = input[3];
            int n = Math.Abs(x1 - x2),m = Math.Abs(y1 - y2);
            if (x1 < x2 && y1 < y2) 
            {
                int x3 = x2 - m, y3 = y2 + n;
                Console.WriteLine($"{x3} {y3} {x3 - n} {y3 - m}");
            } else if (x1 > x2 && y1 < y2)
            {
                int x3 = x2 - m, y3 = y2 - n;
                Console.WriteLine($"{x3} {y3} {x3 + n} {y3 - m}");
            } else if (x1 > x2 && y1 > y2)
            {
                int x3 = x2 + m, y3 = y2 - n;
                Console.WriteLine($"{x3} {y3} {x3 + n} {y3 + m}");
            }  else if (x1 < x2 && y1 > y2)
            {
                int x3 = x2 + m, y3 = y2 + n;
                Console.WriteLine($"{x3} {y3} {x3 - n} {y3 + m}");
            }  else if (x1 == x2 && y1 < y2)
            {
                int x3 = x2 - m, y3 = y2;
                Console.WriteLine($"{x3} {y3} {x3} {y3 - m}");
            } else if (x1 == x2 && y1 > y2)
            {
                int x3 = x2 + m, y3 = y2;
                Console.WriteLine($"{x3} {y3} {x3} {y3 + m}");
            } else if (x1 < x2 && y1 == y2)
            {
                int x3 = x2, y3 = y2 + n;
                Console.WriteLine($"{x3} {y3} {x3 - n} {y3}");
            } else if (x1 > x2 && y1 == y2)
            {
                int x3 = x2, y3 = y2 - n;
                Console.WriteLine($"{x3} {y3} {x3 + n} {y3}");
            }


        }
    }
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a, b;
  while(cin >> a >> b, a || b) {
    int ans = inf;
    for(int i = 1; i*i <= a; i++) {
      if(a%i) continue;
      for(int j = 1; j*j <= b; j++) {
	if(b%j) continue;
	int x = a/i, y = b/j;
	vint v = {i, j, x, y};
	sort(all(v));
	int sum = 0;
	rep(k, 3) sum += (v[k+1]-v[k])*(v[k+1]-v[k]);
	ans = min(ans, sum);
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3004
n,m=map(int,input().split())
h=list(map(int,input().split()))
road=[list(map(int,input().split())) for i in range(m)]

dp=[1 for i in range(n)]
for i in range(m):
    if h[road[i][0]-1]>=h[road[i][1]-1]:
        dp[road[i][1]-1]=0
    if h[road[i][0]-1]<=h[road[i][1]-1]:
        dp[road[i][0]-1]=0
ans=0
for i in range(n):
    if dp[i]>0:
        ans+=1
print(ans)

Measured memory_bytes: 31836
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    int ans=0;
    for(int i=1;i<=n;i++){
        int k;
        cin>>k;
        if(k<a||k>=b) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  sort(ALL(a));
  vector<ll> sums(n+1, 0);
  rep(i, n) sums.at(i+1) = sums.at(i) + a.at(i);
  int index = 0;
  rrep(i, n){
    if(sums.at(i)*2 < a.at(i)){
      index = i;
      break;
    }
  }
  int ans = n - index;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4564
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <numeric>
using namespace std; 

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

int main() {
    int N, M; cin >> N >> M;
	vector<int> X(M);
	for(int i = 0; i < M; i++){
		cin >> X[i];
	}

	sort(X.begin(), X.end());

	vector<int> L(M-1);

	for(int i = 0; i < M-1; i++){
		L[i] = X[i+1] - X[i];
	}

	sort(L.begin(), L.end(), greater<int>());

	int ans = X.back() - X.front();
	for(int i = 0; i < min(N - 1, M - 1); i++){
		ans -= L[i];
	}

	cout << ans << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int s[6];
int c[10];
 
int main(void) {
 
    int N, M;
    cin >> N >> M;
 
    for (int i=0;i<M;i++)
        cin >> s[i] >> c[i];
 
    int ans = -1;
 
    int c1=10;
    int c2=10;
    int c3=10;
 
    for (int i=0;i<M;i++)
    {
        if (s[i] == 1)
                if (c1 != 10){
                  	if (c1 != c[i]){
                      cout << -1 << endl;
                      return 0;
                    }
                }
                else
                {
                    c1 = c[i];
                }
    }
 
    for (int i=0;i<M;i++)
    {
        if (s[i] == 2)
                if (c2 != 10){
                  	if (c2 != c[i]){
                      cout << -1 << endl;
                      return 0;
                    }
                }
                else
                {
                    c2 = c[i];
                }
    }
 
    for (int i=0;i<M;i++)
    {
        if (s[i] == 3)
                if (c3 != 10){
                  	if (c3 != c[i]){
                      cout << -1 << endl;
                      return 0;
                    }
                }
                else
                {
                    c3 = c[i];
                }
    }
 
    if (N==3)
    {
        if (c1==0){
            cout << -1 << endl;
        }
        else {
          if (c1 > 9){
            c1 = 1;
          }
            if (c2 > 9){
                c2 = 0;
            }
            if (c3 > 9){
                c3 = 0;
            }
            cout << c1 << c2 << c3 << endl;
        }
    }
 
    if (N==2)
    {
        if (c1==0){
            cout << -1 << endl;
        }
        else {
            if (c1 > 9){
                c1 = 1;
            }
            if (c2 > 9){
                c2 = 0;
            }
            cout << c1 << c2 << endl;
        }
    }
 
    if (N==1)
    {
        if (c1 > 9){
            cout << 0 << endl;
        }
        else {
            cout << c1 << endl;
        }        
    }
 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
using namespace std;

int main() {
	string a;
	cin >> a;
	int count = 0;
	for (int i = 0; i < 3; i++) {
		if (a.at(i) == 'o')
			count++;
	}
	cout << 700 + 100 * count;
}

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

int main(){


  int a = 0 ,b = 0 ,c = 0;

  cin >> a >> b >> c;

  if(a < b && b < c){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }

    return 0; 

}

Measured memory_bytes: 1124
import numpy as np

H, N = map(int, input().split())

ab = []
for i in range(N):
    a, b = map(int, input().split())
    ab.append([a, b])

ab = np.array(ab)
a_list = ab[:, 0]
b_list = ab[:, 1]
max_a = ab.max()

inf = float('inf')
dp = np.array([inf for _ in range(H + max_a)])
dp[0] = 0

for i in range(1, len(dp)):
    dp[i] = np.amin(dp[np.maximum(i - a_list, 0)] + b_list)

print(int(min(dp[H:])))


Measured memory_bytes: 12772
#pragma warning (disable:4996)
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int a[2000005] = { 0 };
int c[2000005] = { 0 };
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		c[i] = a[i] - (i+1);
	}
	sort(c, c + n);
	int b = c[n / 2];
	long long sadness=0;

	for (int i = 0; i < n; i++)
	{
		sadness = sadness + abs(c[i] - b);
	}

	cout << sadness << endl;
	return 0;
}

Measured memory_bytes: 5120
import math
# N = 2
# ARR = [10, -10]
#
# N = 6
# ARR = [1, 2, 3, 4, 5, 6]

N = int(input())
ARR = [int(s) for s in input().split(" ")]
def calculate(n,arr):
    lSum = 0
    tSum = sum(arr)
    res = []
    for index in range(n-1):
        ar = arr[index]
        lSum = lSum + ar
        rSum = tSum - lSum
        res.append(int(math.fabs(lSum-rSum)))

    print(min(res))



calculate(N,ARR)

Measured memory_bytes: 23800
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template< typename T > using matrix = vector< vector< T > >;

//FUNCTION  

int euclidean_gcd(int a, int b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}


void solve(void)
{
  int N,M;
  cin>>N>>M;
  vector<vector<int> > data(3,vector<int>(N));
  for (int i = 0; i < N; i++)
  {
    cin>>data[0][i]>>data[1][i]>>data[2][i];
  }
  int ANS = 0;
  for (int b = 0; b < 1<<3; b++)
  {
      vector<int> SUM(N,0);
    for (int j = 0; j < N; j++)
    {
      int sign = 1;
      for (int k = 0; k < 3; k++)
      {
        if(b>>k&1)
        {
          sign = -1;
        }
        else
        {
          sign = 1;
        }
        SUM[j] += data[k][j]*sign;
      }

      
    }
      int VAL = 0;
    sort(ALL(SUM),greater<int>());
    for (int k = 0; k < M; k++)
    {
      VAL += SUM[k];
    }
    chmax(ANS,VAL);
  }
  cout<<ANS<<endl;
  
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
const int inf=0x7fffffff;
const int mod=1e9+7;
const int eps=1e-6;
typedef long long ll;
typedef unsigned long long ull;
#define ls p<<1
#define rs p<<1|1
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
int head[N<<1],nxt[N<<1],to[N<<1],w[N<<1],tot=0;
void add(int u,int v,int val)
{
    nxt[++tot]=head[u];
    to[tot]=v;
    w[tot]=val;
    head[u]=tot;
}
int dis[N],vis[N];
int res[N];
int n,x,y;
void dij(int s)
{
    for(int i=1;i<=n;i++)
        dis[i]=inf,vis[i]=0;
    dis[s]=0;
    priority_queue<pii>q;
    q.push({-dis[s],s});
    while(!q.empty())
    {
        int u=q.top().second;
        q.pop();
        if(!vis[u])
        {
            vis[u]=1;
            for(int i=head[u];i;i=nxt[i])
            {
                int v=to[i];
                if(dis[v]>dis[u]+w[i])
                {
                    dis[v]=dis[u]+w[i];
                    q.push({-dis[v],v});
                }
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        res[dis[i]]++;
    }
}
signed main()
{
    IOS;
    cin>>n>>x>>y;
    for(int i=1;i<=n-1;i++)
    {
        add(i,i+1,1);
        add(i+1,i,1);
    }
    add(x,y,1);add(y,x,1);
    for(int i=1;i<=n;i++)
    {
        dij(i);
    }
    for(int i=1;i<=n-1;i++)
    {
        cout<<res[i]/2<<endl;
    }
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define INF 999999999
typedef long long ll;
using namespace std;
int main() {
    int R, G;
    cin >> R >> G;
    cout << 2*G - R << endl;
}

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

int N;
string S;
int main()
{
  cin >> N;
  vector<int> C(4);
  rep(i,N)
  {
    cin >> S;
    if(S == "AC") C[0]++;
    else if(S == "WA") C[1]++;
    else if(S == "TLE") C[2]++;
    else C[3]++;
  }

  cout << "AC" << " " << "x" << " " << C[0] << endl;
  cout << "WA" << " " << "x" << " " << C[1] << endl;
  cout << "TLE" << " " << "x" << " " << C[2] << endl;
  cout << "RE" << " " << "x" << " " << C[3] << endl;
}

Measured memory_bytes: 3572
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    ll n,k;
    cin>>n>>k;
    set<pll> st;
    if(k>(n-1)*(n-2)/2){
        cout<<-1<<endl;
        return 0;
    }
    rep2(i,2,n+1){
        st.insert(pll(1,i));
    }
    ll s=(n-1)*(n-2)/2-k;
    rep(i,s){
        bool flag=false;
        rep2(j,2,n){
            rep2(l,j+1,n+1){
                if(st.find(pll(j,l))==st.end()){
                    st.insert(pll(j,l));
                    flag=true;break;
                }
            }
            if(flag) break;
        }
    }
    cout<<st.size()<<endl;
    for(auto const &p:st) {
        cout<<p.first <<" "<<p.second<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  cout << (1000 - n % 1000) % 1000 << endl;
}

Measured memory_bytes: 3552
import math
from decimal import *
A,B,H,M = map(int,input().split())

h_rad = math.radians((30 * (H + M / 60)))
m_rad = math.radians(6 * M)
diff = abs(h_rad - m_rad)

ans = math.sqrt(pow(A,2) + pow(B,2) - 2 * A * B * math.cos(diff))

print(ans)

Measured memory_bytes: 10164
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

map<int, int> mp;
vector<int> v,ans;
vector<P> g[100100];

int b[100100];
bool visited[100100],one[100100];

void dfs(int u){
	int i;
	visited[u] = true;
	for(i=(g[u].l_ength()-1); i>=0; --i){
		if(visited[g[u][i].first]){
			continue;
		}
		dfs(g[u][i].first);
		if(b[g[u][i].first]){
			b[g[u][i].first] ^= 1;
			b[u] ^= 1;
			ans.push_back(g[u][i].second);
		}
	}
}

int main(void){
	int n,m,i,a,x,l,r;
	cin >> n >> m;
	for(i=0; i<n; ++i){
		cin >> a >> b[i];
		mp[a] = b[i];
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	for(i=0; i<n; ++i){
		b[i] = mp[v[i]];
	}
	b[n] = 0;
	for(i=n; i>0; --i){
		b[i] ^= b[i-1];
	}
	for(i=0; i<m; ++i){
		cin >> l >> r;
		l = (int)(lower_bound(v.begin(),v.end(),l)-v.begin());
		r = (int)(upper_bound(v.begin(),v.end(),r)-v.begin());
		if(l==r){
			continue;
		}else{
			g[r].push_back(P(l,i+1));
			g[l].push_back(P(r,i+1));
		}
	}
	for(i=0; i<n; ++i){
		if(visited[i]){
			continue;
		}
		dfs(i);
		if(b[i]){
			cout << "-1" << endl;
			return 0;
		}
	}
	sort(ans.begin(),ans.end());
	cout << (ans.l_ength()) << endl;
	for(i=0; i<(ans.l_ength()); ++i){
		cout << ((i)?" ":"") << ans[i];
	}
	cout << endl;
	return 0;
}


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



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

	int N;
	cin >> N;
	vector<VI> M(N);
	REP(i, N) {
		int a;
		cin >> a;
		REP(j, a) {
			int b;
			cin >> b;
			M[i].push_back(b);
		}
	}
	priority_queue<int> Q;
	int ans = 0;
	for (int i = N - 1; i >= 0; i--) {
		REP(j, M[i].size()) {
			Q.push(M[i][j]);
		}
		ans += Q.top();
		Q.pop();
	}
	cout << ans << endl;
	return 0;
}




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

using namespace std;

typedef long long ll;

const ll INF = 1LL << 60;

int main(){
  ll N,M; cin >> N >> M;
  vector<pair<ll,ll>> to[1001];
  for(ll i = 0; i < M; i++){
    ll a,b,w; cin >> a >> b >> w; a--; b--; w *= - 1;
    to[a].push_back(make_pair(b,w));}
  
  vector<ll> dist(N,INF);
  dist[0] = 0;
  bool closed = false;
  for(ll i = 0; i < 2*N; i++){
    for(ll v = 0; v < N; v++){
      if(dist[v] == INF){ continue;}
      else{
        //to[v]に格納されている辺に着目する　辺が主語
           for(auto next : to[v]){
           
          if(dist[next.first] > dist[v] + next.second){
            dist[next.first] = dist[v] + next.second;
          if(next.first == N - 1 && i >= N){//N回目以降にノードN-1が更新されていないかを確認
            closed = true;}}
          }}}}
  
  if(closed){ cout << "inf" << endl;}
  else{
    cout << -dist[N-1] << endl; } return 0;}
            
    


Measured memory_bytes: 384
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
inline int read(){int now=0;register char c=getchar();for(;!isdigit(c);c=getchar());
for(;isdigit(c);now=now*10+c-'0',c=getchar());return now;}
#define For(i, x, y) for(int i=x;i<=y;i++)  
#define _For(i, x, y) for(int i=x;i>=y;i--)
#define Mem(f, x) memset(f,x,sizeof(f))  
#define Sca(x) scanf("%d", &x)
#define Sca2(x,y) scanf("%d%d",&x,&y)
#define Sca3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define Scl(x) scanf("%lld",&x);  
#define Pri(x) printf("%d\n", x)
#define Prl(x) printf("%lld\n",x);  
#define CLR(u) for(int i=0;i<=N;i++)u[i].clear();
#define LL long long
#define ULL unsigned long long  
#define mp make_pair
#define PII pair<int,int>
#define PIL pair<int,long long>
#define PLL pair<long long,long long>
#define pb push_back
#define fi first
#define se second 
typedef vector<int> VI;
const double eps = 1e-9;
const int maxn = 3e5 + 10;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7; 
int N,M,K;
char str[maxn];
int pre[maxn],erp[maxn];
int main(){
	Sca(N);
	scanf("%s",str + 1);
	for(int i = 1; i <= N ; i ++){
		pre[i] = pre[i - 1] + (str[i] == 'W');
	}
	for(int i = N; i >= 1; i --){
		erp[i] = erp[i + 1] + (str[i] == 'E');
	}
	int sum = INF;
	for(int i = 1; i <= N ; i ++){
		sum = min(sum,pre[i - 1] + erp[i + 1]);
	}
	cout << sum << endl;
	return 0;
}

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

int main(){
  long long x,y;
  cin>>x>>y;
  long long sum=0;
  for(long long i=y;i<=x+1;i++){
  long long z=i*(x-i+1)+1;
  sum+=z;
  }
  int law=round(pow(10,9)+7);
  cout<<sum%law<<endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long d=sc.nextInt();
		long[] x=new long[n];
		long[] y=new long[n];
		for(int i=0;i<n;i++) {
			x[i]=sc.nextLong();
			y[i]=sc.nextLong();
		}
		int ct=0;
		long c=d*d;
		for(int j=0;j<n;j++) {
		
		if(c>=x[j]*x[j]+y[j]*y[j]) {
			ct++;
		}
		}
		System.out.println(ct);
		sc.close();
	}
}


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

using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    vector<int> v[n+1];
    for(int o=1;o<=n;o++)
    {
        for(int i=o;i<=n;i+=o)
        {
            v[i].push_back(o);
        }
    }
    int a[n+1];
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    vector<int> res;
    for(int o=n;o>=1;o--)
    {
        if(a[o]==1)
        {
            res.push_back(o);
            for(int d:v[o]) a[d]=1-a[d];
        }
    }
    reverse(res.begin(),res.end());
    printf("%d\n",(int)res.size());
    for(int t:res) printf("%d ",t);
    printf("\n");
    return 0;
}


Measured memory_bytes: 23544
package main

import "fmt"

func solve() {
	var N int
	fmt.Scan(&N)
	l := make([]int, N)
	r := make([]int, N)
	ans := 0
	for i := range l {
		fmt.Scan(&l[i], &r[i])
		ans += r[i] - l[i] + 1
	}
	fmt.Println(ans)

}

func main() {
	solve()
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>

long long pow_10 (int x) {
  long long sub = 1;
  if (x == 0 ) {
    return 1;  
  }  
  else {
    while (x) {
      sub = sub*10;
      x--;  
    }  
    return sub;
  }
}

int main () {
  // std::string N;
  // std::cin >> N;
  std::vector<long long> sunuke;

  // まずは, 1-9を入れる.
  for (int i = 1; i < 10; i++) {
    sunuke.push_back(i);  
  }

  // 他
  long long sub = 0;
  long long subsub = 0;
  long long subsubsub = 0;
  for (int i = 1; i <= 15; i++) {
    sub = 0;
    subsub = i;
    while (subsub) {
      sub += 9 * pow_10(subsub - 1);
      subsub--; 
    }
    subsubsub = sub;
    long long subsubsubsub;
    for (int j = 1; j <= 9; j++) {
      sub = subsubsub + j * pow_10 (i);
      if (i == 1){
        sunuke.push_back(sub);  
      }
      else {
        
        subsubsubsub = sub;
        for (int q = 0; q < 10; q++ ) {
          sub = subsubsubsub - q * pow_10(i-1);
          // std::cout << sub << std::endl; 
          if (i == 2) {
            sunuke.push_back(sub);  
          }
          else {
            long long subsubsubsubsub = sub;
            for (int qq = 0; qq < 10; qq++) {
              sub = subsubsubsubsub - qq * pow_10(i-2);
              sunuke.push_back(sub);
            }
          }
          // sunuke.push_back(sub);
        }
      }
    }   
  }

  std::sort(sunuke.begin(),sunuke.end());
  std::vector<float> sunuke_S;
  long long sum;
  for (int i = 0; i < sunuke.size(); i++) {
    sum = 0;
    long long sunukes = sunuke[i];
    while(sunukes) {
      sum = sum + (sunukes%10);  
      sunukes = sunukes/10;
    }
    sunuke_S.push_back((float) sunuke[i]/ (float) sum);
  }
  int K;
  std::cin >> K;
  std::vector<long long> answer;
  for (int i = 0 ; i < sunuke.size(); i++) {
    for (int j = i; j < sunuke.size(); j++) {
      if (sunuke_S[i] <= sunuke_S[j]) {
        
      }
      else {
        break;  
      }
      if (j == (sunuke.size() -1 )) {
        answer.push_back(sunuke[i]);  
      }
    }  
  }

  for (int i = 0; i < K; i++) {
    std::cout << answer[i] << std::endl;
  }
}

Measured memory_bytes: 512
from collections import Counter

N, *A = map(int, open(0).read().split())

C = Counter(A)
B = sorted(C.items(), key=lambda x: x[0])

lim = B[-1][0] + 1

memo = set()
ans = 0
for k, v in B:
    if k in memo:
        continue
    memo |= set(range(k, lim, k))
    ans += (v == 1)

print(ans)

Measured memory_bytes: 132268
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(ll i=a;i<n;i++)
#define ve vector
#define ss second 
#define ff first
#define pf pop_front
#define pob pop_back
#define psf push_front
#define res(x) cout<<x<<'\n'
#define read(t) ll t;cin>>t

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll temp=n*m;
    temp++;
    ll ans=temp/2;
    if(n==1||m==1){
        ans=1;
    }
    cout<<ans<<endl;
    
    


   

}

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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

const ll MOD = 1e9 + 7;

int a[100001];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, l;
	cin >> n >> l;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int maxpos = -1;
	int maxsum = 0;
	for(int i = 0; i < n - 1; i++)
	{
		if(a[i] + a[i + 1] > maxsum)
		{
			maxsum = a[i] + a[i + 1];
			maxpos = i;
		}
	}
	if(maxsum < l)
	{
		cout << "Impossible" << '\n';
		return 0;
	}
	else
	{
		cout << "Possible" << '\n';
		for(int i = 0; i < maxpos; i++)
		{
			cout << i + 1 << '\n';
		}
		for(int i = n - 2; i > maxpos; i--)
		{
			cout << i + 1 << '\n';
		}
		cout << maxpos + 1 << '\n';
	}
	return 0;
}


Measured memory_bytes: 1280
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]


h, w = LI()
a = []
for _ in range(h):
    a.append([x%2 for x in LI()])

operations = []
for i in range(h):
    for j in range(w-1):
        if not a[i][j]:
            continue
        else:
            a[i][j+1] ^= 1
            operations.append(' '.join(map(str, [i+1, j+1, i+1, j+2])))

for i in range(h-1):
    if not a[i][-1]:
        continue
    else:
        a[i+1][-1] ^= 1
        operations.append(' '.join(map(str, [i+1, w, i+2, w])))

print(len(operations))
for row in operations:
    print(row)


Measured memory_bytes: 16272
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;
typedef long long ll;
 
int main(){
   int m, D, ans = 0;
   cin >> m >> D;
   for(int i = 1; i <= m; i++){
      for(int j = 22; j <= D; j++){
         if(j % 10 < 2) continue;
         if(i == (j / 10) * (j % 10)) ans++;
      }
   }
   if(D < 22) cout << 0 << endl;
   else cout << ans << endl;

} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a < b) {
            if (a < c && c  < b) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } else {
            if (b < c && c  < a) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }

    }
}


Measured memory_bytes: 22100
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
d=[lnii() for i in range(n)]

cnt=0
for a,b in d:
  if a==b:
    cnt+=1
  if cnt>=3:
    print('Yes')
    exit()
  if a!=b:
    cnt=0

print('No')

Measured memory_bytes: 9208