akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			//			solveA();
			//			solveB();
			solveC();
			// solveD();
			// solveE();
			// solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int numN = nextInt();
		if (numN < 1200) {
			out.print("ABC");
		} else {
			out.print("ARC");
		}

	}

	private void solveB() {
		String wk = next();

		int first = wk.indexOf("A");
		int last = wk.lastIndexOf("Z");

		String res = wk.substring(first, last + 1);

		out.println(res.length());
	}

	private void solveC() {
		long numN = nextLong();

		long ope = 0;
		long opeNum = (numN / 11) * 2;
		int opeHasu = (numN % 11) == 0 ? 0 : (numN % 11) > 6 ? 2 : 1;
		ope = (opeNum + opeHasu);

		out.println(ope);
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	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;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	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();
		}
	}
}

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

using namespace std;

const int MaxN = 200005;
const long long oo = 1e18;

struct SegmentTree
{
    long long Min[4 * MaxN][3], Lazy[4 * MaxN];
    int Low[4 * MaxN], High[4 * MaxN];
    void InitTree(int x, int L, int R)
    {
        Low[x] = L;
        High[x] = R;
        Lazy[x] = 0;
        Min[x][0] = Min[x][1] = Min[x][2] = oo;
        if (L == R)
        {
            return;
        }
        int Mid = (L + R) / 2;
        InitTree(x * 2, L, Mid);
        InitTree(x * 2 + 1, Mid + 1, R);
    
    }
    void doLazy(int x)
    {
        if (Low[x] != High[x])
        {
            Lazy[x * 2] += Lazy[x];
            Lazy[x * 2 + 1] += Lazy[x];
        }
        for (int i = 0; i < 3; i++)
        {
            Min[x][i] += Lazy[x];
        }
        Lazy[x] = 0;
    }
    void Update(int x, int pos, long long Val)
    {
        doLazy(x);
        if (Low[x] > pos || pos > High[x])
            {return;}
        if (Low[x] == High[x])
        {
            if (Min[x][0] > Val)
            {
                Min[x][0] = Val;
                Min[x][1] = Val - Low[x];
                Min[x][2] = Val + Low[x];
            }
            return;
        }
        Update(x * 2, pos, Val);
        Update(x * 2 + 1, pos, Val);
        for (int i = 0; i < 3; i++)
        {    Min[x][i] = min(Min[x * 2][i], Min[x * 2 + 1][i]);
    }}
    long long Get(int x, int L, int R, int type)
    {
        doLazy(x);
        if (Low[x] > R || High[x] < L)
        {
            return oo;
        }
        if (Low[x] >= L && High[x] <= R)
        {
            return Min[x][type];
        }
        return min(Get(x * 2, L, R, type), Get(x * 2 + 1, L, R, type));
    }
};

int n, q, A, B;
int a[MaxN];
SegmentTree ST;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> q >> A >> B;
    for (int i = 1; i <= q; i++)
    {
        cin >> a[i];
    }
    ST.InitTree(1, 1, n);
    ST.Update(1, B, abs(A - a[1]));
    ST.Update(1, A, abs(B - a[1]));
    for (int i = 2; i <= q; i++)
    {
        long long Min = min(ST.Get(1, 1, a[i], 1) + a[i], ST.Get(1, a[i], n, 2) - a[i]);
        ST.Lazy[1] += abs(a[i - 1] - a[i]);
        ST.doLazy(1);
        ST.Update(1, a[i - 1], Min);
    }
    cout << ST.Min[1][0];
    return 0;
}


Measured memory_bytes: 27648
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <limits.h>
#include <stdio.h>
using namespace std;
 
int main()
{
    std::string s;
    cin >> s;
    /*
    int a[n];
    std::vector<int> v;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        a[i] = tmp;
    }
    */
 
    if(s[s.length()-1] == 's') cout << s << "es" << endl;
    else cout << s << "s" << endl;
    
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int count = 0;

  if(s[0] == '1') count++;
  if(s[1] == '1') count++;
  if(s[2] == '1') count++;

  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()
#define INF 2000000000

int main() {
    int n;
    scanf("%d", &n);
    int i=1;
    while (i*i <= n) {
        i++;
    }
    i--;
    printf("%d\n", i*i);
}

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, Q;
  cin >> N >> Q;
  vector<int> A(N - 1), B(N - 1);
  vector<vector<int>> G(N);
  for (int i = 0; i < N - 1; i++) {
    cin >> A[i] >> B[i];
    A[i]--, B[i]--;
    G[A[i]].emplace_back(B[i]);
    G[B[i]].emplace_back(A[i]);
  }
  vector<int> P(Q), X(Q), C(N);
  for (int i = 0; i < Q; i++) {
    cin >> P[i] >> X[i];
    P[i]--;
    C[P[i]] += X[i];
  }
  vector<bool> f(N, false);
  f[0] = true;
  deque<int> q;
  q.emplace_back(0);
  while (!q.empty()) {
    int u = q.front();
    q.pop_front();
    for (int i : G[u]) {
      if (f[i]) continue;
      f[i] = true;
      C[i] += C[u];
      q.emplace_back(i);
    }
  }
  for (int i = 0; i < N; i++) {
    cout << C[i] << " ";
  }
  return 0;
}


