akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define MAX 100005
#define NIL -1
 
struct Node{
int p, l, r;
};
struct Node Tree[MAX];
int n;

int main(){
  int a, c, d, i, j, l, v;
 
  scanf("%d", &n);
 
  for(i = 0; i < n; i++) Tree[i].p = Tree[i].l = Tree[i].r = NIL;
 
  for(i = 0; i < n; i++){
    scanf("%d %d", &v, &d);
    for(j = 0;j < d; j++){
      scanf("%d", &c);
      Tree[c].p = v;
      if(j == 0) Tree[v].l = c;
      else Tree[a].r = c;
      a = c;
    }
  }
  for(i = 0; i < n; i++) print(i);

  return 0;
}



int getDepth(int u){
  int d = 0, i;

  for(i = u;Tree[i].p != NIL; i = Tree[i].p, d++);

  return d;
}
 
void print(int u){

  int b = getDepth(u), c = Tree[u].l;

  printf("node %d: parent = %d, depth = %d, ", u, Tree[u].p, b);

  if(b == 0) printf("root, ");
  else if (Tree[u].l != NIL) printf("internal node, ");
  else printf("leaf, ");
  printf("[");
  if(Tree[u].l==NIL) printf("]\n");
  else {
    while(1){
      printf("%d", c);
      if(Tree[c].r == NIL){
    printf("]\n");
    break;
      }
      else printf(", ");
      c = Tree[c].r;
    }
  }
}

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    string s; ll n; cin >> s >> n;
    for(ll i=0; i<s.size(); i+=n){
        cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
n, X = map(int, input().split())
x = list(map(int, input().split()))
rec = set()
for i in range(n):
    rec.add(abs(x[i] - X))

rec = sorted(list(rec))


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


num = rec[0]
for k in range(1, len(rec)):
    num = gcd(num, rec[k])


print(num)


Measured memory_bytes: 16784
/*Flamenco Sketches*/
#include<bits/stdc++.h>
using namespace std;
 
#define NL '\n'
#define xx first
#define yy second
#define ll long long
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define sz(x) x.size()
#define all(x) (x).begin(), (x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;++i)
#define async() ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 
//#define FayeValentine 
void dbg(){cerr<<NL;}template<typename H,typename... T> void dbg(H h,T... t){cerr<<' '<<h;dbg(t... );}
#ifdef  FayeValentine
#define debug(...) cerr<<"("<<#__VA_ARGS__<<"):",dbg(__VA_ARGS__)
#else
#define debug(...) 
#endif


void absinthe() {
	int n; cin >> n;
	vector<ll>a(n); rep(i, 0, n) cin >> a[i];
	ll lcm = 1;
	for(int i = 0; i < n; i++) lcm = (a[i]*(lcm / __gcd(a[i], lcm)));	
	cout << lcm << NL;
}
 
 
int main(){
  //freopen("input.txt", "r", stdin);
  async();
  int __t = 1; //cin >> __t;
  for(int __c = 1; __c <=__t; __c++) {
    //cout << "Case #" << __c << ": "; 
    absinthe();
  }
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;
const ll MAX_N=1e5,INF=1e18;
ll N,S[MAX_N];
typedef pair<ll,ll> P;
vector<P> G[MAX_N];
ll ans[MAX_N-1],chl[MAX_N],unv,uninx,dis[MAX_N];
void calchl(ll v,ll p){
	for(auto pa:G[v]){
		ll e=pa.first;
		if(e!=p){
			calchl(e,v);
			chl[v]+=chl[e];
		}
	}
	chl[v]++;
}
void dfs(ll v,ll p){
	REP(i,G[v].size()){
		P e=G[v][i];
		if(e.first!=p){
			if(2*chl[e.first]-N==0){
				unv=v;
				uninx=i;
			}else{
				ans[e.second]=(S[v]-S[e.first])/(2*chl[e.first]-N);
			}
			dfs(e.first,v);
		}
	}
}
void caldis(ll v,ll p,ll d){
	dis[v]=d;
	for(auto e:G[v]){
		if(e.first!=p){
			caldis(e.first,v,min(d+ans[e.second],INF+1));
		}
	}
}
int main(){
	scanf("%lld",&N);
	REP(i,N-1){
		ll a,b;
		scanf("%lld %lld",&a,&b);
		a--;
		b--;
		G[a].push_back(P(b,i));
		G[b].push_back(P(a,i));
	}
	REP(i,N)scanf("%lld",S+i);
	calchl(0,-1);
	unv=-1;
	dfs(0,-1);
	if(unv!=-1){
		ll lb=1,ub=INF+1;
		while(ub-lb>1){
			ll mid=(lb+ub)>>1;
			ans[G[unv][uninx].second]=mid;
			caldis(0,-1,0);
			ll sm=0;
			REP(i,N){
				sm+=dis[i];
				if(sm>INF){
					sm=INF+1;
				}
			}
			if(sm<=S[0]){
				lb=mid;
			}else{
				ub=mid;
			}
		}
		ans[G[unv][uninx].second]=lb;
	}
	REP(i,N-1){
		printf("%lld\n",ans[i]);
	}
		
}

Measured memory_bytes: 17280
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> A;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A.push_back(t);
    }

    int64_t ans = INT64_MAX;

    for (int64_t y = -100; y <= 100; ++y) {
        int64_t c = 0;
        for (auto x: A) {
            c += (x-y)*(x-y);
        }
        ans = std::min(ans, c);
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=400005;

struct node {
	int mn=0x7fffffff,lazy=-1;	
} S[maxn];
int n,q;

void update(int id,int ql,int qr,int v,int l,int r) {
	if (ql==l && qr==r) {
		S[id].lazy=v;
		return;
	}
	if (S[id].lazy!=-1) {
		S[id].mn=S[id].lazy;
		if (l!=r) S[id<<1].lazy=S[id<<1|1].lazy=S[id].lazy;
		S[id].lazy=-1;
	}
	int m=l+r>>1;
	if (qr<=m) update(id<<1,ql,qr,v,l,m);
	else if (ql>m) update(id<<1|1,ql,qr,v,m+1,r);
	else update(id<<1,ql,m,v,l,m), update(id<<1|1,m+1,qr,v,m+1,r);
	int lm=S[id<<1].lazy!=-1?S[id<<1].lazy:S[id<<1].mn;
	int rm=S[id<<1|1].lazy!=-1?S[id<<1|1].lazy:S[id<<1|1].mn;
	S[id].mn=min(lm,rm);
}

int query(int id,int ql,int qr,int l,int r) {
	if (S[id].lazy!=-1) {
		S[id].mn=S[id].lazy;
		if (l!=r) S[id<<1].lazy=S[id<<1|1].lazy=S[id].lazy;
		S[id].lazy=-1;
	}
	if (ql==l && qr==r) return S[id].mn;
	int m=l+r>>1;
	if (qr<=m) return query(id<<1,ql,qr,l,m);
	else if (ql>m) return query(id<<1|1,ql,qr,m+1,r);
	else return min(query(id<<1,ql,m,l,m),query(id<<1|1,m+1,qr,m+1,r));
}

int main() {
	cin>>n>>q;
	for (int i=0;i<q;i++) {
		bool op; cin>>op;
		int s,t,x;
		if (op) {
			cin>>s>>t;
			cout<<query(1,s,t,0,n-1)<<'\n';
		}
		else {
			cin>>s>>t>>x;
			update(1,s,t,x,0,n-1);
		}
	}
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n + 1);
	for (int i = 1; i < n + 1; i++)
	{
		cin >> a[i];
	}
	int light = 1;
	int old = 0;
	int count = 0;
	for(int i = 0; i < n; i++)
	{
		if (light == 2)
		{
			cout << count << endl;
			return 0;
		}
		light = a[light];
		count++;
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int H, R;
    cin >> H >> R;
    if (abs(H) == R && H < 0) {
        cout << "0\n";
    } else if ((abs(H) >= R && H > 0) || (abs(H) < R)) {
        cout << "1\n";
    } else {
        cout << "-1\n";
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; string S; cin >> N >> S; 
	string first[262200] = {}, second[262200] = {}; 
	for(int i = 0; i < (1 << N); i++){
		string tmp1, tmp2; 
		for(int j = 0; j < N; j++){
			if((i >> j) & 1) tmp1.push_back(S.at(j)); 
			else tmp2.push_back(S.at(j)); 
		}
		reverse(tmp2.begin(), tmp2.end()); 
		first[i] = tmp1 + '1' + tmp2; 
	}
	for(int i = 0; i < (1 << N); i++){
		string tmp1, tmp2; 
		for(int j = 0; j < N; j++){
			if((i >> j) & 1) tmp1.push_back(S.at(N+j)); 
			else tmp2.push_back(S.at(N+j)); 
		}
		reverse(tmp2.begin(), tmp2.end()); 
		second[i] = tmp2 + '1' + tmp1; 
	}
	sort(second, second + (1 << N)); 
	long long int ans = 0;
	for(int i = 0; i < (1 << N); i++){
		ans += upper_bound(second, second + (1 << N), first[i]) - lower_bound(second, second + (1 << N), first[i]); 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 39424
K,N=map(int,input().split())
list_a=list(map(int,input().split()))
x = K-list_a[N-1]+list_a[0]
p=0
for i in range(N-1):
    if list_a[1+i]-list_a[i]>p:
            p=list_a[1+i]-list_a[i]
if x>p:
    print(K-x)
else:
    print(K-p)

Measured memory_bytes: 26436
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int n;
	cin>>n;
	cout<<24+(24-n)<<endl;
}


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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll x,y,ans=0,t;
	cin>>x>>y;
	while (x<=y){
		x*=2;
		ans++;
	}
	cout<<ans;
	return 0;
}

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

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

int ans = (n - 1) * (m - 1);
cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int N =sc.nextInt();
      String S =sc.next();
      
      String T =S.substring(N/2);
      
      if(S.startsWith(T) && N%2==0){
      System.out.println("Yes");
      }
      else{
       System.out.println("No");
      }
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())

#define MAX 100010
#define INF 1<<29
int n;
int dp[MAX];

void init() {

}

void input() {
	cin >> n;
}

void solve() {
	dp[0] = 0;
	for (int i = 1; i < MAX; i++) ;
	FOR(i, 1, MAX) dp[i] = INF;
	REP(i, MAX-1) {
		chmin(dp[i+1], dp[i]+1);
		for(int j = 6; i+j < MAX; j *= 6) chmin(dp[i+j], dp[i]+1);
		for(int j = 9; i+j < MAX; j *= 9) chmin(dp[i+j], dp[i]+1);
	}
	cout << dp[n] << endl;

}

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


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

int main(void) {
  ll N; cin >> N;
  ll a = 0;
  for (ll i = 1; i*i < N; i++) if (N%i == 0) if (0 < N/i-1 && i < N/i-1) a += N/i -1;
  cout << a << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen(".in.txt", "r", stdin);
	// freopen(".out.txt", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m, ii; cin >> n >> m;
	vector<int> c = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
	vector<bool> can(10);
	vector<vector<int>> dp(5001, vector<int> (n + 1, -1));
	dp[0][0] = 0;
	for(int i = 0; i < m; i++)
	{
		int a; cin >> a;
		can[a] = 1;
	}
	for(int i = 1; i < 5001; i++) for(int j = 0; j < n + 1; j++) for(int k = 9; k; k--)
		if(can[k] && j - c[k] > -1 && dp[i - 1][j - c[k]] != -1)
	{
		dp[i][j] = k;
		break;
	}
	for(int i = 5000; i > -1; i--) if(dp[i][n] != -1)
	{
		ii = i;
		break;
	}
	for(int i = ii; i; i--)
	{
		cout << dp[i][n];
		n -= c[dp[i][n]];
	}

	return 0;
}

Measured memory_bytes: 195840
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int n = 0;
		for(int i = 0; i <= A; i++) {
			for (int j = 0; j <= B; j++) {
				for(int k = 0; k <= C; k++) {
					if((500 * i + 100 * j + 50 * k) == X) {
						n++;
					}
				}
			}
		}
		System.out.println(n);
	}

}


