akhauriyash/Code-Regression huggingface dataset:
MAX = 2*10**6
MOD = 10**9+7

fac = [0] * (MAX+1)
finv = [0] * (MAX+1)
inv = [0] * (MAX+1)

def comb_init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX+1):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD

def comb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD


if __name__ == '__main__':
    k = int(input())
    s = input()
    n = len(s)
    comb_init()
    ans = 0
    for i in range(k+1):
        val = comb(i+n-1, n-1)
        val *= pow(25, i, MOD)
        val %= MOD
        val *= pow(26, k-i, MOD)
        val %= MOD
        ans += val
        ans %= MOD
    print(ans)


Measured memory_bytes: 135640
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int a, b, c;
  cin >> a >> b >> c;
  if(a+b >= c) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency : generator = Generator, yield;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


ulong log5(ulong x) {
    ulong y = 0;
    while (x > 5) {
        y++;
        x /= 5;
    }
    return y;
}


auto solve(ulong N) {
    if (N % 2 == 1)
        return 0;

    ulong k = log5(N);

    ulong ans;
    foreach (ulong i; 1 .. k + 1) {
        ulong q = N / (2 * 5 ^^ i);
        ans += i * (q - q / 5);
    }
    return ans;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    ulong N;
    N = input.front.to!ulong;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(N);
    else {
        auto ans = solve(N);

        static if (isFloatingPoint!(ReturnType!solve))
            writeln(format("%.9f", ans));
        else static if (is(ReturnType!solve == bool))
            writeln(ans ? YES : NO);
        else
            writeln(ans);
    }
}


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

#define pb push_back
#define mp make_pair
#define size(n) ( int( n.size() ) )
#define sqr(n) ( (n) * (n) )
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int q, h, s, d;
    cin >> q >> h >> s >> d;
    int n;
    cin >> n;
    if ( 2 * q < h ){
        h = 2 * q;
    }
    if ( 2 * h < s ){
        s = 2 * h;
    }
    ll ans;
    if ( s * 2 < d ){
        ans = n * 1ll * s;
    }
    else{
        if ( n % 2 == 0 ){
            ans = ( n / 2 ) * 1ll * d;
        }
        else{
            ans = ( n - 1 ) / 2 * 1ll * d + s;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]= {-1,0,1,-1,1,-1,0,1};
//int dy[]= {1,1,1,0,0,-1,-1,-1};






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    MSI mp;
    int i,n,x,sum=0;
    string s[55];
    cin >> n;
    cin >> s[1] >> x;
    mp[s[1]]=sum=x;
    for(i=2;i<=n;i++)
    {
        cin >> s[i] >> x;
        sum+=x;
        mp[s[i]]=sum;
    }
    cin >> s[0];
    cout << mp[s[n]]-mp[s[0]];
    return 0;
}


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

int t;
int n;
int s;
int f;

int main() {
  while (1) {
    int sum = 0;
     scanf("%d", &t);
     if (t == 0) return 0;

     scanf("%d", &n);
     for (int i=0; i<n; i++) {
       scanf("%d%d", &s, &f);
       sum += f-s;
     }
     if (sum < t) {
       printf("%d\n", t-sum);
     } else {
       puts("OK");
     }
  }
}

Measured memory_bytes: 1044
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		string S; cin >> S;
		string V = "CODEFESTIVAL2016";
		UL ans = 0;
		rep(i, 16) if (S[i] != V[i]) ans++;
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

class dice {
    public:
    int top;
    int bottom;
    int north;
    int east;
    int south;
    int west;
    
    dice(int tin, int sin, int ein, int win, int nin, int bin) {
        top = tin;
        bottom = bin;
        north = nin;
        east = ein;
        south = sin;
        west = win;
    }
    
    void N() {
        int np = north;
        int tp = top;
        int sp = south;
        int bp = bottom;
        north = tp;
        top = sp;
        south = bp;
        bottom = np;
    }
    
    void S() {
        int np = north;
        int tp = top;
        int sp = south;
        int bp = bottom;
        north = bp;
        top = np;
        south = tp;
        bottom = sp;
    }
    
    void E() {
        int ep = east;
        int bp = bottom;
        int wp = west;
        int tp = top;
        east = tp;
        bottom = ep;
        west = bp;
        top = wp;
    }
    
    void W() {
        int ep = east;
        int bp = bottom;
        int wp = west;
        int tp = top;
        east = bp;
        bottom = wp;
        west = tp;
        top = ep;
    }
    
    void clock() {
        int ep = east;
        int sp = south;
        int wp = west;
        int np = north;
        east = np;
        south = ep;
        west = sp;
        north = wp;
    }
    
};

int check(dice dice1, dice dice2) {
    if (dice1.top == dice2.top && dice1.bottom == dice2.bottom
    &&dice1.north == dice2.north && dice1.east == dice2.east
    && dice1.south == dice2.south && dice1.west == dice2.west ) {
        return 1;
    } else {
        return 0;
    }
}