Measured memory_bytes: 18676
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# 
# a, b = list(map(int, input().split()))
# s = input()


no = ":("
N = int(input())

ans = no
for i in range(50000+1):
    if math.floor(i * 1.08) == N:
        ans = i
        break
print(ans)


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

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

const int N = 1e5 + 5;
char s[N], t[N];
int n, m, p[N], q[N];

int main() {
  scanf("%s", s + 1);
  scanf("%s", t + 1);
  n = strlen(s + 1);
  m = strlen(t + 1);

  for (int i = 1; i <= n; ++i) p[i] = p[i - 1] + (s[i] == 'A');
  for (int i = 1; i <= m; ++i) q[i] = q[i - 1] + (t[i] == 'A');

  int Q;
  scanf("%d", &Q);
  while (Q--) {
    int l1, r1;
    int l2, r2;
    scanf("%d %d %d %d", &l1, &r1, &l2, &r2);

    int X = (r1 - l1 + 1) - 2 * (p[r1] - p[l1 - 1]) + 3*N;
    int Y = (r2 - l2 + 1) - 2 * (q[r2] - q[l2 - 1]) + 3*N;
    
    puts((X % 3) == (Y % 3) ? "YES" : "NO");
  }
}



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

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

    int mario[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<mario[k-1];
}


Measured memory_bytes: 3628
#include <iostream>
using namespace std;
long long c = 1e9+7;
long long pow_mod(long long a ,long long b) {
    long long ans = 1;
    long long base = a % c;
    while(b > 0) {
        if(b & 1 != 0)
            ans = (ans *base)%c;
            base = (base*base)%c;
            b >>= 1ll;
    }
    return ans;
}
int main() {
    long long n;
    cin >> n;
    long long ans = pow_mod(10, n);
    long long ans1 = pow_mod(9, n);
    long long ans2 = pow_mod(8, n);
    long long ans3 = (ans + ans2 + 2 * c - 2 * ans1) % c;
    cout << ans3 << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>

using namespace std;

int main(){
  int N;
  string S;
  cin >> N >> S;
  for(int i=0;i<S.length();i++){
    if(S[i]+N > 90){
      cout << (char)(S[i]+N - 90 +64);
    }else{
      cout << (char)(S[i]+N);
    }
  }
  return 0;

}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
const MOD: u64 = 1000000007;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}


fn main() {
    input!{
        W: usize, H: usize, N: usize,
        xya: [(usize, usize, usize); N],
    }
    let mut field = vec![vec![1; W]; H];

    for (x, y, a) in xya {
        for i in 0..H {
            for j in 0..W {
                match a {
                    1 => if j < x {
                        field[i][j] = 0;
                    },
                    2 => if j >= x {
                        field[i][j] = 0;
                    },
                    3 => if i < y {
                        field[i][j] = 0;
                    },
                    4 => if i >= y {
                        field[i][j] = 0;
                    },
                    _ => {}
                }
            }
        }
    }

    let ans = field.iter().fold(0, |acc, ref line| acc + line.iter().fold(0, |acc2, &cell| acc2 + cell ));
    println!("{}", ans);

}