Measured memory_bytes: 23124
#include <iostream>

int main(){
   int X;
   std::cin >> X;

   int max = 0;
   for(int i=1; i<32; ++i){
      int n = i;
      int m = 0;
      for(int j=2; j<10; ++j){
	 n *= i;
	 if(n<=X && n>m) m = n;
      }
      if(max<m) max = m;
   }
   std::cout << max << std::endl;
   return 0;
}


Measured memory_bytes: 256
n, m =map(int, input().split())
py_array = [[int(x) for x in input().split()]+[y] for x, y in enumerate(range(m), 0)]
py_array = sorted(py_array, key=lambda x:(x[0], x[1]))

base = 1
base2 = 0
res_array = []
for i, j, k in py_array:
    if base == i:
        base2 += 1
    else:
        base = i
        base2 = 1
    res_array.append([str(base).zfill(6), str(base2).zfill(6), k])

res_array = sorted(res_array, key=lambda x:x[2])

for i, j, k in res_array:
    print(i+j)

Measured memory_bytes: 46940
from collections import Counter, defaultdict, deque
from math import gcd

MOD = 1000000007
(N,) = [int(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for i in range(N)]

count00 = 0
badTerms = defaultdict(lambda: list([0, 0]))
for i, (a, b) in enumerate(AB):
    if a == 0 or b == 0:
        if a == 0 and b == 0:
            count00 += 1
        elif a == 0:
            badTerms[0][0] += 1
        else:
            assert b == 0
            badTerms[0][1] += 1

    else:

        assert a * b != 0
        isNeg = a * b < 0

        g = gcd(a, b)
        a //= g
        b //= g
        if a < 0 and b < 0:
            a *= -1
            b *= -1
        if a < 0 or b < 0:
            a, b = -b, a
        if a < 0 and b < 0:
            a *= -1
            b *= -1
        assert a > 0 and b > 0

        if isNeg:
            badTerms[(a, b)][0] += 1
        else:
            badTerms[(a, b)][1] += 1

ways = 1

for key, (negCount, posCount) in badTerms.items():
    ways *= pow(2, negCount, MOD) + pow(2, posCount, MOD) - 1
    ways %= MOD

if count00:
    # Can't work with anything else, must be taken on it's own
    ways += count00


print((ways - 1) % MOD)


Measured memory_bytes: 147684
#include <iostream>
#define NUM 1000000007
 
using namespace std;
 
int main(){
    string a, b;
    int i,n;
    int flag = 1;
    long long answer = 3;
    cin >> n >> a >> b;
    for(i = 0; i < n; i++){
        if(a[i] == b[i]){
            if(flag * i){
                answer = answer * 2 % NUM;
            }
            flag = 1;
        }else{
            if(flag){
                answer = answer * 2 % NUM;
            }else{
                answer = answer * 3 % NUM;
            }
            flag = 0;
            i++;
        }
    }
    cout << answer << endl;
}


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

///---OPTIMIZE---///
#define BOOST ios_base::sync_with_stdio(false);cin.tie(NULL);

///---DATA TYPE---///
typedef long long ll;
typedef long long int lli;
typedef vector<int> vi;
typedef map<int,int> mpii;
typedef pair<int,int> pii;

///---INPUT---///
#define sf                        scanf
#define ss(ch)                    scanf("%s",ch)

#define sfi(a)                    sf("%d",&a)
#define sfii(a,b)                 sf("%d %d",&a,&b)
#define sfiii(a,b,c)              sf("%d %d %d",&a,&b,&c)

#define sfl(a)                    sf("%ll",&a)
#define sfll(a,b)                 sf("%ll %ll",&a,&b)
#define sflll(a,b,c)              sf("%ll %ll %ll",&a,&b,&c)

#define sflli(a)                  sf("%lld",&a)

///---OUTPUT---///
#define pf                        printf
#define pfi(a)                    pf("%d\n",a)
#define pfii(a,b)                 pf("%d %d\n",a,b)
#define pfiii(a,b,c)              pf("%d %d %d\n",a,b,c)
#define pfl(a)                    pf("%ll\n",a)
#define pfll(a,b)                 pf("%ll %ll\n",a,b)
#define pflll(a,b,c)              pf("%ll %ll %ll\n",a,b,c)

#define pflli(a)                  pf("%lld",&a)

///---NEWLINE---///
#define nlc                       pf("\n")
#define nlcpp                     cout<<"\n"

///---LOOP---///
#define rep0(ini,end)             for(ini=0;ini<end;ini++)
#define rep1(ini,end)             for(ini=1;ini<=end;ini++)
#define rep(ini,start,end)        for(ini=start;ini<=end;ini++)
#define repinc(ini,start,end,inc) for(ini=start;ini<=end;ini+=inc)

///---VECTOR---///
#define v                         vector
#define vi(a)                     v<int>a
#define pb                        push_back



int i,j,k;

int main()
{
    BOOST

    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        string s;
        cin>>s;
        int len=s.size();
        string s1="";
        for(int i=0; i<len;i++)
        {
            if(s[i]=='?') s1+="D";
            else s1+=s[i];
        }
        cout<<s1<<endl;
    }
    return  0;
}


