akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE FlexibleContexts #-}

import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.Bits
import Data.Int
import Debug.Trace

main = do
  [n,q] <- map read . words <$> getLine :: IO [Int]
  queries <- replicateM q $ map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine :: IO [[Int]]



  seg <- stToIO $ newSegmentTree n 0 :: IO (IOSegmentTree Int)

  forM_ queries $ \[com,x,y] -> do
    when (com == 0) $ do
      stToIO $ modifySegmentTree seg (x-1) (+y) (+)
      --print =<< V.freeze seg
    when (com == 1) $ do
      a <- stToIO $ findSegmentTree seg (x-1) y 0 (+)
      print a
      --print =<< V.freeze seg



type STSegmentTree s a = VM.MVector s a
type IOSegmentTree a = STSegmentTree RealWorld a

newSegmentTree :: Num a => Int -> a ->  ST s (STSegmentTree s a)
newSegmentTree n x = V.thaw $ V.replicate m x
  where m = 2 * (2 ^ (ceiling $ logBase 2 (fromIntegral n))) - 1


updateSegmentTree :: Num a => STSegmentTree s a -> Int -> a -> (a -> a -> a) -> ST s ()
updateSegmentTree tree i x f = modifySegmentTree tree i (\_ -> x) f

modifySegmentTree :: Num a => STSegmentTree s a -> Int -> (a -> a) -> (a -> a -> a) -> ST s ()
modifySegmentTree tree i g f = do
  let
    n = (VM.length tree + 1) `div` 2
    j = i + n - 1
  VM.write tree j =<< g <$> VM.read tree j
  aux ((j-1)`div`2)
  where
    aux i = do
      when (i >= 0) $ do
        VM.write tree i =<< f <$> VM.read tree (i*2+1) <*> VM.read tree (i*2+2)
        aux ((i-1)`div`2)

findSegmentTree :: Num a => STSegmentTree s a -> Int -> Int -> a -> (a -> a -> a) -> ST s a
findSegmentTree tree x y e f = do
  let n = (VM.length tree) `div` 2 + 1
  aux 0 0 n
  where
    aux i l r
      | r <= x || y <= l = return e
      | x <= l && r <= y = VM.read tree i
      | otherwise = f <$> aux (i*2+1) l ((l+r)`div`2) <*> aux (i*2+2) ((l+r)`div`2) r



Measured memory_bytes: 49116
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << a * (a - 1) / 2 + b * (b - 1) / 2 << '\n';
  return 0;
}

Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N;
	std::vector<int> D;
	std::cin >> N;
	D.resize(N);
	for (auto& d : D)
		std::cin >> d;
	
	if (D[0] != 0) {
		std::cout << "0\n";
		return 0;
	}
	if (std::find(D.begin()+1, D.end(), 0) != D.end()) {
		std::cout << "0\n";
		return 0;
	}

	int maxd = *std::max_element(D.begin(), D.end());
	std::vector<int> X;
	X.resize(maxd+1);
	for (auto d : D)
		++X[d];

	long result = 1;
	for (int i = 1; i < maxd+1; ++i) {
		for (int j = 0; j < X[i]; ++j) {
			result = (result * X[i-1]) % 998244353;
		}
	}
	
	std::cout << result << "\n";
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int a, b, c, i, n = 0;
	
	scanf("%d %d %d", &a, &b, &c);
	
	for (i = a; i <= b; i++) {
		if (c % i == 0) n++;
	}
	
	printf("%d\n", n);
	
	return 0;
}

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

const int L = 8;

