akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] froms = new int[m];
		int[] toes = new int[m];
		for (int i = 0; i < m; i++) {
		    froms[i] = sc.nextInt() - 1;
		    toes[i] = sc.nextInt() - 1;
		}
		long[] values = new long[m + 1];
		UnionFindTree uft = new UnionFindTree(n);
		values[m] = uft.value;
		for (int i = m - 1; i >= 0; i--) {
		    uft.unite(froms[i], toes[i]);
		    values[i] = uft.value;
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i <= m; i++) {
		    sb.append(values[i]).append("\n");
		}
	    System.out.print(sb);
   }
   
   static class UnionFindTree {
       int[] parents;
       int[] counts;
       long value;
       public UnionFindTree(int size) {
           parents = new int[size];
           counts = new int[size];
           for (int i = 0; i < size; i++) {
               parents[i] = i;
               counts[i] = 1;
           }
           value = (long)size * (size - 1) / 2;
       }
       
       public int find(int x) {
           if (x == parents[x]) {
               return x;
           } else {
               return parents[x] = find(parents[x]);
           }
       }
       
       public void unite(int x, int y) {
           int xx = find(x);
           int yy = find(y);
           if (xx == yy) {
               return;
           }
           parents[xx] = yy;
           value += (long)counts[xx] * (counts[xx] - 1) / 2;
           value += (long)counts[yy] * (counts[yy] - 1) / 2;
           counts[yy] += counts[xx];
           value -= (long)counts[yy] * (counts[yy] - 1) / 2;
       }
   }
}