Measured memory_bytes: 3840
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    L = [list(map(int,input().split())) for k in range(N)]
    L = sorted(L,key = lambda x: (x[1],x[0]))
    t = 0
    for e in L:
        if t+e[0] > e[1]:
            print("No")
            exit(0)
        else:
            t += e[0]
    print("Yes")
if __name__ == '__main__':
    main()


Measured memory_bytes: 86492
import java.io.*;
import java.util.StringTokenizer;
import static java.lang.Math.*;

public class Main {
  public static void main(String[] args) {
    new Main().solve();
  }

  private void solve() {
    try(InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out)) {

      int n = in.nextInt();
      long ans = 1;
      for (int i = 0; i < n; i++) {
        ans = lcm(ans, in.nextLong());
      }

      out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  long gdc(long a, long b) {
    if(b == 0) return a;
    return gdc(b, a % b);
  }
  long lcm(long a, long b) {
    return b / gdc(a, b) * a;
  }

  int atoi(String s) { return Integer.parseInt(s); }
  long atol(String s) { return Long.parseLong(s); }

  static class InputReader implements AutoCloseable {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream), 32768);
      st = null;
    }

    public String nextLine() throws IOException {
      return br.readLine();
    }
    public String next() {
      if (st == null || !st.hasMoreTokens()) {
        try { st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          throw new UncheckedIOException(e);
        }
      }
      return st.nextToken();
    }
    public int nextInt() { return Integer.parseInt(next()); }
    public long nextLong() { return Long.parseLong(next()); }
    int[] mapInt(int len) {
      int[] ret = new int[len];
      for (int i = 0; i < len; i++) ret[i] = Integer.parseInt(next());
      return ret;
    }
    long[] mapLong(int len) {
      long[] ret = new long[len];
      for (int i = 0; i < len; i++) ret[i] = Long.parseLong(next());
      return ret;
    }
    @Override public void close() throws IOException { br.close(); }
  }
}

