akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main()
{
	int x, y;
	while(1){
		scanf("%d %d", &x, &y);
		if(x==0 && y==0){
			break;
		} else if(x<y){
			printf("%d %d\n", x, y);
		} else {
			printf("%d %d\n", y, x);
		}
	}
	return 0;
}

Measured memory_bytes: 596
import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if(H == 0 && W == 0) break;
			for(int i = 0; i < H; i++) {
				for(int j = 0; j < W; j++) {
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}



Measured memory_bytes: 33092
"use strict";
    
const main = arg => {
  	// NとMを定義する
  	const N = arg.split('\n')[0].split(' ')[0]*1;
  	const M = arg.split('\n')[0].split(' ')[1]*1;  

  	// pathで各行のを切り出す0行目はもう取り出したのでそれ以外
    const path = arg.split('\n').slice(1, M+1);
 	// mapって箱を作る.fillで0埋めをする
    let map = new Array(N).fill(0);
  	// 各要素を切り分けていく
    path.forEach((r)=>
      {
	    let a = r.split(' ')[0]*1 - 1;
      	let b = r.split(' ')[1]*1 - 1;
      	map[a]++;
		map[b]++;
      }
    )
  
    map.forEach(v => console.log(v));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	while(cin>>n){
		rep(i,n){
			cin>>d[i];
		}
		int p = 0;
		unsigned long long int dp[100][22]={0};//dp[i][j]
		dp[0][d[0]] = 1;
		for(int i = 1;i < n-1;i++){
			for(int j = 0;j <=20;j++){
				if(dp[i-1][j]>0){
					if(j+d[i] <=20){
						dp[i][j+d[i]] +=dp[i-1][j];
					}
					if(j-d[i]>=0)
						dp[i][j-d[i]] +=dp[i-1][j];
				}
			}
		}
		int sum = 0;
		for(int i = 0;i <=1000000;i++){
			sum +=1;
		}
		cout <<dp[n-2][d[n-1]]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<int> v;

    for(int i = 0; i < N; ++i){
        int n = 0;
        cin >> n;
        v.push_back(n);
    }
    
    if(is_sorted(v.begin(),v.end())){
        cout << "YES";
        return 0;
    }

    for(int i = 0; i < N; ++i){
        for(int j = i + 1; j < N; ++j){
            auto w = v;
            swap(w.at(i),w.at(j));

            if(is_sorted(w.begin(),w.end())){
                cout << "YES";
                return 0;
            }
        }
    }

    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cmath>
#define int long long
using namespace std;

int n, k;

signed main() {
	cin >> n >> k;
	
	if (n <= 2) { cout << 0 << endl; return 0; }
	
	int ans = 0;
	for (int i = 1; i <= 5; i++) {	//i列目
		for (int j = 1; j < n - 1; j++) {	//j行目
			int num = 1 + 7 * j + i;
			if ((9 * num) % 11 == k) {
				ans += 1 + (n - 2 - j) / 11;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int a,b; cin>>a>>b;
  if(a==2 || b==2) cout<<"No"<<endl;
  else if(a==4 || a==6 || a==9 || a==11){
    if(b==4 || b== 6 || b==9 || b==11) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  else{
    if(b==4 || b== 6 || b==9 || b==11) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
  }
  
  return 0;
}

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

using namespace std;

vector< int > g[150000];
double ee[150000], ans[1500000];

void dfs1(int idx, int par)
{
  double ret = 0;
  int child = 0;

  for(int &to : g[idx]) {
    if(to == par) continue;
    dfs1(to, idx);
    ret += ee[to] + 1.0;
    ++child;
  }
  ee[idx] = 0;
  if(child >= 1) ee[idx] += ret / child;
}

void dfs2(int idx, double d_par, int par)
{
  double ret = 0;
  for(int &to : g[idx]) {
    if(to == par) ret += d_par + 1.0;
    else ret += ee[to] + 1.0;
  }
  ans[idx] = ret / g[idx].size();
  for(int &to : g[idx]) {
    if(to == par) continue;
    dfs2(to, (ret - ee[to] - 1.0) / (g[idx].size() - 1), idx);
  }
}

int main()
{
  int N;
  cin >> N;
  for(int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  if(N <= 2) {
    if(N == 1) cout << 0 << endl;
    else cout << 1 << endl << 1 << endl;
    return (0);
  }

  int root = 0;
  for(int i = 0; i < N; i++) {
    if(g[i].size() >= 2) root = i;
  }

  dfs1(root, -1);
  dfs2(root, 0, -1);
  for(int i = 0; i < N; i++) {
    cout << fixed << setprecision(10) << ans[i] << endl;
  }
}

Measured memory_bytes: 20096
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    そう甘くはないんだな〜w
*/

// from std...
use std::cmp::{
    max, min, Ordering,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::convert::TryInto;
use std::mem::swap;
use std::num::{NonZeroU32, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Index, IndexMut, Mul, MulAssign, Neg, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub,
    SubAssign,
};
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, multinomial, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, Num, NumAssignOps, NumOps, One, Pow, Zero};
use permutohedron::Heap;
use proconio::{
    fastout, input, is_stdin_empty,
    marker::{Bytes, Chars, Isize1, Usize1},
};
use rand::random;

pub const MOD10E9_7: usize = 1000000007;
pub const MOD99_: usize = 998244353;
pub const MAX: usize = std::usize::MAX;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 65;

// code...
// #[fastout]
fn main() {
    input! {
        n: usize,
        mut f: [usize; n]
    }

    f.sort();

    let mut heap = BinaryHeap::new();
    heap.push(f.pop().unwrap());

    let mut ans = 0usize;

    for _ in 1..n {
        let p = f.pop().unwrap();
        ans += heap.pop().unwrap();
        heap.push(p);
        heap.push(p);
    }

    println!("{}", ans);
}



Measured memory_bytes: 7716
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int[] c = new int[n];
        int[] s = new int[n];
        int[] f = new int[n];
        for (int i = 0; i < n - 1; i++) {
            c[i] = sc.nextInt();
            s[i] = sc.nextInt();
            f[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            int t = 0;
            for (int j = i; j < n - 1; j++) {
                if (t < s[j]) {
                    t = s[j];
                } else if (t % f[j] == 0) {
                } else {
                    t = t + f[j] - t % f[j];
                }
                t += c[j];
            }
            System.out.println(t);
        }
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

using namespace std;

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

    int n;
    const int size = (int)('Z' - 'A') + 1;

    while (cin >> n, n) {
        char c;
        vector<int> cnt(size);
        bool find = false;
        int d = 0, idx = 0;

        for (int i = 0; i < n; ++i) {
            cin >> c;
            ++cnt[(int)(c - 'A')];

            auto data = cnt;
            sort(data.begin(), data.end(), greater<int>());

            if (!find && data[0] > data[1] + n - i - 1) {
                find = true;
                for (int j = 0; j < size; ++j)
                    if (cnt[j] == data[0]) idx = j;
                d = i + 1;
            }
        }

        if (find)
            cout << (char)('A' + idx) << ' ' << d << '\n';
        else
            cout << "TIE\n";
    }

    return 0;
}

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

int main()
{
    int a[9];
    for (int i = 1; i <= 9; i++) cin >> a[i];
    int n;
    cin >> n;
    int b;

    rep(i, n){
        cin >> b;
        for (int j = 1; j <= 9; j++) {
            if (a[j] == b) a[j] = 0;
        }
    }
    bool okflag = false;
    if(a[1] == 0 && a[2] == 0 && a[3] == 0) okflag = true;
    if(a[4] == 0 && a[5] == 0 && a[6] == 0) okflag = true;
    if(a[7] == 0 && a[8] == 0 && a[9] == 0) okflag = true;
    if(a[1] == 0 && a[4] == 0 && a[7] == 0) okflag = true;
    if(a[2] == 0 && a[5] == 0 && a[8] == 0) okflag = true;
    if(a[3] == 0 && a[6] == 0 && a[9] == 0) okflag = true;
    if(a[1] == 0 && a[5] == 0 && a[9] == 0) okflag = true;
    if(a[3] == 0 && a[5] == 0 && a[7] == 0) okflag = true;

    if (okflag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using u32 = uint32_t;

int main() {
	u32 N;
	cin >> N;
	
	u32 smax = 0;
	map<string, u32> Ss;
	
	for(uint i=0; i<N; i++) {
		string S;
		cin >> S;
		
		u32 cnt;		
		if(Ss.find(S) != Ss.end()) {
			cnt = Ss.at(S) + 1;
			Ss.erase(S);
		} else {
			cnt = 1;
		}
		
		smax = max(smax, cnt);
		Ss[S] = cnt;
	}
	
	for(auto itr = Ss.begin(); itr != Ss.end(); ++itr) {
		auto cnt = itr->second;
		if(cnt >= smax) {
			cout << itr->first << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
const long long INF = 1LL << 60;
const int MOD = 1000000007;
long long kaijo(long long x){
    ll p=1;
    while(x!=0){
        p*= x;
        p%=MOD;
        x--;
    }
    return p;
}
signed main(void){
    int n; cin>>n;
    int s[2*n];
    rep(i,2*n) {char a; cin>>a; if(a == 'W') s[i]=0; else s[i]=1;}
    int c[2*n+1];
    vector <int> res(2*n); 
    int a=0;
    c[0]=0;
    rep(i,2*n) { if((a+s[i])%2 && a>=0) {a++; res[i] = 1;} else {a--; res[i] = 0;} }
    int ans = 0;
    int cnt = 0;
    ans = 1;
    
    if(count(res.begin(), res.end(),1) != count(res.begin(), res.end(),0)) {cout<<0<<endl; return 0;}
    bool b=false;
    rep(i,2*n){
        if(res[i]) b=true;  
        if(!res[i]&&cnt!=0) ans *= cnt;
        if(b) cnt+=res[i] ? 1: -1;
        ans%=MOD;
    }
    cout<<(ans*kaijo(n))%MOD<<endl;
}


Measured memory_bytes: 3328
/*
    author : Divyansh Gupta
*/

#include <iostream>
#include <iomanip>
#include <cstring>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <utility>
#include <map>

using namespace std;

void print_err() {
	cerr<<"\n";
}

template <class T,class... Arg>
void print_err(T x,Arg&&... args) {
	cerr<<x<<" ";
	print_err(args...);
}

#ifdef local
#define debug(...) print_err(__VA_ARGS__)
#else
#define debug(...)
#endif

#define test_case int test_cases;\
                cin>>test_cases;\
                while(test_cases--)
#define lu(var,l,r) for(var=l;var<r;var++)
#define ld(var,r,l) for(var=r;var>=l;var--)
#define ll long long
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>                	
#define br cout<<"\n"
#define sp cout<<" "
#define pr cout<<
#define in cin>>
#define f first
#define s second                    
#define mod 1000000007
            
double expected(int n,int x,int y,int z,vi &A,vector<vector<vector<double> > > &dp) {
	if(x == 0 && y == 0 && z == 0) {
		return 0;
	}
	if(x < 0 || y < 0 || z < 0) {
		return 0;
	}
	if(dp[x][y][z] > -0.9) {
		return dp[x][y][z];
	}
	double ways = n + x * expected(n,x-1,y,z,A,dp) + y * expected(n,x+1,y-1,z,A,dp) + z * expected(n,x,y+1,z-1,A,dp);
	return dp[x][y][z] = ways / (x + y + z);
}

void solve(){
	int n,x,i;
	vi A,X(4,0);
	A.pb(0);
	in n;
	lu(i,1,n+1) {
		in x;
		A.pb(x);
		X[x]++;
	}
	vector<vector<vector<double> > > dp(301,vector<vector<double> >(301,vector<double>(301,-1.0)));
	pr setprecision(14)<<expected(n,X[1],X[2],X[3],A,dp);
	br;
}

int main(){
    // test_case
    solve();
    return 0;
}

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

using namespace std;

using int64 = long long;

int main()
{
  string S;
  cin >> S;
  bool f = S.front() == S.back();
  bool g = S.size() % 2 == 0;
  if(f ^ g) puts("Second");
  else puts("First");
}

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

int main()
{
    int64_t a, b;
    cin >> a >> b;
    int64_t i = 1;
    for (; a - b != -i - 1; i++)
    {
    }
    cout << i * (i + 1) / 2 - a << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
n = int(input())
a = list(map(int,input().split()))
a.sort()
if a[0] == 0:
  print(0)
  sys.exit()
ans = 1
for i in range(n):
  ans *= a[i]
  if ans > 10**18:
    print(-1)
    sys.exit()
print(ans)


Measured memory_bytes: 21596
import java.util.Scanner;

public class Main {

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

		int answer = 0;
		if (A == B) {
			answer = C;
		} else if (B == C) {
			answer = A;
		} else {
			answer = B;
		}
		System.out.println(answer);
	}

}

Measured memory_bytes: 23252
# Code for A - ∴ (Therefore)
# Use input() to fetch data from STDIN
n = int(input())
if n % 10 in [2,4,5,7,9]:
    print("hon")
elif n % 10 in [0, 1, 6, 8]:
    print("pon")
else:
    print("bon")


Measured memory_bytes: 9164
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int k;
int n;
int co;
char a[11][3];
int cost[11]={0};//ツ使ツづつスツ値ツづ可記ツつオツづーツづつつッツづゥ
char at[101]="\0";//ツ催ャツづつスツ値ツづーツ格ツ納
int anst[100000001];//ツ環ョツ青ャツつオツつスツ値ツづーツ格ツ納
void solve(int p){
  int i;
  char temp[11];
  if(k<=p){
    // printf("p...%d k...%d\n",p,k);
    if(anst[atoi(at)]!=1){
      anst[atoi(at)]=1;
      //  printf("at...%s\n",at);
      co++;
    }
    return;
  }
  for(i=0;i<n;i++){
    if(cost[i]!=1){
      //   printf("i...%d\n",atoi(a[i]));
      strcpy(temp,at);
      strcat(at,a[i]);
      cost[i]=1;
      solve(p+1);
      cost[i]=0;
      strcpy(at,temp);
    }
  }

  return;

}
main(){
  int i,j;
  while(1){
    scanf("%d",&n);
    scanf("%d",&k);
    if(n==0 && k==0) break;
    //memset(at,0,sizeof(at));
    memset(anst,0,sizeof(anst));
    //memset(cost,0,sizeof(cost));
    co=0;
    for(i=0;i<n;i++)
      scanf("%s",a[i]);
    
    solve(0);
    printf("%d\n",co);
  }
    
  return 0;
}

Measured memory_bytes: 0
/* 
 * File:   main.c
 * Author: s1252007
 *
 * Created on July 27, 2018, 12:05 PM
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 5000001

/*
 * 
 */

int H, Heap[MAX];

void maxHeapify(int i);
int extract();
void insert(int key);

int main(int argc, char** argv) {
    int key;
    char command[15];
    while (1)
    {
        scanf("%s", command);
        if (strcmp(command, "extract") == 0) printf("%d\n", extract());
        if (strcmp(command, "insert") == 0)
        {
            scanf("%d", &key);
            insert(key);
        }
        else if (strcmp(command, "end") == 0) break;
    }
    return (EXIT_SUCCESS);
}

void maxHeapify(int i)
{
    int left, right, max, temp;
    left = i*2;
    right = i*2+1;
    
    if (left <= H && Heap[left] > Heap[i]) max = left;
    else max = i;
    if (right <= H && Heap[right] > Heap[max]) max = right;
    
    if (max != i)
    {
        temp = Heap[i];
        Heap[i] = Heap[max];
        Heap[max] = temp;
        maxHeapify(max);
    }
}

int extract()
{
    int max;
    if (H < 1) return -1;
    max = Heap[1];
    Heap[1] = Heap[H--];
    maxHeapify(1);
    return max;
}

void insert(int key)
{
    Heap[++H] = -1;
    int i = H, temp;
    if (key < Heap[i]) return;
    Heap[i] = key;
    while ( i > 1 && Heap[i/2] < Heap[i])
    {
        temp = Heap[i];
        Heap[i] = Heap[i/2];
        Heap[i/2] = temp;
        i = i/2;
    }
}





Measured memory_bytes: 5680
D,G=map(int,input().split())
#[1問当たりの点数,問題数,ﾎﾞｰﾅｽ含むDの点数]
L=[]

for i in range(10):
    if i<D:
        p,c=map(int,input().split())
        L.append([100*(i+1),p,100*(i+1)*p+c])
    else:
        L.append([100*(i+1),0,0])
L.sort(reverse=True)
#print(L)

ans=100000000
for i in range(2**D):
    N=i
    Sco=0
    Prb=0
    l=[0 for i in range(10)]
    for j in range(10):
        if N//(2**(9-j))==1:
            Sco+=L[j][2]
            Prb+=L[j][1]
            l[j]=1
        N%=(2**(9-j))
    if Sco>=G: 
        if ans>Prb:
            ans=Prb
    else:
        for k in range(10):
            if l[k]==0:
                if (L[k][1]-1)*(L[k][0])+Sco>=G:
                    if (G-Sco)%(L[k][0])==0:
                        Prb+=((G-Sco)//(L[k][0]))
                        if ans>Prb:
                            ans=Prb
                    else:
                        Prb+=((G-Sco)//(L[k][0]))+1
                        if ans>Prb:
                            ans=Prb
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <climits>
#include <vector>
#include <cmath>

using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> h(N);

	for(int i = 0; i < N; i++) {
		int cur;
		cin >> cur;
		h[i] = cur;
	}


	vector<int> cost(N, INT_MAX);

	cost[0] = 0;

	cost[1] = abs(h[1] - h[0]);
	for (int i = 2; i < N; i++) {
		cost[i] = min(cost[i - 2] + abs(h[i - 2] - h[i])
			, cost[i - 1] + abs(h[i - 1] - h[i]));
	}
	cout << cost[N - 1] << endl;



	return 0;
}


Measured memory_bytes: 1024
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  first := nextInt()
  second := nextInt()
  third := nextInt()
  count := 0 
  for i:= first; i <= second; i++ { 
    if third % i == 0 {
        count++
    }   
  }
  fmt.Println(count)
}


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


Measured memory_bytes: 1124
#abc145c

n=int(raw_input())
l=[]
for i in range(n):
 x,y=map(int,raw_input().split())
 l.append([x,y])
res=0
for i in range(n):
 for j in range(n):
  res+=((l[i][0]-l[j][0])**2+(l[i][1]-l[j][1])**2)**0.5
print res/n


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

int main(){
  int H,A;
  cin>>H>>A;
  int c;
  c = H/A - (A - H%A)/A + 1;
  cout<<c<<endl;
  //H/A の切り上げ。ceil関数か(H + A − 1)/A の切り捨て
}

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

void rec(char map[8][8], int x, int y) {
  static int d[4][2] = {{1,0},{0,1},{-1,0},{0,-1}};
  map[y][x] = '0';
  for(int i = 0; i < 4; i++) {
    for(int j = 1; j <= 3; j++) {
      int nx = x + d[i][0]*j;
      int ny = y + d[i][1]*j;

      if(nx < 0 || nx >= 8
	 || ny < 0 || ny >= 8) continue;

      if(map[ny][nx] == '1') rec(map, nx, ny);
    }
  }
}

int main() {
  int n;
  cin >> n;
  for(int c = 1; c <= n; c++) {
    char map[8][8];
    for(int i = 0; i < 8; i++) {
      for(int j = 0; j < 8; j++) {
	cin >> map[i][j];
      }
    }
    int x, y;
    cin >> x >> y;
    x -= 1;
    y -= 1;
    rec(map, x, y);

    cout << "Data " << c << ":" << endl;
    for(int i = 0; i < 8; i++) {
      for(int j = 0; j < 8; j++) {
	cout << map[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main(){

  int size;

  cin >> size;

  int *array = new int[size];

  for(int i = 0; i < size; i++){
    cin >> array[i];
  }

  int temp, count = 0, flag = 1, i = 0;

  while(flag){
    flag = 0;
    for(int j = size - 1; j >= i + 1; j--){
      if(array[j] < array[j - 1]){
        temp = array[j];
        array[j] = array[j - 1];
        array[j - 1] = temp;
        flag = 1;
        count++;
      }
    }
    i++;
  }

  for(int i = 0; i < size - 1; i++){
    cout << array[i] << " ";
  }
  cout << array[size - 1] << endl;

  cout << count << endl;

  delete[] array;
  return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <list>
#include <stdio.h>
 
using namespace std;
 
int main() {
    int i,j;
    int n;
    int x;
    char command[16];
    list<int> l;
    list<int>::iterator it_l; // lのイテレータ作成


    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%s%d", command, &x);
        if(command[0] == 'i'){
            //cin >> x;
            l.push_front(x);
        }
        else if(command[0] == 'd' && command[6] == '\0'){
            //cin >> x;
            it_l = l.begin(); // lのイテレータを最初の要素に合わせる
            while(it_l != l.end()){ //ｘをもつ最初の要素（ノード）を探して削除
                if((*it_l)==x){
					l.erase(it_l);
					break;
                    /*このbreakが大切。　要素を消した後は、その要素で it_l++ すると　
                    「list iterator not incrementable」が出てできない
                    消した後も探索したい場合は、消す前にほかのに保存して
                    イテレーターを進めておくこと。
                    */
                }
                it_l++; 
 
            }
        }
        else if(command[0] == 'd' && command[6] == 'F'){
            l.pop_front();
        }
        else if(command[0] == 'd' && command[6] == 'L'){
            l.pop_back();
        }
        //else {cout << "error" << endl; }
    }
    
        //出力普通版
        /*
        it_l = l.begin(); // lのイテレータを最初の要素に合わせる
    while(it_l != l.end()){ //出力
        cout << *it_l;
        it_l++;
        if(it_l == l.end()){ //悪い書き方。　だが適切な改行を出すのにこれが簡単
            cout << endl;
            break;
        } 
        cout << ' ';
    }
        */
 
        //出力三項演算子版
        it_l = l.begin(); // lのイテレータを最初の要素に合わせる
    while(it_l != l.end()){ //出力
                //printf("%d", *it_l);
				cout << *it_l;
                it_l++;
                (it_l == l.end()) ? printf("\n") : printf(" ") ;
    }
 
        return 0;
}
 

Measured memory_bytes: 32364
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()

bool comp(const pii &l, const pii &r) {
    if (l.first < r.first) return true;
    else if (l.first == r.first && l.second < r.second) return true;
    else return false;
}

int main() {
    int N, M, a, b;
    cin >> N >> M;
    vector<pii> pi;
    REP(i, M) {
        cin >> a >> b;
        pi.push_back({a, b});
    }
    sort(ALL(pi), comp);

    int ans = 1, left = 0, right = N + 1;
    for (auto p : pi) {
        if (p.first == left) continue;

        if (p.first >= right) {
            ans++;
            right = p.second;
        }
        else {
            right = min(p.second, right);
        }
        left = p.first;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

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

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int K; std::cin >> K;
  int A, B; std::cin >> A >> B;
  bool flag = false;
  for(int x=A; x<=B; x++) {
    if ( x % K == 0 ) flag = true;
  }
  if ( flag ) std::cout << "OK" << std::endl;
  else std::cout << "NG" << std::endl;
  return 0;
}



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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		String[]s = stdIn.next().split("");

		boolean flag = true;

		String t = "coffee";


		if(!s[2].equals(s[3]) || !s[4].equals(s[5])) {
			flag = false;
		}

		if(flag) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}



	}

}


Measured memory_bytes: 22868
#include <stdio.h>

int main(void) {
	int r, g, b;
	int x;

	scanf("%d %d %d", &r, &g, &b);
	x = r * 100 + g * 10 + b;

	if (x % 4 == 0) printf("YES\n");
	else printf("NO\n");

	return 0;
}

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

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


Measured memory_bytes: 2620
#include <iostream>
#include <string>
#include <iomanip>
#include <ios>
using namespace std;
int main(void){
  string a,b,c;
  cin >> a >> b >> c;
  
  int la = a.length();
  int lb = b.length();
  
  if(a[la - 1] == b[0] && b[lb - 1] == c[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
  return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:


string s;
ll ans;
	
int main(void){
	cin >> s;
	int n=s.size();
	rep(mask,bit(n-1)){
		ll cur=0LL,in=0LL;
		rep(i,n){
			in=10*in+(s[i]-'0');
			if(mask&bit(i)) cur+=in,in=0LL;
		}
		cur+=in;
		ans+=cur;
	}
	cout << ans << endl;
	return 0;
}

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

int red[100001], ball[100001];

int main(void) {
	int N, M, x, y, ans = 0;
	cin.tie(0);
	ios::sync_with_stdio(false);
	red[0] = 1;
	cin >> N >> M;
	fill(ball, ball + N, 1);
	//for (int i = 0; i < N; i++) cout << red[i] << " ";
	//cout << endl;
	for (int i = 0; i < M; i++) {
		cin >> x >> y;
		if (ball[x-1] == 1 && red[x-1]) {
			ball[x-1]--;
			red[x-1] = 0;
			ball[y-1]++;
			red[y-1] = 1;
			//for (int i = 0; i < N; i++) cout << red[i] << " ";
			//cout << endl;
		} else if (ball[x-1] == 1 && !red[x-1]) {
			ball[x-1]--;
			ball[y-1]++;
		} else if (ball[x-1] > 1) {
			ball[x-1]--;
			ball[y-1]++;
			if(red[x-1]) red[y-1]=1;
			//for (int i = 0; i < N; i++) cout << red[i] << " ";
			//cout << endl;
		}
	}
		//for (int i = 0; i < N; i++) cout << red[i] << " ";
		//cout << endl;
		ans = count(red, red + N, 1);
		cout << ans << endl;
		return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long s64;

const int MaxN = 2000;
const int MaxM = 2000;
const int M = 1000000007;

inline int add(int a, const int &b)
{
	a += b;
	return a >= M ? a - M : a;
}
inline int dec(int a, const int &b)
{
	a -= b;
	return a < 0 ? a + M : a;
}

int n, m, nK;
int f[MaxN + MaxM][MaxN + 1];

int g[MaxN + 1];

int res = 0;

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

	int l = (n + m - 1) / --nK;
	int p = n % nK, q = (m - 1) % nK;

	f[0][0] = 1;
	for (int i = 1; i <= l; ++i)
	{
		int now = min(i * nK, n);

		g[0] = f[i - 1][0];
		for (int j = 1; j <= now; ++j)
			g[j] = add(g[j - 1], f[i - 1][j]);

		for (int j = 0; j <= now; ++j)
		{
			int up = min(nK, j);
			int a = up == j ? 0 : g[j - up - 1];
			int b = g[j];
			f[i][j] = dec(b, a);
		}

		for (int j = 0; j <= now; ++j)
		{
			if (j % nK != p || (i * nK - j) % nK != q)
				continue;
			if (i * nK - j < m)
				res = add(res, dec(f[i][j], f[i - 1][j]));
		}
	}

	cout << res << endl;

	return 0;
}

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

using namespace std;

int n,m;

int main() {
    cin>>n;
    vector<int> b(n);
    for(int i=0;i<n;i++) cin >> b[i];
    int bs=n;
    vector<int> ret;
    int time;
    while(bs>0)
    {
        time = -1;
        for(int i=0;i<bs;i++) if(i+1==b[i]) time = i;
        if(time>=0)
        {
            ret.push_back(time+1);
            b.erase(b.begin()+time);
            bs--;
        }
        else
        {
            cout << -1;return 0;
        }
    }
    reverse(ret.begin(),ret.end());
    for(int x:ret) cout << x << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    int n;
    vector<LL> a;
    LL tmp_a;
    LL ans=0;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp_a;
        a.push_back(tmp_a);
    }
    sort(a.begin(), a.end());

    int min_idx=0;
    int max_idx=a.size()-1;
    LL left=a[min_idx];
    LL right=a[max_idx];
    ans+=right-left;
    min_idx++;
    max_idx--;

    //cout << left << " " << right << endl;
    vector<LL> cand(4);
    while(min_idx<=max_idx){
        cand[0]=abs(left-a[min_idx]);
        cand[1]=abs(left-a[max_idx]);
        cand[2]=abs(right-a[min_idx]);
        cand[3]=abs(right-a[max_idx]);
        int max_value =*max_element(cand.begin(),cand.end());
        for(int i=0; i<4; i++){
            if(max_value==cand[i]){
                ans+=cand[i];
                if(i==0){
                    left=a[min_idx];
                    min_idx++;
                }else if(i==1){
                    left=a[max_idx];
                    max_idx--;
                }else if(i==2){
                    right=a[min_idx];
                    min_idx++;
                }else{
                    right=a[max_idx];
                    max_idx--;
                }
                //cout << left << " " << right << endl;
                break;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

#define pb push_back
#define mp make_pair
#define ff first
#define INF LLONG_MAX
#define ss second
#define range(x) (x).begin(), (x).end()

#define vll vector<ll>
#define vstr vector<string>
#define vvll vector<vector<ll>>
#define vp vector<pll>
#define vvp vector<vp>

#define mapll map<ll, ll>
#define mapstr smap<string, ll>
#define setll set<ll>
#define setstr set<string>

#define digits(N) floor(log10(N)) + 1
const ll mod = 1e9 + 7;

#define FLUSH fflush(stdout)
#define arr1d_debug(arr, i, ans) \
    cout << #arr << '[' << i << "] = " << ans << ' ' << flush
#define arr2d_debug(arr, i, j, ans) \
    cout << #arr << '[' << i << ']' << '[' << j << "] = " << ans << ' ' << flush
#define debug1(x) \
    cout << #x << " = " << x << endl
#define debug2(x, y) \
    cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define debug3(x, y, z) \
    cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define newline cout << endl

#define print_container(container) \
    for (auto &it : container)     \
        cout << it << ' ';         \
    newline;

#define IOS                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
/*
    std : merge, rotate, unique, generate, fill, iota
*/
ll ll_scan()
{
    ll x;
    cin >> x;
    return x;
}
string str_scan()
{
    string x;
    cin >> x;
    return x;
}

ll inefficiency(ll x, ll y, vvll &prefix_table)
{
    ll ans = 0;
    for (ll i = 0; i < 101; i++)
    {
        ll temp = prefix_table[y + 1][i] - prefix_table[x][i];
        if (temp > 1)
            ans += temp;
    }
    return ans;
}

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    IOS;
    ll t = 1;
    // t = ll_scan();
    while (t--)
    {
        ll x = 1, k = 10;
        ll n = ll_scan();
        list<bool> ans;
        if (n == 0)
            cout << 0;
        else
            while (n != 0)
            {
                bool bit = n % 2;
                ans.push_front(bit);
                n = ceil(n / -2.0);
                x *= -2;
            }
        for (auto &it : ans)
            cout << it;
        // newline;
    }
}

Measured memory_bytes: 3728
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn calc_score(c: &Vec<i64>, t: &Vec<usize>, s: &Vec<Vec<i64>>) -> i64 {
    let d = s.len();
    let mut score = 0;
    let mut last = vec![0; 26];
    for i in 0..d {
        score += s[i][t[i]];
        last[t[i]] = i + 1;
        for qi in 0..26 {
            score -= c[qi] * (i as i64 + 1 - last[qi] as i64);
        }
    }
    score
}

fn main() {
    let d = read::<usize>();
    let c = read_vec::<i64>();
    let mut s = vec![vec![]; d];
    for i in 0..d {
        s[i] = read_vec::<i64>();
    }

    let mut answers = vec![];

    for i in 0..d {
        let mut max_idx = 0;
        for j in 0..26 {
            if s[i][j] > s[i][max_idx] {
                max_idx = j;
            }
        }
        answers.push(max_idx);
    }
    let mut cur_score = calc_score(&c, &answers, &s);

    let mut xor = Xorshift::new();
    for _ in 0..1000 {
        let rd = xor.next() as usize % d;
        let rq = xor.next() as usize % 26;

        let prev = answers[rd];
        answers[rd] = rq;
        let score = calc_score(&c, &answers, &s);
        if score > cur_score {
            cur_score = score;
        } else {
            answers[rd] = prev;
        }
    }

    for ans in answers {
        println!("{}", ans + 1);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[derive(Debug)]
pub struct Xorshift {
    seed: u64,
}
impl Xorshift {
    pub fn new() -> Xorshift {
        Xorshift {
            seed: 0xf0fb588ca2196dac,
        }
    }
    pub fn with_seed(seed: u64) -> Xorshift {
        Xorshift { seed: seed }
    }
    #[inline]
    pub fn next(&mut self) -> u64 {
        self.seed = self.seed ^ (self.seed << 13);
        self.seed = self.seed ^ (self.seed >> 7);
        self.seed = self.seed ^ (self.seed << 17);
        self.seed
    }
    #[inline]
    pub fn rand(&mut self, m: u64) -> u64 {
        self.next() % m
    }
}


Measured memory_bytes: 2280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  int a, b, _;
  cin >> a >> b >> _;
  cout << (a * b) / 2 << "\n";
}

Measured memory_bytes: 384
import sys
input = lambda: sys.stdin.readline().rstrip()
def scc(E):
    n = len(E)
    iE = [[] for _ in range(n)]
    for i, e in enumerate(E):
        for v in e:
            iE[v].append(i)
    T = []
    done = [0] * n # 0 -> 1 -> 2
    ct = 0
    for i0 in range(n):
        if done[i0]: continue
        Q = [~i0, i0]
        while Q:
            i = Q.pop()
            if i < 0:
                if done[~i] == 2: continue
                done[~i] = 2
                T.append(~i)
                ct += 1
                continue
            if i >= 0:
                if done[i]: continue
                done[i] = 1
            for j in E[i]:
                if done[j]: continue
                Q.append(~j)
                Q.append(j)
    
    done = [0] * n
    SCC = []
    for i0 in T[::-1]:
        if done[i0]: continue
        L = []
        Q = [~i0, i0]
        while Q:
            i = Q.pop()
            if i < 0:
                if done[~i] == 2: continue
                done[~i] = 2
                L.append(~i)
                continue
            if i >= 0:
                if done[i]: continue
                done[i] = 1
            for j in iE[i]:
                if done[j]: continue
                Q.append(~j)
                Q.append(j)
        SCC.append(L)
    return SCC

N, M = map(int, input().split())
X = [[] for i in range(N)]
for i in range(M):
    x, y = map(int, input().split())
    X[x].append(y)
S = scc(X)
print(len(S))
for s in S:
    print(*[len(s)] + s)


Measured memory_bytes: 225164
#include <iostream>
#include <cstdio>
using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to)
#define MAX_PRIME 160000
int main() {
	bool p[MAX_PRIME];
	p[0] = p[1] = 0;
	rep2(i,2,MAX_PRIME) {
		p[i] = 1;
	}
	rep(i,400) {
		if(p[i]) {
			for(int j = 2; i * j < MAX_PRIME; j++) {
				p[i * j] = 0;
			}
		}
	}
	int ret[10010];
	ret[0] = 0;
	int cnt = 0;
	rep2(i,1,10001) {
		while(!p[cnt]) {
			cnt++;
		}
		ret[i] = ret[i-1] + cnt;
		cnt++;
	}
	int n;
	while(cin >> n && n) {
		cout << ret[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 1352
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
  let mut s:Vec<char> = read::<String>().chars().collect();
  s.dedup();
  println!("{}", if s.len() >= 2 {"Yes"} else {"No"});
}

Measured memory_bytes: 2172
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << '\n'
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

long double a, b, x;

long double retV(long double theta) {
    if (a * tan(theta) > b) {
        return a * b * b * tan(pi / 2.0 - theta) / 2.0;
    } else {
        return a * a * b - a * a * a * tan(theta) / 2.0;
    }
}

bool isOK(long double mid, long double key) {
    if (retV(mid) >= key) {
        return true;
    } else {
        return false;
    }
}

int main() {

    cin >> a >> b >> x;

    long double ng = pi / 2.0, ok = 0;
    int count = 0;

    while (true) {
        count++;
        long double mid = (ok + ng) / 2.0;

        if (isOK(mid, x)) {
            ok = mid;
        } else {
            ng = mid;
        }

        if (count == 10000) {
            cout << fixed << setprecision(10) << (ok / 2 / pi) * 360 << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 300005
#define x first
#define y second
using namespace std;
int n,ans,h,w;
pair<int,int> p[N];

const int M=(1<<20)+3;
const int offset=(1<<19)+1; 

int addtag[M],mx[M];
void add(int k,int val){
	addtag[k]+=val,mx[k]+=val;
}
void update(int k){
	while(k!=0){
		if((k<<1)<(1<<20)) mx[k]=max(mx[k<<1],mx[k<<1|1])+addtag[k];
		k>>=1;
	}
}
void pushdown(int k){
	if(k!=1) pushdown(k>>1);
	if(addtag[k]==0||(k<<1)>=(1<<20)) return;
	add(k<<1,addtag[k]),add((k<<1)|1,addtag[k]);
	addtag[k]=0;
}
void modify(int k,int l,int r,int val){//l,r记得加上2^17 区间加 
	pushdown(l);pushdown(r);
	for(int tl=l-1,tr=r+1;(tl^tr)!=1;tl>>=1,tr>>=1){
		if((tl&1)==0) add(tl^1,val);
		if((tr&1)==1) add(tr^1,val);
	}
	update(l);update(r);
}

int sta1[N],sta2[N],top1,top2;
void solve(){
	memset(addtag,0,sizeof(addtag));
	memset(mx,0,sizeof(mx));
	sort(p+1,p+n+1);p[0].x=0,p[n+1].x=w;
	modify(1,0+offset,0+offset,h);
	top1=top2=0;sta1[0]=sta2[0]=0;
	for(int i=1;i<=n+1;i++){
		ans=max(ans,mx[1]+p[i].x);
		if(p[i].y*2<h){
			modify(1,i+offset,i+offset,h-p[i].x);
			modify(1,sta2[top2]+offset,i-1+offset,-p[i].y);
			while(top2>0&&p[sta2[top2]].y<=p[i].y){
				modify(1,sta2[top2-1]+offset,sta2[top2]-1+offset,-p[i].y+p[sta2[top2]].y);
				top2--;
			}
			sta2[++top2]=i;
		}else{
			modify(1,i+offset,i+offset,h-p[i].x);
			modify(1,sta1[top1]+offset,i-1+offset,p[i].y-h);
			while(top1>0&&p[sta1[top1]].y>=p[i].y){
				modify(1,sta1[top1-1]+offset,sta1[top1]-1+offset,p[i].y-p[sta1[top1]].y);
				top1--;
			}
			sta1[++top1]=i;
		}
	}
}
int main(){
	scanf("%d%d%d",&w,&h,&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&p[i].x,&p[i].y);
	solve();
	for(int i=1;i<=n;i++) swap(p[i].x,p[i].y);
	swap(h,w);
	solve();
	cout<<ans*2<<endl;
	return 0;
} 

Measured memory_bytes: 11648
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

int a = 0, b = 0, c = 1, x = 0, y = 0, z = 0, maxy = 0, mini = 9999, counter = 0,startp=0,endp=0,checker=0;
std::vector<unsigned long long int> vec{}, vecsec{};
unsigned long long int iremono[101];
std::vector<int>zerolist{};

bool okada = false,okada2=false;
std::string output, output2, input, nyahhoi;
char kakunou[101][101] = {};
int kakunou2[50][50] = {};
int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int main()
{
	cin >> a;
	for (int i = 1; i <= a;i++) {
		cin >> iremono[i];
	}
	iremono[0] = 0;
	iremono[a+1] = 0;
	for (int i = 1; i <=a; i++) {
		if (iremono[i - 1] < iremono[i]) {
			counter += iremono[i]-iremono[i-1];
		}
	}

		cout << counter << endl;
	
}









Measured memory_bytes: 256