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

#solve
def solve():
    n, m, k = LI()
    ab = LIR_(m)
    cd = LIR_(k)
    par = [i for i in range(n)]
    size = [1] * n
    def root(x):
        if x == par[x]:
            return x
        par[x] = root(par[x])
        return par[x]

    def unite(a, b):
        a = root(a)
        b = root(b)
        if size[a] > size[b]: a, b = b, a
        if a == b: return False
        par[a] = b
        size[b] += size[a]
        return True

    lis = [1] * n
    for a, b in ab:
        unite(a, b)
        lis[a] += 1
        lis[b] += 1
    for c, d in cd:
        if root(c) == root(d):
            lis[c] += 1
            lis[d] += 1
    for i in range(n):
        print(size[root(i)] - lis[i], end=" ")
    print()
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 115036
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int count=0;
	for(int i=1;i<=n;i++)
	{
		if(i%2!=0)
			count++;
	}
	cout<<float(count)/n;
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n, c, k := nextInt(), nextInt(), nextInt()
	t := make([]int, n)
	for i := 0; i < n; i++ {
		t[i] = nextInt()
	}
	sort.Ints(t)

	var ans int
	for i := 0; i < n; {
		s := t[i] + k
		var cnt int
		for i < n && t[i] <= s {
			cnt++
			if cnt > c {
				break
			}
			i++
		}
		ans++
	}

	fmt.Println(ans)
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n; cin >> n;
  vll a(n);

  rep(i, n) cin >> a[i];
  
  ll ans = 0;

  ll right = 0, sum = 0;
  rep(left, n) {
    while (right < n && !(sum & a[right])) {
      sum += a[right];
      ++right;
    }
    sum -= a[left];

    ans += max(1LL, right - left);
    if (right < left) right = left + 1;
  }

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

Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ll = long long;
using ii = pair<int, int>;

int32_t main(){
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	map<string, int> mp;
	for(int i=0; i<n; ++i){
		string s;
		cin >> s;
		++mp[s];
	}
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
}


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

using namespace std;

#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define mod 998244353
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()

typedef vector<lld> vi;
typedef vector<vector<lld>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<lld, lld>> vpi;
typedef long long LL;


int main() {
	fast;
	cin.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	lld n, i;
	cin >> n;
	lld sum = 0;
	for (i = 1; i <= n; i++) {
		if (i % 3 == 0 || i % 5 == 0 || i % 15 == 0) {

		}
		else {
			sum += i;
		}
	}
	cout << sum << endl;
}






Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;

#define ul unsigned long long
#define ll long long 

ul perm(ul n) {
  if (n==1) return 1;
  else return n*perm(n-1);
}