Measured memory_bytes: 23124
import java.util.*;

public class Main {
	public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n==1){
            System.out.println("Hello World");
        }else{
		int A = sc.nextInt();
		int B = sc.nextInt();
            System.out.println(A+B);
        }
        }
}       

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    ll cnt = 0;
    REP(i, n) {
        ll A; cin >> A;
        if (A % 2 == 1) {
            cnt += 1;
        }
    }
    if (n == 1 || cnt % 2 == 0) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
const string tr="abcdefghijklmnopqrstuvwxyz";
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll 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;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}
bool ip/*is_prime*/(long long N) {if (N == 1) return false;for (long long i = 2; i * i <= N; ++i) {if (N % i == 0) return false;}return true;}
int digit(ll N) {int ans = 0;while (N) {++ans;N /= 10;}return ans;}
vector<pair<ll,ll>> pf/*prime_factorize*/(ll n){vector<pair<ll,ll>> res;for(ll a=2;a*a<=n;a++){if(n%a!=0) continue;ll ex=0;while(n%a==0){ex++;n/=a;}res.pb({a,ex});}if(n!=1) res.pb({n,1});return res;}
vector<ll> div/*divisor*/(ll n){  vector<ll> res={1};for(ll a=2;a*a<=n;a++){if(n%a!=0) continue;ll b=n/a;res.pb(b);if(b!=a) res.pb(a);}sort(all(res));return res;}

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

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