void solve() {
	long long n, a, b;
	cin >> n >> a >> b;
	if (a) {
		long long sum = a + b;
		long long iter = n / sum;
		long long ans = a * iter;
		long long term = n - (sum * iter);
		if (term > a) {
			ans += a;
		}	
		else ans += term;
		cout << ans << '\n';
	} else {
		cout << "0" << '\n';
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

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

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

signed main() {
	int N, L;
	cin >> N >> L;

	string possible = "Possible";
	string impossible = "Impossible";

	vector<int> a;
	inputVector(a, N);

	vector<int> ret;

	bool ok = false;
	rep(i, N - 1) {
		if (a[i] + a[i + 1] >= L) {
			ret.push_back(i + 1);
			for (int j = i - 1; j >= 0; j--) {
				ret.push_back(j + 1);
			}
			for (int j = i + 1; j < N - 1; j++) {
				ret.push_back(j + 1);
			}
			ok = true;
			break;
		}
	}
	if (!ok) {
		cout << impossible << endl;
		return 0;
	}

	reverse(all(ret));

	cout << possible << endl;
	rep(i, N - 1) {
		cout << ret[i] << endl;
	}

    return 0;
}


Measured memory_bytes: 2548
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iterator>
using namespace std;

//http://abc054.contest.atcoder.jp/tasks/abc054_d

#define RESIDUE(u,v) (capacity[u][v] - flow[u][v])
#define RCOST(u,v) (cost[u][v] + h[u] - h[v])
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

#define MAX_N 100

int dp[MAX_N][10];

int s[100];

//vector<int> v[10001];
//vector<int> v_old[10001];

/*
int ans(int k,int w){
  int i,ind,s=0;
  vector<int>::iterator m;
  if(v[w].size() <= k){
    return accumulate(v[w].begin(),v[w].end(),0);
  }
  REP(i,k){
    m = max_element(v[w].begin(),v[w].end());
    s += *m;
    ind = distance(v[w].begin(),m);
    v[w].erase(v[w].begin()+ind);
  }
  return s;
}
*/

int main(){
  int n;
  cin >> n;
  int  i,tmp;
  REP(i,n){
    cin >> tmp;
    s[i] = tmp;
  }
  REP(i,10){
    if(i)
      dp[n-1][i]=-1;
    else
      dp[n-1][i]=0;
  }
  int x,d,j;
  REP(i,n){
    x = s[n-i-1];
    d = x % 10;
    if(!i){
      dp[n-i-1][d] = x;
      continue;
    }
    REP(j,10){
      dp[n-i-1][j] = (dp[n-i][(10+j-d) % 10] == -1)? max(-1,dp[n-i][j]):max(dp[n-i][j],dp[n-i][(10+j-d) % 10] + x);
      //cout << n-i-1 << j<< " " <<dp[n-i-1][j] << endl;
    }
  }
  int score=0;
  REP(i,10){
    if(i)
      score = (dp[0][i] > score)? dp[0][i]:score;
  }
  cout << score << endl;
  return 0;
}


Measured memory_bytes: 256
// 他の方のコードを参考にさせていただいたのだけれど、謎割り算があったので、検証するための提出
'use strict'
function main(inp) {
  // 改行ごとに区切る
  inp = inp.trim().split('\n');
  // 最初の情報を別枠に儲ける
  const N = Number(inp.shift())
  // 行ごとに座標化する（ここまではできてた）
  inp = inp.map(r => r.split(' ').map(n => Number(n)))
  let sum = 0
  // 二重ループでそれぞれの組み合わせを作る
  for (let i = 0; i < N; i++) {
    for (let j = 0; j < N; j++) {
      // x座標の2乗数
      const x = Math.pow(inp[i][0] - inp[j][0], 2)
      // y座標の2乗数
      const y = Math.pow(inp[i][1] - inp[j][1], 2)
      // それをルートで出して足し合わせをする
      sum += Math.sqrt(x + y)
    }
  }
  // それをNで割るのはわかるけど
  console.log(sum / N);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
long long n,a[202020],b[202020],ans;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
	}
	for(int i=0;i<n;i++)
	{
		if(b[i]<a[i])
		{
			cout<<-1<<endl;
			return 0;
		}
	}
	priority_queue<pair<long long,long long> >pq;
	for(int i=0;i<n;i++)
	{
		if(a[i]!=b[i])
		{
			pq.push(make_pair(b[i],i));
		}
	}
	while(!pq.empty())
	{
		long long x=pq.top().first,y=pq.top().second;
		pq.pop();
		long long sum=b[(y+n-1)%n]+b[(y+1)%n];
		if(b[y]-a[y]<sum)
		{
			cout<<-1<<endl;
			return 0;
		}
		long long cnt=(b[y]-a[y])/sum;
		b[y]-=sum*cnt;
		ans+=cnt;
		if(b[y]<=a[y])
		{
			continue;
		}
		pq.push(make_pair(b[y],y));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9584
#include<stdio.h>

int main(){
  int a,b,max,d=1,c,e;
  scanf("%d %d",&a,&b);
  if(a<b){
    e=a;
    a=b;
    b=e;
  }
  c=a%b;
  if(c==0){
    max=a;
  }else if(b<c){
    for(d=1;d<=b;d++){
      if(b%d==0 && c%d==0){
	max=d;
      }
    }
  }else{
    for(d=1;d<=c;d++){
      if(b%d==0 && c%d==0){
	max=d;
      }
    }
  }
  printf("%d\n",max);
}



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

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}


int main() {

	ll w, h, n;
	cin >> w >> h >> n;

	vector<vector<int>> vec(w, vector<int>(h));

	ll ans = 0;

	for (int i = 0; i < n; i++) {
		int x, y, a;
		cin >> x >> y >> a;
		if (a == 1) for (int j = 0; j < x; j++) for (int k = 0; k < h; k++) vec[j][k] = 1;
		if (a == 2) for (int j = x; j < w; j++) for (int k = 0; k < h; k++) vec[j][k] = 1;
		if (a == 3) for (int j = 0; j < w; j++) for (int k = 0; k < y; k++) vec[j][k] = 1;
		if (a == 4) for (int j = 0; j < w; j++) for (int k = y; k < h; k++) vec[j][k] = 1;
	}

	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++) {
			if (vec[i][j] == 0) {
				ans++;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		String[] array = new String[A];

		for (int i = 0; i < array.length; i++) {
			array[i] = scan.next();
		}

		int AC = 0;
		int WA = 0;
		int TLE = 0;
		int RE = 0;

		for (int j = 0; j < A; j++) {
			if (array[j].equals("AC")) {
				AC++;
			} else if (array[j].equals("WA")) {
				WA++;
			} else if (array[j] .equals("TLE")) {
				TLE++;
			} else if (array[j] .equals("RE")) {
				RE++;
			}
		}

		System.out.println("AC x "+AC);
		System.out.println("WA x "+WA);
		System.out.println("TLE x "+TLE);
		System.out.println("RE x "+RE);

	}

}

Measured memory_bytes: 63832
#include <stdio.h>
#include<iomanip>
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<algorithm>
#include<string>
#include<cctype>
#include<vector>
#include<queue>
using namespace std;
#define rep(n) for(int i=0;i<n;i++)
#define reps(m,n,c) for(int c=m;c<n;c++)
#define repd(m,n,j) for(int j=n;j>m;j--)
#define oR ||
#define anD &&
#define max(m,n) ((n<m)?m:n)
#define min(m,n) ((n>m)?m:n)

int main()
{
	long x;
	cin >> x;
	std::cout << (long)pow(x, 3) << endl;

}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main(){

	int n;
	while(cin>>n&&n!=0){
		int dx,dy;
		for(int i = 0; i < n; i++){
			int cx=0;
			int cy=0;
			int fx,fy;
			fx=fy=0;
			int maxDist=0;
			while(cin>>dx>>dy&&!(dx==0&&dy==0)){
				cx+=dx;
				cy+=dy;
				if(cx*cx+cy*cy>maxDist){
					maxDist=cx*cx+cy*cy;
					fx=cx;
					fy=cy;
				}
				else if(cx*cx+cy*cy==maxDist){
					if(fx<cx){
						fx=cx;
						fy=cy;
					}
				}
			}
			cout<<fx<<" "<<fy<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>

#define NODE_MAX 256
#define INF 100000000

typedef struct edge_t_tag {
	int max;
	int next;
	struct edge_t_tag* pair;
} edge_t;

int edge_num[NODE_MAX];
edge_t edges[NODE_MAX][NODE_MAX*2];
char visited[NODE_MAX];

int get_one_flow(int now,int goal,int limit) {
	int i;
	if(now==goal)return limit;
	if(visited[now])return 0;
	visited[now]=1;
	for(i=0;i<edge_num[now];i++) {
		int now_flow;
		if(edges[now][i].max<=0)continue;
		now_flow=get_one_flow(edges[now][i].next,goal,
			edges[now][i].max<limit?edges[now][i].max:limit);
		if(now_flow>0) {
			edges[now][i].max-=now_flow;
			edges[now][i].pair->max+=now_flow;
			return now_flow;
		}
	}
	return 0;
}

int get_max_flow(int s,int g) {
	int result=0;
	while(1) {
		int now;
		memset(visited,0,sizeof(visited));
		now=get_one_flow(s,g,INF);
		if(now==0)break;
		result+=now;
	}
	return result;
}

void flow_init(void) {
	memset(edge_num,0,sizeof(edge_num));
}

void flow_add_edge(int s,int t,int max) {
	edges[s][edge_num[s]].max=max;
	edges[s][edge_num[s]].next=t;
	edges[s][edge_num[s]].pair=&edges[t][edge_num[t]];
	edges[t][edge_num[t]].max=0;
	edges[t][edge_num[t]].next=s;
	edges[t][edge_num[t]].pair=&edges[s][edge_num[s]];
	edge_num[s]++;
	edge_num[t]++;
}

int N;
int a[128], b[128], c[128], d[128];

int main(void) {
	int i, j;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &a[i], &b[i]) != 2) return 1;
	}
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &c[i], &d[i]) != 2) return 1;
	}

	flow_init();
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			if (a[i] < c[j] && b[i] < d[j]) {
				flow_add_edge(i, N + j, 1);
			}
		}
	}
	for (i = 0; i < N; i++) {
		flow_add_edge(N * 2, i, 1);
		flow_add_edge(N + i, N * 2 + 1, 1);
	}
	printf("%d\n", get_max_flow(N * 2, N * 2 + 1));
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); /*cout.tie(NULL);*/
	ll r, d, x; cin >> r >> d >> x;
	for (int i = 0; i < 10; i++) {
		x = x * r - d;
		cout << x << '\n';
	}








}


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