int main()
{
  size_t n;
  long int p[8][2];
  cin>>n;
  for (size_t i = 0; i < n; i++)
  {
    cin>>p[i][0]>>p[i][1];
  }
  
  size_t prm[8]={0,1,2,3,4,5,6,7};

  double res=0.0,dx,dy;
  do {
    for (size_t i = 1; i < n; i++)
    {
      dx = p[prm[i-1]][0] - p[prm[i]][0];
      dy = p[prm[i-1]][1] - p[prm[i]][1];
      res += sqrt(dx*dx+dy*dy);
    }
    
  } while (next_permutation(prm,prm+n));

  cout << fixed<<setprecision(16);
  cout << (res/perm(n))<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int sum_of_digits(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

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

    if (n % sum_of_digits(n) == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
}


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

const int N = 2e5 + 10;

int n;
string s;
vector<int> adj[N];
int cnt[N][2], alive[N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int m; cin >> n >> m;
    cin >> s;
    while (m--) {
        int u,v; cin >> u >> v;
        --u; --v;
        adj[u].push_back(v);
        adj[v].push_back(u);
        cnt[u][s[v]-'A']++;
        cnt[v][s[u]-'A']++;
    }
    fill_n(alive, n, 1);
    vector<int> bad;
    for (int u = 0; u < n; u++) if (!cnt[u][0] || !cnt[u][1])
        bad.push_back(u);

    while (!bad.empty()) {
        auto u = bad.back(); bad.pop_back();
        alive[u] = 0;
        for (auto v : adj[u]) if (alive[v]) {
            if (--cnt[v][s[u]-'A'] == 0) bad.push_back(v);
        }
    }
    bool ans = 0;
    for (int u = 0; u < n; u++) ans |= alive[u];
    cout << (ans ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 13392
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;


Int min(Int a, Int b){
    return a < b ? a : b;    
}

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

    Int n, k;
    vector<Int> v;
    cin >> n >> k;
    for(Int i=0; i<n; i++){
        cin >> tmpi;
        v.push_back(tmpi);
    }

    Int max = 0;
    for(Int l=0; l<=min(n, k); l++){
        for(Int r=0; r<=min(n, k)-l; r++){
            vector<Int> hand;
            Int sum = 0;

            for(Int i=0; i<l; i++){
                hand.push_back(v[i]);
                sum += v[i];
            }
            for(Int i=0; i<r; i++){
                hand.push_back(v[n-1-i]);
                sum += v[n-1-i];
            }

            sort(hand.begin(), hand.end());
            for(Int i=0; i<k-r-l; i++){
                if(hand.empty()){
                    break;
                }
                Int& f = hand.front();
                if(f < 0){
                    sum -= f;
                    hand.erase(hand.begin());
                }else{
                    break;
                }
            }

            // cout << sum << ": ";
            // for(Int i=0; i<hand.size(); i++){
            //     cout << hand[i] << " ";
            // }
            // cout << endl;
            
            max = sum > max ? sum : max;
        }
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

vector<pair<ll,ll>> factor_arr;

void myfactor(ll num){ 
    ll count = 0;   
    while (!(num % 2)) { 
        num >>= 1; count++; 
    }  
    if (count) factor_arr.push_back({2,count}); 
    for (auto i = 3; i <= sqrt(num); i += 2) { 
        count = 0; 
        while (num % i == 0) { 
            count++; 
            num /= i; 
        } 
        if (count) factor_arr.push_back({i,count}); 
    } 
    if (num > 2) factor_arr.push_back({num,1});
}

void virus(){
          ll len;
          cin>>len;
          vector<ll> arr(len),dp(len,0);
          for(auto &i:arr) cin>>i;
          dp[1] = abs(arr[1] - arr[0]);
          for(auto i=2; i<len; i++){
              dp[i] = min( dp[i-1] + abs(arr[i] - arr[i-1]), dp[i-2] + abs(arr[i] - arr[i-2]));
          }
          cout<<dp[len-1]<<endl;
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t = 1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 4848
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}




int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int x;
    cin >> x;
    Yes(x >= 30);

    

}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>

using namespace std;

void solve()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A * B >= C * D)
	{
		cout << A * B << endl;
	}
	else
	{
		cout << C * D << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    ll N;
  	cin >> N;
    ll a=1,b=1,c=1;
    ll kiri=1000000007;
    for(ll i=1; i<=N; i++){
        a=a*10;
        b=b*9;
        c=c*8;
        if(a>kiri) a=a%kiri;
        if(b>kiri) b=b%kiri;
        if(c>kiri) c=c%kiri;
    }
    ll d=a+c-b-b;
    while(d<0){
        d=d+kiri;
    } 
    if(d>kiri) d=d%kiri;
    cout << d << endl;
    return 0;
}

Measured memory_bytes: 3632
n = $stdin.gets.chomp.to_i
arr = $stdin.gets.chomp.split(" ")
arr.map! do |a_j|
a_j.to_i
end

arr.sort!

x = 0
for i in 0..n - 2
    x += arr[i]
end


if arr[n-1] < x
    puts "Yes"
else
    puts "No"
end

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

using namespace std;

#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define dump(x) cerr << "~ " << #x << " = " << x << endl

#define N 100005

__int128 ar[N+5];

int main() {

	fast_cin;
	
	int n,flag = 0;
	long long x;

	__int128 ans = 1;
	__int128 high = 1e18; //dump(high);

	cin >> n;

	for(int i = 1; i <= n; i++) {
		
		cin >> x;
		ar[i] = x;

		if(ar[i] == 0) flag = 1;
	}

	if(flag) {
		cout << 0 << endl;
		return 0;
	}


	
	for(int i = 1; i <= n; i++) {
		ans *= ar[i];

		if(ans > high) {
			ans = -1;
			break;
		}
	}
	
	x = ans;
	cout << x << endl;
	
	return 0;
}

Measured memory_bytes: 5204
#include <iostream>
#include <map>

using namespace std;

bool equal(int* a, int* b, int n) {
  for (int i = 0; i < n; i++)
    if (a[i] != b[i])
      return false;
  return true;
}

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (!n) return 0;
    int p[n], s[n], result = 0;
    for (int i = 0; i < n; i++)
      cin >> p[i];
    for (;;) {
      for (int i = 0; i < n; i++)
        s[i] = p[i];
      map<int, int> counts;
      for (int i = 0; i < n; i++)
        counts[s[i]]++;
      for (int i = 0; i < n; i++)
        p[i] = counts[s[i]];
      if (equal(p, s, n)) break;
      result++;
    }
    cout << result << endl;
    for (int i = 0; i < n-1; i++)
      cout << p[i] << ' ';
    cout << p[n-1] << endl;
  }
}

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

int n,A[N];

int main(){
  
  cin>>n;
  for(int i=0;i<n;i++) cin>>A[i];
  
    
  int ans=1,f=0;
    
  for(int i=0;i<n-1;i++){
    
    if(!f){
      if(A[i]<A[i+1])f=1;
      if(A[i]>A[i+1])f=2;
    }
    else if(f==1){
      if(A[i]>A[i+1])ans++,f=0;
    }
    else if(f==2){
      if(A[i]<A[i+1])ans++,f=0;
    }
    
  }
    
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void){
	int kazu,a,b,c,z,i,kotae[1000];
	scanf("%d",&kazu);
	for(z=1;z<=kazu;z++){
		scanf("%d%d%d",&a,&b,&c);
		kotae[z]=0;
		if(a*a==b*b+c*c){
			kotae[z]=1;
			goto a;
		}
		if(a*a+b*b==c*c){
			kotae[z]=1;
			goto a;
		}
		if(a*a+c*c==b*b){
			kotae[z]=1;
			goto a;
		}
		a:;
	}
	for(z=1;z<=kazu;z++){
		if(kotae[z]){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
}


Measured memory_bytes: 2044
package main

import (
  "fmt"
)

const (
  mod = 1e9 + 7
  eps = 1e-13
  inf = 1 << 63 - 1
)

func absInt(x int) int {if x < 0 {x *= -1}; return x}

func dist(x1, y1, x2, y2 int) int {
  return absInt(x2 - x1) + absInt(y2 - y1)
}

func main() {
  var n, m int 
  fmt.Scan(&n, &m)
  a := make([]int, n)
  b := make([]int, n)
  c := make([]int, m)
  d := make([]int, m)
  for i := 0; i < n; i++ {
    fmt.Scan(&a[i], &b[i])
  }
  for i := 0; i < m; i++ {
    fmt.Scan(&c[i], &d[i])
  }
  for i := 0; i < n; i++ {
    d1 := inf
    var res int
    for j := 0; j < m; j++ {
      d2 := dist(a[i], b[i], c[j], d[j])
      if d2 < d1 {
        d1 = d2
        res = j + 1
      }
    }
    fmt.Println(res)
  }
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int l;
vector<pair<int, int>> g[25];
void solve() {
    cin >> l;

    int n = 0;
    int tmp = l;
    while (tmp != 0) {
        tmp >>= 1;
        ++n;
    }

    tmp = 1;
    rep(i, n - 1) {
        g[i].emplace_back(i + 1, 0); g[i].emplace_back(i + 1, tmp);
        tmp <<= 1;
    }

    l -= 1 << (n - 1);
    int num = 1 << (n - 1);
    repd(i, n - 1) {
        if (((l >> i) & 1) == 1) {
            g[i].emplace_back(n - 1, num);
            l -= 1 << i;
            num += 1 << i;
        }
    }

    int m = 0;
    rep(i, n) m += sz(g[i]);

    cout << n << " " << m << endn;
    rep(i, n) rep(j, g[i].size()) cout << i + 1 << " " << g[i][j].first + 1 << " " << g[i][j].second << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 256
from fractions import gcd

#####segfunc######
#評価関数（という言い方であっている？）
def segfunc(x,y):
    if x==0 or y==0:
        return x+y#0ではない方を返す
    return gcd(x,y)


#初期化
def init(init_val):
    #init_valは操作する数列
    for i in range(N):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
        

#k番目の値をxに更新
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])

        
#[p,q)の区間に対するクエリへの応答
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res


#####単位元######
ide_ele = 0

N=int(input())
A = list(map(int, input().split()))

#num:n以上の最小の2のべき乗
num =2**(N-1).bit_length()
seg=[ide_ele]*2*num
init(A)

#i番目の要素をのぞいた時のgcd
max_gcd=[0]*N
for i in range(N):
    gcd_l=query(0,i)
    gcd_r=query(i+1,N)
    max_gcd[i]=gcd(gcd_l,gcd_r)
print(max(max_gcd))

Measured memory_bytes: 99048
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pl;


int main()
{
	int n;
	while (cin >> n, n) {
		int m[10] = {0};
		for (int i = 0; i < n; i++){
			int c; cin >> c;
			m[c]++;
		}
		for (int i = 0; i < 10; i++) {
			if (m[i] != 0) {
				for (int j = 0; j < m[i]; j++) {
					cout << "*";
				}
				cout << endl;
			}
			else
				cout << '-' << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>


typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

int main() {
	for (ll i = 1; i <= 9; i++) {
		for (ll j = 1; j <= 9; j++) {
			cout << i << "x" << j << "=" << i * j << endl;
		}
	}
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
///...................................*****.................................................///
///        Author :  MD. Rakibul Islam ( mmdrakibul2912@gmail.com )                         ///
///                  Department of Computer Science                                         ///
///                  & Engineering,                                                         ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///
using namespace std;
int main()
{
    int n, m, i, j, k, l;
    char c;
    cin>>n>>c>>m;
    if(c=='+')
    {
        cout<<n+m<<endl;
    }
    else
    {
        if(n>m)
            cout<<n-m<<endl;
        else
            cout<<"-"<<m-n<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;
int N,M;

priority_queue< int,vector<int> ,greater<int> > que;

int main(){
	cin >> N >> M;
	for(int i=0;i<N;i++){
		int a;
		cin >> a;
		que.push(a);
	}
	vector< pair<int,int> > pa(M);
	for(int i=0;i<M;i++){
		int b,c;
		cin >> b >> c;
		pa[i] = make_pair(-c,b);
	}
	sort(pa.begin(),pa.end() );
	
		for(int i=0;i<M;i++){
			int c=pa[i].first*-1;
			int b=pa[i].second;
		
			while(1){
				int t = que.top();
				if(b<1 || t>=c){break;}
				que.pop();
				que.push(c);
				b--;
			}
		}
	long long int ans=0;
		while(!que.empty()){
			ans+=que.top();
			que.pop();
		}
		cout << ans << endl;
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int r, g;
    cin >> r >> g;
    cout << 2 * g - r << endl;
    return 0;
}

Measured memory_bytes: 3612
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
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; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
const int mod = 1000000007;
struct mint {
int64_t x;
mint(int64_t 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 { return mint(*this) += a;}
mint operator-(const mint a) const { return mint(*this) -= a;}
mint operator*(const mint a) const { return mint(*this) *= a;}
mint pow(int64_t t) const {if (!t) return 1;mint a = pow(t>>1);a *= a;if (t&1) a *= *this;return a;}
mint inv() const { return pow(mod-2);}
mint& operator/=(const mint a) { return *this *= a.inv();}
mint operator/(const mint a) {return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    string s;cin>>s;
    ll k;cin>>k;
    
    ll cnt=101;
    char ans;
    for(int i = 0; i<s.size(); i++){
        if(s.at(i) != '1') {
            cnt = i+1;
            ans = s.at(i);
            break;
        }
    }

    if(cnt==101) cout<<1<<endl;
    else if(k<cnt) cout<<1<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    const char S = '#';
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    REP(i,h) cin >> s[i];

    vector<vector<int>> ans(h,vector<int>(w));
    int c = 1;

    vector<int> sline;
    REP(i,h) {
        if (s[i].find(S) != string::npos) sline.push_back(i);
    }

    int ys,ye,xs,xe;
    REP(i,sline.size()) {
        if (i == 0) ys = 0;
        else ys = sline[i-1]+1;
        if (i == sline.size()-1) ye = h-1;
        else ye = sline[i];

        int sl = sline[i];
        xs = 0;
        xe = s[sl].find(S,xs);
        while(s[sl].find(S,xe+1) != string::npos) {
            FOR(y,ys,ye+1) FOR(x,xs,xe+1) ans[y][x] = c;
            c++;
            xs = xe+1;
            xe = s[sl].find(S,xs);
        }
        xe = w-1;
        FOR(y,ys,ye+1) FOR(x,xs,xe+1) ans[y][x] = c;
        c++;
    }


    for(auto v:ans) {
        REP(i,v.size()-1) cout << v[i] << " ";
        cout << v.back() << endl;
    }

    return 0;
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine().Any(c => c == '7');
            Console.WriteLine(N ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 18348
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

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

        int H = sc.nextInt();
        int W = sc.nextInt();
        char[][] C = new char[H][W];
        for (int r = 0; r < H; ++r) {
            String line = sc.next();
            for (int c = 0; c < W; ++c) {
                C[r][c] = line.charAt(c);
            }
        }

        System.out.println(solve(C));

        sc.close();
    }

    static String solve(char[][] C) {
        return Arrays.stream(C)
                .map(line -> IntStream.range(0, 2).mapToObj(i -> new String(line)).collect(Collectors.joining("\n")))
                .collect(Collectors.joining("\n"));
    }
}

Measured memory_bytes: 30248
#include<stdio.h>

int main(int argc, char *args[] )
{
  int t, h, m, s;
  scanf("%d", &t);
  h = t / 3600;
  t = t % 3600;
  m = t /60;
  t = t % 60;
  s = t; 
  printf("%d:%d:%d\n", h, m, s);
  return(0);
}

Measured memory_bytes: 592
n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]
INF = 10**9

def dfs(index, x, y, z):
    if index == n:
        return abs(a-x) + abs(b-y) + abs(c-z) - 30 if min(x, y, z) > 0 else INF

    cand1 = dfs(index+1, x+l[index], y, z) + 10
    cand2 = dfs(index+1, x, y+l[index], z) + 10
    cand3 = dfs(index+1, x, y, z+l[index]) + 10
    cand4 = dfs(index+1, x, y, z)

    return min(cand1, cand2, cand3, cand4)

print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const int INF = 1e9;
const double pi=acos(-1);
using namespace std;

int main(){
  string s;
  cin >> s;
  int n=s.size();
  vector<int>a(n+1,0);
  rep(i,n){
    if(s[i]=='<'){
      a[i+1]=max(a[i+1],a[i]+1);
    }
  }
  rep(i,n){
    if(s[n-1-i]=='>'){
      a[n-1-i]=max(a[n-1-i],a[n-i]+1);
    }
  }
  ll sum=0;
  rep(i,n+1)sum+=a[i];
  
  cout <<sum<<endl;
  
  return 0;
}

Measured memory_bytes: 2820
h = Hash.new{ |h, k| h[k] = {} }
n = gets.to_i
for i in 1..n do
  a = gets.split(" ")
  h[a[0]][a[1]] = 1
end
for i in ["S", "H", "C", "D"] do
  for j in 1..13 do
    puts "#{i} #{j}" unless h[i][j.to_s]
  end
end


Measured memory_bytes: 6860
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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 GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────


int main() {
	ll a, b;
	cin >> a >> b;
	ll g = GCD(a, b);
	auto f = factorize(g);
	int ans = f.size() + 1;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
	int a ;
	cin >> a;
	int s[20];
	int i = 0;
  for (int i = 0 ; i < a ; i++)
	{
		cin >> s[i];
	}
	int ans = 1;
	for (int j = 0 ; j < a ; j++)
	{
		for (int p = 0; p < j ; p++)
		{
			if (s[j] < s[p])
			{
				break;
			}
			if (p == j-1)
			{
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// define Bn := {an - n - 1}
// question: minimize sum of abs of {bn - c} with suitable c
// answer: c should be the mode of B

let n = stdin.ReadLine() |> int

let bs = stdin.ReadLine().Split() 
           |> Array.mapi (fun i x -> (int x)-i-1)
           |> Array.sort
           |> Array.map int64 // required: will be summed.

let c = bs.[n/2]

printfn "%d" (bs |> Array.map (fun x -> abs (x-c)) |> Array.sum)

Measured memory_bytes: 33468
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int min = Math.min(N * A, B);
        System.out.println(min);
    }
}

Measured memory_bytes: 24916
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int T = sc.nextInt();
		int minc =1001;
		for (int i = 0; i < N; i++) {
			int ci = sc.nextInt();
			int ti = sc.nextInt();
			if(ti<=T&&ci<minc){
				minc=ci;
			}
		}
		if(minc ==1001){
			System.out.println("TLE");
			return;
		}
		System.out.println(minc);
	}

}

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

int main(){
	int N;
	string S;
	cin >> N >> S;
	int x = 0, xmax = 0;
	rep(i,N) {
		if (S[i] == 'I') x++;
		if (S[i] == 'D') x--;
		xmax = max(xmax,x);
	}
	cout << xmax << endl;
	return 0;
}


Measured memory_bytes: 3624
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        int A = sc.nextInt();
        int B = sc.nextInt();
        String U = sc.next();

        if (U.equals(S)){
            A -= 1;
        } else {
            B -= 1;
        }

        System.out.print(A);
        System.out.print(" ");
        System.out.print(B);
    }
}


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

using namespace std;

#define MAX_V 100
#define INF 1e9

struct edge{ int to,cap,rev; };

int V,E;
vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,G[to].size()});
  G[to].push_back((edge){from,0,G[from].size()-1});
}

int dfs(int v,int t,int f){
  if(v == t) return f;
  used[v] = true;
  for(int i = 0 ; i < (int)G[v].size() ; i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      int d = dfs(e.to,t,min(f,e.cap));
      if(d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow = 0;
  for(;;){
    memset(used,false,sizeof(used));
    int f = dfs(s,t,INF);
    if(f == 0) return flow;
    flow += f;
  }
}

int main(){
  int a,b,c;
  cin >> V >> E;
  for(int i = 0 ; i < E ; i++){
    cin >> a >> b >> c;
    add_edge(a,b,c);
  }
  cout << max_flow(0,V-1) << endl;
  return 0;
}

Measured memory_bytes: 1264
n = int(input())
used = list(input() for x in range(n))
ans = "Yes"
for i in range(n-1): 
  if used.count(used[i]) == 2:
    ans = "No"
    break
  if used[i][-1] != used[i+1][0]:
    ans = "No"
print(ans)

Measured memory_bytes: 9064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; string s, t; cin >> n >> s >> t;
  REP(i, n) {
    if (s.substr(i) == t.substr(0, n - i)) {
      cout << n + i << '\n';
      return 0;
    }
  }
  cout << n + n << '\n';
  return 0;
}


Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	A, B, C := getInt(), getInt(), getInt()
	A, B = B, A
	A, C = C, A
	out(A, B, C)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long k,n,m,ans,s,d;
int main()
{
	cin>>k>>n>>m;
	if(k<=n)
	{
		cout<<'1'<<endl;
		goto A;
	}
	if(n<=m)
	{
		cout<<"-1"<<endl;
		goto A;
	}
	s=n-m;
	d=k-n;
	if(d%s==0)
	{
		ans=d/s;
	}
	else
	{
		ans=d/s+1;
	}
	ans*=2;
	cout<<ans+1;
	A: return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
// ここに処理を記述
    string S;
    cin >> S;

    // cout << S << "\n";

    if(S[0] == 'S') cout << "Cloudy" << "\n";
    else if(S[0] == 'C') cout << "Rainy" << "\n";
    else cout << "Sunny" << "\n";

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#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)
int INF = 1e9;
ll  LINF = 1e18;

int main(){
	ll n,m,x;cin >> n >> x >> m;
	vector<int> res(m,-1),a;
	int len = 0;
	ll tot = 0;
	while(res[x]==-1){
		a.push_back(x);
		res[x] = len;
		tot += x;
		x = (x*x)%m;
		len++;
	}
	int peri = len - res[x];
	ll s = 0;
	for(int i = res[x];i < len;i++) s += a[i];
	ll ans = 0;
	if(n<=len) rep(i,n) ans += a[i];
	else{
		ans += tot;
		n -= len;
		ans += s*(n/peri);
		n %= peri;
		rep(i,n) ans += a[res[x]+i];
	}
	cout << ans << endl;
}






Measured memory_bytes: 4068
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()
a = list(li())

print(-(-(n-1)//(k-1)))

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

int main()
{
    int N;
    int ans = 0;
    long long D;
    vector<long long> X(200000);
    vector<long long> Y(200000);

    cin >> N >> D;

    for (int i = 0; i < N; i++)
    {
        cin >> X[i] >> Y[i];
    }

    for (int i = 0; i < N; i++)
    {
        if (X[i] * X[i] + Y[i] * Y[i] <= D * D)
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6184
#!/usr/bin/env python3


def main():
    N = int(input())
    F = [None for _ in range(N)]
    for i in range(N):
        F[i] = list(map(int, input().split()))
    
    P = [None for _ in range(N)]
    for i in range(N):
        P[i] = list(map(int, input().split()))

    ans = -10**10

    for i in range(1,2**10):
        c = [0] * N
        for j in range(10):
            if (i >> j) & 1:
                for k in range(N):
                    c[k] += F[k][j]
        
        tmp = 0
        for k in range(N):
            tmp += P[k][c[k]]
        ans = max(ans, tmp)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int N, M, K, H, W, L, R, X;
string S, T;

signed main(){
  cin >> N >> K;
  if(K==0){cout << N*N << endl; return 0;}
  int ans = 0;
  rep2(i,K+1,N+1){
    int c = N/i;
    ans += (i-K)*c;
    int d = N%i;
    if(d >= K) ans += d-K+1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3560
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  string S; cin>>S;

  map<string,int> mp;
  mp["SUN"] = 7;
  mp["MON"] = 6;
  mp["TUE"] = 5;
  mp["WED"] = 4;
  mp["THU"] = 3;
  mp["FRI"] = 2;
  mp["SAT"] = 1;

  int ans = mp[S];
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace::std;
#define int long long

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sax(x) cout << "!!!!!!!!!!! " << #x << " = " << x << '\n'
#define inf (sizeof(int) == 4 ? (int)1E9 : (int)1E18)
#define one(x) x.insert(x.begin(), 0);
#define TCT template <class T>
#define TCT12 template <class T1, class T2>
#define IS istream
#define OS ostream
#define OP operator

//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,
//tree_order_statistics_node_update> imsi;

TCT IS& OP>>(IS &I, vector<T>& v) {for (T &e: v) I >> e; return I;}
TCT OS& OP<<(OS &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const unordered_set<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const set<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const unordered_multiset<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const multiset<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT IS& OP>>(IS &I, deque<T>& v) {for (T &e: v) I >> e; return I;}
TCT OS& OP<<(OS &O, const deque<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, priority_queue<T> v) {while (!v.empty()) {O << v.top() << ' '; v.pop();} return O;}
TCT OS& OP<<(OS &O, stack<T> v) {while (!v.empty()) {O << v.top() << '\n'; v.pop();} return O;}
TCT OS& OP<<(OS &O, queue<T> v) {while (!v.empty()) {O << v.front() << ' '; v.pop();} return O;}
TCT12 IS& OP>>(IS &I, pair<T1,T2>& p) {return I >> p.first >> p.second;}
TCT12 OS& OP<<(OS &O, const pair<T1,T2>& p) {return O << '(' << p.first << ' ' << p.second << ')';}
TCT12 OS& OP<<(OS &O, const unordered_map<T1,T2>& v) {for (const auto &e: v) O << e << ' '; return O;}
TCT12 OS& OP<<(OS &O, const map<T1,T2>& v) {for (const auto &e: v) O << e << ' '; return O;}
typedef pair<int,int> pii;
typedef vector<int> vi;





void _main() {
        int a, b; cin >> a >> b;
        int now = 1;
        int cnt = 0;
        while (true) {
                if (now >= b) break;
                cnt++;
                now += a;
                now--;
        }

        cout << cnt;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 1005
using namespace std;
int n,m,a,b;
int ans[maxn][maxn];
int main()
{
	cin>>n>>m>>a>>b;
	for(int i=1;i<=b;i++)
	{
		for(int j=1;j<=a;j++)
		{
			ans[i][j]=1;
		}
	}
	for(int i=b+1;i<=n;i++)
	{
		for(int j=a+1;j<=m;j++)
		{
			ans[i][j]=1;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cout<<ans[i][j];
		}
		cout<<endl;
	}
}

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

int main(){
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for(int i=0; i<=k; ++i){
    for(int j=0; j<=k; ++j){
      if(s-i-j >= 0 && s-i-j <= k) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define pb push_back
#define mp make_pair
#define fi(i,start,end) for(int i=start; i < end ; ++i)
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mod 10000000


int main()
{
	long long int a,b,c,d;
	cin>>a>>b>>c>>d;
	long long int temp;

	temp=a*c;
	temp=max(temp,a*d);
	temp=max(temp,b*c);
	temp=max(temp,b*d);
	cout<<temp;
}


Measured memory_bytes: 3632