int main() {
  int N, M;
  cin >> N >> M;

  UnionFind tree(N);

  for(int i = 0; i < M; i++) {
    int  x, y;
    cin >> x >> y;
    tree.unite(x-1, y-1);
  }

  int cnt=0;
  for(int i=0;i<N;i++){
    if(!tree.same(0,i)){
      tree.unite(0, i);
      cnt++;
    }
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3776
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')
import sys
import itertools
import copy


def main():
    N = I()
    a_list = LI()
    sum_list = []
    # print(a_list)
    # print(list(range(N)))
    # print(list(itertools.combinations(list(range(N))), 2))
    # print(list(itertools.combinations([1, 2, 3], 2)))
    cnt = 0
    total = sum(a_list)
    # print(total)
    current_sum = 0
    for i in range(N):
        current_sum += a_list[i]
        sum_list.append(total - current_sum)
    # print(sum_list)
    ans = 0
    for i in range(N):
        ans += sum_list[i] * a_list[i]
        ans =  ans % (10**9 + 7)
    print(ans)
    # L = LLIN(N)

    #     if T[-i]
    # if D / T <= S:
    #     print('Yes')
    # else:
    #     print('No') 
    # cnt = 0
    # for l in L:
    #     num = l[0] ** 2 + l[1] ** 2 
    #     if num <= D ** 2:
    #         cnt+=1
    # print(cnt)
    # print(row)
    # total = sum(row)
    # target = total - K
    # if K == total:
    #     print(1)
    #     sys.exit()
    # col = []
    # for w in range(W):
    #     cnt = 0
    #     for h in range(H):    
    #         print(A[h][w])
    #         if A[h][w] == '#':
    #             cnt += 1
    #     col.append(cnt)
    # print(col)
    # ans = 0
    # for w in range(W):
    #     for h in range(H):
    #         if A[h][w] == '#':
    #             if col[w] + row[h] - 1 == target:
    #                 print(str(h) + str(w))
    #                 ans +=1
    #         else:
    #             if col[w] + row[h] == target:
    #                 print(str(h) + str(w))
    #                 ans +=1
    # print(ans)
    #     for  in x:


    # print('AC x ' + str(cnt['AC']))
    # print('WA x ' + str(cnt['WA']))
    # print('TLE x ' + str(cnt['TLE']))
    # print('RE x ' + str(cnt['RE']))
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 33828
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (X, Y, Z) = Slice3<long>();
            var c = X / (Y + Z);
            if (Y * c + Z * (c + 1) <= X)
                WriteLine(c);
            else
                WriteLine(c - 1);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27588
#include<stdio.h>

int main()
{
    char ch;
    int num[26]={0};
    while(scanf("%c",&ch)!=EOF){
        if('A'<=ch && ch<= 'Z'){
            num[ch-'A']++;
        }else if('a'<=ch && ch<= 'z'){
            num[ch-'a']++;
        }
    }
    for(int i=0;i<26;i++){
        printf("%c : %d\n",'a'+i,num[i]);
    }
    return 0;
}


Measured memory_bytes: 2708
import math
#import time
#t1=time.time()
def f(x, y, z):
    return x**2+y**2+z**2+x*y+y*z+z*x

n=int(input())
l=[0 for i in range(n)]
root = math.floor(math.sqrt(n))

for x in range(1,root+1):
    for y in range(1,root+1):
        for z in range(1,root+1):
            num=f(x,y,z)
            if num<=n:
                l[num-1]+=1
            if num>n:
                break

for s in l:
    print(s)
#print(t2-t1)
#print(l)



Measured memory_bytes: 69780
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

using namespace std;

inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }

//const int maxn=

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	int n;
	
	while(cin>>n)
	{
		
		int ans=1000-(n-n/1000*1000);
		
		if(ans==1000)
			ans=0;
		
		cout<<ans<<endl;
		
	}
	
	
	return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
struct edge{int to,cost;};
vector<edge>G[1000];
const long long inf=1e15;
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b,c;
		cin>>a>>b>>c;
		G[--a].push_back((edge){--b,-c});
	}
	long long dist[1000];
	for(int i=0;i<n;i++)
		dist[i]=inf;
	dist[0]=0;
	for(int i=0;i<n;i++){
		for(int v=0;v<n;v++){
			for(auto x:G[v]){
				int u=x.to;
				if(dist[u]>dist[v]+x.cost){
					dist[u]=dist[v]+x.cost;
					if(i==n-1&&u==n-1){
						cout<<"inf"<<endl;
						return 0;
					}
				}
			}
		}
	}
	cout<<-dist[n-1]<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] border = new int[101];
		int[] height = new int[101];
		int answer = 0;	//
		int count = 0;
		boolean flag = false;

		// input
		int num = scan.nextInt();
		for(int i = 0; i < num; i++){
			border[i] = scan.nextInt();
			if(border[i] == 0) {
				count++;
			}
		}
		border[num] = -1;

		while(true){
			flag = false;
			for(int i = 0; i <= num; i++){
				if(height[i] < border[i]){
					height[i] += 1;		// give water
					flag = true;
					if(height[i]== border[i]) {
						count++;
					}
				} else if(flag) {
					answer++;
					flag = false;
				}
			}
			if(count == num) {
				break;
			}
		}

		System.out.println(answer);


	}
}


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