template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

int divisor(int x){
    int ans=0;
    for(int i=1; i<=x; i++){
        if(x%i==0) ans++;
    }
    return ans;
}
int main(){
    int n; cin >> n;
    int ans=0;
    for(int i=1; i<=n; i+=2){
        if(divisor(i)==8) ans++;
    }
    COUT(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int n;
	int a[100001];
	cin>>n;
	rep(i,n)cin>>a[i];
	int total=0;
	rep(i,n){
		if(a[a[i]-1]==i+1){
			total++;
			a[i]=0;
		}
	}
	cout<<total<<endl;
	return 0;

}


Measured memory_bytes: 640
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<int>dis(N, INT_MAX);
	dis[1] = 1;
	deque<int>Q;
	Q.push_back(1);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop_front();
		int c = dis[cn];
		if (dis[(cn + 1) % N] > c + 1) {
			dis[(cn + 1) % N] = c + 1;
			Q.push_back((cn + 1) % N);
		}
		if (dis[(cn * 10) % N] > c) {
			dis[(cn * 10) % N] = c;
			Q.push_front((cn * 10) % N);
		}
	}
	cout << dis[0] << endl;
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
using namespace std;
int main (){
  int n;
  string s;
  string a;
  cin >> n >> s;
  a = s.substr(n / 2);
  if(s == a + a ){ 
    cout << "Yes" << endl;
  } 
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    string a,b;
    int n; cin >> n;
    cin >> a >> b;
    int ans = 0;
    for(int l= 1; l<=n; l++){
        auto sa = a.substr(n-l,l);
        auto sb = b.substr(0,l);
        if(sa == sb)ans = max(ans,l);
       // cout << sa << endl <<sb <<endl;
        
    }
    cout << n*2 - ans << endl;
}



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

