akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n,x;
  cin>>n>>x;
  int d=0;
  int ans=0;
  int l;
  if(d<=x){
    ans++;
  }
  REP(i,n){
    cin>>l;
    d += l;
    if(d<=x){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

#define ll long long

int main() {
	ll a, b, c, x, y, small;
	ll sum1, sum2, sum3;
	cin >> a >> b >> c >> x >> y;
	if (x > y) sum1 = c * 2 * y + (x - y) * a;
	else sum1 = c * 2 * x + (y - x) * b;
	sum2 = a * x + b * y;
	sum3 = c * 2 * max(x, y);
	cout << min(min(sum1, sum2), sum3) << endl;
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

const ll N_MAX = 202020;
struct RAQSB{
	ll N;
	ll sN;
	ll data[N_MAX];
	ll bucket[N_MAX];

	RAQSB(ll n){
		sN = (ll)sqrt(n) + 1;
		N = sN * sN;
		REP(i, N_MAX){
			data[i] = 0;
			bucket[i] = 0;
		}
	}

	void add(ll s, ll t, ll x){
		// add x to range [s, t)
		ll ss = s/sN;
		ll tt = t/sN;
		if(ss==tt){
			for(int i=s;i<t;i++){
				data[i] += x;
			}
		}else{
			for(int i=s;i<(ss+1)*sN;i++){
				data[i] += x;
			}
			for(int i=tt*sN;i<t;i++){
				data[i] += x;
			}
			for(int i=ss+1;i<tt;i++){
				bucket[i] += x;
			}
		}
	}

	ll get_val(ll i){
		return data[i] + bucket[i/sN];
	}
};

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

    ll n, m;
    cin >> n >> m;
    RAQSB rs(m+1);
    vector<ll> lens[m+1];
    vector<pll> miya;
    REP(i, n){
    	ll l, r;
    	cin >> l >> r;
    	miya.push_back({l, r});
    	lens[r-l+1].push_back(i);
    }

    ll nagai = n;
    for(int d=1;d<=m;d++){
    	ll res = 0;
    	res += nagai;
    	//dump(res)
    	for(int pos=0;pos<=m;pos+=d){
    		res += rs.get_val(pos);
    	}
    	cout << res << endl;
    	nagai -= lens[d].size();
    	REP(i, lens[d].size()){
    		ll idx = lens[d][i];
    		rs.add(miya[idx].first, miya[idx].second+1, 1);
    	}
    }
    return 0;
}

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

const int inf = 1000000;

signed main() {
  int n;
  cin >> n;
  int ans = inf;
  rep(i, n) {
    int w;
    cin >> w;
    rep(j, inf) {
      if(w % 2 == 1) {
	ans = min(ans, j);
	break;
      }
      w /= 2;
    }
  }
  cout << ans << endl;
}

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

S = input()
L = len(S)
K = L
for i in range(L-1):
    if S[i] != S[i+1]:
        K = min(K, max(i+1, L-i-1))
print(K)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair <int,int> PAIR;
const int N = 1e5 + 7;
const double pi = acos(-1);
const ll mod = 1e9 + 7;
const double eps = 1e-6;
const ll inf = 0x3f3f3f3f;

int main(){	
	ll n,d,ans = 0;
	cin >> n >> d;
	for(int i = 1; i <= n; i++){
		ll a,b;
		cin >> a >> b;
		if(a*a + b*b <= d*d)
			ans++;
	}
	cout << ans << endl;
    return 0;
}

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

namespace ConsoleApp36 {
    class Program {
        static void Main(string[] args) {
            string S = Console.ReadLine();

            string ans = "";

            for (int i = 0; i < S.Length; i++) {
                if (i == 3) {
                    ans += "8";
                } else {
                    ans += S[i];
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
class Solution:
    def solve(self, a, b):
        str1 = "".join([str(b) for _ in range(a)])
        str2 = "".join([str(a) for _ in range(b)])

        if str1 <= str2:
            return str1
        else:
            return str2


sol = Solution()

[a, b] = list(map(int, input().strip().split(" ")))

print(sol.solve(a, b))


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {        
    int n;
    cin >> n;
    vector<int> v(n + 1, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i + 1];
    }
    int res = 0;
    for (int i = 1; i <= n; i++) {
        if (v[i] == i) {
            if (i < n) {
                swap(v[i], v[i + 1]);
            } 
            res++;
        }
    }
    cout << res << endl;
}


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


const ll maxval = 1000000000;

void solve(long long N, long long K, long long S){
    ll v1, v2;
    if(S < maxval){
        v1 = S;
        v2 = S + 1;
    }else{
        v1 = S;
        v2 = 1;
    }
    for(ll i = 0; i < K; ++i){
        cout << v1;
        if(i < N - 1){ cout << ' '; }
    }
    for(ll i = K; i < N; ++i){
        cout << v2;
        if(i < N - 1){ cout << ' '; }
    }
    cout << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long S;
    scanf("%lld",&S);
    solve(N, K, S);
    return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<utility>
#include<queue>
using namespace std;

typedef pair<int,int> P;

int main(){
  int w,h;
  int xs,ys,xg,yg;
  int n;
  int c,d,x,y;
  int grid[101][101];
  bool visit[101][101];

  for(;;){
    cin >> w >> h;
    if(!w && !h)break;

    for(int i=1;i<=h;i++)
      for(int j=1;j<=w;j++){
	grid[i][j] = 0;
	visit[i][j] = false;
      }
    cin >> xs >> ys >> xg >> yg;

    cin >> n;
    for(int i=0;i<n;i++){
      cin >> c >> d >> x >> y;
      if(d){
	for(int j=0;j<4;j++)
	  for(int k=0;k<2;k++)grid[y+j][x+k] = c;
      }else{
	for(int j=0;j<2;j++)
	  for(int k=0;k<4;k++)grid[y+j][x+k] = c;
      }
    }

    int color = grid[ys][xs];    
    queue<P> q;
    if(color){
      q.push(P(ys,xs));
      visit[ys][xs] = true;
      while(q.size()){
	P p = q.front();q.pop();
	y = p.first;
	x = p.second;
	
	int dx[] = {0,1,0,-1},dy[] = {-1,0,1,0};
	for(int i=0;i<4;i++){
	  int sx = x+dx[i],sy = y+dy[i];
	  if(sx<=0 || sy<=0 || w<sx || h<sy)continue;
	  if(visit[sy][sx] || grid[sy][sx]!=color)continue;
	  q.push(P(sy,sx));
	  visit[sy][sx] = true;
	}
      }
      if(visit[yg][xg])cout << "OK\n";
      else cout << "NG\n";
    }else{
      cout << "NG\n";
    }
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h, n, a;
    cin >> h >> n;
    while(n--){
        cin >> a;
        h -= a;
    }
    if(h <= 0)  cout << "Yes" << '\n';
    else        cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    while (cin>>n) {
        if (n<=39) {
            if (n/10==0) {
                cout<<"3C"<<0<<n<<endl;
            } else {
                cout<<"3C"<<n<<endl;
            }
        } else {
            while(n>39){
                n=n-39;
            }
            if (n/10==0) {
                cout<<"3C"<<0<<n<<endl;
            } else {
                cout<<"3C"<<n<<endl;
            }
        }
    }
}



Measured memory_bytes: 3084
#include <iostream>
#include <string>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
using namespace std;

int main() {
  double a, b, C, S, L, h;
  cin >> a >> b >> C;
  h = b * sin(C * M_PI / 180);
  S = a * h / 2;
  L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(C * M_PI / 180));
  printf("%f\n", S);
  printf("%f\n", L);
  printf("%f\n", h);

  return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define MAX 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

typedef long long ll;

int main()
{
    FASTIO
   /* 
   double start_time = clock();
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
  #endif
    */
    int n;
    cin >> n;
    vector<int> H(n+10, 0);
    for(int i = 0; i < n; i++) cin >> H[i];

      vector<int> ans(n+5, INF);
    ans[0] = 0;
    for(int i = 0; i < n; i++){
      ans[i+1] = min(ans[i+1], ans[i] + abs(H[i+1] - H[i]));
      ans[i+2] = min(ans[i+2], ans[i] + abs(H[i+2] - H[i]));
    }
    cout << ans[n-1]<<endl;

     //double end_time = clock();
  //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
   
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
const ll INF=1e9;

main(){
  ll N,W;
  cin >> N >> W;
  ll w[N],v[N];
  for(ll ii=0;ii<N;ii++)cin >> w[ii] >> v[ii];
  ll dp[N+2][W+2];
  for(ll ii=0;ii<=N;ii++){
    for(ll jj=0;jj<=W;jj++){
      dp[ii][jj]=0;
    }
  }
  for(ll ii=0;ii<N;ii++){
    for(ll jj=0;jj<=W;jj++){
      if(jj>=w[ii])dp[ii+1][jj]=max(dp[ii][jj],dp[ii][jj-w[ii]]+v[ii]);
      else dp[ii+1][jj]=dp[ii][jj];
    }
  }
  cout << dp[N][W] << endl;
}


Measured memory_bytes: 79872
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstring>
using namespace std;
int main()
{
	char s[1000];
	int a,b,i,j;
	int ans=0;
	scanf("%d %d\n",&a,&b);
	scanf("%s",s);
	if(a+b+1!=strlen(s))
		goto z;
	if(s[a]!='-')
		goto z;
	for(i=a-1;i>=0;i--){
		if(s[i]>='0'&&s[i]<='9')
			continue;
		else
			break;
	}
	if(i==-1)
		ans++;
	for(j=a+1;j<a+b+1;j++){
		if(s[j]>='0'&&s[j]<='9')
			continue;
		else
			break;
	}
	if(j==a+b+1)
		ans++;
	if(ans==2)
		puts("Yes");
	else
		z:puts("No");
	return 0;
}

Measured memory_bytes: 256
package main

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

const mod = 998244353
const facNum = 300001
const INF = 10000000007

func main() {
	sc := newScanner(os.Stdin)
	N, M, K := sc.i(), sc.i(), sc.i()
	A := sc.is(N)
	B := sc.is(M)
	ac := make([]int, N+1)
	bc := make([]int, M+1)

	for i := 0; i < N; i++ {
		if i == 0 {
			ac[i+1] = A[i]
		} else {
			ac[i+1] = ac[i] + A[i]
		}
	}
	for i := 0; i < M; i++ {
		if i == 0 {
			bc[i+1] = B[i]
		} else {
			bc[i+1] = bc[i] + B[i]
		}
		//dp[i] = min(dp[i], bc[i])
	}
	ans := 0
	j := M
	for i := 0; i <= N; i++ {
		if ac[i] > K {
			break
		}
		k := K - ac[i]
		for bc[j] > k {
			j--
		}
		ans = max(ans, i+j)
	}
	fmt.Println(ans)
}

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

// fmt.Println("Yes")
// fmt.Println("No")

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

//------------------------------

//const factorial = new
func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

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

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	//while n != 0
	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

func abs(i int) int {
	if i < 0 {
		return -i
	}
	return i
}

// 階乗: factorial
// コンビネーションを計算する際に前もって計算しておく
// fac[k] => k! (mod M)
// ifac[k] => k!^(M-2) (mod M)
// n: ex. 2 * 10^5 => 200001
// fac, ifac := factorial()
func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}

// vs: sorted slice int value
func lowerBound(vs []int, v int) (index int) {
	n := len(vs) / 2
	m := len(vs)
	for m != n {
		if vs[n] < v {
			n = (m-n+1)/2 + n
			//m = m
		} else {
			m = n
			n = n / 2
		}
	}
	return n
}

func IntSlice(n, init int) []int {
	r := make([]int, n)
	for i := range r {
		r[i] = init
	}
	return r
}


Measured memory_bytes: 11144
import java.util.Scanner;



public class Main {

	static double EPS = 0.0000000001;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Segment seg  =new Segment(new Point(sc.nextInt(),sc.nextInt()),new Point(sc.nextInt(),sc.nextInt()));

		int q=sc.nextInt();
		for (int i=0;i<q;i++) {
			Point p = project(seg,new Point(sc.nextInt(),sc.nextInt()));
			System.out.println(p.x+" "+p.y);
		}
	}
	static Point project(Segment s, Point p) {
		Vector base = s.p2.diff(s.p1);
		double r = p.diff(s.p1).dotProduct(base) / base.norm();
		return s.p1.sum(base.mult(r));
	}
}
class Point {
	static double EPS = 0.0000000001;
	double x; double y;
	public Point(double ax, double ay){x=ax;y=ay;}
	public Vector sum(Point p) { return new Vector(x+p.x,y+p.y); }
	public Vector diff(Point p) { return new Vector(x-p.x,y-p.y); }
	public Vector mult(double k) { return new Vector(x*k,y*k); }
	public Vector div(double k) { return new Vector(x*(1.0/k),y*(1.0/k)); }
	public boolean equals(Point p){return Math.abs(x-p.x)<EPS && Math.abs(y-p.y)<EPS;}
}
class Vector extends Point {
	public Vector(double ax, double ay) {super(ax,ay);}
	public Vector(Point p1, Point p2) {super(p1.x-p2.x,p2.x-p2.y);}
	public double norm() {return x*x+y*y;}
	public double abs() {return Math.sqrt(norm());}
	// TODO:
	public boolean isSmallerThan(Vector v) {return x!=v.x?x<v.x:y<v.y;}
	public double dotProduct(Vector v) {return x*v.x+y*v.y;}
	public double crossProduct(Vector v) {return x*v.y - y*v.x;}
}

class Segment {
	Point p1; Point p2;
	public Segment(Point ap1, Point ap2){p1=ap1;p2=ap2;}
	public double dotProduct(Segment s) {return (p1.x-p2.x)*(s.p1.x-s.p2.x)+(p1.y-p2.y)*(s.p1.y-s.p2.y);}
	public double crossProduct(Segment s) {return (p1.x-p2.x)*(s.p1.y-s.p2.y) - (p1.y-p2.y)*(s.p1.x-s.p2.x);}
}

Measured memory_bytes: 34748
n = int(input())
ans = 1
A = list(map(int,input().split()))
A.sort()
if A[0] == 0:
    print(0)
    exit()
elif A[-1]*A[-2] > 10**18:
    print(-1)
    exit()
from collections import defaultdict
d = defaultdict(int)
for a in A:
    d[a] += 1
for k in d:
    ans *= k**d[k]
if ans > 10**18:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 21644
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

p=min(a,b,c,d,e)

if n%p==0:
    q=n//p
else:
    q=n//p+1

print(5+q-1)


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

int main() {
    string s;
    cin >> s;
    bool flag=true;
    for(int i=0; i<s.size(); i++) {
        if(i%2==0) {
            if(s.at(i) != 'h') {
                flag=false;
                break;
            }
        }
        else {
            if(s.at(i) != 'i') {
                flag=false;
                break;
            }
        }
    }
    if(s.size()%2==1) {
        flag=false;
    }

    if(flag) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
import itertools

N = int(input())
S = input()

RGB = {"R":[0]*N, "G":[0]*N, "B":[0]*N}
for i in range(N):
    if S[i] == "R":
        RGB["R"][i] = 1
    elif S[i] == "G":
        RGB["G"][i] = 1
    else:
        RGB["B"][i] = 1

for k in RGB.keys():
    RGB[k] = list(itertools.accumulate(RGB[k]))

ans = 0
for i in range(N-2):
    l_i = S[i]
    for j in range(i+1, N-1):
        l_j = S[j]
        d = {"R", "G", "B"}
        if l_i != l_j:
            d.remove(l_i)
            d.remove(l_j)
            l_k = d.pop()
            ans += RGB[l_k][N-1] - RGB[l_k][j]
            if j*2 - i <= N-1:
                if S[j*2 - i] == l_k:
                    ans -= 1

print(ans)




Measured memory_bytes: 74380
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, A, B = list(map(int, read().split()))

ans = 0
if A > B:
    pass
elif (N == 1):
    if (A != B):
        pass
    else:
        ans = 1
elif N == 2:
    ans = 1
else:
    ans = (B - A) * (N - 2) + 1

print(ans)


Measured memory_bytes: 3060
#include<algorithm>
#include<string.h>
#include<iostream>
#include<stdio.h>
using namespace std;

const int N=60;
int a[N];
int n;
long long sum;

int main(){
	cin>>n;
	
	for(int i=0; i<n; i++)
		cin>>a[i];
	
	for(int i=0; i<n; i++)
		for(int j=i+1; j<n; j++)
			sum+=a[i]*a[j];
	
	cout<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  int x, a, b;
  cin >> x >> a >> b;
  if(abs(x-a)<abs(x-b)){cout<<'A'<<endl;}
  else{cout<<'B'<<endl;}
 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;
int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> l(m),r(m);
    for(ll i=0;i<m;i++){
        cin>>l[i]>>r[i];
    }
    sort(l.begin(),l.end());
    sort(r.begin(),r.end());
    cout<<max((ll)0,r[0]-l.back()+1);
    return 0;
}

Measured memory_bytes: 1792
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n;
    cin >> n;
    P cnt_odd[SIZE], cnt_even[SIZE];
    for( int i = 0; i < SIZE; ++i ) {
        cnt_odd[i].F = cnt_even[i].F = 0;
        cnt_odd[i].S = cnt_even[i].S = i;

    }

    vector< int > odd, even;
    for( int i = 0; i < n; ++i ) {
        int v;
        cin >> v;
        if( i % 2 == 0 ) {
            odd.pb( v );
            cnt_odd[v].F++;

        } else {
            even.pb( v );
            cnt_even[v].F++;

        }
    }

    sort( cnt_odd, cnt_odd + SIZE, greater< P >() );
    sort( cnt_even, cnt_even + SIZE, greater< P >() );

    int res = 0;
    n /= 2;
    if( cnt_odd[0].S == cnt_even[0].S ) {

        res = min( n - cnt_odd[0].F + n - cnt_even[1].F,
                    n - cnt_odd[1].F + n - cnt_even[0].F );

    } else {
        res = n - cnt_odd[0].F + n - cnt_even[0].F;

    }
    cout << res << endl;
    return 0;
}



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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


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

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

vector<ll> a(200100), b(200100);
ll N, M, K;
ll bmax;

void solve()
{
  cin >> N >> M  >> K;
  rep(i, N) cin >> a[i];
  rep(i, M) cin >> b[i];
  bmax = 0;
  ll ai = 0, bi = 0;

  ll t = 0;
  for(ai = 0; ai < N && t + a[ai] <= K; ai++) t += a[ai];
  //cerr << ai << ":" << bi << ":" << t << endl;
  bmax = ai;
  while(ai >= 0) { 
    while(bi < M && t + b[bi] <= K) {
      t += b[bi];
      bi ++;
      chmax(bmax, ai + bi);
    }
    //cerr << ai << ":" << bi << ":" << t << endl;
    ai --;
    t -= a[ai];
  }
  
  
  cout << bmax << endl;

}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 6300
#include <bits/stdc++.h>
using namespace std;
int main(){
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	int n,minv=100000000;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=100;i++){
		int sum=0;
		for(int j=1;j<=n;j++){
			sum+=(a[j]-i)*(a[j]-i);
		}
		if(sum<minv){
			minv=sum;
		}
	}
	cout<<minv;

}


Measured memory_bytes: 256
#include<cstdio>
int a,b,c,t=0,n,ans,s;
int main()
{
    scanf("%d%d%d%d",&a,&b,&c,&n);
    for(;t<=a;t++)
    {
    	for(s=0;s<=b;s++)
    	{
      		if((n-t*500-s*100>=0)&&(n-t*500-s*100<=c*50))
      		{
			  	ans++;
			}
      	}
    }
    printf("%d",ans);
}

Measured memory_bytes: 128
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#define DEBUG 1
#define dd if (DEBUG)

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, A) for (auto & a : A)
#define all(a) (a).begin (), (a).end ()
#define rall(a) (a).rbegin (), (a).rend ()
#define sz(a) (int) (a).size ()
#define szl(a) (int) (a).length ()
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit);

typedef long long ll;
typedef pair <int, int> pii;
#define f first
#define s second
#define mp(a, b) make_pair((a), (b))
typedef vector <int> vi;
#define pb(a) push_back ((a))

const ll MOD = 1e+9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int INFi = 0x3f3f3f3f;
const ll MAXN = 1e+6+7;

int main ()
{
    FASTIO;
    int i, j, k, n;
    cin >> n;
    vector <vi> ac (n, vi (3)), dp (n, vi (3));
    trav (v, ac)
        trav (a, v)
            cin >> a;
    for (j = 0; j < 3; j++)
        dp[0][j] += ac[0][j];
    for (i = 1; i < n; i++)
    {
        for (j = 0; j < 3; j++)
        {
            for (k = 0; k < 3; k++)
            {
                if (j == k) continue;
                dp[i][j] = max (dp[i][j], dp[i - 1][k]);
            }
            dp[i][j] += ac[i][j];
        }
    }
    cout << max (max (dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]) << "\n";

    return 0;
}



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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

int gcd(int x, int y)
{
	return y ? gcd(y, x % y) : x;
}	

void hawawa()
{
	int a, b;
	cin >> a >> b;
	cout << max({ a + b, a - b, a * b }) << "\n";

}

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


Measured memory_bytes: 256
# include <iostream>
# include <string>
# include <algorithm>
# include <vector>
# include <cstring>
# include <stdio.h>
# include <map>
# include <queue>

# define ll long long
# define pii pair<int,int>
# define FOR(a,b) for(int a=1; a<=b; a++)
# define REP(a,b) for(int a=0; a<b; a++)
# define FORU(a,b,c) for(int a=b; a<=c; a++)
# define FORD(a,b,c) for(int a=b; a>=c; a--)

using namespace std;

int N, Q, p[100005], par[100005];

int findpar(int u){
  return u==par[u] ? u : par[u]=findpar(par[u]);
}

void merge(int u,int v){
  par[findpar(u)] = findpar(v);
}

bool isSameSet(int u,int v){
  return findpar(u) == findpar(v);
}

int main(){

  ios :: sync_with_stdio(false);
  cin >> N >> Q;
  FOR(i,N) cin >> p[i];
  FOR(i,N) par[i] = i;

  FOR(i,Q){
    int u, v;
    cin >> u >> v;
    merge(u,v);
  }

  int ans = 0;
  FOR(i,N){
    ans += isSameSet(p[i], i);
  }

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef long double ld;
const ld pi = 4*atan((ld)1);
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll nax = 0;

ll n, ans[10005];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	for(ll i = 1; i <= 100; i++){
		for(ll j = 1; j <= 100; j++){
			for(ll k = 1; k <= 100; k++){
				ll ii = i * i;
				ll jj = j * j;
				ll kk = k * k;
				ll ij = i * j;
				ll ik = i * k;
				ll jk = j * k;
				ll ret = ii + jj + kk + ij + jk + ik;
				if(ret > 10000){
					break;
				}
				ans[ret]++;
			}
		}
	}
	cin >> n;
	for(ll i = 1; i <= n; i++){
		cout << ans[i] << '\n';
	}
}



Measured memory_bytes: 3716
#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 h, w;
  cin >> h >> w;
  vector<vector<int>> c(10, vector<int>(10));
  rep(i, 10) rep(j, 10) cin >> c.at(i).at(j);
  vector<vector<int>> a(h, vector<int>(w));
  rep(i, h) rep(j, w) cin >> a.at(i).at(j);
  // ワーシャルフロイド法で各数字間のコスト(魔力)を計算
  for (int k = 0; k < 10; k++) {
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        c.at(i).at(j) = min(c.at(i).at(j), c.at(i).at(k) + c.at(k).at(j));
      }
    }
  }
  // 計算したコストから置き換えに必要な値を計算
  int res = 0;
  rep(i, h) rep(j, w) {
      int aa = a.at(i).at(j);
      if (aa == -1) {
        continue;
      }
      res += c.at(aa).at(1);
    }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3792
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cstring>
#include <cassert>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif


#ifdef L_JUDGE
#pragma warning(disable:4996)
#endif

using namespace std;

template <typename T>
inline bool read(T& ret) {
    T x = 0, f = 1; char ch = getchar();
    while(ch!=EOF && (ch > '9' || ch < '0')) { if(ch == '-') f = -1; ch = getchar();  }
    if(EOF==ch)return false;
    do x = x * 10 + ch - 48, ch = getchar(); while(ch >= '0' && ch <= '9');
    ret = x * f;
    return true;
}


inline char nc() {
    static char buf[100000], *p1 = buf, *p2 = buf;
    return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++;
}
template <typename T>
bool rn(T& v) {
    static char ch;
    while (ch != EOF && !isdigit(ch)) ch = nc();
    if (ch == EOF) return false;
    for (v = 0; isdigit(ch); ch = nc())
        v = v * 10 + ch - '0';
    return true;
}

template <typename T>
void o(T p) {
    static int stk[70], tp;
    if (p == 0) { putchar('0'); return; }
    if (p < 0) { p = -p; putchar('-'); }
    while (p) stk[++tp] = p % 10, p /= 10;
    while (tp) putchar(stk[tp--] + '0');
}


LL bin(LL x, LL n, LL MOD) {
    LL ret = MOD != 1;
    for (x %= MOD; n; n >>= 1, x = x * x % MOD)
        if (n & 1) ret = ret * x % MOD;
    return ret;
}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }



void Solve(){
}


int main(){
#ifdef L_JUDGE
    freopen("in1.txt","r",stdin);
    //		freopen("out.txt","w",stdout);
#endif
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    long long X,K,D;
    while(cin>>X>>K>>D){
        if(X>=0){
            long long mod=X%D;
            long long mul=X/D;
            if(K<=mul){
                cout<<abs(X-K*D)<<endl;
            }else{
                X=mod;
                K-=mul;
                if(K&1){
                    X-=D;
                }
                cout<<abs(X)<<endl;
            }
        }else{
            long long mod=X%D;
            long long mul=X/D*-1;
            if(K<=mul){
                cout<<abs(X+K*D)<<endl;
            }else{
                X=mod;
                K-=mul;
                if(K&1){
                    X+=D;
                }
                cout<<abs(X)<<endl;
            }
        }
    }
    return 0;

#ifdef L_JUDGE
    fclose(stdin);
    fclose(stdout);
    //		system("out.txt");
#endif

	return 0;
}


Measured memory_bytes: 3184
import Data.List
main=print.solve=<<getLine
solve s=minimum$map(f s)$map head.group.sort$s
f s c=g 0 s where
  g i s=if all(==c)s then i else g(i+1)$(zipWith h=<<tail)s
  h c1 c2=if c1==c || c2==c then c else c1

Measured memory_bytes: 4832
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const string END = "6174";

bool isNG(string s){
  REP(i, s.length()) if(s[0] != s[i]) return false;
  return true;
}

int make_L(string N){
  SORT(N);
  REVERSE(N);
  int ret = 0;
  REP(i, N.length()){
    ret *= 10;
    ret += (N[i] - '0');
  }
  return ret;
}

int make_S(string N){
  SORT(N);
  int ret = 0;
  REP(i, N.length()){
    ret *= 10;
    ret += (N[i] - '0');
  }
  return ret;
}

int main() {
  string N;
  while(cin >>N && N != "0000"){
    int cnt = 0;
    if(isNG(N)){
      cout <<"NA" <<endl;
      continue;
    }
    while(N != END){
    //REP(i, 10){
      int L = make_L(N);
      int S = make_S(N);
      //cout <<L <<", " <<S <<endl;
      stringstream ss; ss << (L - S);
      string s = ss.str();
      while(s.length() < 4) s = "0" + s;
      //cout <<s <<endl;
      N = s;
      ++cnt;
    }
    cout <<cnt <<endl;
  }
  return 0; }

Measured memory_bytes: 1232
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
int main(){
  ll n,ans=0;
  cin>>n;
  ll all_min=174417441744;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    if(all_min>a) ans++;
    all_min=min(all_min,a);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;

int main(void){
    ll k;
    cin>>k;
    string s;
    cin>>s;
    if(s.size()<=k)cout<<s<<endl;
    else {
        rep(i,k)cout<<s[i];
        cout<<"..."<<endl;
    }
    
    
}

Measured memory_bytes: 3592
N,K = (gets).split(" ").map {|v| v.to_i}
baggeges = []
pp = 0

N.times do
    bg = (gets).to_i
    baggeges << bg
    pp += bg
end
baggeges << 0

up_p = pp
dw_p = baggeges.max
check_list = []
ans = 0
while  true  do
    cur_p = (up_p + dw_p).div(2)
    if  check_list.include?(cur_p)  then
        if  check_list.include?(cur_p+1)  then
            break
        else
            cur_p += 1
        end
    end
    #puts "\n--[#{cur_p}]---------"
    check_list << cur_p
    trk = 0
    trk_num = 0
    can_load = true
    baggeges.each do |bag|
        t = trk + bag
        if  t > cur_p   then
            trk_num += 1
            trk = bag
            if  trk_num == K  then
                can_load = false
                #print "#{bag} "
                break
            end
            #puts ""
        else
            trk = t
        end
        #print "#{bag} "
    end
    if  can_load  then
        up_p = cur_p
        ans = cur_p
    else
        dw_p = cur_p
    end
end

puts ans



Measured memory_bytes: 7780
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		int s,h,m;
		Scanner scan = new Scanner(System.in);

	    s= Integer.parseInt(scan.next());
	    h=s/3600;
	    s=s%3600;
	    m=s/60;
	    s=s%60;
	    
	    System.out.println(h+":"+m+":"+s);

	}

}

