akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//def   puts(a) printf("%s\n", a) 文字はこっち
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
//your code here!


int main(void){
    char A[110], B[110];
    ins(A); ins(B);
    /*if(strlen(A)>strlen(B)){
        puts("GREATER");
        return 0;
    }
    else if(strlen(A)<strlen(B)){
        puts("LESS");
        return 0;
    }
    else {
        rep(i,strlen(A)){
            ll a = A[i]-'0', b = B[i]-'0';
            if(a>b){
                puts("GREATER");
                return 0;
            }
            else if(a<b){
                puts("LESS");
                return 0;
            }
        }
    }
    puts("EQUAL");*/
    //もっと短くできた
    ll a=strlen(A), b=strlen(B);
    if(a==b){
        int c=strcmp(A,B);
        if(c==0)    puts("EQUAL");
        else if(c>0)puts("GREATER");
        else        puts("LESS");
    }
    else if(a>b) puts("GREATER");
    else         puts("LESS");
    return 0;
}


Measured memory_bytes: 128
A, B, K = map(int, input().split())
if A + K - 1 >= B - K + 1:
    print("\n".join(map(str, [i for i in range(A, B + 1)])))
else:
    print("\n".join(map(str, [i for i in range(A, A + K)])))
    print("\n".join(map(str, [i for i in range(B - K + 1, B + 1)])))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
string s,t;
int main()
{
   cin>>s>>t;
   for(int i=0; i<s.size(); i++)
       if(s[i]!=t[i])
       {
           cout<<"No";
           return 0;
       }
   cout<<"Yes";
}


Measured memory_bytes: 3624
#include<stdio.h>
int main(){
int N,L[100],max=0,sum=0;
scanf("%d",&N);
for(int i=0;i<N;i++){
  scanf("%d",&L[i]);
  if(max<L[i])max=L[i];
  sum+=L[i];
}  
sum=sum-max;
if(sum>max){printf("Yes");}else{printf("No");}
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;
double GPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 30){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}


ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll N;
vector<ll> E[55];
ll M;
ll U[55], V[55];
ll nuled[55];
ll par[55];
ll depth[55];
vector<bitset<55>> bset(55);
map<pair<ll, ll>, ll> ID;

void make_depth(ll now, ll from, ll dep){
  depth[now] = dep;
  for(ll to: E[now])if(to != from){
    make_depth(to, now, dep + 1);
  }
}

void make_par(ll now, ll from){
  for(ll to: E[now])if(to != from){
    par[to] = now;
    make_par(to, now);
  }
}

void nul(ll u, ll v, ll id){
  if(depth[u] > depth[v]) swap(u, v);
  while(depth[u] != depth[v]){
    ll edge = ID[{v, par[v]}];
    bset[id][edge] = 1;
    v = par[v];
  }
  while(u != v){
    ll edge = ID[{u, par[u]}];
    bset[id][edge] = 1;
    u = par[u];
    edge = ID[{v, par[v]}];
    bset[id][edge] = 1;
    v = par[v];
  }
}


