akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b) % 24 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <stdbool.h>

typedef double db;
typedef int in;
typedef long int li;
typedef long long int lli;
typedef long ld;
typedef long lld;

#define pi M_PI
#define in scanf
#define out printf
#define inf INT_MAX
#define rep(i,n) for(int i=0;i<n;++i)
#define debugd(d) printf("%d\n",d)
#define debugs(s) printf("%s\n",s)
#define debugc(c) printf("%c\n",c)
#define debugf(f) printf("%f\n",f)


int main (void)
{
  char s[100010];
  gets(s);
  int alp[26];
  int i;
  for(i=0;i<26;++i){
    alp[i]=0;
  }
  
  for(i=0;i<strlen(s);++i)
  {
    alp[s[i]-'a']=1;
  }
  for(i=0;i<26;++i)
  {
    if(alp[i]==0){
      printf("%c\n",i+'a');
      return 0;
    }   
  }
  puts("None");
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val N = sc.nextInt
    if (N != 0) {
      val A = Array.fill(N)(sc.nextInt)
      var flag = true
      var ans = 0
      while (flag) {
        flag = false
        for (i <- Range(0, N - 1)) {
          if (A(i) > A(i + 1)) {
            val tmp = A(i)
            A(i) = A(i + 1)
            A(i + 1) = tmp
            flag = true
            ans += 1
          }
        }
      }
      println(ans)
      solve(sc)
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}




Measured memory_bytes: 47244
#include<bits/stdc++.h>
const int MN=2000+5;
const int P=1000000007;
using namespace std;
typedef long long ll;
template<typename T>inline T&IN(T&in){
	in=0;char c=getchar();int f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))in=in*10+c-'0',c=getchar();
	return in*=f;
}
int n,m;
int inv[MN*MN],fac[MN*MN],f[MN][MN];
int qp(int a,int b){int c=1;for(;b;b>>=1,a=(ll)a*a%P)if(b&1)c=(ll)c*a%P;return c;}
int C(int n,int m){return (ll)fac[n]*inv[m]%P*inv[n-m]%P;}
void input(){
	IN(n),IN(m);f[0][0]=fac[0]=1;
	if(m==1)return puts("1"),void();
	for(int i=1;i<=MN*MN-1;++i)fac[i]=(ll)fac[i-1]*i%P;
	inv[MN*MN-1]=qp(fac[MN*MN-1],P-2);
	for(int i=MN*MN-1;i>=1;--i)inv[i-1]=(ll)inv[i]*i%P;
	for(int i=1;i<=n;++i){
		f[i][0]=(ll)f[i-1][0]*C(i*m-i-1,m-2)%P;
		for(int j=1;j<=i;++j){
			f[i][j]=((ll)f[i][j-1]+(ll)f[i-1][j]*C(i*m+j-i-1,m-2)%P)%P;
		}
	}
	printf("%lld\n",(ll)f[n][n]*fac[n]%P);
}
int main(){
	input();
	return 0;
}