int main() {
  
  dice dice1(0, 0, 0, 0, 0, 0);
  cin >> dice1.top >> dice1.south >> dice1.east;
  cin >> dice1.west >> dice1.north >> dice1.bottom;
  
  dice dice2(0, 0, 0, 0, 0, 0);
  cin >> dice2.top >> dice2.south >> dice2.east;
  cin >> dice2.west >> dice2.north >> dice2.bottom;
  
      for (int i=0; i<4 && check(dice1,dice2) == 0; i++) {
          dice2.E();
          for (int j=0; j<4 && check(dice1,dice2) == 0; j++) {
              dice2.clock();
          }
      }
      for (int i=0; i<4 && check(dice1,dice2) == 0; i++) {
          dice2.N();
          for (int j=0; j<4 && check(dice1,dice2) == 0; j++) {
              dice2.clock();
          }
      }
  
  if (check(dice1,dice2) == 0) {
      cout << "No" << endl;
  } else {
      cout << "Yes" << endl;
  }

  return 0;
}




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

const int N = 2005;
typedef long long ll;

int n, a[N], tot, ans;
bitset <N*N> f;

int main() {
	cin>>n;
	f[0] = 1;
	for(int i = 1; i <= n; i++) {
		cin>>a[i];
		f |= f<<a[i];
		tot += a[i];
	}
	ans = (tot + 1)/2;
	while(!f[ans]) ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    deque<char>deq;
    string s;
    cin >> s;
    REP(i,s.length()){
        if(s[i]=='B'){
            if(!deq.empty())
                deq.pop_back();
        }
        else{
            deq.push_back(s[i]);
        }
    }
    REP(i,deq.size()){
        cout << deq[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
  string S, T;
  cin >> S >> T;
  if (S.size() != T.size()) {
    cout << "No" << endl;
    return 0;
  }
  int N = S.size();
  for (int i=0; i<N; i++) {
    bool f=true;
    for (int j=0; j<N; j++) {
      if (S[j] != T[(j+i)%N]) {
        f = false;
        break;
      }
    }
    if (f) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	nextReader = newScanner()

	x := nextInt()
	h := x / 3600
	m := (x % 3600) / 60
	s := (x % 3600) % 60
	fmt.Printf("%d:%d:%d\n", h, m, s)
}

var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}



Measured memory_bytes: 1100
from heapq import heappop, heappush

N,M = map(int,input().split())
LRC = [list(map(int,input().split())) for _ in range(M)]

INF = float('inf')
def dijkstra(s,n,g): # sからの最短距離 頂点数n g[v]=[(u1,w1),(u2,w2)....]:vからuへの有向辺があり、重みw
  que = []
  d = [INF for _ in range(n)]
  d[s] = 0
  heappush(que,(0,s))
  while len(que) > 0:
    p = heappop(que)
    v = p[1]
    if d[v] < p[0]:
      continue
    for u,w in g[v]:
      if d[u] > d[v]+w:
        d[u] = d[v]+w
        heappush(que,(d[u],u))
  return d

G = [[] for _ in range(N)]
for i in range(N-1):
  G[i+1].append((i,0))
for l,r,c in LRC:
  l -= 1
  r -= 1
  G[l].append((r,c))

p = dijkstra(0,N,G)[N-1]
print(p if p != INF else -1)


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

int main(){
  int N;
  int t[110000],x[110000],y[110000];
  cin >> N;
  t[0] =  x[0] = y[0] =0;
  for (int i=0;i<N;i++) cin >> t[i+1] >> x[i+1] >> y[i+1];
  
  bool kyan = 1;
  for (int i=0;i<N;i++){
  int dt = t[i+1] - t[i];
  int dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
  
  if (dt < dist) kyan = 0;
  if (dt%2 != dist%2) kyan = 0;
  }
  
  if (kyan) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <algorithm>

const int maxn=2e5+5;
#define int long long
struct question{
	int opt,x,s,t;
}q[maxn];

int n,Q,L,R,a[maxn];

#define F_L 1
#define F_R 0

inline bool check(int x,bool flag){
	for(int i=1;i<=Q;i++){
		if(q[i].opt==1){
			if(x>=q[i].x){
			x+=q[i].s;x*=q[i].t;}
		}else{
			if(x<=q[i].x){
			x-=q[i].s;x/=q[i].t;}
		}
	}
	//printf("%d\n",x);
	if(flag){
		return x>=L;
	}return x<=R;
}

signed main(){
	scanf("%lld%lld%lld%lld",&n,&Q,&L,&R);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	std::sort(a+1,a+n+1);
	for(int i=1;i<=Q;i++) scanf("%lld%lld%lld%lld",&q[i].opt,&q[i].x,&q[i].s,&q[i].t);
	int l=1,r=n,mid,res=0;
	while(l<=r){
		mid=(l+r)>>1;
		int now=a[mid];
		if(check(now,F_L)){
			r=mid-1;
			res=mid;
		}else l=mid+1;
		//printf("%d\n",mid);
	}int ansl=res;
	l=1,r=n,res=0;//printf("------------------\n");
	while(l<=r){
		mid=(l+r)>>1;
		int now=a[mid];
		if(check(now,F_R)){
			l=mid+1;
			res=mid;
		}else r=mid-1;
		//printf("%d\n",mid);
	}
	//printf("%lld %lld\n",ansl,res);
	printf("%lld\n",res-ansl+1);
	return 0;
}


Measured memory_bytes: 10404
# A, B 水 100g単位
# C, D 砂糖
# E 100g の水に溶ける砂糖の量
# F ビーカーに入る砂糖水の重さ

a, b, c, d, e, f = gets.split.map(&:to_i)
a *= 100
b *= 100

max_concentration = 0.0
ans = [a, 0]
0.upto(f/a) do |na|
  0.upto((f - a*na)/b) do |nb|
    0.upto((f - a*na - b*nb)/c) do |nc|
      0.upto((f - a*na - b*nb - c*nc)/d) do |nd|
        water = a*na + b*nb
        sugar = c*nc + d*nd
        break if water == 0 || sugar.fdiv(water) > e.fdiv(100)
        concentration = (100*sugar).fdiv(water+sugar)
        if concentration > max_concentration
          ans = [water + sugar, sugar]
          max_concentration = concentration
        end
      end
    end
  end
end

puts ans.join(' ')

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

int main(void){
    double x=0;
    double y=0;
    double angle=90;
    int d,a;
    while(1){
        scanf("%d,%d",&d,&a);
        if(d==0 && a==0){
            printf("%d\n%d\n",(int)x,(int)y);
            return 0;
        }
        x+=d*cos(angle*2*M_PI/360);
        y+=d*sin(angle*2*M_PI/360);
        angle-=a;
    }

}



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

namespace Prediction_and_Restriction
{
    class Program
    {
        static void Main(string[] args)
        {
            const char INVALID_CHAR = 'n';
            var input1 = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
            var input2 = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
            var input3 = Console.ReadLine();
            var _N = input1[0];
            var _K = input1[1];
            var _R = input2[0];
            var _S = input2[1];
            var _P = input2[2];
            var _T = input3.ToCharArray();
            var bestRSP = _T.Select(x => x == 'r' ? 'p' : (x == 's' ? 'r' : 's')).ToArray();

            for (var i = 0; i + _K < _N; i++)
            {
                if(bestRSP[i] != INVALID_CHAR && bestRSP[i] == bestRSP[i + _K])
                {
                    bestRSP[i + _K] = INVALID_CHAR;
                }
            }
            var scores = bestRSP.Select(x => x == 'r' ? _R : (x == 's' ? _S : (x == 'p' ? _P : 0))).ToArray();
            Console.WriteLine(scores.Sum());
        }
    }
}


Measured memory_bytes: 17120
import sys
input = sys.stdin.readline

def main():
    K = int(input())
    
    if K%2==0:
        return -1
    
    if K % 7:
        L = 9*K
    else:
        L = 9*K//7
    a = 1
    for i in range(1,L+1):
        a = (a * 10) % L
        if a == 1:
            return i
    return -1
ans =main()
print(ans)

Measured memory_bytes: 9176
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
    double A,B,H,M;
    cin >> A >> B >> H >> M;
    cout << fixed << setprecision(11);
    double theta = M_PI * (11. * M - 60. * H) / 360.;
    // cout << (11. * M - 60. * H) / 360. << endl;
    double len = sqrt(A*A + B*B - 2. * A * B * cos(theta));
    cout << len << endl;
    
    return 0;
}

Measured memory_bytes: 4168
def main():
  n = int(input())
  l = list(map(int,input().split()))

  if 0 in l:
    print(0)
    return
  
  ans=1
  for i in range(n):
    ans*=l[i]
    if ans> 10**18:
      print(-1)
      return
    
  print(ans)
        
main()
        
        
  

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

#define INF 1001001001
#define MAX 1e18

int main() {
  int n, m;
  cin >> n >> m;
  scc_graph g(n);
  rep(i,m) {
    int a, b; cin >> a >> b;
    g.add_edge(a,b);
  }
  vector< vector<int> > ans = g.scc();
  cout << ans.size() << endl;
  for (auto a : ans) {
    cout << a.size();
    for (auto aa : a) cout << " " << aa;
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 40084
#include <iostream>
#include <string>

int main(){

    int n;
    int *array;
    int key;
    std::string str;

   // std::cout << "Input the length of the array: ";
    std::cin >> n;

  //  std::cout << "Input the array: ";

    array = new int[n];

    for(int i = 0; i < n; i++)
        std::cin >> array[i];
    
    //show the array before sorting
    for(int k = 0; k < n-1; k++)
            std::cout << array[k] << " ";
    std::cout << array[n-1] << std::endl;

    for(int i = 1, j; i < n; i++){
        key = array[i];
        //insert Array[i] into the sorted sequence A[0,...,j-1] 
        j = i - 1;
        while(j >= 0 && array[j] > key){
            array[j+1] = array[j];
            j--;
        }
        array[j+1] = key;
        //show the intersection of sorting
        for(int k = 0; k < n-1; k++)
            std::cout << array[k] << " ";
        std::cout << array[n-1] << std::endl;
    }

    delete[] array;
    return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n,p[100],a,t;
	while(cin>>n){
		rep(i,n)cin>>p[i];
		sort(p,p+n);a=t=0;
		rep(i,n)t+=p[i],a+=t;
		cout<<a<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
n=int(input())
r=[list(map(int,input().split())) for i in range(n)]
b=[list(map(int,input().split())) for i in range(n)]
b.sort(key=lambda x:x[0])
cnt=0
r_used=[False]*n
for i in range(n):
  bx,by=b[i][0],b[i][1]
  max_y=-1
  idx=-1
  for j in range(n):
    if r[j][0]<bx and r[j][1]<by and max_y<r[j][1] and not r_used[j]:
      idx=j
      max_y=r[j][1]
  if idx>=0:
    r_used[idx]=True
    cnt+=1
print(cnt)

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


int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int kotae=min(b,d)-max(a,c);
  if(kotae<=0){
    cout<<0<<endl;
  }else{
    cout<<kotae<<endl;
  }
  return 0;
}

Measured memory_bytes: 3644
# -*- coding: utf-8 -*-

import sys
from operator import itemgetter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 **18
MOD = 10 ** 9 + 7

class SegTree:
    """
    セグメント木
    1.update:  i番目の値をxに更新する
    2.query: 区間[l, r)の値を得る
    """

    def __init__(self, n, func, intv, A=[]):
        """
        :param n: 要素数(0-indexed)
        :param func: 値の操作に使う関数(min, max, add, gcdなど)
        :param intv: 要素の初期値(単位元)
        :param A: 初期化に使うリスト(オプション)
        """
        self.n = n
        self.func = func
        self.intv = intv
        # nより大きい2の冪数
        n2 = 1
        while n2 < n:
            n2 <<= 1
        self.n2 = n2
        self.tree = [self.intv] * (n2 << 1)
        # 初期化の値が決まっている場合
        if A:
            # 1段目(最下段)の初期化
            for i in range(n):
                self.tree[n2+i] = A[i]
            # 2段目以降の初期化
            for i in range(n2-1, -1, -1):
                self.tree[i] = self.func(self.tree[i*2], self.tree[i*2+1])

    def update(self, i, x):
        """
        i番目の値をxに更新
        :param i: index(0-indexed)
        :param x: update value
        """
        i += self.n2
        self.tree[i] = x
        while i > 1:
            self.tree[i >> 1] = x = self.func(x, self.tree[i ^ 1])
            i >>= 1
 
    def query(self, a, b):
        """
        [a, b)の値を得る
        :param a: index(0-indexed)
        :param b: index(0-indexed)
        """
        l = a + self.n2
        r = b + self.n2
        s = self.intv
        while l < r:
            if r & 1:
                r -= 1
                s = self.func(s, self.tree[r])
            if l & 1:
                s = self.func(s, self.tree[l])
                l += 1
            l >>= 1
            r >>= 1
        return s

    def get(self, i):
        """ 一点取得 """
        return self.tree[i+self.n2]

N = INT()
LR = []
for i in range(N):
    l, r = MAP()
    LR.append((l, r))

LR.sort(key=itemgetter(0))
L, R = zip(*LR)
st1 = SegTree(N, max, -INF, L)
st2 = SegTree(N, min, INF, R)

ans = 0
# 1区間だけ独立させるケース
for i in range(N):
    l1 = st1.get(i)
    r1 = st2.get(i)
    l2 = max(st1.query(0, i), st1.query(i+1, N))
    r2 = min(st2.query(0, i), st2.query(i+1, N))
    ans = max(ans, max(r1-l1+1, 0) + max(r2-l2+1, 0))

# ある場所から半分に分けるケース
for i in range(N-1):
    l1 = st1.query(0, i+1)
    r1 = st2.query(0, i+1)
    l2 = st1.query(i+1, N)
    r2 = st2.query(i+1, N)
    ans = max(ans, max(r1-l1+1, 0) + max(r2-l2+1, 0))

print(ans)


Measured memory_bytes: 83548
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
#include <set>
#include <numeric>
using namespace std;

using ll = long long;

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

int main()
{
	string S, T;
	cin >> S >> T;

	int ans = 0;
	rep(i, S.size())
	{
		if (S[i] != T[i]) ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3848
#include<iostream>
using namespace std;
int main(){
  long long n,rm_num,rm_cnt,sum_stone=0;
  cin >> n;
  int a[n],dif[n];
  bool f=false;
  rm_num=(n*(n+1))/2;
  cin >> a[0];
  sum_stone+=a[0];
  for(int i=0;i<n-1;i++){
    cin >> a[i+1];
    dif[i] = a[i+1]- a[i];
    sum_stone+=a[i+1];
  }
  dif[n-1] = a[0]-a[n-1];
  rm_cnt = sum_stone/rm_num;
  if(rm_cnt*rm_num!=sum_stone){
    cout <<"NO\n";
    return 0;
  }
  for(int i=0;i<n;i++){
      dif[i]-=rm_cnt;
    }
    for(int i=0;i<n;i++){
      while(dif[i]<0){
        dif[i]+=n;
      }
      if(dif[i]!=0){
        f=true;
        break;
      }
    }
    if(f) cout<<"NO\n";
    else cout <<"YES\n";

}


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

int main() {
 int N;
 string S;
 cin >> N >> S;
 int count =0;
 for(int i =0; i<N-2; i++){
     if(S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C'){
         count++;
     }
 }
cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

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

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

#define MAX 1010

int main(){
  int q;
  while(cin>>q, q+1){
    double x = q / 2.0;
    while( abs(x*x*x - q) >= 0.00001 * q )
      x = x - (x*x*x - q) / (3*x*x);
    printf("%.6f\n",x);
  }
  return 0;
}

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

using namespace std;

long long n, x;

long long f(long long a, long long b){
	if (a == 0) return -b;
	return 2 * (b / a) * a + f(b % a, a);
}

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%lld%lld",&n,&x);
	printf("%lld",n + f(min(n - x, x), max(x, n - x)));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

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

    vector<ll> evens;
    stack<ll> odds;

    bool isOdd = n%2;


    REP(i, n){
        if (!((i%2 == 0)^isOdd)){
            
            odds.emplace(a[i]);
        }
        else{
            evens.push_back(a[i]);
        }
    }

    while(!odds.empty()){
        cout << odds.top() << ' ';
        odds.pop();
    }
    for (auto i : evens){
        cout << i << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 6564
#include<stdio.h>

int main(){

  int i,j,H,W;
  while (1){scanf("%d %d",&H,&W);if(W==0&&H==0){break;}
for(j=0;j<H;j++){for(i=0;i<W;i++){
 if (i%2==0&&j%2!=0){printf(".");}
 else if (i%2!=0&&j%2==0){printf(".");}
else{printf("#");}
}
printf("\n");}
 printf("\n");}
 
 return 0;
}


Measured memory_bytes: 2052
'use strict';
var Main = function(stdin) {
  var line = stdin.split('\n');
  var param = line[0].split(' ').map(Number);
  var result = (function(a,b,c) {

  	return (a < b && b < c)
  		? 'Yes'
  		: 'No';
 
  }(
  	param[0],param[1],param[2]
  ));
  console.log(result);
};

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7380
// chrono::system_clock::now().time_since_epoch().count()
#include<bits/stdc++.h>

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " = " << x << endl;

using namespace std;

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

const int MOD = (int)1e9 + 7;
const int M = (1 << 17);

int dp[2][M];
int n, x, y, z;
int ans;

int addMod(int a, int b, int m = MOD) {
  a += b;
  
  if (m <= a) {
    a -= m;
  }
  
  return a;
}

bool bit(int x, int p) {
  return x & (1 << p);
}

void solve() {
  scanf("%d %d %d %d", &n, &x, &y, &z);
  int bad = (1 << (z - 1)) + (1 << (y + z - 1)) + (1 << (x + y + z - 1));
  dp[0][0] = 1;
  
  for (int i = 1; i <= n; ++i) {
    for (int mask = 0; mask < M; ++mask) {
      for (int j = 1; j <= 10; ++j) {
        int nmask = (mask << j) + (1 << (j - 1));
        nmask &= (M - 1);
        
        if ((nmask & bad) != bad) {
          dp[1][nmask] = addMod(dp[1][nmask], dp[0][mask]);
        }
      }
    }
    
    for (int mask = 0; mask < M; ++mask) {
      dp[0][mask] = dp[1][mask];
      dp[1][mask] = 0;
    }
  }
  
  for (int mask = 0; mask < M; ++mask) {
    ans = addMod(ans, dp[0][mask]);
  }
  
  int rest = 1;
  
  for (int i = 1; i <= n; ++i) {
    rest = (rest * 10ll) % MOD;
  }
  
  printf("%d\n", addMod(rest, MOD - ans));
}

int main() {
  int tt = 1;
  
  while (tt--) {
    solve();
  }

  return 0;
}



Measured memory_bytes: 4776
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <cstring>
#include <cctype>
#include <ctime>
#include <climits>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <tuple>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <complex>
#include <random>
#include <cassert>
#include <chrono>
#include <cstdint>
#include <functional>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#ifndef M_PI
#define M_PI 3.141592653589793238462643383279
#endif

#define int long long

#define mp make_pair
#define mt make_tuple
#define fr first
#define sc second
#define pb push_back
#define pp pop_back
#define all(x) x.begin(), x.end()
#define get0 get<0>
#define get1 get<1>
#define get2 get<2>
#define get3 get<3>

#define debug(x) cerr << #x << " = " << x << ", line = " << __LINE__ << endl

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef tuple<long long, long long, long long> tlll;
typedef tuple<int, int, int> tiii;
typedef tuple<int, int, int, int> tiiii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MOD = 1e9 + 7;



int32_t main()
{
#ifdef chikibambony
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int j = 0; j < n; ++j) {
        cin >> b[j];
    }
    reverse(all(b));
    int c = -1;
    for (int i = 0; i < n; ++i) {
        if (a[i] == b[i]) {
            c = a[i];
            break;
        }
    }
    int l = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] == c && b[i] == c) {
            l = i;
            break;
        }
    }
    int r = -1;
    for (int i = n - 1; i >= 0; --i) {
        if (a[i] == c && b[i] == c) {
            r = i;
            break;
        }
    }

    for (int i = 0; i < n; ++i) {
        if (a[i] != c && b[i] != c && l <= r) {
            swap(b[i], b[l]);
            ++l;
        }
    }

    if (l <= r) {
        cout << "No\n";
        return 0;
    }

    cout << "Yes\n";

    for (int i = 0; i < n; ++i) {
        cout << b[i] << ' ';
        assert(b[i] != a[i]);
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 6364
#include <iostream> 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define MAX 1000001
ll prime[MAX];
#define FAST           ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define gcd __gcd
// ll rec(vector<vector<ll> >& dp,vector<ll>& arr,int n,int i,int k,int w)
// {
//   ll ans=0;
//   if(i>=n)
//     return 0;

//   if(dp[i][k]!=-1)
//     return dp[i][k];


//   if(k!=0)
//   ans=max(rec(dp,arr,n,i+1,w,w),arr[i]+rec(dp,arr,n,i+1,k-1,w));
//   else
//   ans=max(rec(dp,arr,n,i+1,k,w),rec(dp,arr,n,i+1,w,w));

//   return dp[i][k]=ans;

// }

//ll t[400008];
// void build(vector<ll>& a, int v, int tl, int tr) {
//     if (tl == tr) {
//         t[v] = a[tl];
//     } else {
//         int tm = (tl + tr) / 2;
//         build(a, v*2, tl, tm);
//         build(a, v*2+1, tm+1, tr);
//         t[v] = max(t[v*2] ,t[v*2+1]);
//     }
// }

// ll maxi(int v, int tl, int tr, int l, int r) {
//     if (l > r) 
//         return 0;
//     if (l == tl && r == tr) {
//         return t[v];
//     }
//     int tm = (tl + tr) / 2;
//     return max(maxi(v*2, tl, tm, l, min(r, tm)) ,maxi(v*2+1, tm+1, tr, max(l, tm+1), r));
// }



// void update(int v, int tl, int tr, int pos, ll new_val) {
//     if (tl == tr) {
//         t[v] = new_val;
//     } else {
//         int tm = (tl + tr) / 2;
//         if (pos <= tm)
//             update(v*2, tl, tm, pos, new_val);
//         else
//             update(v*2+1, tm+1, tr, pos, new_val);
//         t[v] = max(t[v*2] ,t[v*2+1]);
//     }
// }


struct hash_pair {
   template <class T1, class T2>
   size_t operator()(const pair<T1, T2>& p) const{
      auto hash1 = hash<T1>{}(p.first);
      auto hash2 = hash<T2>{}(p.second);
      return hash1 ^ hash2;
   }
};


int temp[1000002]={0};

void sieve()
{
  
  for(int i=1;i<1000002;i++)
    temp[i]=1;

  for(int i=2;i<1000002;i++)
  {
     temp[i]++;
      for(int j=i*2;j<1000002;j+=i)
      { 
        temp[j]++;;
      }
  }

}

void dfs(int i,vector<vector<int> >& g,vector<bool>& v)
{
  v[i]=true;

  for(auto x:g[i])
  {
    if(v[x]==false)
      dfs(x,g,v);
  }
}


int main() { 

int n,m,x,y;
cin>>n>>m;
vector<bool> v(n,false);

vector<vector<int> > g(n);

for(int i=0;i<m;i++)
{
cin>>x>>y;
x--;
y--;
  g[x].pb(y);
  g[y].pb(x);
}

int c=0;
for(int i=0;i<n;i++)
if(v[i]==false)
{
  dfs(i,g,v);
  c++;
}

cout<<c-1<<"\n";
return 0;
}
/*

*/


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

int main()
{
	int n, m;
	int L, R;
	vector<int> l, r;
	int max=0, min=1000001;
	cin >> n >> m;

	for (int j = 0; j < m; j++) {
		cin >> L >> R;
		l.push_back(L);
		r.push_back(R);
	}
	int i;
	for (i = 1; i < l.size(); i++) {
		l[i] = (l[i] < l[i - 1]) ? l[i - 1] : l[i];
		r[i] = (r[i] > r[i - 1]) ? r[i - 1] : r[i];
	}
	i--;
	int answer = r[i] - l[i] + 1;
	answer = (answer < 0) ? 0 : answer;
	cout <<answer<< endl;
	return 0;
}

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

int gcd(int w, int h) {
  int r;
  while (0!=h) {
    r=w%h;
    w=h;
    h=r; 
  }
  return w;
}

int main(){
	int W,H,C;
	cin>>W>>H>>C;
	int cost=0;
	int M=gcd(W,H);
	cost=((W/M)*C)*(H/M);
	cout<<cost<<endl;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(150) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<lli,lli>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  lli A,B,C,D,E,L,R,X,Y,W,H,N,M,K,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  A=0;B=0;C=0;
  rep(i,0,N){
    cin >> D >> X >> Y;
    K=D-A;
    L=abs(X-B);
    R=abs(Y-C);
    if(K<L||K<R||K%2!=(L+R)%2){
      flag=1;Out("No");break;
    }
    swap(A,D);
    swap(B,X);
    swap(C,Y);
  }
  if(!flag)Out("Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(int _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 200000

using namespace std;

ll h[maxn+5], d[maxn+5];

ll sq (ll x) { return x*x; }

struct linie {
  ll a, b;
  ll eval (ll x) { return a*x+b; }
};

struct trick {
  deque<linie> dq;
  bool xcresc (linie &x, linie &y, linie &z) {
    return (x.b-y.b)*(z.a-y.a) < (y.a-x.a)*(y.b-z.b);
  }
  void baga (linie x) {
    while (sz(dq) > 1 && !xcresc(dq.end()[-2], dq.end()[-1], x)) dq.pop_back();
    dq.pb(x);
  }
  ll query (ll x) {
    while (sz(dq) > 1 && dq[0].eval(x) > dq[1].eval(x)) dq.pop_front();
    return dq[0].eval(x);
  }
};

trick cht;

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; ll c; cin >> n >> c;
  int i, j, z;
  for (i = 1; i <= n; i++) cin >> h[i];
  d[1] = 0;
  cht.baga({-2*h[1], sq(h[1])});
  for (i = 2; i <= n; i++) {
    d[i] = c + sq(h[i]) + cht.query(h[i]);
    cht.baga({-2*h[i], d[i]+sq(h[i])});
  }
  cout << d[n];
  return 0;
}


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

int main() {
	ll n;
	cin >> n;
	ll ans = 0;
	for (ll i = 1; i <= n; ++i) {
		for (ll j = i; j <= n; j += i) {
			ans += j;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3624
fun main() {
    val n = readInt()
    println(if (n >= 30) "Yes" else "No")
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readLong() = readString().toLong()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 34532
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
//template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
signed main(){
  int a,b,c,d=0;
  cin>>a>>b>>c;
  for(int i=1;i<=a;i++){
    if(ketas(i)>=b&&ketas(i)<=c)
      d+=i;
  }
  cout<<d<<endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k, sum int
	fmt.Scan(&n, &k)
	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}
	sort.Ints(p)
	for i := 0; i < k; i++ {
		sum += p[i]
	}
	fmt.Println(sum)
}


Measured memory_bytes: 1884
#include<iostream>
#include<cstdio>
using namespace std;
int n,a,b;
int main()
{
	scanf("%d",&n);
	if(n==1)printf("Hello World\n");
	else
	{
		scanf("%d%d",&a,&b);printf("%d\n",a+b);
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx") 
#include<bits/stdc++.h>
using namespace std;

inline int read()
{
	int ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}
#define N 6006
int flag,vis[N],L[N],vi[N],qn,n,m,p,cnt[N],c[N][3],tot,a[N],u,v,w,C[N][2],A[N];
int q[9000009];
long long D[N];

void dfs(int p)
{
	L[p]=1;
	for(int o=A[p]; o; o=C[o][1]){
		if(L[C[o][0]])continue;
		dfs(C[o][0]);
	}
}


void df(int u){
    if(flag) return ;
    vis[u]=true;
    for(int o=a[u];o;o=c[o][1]){
        if(flag) return ;
        int v=c[o][0];
        if(!L[v])continue;
        if(D[u]+c[o][2]<D[v]){
            D[v]=D[u]+c[o][2];
            if(vis[v]){
                flag=true;
                return;
            }else{
                df(v);
            }
        }
    }
    vis[u]=false;
}
 
int main()
{
	n=read(); m=read(); p=read();
	for(int i=1;i<=m;++i){
		u=read(); v=read(); w=read();
		c[++tot][0]=v; c[tot][1]=a[u]; a[u]=tot; c[tot][2]=p-w; 
		C[tot][0]=u; C[tot][1]=A[v]; A[v]=tot; 
	} 
	
	dfs(n);
	if(!L[1]){
		puts("-1");
		return 0;
	}
	
	df(1);
	if(flag){
		puts("-1");
		return 0;
	}
	
	for(int i=1;i<=n;++i)D[i]=1e9,vi[i]=0; D[1]=0;
	
	q[qn=1]=1;
	for(int q1=1;q1<=qn;++q1){
		u=q[q1]; vi[u]=0;
		for(int o=a[u]; o; o=c[o][1]){
			v=c[o][0];
			if(!L[v])continue;
			if(D[u]+c[o][2]<D[v]){
				D[v]=D[u]+c[o][2];
				if(!vi[v]){
					
					++cnt[v];
					if(cnt[v]>n){
						puts("-1");
						return 0;
					} 
					
					q[++qn]=v;
					vi[v]=1;
				}
			}
		}
	}
	printf("%lld\n",max(0ll,-D[n]));
}

Measured memory_bytes: 24960
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define forn(i,a,b) for(ll i=1;i<=b;++i)
#define forr(i,a,b) for(ll i=0;i<b;++i)
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define r0 return 0
#define mp make_pair
#define cf cout.flush()
int main()
{
   ios;
   long double t , x  ;
   cin >> t >> x;
   cout << setprecision(10);
   cout << t/x <<endl ; cf ; r0 ;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)

const ll INF = (1LL << 62) - 1;

void solve() {
	ll N;
	cin >> N;
	vector<ll> X(N);
	REP(i, N) cin >> X[i];

	ll P = accumulate(X.begin(), X.end(), 0) / N;

	ll ans = 0, ans2 = 0;
	REP(i, N) {
		ans += (X[i] - P) * (X[i] - P);
		ans2 += (X[i] - (P+1)) * (X[i] - (P+1));
	}

	cout << min(ans, ans2) << endl;

}

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

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b;
char op;

while(op!='?'){
    cin>>a>>op>>b;
    if(op=='+'){
        cout<<a+b<<endl;
    }
    else if(op=='-'){
        cout<<a-b<<endl;
    }
    else if(op=='*'){
        cout<<a*b<<endl;
    }
    else if(op=='/'){
        cout<<a/b<<endl;
    }
}
return 0;
}


Measured memory_bytes: 3100
from itertools import combinations

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

hs = []
for _ in range(N):
    hs.append(int(input()))

hs.sort()

R = 10 ** 9 
for i in range(N - K + 1):
    R = min(hs[i + K - 1] - hs[i], R)

print(R)


Measured memory_bytes: 7540
#coding: utf-8

n=gets.chomp.to_i
t=gets.chomp.split(" ")
i=0
ans=0
sum=0.0
while(i<n)
	sum+=t[i].to_i
	i+=1
end
sum/=n
if(sum-sum.to_i<0.5)
	sum=sum.to_i
else
	sum=sum.to_i+1
end
i=0
while(i<n)
	ans+=(t[i].to_i-sum)**2
	i+=1
end
puts(ans)


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int arr[3][3];
    for(int i=0;i<3;i++)
	for(int j=0;j<3;j++)
	    cin>>arr[i][j];
    int n;
    cin>>n;
    int vals[n];
    for(int i=0;i<n;i++)
    cin>>vals[i];
    sort(vals,vals+n);
    if(binary_search(vals,vals+n,arr[0][0]) && binary_search(vals,vals+n,arr[1][1]) 
	    && binary_search(vals,vals+n,arr[2][2]))
	    {cout<<"Yes";return 0;}
    if(binary_search(vals,vals+n,arr[0][2]) && binary_search(vals,vals+n,arr[1][1]) 
	    && binary_search(vals,vals+n,arr[2][0]))
	    {cout<<"Yes";return 0;}


    for(int i=0;i<3;i++)
    {
	if(binary_search(vals,vals+n,arr[i][0])
	    && binary_search(vals,vals+n,arr[i][1]) 
	    && binary_search(vals,vals+n,arr[i][2]))
	    {cout<<"Yes";return 0;}

	if(binary_search(vals,vals+n,arr[0][i])
	    && binary_search(vals,vals+n,arr[1][i]) 
	    && binary_search(vals,vals+n,arr[2][i]))
	    {cout<<"Yes";return 0;}
    }

    cout<<"No";
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()


int main() {

    int N;
    cin >> N;

    vi V(N);
    vi C(N);

    REP(i,N){
        cin >> V[i];
    }

    REP(i,N){
        cin >> C[i];
    }

    int sum = 0;
    REP(i,N){
        int tmp = V[i]-C[i];
        if(tmp>0)sum+=tmp;
    }

    cout << sum << endl;

    }



Measured memory_bytes: 256
#include<cstdio>
#define MAX 10000
#define NIL -1

struct Node {int parent, left, right; };

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u, int d){
	if(u==NIL) return;
	D[u]=d;
	setDepth(T[u].left, d+1);
	setDepth(T[u].right, d+1);
}

int setHeight(int u){
	int h1 = 0, h2 = 0;
	if(T[u].left != NIL)
		h1 = setHeight(T[u].left) + 1;
	if(T[u].right != NIL)
		h2 = setHeight(T[u].right) + 1;
	return H[u] = (h1>h2 ? h1:h2);
}


//節点uの兄弟を探す
int getSibling(int u){
	if(T[u].parent == NIL) return NIL;
	if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
	return T[T[u].parent].left;
	if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
	return T[T[u].parent].right;
	return NIL;
}

void print(int u){
	printf("node %d: ", u);
	printf("parent = %d, ", T[u].parent);
	printf("sibling = %d, ", getSibling(u));
	int deg = 0;
	if(T[u].left != NIL) deg++;
	if(T[u].right != NIL) deg++;
	printf("degree = %d, ", deg);
	printf("depth = %d, ", D[u]);
	printf("height = %d, ", H[u]);
	
	if(T[u].parent == NIL){
		printf("root\n");
	}else if (T[u].left == NIL && T[u].right == NIL){
		printf("leaf\n");
	}else{
		printf("internal node\n");
	}
}

int main(){
	int v, l, r, root = 0;
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++)T[i].parent = NIL;
	
	for(int i = 0; i < n; i++){
		scanf("%d %d %d", &v, &l, &r);
		T[v].left = l;
		T[v].right = r;
		if(l != NIL)T[l].parent = v;
		if(r != NIL)T[r].parent = v;
	}
	
	for(int i = 0; i < n; i++) if(T[i].parent == NIL)root = i;
	
	setDepth(root, 0);
	setHeight(root);
	
	for(int i = 0; i < n; i++) print(i);
	
	return 0;
}


Measured memory_bytes: 2764
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const LL MOD = 1e9 + 7;
const LL MAX = 4321;
LL F[MAX];
LL IF[MAX];

LL inverse(LL a, LL b){
    LL t = 1;
    while(b) {
        if(b & 1) t = (t * a) % MOD;
        a *= a;
        a %= MOD;
        b >>= 1;
    }
    return t % MOD;
}
 
void initialize(){
    F[0] = 1, IF[0] = 1;
    for(LL i = 1; i < MAX; i++){
        F[i] = (F[i - 1] * i) % MOD;
        IF[i] = inverse(F[i], MOD - 2) % MOD;
    }
}

LL combination(LL n, LL k){
    if(n < 0 || k < 0 || k > n) return 0;
    LL ret = F[n] * IF[k] % MOD * IF[n - k] % MOD;
    return ret;
}
 
int main() {
 
    LL N, K;
    scanf("%lld %lld", &N, &K);
    initialize();
    
    for(int i = 1; i <= K; i++){
        LL rp = i - 1;      
        LL rr = N - K - rp; 
        LL bp = i;          
        LL br = K - bp;     
        LL ans = combination(rr + bp, rr);
        ans %= MOD;
        
        ans *= combination(rp + br, br);
        ans %= MOD;
        
        
        printf("%lld\n", ans);
    }
    return 0;
 
}

Measured memory_bytes: 256