void solve(){
  cin >> N;
  rep(i, N-1){
    ll a, b;
    cin >> a >> b;
    a--, b--;
    E[a].pb(b);
    E[b].pb(a);
    ID[{a, b}] = i;
    ID[{b, a}] = i;
  }
  cin >> M;
  rep(i, M){
    cin >> U[i] >> V[i];
    U[i]--, V[i]--;
  }
  make_par(0, -1);
  make_depth(0, -1, 0);
  rep(i, M){
    nul(U[i], V[i], i);
  }
  ll ans = 0;
  rep(i, 1<<M){
    bitset<55> sum;
    rep(j, M)if((i>>j)&1){
      sum |= bset[j];
    }
    ll cnt = 0;
    rep(j, N) if(sum[j] == 1) cnt++;
    ll bcnt = cnt_bit(i);
    if(bcnt & 1) ans -= pow_long(2, N-1-cnt);
    else ans += pow_long(2, N-1-cnt);
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
#define SIZE 200005
#define M 1000000007
ll power(ll a,ll b){
	if(b==0)
		return 1;
	ll p=power(a,b/2);
	p=(p*p)%M;
	if(b%2==0){
		return p;
	}
	else{
		return (p*a)%M;
	}
}
ll arr[SIZE];
ll presum[SIZE];
// ll binomial[SIZE];
// ll binomialCoeff(ll n, ll k)  
// { 
// 	if(n==0)
// 		return 1;

//     ll res = 1;  
  
//     // Since C(n, k) = C(n, n-k)  
//     if ( k > n - k )  
//         k = n - k;  
  
//     // Calculate value of  
//     // [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]  
//     for (ll i = 0; i < k; ++i)  
//     {  
//         res *= (n - i);  
//         res /= (i + 1);  
//     }  
  
//     return res;  
// }

int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll N;
	cin>>N;
	for(ll i=1;i<=N;++i){
		cin>>arr[i];
	}
	sort(arr+1,arr+N+1,greater<ll>());
	ll ans=0,ans2=0;
	presum[0]=1;
	for(ll i=1;i<=N;++i){
		// ll temp=0;
		// for(ll j=0;j<i;++j){
		// 	temp+=(j+1)*binomialCoeff(i-1,j);
		// }
		// ans2=(ans2+((power(2,i)*temp)%M*(arr[i]*power(2,2*(N-i)))%M)%M)%M;
		ans=(ans+(((power(2,i)*presum[i-1])%M)*((arr[i]*power(2,2*(N-i)))%M)%M))%M;
		presum[i]=((2*presum[i-1])%M+power(2,i-1))%M;
		// cout<<arr[i]<<" "<<ans<<" "<<presum[i-1]<<":"<<ans2<<" "<<temp<<endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3328
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int X;
  cin >> X;

  for (int i = 1;; i++) {
    int sum = i * (i + 1) / 2;
    if (sum >= X) {
      cout << i << endl;
      return 0;
    }
  }

  cout << X << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
int ret;

int gcd(int x,int y){
    int r;
    if(x < y)
        std::swap(x,y);
    while(y > 0){
        r = x % y;
        x = y;
        y = r;
    }
    ret = x;
    return ret;
}

int main(){
    unsigned int x,y;
    scanf("%d%d",&x,&y);
    gcd(x,y);
    printf("%d\n",ret);

    return 0;
}


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

int main(void)
{
  int h,w;
  cin>>h>>w;
  string s[h][w];
  char ans1;
  int ans2;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>s[i][j];
      if(s[i][j]=="snuke"){
        ans1='A'+j;
        ans2=i+1;
        break;
      }
    }
  }
  cout<<ans1<<ans2<<endl;
  
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from itertools import permutations
from itertools import combinations

N = int(input().strip())
xy_list = [list(map(int, input().rstrip().split())) for i in range(N)]
#-----

dist ={}
for i,j in combinations(range(1,N+1),2):
    xi = xy_list[i-1][0]
    yi = xy_list[i-1][1]

    xj = xy_list[j-1][0]
    yj = xy_list[j-1][1]
    
    key = tuple(sorted( (i,j) ))
    dist[key] = ( (xi-xj)**2 + (yi-yj)**2 )**(1/2)


dist_all=[]
for p in permutations(range(1,N+1)):
    dist_sub=0 
    for i in range(len(p)-1):
        key = tuple(sorted( (p[i],p[i+1]) ))
        dist_sub += dist[key]
    
    dist_all.append(dist_sub)


ans = sum(dist_all) / len(dist_all)
print(Decimal(str(ans)).quantize(Decimal('1E-10'), rounding=ROUND_HALF_UP))


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();

            string[] inputs = input.Split(' ');

            int age = int.Parse(inputs[0]);
            int cost = int.Parse(inputs[1]);

            int result = 0;

            if (age >= 13)
            {
                result = cost;
            }  else if (age >= 6 && age <= 12)
            {
                result = cost / 2;
            } else
            {
                result = 0;
            }

            Console.WriteLine(result);

        }



    }
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

string A, B, C;