Measured memory_bytes: 46592
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        //Solve();
        WriteLine(Solve());
    }
    static string Solve()
    {
        var num = Input.numL;
        var ar = Input.arL;
        var sum = ar.Sum();
        if (sum % (num * (num + 1) / 2) != 0)
            return "NO";
        sum /= num * (num + 1) / 2;
        for(var i = 0; i < num; i++)
        {
            var dif = ar[(i + 1) % num] - ar[i];
            dif -= sum;
            if (dif > 0 || dif % num != 0) return "NO";
        }
        return "YES";
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 19040
#https://atcoder.jp/contests/abc122/submissions/14662859
#上のURLを参照にした。何回やっても時間制限かかるから。

#はじめから最後まで回す
#l,rまですべてのACの数をpushする。最後にlまでの合計からrまでの合計を引く。
n, q = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp.split("")
s = s.unshift(" ")
arr = Array.new(n+1,0)
i = 2
ans = 0
while true
    if s[i] == "C" && s[i-1] == "A"
        arr[i] = ans + 1
    else
        arr[i] = ans
    end
    if i == n
        break
    end
    ans = arr[i]
    i += 1
end
#p arr
q.times do
    l, r = gets.chomp.split(" ").map(&:to_i)
    all = arr[r] - arr[l]
    # if s[l] == "C" && s[l-1] == "A"
    #     all -= 1
    # end
    puts [all,0].max
end


Measured memory_bytes: 23624
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
#include <math.h>
#include <numeric>
#include <stack>
using namespace std;

const int M_MAX = 100001;
int N, M, X[M_MAX];
int d[M_MAX];
int ans = 0;

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) cin >> X[i];
	if (N<M){
	sort(X, X + M);
	for (int i = 1; i < M; i++) d[i] = X[i] - X[i - 1];
	sort(d + 1, d + M);
	for (int i = 1; i < M - N+1; i++) ans += d[i];
	cout << ans << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 1024
def c_strange_bank(N):
    # 100,000 以下の6または9の冪乗(10万円より多く引き出す必要はない)
    money_withdraw = [1, 6, 9, 36, 81, 216,
                      729, 1296, 6561, 7776, 46656, 59049]
    # dp[k]はk円引き出すために必要な最小の操作回数
    dp = [float('inf') for _ in range(N + 1)]
    dp[0] = 0  # 0円引き出すために必要な回数は0
    for k in range(1, N + 1):
        for money in money_withdraw:
            if money > k:
                continue
            else:
                # k円引き出すために必要な最小回数を更新するとしたら、
                # k-money円から追加でmoney円を(1回)引き出したときの回数である
                dp[k] = min(dp[k - money] + 1, dp[k])
    ans = dp[-1]
    return ans

N = int(input())
print(c_strange_bank(N))

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

int main(){
    string s;
    cin >> s;
    int n, k;
    cin >> k;
    n = s.size();

    for(int i = 0;i < n;i++){
        if(s[i] != 'a'){
            if(26-(s[i]-'a') <= k){
                k -= 26-(s[i]-'a');
                s[i] = 'a';
            }
        }
    }

    if(k > 0){
        s[n-1] = (k+s[n-1]-'a')%26 + 'a';
    }

    cout << s << endl;

    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <cstdint>

using namespace std;

using u32 = uint32_t;

int main(void)
{
  u32 n, x;
  cin >> n >> x;

  uint64_t c = 0;

  vector<u32> a(n);
  vector<u32> s(n + 1);
  for(auto& x : a) cin >> x;
  for(int i = 0; i < n; i++) s[i + 1] = a[i] + a[i + 1];
  s[0] = s[n] = 0;

  for(int i = 1; i < n; i++){
    if(s[i] <= x) continue;

    u32 r = a[i] < s[i] - x ? a[i] : s[i] - x;
    u32 l = s[i] - r > x ? s[i] - r - x : 0;

    a[i] -= r;
    a[i - 1] -= l;
    c += l + r;

    s[i + 1] -= r;
  }

  cout << c << endl;

  return 0;
}

Measured memory_bytes: 1024
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	colors := map[int]int{}
	for i := 0; i < N; i++ {
		colors[checkColor(nextInt())]++
	}
	var min, max int
	if _, exist := colors[9]; exist {
		if len(colors) > 1 {
			max = len(colors) + colors[9] - 1
			min = len(colors) - 1
		} else {
			max = colors[9]
			min = 1
		}
	} else {
		max = len(colors)
		min = max
	}
	fmt.Println(min, max)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func checkColor(a int) int {
	colornum := 0
	switch {
	case a < 400:
		colornum = 1
	case 400 <= a && a < 800:
		colornum = 2
	case 800 <= a && a < 1200:
		colornum = 3
	case 1200 <= a && a < 1600:
		colornum = 4
	case 1600 <= a && a < 2000:
		colornum = 5
	case 2000 <= a && a < 2400:
		colornum = 6
	case 2400 <= a && a < 2800:
		colornum = 7
	case 2800 <= a && a < 3200:
		colornum = 8
	case 3200 <= a:
		colornum = 9
	}
	return colornum
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,a;
    cin>>h>>a;
    int c=0;
    while(1)
    {
        h=h-a;
        c++;
        if(h<=0)
        {
            break;
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int cnt=0;
		for(int i=A;i<=B;i++) {
			if(i/10000==i%10 && (i%10000)/1000==(i%100)/10)cnt++;
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <string>
using namespace std;
string s1,s2;
int prev1[5000][5000];
int dp[5000][5000];
void backtrack(int,int);
bool succeed = false;
int main()
{
    ios::sync_with_stdio(false);
    cin>>s1>>s2;
    int n1 = s1.length();
    int n2 = s2.length();
    s1.insert(0,"0");
    s2.insert(0,"0");
    for(int i = 1; i <= n1; i++)
    {
        for(int j = 1; j <= n2; j++)
        {
            if(s1[i]==s2[j])
            {
                dp[i][j] = dp[i-1][j-1]+1;
                prev1[i][j] = 0;
            }
            else
            {

                if(dp[i][j-1]>dp[i-1][j])
                {
                    dp[i][j] = dp[i][j-1];
                    prev1[i][j] = 2;

                }
                else
                {
                    dp[i][j] = dp[i-1][j];
                    prev1[i][j] = 1;
                }
            }
            //cout <<"( "<<i<<", "<<j<<" )"<<endl;
            //cout << dp[i][j]<<endl;
        }
    }
   // cout << dp[n1-1][n2-1]<<endl;
    backtrack(n1,n2);
    if(succeed)cout <<"\n";
}
void backtrack(int x,int y)
{
    if(x==0||y==0)return;
    if(prev1[x][y]==0)
    {
        backtrack(x-1,y-1);
        succeed = true;
        cout << s1[x];
    }
    else if(prev1[x][y] == 1)backtrack(x-1,y);
    else backtrack(x,y-1);

}



Measured memory_bytes: 120832
n = int(input())
p = list(map(int, input().split()))
mini = p[0]
flag = 0
cnt = 1
for i in range(1, len(p)):
  if(flag == 1):
    if(mini >= p[i]):
      mini = p[i]
      cnt += 1
  if(flag == 0):
    if(p[i-1] >= p[i]):
      mini = p[i]
      cnt += 1
    else:
      flag = 1

print(cnt)

Measured memory_bytes: 25716
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int> S(N,-1);
  for(int i=0;i<M;i++){
    int s,c;
    cin>>s>>c;
    if(S[s-1]==-1)
      S[s-1]=c;
    else if(S[s-1]!=-1 && S[s-1]==c)
      ;
    else{
      cout<<-1<<endl;
      return(0);
    }
  }
  if(N==3){
    if(S[0]==0){
      cout<<-1<<endl;
      return(0);
    }      
    else if(S[0]==-1)
      S[0]=1;
    if(S[1]==-1)
      S[1]=0;
    if(S[2]==-1)
      S[2]=0;
  }
  if(N==2){
    if(S[0]==0){
      cout<<-1<<endl;
      return(0);
    }
    else if(S[0]==-1)
      S[0]=1;
    if(S[1]==-1)
      S[1]=0;
  }
  if(N==1){
    if(S[0]==-1)
      S[0]=0;
  }
  for(int i=0;i<N;i++)
    cout<<S[i];
  cout<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(cin.hasNext()){
			double v = cin.nextDouble();
			int i=1;
			while(true){
				double t = Math.sqrt((5*i-5)/4.9);
				if(9.8*t >= v){
					System.out.println(i);
					break;
				}
				i++;
			}
		}
	}

}

Measured memory_bytes: 12000
<?php
$s = str();
$flag = false;
for($i = 0; $i < 3; $i++){
    if($s[$i] == 7)$flag = true;
}
echo $flag ? "Yes":"No";
function str(){return trim(fgets(STDIN));}
function ints(){return array_map('intval',explode(' ',trim(fgets(STDIN))));}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}

function dfs($current, $from = -1, $d = 0){
  global $G, $distance;
  $distance[$current] = $d;
  foreach($G[$current] as $to){
    if($from != $to){
      dfs($to, $current, $d + 1);
    }
  }
}

function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$N = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      $G[$a][] = $b;
      if($both)$G[$b][] = $a;
    }else{
      list($a, $b, $d) = $values;
      $G[$a][] = [$b, $d];
      if($both)$G[$b][] = [$a, $d];
    }
  }
  return $G;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int H, W, K;
    cin >> H >> W >> K;

    vector<string> S(H);
    rep(i, H) cin >> S[i];

    int ans = INF;
    rep(bit, 1 << (H - 1)) {
        int res = __builtin_popcount(bit);

        vector<int> line;
        line.push_back(0);
        rep(i, H - 1) {
            if (bit >> i & 1) line.push_back(i + 1);
        }
        line.push_back(H);

        vector<vector<int>> nS(res+1, vector<int>(W));
        rep(i, line.size() - 1) {
            rep(j, W) {
                int cnt = 0;
                for (int k = line[i]; k < line[i+1]; ++k) {
                    cnt += S[k][j] - '0';
                }
                nS[i][j] = cnt;
            }
        }

        bool NG = false;
        for (auto &i : nS) {
            for (auto &j : i) {
                if (K < j) NG = true;
            }
        }
        if (NG) continue;

        vector<int> sum(line.size() - 1);
        rep(i, W) {
            bool flg = false;
            rep(j, line.size() - 1) {
                sum[j] += nS[j][i];
                if (K < sum[j]) flg = true;
            }
            if (flg) {
                res++;
                rep(j, line.size() - 1) sum[j] = nS[j][i];
            }
        }

        ans = min(ans, res);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    int n;cin >> n;
    n%=10;
    if(n==3){
        cout << "bon" << endl;
    }
    else if(n==0 || n == 1 || n == 6 || n == 8){
        cout << "pon" << endl;
    }
    else{
        cout << "hon" << endl;
    }
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int solve(int, int, int);
int a[20];

int main(){
  int n, q, i, res, j = 0;
  int m[200];

  scanf("%d", &n);
  for(i = 0; i < n; i++)
    scanf("%d", &a[i]);

  scanf("%d", &q);
  for(i = 0; i < q; i++)
    scanf("%d", &m[i]);

  for(i = 0; i < q; i++){
    res = solve(j, m[i], n);

    if(res == 1)
      printf("yes\n");
    else if(res == 0)
      printf("no\n");
  }

  return 0;

}

int solve(int i, int m, int n){
  int re;

  if(m == 0)
    return 1;
  if(i >= n)
    return 0;

  re = solve(i+1, m, n) || solve(i+1, m - a[i], n);
  return re;
}

Measured memory_bytes: 580
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/*
const ll MOD = (ll)1e9 + 7;
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
*/

const int N = 100100;
ll a[N];
ll b[N];
ll c[N];
ll d[N];
ll ans = 0;
int n;
ll C;

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

	scanf("%d%lld", &n, &C);
	for (int i = 0; i < n; i++) {
		scanf("%lld%lld", &a[i], &b[i]);
	}
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		sum += b[i];
		ans = max(ans, sum - a[i]);
		c[i] = sum - 2 * a[i];
	}
	sum = 0;
	for (int i = n - 1; i >= 0; i--) {
		sum += b[i];
		ans = max(ans, sum - (C - a[i]));
		d[i] = sum - 2 * (C - a[i]);
	}
	for (int i = 1; i < n; i++)
		c[i] = max(c[i], c[i - 1]);
	for (int i = n - 2; i >= 0; i--)
		d[i] = max(d[i], d[i + 1]);

	sum = 0;
	for (int i = 0; i < n - 1; i++) {
		sum += b[i];
		ans = max(ans, sum - a[i] + d[i + 1]);
	}
	sum = 0;
	for (int i = n - 1; i > 0; i--) {
		sum += b[i];
		ans = max(ans, sum - (C - a[i]) + c[i - 1]);
	}
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

//繰り返し二乗法
ll EX(ll x,ll n){
    if(n == 0)return 1;
    else if(n%2 == 1)return EX(x,n-1)*x;
    else return EX(x*x,n/2);
};

vector<int> ac(ll n,int k){
    vector<int> res;
    while(n > 0){
        if(n%26 == 0){
            res.push_back(26);
            n = (n-1)/26;
        }
        else{
            res.push_back(n%26);
            n /= 26;
        }
    }
    return res;
}

int main(){
    ll n;
    cin >> n;
    vector<int> num = ac(n,26);
    for(int i = num.size()-1; i >= 0; i--){
        cout << (char)('a'+num[i]-1);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3624
use std::cmp::min;
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (d, g): (usize, usize) = parse!(it, 2);
    let mut p = vec![];
    let mut c = vec![];
    for _ in 0..d {
        let (pi, ci): (usize, usize) = parse!(it, 2);
        p.push(pi);
        c.push(ci);
    }
    let iscore = |i| (i + 1) * 100;
    let mut ret = std::usize::MAX / 10;
    'outer: for i in 0..(1 << d) {
        let mut reti = 0;
        let mut score = 0;
        for j in 0..d {
            if (i >> j) & 1 == 1 {
                score += c[j];
                score += iscore(j) * p[j];
                reti += p[j];
            }
        }
        if score >= g {
            ret = min(ret, reti);
            continue;
        }
        for j in (0..d).rev() {
            if (i >> j) & 1 == 0 {
                let remain = g - score;
                let cj = remain / iscore(j) + if remain % iscore(j) != 0 { 1 } else { 0 };
                let cj = min(cj, p[j] - 1);
                reti += cj;
                score += cj * iscore(j);
                if score >= g {
                    ret = min(ret, reti);
                    continue 'outer;
                }
            }
        }
    }
    println!("{}", ret);
}

fn test() {
    let mut f = fs::File::open("foo.txt").unwrap();
    let mut s = String::new();
    f.read_to_string(&mut s).unwrap();
    solve(&s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_main() {
        test();
    }
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(void) {
	int N;
	cin >> N;
	int num, i, cnt = 0;
	for (i=0; i<N; i++) {
		cin >> num;
		if ((i+1)%2 == 1 && num%2 == 1)
			cnt++;
	}
	cout << cnt;
	
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define mem(ar,value) memset(ar,value,sizeof(ar))
#define all(x) x.begin(),x.end()
#define len(s) (int)s.size()
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))
#define mod 1e9+7
#define limit 200005
#define READ freopen("input.txt","r",stdin)
#define WRITE freopen("output.txt","w",stdout)
#define d1(x) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<endl;
#define d2(x,y) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<endl;
#define d3(x,y,z) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<" | "#z" = "<<z;
#define GG {printf("-1"); return 0;}
#define inf 1e9*2
#define y1 asdas
#define ll long long
#define writesize(a) printf("%d\n",len(a));
#define writeall(a) for(int i=0;i<len(a);i++) printf("%d ",a[i]);
int n,ar[limit],t=1,d[limit],mx,mn=1,k=1;
pair<int,int> ans[limit];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&ar[i]);
	}
	mx=n;
	for(int i=n;i>=1;i--,k++)
	{
		d[i]=t;
		if(k%2) mn++;
		else mx--;
		if(k%2) t=mx;
		else t=mn; 
	}
	for(int i=1;i<=n;i++)
	{
		ans[i]=mp(d[i],ar[i]);
	}
	sort(ans+1,ans+n+1);
	for(int i=1;i<=n;i++)
	{
		printf("%d ",ans[i].sc);
	}
}