Measured memory_bytes: 4352
#include<stdio.h>
int main(void)
{
	double r,a,b;
	scanf("%lf",&r);
	a =(double)r * r * 3.1415926535897;
	b =(double)2 * r * 3.1415926535897;
	printf("%f %f",a,b);
	return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void makeCombiUtil(vector<vector<int> > &ans, vector<int> &tmp, int n, int left, int k) {
    if (k == 0) {
        ans.push_back(tmp);
        return;
    }
    for (int i = left; i <= n; ++i) {
        tmp.push_back(i);
        makeCombiUtil(ans, tmp, n, i, k - 1);
        tmp.pop_back();
    }
}

// n 個の中から k 個取り出す組合せを作成する
vector<vector<int> > makeCombi(int n, int k) {
    vector<vector<int> > ans;
    vector<int> tmp;
    makeCombiUtil(ans, tmp, n, 1, k);
    return ans;
}

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

    int n, m, q;
    cin >> n >> m >> q;

    vector<int> a(q), b(q), c(q), d(q);
    REP(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];

    vector<vector<int> > comb = makeCombi(m, n);

    int ans = 0;
    REP(i, comb.size()) {
        int sum = 0;
        REP(j, q)
            if (comb[i][b[j]-1] - comb[i][a[j]-1] == c[j])
                sum += d[j];
        ans = max(ans, sum);
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 9824
#include <stdio.h>

int gcd(int x, int y);
void swap(int *x, int *y);

int main(void){
  int x, y;
  scanf("%d %d", &x, &y);
  x = gcd(x, y);
  printf("%d\n", x);
  return 0;
}

int gcd(int x, int y){
  int r;
  if (x < y)
    swap(&x, &y);
  while (y > 0) {
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}

void swap(int *x, int *y){
  int tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
  return;
}

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

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ld long double

int main()
{
	IOS;
	int n;
	cin >>n;
	int arr[n];
	for(int i=0;i<n;i++)
		cin >>arr[i];
	int c=0;
	for(int i=1;i<n-1;i++)
	{
		if((arr[i]>arr[i-1] && arr[i]<arr[i+1]) || (arr[i]<arr[i-1] && arr[i]>arr[i+1]))
			c++;
	}
	cout <<c<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
const ll INF_LL = 1000000000000;
#define fir first
#define sec second
using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    vector<vector<int>> hen(n);
    if(k > (n - 1) * (n - 2) / 2){cout << -1 << endl; return 0;}

    for(int i = 1; i < n; i++){
        hen[0].push_back(i);
        hen[i].push_back(0);
    }

    int cnt = 0; //cnt < ((n - 1)(n - 2) / 2 - k)
    int lim = ((n - 1) * (n - 2) / 2) - k;

    for(int i = 1; i < n && cnt < lim; i++){
        for(int j = i + 1; j < n && cnt < lim; j++){
            hen[i].push_back(j);
            hen[j].push_back(i);
            cnt++;
        }
    }
    std::cout << lim + n - 1<< std::endl;
    for(int i = 0; i < n; i++){
        for(auto j : hen[i]){
            if(i < j){
                std::cout << i + 1<< " " << j + 1 << std::endl;
            }
        }
    }
}


Measured memory_bytes: 384
s = int(input())

def f(x):
    if x % 2 == 0:
        return x/2
    else:
        return 3*x + 1

a = [s]
t = s
while f(t) not in a:
    a.append(f(t))
    t = f(t)
print(len(a)+1)

Measured memory_bytes: 3188
// D - Xor Sum 2

// 尺取り法による解法

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

ll A[200000];

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

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

	ll ans = 0;

	int right = 0;
	ll sum = 0;
	ll xor_sum = 0;
	for (int left = 0; left < N; ++left) {
		while (right < N && ((sum + A[right]) == (xor_sum ^ A[right]))) {
			sum += A[right];
			xor_sum ^= A[right];
			right++;
		}

		ans += (right - left);

		if (right == left) ++right; // leftがrightを追い越さないようにする
		else {
			sum -= A[left];
			xor_sum ^= A[left];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0 ; (i)<(int)(n) ; ++(i))
#define rer(i,l,u) for(int(i)=(int )(l) ; (i)<=(int )(u) ; ++(i))
#define reu(i,l,u) for(int( i)=(int)( l) ; (i)<(int)( u) ; ++(i))
#define repv(i,n) for(int (i)=(int)(n-1) ; (i)>=0 ; --(i))
#define pb push_back
#define eb emplace_back
#define all(i) (i).begin() , (i).end()
#define mp make_pair
#define ft first
#define sd second
typedef vector<int>  vi ;
typedef pair<int,int> pii ;
typedef vector<pair<int,int> > vpii ;
typedef long long ll ;
const long MOD=1e9+7 ;
const ll INF=2e9+10 ;
int main()
{
  ios::sync_with_stdio(false) ;
   int n ;
  int l [203] ; int sum=0;
cin >> n ;
rep (i,2*n) cin >> l [i] ;
sort (l,l+2*n) ;
for (int i=0 ; i < 2*n ; i+=2) sum+=l [i] ;
cout << sum << "\n" ;
  return 0 ;
} 


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

int main() {
    int a, b, c; cin >> a >> b >> c;
    //int maxv = max({a, b, c});
    if ((a == b) && (b == c)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int K = sc.nextInt();
		int R = sc.nextInt();
		int S = sc.nextInt();
		int P = sc.nextInt();
		String T = sc.next();
		int r = 0;
		int s = 0;
		int p = 0;
		char[] c = T.toCharArray();

		for (int i = 0; i < K; i++) {
			if (T.charAt(i) == 'r')
				p++;
			else if (T.charAt(i) == 's')
				r++;
			else if (T.charAt(i) == 'p')
				s++;
		}

		for (int i = 0; i < K; i++) {
			for (int j = i + K; j < N; j += K) {
				if (c[j - K] == T.charAt(j)) {
					c[j] = ' ';
					continue;
				} else if (T.charAt(j) == 'r')
					p++;
				else if (T.charAt(j) == 's')
					r++;
				else if (T.charAt(j) == 'p')
					s++;
			}
		}

		System.out.println(R * r + S * s + P * p);

	}

	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
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: 23892
#include<bits/stdc++.h>     
          using namespace std;  
          typedef long long  ll;
          typedef pair<ll,ll> pll;  
          #define pb(x) push_back(x)     
          typedef unsigned long long  ull;     
          #define mem(A, X) memset(A, X, sizeof A)
          #define ford(i,l,u) for(ll (i)=(ll)(l);(i)>=(ll)(u);--(i))
          #define foreach(e,x) for(__typeof(x.begin()) e=x.begin();e!=x.end();++e)
          #define fori(i,l,u) for(ll (i)=(ll)(l);(i)<=(ll)(u);++(i))    
          typedef pair<int,int> pii;
          #define sec second
          #define fir first  
        
          const ll mod=1e9+7; 
          const ll maxn=1e5+10; 
          ll a[maxn];
          int main()
          {
               std::ios::sync_with_stdio(false); 
               //freopen("in.txt","r",stdin); 
               ll n,x;
               while(cin>>n&&n)
               {
                cin>>x;
                fori(i,1,n) cin>>a[i];

                ll ans=0;
                if(a[1]>x) {ans+=a[1]-x;a[1]=x;}
                fori(i,2,n)
                {
                  if(a[i]+a[i-1]>x) { ans+=a[i]+a[i-1]-x; a[i]=x-a[i-1];} 
                }
                cout<<ans<<endl;
               }
            return 0;
          }

Measured memory_bytes: 1024
#include<iostream>

int main(void){
    int k;
    std::cin >> k;
    int cur = 7 % k;
    int cnt = 1;
    for(int i = 0; i <= k; i++){
        if(cur == 0){
            std::cout << cnt << std::endl;
            return 0;
        }else{
            cnt++;
            cur = cur * 10 + 7;
            cur %= k;
        }
    }
    std::cout << -1 << std::endl;
    return 0;
}

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

using ll = long long;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

const ll INF = (ll)1e11;
const ll MOD = 998244353;

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> A;
    ll S = 0;
    for (int i = 0, a; i < N; ++i) {
        cin >> a;
        A.push_back(a);
        S += a;
    }

    ll cnt = 1;
    for (int i = 0; i < N; ++i) {
        cnt *= 3;   // all ways to paint stones
        cnt %= MOD;
    }

    // subtract the numbers of ways to paint such that R,G,B cannot construct a triangle from all.

    {   // reduce the number of ways to paint such that R >= G + B, G >= B + R, B >= R + G
        vector<ll> dp(S + 10, 0);
        dp[0] = 1;  // assume that R = max(R,G,B) here
        for (auto a : A) {
            for (ll s = S; s > a - 1; --s) {
                dp[s] += 2 * dp[s-a];   // select a_i in G or B
                dp[s] %= MOD;
            }
        }
        
        for (ll s = 0; s < S / 2 + 1; ++s) {
            cerr << "----" << endl;
            cnt -= 3 * dp[s];   // subtract sum of R, G, B = max(R,G,B)
            while (cnt < 0) cnt += 3 * MOD;
            cnt %= MOD;
            
            cerr << cnt << endl;
        }
    }

    cerr << cnt << endl;

    if (S % 2 == 0) {   // add the number of ways to paint such that R == G && B == 0, G == B && R == 0, B == R && G == 0
        vector<ll> dp(S + 10, 0);
        dp[0] = 1;  // assume that R == G && B == 0 here
        for (auto&& a : A) {
            for (ll s = S; s > a - 1; --s) {
                dp[s] = (dp[s] + dp[s-a]) % MOD;   // select a_i in R (G)
                dp[s] %= MOD;
            }
        }

        cnt += 3ll * dp[S/2];   // add sum of R,G,B == 0
        cnt %= MOD;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 1024
n = int(input())
s1 = input()
s2 = input()
memo_ls = [0 for j in range(n)]
ind = 0
while ind < n:
    if s1[ind] == s2[ind]:
        if ind == 0:
            memo_ls[ind] = 3
        elif s1[ind-1] == s2[ind-1]:
            memo_ls[ind] = memo_ls[ind - 1] * 2 % (10**9+7)
        else:
            memo_ls[ind] = memo_ls[ind - 1]
        ind += 1
    else:
        if ind == 0:
           memo_ls[ind] = 6
        elif s1[ind-1] == s2[ind-1]:
            memo_ls[ind] = memo_ls[ind - 1] * 2 % (10 ** 9 + 7)
        else:
            memo_ls[ind] = memo_ls[ind - 1] * 3 % (10 ** 9 + 7)
        memo_ls[ind + 1] = memo_ls[ind]
        ind += 2
print(memo_ls[n-1])

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
const int MOD = 1000000007;
const double pi = acos(-1);

int main() {
    vecveci C(3,veci(3));
    REP(i,3) REP(j,3) cin >> C[i][j];
    REP(a1,101) REP(a2,101) REP(a3,101) {
        bool ok = true;
        bool b1 = (C[0][0]-a1 == C[1][0]-a2) && (C[1][0]-a2 == C[2][0] - a3);
        bool b2 = (C[0][1]-a1 == C[1][1]-a2) && (C[1][1]-a2 == C[2][1] - a3);
        bool b3 = (C[0][2]-a1 == C[1][2]-a2) && (C[1][2]-a2 == C[2][2] - a3);
        if(b1 && b2 && b3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3576
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int d = 0, t = 0, s = 0;
	cin >> d >> t >> s;
	cout << (s * t >= d ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3608
if __name__ == '__main__':
    N, K = map(int, input().split())
    
    # Kの倍数の数
    mod_0 = N//K
    
    # mod K が K/2
    mod_half = 0
    if K%2 == 0:
        for n in range(1, N+1):
            if n%K == K//2:
                mod_half += 1
    
    print(mod_0**3 + mod_half**3)

Measured memory_bytes: 2940
#include <iostream>
#include <stack>
#include <climits>
#include <algorithm>
using namespace std;

int abs(int a) {return (a < 0) ? -a : a;}

int main(){
    int N; cin >> N; int a[N];
    long long s[N], t[N], x=0, y=0;
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < N; i++)
        s[N-i-1] = (x+=a[i]), t[i] = (y+=a[N-i-1]);

    long long MIN = LONG_MAX;
    for (int i = 1; i < N; i++)
        MIN = min(MIN, abs(t[i-1]-s[i]));

    cout << MIN << endl;

    return 0;
}


Measured memory_bytes: 4096
dict1 = {}
dict2 = {}

while True:
	log = raw_input()
	if len(log) == 0:
		break
	
	log = log.split(",")[0]
	
	if log in dict1:
		dict1[log] = dict1[log] + 1
	else:
		dict1[log] = 1
		
while True:
	try:
		log = raw_input()
		
		log = log.split(",")[0]
		
		if log in dict2:
			dict2[log] = dict2[log] + 1
		else:
			dict2[log] = 1
			
	except EOFError:
		break

list = set(dict1) & set(dict2)
for var in list:
	print var, dict1[var] + dict2[var]

Measured memory_bytes: 6244
#include<stdio.h>
int main(void){
	int n,a,b,c,N;
	scanf("%d",&n);
	a=n%10;
	if(a==9)
	a-=8;
	else
	a+=8;
	n/=10;
	b=n%10;
	if(b==9)
	b-=8;
	else
	b+=8;
	n/=10;
	c=n;
	if(c==9)
	c-=8;
	else
	c+=8;
	N=(100*c)+(10*b)+a;
	printf("%d\n",N);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int n;
	int cnt;

	scanf("%d",&n);
	while(n!=0){
		cnt=0;
		while(n!=1){
			if(n%2==0){
				n=n/2;
				cnt++;
			}
			else{
				n=n*3+1;
				cnt++;
			}
	
		}
		printf("%d\n",cnt);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <stdio.h>
int main(){
  int n,i,x;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    x=i;
    if((x%3)==0) printf(" %d",i);
    else{
      while(1){
	if((x%10)==3){
	  printf(" %d",i);
	  break;
	}
	if((x/=10)==0) break;
      }
    }
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 600
class nnDigitSum:
	def dfs(self,b,n):
		if n<b:
			return n
		return self.dfs(b,n/b)+n%b
	def returnMinimumB(self,n,s):
		if n<s: return -1
		if n==s: return n+1
		i=2
		while i*i<=n:
			if self.dfs(i,n)==s: return i
			i+=1
		cands=[]
		i=1
		while i*i<=n-2:
			if not (n-s)%i: cands.append((n-s)/i+1)
			i+=1
		cands=sorted(cands)
		for cand in cands:
			if self.dfs(cand,n)==s: return cand
		if s==1: return n
		return -1
if __name__ == "__main__":
	N = int(raw_input())
	s = int(raw_input())
	d = nnDigitSum()
	print d.returnMinimumB(N,s)

Measured memory_bytes: 2696
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <map>
#define ll long long
using namespace std;

#define MOD 1000000007

class Solve
{
private:
	ll n, m, k;
public:
	Solve(){
		cin >> n >> m >> k;

	}

	void exec(){
		for (ll i = 0; i <= m; ++i)
		{
			for (ll j = 0; j <= n; ++j)
			{
				if(i * j + (m-i) * (n-j) == k) {
					cout << "Yes" << endl;
					return;
				}
			}
		}
		cout << "No" << endl;
	}
};

int main(){
	Solve solver = Solve();
	solver.exec();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  string op;
  cin >> a >> b >> c >> d;
 
  if(a + b > c + d){
	cout << "Left" << endl;
  }else if(a + b == c + d){
	cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod (1000000000+7)
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

const int N = 100001;
int dp[N][3];
int a[N] , b[N] , c[N];

int main()
{
    int n; cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i]>>b[i]>>c[i];
    dp[1][0] = a[1];
    dp[1][1] = b[1];
    dp[1][2] = c[1];
    for(int i=2;i<=n;i++)
    {
        dp[i][0] = a[i] + max(dp[i-1][1] , dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0] , dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0] , dp[i-1][1]);
    }
    int ans = max(dp[n][0], max(dp[n][1], dp[n][2]));
	cout << ans;
}


Measured memory_bytes: 5972
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTA(a,n) sort(a,a+n)
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
	int n;
  	cin >> n;
  	//処理
  	int ans = log2(n);
    //出力
    cout << pow(2,ans) << ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    char s[5];
    scanf("%s",&s);

   if(s[0]==s[1]&&s[1]==s[2])
	{
     	printf("Yes\n");
    }
   else if(s[1]==s[2]&&s[2]==s[3])
    {
        printf("Yes\n");
    } 
   else 
   {
   	    printf("No\n");
   }
	return(0);
}

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

int main(void)
{
	int i,n,l,r,sum=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		{
		scanf("%d%d",&l,&r);
		sum+=r-l+1;
		}
	printf("%d\n",sum);
	return 0;
}



Measured memory_bytes: 128
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    N, M, K = map(int, input().split())
    num_friends = [0 for _ in range(N)]
    blocks = [[] for _ in range(N)]
    uf = UnionFind(N)

    for _ in range(M):
        a, b = map(int, input().split())
        num_friends[a-1] += 1
        num_friends[b-1] += 1
        uf.union(a-1, b-1)
    for _ in range(K):
        a, b = map(int, input().split())
        blocks[a-1].append(b-1)
        blocks[b-1].append(a-1)

    ans = []
    for i in range(N):
        cnt = uf.size(i) - 1 - num_friends[i]
        for j in blocks[i]:
            if uf.same(i, j):
                cnt -= 1
        ans.append(cnt)
    
    print(*ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 31872
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
using namespace  std;

const int N = 1e5+5;
int p[N];
void init(int n){
    rep(i,1,n){
        p[i] = i;
    }
}
int getfa(int x){
    if(p[x]!=x){
        return p[x] = getfa(p[x]);
    }else{
        return x;
    }
}
void merge(int x,int y){
    int fx = getfa(x),fy = getfa(y);
    if(fx!=fy){
        p[fx] = fy; 
    }
}
int main(){
    ios::sync_with_stdio(0);
    int n,m;cin>>n>>m;
    init(n);
    rep(i,1,m){
        int a,b;cin>>a>>b;
        merge(a,b);
    }
    int cnt = 0;
    rep(i,1,n){
        if(p[i] == i){
            ++cnt;
        }
    }
    cout<<cnt-1;
}



Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

vector<ll> a(1, 1), p(1, 1); //a：全体の枚数，p；パティの枚数

ll f(ll n, ll x)
{
    if (n == 0)
    {
        if (x <= 0)
        {
            return 0;
        }
        else
        {
            return 1;
        }
    }
    else if (x <= 1 + a[n - 1])
    {
        return f(n - 1, x - 1);
    }
    else
    {
        return p[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1]);
    }
}

int main()
{
    ll n, x;
    cin >> n >> x;

    for (int i = 0; i < n; i++)
    {
        a.push_back(a[i] * 2 + 3);
        p.push_back(p[i] * 2 + 1);
    }
    cout << f(n, x) << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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

int main() {
  int h,w,ans=0;
  cin >> h >> w;
  vector<char> s(h*w);
  for(int i=0;i<h*w;i++) cin >> s[i];
  vector<vector<int>> g(h*w);
  for(int i=0;i<h;i++){
    for(int j=0;w>1 && j<(w-1);j++){
      if (s[i*w+j] == '.' && s[i*w+j+1] == '.'){
        g.at(i*w+j).push_back(i*w+j+1);
        g.at(i*w+j+1).push_back(i*w+j);
      }
    }
  }
  for(int i=0;i<w;i++){
    for(int j=0;h>1 && j<(h-1);j++){
      if (s[j*w+i] == '.' && s[j*w+i+w] == '.'){
        g.at(j*w+i).push_back(j*w+i+w);
        g.at(j*w+i+w).push_back(j*w+i);
      }
    }
  }
  for(int i=0;i<h*w;i++){
    vector<int> dist(h*w,-1);
    queue<int> que;
    dist[i] = 0;
    que.push(i);
    while (!que.empty()) {
      int v = que.front();
      que.pop();
      for (int nv : g[v]) {
        if (dist[nv] != -1) continue;
        dist[nv] = dist[v] + 1;
        que.push(nv);
      }
    }
    for(int j=0;j<h*w;j++)  ans = max(ans,dist[j]);
  }
  cout << ans << endl;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    string S,T;
    cin>>S>>T;
    rep(i,T.size()){
        rotate(T.begin(),T.begin()+1,T.end());
        if(S==T){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a;
  cin >> a;
  int ans;
  if(a%2==0){
    ans = a/2-1;
  }else{
    ans  = (a-1)/2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> w(n);
	for (int i = 0; i < n; i++) {
		cin >> w[i];
	}
	int head = 0, tail = n-1;
	int a = 0, b = 0;
	while (1) {
		if (a <= b) {
			a += w[head];
			head++;
		}
		else {
			b += w[tail];
			tail--;
		}
		if (head == tail+1) {
			break;
		}
	}
	if (a <= b) {
		cout << b - a;
	}
	else {
		cout << a - b;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

bool check(int i, vector<int> p){
    bool a = false;
    int j;
    for(int j = 0; j != p.size(); j++){
        if(p[j] == i){
            a = true;
            break;
        }
    }
    return a;
}

int main(){
    int x, n, ans;
    cin >> x >> n;
    vector<int> p(n);
    rep(i,n){
        cin >> p[i];
    }
    bool ok;
    rep(i,102){
        ok = check(x-i,p);
        if(!ok){
            if(x-i <= 101 && x-i >= 0){
                ans = x-i;
                break;
            }
        }
        if(i != 0){
            ok = check(x+i,p);
            if(!ok){
                if(x+i <= 101 && x+i >= 0){
                    ans = x+i;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
const double PI = acos(-1);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

/*C++になってるか確認したほうがよくない？WOWWOW*/
/*DP使ったほうがよくない？？WOWWOW*/

int main(){
    string S; cin>>S;
    if(S=="ABC"){
        cout<<"ARC"<<endl;
    }
    else{
        cout<<"ABC"<<endl;
    }
}

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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COL(x) cout << x << endl
#define CO(x) cout << x
//#define int long long

template<typename T> inline constexpr auto square(T x) { return (x) * (x); }

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const int MOD = 1000000007;
const int INF = INT_MAX;

signed main()
{
	int M, D;
	cin >> M >> D;

	int ans = 0;
	rng(m, 4, M + 1) {
		rng(d, 2, D + 1) {
			int d1 = d % 10;
			int d10 = d / 10;

			if ((d1 < 2) || (d10 < 2)) continue;

			if (m == d1 * d10) ans++;
		}
	}

	COL(ans);

	return 0;
}

Measured memory_bytes: 256
///  author:Kissheart  ///
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<vector>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<deque>
#include<ctype.h>
#include<map>
#include<set>
#include<stack>
#include<string>
#define INF 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)
const double PI = acos(-1.0);
const double eps = 1e-6;
const int MAX=1e5+10;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
#define gcd(a,b) __gcd(a,b)
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll qpow(ll a,ll b){ll r=1,t=a; while(b){if(b&1)r=(r*t);b>>=1;t=(t*t);}return r;}
inline ll inv1(ll b){return qpow(b,mod-2);}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll r=exgcd(b,a%b,y,x);y-=(a/b)*x;return r;}
inline ll read(){ll x=0,f=1;char c=getchar();for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;for(;isdigit(c);c=getchar()) x=x*10+c-'0';return x*f;}
//freopen( "in.txt" , "r" , stdin );
//freopen( "data.txt" , "w" , stdout );
int n,h,w;
int main()
{
    scanf("%d%d%d",&n,&h,&w);
    int p=n-w+1,q=n-h+1;

    printf("%d\n",p*q);
    return 0;
}


Measured memory_bytes: 256
//smallequal.cpp
#include <iostream>
#include <string>
using namespace std;
int main (){
  int a, b;
  string s;
  cin >> a >> b;
  if (a < b) s = "a < b";
  else if (a > b) s= "a > b";
  else s="a == b";
  cout <<  s << endl;
}



Measured memory_bytes: 3168
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  vi a(3);
  scan(a);
  sort(all(a));
  if (a[0] == a[1] && a[1] == a[2]) {
    print("Yes");
  } else {
    print("No");
  }
  return 0;
}


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

int main() {
  int N, K, S = 0;
  cin >> N;
  cin >> K;
  vector<int> X(N);
 
  for (int i = 0; i < N; i++) {
    cin >> X.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    S = S + min(X.at(i), abs(X.at(i)-K));
  }
  
  cout << S * 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
	long long K;
	cin >> N >> K;
    std::vector<pair<int,int>> v(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> v[i].first >> v[i].second;
	}
	sort(v.begin(), v.end());
	long long sumCount = 0;
	for (long long i = 0; i < N; ++i)
	{
		sumCount += v[i].second;
		if(sumCount >= K){
			cout << v[i].first << endl;
			break;
		}
	}
}

Measured memory_bytes: 1024
/* AOJ 0000 QQ */

#include <stdio.h>

int
main(void)
{
    int i, j;

    for (i = 1; i < 10; i++)
        for (j = 1; j < 10; j++)
            printf("%dx%d=%d\n", i, j, i * j);

    return 0;
}

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

const int MAX = 10005;

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

  vector<int> c(MAX, 0);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int val = x * x + y * y + z * z + x * y + y * z + z * x;
        if (val > MAX) break;
        c[val]++;
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    int ans = c[i];
    printf("%d\n", ans);
  }
}


Measured memory_bytes: 3760
n,m,x=map(int,input().split())
book_list=[list(map(int,input().split())) for _ in range(n)]
ans=-1
for i in range(2**n):
    result=[0]*(m+1)
    for j in range(n):
        if (i>>j)&1:
            for k in range(m+1):
              result[k]+=book_list[j][k]
    if min(result[1:m+1])>=x:
      if ans==-1:
        ans=result[0]
      else:
        ans=min(ans,result[0])
print(ans)


Measured memory_bytes: 9208
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <set>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll n;
const ll MAX_N = 200000;
ll a[MAX_N];

int main(){
  cin >> n;
  REP(i, n) cin >> a[i];
  ll b[n + 1];
  REP(i, n) b[a[i]] = i + 1;

  set<ll> s;
  s.insert(0);
  s.insert(n + 1);

  ll ans = 0;
  for(ll i = 1; i <= n; i++) {
    auto itr = s.lower_bound(b[i]);
    ll r = *itr;
    itr--;
    ll l = *itr;
    ans += i * (r - b[i]) * (b[i] - l);
    s.insert(b[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 12800
N = int(input())
c_list = [float("inf")]*N
h_list = list( map(int,input().split() ) )
c_list[0] = 0
c_list[1] = abs( h_list[1] - h_list[0] )
for i in range(2,N):
    c_list[i] = min(c_list[i-2] + abs( h_list[i] - h_list[i-2]), 
                    c_list[i-1] + abs(h_list[i] - h_list[i-1]) )
print(c_list[N-1])

Measured memory_bytes: 14748