akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}


int main(){
    ll n,a=INF;
    cin >> n;
    for (ll i=0;i<5;i++){
        ll b;
        cin >> b;
        a=min(a,b);
    }
    if (n%a){
        n=n/a+1;
    }else{
        n=n/a;
    }
    
    cout << n+4 << endl;
    return 0;
}


Measured memory_bytes: 384
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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


int main(){
    int N,i;
    cin >> N >> i;
        
    cout << (N-i+1) << endl;

    

    /* 
      vector<int> vec(10,5);
      for(auto itr = vec.begin(); itr != vec.end(); ++itr){
          std::cout << *itr << "\n";        
          
      }
      
      int aiueo = 1000;
      a = aiueo;
     */
   
}





Measured memory_bytes: 256
n,m = map(int, input().split())
lst = [[] for i in range(n)]
for i in range(n):
    a,b = map(int, input().split())
    lst[i] = (a,b)
lst.sort()

ans = 0
for i in range(n):
    if lst[i][1]<m:
        ans += lst[i][0]*lst[i][1]
        m -=lst[i][1]
    else:
        ans += lst[i][0]*m
        print(ans)
        exit()


Measured memory_bytes: 16992
#include<stdio.h>
#define N 101
  
main(){
   
  int M[N][N];
  int n,m,k,l,i,j;
    
  scanf("%d",&n);
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      M[i][j]=0;
    }
  } 
      
  for(i=0;i<n;i++){
    scanf("%d%d",&m,&k);    
    for(j=0;j<k;j++){
      scanf("%d",&l);
      M[m][l]=1;      
    }
  }
      
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j==n){
    if(M[i][j]!=0) printf("1");
    else printf("0");
    break;    
      }
      
      if(M[i][j]!=0) printf("1 ");
      else printf("0 ");   
    }
    printf("\n");
 
  }
  return 0;
}

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

ll dp[100+10][100000+10];
ll arr[100+10][2];
int n,w;

ll solve (int i,int  j)
{
    if(i>=n)
	{
		return 0;
	}	
	if(dp[i][j]!=-1)return dp[i][j];
	
	ll a=INT_MIN,b=INT_MIN;
	a=solve(i+1,j);
	
	if(j+arr[i][0]<=w)
	{
		b=max(b,solve(i+1,j+arr[i][0]))+arr[i][1];
	}
	
	return dp[i][j]=max(a,b);
}


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>w;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++)
    {
    	cin>>arr[i][0]>>arr[i][1];
	}
	
	cout<<solve(0,0)<<endl;
    

	return 0;
	
}