int main() {
	int N;
	cin >> N;
	int a, b, c, d;
	a = N/1000;
	b = (N-a*1000)/100;
	c = (N-a*1000-b*100)/10;
	d = (N-a*1000-b*100-c*10);

	if ((a==b && b==c) || (b==c && c==d)) puts("Yes");
	else puts("No");
}

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 200007;

int n;
int a[MAXN];
int p[MAXN];

void init ();
void input ();
void work ();



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	cin >> n;
	lpi ( i, 1, n ) cin >> a[i];
}

void work ()
{
	// main work

	lpi ( i, 1, n ) p[a[i]] = i;

	int r, ans = 0;
	for ( int i = 1; i <= n; ) {
		r = i + 1;
		while ( r <= n && p[r - 1] < p[r] ) ++r;
		ans = qmax ( ans, r - i );
		i = r;
	}

	cout << n - ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int n, c0, c1, c2, c3;
string s;

int main() {
	cin >> n;
	
	for (int i = 1; i <= n; ++i) {
		cin >> s;
		if (s == "AC") c0++;
		if (s == "WA") c1++;
		if (s == "TLE") c2++;
		if (s == "RE") c3++;
	}
	
	cout << "AC x " << c0 << '\n';
	cout << "WA x " << c1 << '\n';
	cout << "TLE x " << c2 << '\n';
	cout << "RE x " << c3 << '\n';
	
	return 0;
}

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

int main() {
	string s;
	int q, t, f;
	char c;
	cin >> s >> q;

	bool rot = 0;
	string front = "";
	string back = "";
	for (int i = 0; i < q; ++i) {
		cin >> t;
		if (t == 1) {
			rot ^= 1;
		}
		else {
			cin >> f >> c;
			if (f == 1) {
				if (rot) {
					back.push_back(c);
				}
				else {
					front.push_back(c);
				}
			} else {
				if (rot) {
					front.push_back(c);
				}
				else {
					back.push_back(c);
				}
			}
		}
	}
	if (rot) {
		reverse(s.begin(), s.end());
		reverse(back.begin(), back.end());
		cout << back + s + front;
	} else {
		reverse(front.begin(), front.end());
		cout << front + s + back;
	}
	return 0;
}

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

using namespace std;

int N;
set<int> PointData;
set<set<int> > SurfaceInfos;

int main() {
	int p;

	cin >> N;
	for (int i = 0; i < N; ++i) {
		PointData.clear();
		for (int j = 0; j < 3; ++j) {
			cin >> p;
			PointData.insert(p);
		}
		SurfaceInfos.insert(PointData);
	}
	cout << N-SurfaceInfos.size() << endl;

	return 0;
}


Measured memory_bytes: 3352
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = n*a;
        if (b <= c) {
            System.out.println(b);
        }
        else {
            System.out.println(c);
        }
    }
}

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