Measured memory_bytes: 5248
import sys
readline = sys.stdin.buffer.readline

INF = 10**18+3
N, T = map(int, readline().split())

AB = [tuple(map(int, readline().split())) for _ in range(N)]
ABzero = [b for a, b in AB if a == 0]
ABnonzero = [(a, b) for a, b in AB if a]
ABnonzero.sort(key = lambda x: (x[1]+1)/x[0])


dp = [0]
for a, b in ABnonzero:
    dp2 = dp + [INF]
    for j in range(1, len(dp2)):
        dp2[j] = min(dp2[j], (dp[j-1]+1)*(a+1)+b)
    dp = [d for d in dp2 if d <= T]

ABzero.sort()
dpzero = [0] + [b+1 for b in ABzero]
for i in range(1, len(dpzero)):
    dpzero[i] += dpzero[i-1]

DP = [INF]*(N+1)
for i in range(len(dp)):
    for j in range(len(dpzero)):
        DP[i+j] = min(DP[i+j], dp[i] + dpzero[j])

DP = [d for d in DP if d <= T]
print(max(0, len(DP)-1))


Measured memory_bytes: 91136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<30;

int main(){
    
    int N;cin>>N;
    vector<int> A(N),id(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    iota(all(id),0);
    sort(all(id),[&](int i,int j){
        return A[i]<A[j];
    });
    
    for(int i=0;i<N;i++){
        cout<<id[i]+1<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define maxn 200100
using namespace std;
struct edge{
	int r,nxt;
}e[maxn<<1];
int d[maxn],head[maxn],esz,n,dp[maxn];
void addedge(int u,int v){
	e[++esz].r=v;e[esz].nxt=head[u];head[u]=esz;
	e[++esz].r=u;e[esz].nxt=head[v];head[v]=esz;
}
void dfs(int u,int f){
	for(int t=head[u];t;t=e[t].nxt)if(e[t].r!=f)dfs(e[t].r,u);
	int ans1=0,ans2=1;
	for(int t=head[u];t;t=e[t].nxt)if(e[t].r!=f){
		ans1+=dp[e[t].r];
		for(int t2=head[e[t].r];t2;t2=e[t2].nxt)if(e[t2].r!=u)ans2+=dp[e[t2].r];
	}
	dp[u]=max(ans1,ans2);
}
int main(){
	scanf("%d",&n);
	for(int i=2,u,v;i<=n;++i)
		scanf("%d%d",&u,&v),addedge(u,v);
	dfs(1,0),printf(dp[1]<=n/2?"Second":"First");
}

Measured memory_bytes: 3072
import java.io.*;
import java.math.*;
import java.util.*;

public class Main
{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		int count = 0;
		for (int i=0; i<n; i++)
		{
		    int x = in.nextInt();
		    int y = in.nextInt();
		    double dist = Math.sqrt(Math.pow(x,2)+Math.pow(y,2));
		    if (dist<=k)
		    {
		        count++;
		    }
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 59372
//BROWNIE TK

#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define acc(v) accumulate(all(v), 0)
#define F first
#define S second

#define forz(i, n) for (int i = 0; i < n; i++)
#define fore(i, m, n) for (int i = m; i <= n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rforzm(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define gcd __gcd
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetlli tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order
using namespace std;

/*STD fucntions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        //y must be even now
        y = y >> 1; //y=y/2
        x = (x * x) % p;
    }
    return res;
}
lli modi(lli a, lli m)
{
    // fermat little thm where m is prime
    return power(a, m - 2, m);
}
/*CODE BEGINS*/
int main()
{
    kira;
    lli n;
    cin>>n;
    ldb x[n],y[n];
    forz(i,n)
    {
      cin>>x[i]>>y[i];
    }
    vector<lli>v;
    forz(i,n)v.pb(i);
    ldb s=0;
    lli fac[n+1];
    fac[0]=1;
    for(int i=1;i<=n;i++)
    {
      fac[i]=fac[i-1]*i;
    }
    lli k=fac[n];
    while(k)
    {
      forz(i,n-1)
      {
        s+=sqrt((x[v[i]]-x[v[i+1]])*(x[v[i]]-x[v[i+1]])+(y[v[i]]-y[v[i+1]])*(y[v[i]]-y[v[i+1]]));
      }
      next_permutation(all(v));
      k--;
    }
    s=s/ldb(fac[n]);
    cout<<deci(10)<<s;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod =  1000000007;
//const ll maxn = 1000000000;
// const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
  ll n,d,ans=0;
  cin>>n>>d;
  vvll x(n,vll(d));
  rep(i,n){
      rep(j,d)cin>>x.at(i).at(j);
  }
  rep(i,n-1){
      for(int j=i+1;j<n;j++){
          ll squre=0;
          rep(k,d){
              squre +=(x.at(i).at(k)-x.at(j).at(k))*(x.at(i).at(k)-x.at(j).at(k));
          }
          int find_squre=pow(squre,0.5);
          if(squre==find_squre*find_squre)ans++;
          //cout<<squre<<endl;
      }
  }
  cout<<ans<<endl;
  
}
   



Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    double bapri,topri,baca,toca[101];
    int N;
    cin>>N>>bapri>>topri>>baca;
    for(int i=0;i<N;i++)cin>>toca[i];
    sort(toca,toca+N);
    double sumpri=bapri,sumca=baca;
    for(int i=N-1;0<=i;i--){
        if(sumca/sumpri<toca[i]/topri)sumca+=toca[i],sumpri+=topri;
        else break;
    }
    printf("%d\n",(int)(sumca/sumpri));
    return 0;
}

Measured memory_bytes: 1224
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
  
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
   
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
   
typedef pair<int, int> pii;
typedef long long ll;
   
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
   
signed main() {
    int N; cin >> N;
    int H, A, D, S; cin >> H >> A >> D >> S;
  
    vector< tuple<int, int, int, int> > enemies;
    for(int i=0; i<N; i++) {
        int h, a, d, s; cin >> h >> a >> d >> s;
  
        // 主人公が攻撃しても意味ない
        if(A - d <= 0) {
            // 敵がつよい
            if(a - D > 0) {
                cout << -1 << endl;
                return 0;
            }
            // 戦闘不能判定に関係ないからいらなさそう
            else {
                continue;
            }
        }
        // 敵が攻撃しても意味ない
        if(a - D <= 0) {
            continue;
        }
          
        enemies.emplace_back(h, a, d, s);
    }
  
    sort(enemies.begin(), enemies.end(), [&](auto x, auto y) {
            int xh, xa, xd, xs; tie(xh, xa, xd, xs) = x;
            int yh, ya, yd, ys; tie(yh, ya, yd, ys) = y;
  
            // 何ターンで死ぬか
            int xdam = A - xd; int xturn = (xh + xdam - 1) / xdam;
            int ydam = A - yd; int yturn = (yh + ydam - 1) / ydam;
  
            // 敵の攻撃はいくつ？
            int xinj = xa - D, yinj = ya - D;
  
            // 何回攻撃するか (x -> y)
            int xatkl = (xs > S ? xturn : xturn - 1);
            int yatkl = (ys > S ? xturn + yturn : xturn + yturn - 1);
  
            // 何回攻撃するか (y -> x)
            int yatkr = (ys > S ? yturn : yturn - 1);
            int xatkr = (xs > S ? xturn + yturn : xturn + yturn - 1);
  
            int suml = xinj * xatkl + yinj * yatkl;
            int sumr = xinj * xatkr + yinj * yatkr;
            return suml < sumr;
        });
  
    int turn_sum = 0, mi = 0;
    for(auto e : enemies) {
        int h, a, d, s; tie(h, a, d, s) = e;
        int dam = A - d, turn = (h + dam - 1) / dam;
        int inj = a - D;
  
        // fprintf(stderr, "dam = %lld, turn = %lld, inj = %lld\n", dam, turn, inj);
        turn_sum += turn;
        int atk = (s > S ? turn_sum : turn_sum - 1);
  
        mi += atk * inj;
        if(mi >= H) {
            cout << -1 << endl;
            return 0;
        }
    }
  
    if(mi >= H) cout << -1 << endl;
    else cout << mi << endl;
    return 0;
}


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find algo with array
// Find()
int findpar(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
// Union()
void Union(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}

// Main Code
int ans = 0;
int n, m;
void dfs3(int curr, int stat)
{
  if(stat == ((1<<n)-1))
  {
    ans++;
    return;
  }
  for(int x: g[curr])
  {
    if((stat & (1<<x)) == 0)
      dfs3(x, stat | (1<<x));
  }
}
int main()
{

  cin>>n>>m;
  while(m--)
  {
    int a, b;
    cin>>a>>b;
    a--;
    b--;
    g[a].pb(b);
    g[b].pb(a);
  }
  dfs3(0, 1);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 12160
fun main(args: Array<String>) {
    val answers = mutableSetOf<Int>(81)
    for (i in 1 until 10) for (j in 1 until 10){
        answers.add(i * j)
    }
    if(readLine()!!.toInt() in answers){
        println("Yes")
    }
    else
    {
        println("No")
    }
}

Measured memory_bytes: 35620
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lld double
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define vc vector
#define rep1(it,v) for(it=v.begin();it!=v.end();it++)
#define ayush ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define input(v) for(auto &it:v)cin>>it
#define inf 100000000007
#define pb push_back

ll v1[100005][3]; ll dp[100005][3];

ll fun(ll n1, ll k1)
{
    if(n1==0) return 0; if(k1==-1) k1=2; if(k1==3) k1=0;
    if(dp[n1-1][k1]!=-1) return dp[n1-1][k1];
    else 
    {
        return dp[n1-1][k1]=v1[n1-1][k1]+max(fun(n1-1,k1-1),fun(n1-1,k1+1));
    }
    
}

int main()
{
    ll n; cin>>n; 
    rep(i,0,n-1) cin>>v1[i][0]>>v1[i][1]>>v1[i][2];
    memset(dp,-1,sizeof(dp)); ll ans1=fun(n,0); 
    memset(dp,-1,sizeof(dp)); ll ans2=fun(n,1); 
    memset(dp,-1,sizeof(dp)); ll ans3=fun(n,2); 
    cout<<max(ans1,max(ans2,ans3));
}




Measured memory_bytes: 14508
#include<stdio.h>

 int main(){
 int a,b,i;
 char s;
 
  for(i=0;i<1000;i++){

 scanf("%d %c %d",&a,&s,&b); 

 if(s == '+')printf("%d\n",a + b);
 if(s == '-')printf("%d\n",a - b);
 if(s == '*')printf("%d\n",a * b);
 if(s == '/')printf("%d\n",a / b);
 if(s == '?')break;
}

 return 0;

}





Measured memory_bytes: 2052
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>

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

using namespace std;

int main() {
	
	int n,m;
	cin >> n;
	vector<int>T(n);
	rep(i, 0, n)cin >> T[i];
	cin >> m;
	vector<int>P(m);
	vector<int>X(m);
	rep(i, 0, m) {
		cin >> P[i]>>X[i];
	}


	
	rep(i, 0, m) {
		int sum = 0;


		rep(j, 0, n) {
			if (P[i]-1 == j) {
				sum += X[i];
			}
			else
			{
				sum += T[j];
			}


		}
		cout << sum << endl;

	}




	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
*/#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
/*namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
*/#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#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(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> N;
  M=sqrt(N);
  rep(i,1,M+1)if(N/i==N%i)sum+=i;
  if(N==M*M)M--;
  rep(i,1,M+1)if(N%i==0&&N/i-1>M)sum+=N/i-1;
  Out(sum);
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int mod  = 1e9+7;
int main() {
	// your code goes here
	
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n;
	cin>>n;
	
	vector<vector<int>>comp(n,vector<int>(n));
	
	for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	cin>>comp[i][j];
	
	vector<long long>dp((1<<n));
	dp[0]=1;
	for(int i=0;i<(1<<n);i++)
	{
		int m = __builtin_popcount(i);
		for(int w=0;w<n;w++)
		{
			if((i&(1<<w))==0 && comp[m][w]==1)
			{
				int j = (i|(1<<w));
				dp[j] = (dp[j]+dp[i]%mod)%mod;
			}
		}
	}
	
	long long res = dp[(1<<n)-1]%mod;
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 19556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl

ll dp[401][401],a[401],n,sum[401];
ll culc(ll x ,ll y){
	if(dp[x][y]!=INF)return dp[x][y];
	FOR(i,x,y){
		dp[x][y] = min( dp[x][y] , culc(x,i)+culc(i+1,y));
	}
	dp[x][y] += sum[y]-sum[x-1];
	return dp[x][y];
}


int main(){
	cin >> n;
	FOR(i,1,n+1)cin >> a[i];
	FOR(i,1,n+1){
		sum[i] = sum[i-1] + a[i];
		FOR(j,1,n+1){
			if(j==i)continue;
			dp[i][j]=INF;
		}
	}
	cout << culc(1,n) << endl;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n;cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    ll mi=inf;
    REP(i,-100,101){
        ll sum=0;
        rep(j,n){
            sum+=(a[j]-i)*(a[j]-i);
        }
        mi=min(sum,mi);
    }
    cout<<mi<<endl;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

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

    vector<int> ans;
    int lim=1;
    while(lim*(lim+1)/2 < n) ++lim;

    // printf("lim %d\n", lim);
    for(int i=lim; i>=1; --i)
    {
        if(n-i>=0)
        {
            printf("%d\n", i);
            n-=i;
        }
    }
    return 0;
}


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

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

const ll MAX_N = 1e5 + 5, inf = 1000000LL * 1000000LL * 1000000LL;
ll n, p;
string s1, s2, s;
string type[MAX_N];

void t1 (int l, int r);

void t2 (int l, int r) {
	// cout << "T2 " << l << " " << r << "\n";
	cout << (r + l) / 2 - 1 << endl;
	cin >> s;

	type[(r + l) / 2] = s;
	if (type[(r + l) / 2] == "Vacant")
		return ;
	
	if (((r - l + 1) / 2 + 1) % 2) {
		if (type[(r + l) / 2] != type[l])
			t2(l, (r + l) / 2);
		else
			t2((r + l) / 2, r);
	}
	else {
		if (type[(r + l) / 2] == type[l])
			t1(l, (r + l) / 2);
		else
			t1((r + l) / 2, r);
	}
}



int main() {
//	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	
	cout << 0 << endl;
	cin >> s1;

	cout << (n + 1) / 2 - 1 << endl;
	cin >> s2;

	type[1] = s1;
	type[(n + 1) / 2] = s2;

	if (s1 == "Vacant" || s2 == "Vacant")
		return 0;
	
	if (((n + 1) / 2) % 2) {
		if (s1 != s2)
			t2(1, (n + 1) / 2);
		else
			t1((n + 1) / 2, n + 1);
	}
	else {
		if (s1 == s2)
			t1(1, (n + 1) / 2);
		else
			t2((n + 1) / 2, n + 1);
	}
	return 0;
}

void t1 (int l, int r) {
	// cout << "T1 " << r - l + 1 << " " << l << " " << r << "\n";
	cout << (l + r) / 2 - 1 << endl;
	cin >> s;
	
	type[(l + r) / 2] = s;
	if (type[(l + r) / 2] == "Vacant")
		return ;
	
	if (((r - l + 1) / 2) % 2) {
		if (type[(l + r) / 2] != type[l])
			t2(l, (l + r) / 2);
		
		else
			t1((l + r) / 2, r);
	}
	else {
		if (type[(l + r) / 2] == type[l])
			t1(l, (l + r) / 2);
		else
			t2((l + r) / 2, r);
	}
}


Measured memory_bytes: 1620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
    int n, m, x, y;
    scanf("%d%d%d%d", &n, &m, &x, &y);
    rep(i, n)
    {
        int xi;
        cin >> xi;
        x = max(x, xi);
    }
    rep(i, m)
    {
        int yi;
        cin >> yi;
        y = min(y, yi);
    }

    for (int z = -100; z <= 100; ++z)
    {
        if (x < z && z <= y)
        {
            printf("No War\n");
            return 0;
        }
    }
    printf("War\n");
    return 0;
}

Measured memory_bytes: 3664