namespace io {
char buf[1<<21], *p1 = buf, *p2 = buf;
inline char gc() {
    if(p1 != p2) return *p1++;
    p1 = buf;
    p2 = p1 + fread(buf, 1, 1 << 21, stdin);
    return p1 == p2 ? EOF : *p1++;
}
#define G gc

#ifndef ONLINE_JUDGE
#undef G
#define G getchar
#endif

template<class I>
inline void read(I &x) {
    x = 0; I f = 1; char c = G();
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = G(); }
    while(c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = G(); }
    x *= f;
}

template<class I>
inline void write(I x) {
    if(x == 0) {putchar('0'); return;}
    I tmp = x > 0 ? x : -x;
    if(x < 0) putchar('-');
    int cnt = 0;
    while(tmp > 0) {
        buf[cnt++] = tmp % 10 + '0';
        tmp /= 10;
    }
    while(cnt > 0) putchar(buf[--cnt]);
}

#define in(x) read(x)
#define outn(x) write(x), putchar('\n')
#define out(x) write(x), putchar(' ')

} using namespace io;

#define ll long long
const int N = 200010;

int n, a[N];
priority_queue<int>q;

int main() {
	read(n);
	for(int i = 1; i <= n; ++i) {
		read(a[i]);
		q.push(a[i]);
	}
	for(int i = 1; i <= n; ++i) {
		int now = q.top();
		if(now == a[i]) {
			q.pop();
			now = q.top();
			q.push(a[i]);
		}
		outn(now);
	}
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        int count = 0;
        for (int i = 0 ; i < a.length(); i++) {
            String aa = a.substring(i, i + 1);
            String bb= b.substring(i, i + 1);
            String cc = c.substring(i, i + 1);
            Set<String> strings = new HashSet<>();
            strings.add(aa);
            strings.add(bb);
            strings.add(cc);
            if (strings.size() == 1) {

            } else if (strings.size() == 2) {
                count++;
            } else {
                count += 2;
            }


    }
        System.out.println(count);
}}


Measured memory_bytes: 21844
def main():
    n_ansl = [0]*(2*(10**5))
    for i in range(1,2*(10**5)):
    # for i in range(1,20):
        cnt = 0
        one_cnt = bin(i).count("1")
        rem = i
        while rem != 0:
            one_cnt = bin(rem).count("1")
            rem = rem%one_cnt   
            cnt += 1
        n_ansl[i] = cnt
 
    n = int(input())
    x = list(input())
    one_cnt = x.count('1')

    if one_cnt == 0:
        for i in range(n):
            print(1)
        exit()
    
    x = x[::-1]

    curr_sum_p1 = 0
    curr_sum_m1 = 0
    for i, xi in enumerate(x):
        if xi == '1':
            curr_sum_p1 += pow(2,i,one_cnt+1)
            curr_sum_p1%=(one_cnt+1)
            if one_cnt > 1:
                curr_sum_m1 += pow(2,i,one_cnt-1)
                curr_sum_m1%=(one_cnt-1)
 
        
    ansl = [0]*(n)
    for i, xi in enumerate(x):
        if xi == '1':
            if one_cnt > 1:
                diff = (-1)*pow(2,i,one_cnt-1)
                ans = (curr_sum_m1 + diff)%(one_cnt-1)
                ansl[i] = n_ansl[ans]+1
            else:
                ansl[i] = 0
        else:
            diff = pow(2,i,one_cnt+1)
            ans = (curr_sum_p1 + diff)%(one_cnt+1)
            ansl[i] = (n_ansl[ans]+1)
 
 
    # print(ansl)
    for a in ansl[::-1]:
        print(a)
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 90436
def solve():
    N = int(input())
    s = []
    ans = 0

    A_cnt = 0
    B_cnt = 0
    BA_cnt = 0
    for i in range(N):
        s_tmp = input()
        s.append(s)
        for j in range(len(s_tmp)-1):
            if s_tmp[j] == "A" and s_tmp[j+1] == "B":
                ans += 1
        
        if s_tmp[0] == "B" and s_tmp[-1] == "A":
            BA_cnt += 1
        elif s_tmp[0] == "B":
            B_cnt += 1
        elif s_tmp[-1] == "A":
            A_cnt += 1
    
    if BA_cnt > 0:
        ans += BA_cnt - 1
        if A_cnt > 0:
            A_cnt -= 1
            ans += 1
        if B_cnt > 0:
            B_cnt -= 1
            ans += 1
    
    ans += min(A_cnt,B_cnt)
    
    print(ans)