using namespace std;

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

  int cnt = 0;
  for (int i = 0; i < (s.size() + 1) / 2; i++) {
    if (s[i] != s[s.size() - i - 1]) cnt++;
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repl(i, l, r) for (int i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int M = 300000;
int p, v[M], w[M], dp[512][100001];
void solve() {
	int V, L;
	cin >> V >> L;
	V;
	if (V <= p) {
		cout << dp[V][L] << endl;
		return;
	}
	vector<int> A;
	while (V > p) {
		A.push_back(V);
		V = V / 2;
	}
	int s = A.size(), ans = 0;
	rep(bit, 1 << s) {
		int nw = 0, nv = 0;
		rep(i, s) {
			if (bit >> i & 1) {
				nw += w[A[i] - 1];
				nv += v[A[i] - 1];
			}
		}
		if (L >= nw) ans = max(ans, nv + dp[V][L - nw]);
	}
	cout << ans << endl;
}
int main() {
	int n;
	scanf("%d", &n);
	rep(i, n) scanf("%d%d", &v[i], &w[i]);
	p = (log2(n) + 1) / 2;
	p = (1 << p) - 1;
	rep(i, p) {
		rep(j, 100001) {
			if (j) dp[i + 1][j] = max(dp[i + 1][j - 1], dp[(i + 1) / 2][j]);
			if (j >= w[i]) dp[i + 1][j] = max(dp[i + 1][j], dp[(i + 1) / 2][j - w[i]] + v[i]);
		}
	}
	int q;
	scanf("%d", &q);
	while (q--) solve();
	return 0;
}

Measured memory_bytes: 205592
N = int(input())
A = list(map(int, input().split()))
A.sort()
old = A[0]
a = 1
ans = 0
for i in range(1, N):
    cur = A[i]
    if cur == old:
        a += 1
    else:
        if old <= a:
            ans += a - old
        else:
            ans += a
        a = 1
    old = cur
if old <= a:
    ans += a - old
else:
    ans += a
print(ans)

Measured memory_bytes: 20676
import sys
import heapq
input = sys.stdin.readline
n, m = map(int, input().split())
q = [0]
heapq.heapify(q)
to = [[] for _ in range(m)]
count = 0
for i in range(n):
    a, b = map(int, input().split())
    if a > m:
        continue
    to[a-1].append(b)
for i in range(m):
    for j in to[i]:
        heapq.heappush(q, -j)
    if len(q) != 0:
        count += heapq.heappop(q) * -1
print(count)

Measured memory_bytes: 18376
// Aizu 1102:   Calculation of Expressions
// 2017.9.12 bal4u@uu

#include <stdio.h>
#include <ctype.h>

#define abs(a) ((a)>=0?(a):-(a))
#define B 10000
int calc();

char buf[200], *p;

int factor(int *r, int *i)
{
	int r1, i1;

	if (*p == '(') { p++; if (!calc(&r1, &i1)) return 0; p++; }
	else if (*p == 'i') p++, r1 = 0, i1 = 1;
	else {
		r1 = i1 = 0;
		while (isdigit(*p)) { r1 = 10 * r1 + (*p++ - '0'); if (r1 > B) return 0; }
	}
	*r = r1, *i = i1;
	return 1;
}

int term(int *r, int *i)
{
	int r1, r2, i1, i2, rr, ii;

	if (!factor(&r1, &i1)) return 0;
	while (1) {
		if (*p == '*') p++;
		else break;
		if (!factor(&r2, &i2)) return 0;
		rr = r1*r2-i1*i2, ii = r1*i2+i1*r2;
		r1 = rr, i1 = ii;
		if (abs(r1) > B || abs(i1) > B) return 0;

	}
	*r = r1, *i = i1;
	return 1;
}

int calc(int *r, int *i)
{
	int r1, r2, i1, i2, op;
	
	if (!term(&r1, &i1)) return 0;
	while (1) {
		if      (*p == '+') op = 1;
		else if (*p == '-') op = 0;
		else break;
		p++;
		if (!term(&r2, &i2)) return 0;
		if (op) r1 += r2, i1 += i2;	else r1 -= r2, i1 -= i2;
		if (abs(r1) > B || abs(i1) > B) return 0;
	}
	*r = r1, *i = i1;
	return 1;
}

int main()
{
	int r, i;

	while (fgets(p = buf, 150, stdin) != NULL) {
		if (!calc(&r, &i)) { puts("overflow"); continue; }
		if (r == 0 && i == 0) puts("0");
		else if (i == 0) printf("%d\n", r);
		else if (r == 0) printf("%di\n", i);
		else             printf("%d%+di\n", r, i);
	}
	return 0;
}

Measured memory_bytes: 1760
using System;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            int N = cin.NextInt();
            bool[] nn = new bool[N];
            int K = cin.NextInt();
            int sum = 0;
            int[] d = new int[K];
            int[][] A = new int[K][];
            for(int i = 0; i < K; i++)
            {
                d[i] = cin.NextInt();
                A[i] = cin.ArrayInt(d[i]);
            }
            for(int i = 0; i < K; i++)
            {
                for(int j = 0; j < A[i].Length; j++)
                {
                    nn[A[i][j] - 1] = true;
                }
            }
            for(int i = 0; i < N; i++)
            {
                if (nn[i] == false)
                {
                    sum++;
                }
            }
            Console.WriteLine(sum);


        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public string[] ArrayNext(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Next();
            }
            return Array;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 18348
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 512345
constexpr ll MOD = 1'000'000'007;
ll fct[N] = {1}, fctinv[N];
ll pw(ll a, ll b){
	ll c = 1;
	do {
		if(b%2) c = c*a % MOD;
		a = a*a % MOD;
	}while(b/=2);
	return c;
}
ll inv(ll a){
	return pw(a, MOD-2);
}
ll cho(ll a, ll b){
	return fct[a] * fctinv[a-b] % MOD;
}
ll cmb(ll a, ll b){
	return cho(a, b) * fctinv[b] % MOD;
}

int main(){
	FOR(i, 1, N) fct[i] = fct[i-1] * i % MOD;
	REP(i, N) fctinv[i] = inv(fct[i]);
	ll n, m; scanf("%lld%lld", &n, &m);
	ll ans = 0;
	REP(i, n+1){
		ll t = MOD + (i%2 ? -1 : 1);
		ll u = cmb(n, i) * cho(m-i, n-i) % MOD;
		DEBUG("%lld %lld\n", t, u);
		ans = (ans + t * u) % MOD;
	}
	ans = ans * cho(m, n) % MOD;
	printf("%lld\n", ans);
}






Measured memory_bytes: 11764
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
//自作関数
template<class T> ll llpow(T x,T n){ll ans=1;while(n--){ans*=x;}return ans;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
    ll n,sekisai[5];
    cin>>n;
    rep(i,5)cin>>sekisai[i];
    ll hito[6]={n,0,0,0,0,0};
    ll time=0;
    ll saiakunoeki=0;
    ll saiaku=1e15;
    rep(i,5){
    if(saiaku>sekisai[i]){
        saiakunoeki=i;
        saiaku=sekisai[i];
        }
    }
    cout<<(n%min({sekisai[0],sekisai[1],sekisai[2],sekisai[3],sekisai[4]})!=0)+n/min({sekisai[0],sekisai[1],sekisai[2],sekisai[3],sekisai[4]})+4<<endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x[] = new int[5];
		int count =0;

		for(int i=0;i<5;i++) {
			x[i]=sc.nextInt();
		}
		for(int i=0;i<5;i++) {
			count +=1;
			if(x[i]==0) {
				break;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 35816
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <set>
#include <map>
#include <numeric>
#include <cassert>

using namespace std;
#define int long long
#define uint unsigned long long
constexpr int MOD = 1000000007;
constexpr int INF = 1145141919810;

#define LOADVEC(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;


void proc();

signed main() {
	ios::sync_with_stdio(false);
	proc();
	return 0;
}

/*
--------------------------------------------------------
--------------------------------------------------------
---------------    template      ----------------------
--------------------------------------------------------
--------------------------------------------------------
*/


void proc() {
	LOAD(int, N);
	LOADVEC(int, A, N);

	std::multimap<int, int> m;
	for (int i = 0; i < N; ++i) {
		m.insert({ A[i],1 });
	}
	while (m.size() > 1) {
		auto itr0 = m.begin();
		auto itr1 = itr0;
		++itr1;
		int mass = itr0->first + itr1->first;
		int nColor;
		if (itr0->first * 2 < itr1->first) {
			nColor = itr1->second;
		}
		else {
			nColor = itr0->second + itr1->second;
		}
		m.erase(itr0);
		m.erase(itr1);
		m.insert({ mass,nColor });
	}
	cout << m.begin()->second;
}


#endif


Measured memory_bytes: 7296
def main():
    N, M, C = list(map(int, input().split()))
    B = list(map(int, input().split()))
    A = []
    for i in range(N):
        A.append(list(map(int, input().split())))

    count = 0
    for a in A:
        result = sum([x * y for x, y in zip(a, B)]) + C
        if result > 0:
            count += 1

    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<stdio.h>

int main()
{
    int A1,A2,A3;
    scanf("%d%d%d",&A1,&A2,&A3);
    if (A1+A2+A3<22)
    {
        printf("win\n");
    }
    else
    printf("bust\n");
    return 0;
}

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

#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) for (int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define bug(x) cerr<<#x<<" is "<<x<<endl

using namespace std;

#define int ll

const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"0\n"; exit(0);}

ll mpow(ll a, ll n, ll mo = mod){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mo;
        a = a*a %mo;
        n>>=1;
    }
    return re;
}

ll inv (ll b, ll mo = mod){
    if (b==1) return b;
    return (mo-mo/b) * inv(mo%b) % mo;
}

const int maxn = 1e5+5;



main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    vector<int> a(3);
    REP(i,3) cin>>a[i];
    sort(ALL(a));
    REP(i,3){
        if (a[i]%2==0) GG();
    }
    cout<<(ll)a[0]*(ll)a[1]<<endl;
    
} 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  int n,x;
  cin>>n>>x;
  int m[n];
  int y(x);
  for(int i(0);i<n;i++){
    cin>>m[i];
    y-=m[i];
  }
  int min(m[0]);
  for(int i(1);i<n;i++){
    if(min>m[i])min=m[i];
  }
  y/=min;
  cout<<n+y<<endl;
  return 0;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    For(i, a, b) {
        string s = to_string(i);
        if (s[0] == s[4] and s[1] == s[3]) cnt++;
    }
    print(cnt);

    return 0;
}


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

int main() {
	int length[10];
	int v1,v2;
	float res;
	while ( scanf("%d",&length[0] ) != -1) {
		for ( int i = 1; i < 10; i++ ) {
			scanf(",%d",&length[i] );
		}
		scanf(",%d,%d", &v1, &v2);
		
		int sum = 0;
		for ( int i = 0; i < 10; i++ )
			sum = sum + length[i];
		res = (float)sum / (1+(float)v2/v1);
		for ( int i = 0; i < 10; i++ ){
			if ( res - length[i] > 0 ) {
				res = res - length[i];
			} else {
				cout << i+1 << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1208
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N;
  while (cin >> N) {
    vector<int> h(N);
    for (int i = 0; i < N; i++) cin >> h[i];
    int res = h[0];
    for (int i = 1; i < N; i++) {
      res += max(0, h[i] - h[i - 1]);
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int sum, num;
		int total = 0;
		
		for(int i = 1; i <= N; i++) {
			sum = 0;
			num = i;
			while(num > 0) {
				sum += num % 10;
				num /= 10;
			}
			if(A <= sum && sum <= B) {
				total += i;
			}
		}
		
		System.out.println(total);
	}

}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(ll i=vv;i<n;i++)
#define FORR(i,n,vv) for(ll i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v))-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)


int main(){

	#ifndef ONLINE_JUDGE
    // for getting input from input.txt	
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	 #endif

    FAST
	//PRECISE



ll n;
cin>>n;
ve <ll> v(n);
ve <ll> dum(1000000+5);
FOR(i,0,n){
cin>>v[i];
dum[v[i]]++;
}
ll tg=v[0];
for(auto i:v)
tg=__gcd(tg,i);
ll ok=1;
FOR(i,2,1000000+5){
	ll tot=0;
	for(ll j=i;j<1000000+5;j+=i)
		tot+=dum[j];
	if(tot>1){
		ok=0;
		break;
	}
}
if(ok)cout<<"pairwise coprime";
else if(tg==1)cout<<"setwise coprime";
else cout<<"not coprime";


return 0;
 }

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

struct UnionFind{
    vector<ll> par;
    
    UnionFind(ll n) : par(n, -1) { }
    void init(ll n) { par.assign(n, -1); }
    
    int root(ll x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }
    
    bool merge(ll x, ll y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(ll x) {
        return -par[root(x)];
    }
};

int main(){
    ll N,M;
    cin >> N >> M;
    ll A[M],B[M];
    for(ll i = 0; i < M; i++){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }
    
    UnionFind uf(N);
    ll cur = (N*(N-1))/2;
    vector<ll> ans;
    for(ll i = 0; i < M; i++){
        ans.push_back(cur);
        
        ll a = A[M-i-1],b = B[M-i-1];
        if(uf.issame(a,b)) continue;
        
        ll sa = uf.size(a),sb = uf.size(b);
        cur -= sa*sb;
        uf.merge(a,b);
    }
    
    for(ll i = ans.size() - 1; i >= 0; i--)
        cout << ans[i] << "\n";
    return 0;
}

Measured memory_bytes: 4596
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s=chomp(readline())
    n=length(s)
    ans="NO"
    for i in 1:n
        for j in i-1:n+1
            if s[1:i-1]*s[max(j,1):end]=="keyence"
                ans="YES"
                break
            end
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 163064
/*    ####################  */
/*   # I_LOVE_THUY_LINH #  */
/*  ####################  */
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define ii pair<int,int>
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define matrix vector<vector<ll>>
#define fir first
#define sec second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define sz(a) int((a).size())
#define ms(s,val) memset(s,val,sizeof(s))
#define bitcount(n) __builtin_popcountll(n)
#define getbit(s,k) ((s >> k)&1)
#define turnbit(s,k) (s | (1<<k))
#define offbit(s,k) (s & ~(1<<k))
#define flipbit(s,k) (s ^ (1<<k))
#define prec(n) fixed<<setprecision(n)
#define sqr(x) (ll)(x)*(ll)(x)
#define lcm(a,b) ((ll)a/__gcd((ll)a,(ll)b)*(ll)(b))
#define gcd(a,b) __gcd(a,b)
using namespace std;
const int INF = int(1e9);
int N, M;
int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> N >> M;
    if (N == M) cout << "Yes";
    else cout << "No";
    return 0;
}

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

int main() {
  double N, M, m;
  cin >> N >> M;
  double A[1010];
  double sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
  }
  m = sum / (4 * M);
  int counter = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] >= m) counter++;
  }
  if (counter < M)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}


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

#define ll long long
#define REP(i, a, b) for (int i = a; i <= b; ++i)

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, y;
	cin >> x >> y;
	int n1 = ((x * 4) - y) / 2;
	int n2 = ((n1 * 2) - y) / 4;
	if((2 * abs(n1)) + (4 * abs(n2)) == y) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	cout << "\n";
	return 0;
}


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