Measured memory_bytes: 26204
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
----
local A = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"}
local N = read.n()

local ans = {}
local build = {}
local function dfs_cps(i, mx, cont)
    if i == N then
        table.insert(ans, table.concat(build))
        return cont()
    else
        local function make_cont(j, lim)
            return function()
                if j <= lim then
                    build[i+1] = A[j]
                    return dfs_cps(i+1, math.max(j,mx), make_cont(j+1,lim))
                else
                    return cont()
                end
            end
        end
        make_cont(1, mx+1)()
    end
end
dfs_cps(0, 0, function()
    for i=1,#ans do
        print(ans[i])
    end
end)

Measured memory_bytes: 45756
#include <bits/stdc++.h>
#define N 100001
using namespace std;
typedef pair<int,int> P;
vector<int> G[N];
vector<P> ans;
int cnt[N],dep[N];

void dfs(int pos,int pre){
  for(int i=0;i<G[pos].size();i++){
    int nx=G[pos][i];
    if(nx==pre||dep[nx]>dep[pos]) continue;

    if(dep[nx]!=-1&&dep[nx]<dep[pos])cnt[nx]--,cnt[pos]++;
    else{ 
      dep[nx]=dep[pos]+1;
      dfs(nx,pos);
      if(cnt[nx]==0) ans.push_back(P(min(pos,nx),max(pos,nx)));
      cnt[pos]+=cnt[nx];
    } 
  }
}