Measured memory_bytes: 86272
-- extension section
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE BangPatterns      #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}
-- not supported extension
--{-# LANGUAGE Strict, StrictData #-}


module Main where

-- @@@@@@@@@@@@@@@@@--
-- import section   --
-- @@@@@@@@@@@@@@@@@--
--    import A.B.C( function name )  ...
-- or import A.B.C 

--
import Prelude hiding(
  getLine,
  getContents,
  lines,
  words
  )

-- standard library
import Control.Monad.ST


-- bytestring


-- containers


-- deepseq


-- regex-posix


-- text
import Data.Text.Lazy.IO as TIO
import Data.Text.Lazy as T
import Data.Text.Lazy.Read as TR

-- import Data.Text.IO as TIO
-- import Data.Text as T
-- import Data.Text.Read as TR



-- unordered-containers


-- vectors
import Data.Vector.Unboxed as UV
import Data.Vector.Unboxed.Mutable as MV


-- mtl


-- @@@@@@@@@@@@@@@@@--
-- main section     --
-- @@@@@@@@@@@@@@@@@--

main :: IO ()
main = do
  input <- getInput
  Prelude.putStr . show . getAnswer $ input 

-- main :: IO()
-- main = do
--   answer <- getInputandanser
--   putStr . show $ answer


-- @@@@@@@@@@@@@@@@@@@@@--
-- I/O DataType section --
-- @@@@@@@@@@@@@@@@@@@@@--
data Input = I (Int,[Int])
  deriving(Show)

type Answer = Int



-- @@@@@@@@@@@@@@@@@--
-- answerSection    --
-- @@@@@@@@@@@@@@@@@--
getInput :: IO Input
getInput = do
  Right (n, _) <- getLine >>= ( return . TR.decimal )
  numTexts <- getLine >>= ( return . (fmap textToInt) .words) 
  return (I (n, numTexts) )
  where 
    textToInt t = case TR.decimal t of
      Right (n , _) -> n


getAnswer :: Input -> Answer 
getAnswer ( I (_ , nums) ) = occur
  where go n ind (x:l@(x':l'@(x'':xs))) 
          | ind == x && (ind+1) == x' = go (n+1) (ind+2) l'
          | ind == x = go (n+1) (ind+1) l
          | (ind+1) == x' && (ind+2) == x''  = go (n + 1) (ind+3) xs
          | otherwise = go n (ind + 1) l
        go n ind (x:x':xs) | ind == x && (ind+1) == x' = go (n+1) (ind+2) xs
                           | ind == x = go (n+1) (ind+1) (x':xs)
                           | otherwise = go n (ind+1) (x':xs)
        go n ind (x:xs)  | ind == x = go (n+1) (ind+1) xs
                         | otherwise = go n (ind + 1) xs
        go n _ [] = n
        occur = go 0 1 nums 

getInputAndAnser :: IO Answer
getInputAndAnser = undefined


-- @@@@@@@@@@@@@@@@@@@@@@@@@@--
-- question unique section    --
-- @@@@@@@@@@@@@@@@@@@@@@@@@@--





-- @@@@@@@@@@@@@@@@@--
-- util section     --
-- @@@@@@@@@@@@@@@@@--

-- standard Input Function
gLine :: IO Text
gLine = getLine

gContents :: IO Text
gContents = getContents



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

class Dice {
    public:
	int f[7];
	Dice() {}
	void roll_x() { roll(1, 4, 6, 3); } // to E
	void roll_y() { roll(1, 2, 6, 5); } // to N
	void roll_z() { roll(2, 3, 5, 4); } // 上から見て時計回り
	void roll(int i, int j, int k, int l) {
		int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
	}
};

bool judge(Dice c1, Dice c2) {
	for (int i = 1; i <= 6; i++) {
		if (c1.f[i] != c2.f[i]) return false;
	}
	return true;
}

bool getRight(Dice c1, Dice c2) {
	for (int i = 0; i < 6; i++) {
		for (int j = 0; j < 4; j++) {
			if (judge(c1, c2)) return true;
			c1.roll_z();
		}
		if (i % 2 == 0) c1.roll_x();
		else c1.roll_y();
	}
	return false;
}

int main() {
	Dice c1,c2;

	for (int i = 1; i <= 6; i++) cin >> c1.f[i];
	for (int i = 1; i <= 6; i++) cin >> c2.f[i];

	if(getRight(c1,c2)) cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
}



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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int x=0;
  int ans =0;
  
  for(int i=0; i<N; i++){
    if(S.at(i)=='I')x++;
    else x--;
    
    if(x>ans)ans=x;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
using namespace std;
int main() {
  unsigned long long n, k;
  cin >> n >> k;
  vector<pair<unsigned long long, unsigned long long>> p(n);
  for(int i = 0; i < n; i++) cin >> p[i].first >> p[i].second;
  unsigned long long ans = 0, ans2 = 0;
  for(int i = 0; i < n; i++) if((~k & p[i].first) == 0) ans += p[i].second;
  int id = 0;
  unsigned long long kk = k;
  for(int i = 0; kk > 0; i++) {
    id = i;
    kk /= 2;
  }
  for(int i = 1; i <= id; i++) {
    if((k & (1 << i)) == 0) continue;
    unsigned long long kf = (k ^ (1 << i)) | ((1 << i) - 1);
    ans2 = 0;
    for(int j = 0; j < n; j++) if((~kf & p[j].first) == 0) ans2 += p[j].second;
    ans = max(ans, ans2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF =ll(1e9)+5;

int main() {
    ll N,A,B;
    cin >> N >>A>>B;
    vector<ll> h(N);
    for(int i=0;i<N;i++){
        cin >> h[i];
    }
    ll l=0;
    ll r = INF;
    ll C= A-B;
    while(l+1<r){
        ll mid = (l+r)/2;
        ll temp =0;
        for(int i=0;i<N;i++){
            temp += max(0ll,(h[i]-B*mid +C-1)/C);
        }
        if(temp<=mid){
            r = mid;
        }else{
            l = mid;
        }
    }
    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3960
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a;i<(ll)b;i--)
#define Fi first
#define Se second
typedef pair<ll, ll> pll;
const ll MAX = 1000000;
const char ENDL = '\n';


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

	ll Ans = 0, N, sub = 0;
	cin >> N;
	vector<ll> a(N);

	rep(i, N)
		cin >> a[i];
	sort(a.begin(), a.end());

	bool flag = true;
	ll n = 0;
	rep(i, N) {
		if (a[i] >= 3200) {
			flag = false;
			sub++;
		}

		else if (a[i] >= n){
			Ans++;
			while (a[i]>=n)
				n += 400;
		}
	}
	sub += Ans;

	if (Ans == 0)
		cout << 1 << " ";
	else
		cout << Ans << " ";

	if (flag == true)
		cout << Ans << ENDL;
	else
		cout << sub << ENDL;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include <numeric>
#include<vector>

#define LL long long
#define MOD 1000000007

using namespace std;

LL gcd(LL C, LL D) {
	if (C < D) gcd(D, C);

	if (C%D == 0)return D;
	else gcd(D, C%D);
}


int main() {

	int a, b, c;
	cin >> a >> b >> c;

	if (a == b && b == c) {
		cout << "No" << endl;
		return 0;
	}

	if (a == b) {
		cout << "Yes" << endl;
		return 0;
	}
	else if (a == c) {
		cout << "Yes" << endl;
		return 0;
	}
	else if (b == c) {
		cout << "Yes" << endl;
		return 0;
	}
	
	cout << "No" << endl;

	return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <queue>
#include <deque>
#include <vector>
#define maxc 100010
#define inf 0x3f3f3f3f
#define ll long long
using namespace std;
int main(){
   int n;
   char a[200];
   cin>>n;
   for(int i=0;i<n;i++)
        cin>>a[i];
   int sum=0,sum1=0;
   int b[50];
   for(int i=1;i<=26;i++)
        b[i]=0;
   for(int i=1;i<n;i++){
        sum1=0;
        for(int k=0;k<i;k++){
            b[a[k]-96]=1;
        }
        for(int j=i;j<n;j++){
            if(b[a[j]-96]==1){
                sum1++;
                b[a[j]-96]=0;
            }
        }
        if(sum<sum1)
            sum=sum1;
   }
   cout<<sum<<endl;
   return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

a,b = I()
print(max(a+b,a-b,a*b))

Measured memory_bytes: 10008
<?php
# 入力部
fscanf(STDIN, "%d", $k);
fscanf(STDIN, "%d %d", $a, $b);
// $s1 = fgets(STDIN); //"\n"の2文字
// $s2 = fgets(STDIN);
// fscanf(STDIN, "%d", $n);
// fscanf(STDIN, "%s", $s);
// fscanf(STDIN, "%s", $s2);

# 処理部
// $arr1 = str_split($s1);
// $arr2 = str_split($s2);
// $arr1 = explode(" ", $s1);
// $arr2 = explode(" ", $s2);
// for ($i = 0; $n > $x * $i; $i++) {
// }
// if (strpos($s, 'RRR') !== false) {
//   $r = 3;
// } elseif (strpos($s, 'RR') !== false) {
//   $r = 2;
// } elseif (strpos($s, 'R') !== false) {
//   $r = 1;
// } else {
//   $r = 0;
// }
// $s = "No";
// if ($x >= 30) {
//   $s = "Yes";
// }
// for ($i = 0; $i * 1000 < $n; $i++) {
// }
// $c = "a";
// if (ctype_upper($a)) {
//   $c = "A";
// }
// $s = "Yes";
// echo count($arr1);
// for ($i = 0; $i < strlen($s1); $i++) {
//   if ($arr1[$i] != $arr2[$i]) {
//     $s = "No";
//   }
// }
// $unit;
// switch ($n % 10) {
//   case 0:
//   case 1:
//   case 6:
//   case 8:
//     $unit = "pon";
//     break;
//   case 3:
//     $unit = "bon";
//     break;
//   default:
//     $unit = "hon";
//     break;
// }
// if ($s == "ABC") {
//   $r = "ARC";
// } else {
//   $r = "ABC";
// }
$r = "NG";
for ($i = $a; $i <= $b; $i++) {
  if ($i % $k == 0) {
    $r = "OK";
  }
}

# 出力部
echo $r . "\n";
// echo ($i * 1000) - $n . "\n";

Measured memory_bytes: 16224
#include<bits/stdc++.h>
using namespace std;
long long dp[101][100001],v[101],w[101];
int main()
{
    int n,W;
    cin>>n>>W;
    for(int i=0;i<n;i++)
        cin>>w[i]>>v[i];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=W;j++)
        {
            if(w[i]>j)
                dp[i+1][j]=dp[i][j];
            else
                dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
        }
    }
    cout<<dp[n][W]<<endl;
    return 0;
}


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


int main()
{

string s,t;
cin>>s>>t;
if(s.size()!=t.size()){ cout<<"No"<<endl; return 0;}
int n=t.size();
for(int i=0;i<s.size();i++)
{
    string tmp=t.substr(i)+t.substr(0,i);
    if(tmp==s){cout<<"Yes"<<endl;return 0;}
}
{ cout<<"No"<<endl; return 0;}


return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <decimal/decimal>


using namespace std;


int pow_int(int a, int n) {
    if (n == 0) {
        return 1;
    }
    return a * pow_int(a, n - 1);
}

int main() {
  int N, K;
  cin >> N >> K;
  // 17 = log2 10^5
  vector<long long int> numerators(18, 0);
  long long int denominator = (long long int) pow_int(2, 17) * N;
  int upper, lower, thresh;
  bool in_n = true;

  for (int i = 0; i <= 17; i++) {
      thresh = (K - 1) / pow_int(2, i) + 1;
      if (i == 0) {
          upper = N;
          lower = min(N, thresh);
      } else {
          upper = lower;
          lower = min(N, thresh);
      }
      if (thresh > N) {
          continue;
      }
      numerators[i] = upper - lower;
      if (in_n) {
          numerators[i] += 1;
          in_n = false;
      }
   numerators[i] *= pow_int(2, 17 - i);   
  }
  long long int sum = accumulate(numerators.begin(), numerators.end(), 0LL);
//   cout << sum << "/" << denominator << endl;
  long double prob = (long double) sum / denominator;
  cout << setprecision(16) << prob << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

const MOD = 1000000007

var fac [2000020]int

func bipow(n, m int) int {
	if m == 0 {
		return 1
	}
	if m%2 == 0 {
		return bipow((n*n)%MOD, m/2)
	} else {
		return (n * bipow(n, m-1)) % MOD
	}
}

func fill_table() {
	fac[0] = 1
	for i := 1; i < 2000020; i++ {
		fac[i] = (fac[i-1] * i) % MOD
	}
}

func comb(n, m int) int {
	a := fac[n]
	b := bipow(fac[m], MOD-2)
	c := bipow(fac[n-m], MOD-2)
	ret := (((a * b) % MOD) * c) % MOD
	return ret
}

func S(r, c1, c2 int) int {
	ret := 0
	for j := c1; j <= c2; j++ {
		ret += comb(j+r+1, r)
		ret %= MOD
	}
	return ret
}

func main() {
	var r1, c1, r2, c2 int
	fmt.Scan(&r1, &c1, &r2, &c2)

	fill_table()

	ans := (S(r2, c1, c2) + MOD - S(r1-1, c1, c2)) % MOD
	fmt.Println(ans)
}


Measured memory_bytes: 16128
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main(void)
{
    int menu[5],menu10[5],menu1[5];
    int min= 10,j = 0,sum = 0;

    for(int i = 0;i < 5;i++) cin >> menu[i];


    for(int i = 0;i < 5;i++) menu10[i] = (menu[i] + 9) / 10;    
    for(int i = 0;i < 5;i++) menu1[i] = menu[i] % 10;

    for(int i = 0;i < 5;i++)
    {
        if(menu1[i] <= min && menu1[i] > 0)
        {
            min = menu1[i];
            j = i;
        }

    }

    for(int i = 0;i < 5;i++)
    {
        if(i == j)
        {
            sum += menu[i];
        }else{
            sum += menu10[i] * 10;
        }

    }

    cout << sum << endl;

    return 0;


}

Measured memory_bytes: 256
from itertools import accumulate


class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
  
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
  
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
            
def compress(arr):
    a = sorted([(v,k) for k,v in enumerate(arr)])
    return [k+1 for v,k in a]

n,k = map(int, input().split())
a = [int(input())-k for i in range(n)]
cumsum = [0] + list(accumulate(a))
comp = compress(cumsum)
bit = BIT(n+1)
ans = n * (n+1) // 2
for k,v in enumerate(comp):
  bit.add(v,1)
  ans -= k+1-bit.sum(v)
print(ans)

Measured memory_bytes: 87460
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
using namespace std;
typedef long long ll;
typedef vector<int>VI;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define fi first
#define se second
#define MAX 100100//5
#define MAX_N 200100
#define MAX_B 1001001//6
#define MAX_S 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL
#define MAX_INT INT_MAX
#define MAX_LL 
int n;
int factorial(int n){if(n==0)return 1;return n*factorial(n-1);}
int main(){
    cin>>n;
    vector<int>p(n),q(n);
    rep(i,n)cin>>p[i];rep(i,n)cin>>q[i];
    vector<vector<int> >v(factorial(n));
    vector<int>sample(n);
    rep(i,n)sample[i]=i+1;
    int index=0;
    do{
        v[index]=sample;
        index++;
    }while(next_permutation(ALL(sample)));
    int a,b;
    rep(i,v.size()){if(v[i]==p)a=i;if(v[i]==q)b=i;}
    cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include<math.h>
using namespace std;

int main() {
	int K, S;
	cin >> K >> S;
	int count = 0,sum;
	for (int i = 0; i <= K; i++) {
		for (int j = 0; j <= K; j++) {
			sum = i + j;
			if (sum>=S-K && sum<=S) ++count;
		}
	}
	cout << count << endl;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    /*
    lint q,h,s,d;
    cin >> q>>h>>s>>d;
    h = min(2 * q, h);
    */
    vector<lint> v(4);
    REP(i,4){
        cin >> v[i];
    }
    REP(i,3){
        v[i + 1] = min(v[i] * 2, v[i + 1]);
    }
    lint n;
    cin >> n;
    lint ans=0;
    n *= 4;
    IREP(i,4){
        lint tmp = n / ((lint)pow(2,i));
        //cout << tmp << "\n";
        lint price = v[i] * tmp;
        ans += price;
        n -= (lint)pow(2, i)*tmp;
        //cout <<"tmp"<<tmp<<"n"<< n <<"p"<<price<< "\n";
    }

    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [False for _ in range(n+1)]
B[1] = True
C = [1]

for i in range(1,n):
    C.append(A[C[-1]])
    #print(C)
    B[C[-1]] = True
    if B[A[C[-1]]] == True:
        C.append(A[C[-1]])
        break

num = i + 1
s = C.index(C[-1])
N = num - s

if k < s:
    print(C[k])
else:
    C = C[s:-1]
    #print(C)
    print(C[(k-s)%N])

Measured memory_bytes: 32336
#include<iostream>
using namespace std;
int main()
{
    int a,b,x,i,j,n,sum=0;
    cin>>x;
    int arr[x];
    for(n=0;n<x;n++)
    {
     cin>>arr[n];
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            sum+=arr[i]*arr[j];
        }
    }
    cout<<sum<<endl;



}


Measured memory_bytes: 256
s=list(input())
for i in range(len(s)):
  if i%2!=0:
    if s[i]=='L' or s[i]=='U' or s[i]=='D':
      s[i]='i'
      
  else:
    if s[i]=='R' or s[i]=='U' or s[i]=='D':
      s[i]='i'
      
#print(s)
if s==['i']*len(s):
  print('Yes')
  
else:
  print('No')

Measured memory_bytes: 3060
N = int(input())
cnt = [0] * 11000

for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            value = x*x + y*y + z*z + x*y + y*z + z*x
            if value <= 11000:
                cnt[value] += 1
for i in range(1,N+1):
    print(cnt[i])

Measured memory_bytes: 74296
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

int n, d;
VV c;
V sm;

bool update() {
    rep(i, n) {
        if (!c[i].empty()) {
            sm[i] -= c[i].back();
            if (*max_element(all(sm)) - *min_element(all(sm)) <= d) {
                c[i].pop_back();
                return true;
            }
            sm[i] += c[i].back();
        }
    }
    return false;
}

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

    while (cin >> n >> d, n) {
        c.clear();
        c.resize(n);
        rep(i, n) {
            int m;
            cin >> m;
            rep(j, m) {
                int x;
                cin >> x;
                c[i].emplace_back(x);
            }
        }
        sm.clear();
        sm.resize(n);
        rep(i, n) {
            sm[i] = accumulate(all(c[i]), 0);
        }

        while (update()) ;

        cout << (*max_element(all(sm)) <= 0 ? "Yes" : "No") << endl;
    }
}

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

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

    ll h, w;
    cin >> h >> w;
    ll si, sj, gi, gj;
    cin >> si >> sj >> gi >> gj;
    --si;
    --sj;
    --gi;
    --gj;

    vector<string> s(h);
    rep(i, h) cin >> s[i];

    priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> pq;
    pq.push({0, {si, sj}});
    const int INF = 1001001001;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    dist[si][sj] = 0;
 
    while(!pq.empty()){
        pair<int, pair<int, int>> p = pq.top();
        pq.pop();
        int y = p.second.first;
        int x = p.second.second;

        for(int ni = -2; ni <= 2; ++ni) for(int nj = -2; nj <= 2; ++nj){
            if(ni==0 && nj==0) continue;
            int ny = y + ni;
            int nx = x + nj;

            if(ny<0 || ny>=h || nx<0 || nx>=w) continue;
            if(s[ny][nx] == '#') continue;
            int cost;
            if((ni==0&&nj==1) || (ni==1&&nj==0) || (ni==0&&nj==-1) || (ni==-1&&nj==0)) cost = 0;
            else cost = 1;
 
            if(dist[y][x] + cost < dist[ny][nx]){
                dist[ny][nx] = dist[y][x] + cost;
                pq.push({dist[ny][nx], {ny, nx}});
            }

        }
    }

    if(dist[gi][gj] == INF) cout << -1 << endl;
    else cout << dist[gi][gj] << endl;

    return 0;
}

Measured memory_bytes: 8632
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
#include <random>
using namespace std;

/////////////////////////////////////////////////////////////////////////////////////////////
#define rep_re(i,s,n)for(ll i = n-1;i>=s;i--)
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep(i,s,n)for(ll i = s;i<n;i++)
typedef long long int ll;
typedef vector<int> Vi;
typedef vector<vector<int>> VVi;
ll MOD = 1e9 + 7;

ll c[100001] = {};
ll v[100001] = {};
ll d[100001] = {};
vector<vector<pair<ll, ll>>> V;

void dfs(ll id,ll dis) {
    c[id] = dis;
    v[id] = true;

    for (auto p : V[id]) {
        if (!v[p.first]) {
            dfs(p.first, dis + p.second);
        }
    }
}

int main()
{
    ll n; cin >> n;
    V.resize(n+1);

    rep(i, 0, n - 1) {
        ll u, v, w; cin >> u >> v >> w;
        V[u].push_back({ v,w });
        V[v].push_back({ u,w });
    }

    dfs(1,0);

    repe(i, 1, n) {
        cout << (c[i] & 1) << endl;
    }

    return 0;
}


Measured memory_bytes: 9984
#include <stdio.h>
#include <stdlib.h>
 
int
main(int argc, char *argv[])
{
        int r, c;
        int i, j;
        int rsum, *csum;
        int *data, *itr;
 
        scanf("%d %d", &r, &c);
        data = (int *)malloc((r + 1) * (c + 1) * sizeof(int));
        csum = data + (c + 1) * r;
        for (i = 0; i < r; i++) {
                itr = data + (c + 1) * i;
                rsum = 0;
                for(j = 0; j < c; j++) {
                        scanf("%d", itr);
                        rsum += *itr;
                        csum[j] += *itr;
                        itr++;
                }
                *itr = rsum;
        }
        for (j = 0; j < c; j++)
                csum[c] += csum[j];
 
        itr = data;
        for (i = 0; i < r + 1; i++)
                for (j = 0; j < c + 1; j++)
                        printf("%d%c", *itr++, (j == c)? '\n' : ' ');
 
        return 0;
}


Measured memory_bytes: 2040
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int res = 0;

		//　桁数が奇数の数を数える
		for(int i = 1; i <= n; i++) {
			if(Integer.toString(i).length() % 2 == 1) {
				res++;
			}
		}
		
		System.out.println(res);
		sc.close();
	}
}

Measured memory_bytes: 27604
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
using Int = int64_t;
int main() {
    Int n;
    cin >> n;
    vector<int> min(26, 50);
    string S;
    for (int i = 0; i < n; i++) {
        cin >> S;
        vector<int> cnt(26);
        for (char c : S) cnt[c - 'a']++;
        for (int j = 0; j < 26; j++) if (cnt[j] < min[j]) min[j] = cnt[j];
    }
    bool exist = false;
    for (int i = 0; i < 26; i++) {
        if (min[i] > 0) {
            exist = true;
            cout << string(min[i], (char)(i + 'a'));
        }
    }
    if (exist) cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int A, B;
  scanf("%d %d", &A, &B);
  if(A==1 || B==1){
	if(A==2 || B==2){ printf("3");}
    else{printf("2");}
  }
  else if(A==2 || B==2){
	if(A==1 || B==1){ printf("3");}
    else{printf("1");}
  }
  else if(A==3 || B==3){
	if(A==1 || B==1){ printf("2");}
    else{printf("1");}
  }
}
  
    
    

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int const mxn=3e5+5;
ll a[mxn];

void add(ll &a, ll b){
	a%=MOD; b%=MOD; a+=b; a%=MOD;
	return;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n; cin >> n;
	map<int,ii>mp;
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	for(int i=0; i<n; i++){
		for(int j=59; j>=0; j--){
			if(a[i]>>j&1)mp[j].se++;
			else mp[j].fi++;
		}
	}
	ll ans = 0; ll two = 1;
	for(int j=0; j<60; j++){
		add(ans,(((two*mp[j].fi)%MOD)*mp[j].se)%MOD);
		two*=2;
		two%=MOD;
	}
	cout << ans << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;

// Call gen_f to generate factiorials
// Be sure about MOD 
// Call get_c(i, j) to obtain c[i][j]

const ll MOD = 1e9 + 7;

const int MAXF = 2e5 + 5;

ll f[MAXF], f_inv[MAXF];

ll pow_mod(ll a, ll st) {
	ll ans = 1ll;
	for(; st; st >>= 1ll) {
		if (st & 1) {
			ans = (ans * a) % MOD;
		}
		a = (a * a) % MOD;
	}
	return ans;
}

ll get_inv(ll v) {
	return pow_mod(v, MOD - 2);
}

void gen_f() {
	f[0] = 1;
	REP(i, 1, MAXF) {
		f[i] = (f[i - 1] * i) % MOD;
	}
	f_inv[MAXF - 1] = get_inv(f[MAXF - 1]);
	for(int i = MAXF - 2; i >= 0; i--) {
		f_inv[i] = (f_inv[i + 1] * (i + 1)) % MOD;
	}
}

ll get_c(int i, int j) {
	if (j > i || j < 0) {
		return 0ll;
	}
	return (((f[i] * f_inv[j]) % MOD) * f_inv[i - j]) % MOD;
}

void add(ll &p0, ll &q0, ll p1, ll q1){
	ll p2 = (p0 * q1 + q0 * p1) % MOD;
	ll q2 = (q0 * q1) % MOD;
	p0 = p2, q0 = q2;
}

void solve(){
	gen_f();
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	ll p0 = 0, q0 = 1, p1, q1;
	ll bn = pow_mod(b, n);
	ll an = pow_mod(a, n);
	ll abn = pow_mod(a + b, n);
	REPN(i, 0, n - 1) {
		p1 = pow_mod(a, i);
		q1 = pow_mod(a + b, i);
		p1 = (p1 * get_c(n - 1 + i, i)) % MOD;
		p1 = (p1 * (i + n)) % MOD;
		p1 = (p1 * bn) % MOD;
		q1 = (q1 * abn) % MOD;
		add(p0, q0, p1, q1);
		
		p1 = pow_mod(b, i);
		q1 = pow_mod(a + b, i);
		p1 = (p1 * get_c(n - 1 + i, i)) % MOD;
		p1 = (p1 * (i + n)) % MOD;
		p1 = (p1 * an) % MOD;
		q1 = (q1 * abn) % MOD;
		add(p0, q0, p1, q1);		
	}
	p0 = (p0 * 100) % MOD;
	q0 = (q0 * (100 - c)) % MOD;
	ll ans = (p0 * get_inv(q0)) % MOD;
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0 ; i < N; i++)
    {
        cin >> A[i];
    }
    ll m = 0;
    ll ans=0;
    for (int i = 1; i < N; i++)
    {
        m = max(m, A[i - 1]);
        if (m > A[i]) ans += (m - A[i]);
    }
    cout << ans;
}

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

int main(){
  string s;
  cin>>s;
  vector<int>ad(26);
  for(int i=0;i<26;i++){
    ad[i]=0;
  }
  for(int i=0;i<s.size();i++){
    ad[s[i]-'a']++;
  }
  for(int i=0;i<26;i++){
    if(ad[i]==0){
      cout<<char('a'+i)<<endl;
      return 0;
    }
  }
  cout<<"None"<<endl;
}
    


Measured memory_bytes: 512
//abc147D
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define deb 60
int main(void) {
  int i, j;
  long long n,a, mod=1000000007, sum=0,bin=1, x[deb];
  scanf("%lld", &n);
  
  for(i=0; i < deb; i++) x[i]=0;
  for(i=0; i < n; i++){
    scanf("%lld", &a);
    for(j=0; j < deb; j++){
      if(a & 2 != 0) x[j]++;
      else if(a==0)break;
      a/=2;
    }
  }

  for(i=0; i < deb; i++){
    sum=(sum+x[i]*(n-x[i])%mod*bin)%mod;
    bin=bin*2%mod;
  }
  printf("%lld", sum);
}

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

r = [0 for i in range(N)]
r[0] = A[0]
sumA = sum(A)
for i in range(1, N):
    r[i] = r[i-1] + A[i]

ans = abs(2 * r[0] - sumA)
for i in range(N):
   ans = min(abs(2 * r[i] - sumA), ans)
print(ans)

Measured memory_bytes: 26224
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function heap(a::Array{Tuple{Int,Int},1})
	h = [a[1]]
	for i in 2:length(a)
		hpush(h,a[i])
	end
	h
end
function hpush(h::Array{Tuple{Int,Int},1},x::Tuple{Int,Int})
	push!(h,x)
	if length(h) > 1
		l = length(h)
		k = div(l,2)
		while h[k][2]<x[2]&&k>=1
			tmp = h[k]
			h[k] = x
			h[l] = tmp
			k = max(div(k,2),1)
			l = div(l,2)
		end
	end
end

function hpop(h::Array{Tuple{Int,Int},1})
	x = h[1]
	z = pop!(h)
	if !isempty(h)
		h[1] = z
		k = 1
		l = length(h)
		while k <= l
			if 2*k>l
				break
			elseif 2*k+1>l
				if h[2*k][2]<=z[2]
					break
				else
					tmp = h[2*k]
					h[2*k] = z
					h[k] = tmp
					k = 2*k
				end
			else
				if h[2*k][2]<=z[2]&&h[2*k+1][2]<=z[2]
					break
				else
					t = h[2*k][2]>h[2*k+1][2]?2*k:2*k+1
					tmp = h[t]
					h[t] = z
					h[k] = tmp
					k = t
				end
			end
		end
	end
	x
end



function main()
	n,m = readline() |> split |> parseMap
	a = Tuple{Int,Int}[(0,0) for i in 1:n]
	for i in 1:n
		p,q = readline() |> split |> parseMap
		a[i] = (p,q)
	end
	v = zeros(Int,m)
	a = sort(a,by=x->x[1])
	h = Array{Tuple{Int,Int},1}()
	for i in 1:m
		if !isempty(a)
			while a[1][1]<=i
				hpush(h,shift!(a))
				if isempty(a)
					break
				end
			end
		end
		if !isempty(h)
			v[i]=hpop(h)[2]
		end
	end
	println(sum(v))
end

main()

Measured memory_bytes: 160484
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  ll N;
  ll a[1100], t[1100];
  ll res=0;
  cin >> N;

  rep(i,N) {
    cin >> t[i] >> a[i];
  }

  ll T=t[0], A=a[0];
  FOR(i,1,N-1){
    ll n = max(T/t[i] + (T%t[i]>0), A/a[i] + (A%a[i]>0));
    T = t[i] * n;
    A = a[i] * n;
  }
  cout << T + A << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int main()
{
	int n, m;
	char c1, c2;
	vector<pair<char, char> > conv;
	vector<char> data;

	while(cin >> n)
	{
		if(n == 0)
			break;

		for (int i=0; i<n; i++)
		{
			cin >> c1 >> c2;
			conv.push_back (make_pair(c1, c2));
		}
	
		cin >> m;
	
		for (int i=0; i<m; i++)
		{
			cin >> c1;
	
			for (int j=0; j<n; j++)
			{
				if (c1 == conv[j].first)
				{
					c1 = conv[j].second;
					break;
				}
			}
	
			data.push_back (c1);
		}

		for(int i=0; i<m; i++)
			cout << data[i];
	
		cout << endl;

		conv.clear();
		data.clear();
	}
	
	return 0;
}

Measured memory_bytes: 1340
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#include <random>
#include <map>
#pragma warning(disable : 4996)



int main(void) {
	std::vector<int> T;
	int n;
	scanf("%d", &n);
	int sum = 0;
	for (int i = 0; i < n; ++i) {
		int t;
		scanf("%d", &t);
		T.push_back(t);
		sum += t;
	}
	int m;
	scanf("%d", &m);
	for (int i = 0; i < m; ++i) {
		int p, x;
		scanf("%d %d", &p, &x);
		printf("%d\n", sum - T[p - 1] + x);
	}
	return 0;
}


Measured memory_bytes: 256
let main = (standardInput) => {
    let lengthList = standardInput.split(' ');
    let varticalLength = Number.parseInt(lengthList[0]);
    let horizonLength = Number.parseInt(lengthList[1]);

    console.log(`${varticalLength * horizonLength} ${2 * (varticalLength + horizonLength)}`);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


Measured memory_bytes: 15096
from collections import deque
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


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

dp = [-1]*(W+1)
dp[0] = 0

for loop in range(N):
    value,weight = map(int,input().split())
    for i in range(weight,W+1):
        if dp[i-weight] == -1:
            pass
        else:
            dp[i] = max(dp[i],dp[i-weight]+value)

ans = 0
for i in range(W+1):
    ans = max(ans,dp[i])

print("%d"%(ans))



Measured memory_bytes: 6664
#include<iostream>
using namespace std;
string str;
typedef unsigned us;
char r[] = "yuiophjklnm";
bool isRight(char c){
  for(us i = 0;i < sizeof(r);i++){
    if(c == r[i])return true;
  }
  return false;
}
int solve(const string &str){
  int res = 0;
  bool isr = false;
  isr = isRight(str[0]);
  for(unsigned i = 0;i < str.size();i++){
    if(isr != isRight(str[i])){
      res += 1;
      isr = isRight(str[i]);
    }
  }
  return res;
}

int main(){
  while(true){
    getline(cin,str);
    if(str == "#")break;
    cout << solve(str) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
int main(){
	char a[11],b[1001],c[12]="END_OF_TEXT";
	int i,count=0;
	scanf("%s",a);
	while(1){
		scanf("%s",b);
		if(strcmp(b,c)==0) break;
		for(i=0;b[i]!='\0';i++){
			b[i]=tolower(b[i]);
		}
		if(strcmp(b,a)==0) count++;
	}
	printf("%d\n",count);
}
		


Measured memory_bytes: 2116
#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 N, M, Q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> &A) {
  if (A.size() == N + 1)
  {
    int temp = 0;
    for (int i = 0; i < Q; i++)
    {
      if (A[b[i]] - A[a[i]] == c[i])
      {
        temp += d[i];
      }
      
    }
    ans = max(ans, temp);
    return;
  }
  
  for (int i = A.back(); i <= M; i++)
  {
    A.push_back(i);
    dfs(A);
    A.pop_back();
  }
  
}

int main() {
  cin >> N >> M >> Q;
  a.resize(Q); b.resize(Q); c.resize(Q); d.resize(Q);
  for (int i = 0; i < Q; i++)
  {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    // --a[i]; --b[i];
  }
  
  vector<int> A;
  A.push_back(1);
  ans = 0;
  dfs(A);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int m, f, r, sum;
    int i;
    
    for (i=0; i<50; i++) {
        scanf("%d %d %d", &m, &f, &r);
        sum = m+f;
        //printf("sum = %d\n", sum);
        //printf("(m, f, r) = (%d, %d, %d)\n", m, f, r);
        
        if (m == -1 && f == -1 && r == -1) {//全部-1
            return 0;
        }
        if (m==-1 || f==-1) {
            printf("F\n");
        }else if (sum>=80) {
            printf("A\n");
        }else if (65<=sum && sum<80) {
            printf("B\n");
        }else if (50<=sum && sum<65) {
            printf("C\n");
        }else if (30<=sum && sum<50) {
            if (r>=50) {
                printf("C\n");
            }else{
                printf("D\n");
            }
        }else if (sum<30) {
            printf("F\n");
        }
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}
// end of Template

ll n,z;
ll p[200000];
ll fac[200000];
ll md = 1e9+7;
ll calc (ll x, ll y){
    if(x<y)return 0;
    else{
        ll up,d1,d2,down;
        up = fac[x];
        d1 = fac[y];
        d2 = fac[x-y];
        down = (d1*d2)%md;
        down = invmod(down,md);
        ll res = (up * down) % md;
        return res;
    }
}
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;n++;
    for(int i=1;i<=n;i++){
        int temp; cin>>temp;
        if(!p[temp])p[temp]=i;
        else{z = (p[temp]-1)+(n-i);}
    }
    fac[0]=1;
    for(int i=1;i<=n;i++){
        fac[i] = ((fac[i-1]) * i)%md;
    }
    for(int k=1;k<=n;k++){
        ll ans = calc(n,k) - calc(z,k-1);
        if(ans<0)ans = md + ans;
        cout<<ans<<newl;
    }

}


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

using namespace std;
#define mod 10000000+7

#define ll long long
int main() {
 ll n,k;
 cin>>n>>k;
 ll sum=0;
  ll arr[n];
  for(ll i=0;i<n;i++)
      cin>>arr[i];
    sort(arr,arr+n,greater<int>());
    for(ll i=0;i<n;i++){
        if(i<k)
        continue;
        else
        sum+=arr[i];
    }
    cout<<sum;
      
      
 }
   



 
  




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

using namespace std;

int main() {
    string S;
    cin >> S;
    int l = S.length();
    int a = 0, b = 0;
    for (int i = 0; i < l; i++) {
        if (i % 2 == S[i] - '0') {
            a++;
        } else {
            b++;
        }
    }
    cout << min(a, b) << endl;
}

Measured memory_bytes: 512
(let* ((n (read))
			 (a (make-array n :initial-contents (loop :repeat n :collect (read))))
			 (avg (round (reduce #'+ a) (length a))))
	(loop
		 :for x :across a
		 :summing (expt (- x avg) 2) :into s
		 :finally (format t "~a~%" s)))


Measured memory_bytes: 18536
#include <bits/stdc++.h>
using namespace std;
int main () {
	int N;
	cin >> N;
	int MIN = 100000000;
	for (int i = 0; i < N; ++i)
	{
		int tmp = 0;
		cin >> tmp;
		int tmp1 = 0;
		while(tmp % 2 == 0){
			tmp /= 2;
			tmp1++;
		}
		MIN = min(MIN,tmp1);
	}
	cout << MIN << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;

ll x, y;

int main() {
	scanf("%lld%lld", &x, &y);
	if (abs(y - x) <= 1) puts("Brown");
	else puts("Alice");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;

    if(a == b){
        cout << "Draw" << endl;
    }else if(a > b && b != 1 || a == 1){
        cout << "Alice" << endl;
    }else if(a < b && a != 1 || b == 1){
        cout << "Bob" << endl;
    }
    return 0;
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    string S;
    cin >> S;
    int k = S.size();
    int cnt = 15 - k;
    rep(i, k) {
        if (S[i] == 'o')cnt++;
    }
    if (cnt >= 8) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


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

int main() {
	ll n, m;
	cin >> n >> m;
	ll wa = 0;
	ll ac = 0;
	vector<ll> flag(n, 0);//-1:AC,1~:ペナ数
	for (ll i = 0; i < m; ++i) {
		ll p;
		string s;
		cin >> p >> s;
		--p;
		if (flag[p] == -1)continue;
		if (s == "WA") {
			++flag[p];
		}
		else {
			++ac;
			wa += max(0ll, flag[p]);
			flag[p] = -1;
		}
	}
	cout << ac << " " << wa << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r, g, b;
  cin >> r >> g >> b;
  if( (100*r +10*g + b)%4 == 0){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
  
}

Measured memory_bytes: 3672