void solve()
{
    cin >> A >> B >> C;
    if(A[A.length()-1] == B[0] && B[B.length()-1] == C[0])
        cout << "YES" << endl;
    else cout << "NO" << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

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

int main(void) {
	string S;
	cin >> S;
	bool flag = true;
	int ans = 0;
	int Const_i = 0;
	int bef = 1;
	while (true) {
		flag = true;
		for (; Const_i < S.length(); Const_i++) {
			if (S[Const_i] != S[0]) {
				flag = false;
				break;
			}
		}
		//違った場合Const_iの更新を止める
		if (flag)break;
		S = (S[0] == 'B' ? "W" : "B") + S;
		for (; bef <= Const_i; bef++) {
			if (S[bef] != S[0])S[bef] = S[0];
			else if (S[bef] == S[0])break;
		}
		ans++;
		//cout << S << endl;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 848
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0); 
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}
int main()
{
  //flash;
  ll x,y;
  cin>>x>>y;
  if(y>=x)cout<<"unsafe";
  else cout<<"safe";
  return 0;
}
//code the AC sol !
// BS/queue/map

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=3e3+10;
int ksm(int x,int y,int mod){
	int res=1;
	while(y){
		if(y&1) res=(ll)x*res%mod;
		x=(ll)x*x%mod;
		y>>=1;
	}
	return res;
}
int C[maxn][maxn],S[maxn][maxn];
int main(){
	int n=read(),mod=read();
	S[0][0]=C[0][0]=1;
	REP(i,1,n+1){
		C[i][0]=1;S[i][0]=0;
		REP(j,1,i) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod,S[i][j]=(S[i-1][j-1]+(ll)j*S[i-1][j]%mod)%mod;
	}
	int ans=0;
	REP(i,0,n){
		int tmp=0,res=1,num=ksm(2,n-i,mod);
		REP(j,0,i){
			tmp=(tmp+(ll)res*S[i+1][j+1]%mod)%mod;
			res=(ll)res*num%mod;
		}
		tmp=(ll)tmp*C[n][i]%mod*ksm(2,ksm(2,n-i,mod-1),mod)%mod;
		ans=(ans+((i&1)?(mod-tmp):tmp))%mod;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 69632
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int K = sc.nextInt();

    sc.close();

    long count = 1;

    for (int i = 0; i < N; i++) {
      if (i == 0) {
        count *= K;
      } else {
        count *= (K - 1);
      }
    }

    System.out.println(count);

  }

}

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

void add_point ( string t, ll& sum, int i, int r, int s, int p ) {
    if ( t[i] == 'r' ) {
        sum += (ll)p;
    }
    if ( t[i] == 's' ) {
        sum += (ll)r;
    }
    if ( t[i] == 'p' ) {
        sum += (ll)s;
    }
    return;
}

bool check_k_intrvl ( string t, int i, int k, vector<int>& k_intrvl_num ) {
//    int dif_num = k;
//    int cnt = 0;
//    while(1) {
//        if ( i - dif_num < 0 ) break;
//        if ( t[i-dif_num] != t[i] ) break;
//        ++cnt;
//        dif_num += k;
//    }
    k_intrvl_num[i] = k_intrvl_num[i-k]+1;
    if ( k_intrvl_num[i] % 2 == 1 ) return false;
    else                            return true;
}

int main(){
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;

    ll sum = 0;
    vector<int> k_intrvl_num(n, 0);
    rep(i, n) {
        if ( i < k ) {
            add_point( t, sum, i, r, s, p );
        }
        else if ( t[i-k] == t[i] ) {
            bool add_check = check_k_intrvl(t, i, k, k_intrvl_num);
            if ( add_check ) {
                add_point( t, sum, i, r, s, p );
            }
        }
        else {
            add_point( t, sum, i, r, s, p );
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 896
//
// Created by Pulak on 02-11-2019.
//
#include <bits/stdc++.h>
#include <iostream>

int n;

int solve(int day, int taken);
int dp[100005][200];
int a[100005], b[100005], c[100005];
using namespace std;

int main() {
    //lets say on last day the guy does activity a
    cin >> n;
    // int a[n], b[n], c[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i] >> c[i];
    }
    memset(dp,-1, sizeof(dp));
    int ans1 = a[0] + solve(1, 'a');
    int ans2 = b[0]+solve(1, 'b');
   int ans3 = c[0]+solve(1, 'c');
    printf("%d", max(ans1,max( ans2,ans3)));
    
}

int solve(int day, int taken) {
    if(dp[day][taken] != -1) return dp[day][taken];
    if(day > n - 1) return 0;
    if (day == n - 1) {
        if (taken == 'a')
            return max(b[n - 1], c[n - 1]);
        if (taken == 'b')
            return max(a[n - 1], c[n - 1]);
        return max(a[n - 1], b[n - 1]);
    }
    if (taken == 'a')
        return dp[day][taken] = max(b[day] + solve(day + 1, 'b'), c[day] + solve(day + 1, 'c'));
    if (taken == 'b')
        return dp[day][taken ] = max(a[day] + solve(day + 1, 'a'), c[day] + solve(day + 1, 'c'));
    return dp[day][taken] = max(a[day] + solve(day + 1, 'a'), b[day] + solve(day + 1, 'b'));
 
}


Measured memory_bytes: 84224
h,w=map(int,input().split())
ans=((h+2)//3-h//3)*w
ans=min(ans,((w+2)//3-w//3)*h)
for i in range(1,h):
  s=[i*w,(h-i)*(w//2),(h-i)*(w-w//2)]
  ans=min(ans,max(s)-min(s))
for i in range(1,w):
  s=[i*h,(w-i)*(h//2),(w-i)*(h-h//2)]
  ans=min(ans,max(s)-min(s))
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
#define SQR(_a) ((_a) * (_a))
typedef long long LL; using namespace std;

int main() {
	LL xs, ys, xt, yt;
	cin >> xs >> ys >> xt >> yt;
	int n;
	cin >> n;
	LL x[n + 2], y[n + 2], r[n + 2];
	x[0] = xs, y[0] = ys, r[0] = 0;
	x[n + 1] = xt, y[n + 1] = yt, r[n + 1] = 0;
	ffor (i, 1, n + 1)
		cin >> x[i] >> y[i] >> r[i];
	n += 2;
	bool done[n];
	SET(done, 0);
	double dist[n];
	FOR (i, n)
		dist[i] = -1.0;
	dist[0] = 0.0;
	while (!done[n - 1]) {
		int v = -1;
		FOR (i, n) {
			if (!done[i])
				if (dist[i] > -0.5)
					if (v == -1 || dist[i] < dist[v])
						v = i;
		}
		done[v] = true;
		FOR (i, n) {
			if (done[i])
				continue;
			double d = sqrt(SQR(x[i] - x[v]) + SQR(y[i] - y[v]));
			d -= (r[v] + r[i]);
			if (d < 0.0)
				d = 0.0;
			if (dist[i] < -0.5 || dist[v] + d < dist[i])
				dist[i] = dist[v] + d;
		}
	}
	cout << std::fixed;
	cout << std::setprecision(10) << dist[n - 1] << endl;
	return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

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

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  string S;
  cin >> S;
  int ret = 0;
  for(int i = 0; i + i < S.size(); i++) {
    ret += S[i] != S[S.size() - i - 1];
  }
  cout << ret << endl;
}




Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
import sys
input = sys.stdin.readline
INF = float("inf")


def check(g, n):
    visited = [False] * n
    dist = [INF] * n  # 最短距離を管理
    # 連結でない場合に備えて全頂点をスタートにする
    for s in range(n):
        if visited[s]:
            continue
        # 探索していなければBFSで探索開始
        que = deque([(0, s)])
        dist[s] = 0
        visited[s] = True
        while que:
            d, u = que.popleft()
            for nd, v in g[u]:
                nd += d
                if visited[v]:
                    #  すでに探索済みなら距離が一致しているか判定
                    if dist[v] != nd:
                        return False
                else:
                    # そうでなければ探索済みにしてqueに隣接頂点を追加
                    visited[v] = True
                    dist[v] = nd
                    que.append((nd, v))
    return True


def main():
    n, m = map(int, input().split())
    g = [[] for _ in range(n)]
    for i in range(m):
        l, r, d = map(int, input().split())
        l -= 1
        r -= 1
        # 重み付き有向グラフ
        g[l].append((d, r))  # (重み，頂点)で管理
        g[r].append((-d, l))  # 逆方向は-をつけることで有効グラフを表現
    if check(g, n):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


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

int main(){
    string s;
    cin >> s;

    for(int i=0; i<s.length(); i++){
        if(s[i] == '1') cout << 9;
        if(s[i] == '9') cout << 1;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


constexpr double eps = 1e-10;
int sgn(double a) { return a < -eps ? -1 : a > eps; }
using P = complex<double>;
namespace std {
  istream& operator>>(istream& i, P& p) { double x, y; i >> x >> y; p = P(x, y); return i; }
  ostream& operator<<(ostream& o, const P& p) { return o << real(p) << ' ' << imag(p); }
}
double dot(const P& p, const P& q) { return real(conj(p) * q); }
double cross(const P& p, const P& q) { return imag(conj(p) * q); }

int ccw(P p0, P p1, P p2) {
  p1 -= p0, p2 -= p0;                         //             (1)
  if (sgn(cross(p1, p2)) > 0) return 1;       //
  if (sgn(cross(p1, p2)) < 0) return -1;      // (-2)---p0---(0)---p1---(2)
  if (sgn(dot(p1, p2) < 0)) return -2;        //
  if (sgn(norm(p1) - norm(p2)) < 0) return 2; //             (-1)
  return 0;
}

V<string> split(const string& s, char c) {
  V<string> res;
  stringstream ss(s);
  string t;
  while (getline(ss, t, c)) res.push_back(t);
  return res;
}

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  string s;
  while (getline(cin, s)) {
    auto ss = split(s, ' ');
    V<P> p(3);
    for (int i = 0; i < 3; ++i) {
      p[i] = {stod(ss[2 * i]), stod(ss[2 * i + 1])};
    }
    P q = {stod(ss[6]), stod(ss[7])};
    bool in = true;
    for (int i = 0; i < 3; ++i) {
      if (ccw(p[i], p[(i + 1) % 3], p[(i + 2) % 3]) != ccw(p[i], p[(i + 1) % 3], q)) {
        in = false;
        break;
      }
    }
    cout << (in ? "YES" : "NO") << '\n';
  }
}


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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))
#define Ssort(v) sort((v).begin(),(v).end(),[](auto &left,auto &right){return left.second<right.second;})

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

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

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll k;
    cin>>k;
    cout<<k/2*((k+1)/2)<<endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
static const int CONST = 1000000007;


int main(){

    int N; cin >> N;
    vector<long long> A;
    for(int i = 0; i < N; i++){
        long long a; cin >> a;
        A.push_back(a);
    }
    long long ans = 0;
    for(int i = 0; i < 60; i++){
        int num0 = 0, num1 = 0;
        for(int j = 0; j < N; j++){
            if(A[j] % 2 == 0) num0++;
            else num1++;
            A[j] /= 2;
        }
        long long twos = pow(2, i);
        //cout << num0 << " " << num1 << " " << twos << endl;
        //ans += num0 * num1 * twos; 
        twos %= CONST;
        twos *= num0;
        twos %= CONST;
        twos *= num1;
        twos %= CONST;
        ans += twos;
        ans %= CONST;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6512
n,a,b=list(map(int, input().split()))
C=10**9+7

def perm(a,b):
    tmp=1
    for i in range(b):
        tmp*=a-i
        tmp=tmp%C
    return tmp

cta=perm(n,a)*pow(perm(a,a),C-2,C)
ctb=perm(n,b)*pow(perm(b,b),C-2,C)

ans=pow(2,n,C)-1-cta-ctb
print(ans%C)

Measured memory_bytes: 63544
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int n,m,mod=1e9+7;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m;n++;
	int ans=0,l,r;
	FOR(i,m,n){
		l=(1+i)*i/2;
		r=(2*n-i+1)*i/2;
		ans=ans+r-l+1;
		ans=ans%mod;
	}
	cout<<ans<<'\n';
	RE 0;
}




Measured memory_bytes: 3648
n = int(input())
s = input()
s += s[0]
lst = ["SS","SW","WS","WW"]
for x in lst:
    ans = x
    for i in range(1,n+1):
        if (s[i] == "o" and ans[i] == "S") or (s[i] == "x" and ans[i] == "W"):
            if ans[i-1] == "S": ans += "S"
            else: ans += "W"
        else:
            if ans[i-1] == "S": ans += "W"
            else: ans += "S"
    if ans[-2:] == x:
        print(ans[:n])
        exit()
print(-1)

Measured memory_bytes: 3444
#include <iostream>

int main(void)
{
    int debt = 100000;

    int n;
    std::cin >> n;

    for(int i = 0; i < n; ++i)
    {
        debt *= 1.05;
        debt += (debt % 1000 != 0 ? 1000 - debt % 1000 : 0);
    }

    std::cout << debt << std::endl;
    return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

void solve() {

}

int main() {
  int n;
  cin >> n;
  deque<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(ALL(a));
  reverse(ALL(a));
  ll ans = 0;
  int cnt = 0, cur = 0;
  rep(i,n-1) {
    if( i == 0 ) {
      ans += a[cur];
      ++cur;
    } else {
      if( cnt == 0 ) {
	ans += a[cur];
	++cnt;
      } else {
	ans += a[cur];
	++cur;
	cnt = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5260
import numpy as np

n, m, x = map(int, input().split())

books = []

for i in range(n):
    books.append(list(map(int, input().split())))

books = np.array(books)

ok = 0
min_c = 100000000

for i in range(1 << n):
    ans = np.array([0 for j in range(m+1)])
    for k in range(n):
        if (i >> k & 1) == 1:
            ans += books[k]
    if ((ans[1:] - x) >= 0).all():
        ok = 1
        min_c = min(min_c, ans[0])

if not ok:
    print(-1)
else:
    print(min_c)


Measured memory_bytes: 27344
//Pantyhose(black) + glasses = infinity

#include <bits/stdc++.h>
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"

const int MAX_N = 100002;
const int MOD = 1000000007;

int n, a[MAX_N];
int64_t ps[MAX_N], s[MAX_N];

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

int64_t pw(int64_t n, int64_t k) {
	if (k==0)
		return 1;
	int64_t tmp = pw(n, k/2);
	if (k%2)
		return tmp * tmp % MOD * n % MOD;
	return tmp * tmp % MOD;
}

int64_t get(int l, int r) {
	return (ps[r] - ps[l-1] + MOD) % MOD;
}

void solve() {
	for (int i=1; i<=n; ++i)
		ps[i] = (ps[i-1] + a[i]) % MOD;
	int64_t fact = 1;
	for (int i=1; i<=n; ++i)
		fact = fact * i % MOD;
	int64_t res = 0;
	for (int i=1; i<=n; ++i) {
		s[i] = ((s[i-1] - get(n-i+2, n) + MOD + get(i, n))) % MOD;
		if (i==n) {
			res = (res + s[n] * fact) % MOD;
			break;
		}
		int64_t tmp1 = (get(1, i) + get(n-i+1, n)) % MOD;
		int64_t tmp2 = (s[i] - tmp1 + MOD) % MOD;
		res = (res + tmp1 * fact % MOD * pw(i+1, MOD-2)) % MOD;
		res = (res + tmp2 * fact % MOD * pw(1LL*(i+2)*(i+1)/2, MOD-2)) % MOD;
	}
	cout << res;
}

int main() {
	#ifdef GLASSES_GIRL
		freopen(FILE_NAME".inp", "r", stdin);
		freopen(FILE_NAME".out", "w", stdout);
	#endif
	ios::sync_with_stdio(0); cin.tie(0);
	readInput();
	solve();
}

Measured memory_bytes: 2176
N = int(input())
MOD = 10**9 + 7
S = input() + "_"
T = input() + "_"
C = []
k = 0
while k < N:
    if S[k] == S[k+1]:
        C.append(2)
        k += 1
    else:
        C.append(1)
    k += 1
if C[0] == 1:
    ans = 3
else:
    ans = 6

for k in range(1,len(C)):
    if C[k-1] == 2 and C[k] == 2:
        ans *= 3
        ans %= MOD
    elif C[k-1] == 2 and C[k] == 1:
        ans *= 1
    elif C[k-1] == 1 and C[k] == 2:
        ans *= 2
        ans %= MOD
    else:
        ans *= 2
        ans %= MOD
print(ans)


Measured memory_bytes: 3064
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	input = input.split('\n')[0];
	var N = input.length;
	var sn = 0;
	for(var i = 0; i < N; i++) sn += toInt(input[i]);
	var n = toInt(input);
	var ans = n%sn===0? 'Yes': 'No';
	console.log(ans);
}


Measured memory_bytes: 7372
N,K=map(int,input().split())
if K>(N-1)*(N-2)//2:
    print(-1)
    quit()
print(N-1+(N-1)*(N-2)//2-K)
for i in range(2,N+1):
    print(1,i)
k=(N-1)*(N-2)//2-K
g=[]
for i in range(2,N+1):
    for j in range(2,N+1):
        if i<j:
            g.append([i,j])
for i in range(k):
    print(g[i][0],g[i][1])


Measured memory_bytes: 43504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    string s;
    cin >> s;
    ll ans=0;
    if(s[0]==s[1]&&s[1]==s[2]&&s[2]=='R') ans=3;
    else if((s[0]==s[1]&&s[0]=='R')||(s[1]==s[2]&&s[2]=='R')) ans=2;
    else if(s[0]=='R'||s[1]=='R'||s[2]=='R') ans=1;
    cout << ans << endl;
}

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

Measured memory_bytes: 1004
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(){
    int n;
    cin >> n;
    map<string, int> m;
    while (n--) { string s;
        cin >> s;
        ++m[s];
    }
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int MAX = 50;

int main(){
    int N;
    int d[MAX];
    int ans = 0;

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

    for(int i = 0;i < N;i++){
        for(int j = i + 1;j < N;j++){
            ans += d[i] * d[j];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
N = int(input())
A = [0] + [int(x) for x in input().split()] + [0]

cnt = sum(abs(A[i+1] - A[i]) for i in range(N+1))

for j in range(1, N+1):
    print(cnt - (abs(A[j]-A[j-1]) + abs(A[j+1]-A[j])) + abs(A[j+1]-A[j-1]))


Measured memory_bytes: 14048
def Distance(X,Y,p):
    s=0
    for x,y in zip(X,Y):
        s+=abs(x-y)**p
    print(s**(1/p))
    
n=int(input())
X=list(map(int,input().split()))
Y=list(map(int,input().split()))

for p in range(1,4):
    Distance(X,Y,p)
print(max(abs(x-y) for (x,y) in zip(X,Y)))


Measured memory_bytes: 5648
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef string str;

int main(){
  ll a,b,c,x;
  cin >> a >> b >> c >> x;
  ll ans = 0;
  REP(i,a+1){
    REP(j,b+1){
      REP(k,c+1){
        if(500*i+100*j+50*k==x) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


ll N;
ll Q;
ll A[100010];
ll X[100010];
ll sums1[100010];
ll sums_alt[100010];

bool check(ll k, ll x){
    // A[N  - k] の要素まで取ることができる
    // x からの差分を計算する
    ll diff = A[N  - k] - x;


    ll l = lower_bound(A, A + N,  x - diff) - A;
    ll r = lower_bound(A, A + N,  x + diff) - A;

    ll cnt = r - l + 1;
    // cout << k << " " << cnt << endl;

    return (cnt >= k);
}

int main(){
    cin >> N >> Q;
    for(ll i = 0; i < N; i++){
        cin >> A[i];
    }
    for(ll i = 0; i < Q; i++){
        cin >> X[i];
    }

    for(ll i = 0; i < N; i++){
        sums1[i + 1] = sums1[i] + A[i];
        sums_alt[i + 1] = A[i];
        if(i - 1 >= 0) {
            sums_alt[i + 1] += sums_alt[i - 1];
        }
    }


    for(ll i = 0; i < Q; i++){
        ll ub = N + 1;
        ll lb = 1;
        while(ub - lb > 1){
            // cout << ub << ", " << lb << endl;
            ll mid = (ub + lb) / 2;
            if(check(mid, X[i])){
                lb = mid;
            }
            else{
                ub = mid;
            }
        }
        ll K = lb;
        // cout << K << endl;
        // cout << sums_alt[N-2*K] << endl;
        ll ans = sums1[N] - sums1[N - K] + (N - 2 * K >= 0 ? sums_alt[N - 2 * K] : 0);
        cout << ans << endl;
    }
    
    

}


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

int main()
{
	char b, ans;
	cin >> b;
	if (b == 'A')
		ans = 'T';
	else if (b == 'T')
		ans = 'A';
	else if (b == 'C')
		ans = 'G';
	else
		ans = 'C';
	cout << ans << endl;
}

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

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

vector<pair<ll,ll>> E[100005];
ll ans[100005];

void dfs(ll fro, ll to, ll dis) {
  ans[to] = dis%2;
  for (auto& e:E[to]) {
    if (e.first != fro) dfs(to, e.first, dis+e.second);
  }
}

int main() {
  int n;
  cin >> n;
  ll u,v,w;
  rep(i,n-1) {
    cin >> u >> v >> w;
    E[u-1].push_back({v-1, w%2});
    E[v-1].push_back({u-1, w%2});
  }
  dfs(-1,0,0);
  rep(i,n) printf("%lld\n", ans[i]);
  return 0;
}


Measured memory_bytes: 13340
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;


int main() {
    int x, y, z;
    cin >> x >> y >> z;
    cout << (x - z) / (y + z) << endl;
    return 0;
}

Measured memory_bytes: 256
//0360
#include <iostream>
using namespace std;
int main(void){
    int a,b,s,f,n,i,c;
    cin >> a >> b >> n;
    c=0;
    
    for(i=1;i<=n;i++){
        cin >> s >> f;
    if((a<s&&s<b)||(s<=a&&a<f))
        c ++ ;

    }
    if(c==0)
    cout << '0' << endl;
    else
    cout << '1' << endl;
}



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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int n, k; cin >> n >> k;

    if (n == 1) {
        cout << k << endl;
    } else {
        int ans = k;
        for (int i = 1; i < n; ++i) {
            ans *= (k - 1);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
typedef long long LL;
int n;
LL a[200050],sum;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		a[i]-=i;
	}
	sort(a+1,a+n+1);
	if(n%2==0){
		int pos=(a[n/2+1]+a[n/2])/2;
		sum=0;
		for(int i=1;i<=n;i++){
			sum+=abs(a[i]-pos);
		}
	}
	else{
		int pos=a[(n+1)/2];
		sum=0;
		for(int i=1;i<=n;i++){
			sum+=abs(a[i]-pos);
		}
	}
	printf("%lld\n",sum);
}

Measured memory_bytes: 1792
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>

using namespace std;

class Octahedra{
public:
  vector<int> x;

  Octahedra(){
    x.resize(8);
  }
  
  void rollLR(){
    int tmp = x[0];
    x[0] = x[3];
    x[3] = x[4];
    x[4] = x[1];
    x[1] = tmp;

    tmp = x[7];
    x[7] = x[6];
    x[6] = x[5];
    x[5] = x[2];
    x[2] = tmp;
  }

  void rollTF(){
    swap(x[0],x[7]);
    swap(x[1],x[2]);
    swap(x[4],x[5]);
    swap(x[3],x[6]);
  }

  void rollR(){
    int tmp = x[0];
    x[0] = x[7];
    x[7] = x[2];
    x[2] = x[1];
    x[1] = tmp;
    
    tmp = x[3];
    x[3] = x[6];
    x[6] = x[5];
    x[5] = x[4];
    x[4] = tmp;
  }

  bool equal(const Octahedra &o){
    for(int i = 0 ; i < 8 ; i++){
      if(x[i] != o.x[i]){ return false; }
    }
    return true;
  }

  bool operator == (const Octahedra &o){
    for(int i = 0 ; i < 2 ; i++){
      for(int j = 0 ; j < 4 ; j++){
        if(equal(o)){ return true; }
        rollLR();
      }
      rollTF();
    }
    for(int i = 0 ; i < 4 ; i++){
      for(int j = 0 ; j < 4 ; j++){
        if(equal(o)){ return true; }
        rollLR();
      }
      rollR();
    }
    rollLR();
    for(int i = 0 ; i < 4 ; i++){
      for(int j = 0 ; j < 4 ; j++){
        if(equal(o)){ return true; }
        rollLR();
      }
      rollR();
    }
    return false;
  }

  bool operator < (const Octahedra &o)const{
    for(int i = 0 ; i < 8 ; i++){
      if(x[i] != o.x[i]){
        return x[i] < o.x[i];
      }
    }
  }
};

int main(){
  map<string,int> mp;
  string s;
  while(cin >> s){
    Octahedra o;
    mp.clear(); mp[s] = 0;
    o.x[0] = 0;
    int idx = 1;
    set<Octahedra> st;
    for(int i = 0 ; i < 7 ; i++){
      cin >> s;
      if(mp.find(s) == mp.end()){
        mp[s] = idx++;
      }
      o.x[i+1] = mp[s];
    }
    sort(o.x.begin(),o.x.end());
    set<Octahedra>::iterator it;
    do{
      bool found = false;
      for(it = st.begin() ; it != st.end() ; ++it){
        Octahedra a = *it;
        if(a == o){
          found = true;
          break;
        }
      }
      if(!found){
        st.insert(o);
      }
    }while(next_permutation(o.x.begin(),o.x.end()));
    cout << st.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 1400
/*
--> WHEN IT'S OBVIOUS THAT THE GOAL CANNOT BE REACHED,
	DON'T ADJUST THE GOALS,
	ADJUST THE ACTION STEPS.

--> THE WAY YOU CONQUER SELF-DOUBT IS BY DOING THINGS THAT MAKE YOU UNCOMFORTABLE.

--> IT IS DURING OUR DARKEST MOMENTS WE MUST FOCUS TO SEE LIGHT.
*/

#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <climits>
using namespace std;
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortAll(x) sort(all(x))
#define sz(x) (int)x.size()
#define clr(x) memset(x, 0, sizeof(x))
#define PI 3.1415926535897932384626
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); IO();
typedef long long ll;
typedef pair< int, int >	pii;
typedef pair< ll, ll >		pl;
typedef vector< int >		vi;
typedef vector< ll >		vl;
typedef vector< pii >		vpii;
typedef vector< pl >		vpl;
typedef vector< vi >		vvi;
typedef vector< vl >		vvl;

const int MOD = 1e9 + 7;

ll power(ll a, ll b)
{
	ll ans = 1;

	while (b > 0)
	{
		if (b & 1)
			ans *= a;
		a = a * a;
		b >>= 1;
	}
	return ans;
}

ll powm(ll a, ll b)
{
	a %= MOD;
	ll ans = 1;

	while (b > 0)
	{
		if (b & 1)
			ans = (ans * a) % MOD;
		a = (a * a) % MOD;
		b >>= 1;
	}
	return ans;
}

void IO()
{
	#ifndef ONLINE_JUDGE
		freopen("Input.txt", "r", stdin);
		freopen("Output.txt", "w", stdout);
	#endif
}

//================================

int main()
{
	// FAST;

	ll n;
	cin >> n;

	ll i = 1, ans = 0;
	while (n--)
	{
		if (i % 3 != 0 && i % 5 != 0)
			ans += i;
		i++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
priority_queue<int, vector<int>, greater<int> > q;
priority_queue<int> q1;
int n;
int a[300015];
long long f[300015], f1[300015];
int main() {
	//freopen("a.inp", "r", stdin);
	scanf("%d", &n);
	for (int i = 0; i < 3 * n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++) {
		f[n - 1] += a[i];
		q.push(a[i]);
	}

	for (int i = n; i < 2 * n; i++) {
		f[i] = f[i - 1];
		int k = q.top();
		if (a[i] > k) {
			f[i] = f[i - 1] + a[i] - k;
			q.pop();
			q.push(a[i]);
		}
	}
	for (int i = 3 * n - 1; i >= 2 * n; i--) {
		f1[2 * n] += a[i];
		q1.push(a[i]);
	}
	for (int i = 2 * n - 1; i >= n; i--) {
		f1[i] = f1[i + 1];
		int k = q1.top();
		// printf("%d\n",k);
		if (a[i] < k) {
			f1[i] = f1[i + 1] + a[i] - k;
			q1.pop();
			q1.push(a[i]);
		}
	}
	long long ans = -1e16;
	for (int i = n; i <= 2 * n; i++) {
		ans = max(ans, f[i - 1] - f1[i]);
		// printf("%lld %lld\n", f[i - 1], f1[i]);
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 5112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    ll N;
    cin>>N;
    for(ll h=1;h<=3500;h++){
        for(ll n=1;n<=3500;n++){

            ll up=N*h*n;
            ll dow=4LL*h*n-N*n-N*h;
            if(dow==0) continue;
            if(up%dow!=0) continue;
            ll w=up/dow;
            if(0<w && w<=3500){
                cout<<h<<" "<<n<<" "<<w<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256