Measured memory_bytes: 73648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
using ll = long long;
const ll INF = 100100100;
template <typename T> inline bool chmin(T& a, T b) { 
  if(a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> inline bool chmax(T& a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
}

int N;
long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];

    // 初期化は既に 0 に初期化される
    // 初期条件も既に 0 で OK

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    // 答え
    long long res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
    cout << res << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  string s; cin >> s;
  int odd = 0, even = 0;
  vi ans(s.size());
  int point = 0;
  rep(i,s.size()){
    odd += i%2;
    even += 1-i%2;
    if(s.substr(i,2) == "RL") point = i;
    if(s.substr(i,2) == "LR"){
      if(point % 2 == 0){
        ans[point] = even;
        ans[point+1] = odd;
      }else{
        ans[point] = odd;
        ans[point+1] = even;
      }
      odd = even = 0;
    }
  }
  if(point % 2 == 0){
    ans[point] = even;
    ans[point+1] = odd;
  }else{
    ans[point] = odd;
    ans[point+1] = even;
  }
  rep(i,s.size()) cout << ans[i] << " ";
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3784
import sys
import numpy as np
read = sys.stdin.readline


def main(n, k, a):
    for i in range(n, 100000):
        s = np.array(list(map(int, str(i))), dtype=np.int64)
        ok = True
        for j in s:
            ok &= j not in a
        if ok:
            print(i)
            break


if __name__ == '__main__':
    n, k = np.fromstring(read(), dtype=np.int64, sep=' ')
    a = np.fromstring(read(), dtype=np.int64, sep=' ')
    main(n, k, a)


Measured memory_bytes: 27008
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define INF (1LL << 60)
using namespace std;
typedef long long ll;

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

vector<edge> G[1000];
bool used[1000];

void add_edge(ll from, ll to, ll cap) {
  G[from].push_back((edge) { to, cap, (ll) G[to].size() });
  G[to].push_back((edge) { from, 0, (ll) G[from].size() - 1 }); // Directed Graph
  // G[to].push_back((edge) { from, cap, (ll) G[from].size() - 1 }); // Undirected Graph
}

ll dfs(ll v, ll t, ll f) {
  if(v == t) return f;
  used[v] = true;
  REP(i, 0, G[v].size()) {
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0) {
      ll 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;
}

ll max_flow(ll s, ll t) {
  ll flow = 0;
  while(1) {
    memset(used, 0, sizeof(used));
    ll f = dfs(s, t, INF);
    if(f == 0 || f == INF) break;
    flow += f;
  }
  return flow;
}

int main(void) {
  ll N;
  cin >> N;
  vector<ll> A(N), B(N), C(N), D(N);
  REP(i, 0, N) cin >> A[i] >> B[i];
  REP(i, 0, N) cin >> C[i] >> D[i];

  ll s = 2 * N, t = 2 * N + 1;
  REP(i, 0, N) add_edge(s, i, 1);
  REP(i, 0, N) add_edge(i + N, t, 1);
  REP(i, 0, N) REP(j, 0, N) if(A[i] < C[j] && B[i] < D[j]) add_edge(i, j + N, 1);

  cout << max_flow(s, t) << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ld pi = 3.141592653589793238;

bool isprime(int p) {
	if (p == 1) return false;
	for (int i = 2; i < p; i++) {
		if (p % i == 0) return false;
	}
	return true;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll keta(ll n) {
	ll res = 0;
	while (n >= 1) {
		res += n % 10; n /= 10;
	}
	return res;
}
ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}
ll nCk(ll n, ll k) {
	ll a = 1, b = 1;
	for (int h = n - k + 1; h <= n; h++) { a *= h; a %= mod; }
	for (int h = 1; h <= k; h++) { b *= h; b %= mod; }
	return a * modpow(b, mod - 2) % mod;
}
//printf("%.10f\n", n);


signed main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	
	string s, t;
	ll n, q, x, m, cnt = 0, ans = 0;
	cin >> n >> q;

	ans = (n - 2) * (n - 2);
	set<ll> sita, migi;
	sita.insert(0); migi.insert(0);
	map<ll, ll> S, M; S[0] = n - 2; M[0] = n - 2;
	//cout << ans << endl;
	rep(i, q) {
		ll a, b; cin >> a >> b;
		if (a == 1) {//sita
			auto itr = sita.lower_bound(b); itr--;
			ans -= S[*itr];
			sita.insert(b); S[b] = S[*itr];
			if (*itr == 0) { M[0] = b - 2; }
		}
		else {
			auto itr = migi.lower_bound(b); itr--;
			ans -= M[*itr];
			migi.insert(b); M[b] = M[*itr];
			if (*itr == 0) { S[0] = b - 2; }
		}
		//cout << ans << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 25528
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int K = in.nextInt();
		long h[]=new long[N];
		for(int i=0;i<N;i++) {
			h[i]=in.nextLong();
		}
		Arrays.sort(h);
		long max=1000000001;
		for(int i=0;i<N-K+1;i++) {
			max=Math.min(max,h[i+K-1]-h[i]);
		}
		System.out.println(max);

	}
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; i++)

typedef long long ll;

int main()
{
	int xx, yy, n;
	cin >> xx >> yy >> n;
	int x, y;
	vector<int> a[200010];
	rep(i, yy) a[i+1].push_back(xx+1);
	rep(i, n)
	{
		cin >> x >> y;
		a[y].push_back(x);
	}
	rep(i, yy) sort(a[i+1].begin(), a[i+1].end());
	int th=1;
	int ans=a[1][0]-1;
	for(int i=2; i<=min(yy, xx); i++)
	{
		for(int j=0; j<a[i].size(); j++)
		{
			if(a[i][j]==th+1) th++;
			else if(a[i][j]>th+1)
			{
				ans=min(ans, a[i][j]-1);
				th++;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11648
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;
    int ans = 0;
    cin >> n;

    vector<int> p(n);

    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }

    for (int i = 1; i < n - 1; i++)
    {
        if (p[i] > p[i - 1] && p[i] > p[i + 1])
        {
        }
        else if (p[i] < p[i - 1] && p[i] < p[i + 1])
        {
        }
        else
        {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
struct data{
    int a,b,c;
};

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
#define MAXSIZE 200000
int list[MAXSIZE];
int tail;

void Init(void){
    tail=0;
}
int Top(void){
    return 0;
}

int Next(int pos){
    if(pos<tail-1){
        return pos+1;
    }else{
        return -1;
    }
}
int Count(void){
    return tail;
}

int Item(int pos){
    if((pos>=0)&&(pos<tail)){
        return list[pos];
    }else{
        return 0;
    }
}
void Add(int value){
    if(tail<MAXSIZE){
        list[tail]=value;
        tail++;
    }
}
void Delete(int pos){
    if((pos>=0)&&(pos<tail)){
        int i;
        for(i=pos;i<tail-1;i++){
            list[i]=list[i+1];
        }
        tail--;
    }
}

int main(){
    int s;
    scanf("%d",&s);
    if(s==2){
        printf("%d",2);
        return 0;
    }else{
        ;
    }
    while(1){
        int jd=0;
        for(int i=2;i<=sqrt(s);i++){
            if(s%i==0){
                jd=1;
            }else{
                ;
            }
        }
        if(jd==0){
            printf("%d",s);
            return 0;
        }else{
            ;
        }
        s++;
    }
}


Measured memory_bytes: 2124
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

const int M = 62;

int n, a[N];
int32_t main(){_

   cin>>n;

   for (int i = 0; i < n; ++i)
   {
      cin>>a[i];
   }

   vector<int> cnt(M, 0);
   for (int i = 0; i < n; ++i)
   {
      for (int j = 0; j < M; ++j)
      {
         if(a[i] & (1LL << j))
            cnt[j]++;
      }
   }
   
   int ans = 0;
   for (int j = 0; j < M; ++j)
   {
      int ok = (cnt[j]) * (n - cnt[j]) % mod;
      ok *= ((1LL << j) % mod);
      ok %= mod;
      ans += ok;
      ans %= mod;
   }
   
   cout<<ans;

   return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>

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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> as(N, 0);
    ll h = 0;
    ll w = 0;
    for(int i = 0; i < N;  i ++){
        cin >> as[i];
    }
    sort(as.begin(), as.end());

    for(int i = 0; i < N; ){
        int a = as[i];
        int cnt = 1;
        i ++;
        for(int j = i; j < N; j ++){
            i = j;
            if(a != as[j]){
                break;
            }
            cnt ++;
        }
        if(2 <= cnt && cnt <= 3){
            // h < w;
            h = w;
            w = a;
        }
        if(4 <= cnt){
            h = w = a;
        }
    }
    cout << h * w << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int main(){
    int n, a[100010], min=2e9, kari, j;
    bool check=true;;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(min > a[i]){
            min = a[i];
            j=i;
        }
    }
    kari = min;
    while(check){
        check = false;
        for(int i=0; i<n; i++){
            if(kari > a[i]%min && a[i]%min != 0){
                kari = a[i]%min;
                check=true;
                j=i;
            }
        }
        min = kari;
        a[j] = kari;
    }
    cout << min << endl;
}

Measured memory_bytes: 640
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);
 
int a[101010], b[101010];
vector<pair<int, int>>v;
const int MOD = 1e9 + 7;
 
int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i], v.emplace_back(a[i], 1);
	for (int i = 0; i < n; i++) cin >> b[i], v.emplace_back(b[i], 2);
	sort(ALL(v));
	LL ans = 1;
	int pa = 0, pb = 0;
	for (int i = 0; i < 2 * n; i++) {
		if (v[i].second == 1) {
			if (pb == 0)pa++;
			else (ans *= pb) %= MOD,pb--;
		}
		if (v[i].second == 2) {
			if (pa == 0)pb++;
			else (ans *= pa) %= MOD,pa--;
		}
	}
	cout << ans%MOD << endl;
}

Measured memory_bytes: 2932
import numpy as np
n = int(input())
value = np.array(tuple(map(int, input().split())))
cost = np.array(tuple(map(int, input().split())))
xy = value - cost
ans = 0
for i in range(n):
    if xy[i] < 0:
        continue
    else:
        ans += xy[i]
print(ans)

Measured memory_bytes: 12508
#include "bits/stdc++.h"
using namespace std;
#include "string"
#define int long long
#define pi pair <int, int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl '\n'

typedef struct segnode{
	int ans=0;
	segnode operator + (const segnode &b) {
		segnode tmp;
		tmp.ans = max(ans , b.ans);
		return tmp;
	}
}sn;


sn merge(sn a, sn b)
{
	return a + b;
}

int n;

class segment_tree{
private:
	vector< int > a;
	vector< sn > tree;

public:
	segment_tree(vector < int > &v){
		n = v.size();
		a = v;
		tree.resize(4 * n);
	}
	void built(int x = 1,int ss = 0,int ee = n - 1) {
		if(ss == ee) {
			tree[x] = {a[ss]};
			return;
		}
		int m = (ss + ee) / 2;
		built(2 * x, ss, m);
		built(2 * x + 1, m + 1, ee);
		tree[x] = merge(tree[2 * x], tree[2 * x + 1]);
	}

	void update(int pos,int val,int x = 1,int ss = 0,int ee = n - 1) {
		if(ss>pos || ee<pos || ss>ee)
			return;
		if(ss == ee) {
			tree[x] = {val};
			return;
		}
		int m = (ss + ee) / 2;
		update(pos, val, 2 * x, ss, m);
		update(pos, val, 2 * x + 1, m + 1, ee);
		tree[x] = merge(tree[2 * x], tree[2 * x + 1]);
	}

	sn query(int l, int r, int x = 1, int ss = 0, int ee = n - 1) {
		if(ss > r || ee < l ||ss > ee)
			return tree[0];
		if(l <= ss && r >= ee)
			return tree[x];
		int m = (ss + ee) / 2;
		sn p=query(l, r, 2 * x, ss, m);
		sn q=query(l, r, 2 * x + 1, m + 1, ee);
		return merge(p, q);
	}
};


const int N = 3e5 + 5;

int32_t main() {
	boost;
	int n, k;
	cin >> n >> k;
	vector < int > a(n);
	for(int &i : a)
		cin >> i;
	vector < int > v(N, 1);
	segment_tree st(v);
	for(int &i : a) {
		int maxi = st.query(i - k, i + k).ans;
		st.update(i, maxi + 1);
	}
	cout << st.query(1, N - 1).ans << endl;
}

Measured memory_bytes: 19588
import numpy as np

n, k, q = map(int, input().split())

a = np.full(n, k)
plus_point = np.zeros(n, dtype=np.int)

for _ in range(q):
    seikaisha = int(input()) - 1
    plus_point[seikaisha] += 1


a -= q
a += plus_point

for sankasha_point in a:
    if sankasha_point > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 14756
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}

func readLines() -> [String] {
    return readLine()!.map { String($0) }
}

///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}
// https://algo-logic.info/divisor/
/// 約数の配列を返す
func divisor(_ n:Int) -> [Int] {
    var ret = [Int]()
    var i = 1
    while i * i <= n {
        if n % i == 0 {
            ret.append(i)
            if i * i != n {
                ret.append(n / i)
            }
        }
        i += 1
    }
    return ret.sorted()
}

func main() {
    let input = readInts()
    let (X, Y) = (input[0], input[1])
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    var x = X
    var count = 0
    while x <= Y {
        x *= 2
        count += 1
    }
    print(count)
}
main()


Measured memory_bytes: 13520
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


const int MAX = 101010;
const int MOD = 998244353;
ll fac[MAX], finv[MAX], inv[MAX];

void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int K, N;
	cin >> K >> N;
	combinit();


	for (int i = 2; i <= 2 * K; i++) {
		set<pair<int, int>>st;
		int same = 0;
		for (int x = 1; x <= K; x++) {
			int y = i - x;
			if (1 <= y && y <= K && x <= y) {
				st.insert({ x,y });
				if (x == y)same = 1;
			}
		}
		int pcnt = st.size();
		ll tot = comb(N + K - 1, K - 1);
			for (int m = 1; m <= pcnt; m++) {
				ll temp = comb(pcnt, m);
				temp *= comb(N - 2 * m + K - 1, K - 1);
				temp %= MOD;
				if (m % 2 == 0)tot += temp;
				else tot -= temp;
				tot += 2LL * MOD;
				tot %= MOD;
			}
		puts(tot);
	}

	return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

V<int> dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    V<int> p(n * n);
    for (int i = 0; i < n * n; i++) {
        cin >> p[i];
        p[i]--;
    }

    V< V<int> > dist(n, V<int>(n, INF));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            dist[i][j] = min({i, j, n - i - 1, n - j - 1});
        }
    }
    V< V<bool> > used(n, V<bool>(n, true));

    int ans = 0;
    for (int i = 0; i < n * n; i++) {
        // for (int iii = 0; iii < n; iii++) DEBUG_VLL(dist[iii])
        // cerr << '\n';
        int h = p[i] / n, w = p[i] % n;
        ans += dist[h][w];

        queue< P<int, int> > que;
        for (int di = 0; di < 4; di++) {
            int nxth = h + dx[di], nxtw = w + dy[di];
            if (nxth < 0 || nxth >= n || nxtw < 0 || nxtw >= n) continue;
            if (dist[nxth][nxtw] > dist[h][w]) {
                dist[nxth][nxtw] = dist[h][w];
                que.push( make_pair(nxth, nxtw) );
            }
        }
        used[h][w] = false;

        while (!que.empty()) {
            P<int, int> q = que.front(); que.pop();
            for (int di = 0; di < 4; di++) {
                int nxth = q.first + dx[di], nxtw = q.second + dy[di];
                if (nxth < 0 || nxth >= n || nxtw < 0 || nxtw >= n) continue;
                if (used[q.first][q.second]) {
                    if (dist[nxth][nxtw] > dist[q.first][q.second] + 1) {
                        dist[nxth][nxtw] = dist[q.first][q.second] + 1;
                        que.push( make_pair(nxth, nxtw) );
                    }
                } else {
                    if (dist[nxth][nxtw] > dist[q.first][q.second]) {
                        dist[nxth][nxtw] = dist[q.first][q.second];
                        que.push( make_pair(nxth, nxtw) );
                    }
                }
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 5280
import numpy as np
N = int(input())
P = []
for n in range(N):
    x, y = map(int, input().split())
    P.append((x, y))


def dist(p0, p1):
    x0, y0, x1, y1 = p0[0], p0[1], p1[0], p1[1]
    return (x0 - x1) ** 2 + (y0 - y1) ** 2


def f(x, y):
    return max([dist(p, (x, y)) for p in P])


def minfx(y):
    left = 0
    right = 1000
    for _ in range(80):
        left_ = left * (2 / 3) + right * (1 / 3)
        right_ = left*(1/3)+right*(2/3)
        if f(left_, y) <= f(right_, y):
            right = right_
        else:
            left = left_
    x0 = (left + right) / 2
    return f(x0, y)


left = 0
right = 1000
for _ in range(80):
    left_ = left * (2 / 3) + right * (1 / 3)
    right_ = left*(1/3)+right*(2/3)
    if minfx(left_) <= minfx(right_):
        right = right_
    else:
        left = left_
y0 = (left + right) / 2
print(np.sqrt(minfx(y0)))


Measured memory_bytes: 12452
using System;

namespace ABC139
{
    class Program
    {
        static void Main(string[] args)
        {
            var n_var = System.Console.ReadLine();
            int N = System.Int32.Parse(n_var);

            long score = 0;

            if (N != 0)
            {
                for (int i = 0; i < N; i++)
                {
                    score += i;
                }
            }
            else
            {
                score = 0;
            }

            Console.WriteLine(score);
        }
    }
}


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

int main() {
  string s, t;
  cin >> s >> t;
  int count = 0;
  for(int i = 0; i < 3; i++) {
    if(s[i] == t[i]) {
      count++;
    }
  }
  cout << count << endl;
}
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int a[n];
    map<int,int>frequency1;
    map<int,int>frequency2;
    for(int i=0;i<n;i++)
    {
           cin>>a[i];
    }
    for(int i=0;i<n;i+=2)
      frequency1[a[i]]++;
    for(int i=1;i<n;i+=2)
      frequency2[a[i]]++;
    int maxfrequency1=0;
    int max1=0;
    for(int i=0;i<n;i+=2)
    {
        if(frequency1[a[i]]>maxfrequency1)
        {
            maxfrequency1=frequency1[a[i]];
            max1=a[i];
        }
    }
    int maxfrequency2=0;
    int max2=0;
    for(int i=1;i<n;i+=2)
    {
         if(frequency2[a[i]]>maxfrequency2)
         {
            maxfrequency2=frequency2[a[i]];
            max2=a[i];
         }
    }
    int ans=0;
    if(max1!=max2)
    {
      for(int i=0;i<n;i+=2)
      {
          if(a[i]!=max1)
            ++ans;
      }
      for(int i=1;i<n;i+=2)
      {
          if(a[i]!=max2)
          ++ans;
      }
      cout<<ans;
      return 0;
    }
    int fuck=0;
    int ans1=0;
    for(int i=0;i<n;i+=2)
    {
        if(frequency1[a[i]]>=ans1&&a[i]!=max1)
        {
             ans1=frequency1[a[i]];
             fuck=a[i];
        }
    }
    int temp=0;
    int temp1=0;
    for(int i=1;i<n;i+=2)
    {
        if(frequency2[a[i]]>=temp1&&a[i]!=max2)
        {
            temp1=frequency2[a[i]];
            temp=a[i];
        }
    }
    if(fuck==0&&temp==0)
    {
        cout<<n/2;
        return 0;
    }
    int ans2;
    ans1=ans2=0;
    for(int i=1;i<n;i+=2)
    {
        if(a[i]!=temp)
          ++ans1;
    }
    for(int i=0;i<n;i+=2)
    {
       if(a[i]!=fuck)
        ++ans2;
    }
    for(int i=0;i<n;i+=2)
      if(a[i]!=max1)
        ans1++;
    for(int i=1;i<n;i+=2)
      if(a[i]!=max2)
        ans2++;
    cout<<min(ans1,ans2);
 }

    

Measured memory_bytes: 5376
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

vector<pair<int, int>> vp;

int main(){
    cin.tie(0);

    int N; cin >> N;
    for (int i = 0; i < N; i++){
        int a; cin >> a;
        vp.push_back({a, 0});
    }
    for (int i = 0; i < N; i++){
        int b; cin >> b;
        vp.push_back({b, 1});
    }

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

    long long A = 0, B = 0;
    long long ans = 1;
    for (int i = 0; i < vp.size(); i++){
        if (vp[i].second){
            if (B == 0) A++;
            else{
                ans *= B;
                ans %= MOD;
                B--;
            }
        }else{
            if (A == 0) B++;
            else{
                ans *= A;
                ans %= MOD;
                A--;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2420
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define lowbit(x) x&(-x)
#define PII  pair<int, int> 
#define all(x) x.begin(), x.end()
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
typedef long long ll;
const ll inf = 1e18;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e3 + 5;
using namespace std;
 
#define int ll
 
struct node{
	int x, y;
}a[maxn];
 
int d[50];
int dir[4][2] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} };
string s = "RLDU";
int n, cnt = 0;
 
int dis(int x1, int y1, int x2, int y2){
	return abs(x1 - x2) + abs(y1 - y2);
}
 
void work(int x, int y){
	node now;
	now.x = x,now.y = y;
	for(int i = 1; i <= cnt; i++){
		int Min = inf;
		int pos = 0;
		for(int j = 0; j < 4; j++){
			int tx = now.x + dir[j][0] * d[i], ty = now.y + dir[j][1] * d[i];
			int t = dis(tx, ty, 0, 0);
			if(Min > t) Min = t, pos = j;
		}
		now.x += d[i] * dir[pos][0], now.y += d[i] * dir[pos][1];
		putchar(s[pos]);
	}
	puts("");
}
 
int32_t main()
{
	scanf("%lld", &n);
	for(int i = 1; i <= n; i++){
		scanf("%lld %lld", &a[i].x, &a[i].y);
		if((abs(a[i].x + a[i].y) & 1) != (abs(a[1].x + a[1].y) & 1)) return 0 * puts("-1");
	}
	for(int i = 30; i >= 0; i--){
		d[++cnt] = 1 << i;
	}
	if((a[1].x + a[1].y) % 2 == 0) d[++cnt] = 1;
	printf("%lld\n", cnt);
	for(int i = 1; i < cnt; i++)
		printf("%lld ", d[i]);
	printf("%lld\n", d[cnt]);
	for(int i = 1; i <= n; i++){
		work(a[i].x, a[i].y);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <math.h>
typedef long long ll;
using namespace std;

int main() {
	ll n,ans=0,p;
	cin >>n;
	if(n==1){
		cout << 1<<endl;
		return 0;
	}
	for(int i=1;i<=n/2;i++){
		for(int j=1;j<10;j++){
			p=pow(i,j);
			if(p<=n){
				ans=max(ans,p);
			}
		}
	}
	cout<<ans<< endl;
 	return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, ans =0;
	cin >>n;
	vector<VI> zc(10, VI(10));
	rep(i, n){
		string  s = to_string(i+1);
		if(s[sz(s)-1]=='0') continue;
		zc[s[0]-'0'][s[sz(s)-1]-'0']++;
	}
	rep(i, n){
		string  s = to_string(i+1);
		if(s[sz(s)-1]=='0') continue;
		ans += zc[s[sz(s)-1]-'0'][s[0]-'0'];
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define len(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int n,a,b;cin>>n>>a>>b;
  cout << min(n*a, b);
}


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

struct item{
	int p;
	int memo;
	vector<item*> q;
	
	item(): memo(-1) {}
};

map<string,item> table;

int getcost(item &it){
	if(it.memo == -1){
		it.memo = it.p;
		if(!it.q.empty()){
			int s = 0;
			for(int i = 0; i < it.q.size(); ++i){
				s += getcost(*it.q[i]);
			}
			it.memo = min(it.p, s);
		}
	}
	return it.memo;
}

int main(){
	int n, m, p, k;
	string s;
	while(cin >> n, n){
		table.clear();
		for(int i = 0; i < n; ++i){
			cin >> s >> p;
			table[s].p = p;
		}
		cin >> m;
		for(int i = 0; i < m; ++i){
			cin >> s >> k;
			vector<item*> &v = table[s].q;
			v.resize(k);
			for(int j = 0; j < k; ++j){
				cin >> s;
				v[j] = &table[s];
			}
		}

		cin >> s;
		cout << getcost(table[s]) << '\n';
	}
}

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

using namespace std;

typedef long long LL;

const int MOD = 1000000007;

vector<int> a;

vector<int> f;

int bpow(int a, int b) {
    if (b == 0) {
        return 1;
    }
    int r = bpow(a, b / 2);
    return (LL) r * r % MOD * (b % 2 == 1 ? a : 1) % MOD;
}

int C(int n, int k) {
    if (k < 0 || k > n) {
        return 0;
    }
    return (LL) f[n] * bpow(f[k], MOD - 2) % MOD * bpow(f[n - k], MOD - 2) % MOD;
}

int main() {
    int n, k;
    cin >> n >> k;
    a.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    f.resize(n + 1);
    f[0] = 1;
    for (int i = 1; i <= n; ++i) {
        f[i] = (LL) f[i - 1] * i % MOD;
    }
    sort(a.begin(), a.end());
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        sum = (sum - (LL) a[i] * C(n - i - 1, k - 1) % MOD + MOD) % MOD;
        sum = (sum + (LL) a[i] * C(i, k - 1) % MOD + MOD) % MOD;
    }
    cout << sum << '\n';
    return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

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

  ll ans = 0;
  rep(i, n) {
    if (i % 2 == 0) {
      ans += a[i];
    } else {
      ans -= a[i];
    }
  }
  cout << ans;
  rep(i, n - 1) {
    cout << " ";
    ans = (a[i] - ans/2) * 2;
    cout << ans;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 2176
import java.util.Scanner;

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

    //input
    int l = sc.nextInt();
    int r = sc.nextInt();
    int d = sc.nextInt();

    //output
    int count = 0;
    for(int i = l; i <= r; i++){
      if( i % d == 0 ){ //if divisible
        count++;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 26924
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 200009
#define MOD 1000000007
#define INF 1000000000
using Graph=vector<vector<int>>;

int main(){
  int N;
  ll K;
  cin>>N>>K;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    A.at(i)--;
  }
  vector<vector<int>> warp(N,vector<int>(70));
  for(int i=0;i<N;i++){
    warp.at(i).at(0)=i;
    warp.at(i).at(1)=A.at(i);
  }
  for(int j=2;j<70;j++){
    for(int i=0;i<N;i++){
      warp[i][j]=warp[warp[i][j-1]][j-1];
    }
  }
  int town=0;
  for(int j=1;j<70;j++){
    int bit=K%2;
    if(bit==1){
      town=warp[town][j];
    }
    K/=2;
  }
  cout<<town+1<<endl;
}


Measured memory_bytes: 65020
//新幹線からAC

#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
using namespace std;
    
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define rep(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
    
using ll = long long;
const ll INF = LLONG_MAX / 4 - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
    
class fact {
public:
    int fmod = 1e9+7;
    vector<int> fac, inv;
    fact (int n, int Mod = 1e9+7) {
        fmod = Mod;
        fac = vector<int>(n,0);
        inv = vector<int>(n,0);
        fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
        for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
    }
    ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
    ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
    
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return (a / GCD(a,b)) * b;}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}

bool solve() {
    int n; cin >> n;
    vi x(n), y(n), h(n);
    vector<int> xyz;
    rep (i, n) {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i]) {
            xyz = {x[i], y[i], h[i]};
        }
    }
    rep (i, 101) {
        rep (j, 101) {
            int H = xyz[2] + abs(i - xyz[0]) + abs(j - xyz[1]);
            bool flag = true;
            rep (k, n) {
                int cand = max(0ll, H - abs(i - x[k]) - abs(j - y[k]));
                if (cand != h[k]) flag = false;
            }
            if (flag) {
                cout << i << " " << j << " " << H << endl;
                return 0;
            }
        }
    }
}

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <tuple>
using namespace std;

const int MOD = 1e9 + 7;

int main(){

    int n; cin >> n;

    string str;
    cin >> str;

    map<char, int> m;

    for(int i=0; i<n; i++){
        if(m.find(str[i]) == m.end()){
            m.insert(make_pair(str[i],1));
        }
        else{
            m[str[i]]++;
        }
    }

    map<char, int>::iterator itr;

    long long cnt = 1;
    for(itr = m.begin(); itr != m.end(); itr++){
        pair<char, int> p = *itr;
        cnt = (cnt * (p.second + 1)) % MOD;
    }

    cout << cnt - 1;

    return 0;
}

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

using namespace std;

int main()
{
  int N; cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; ++i) {
    cin >> s[i];
  }

  int M; cin >> M;
  vector<string> t(M);
  for (int i = 0; i < M; ++i) {
    cin >> t[i];
  }

  map<string, int> blue, red;

  for (int i = 0; i < N; ++i) {
    blue[s[i]]++;
  }

  for (int i = 0; i < M; ++i) {
    red[t[i]]++;
  }

  int ans = 0;
  for (auto x : blue) {
    ans = max(ans, x.second - red[x.first]);
  }

  cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct Dice{
    int lab[6];
    void in(){
        for(int i=0;i<6;i++){
            cin >> lab[i];
        }
    }
    void roll(char a){
        if(a=='S'){
            int stock;
            stock=lab[0];
            lab[0]=lab[4];
            lab[4]=lab[5];
            lab[5]=lab[1];
            lab[1]=stock;
        }
        if(a=='N'){
            int stock;
            stock=lab[0];
            lab[0]=lab[1];
            lab[1]=lab[5];
            lab[5]=lab[4];
            lab[4]=stock;
        }
        if(a=='W'){
            int stock;
            stock=lab[0];
            lab[0]=lab[2];
            lab[2]=lab[5];
            lab[5]=lab[3];
            lab[3]=stock;
        }
        if(a=='E'){
            int stock;
            stock=lab[0];
            lab[0]=lab[3];
            lab[3]=lab[5];
            lab[5]=lab[2];
            lab[2]=stock;
        }
    }
    
    int top(){
        return lab[0];
    }
};

int main() {
    Dice d;
    d.in();
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        d.roll(s.at(i));
    }
    cout << d.top() << endl;
}


Measured memory_bytes: 3184
import java.util.*
 
fun main(args: Array<String>) {
    val argList = Scanner(System.`in`)
 
 
    val firstLine = argList.nextLine().split(" ")
    val l = firstLine[0].toLong()
    val r = firstLine[1].toLong()
 
    val e = RemainderMinimization2019()
    println(e.execute(l, r))
 
}
 
class RemainderMinimization2019 {
    private val r2019 = 2019
    fun execute(l: Long, r: Long): Long {
 
        val lMod = l % r2019
        val rMod = r % r2019
 
        if (lMod == 0L || rMod == 0L) return 0
 
        if (l + (r2019 - lMod)  <= r ) {
            // 2019以上離れている場合、
            // 2019の倍数を選べばよいので、modの最小値は0
            return 0
        }
 
        var ans: Long = 2018
        for (n in l..r) {
            for (i in n + 1..r) {
                val result = n * i % r2019
                if (ans > result) {
                    ans = result
                }
            }
        }
 
        return ans
    }
}

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

int main() {
  long long n, r=0;
  cin >> n;
  if(n%2!=0) cout << 0 << endl;
  else {
    for(long long d=10;d<=n;d*=5) r += n / d;
    cout << r << endl;
  }
}

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

#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=1e5+10, maxm=5e4+10, lg=21, mod=998244353, inf=1e18;

struct adam{ll g,s,b;bool operator<(adam &x){return g-s>x.g-x.s;}}a[maxn];
ll x,y,z,ans,lans[maxn],rans[maxn];
priority_queue<ll> q;

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>x>>y>>z;
	for(int i=0;i<x+y+z;i++) cin>>a[i].g>>a[i].s>>a[i].b;
	sort(a,a+x+y+z);
	for(int i=0;i<x+z;i++){
		q.push(a[i].b-a[i].g);
		lans[i]=lans[i-1]+a[i].g;
		if(i>=x) lans[i]+=q.top(), q.pop();
	}
	while(!q.empty()) q.pop();
	for(int i=x+y+z-1;i>=x;i--){
		q.push(a[i].b-a[i].s);
		rans[i]=rans[i+1]+a[i].s;
		if(i<x+z) rans[i]+=q.top(), q.pop();
	}
	for(int i=x-1;i<x+z;i++) ans=max(ans,lans[i]+rans[i+1]);
	cout<<ans;

	return 0;
}



 


Measured memory_bytes: 7268
#include<algorithm>
#include<iostream>
#include<vector>

int main(){
  int n; std::cin >> n;
  std::vector<int> v(3*n);
  for(auto i=0; i<3*n; ++i)
    std::cin >> v[i];
  std::sort(v.begin(), v.end());
  auto r = 0LL;
  auto j = 3*n-1;
  for(auto i=0; i<n; ++i)
    {
      --j;
      r += v[j];
      --j;
    }
  std::cout << r << '\n';
}


Measured memory_bytes: 1408
import numpy as np
from numpy.fft import rfft, irfft
from itertools import cycle

mod = 10 ** 9 + 7
S = input()

mat = []
for i in range(6):
    w = np.zeros(13)
    for j in range(10):
        w[(10 ** i * j) % 13] += 1
    mat.append(rfft(w))

ress = [[(10 ** i * j) % 13 for j in range(10)] for i in range(6)]


state = np.zeros(13)
state[0] = 1
state = rfft(state)

res = 5
for keta, s in zip(cycle(range(6)), S[::-1]):
    if s == "?":
        state = state * mat[keta]
        if state[0] >= 2 ** 50:
            state = np.round(irfft(state, 13))
            state = rfft(np.remainder(state, mod))
    else:
        res -= ress[keta][int(s)]


state = irfft(state, 13)
print(int(np.round(state[res % 13])) % mod)


Measured memory_bytes: 12968
def main():
    mod=1000000007
    r1,c1,r2,c2=map(int,input().split())
    Fact=[1] #階乗
    n=r2+c2+1
    for i in range(1,n+1):
        Fact.append(Fact[i-1]*i%mod)
    Finv=[0]*(n+1) #階乗の逆元
    Finv[-1]=pow(Fact[-1],mod-2,mod)
    for i in range(n-1,-1,-1):
        Finv[i]=Finv[i+1]*(i+1)%mod
    def comb(n,r):
        if n<r:
            return 0
        return Fact[n]*Finv[r]*Finv[n-r]%mod
    def f(r,c):
        ret=0
        for i in range(r+1):
            ret+=comb(c+i+1,c)
            ret%=mod
        return ret
 
    print((f(r2,c2)-f(r2,c1-1)-f(c2,r1-1)+f(r1-1,c1-1))%mod)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 124856
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    for (int i=0, zi; i<5; i++) {
        cin >> zi;
        if (zi == 0) {
            cout << i + 1 << '\n';
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3572