int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0,a,b;i<m;i++){
    cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  memset(dep,-1,sizeof(dep));
  dep[0]=0;
  dfs(0,-1);
  sort(ans.begin(),ans.end());
  for(int i=0;i<ans.size();i++)cout <<ans[i].first<<" "<<ans[i].second<<endl;

  return 0;
}

Measured memory_bytes: 7568
N, K = map(int, input().split())
A = list(map(int, input().split()))

ng = 0
ok = max(A)

while ok - ng > 1:
    cnt = 0
    l = (ok + ng) // 2
    for a in A:
        cnt += (a // l) + (a % l != 0) - 1

    if cnt <= K:
        ok = l
    else:
        ng = l
print(ok)

Measured memory_bytes: 103756
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
	int a;
	cin >> a;
	cout << a + (a * a) + (a * a * a);
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define SORT(x) (sort(x.begin(),x.end()))
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    char A[107],B[107];
    cin >> A >> B;
    strcat(A,B);
    int y=stoi(A);
    cout << ((int)sqrt(y)*(int)sqrt(y)==y ? "Yes" : "No") <<endl;
}

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


int main(){
	int X;cin>>X;
	int ans = 1;
	for(int i=2;i<=X;i++){
		int curr = i;
		for(int j=2;j<=20;j++){
			curr *= i;
			if(curr <= X) ans = max(curr,ans);
			else break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;
inline int Get() {
	char ch;
	while ((ch = getchar()) < '0' || ch > '9');
	int Num = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')
		Num = (Num << 3) + (Num << 1) + ch - '0';
	return Num;
}
const int N = 1e5 + 5;
int n, a[N * 3];
int main() {
	n = Get();
	for (int i = 1; i <= n * 3; ++i) a[i] = Get();
	std :: sort(a + 1, a + n * 3 + 1);
	
	ll ans = 0;
	for (int i = 1; i <= n; ++i) ans += a[n + i * 2 - 1];
	printf("%lld\n", ans);
}

Measured memory_bytes: 1280
#include <cstdio>
#include <iostream>
#include <string>
#include <queue>
#define INF (1<<21)
using namespace std;

class Point{
public:
  int c,i,j;
};

int main(){
  while(1){
    int i,j,n,a[100][2],ans;
    bool f[100][2];
    queue <Point> Q;
    Point u,v,u2;
    cin >> n;
    if(n == 0) break;

    for(i=0;i<n;i++){
      cin >> a[i][0];
      f[i][0] = false;
    }
    for(i=0;i<n;i++){
      cin >> a[i][1];
      f[i][1] = false;
    }
    ans = INF;

    if(a[0][0] == 1){
      for(i=0;i<n;i++){
	if(a[i][0] != 1) break;
      }
    }
    else i = 1;

    u.i = i - 1;
    u.j = 0;
    u.c = 0;
    f[u.i][0] = true;
    
    if(a[0][1] == 1){
      for(i=0;i<n;i++){
	if(a[i][1] != 1){
	  break;
	}
      }
    }
    else i = 1;

	u2.i = i - 1;
	u2.j = 1;
	u2.c = 0;
	f[u2.i][1] = true;

    Q.push(u);
    Q.push(u2);
    while(!Q.empty()){
      u = Q.front();
      Q.pop();

      if(u.i == n - 1){
	ans = u.c;
	break;
      }
    
      for(i=1;i<=2;i++){
	if(u.i + i >= n) continue;

	v = u;
	v.i += i;
	v.j = (v.j + 1) % 2;
	v.c++;

	if(a[v.i][v.j] == 0 && !f[v.i][v.j]){
	  f[v.i][v.j] = true;
	  Q.push(v);
	}

	else if(a[v.i][v.j] == 1){
	  for(j=v.i;j<n;j++){
	    if(a[j][v.j] != 1) break;
	  }
	  v.i = j - 1;
	  if(!f[v.i][v.j]){
	    f[v.i][v.j] = true;
	    Q.push(v);
	  }
	}

	else if(a[v.i][v.j] == 2){
	  for(j=v.i;j>0;j--){
	    if(a[j][v.j] != 2) break;
	  }
	  v.i = j;
	  if(!f[v.i][v.j]){
	    f[v.i][v.j] = true;
	    Q.push(v);
	  }
	}

      }
    }
    if(ans == INF) cout << "NA" << endl;
    else cout << ans << endl;

  }
  return 0;
}

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

using namespace std;
typedef long long ll;

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

ll max(ll a, ll b) {return a < b ? b : a; }

int main() {
  string S;
  
  cin >> S;
  
  for(int i=0; i<S.size(); ++i) {
    S[i] = 'x';
  }
  
  cout << S << endl;
  
  return 0;
}

Measured memory_bytes: 256
r,g,b,n=gets.split.map(&:to_i)
k = 0
3001.times do |ri|
    3001.times do |gi|
        break if  (n - (r*ri) - (g*gi)) < 0
        if (n - (r*ri) - (g*gi)) % b == 0 
            #p n - (r*ri) - (g*gi)
            k += 1 
        end
    end
end

p k

Measured memory_bytes: 1788
def main():
    N = int(input())
    S = [int(_) for _ in input().split()]
    Q = int(input())
    T = [int(_) for _ in input().split()]

    ans = 0

    for t in T:
        for s in S:
            if s == t:
                ans += 1
                break

    print(ans)

main()



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


using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  srand((unsigned)time(NULL));
  int d;
  int res = 0;
  cin >> d;
  vector<int> c(26);
  rep(i,26)cin >> c[i];
  vector<vector<int>> v(d,vector<int>(26));
  vector<int> contest(d,0);
  vector<int> last(26,0);
  vector<int> satisfy(26,0);
  rep(i,d)rep(j,26){
    int x;cin >> x;
    v[i][j] = x;
  }
  for(int i = 1;i <= d;i++){
    rep(j,26)if(v[i-1][contest[i-1]] < v[i-1][j])contest[i-1] = j;
    last[contest[i-1]] = i;
    res += v[i-1][contest[i-1]];
    rep(j,26)res -= c[j]*(i-last[j]),satisfy[j] += c[j]*(i-last[j]);
  }
  while(1.0*clock()/CLOCKS_PER_SEC <= 1.7){
    //int now_time = clock();
    //if(1.0*now_time/CLOCKS_PER_SEC > 1.7)break;
    int day = rand()%d,pos = rand()%26;
    vector<int> new_contest = contest;
    int res_ = res;
    int pre = new_contest[day];
    res_ += satisfy[pos];
    res_ += satisfy[pre];
    res_ -= v[day][pre];
    res_ += v[day][pos];
    int pos_satisfy = 0,pre_satisfy = 0;
    last[pos] = last[pre] = 0;
    new_contest[day] = pos;
    for(int i = 1;i <= d;i++)last[pos] = (new_contest[i-1] == pos ? last[pos] = i : last[pos]),pos_satisfy += c[pos]*(i-last[pos]);
    for(int i = 1;i <= d;i++)last[pre] = (new_contest[i-1] == pre ? last[pre] = i : last[pre]),pre_satisfy += c[pre]*(i-last[pre]);
    res_ -= (satisfy[pos]+satisfy[pre]);
    if(res < res_){
      res = res_;
      contest = new_contest;
      satisfy[pre] = pre_satisfy;
      satisfy[pos] = pos_satisfy;
    }
  }
  rep(i,d)cout << contest[i]+1 << endl;
  


  return 0;
}


Measured memory_bytes: 3684