if __name__ == '__main__':
    solve()

Measured memory_bytes: 57432
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
using d64 = long double;

#define INF (i64)(1e18)
#define MOD (i64)(1e9+7)
#define REP(i, n) for(i64 i = 0; i < (n); i++)
#define RANGE(i, a, b) for(i64 i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) ((i64)(v).size())
template<class T> inline void chmax(T &a, const T &b) { if (a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if (a > b) a = b; }

struct Vector2 {
  d64 x, y;
  Vector2() {
    x = 0;
    y = 0;
  }
  Vector2(d64 a1, d64 a2) {
    x = a1;
    y = a2;
  }
  inline Vector2 &operator+=(Vector2 p) {
    x += p.x;
    y += p.y;
    return *this;
  }
  inline Vector2 &operator-=(Vector2 p) {
    x -= p.x;
    y -= p.y;
    return *this;
  }
  inline Vector2 &operator*=(d64 k) {
    x *= k;
    y *= k;
    return *this;
  }
  inline Vector2 &operator/=(d64 k) {
    x /= k;
    y /= k;
    return *this;
  }
  inline Vector2 operator+(Vector2 p) {
    return Vector2(*this) += p;
  }
  inline Vector2 operator-(Vector2 p) {
    return Vector2(*this) -= p;
  }
  inline Vector2 operator*(d64 k) {
    return Vector2(*this) *= k;
  }
  inline Vector2 operator/(d64 k) {
    return Vector2(*this) /= k;
  }
  inline Vector2 operator-(void) {
    return Vector2() -= *this;
  }
  inline d64 product(Vector2 p) {
    return x * p.x + y * p.y;
  }
  inline d64 lengthSq() {
    return product(*this);
  }
  inline d64 length() {
    return sqrt(lengthSq());
  }
  inline Vector2 normalize() {
    return *this / length();
  }
};

inline d64 lenSq(d64 x1, d64 y1, d64 x2, d64 y2) {
  return (x1-x2) * (x1-x2) + (y1-y2) * (y1-y2);
}

int main() {
  int n;
  cin >> n;
  vector<Vector2> v(n);
  REP(i, n) cin >> v.at(i).x >> v.at(i).y;

  d64 r = 1.0e7, s = 1.0e7 / 2.0;
  d64 delta = 1.0e-10;
  while (s > 1e-8) {
    bool flag = false;
    RANGE(i, 0, n) {
      RANGE(j, i+1, n) {
        Vector2 mv = (v[j] - v[i]) / 2.0;
        if (r*r < mv.lengthSq()) continue;
        d64 vh = sqrt(r*r - mv.lengthSq());
        Vector2 vv = Vector2(-mv.y, mv.x).normalize() * vh;
        Vector2 mp = v[i] + mv;
        Vector2 p1 = mp + vv, p2 = mp - vv;
        bool f1 = true, f2 = true;
        REP(k, n) {
          if ((v[k] - p1).length() > r+delta) f1 = false;
          if ((v[k] - p2).length() > r+delta) f2 = false;
        }
        if (f1 || f2) flag = true;
      }
    }
    if (flag) r -= s;
    else r += s;
    s /= 2.0;
  }

  cout << fixed << setprecision(15) << r << endl;

  return 0;
}


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

int N, K, Q, diff[100002];
int main(){
    scanf("%d %d %d", &N, &K,  &Q);
    for (int i = 0, x; i < Q; i++) {
        scanf("%d", &x);
        diff[1]+=1; diff[x] -=1;
        diff[x+1] += 1; diff[N+1] -=1;
    }
    for (int i = 1; i <= N; i++) {
        diff[i] += diff[i-1];
        if(K-diff[i] <= 0) printf("No\n");
        else printf("Yes\n");
    }
}

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

/* {{{ */
#define CL(N) cout << N << endl
#define DCT(N) cout << "debug " << N << endl
#define REP(i, N) for (int i = 0; i < N; i++)
/* }}} */

long long dp[101][21];

int main()
{
    int n, num[101];

    cin >> n;

    REP(i, n){
       cin >> num[i];
    }

    dp[0][num[0]] = 1;

    for (int i = 1; i < n - 1; i++){
        REP(j, 21){
            if (0 <= j - num[i]){
                dp[i][j] += dp[i - 1][j - num[i]];
            }
            if (j + num[i] <= 20){
                dp[i][j] += dp[i - 1][j + num[i]];
            }
        }
    }

    CL(dp[n - 2][num[n - 1]]);

    return (0);
}

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>

using namespace std;

int main(void){
  double ax,ay,bx,by,cx,cy,dx,dy;

  while(cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy){
    if(ax == bx){
      if(cy == dy){
	cout << "YES" << endl;
      }else{
	cout << "NO" << endl;
      }
    }else if(cx == dx){
      if(ay == by){
	cout << "YES" << endl;
      }else{
	cout << "NO" << endl;
      }
    }else{
      double arg1, arg2;
      arg1 = (by - ay) / (bx - ax);
      arg2 = (dy - cy) / (dx - cx);
      if(fabs(arg1*arg2 + 1) < 1e-6){
	cout << "YES" << endl;
      }else{
	cout << "NO" << endl;
      }
    }
  }
}

Measured memory_bytes: 0
// https://beta.atcoder.jp/contests/agc019/submissions/1541809
// user : dotorya

#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
 
#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;
 
#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  
 
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
 
int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
 
char A[2050];
char B[2050];
 
int L[2050];
int R[2050];
 
int mx1[2050];
int mx2[2050];
int getans(char* A, char* B) {
	int N = strlen(A), i, j;
	for (i = 0; i < N; i++) if (B[i] == '1') break;
	if (i >= N) {
		for (i = 0; i < N; i++) if (A[i] == '1') return INF;
		return 0;
	}
 
	for (i = 0; i < N; i++) {
		for (j = i;; j--) if (B[(j + N) % N] == '1') break;
		L[i] = j;
		for (j = i;; j++) if (B[j%N] == '1') break;
		R[i] = j;
	}
 
	int rv = INF;
	for (i = 0; i < N; i++) {
		vector <pii> Vu;
		int x = i;
		for (j = 0; j < N; j++) {
			if (A[j] == B[(j - i + N) % N]) continue;
			x++;
 
			int s = -i + j, e = j;
			if (L[e] >= s) continue;
 
			Vu.emplace_back(R[e] - e, (s+N)%N - L[(s+N)%N]);
		}
		sort(all(Vu));
 
		mx1[0] = 0;
		for (j = 0; j < Vu.size(); j++) mx1[j + 1] = max(mx1[j], Vu[j].first);
		mx2[Vu.size()] = 0;
		for (j = (int)Vu.size() - 1; j >= 0; j--) mx2[j] = max(mx2[j + 1], Vu[j].second);
 
		for (j = 0; j <= Vu.size(); j++) rv = min(rv, x + 2 * (mx1[j] + mx2[j]));
	}
	return rv;
}
int main() {
	scanf("%s %s", A, B);
	
	int N = strlen(A);
	int ans = getans(A, B);
	reverse(A, A + N);
	reverse(B, B + N);
	ans = min(ans, getans(A, B));
	if (ans == INF) ans = -1;
	return !printf("%d\n", ans);
}

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


void solve(long long N){
  long long digit = floor(log(N)/log(10));
  long long acc = N;
  bool allnine = true;

  for(int i = 0; i < digit; i++){
    if (acc % 10 != 9) allnine = false;
    acc /= 10;
  }

  if(!allnine) acc -= 1;


  for(int i = 0; i < digit; i++){
    acc += 9;
  }
  cout << acc << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 512
import sys


L=int(input())-1
if L==1:
    print(2,2)
    print(1,2,0)
    print(1,2,1)
    sys.exit()

M=0
threelist=[]
j=1
i=1
while i<=10**6:
    i=3**j-1
    threelist.append(i)
    j+=1


threelist=threelist[::-1]

j=0
while True:
    if L>=threelist[j]:
       break
    else:
        j+=1

node=len(threelist)-j

PATH=[]
for i in range(2,2+node):
    PATH.append((i,i+1,0))

    PATH.append((i,i+1,3**(node+2-i-1)))
    PATH.append((i,i+1,2*3**(node+2-i-1)))
    M+=3

while L>0:
    j=0
    while True:
        if L>=threelist[j]:
            break
        else:
            j+=1

    k=len(threelist)-j
    rest=L-(3**k-1)

    PATH.append((1,node+2-k,rest))
    M+=1

    L=rest-1

    if L==0:
        PATH.append((1,node+2,0))
        M+=1
        break
    if L==1:
        PATH.append((1,node+2,0))
        PATH.append((1,node+2,1))
        M+=2
        break

print(node+2,M)
for pa in PATH:
    print(pa[0],pa[1],pa[2])


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String a = sc.next();
		String b = sc.next();

		if (a.charAt(0) == b.charAt(2) && a.charAt(1) == b.charAt(1) && a.charAt(2) == b.charAt(0)) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21844
L,R=(int(x) for x in input().split())
ans=[]
for n in range(2019):
    if L+n>=R:
        break
    for l in range(n+1,2019):
        if L+l>R:
            break
        a=(L+n)%2019
        b=(L+l)%2019
        c=a*b%2019
        ans.append(c)
print(min(ans))


Measured memory_bytes: 75432
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		long count = 0;
		if(k == 0) {
			count = n * n;
		} else {
			for(long b = k + 1; b <= n; b++) {
				//n = p * b + rとする
				long p = n / b;
				long r = n % b;
				count += p * Math.max(b - k, 0);
				count += Math.max(r - k + 1, 0);
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21716