/********************************************************************/
#define M1 1000000007
#define M2 998244353
#define ll long long
#define pll pair<ll,ll>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPR(i,a,b) for(ll i=b-1;i>=a;i--)
#define forr(i,n) for(ll i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#define DB pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
/********************************************************************/
// const int mx = 1e7 + 5;
const double pi = 3.1415926535;
/********************************************************************/
//FAST IO//
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
const int mx = 1e5 + 5;
ll freq[mx] = {};


/********************************************************************/
int main() {
	FAST();
	char ch;
	cin >> ch;
	if (ch >= 'A' && ch <= 'Z')
		cout << 'A';
	if (ch >= 'a' && ch <= 'z')
		cout << 'a';
	return 0;
}

Measured memory_bytes: 3576
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(void)
{
    long long int a,b,c,n,count = 0,i,j,x,count1 = 0 ;
    scanf("%lld",&n);
    
    
    for(x = 1 ; x < n ; x++)
    {
        count += (n - 1) / x;
    }
    printf("%lld\n",count);
    return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>
#include <string.h>
int table[10];
int main()
{
  for(;;){
    int n,i,j;
    scanf("%d",&n);
    if(n == 0) break;
    memset(table,0,sizeof(table));
    for(i=0; i<n; i++){
      scanf("%d",&j);
      table[j]++;
    }
    for(i=0; i<10; i++){
      if(table[i] == 0){
        printf("-");
      }else{
        for(j=0;j<table[i];j++){
          printf("*");
        }
      }
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 572
while line = STDIN.gets
  t500, t1000 = line.chomp.split(' ').map { |item| item.to_f }
  if t500 < 35.5 and t1000 < 71.00 then
    puts 'AAA'
  elsif t500 < 37.5 and t1000 < 77.00 then
    puts 'AA'
  elsif t500 < 40.0 and t1000 < 83.00 then
    puts 'A'
  elsif t500 < 43.0 and t1000 < 89.00 then
    puts 'B'
  elsif t500 < 50.0 and t1000 < 105.00 then
    puts 'C'
  elsif t500 < 55.0 and t1000 < 116.00 then
    puts 'D'
  elsif t500 < 70.0 and t1000 < 148.00 then
    puts 'E'
  else 
    puts 'NA'
  end
end

Measured memory_bytes: 8612
n = int(input())
A = [0] + [int(input()) for i in range(n)]

L = [0] * (n+1)


def b(s):
    #print(s)
    co = 0
    while True:
        if s == 2:
            return co
        elif L[s] == 1:
            return -1
        else:
            L[s] = 1
            s = A[s]
            co += 1

print(b(1))

Measured memory_bytes: 7852