akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    map<int, int> ma;
    rep(i,n){
        int a; cin >> a;
        ma[a]++;
    }
    int ans = 0;
    for(auto p : ma){
        if(p.second >= p.first) ans += p.second - p.first;
        else ans += p.second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4736
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]


from collections import defaultdict, Counter
import math
from bisect import bisect_left, bisect_right
import numpy as np

mod = 1000000007

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

#### START
n, m = map(int,input().split())

if n==m:
    a = math.factorial(n)
    print(mul(mul(a, a), 2))
elif n==m-1 or n-1==m:
    if n<m:
        a = math.factorial(n)
        b = a*m
    else:
        a = math.factorial(m)
        b = a*n
    print(mul(a, b))
else:
    print(0)

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

INF = 1 << 29

"""
・dp[bit][s]
ビットに1が立っているカードはソートされて左から並んでいる。
そのとき最後の値をsにするのに必要な最小操作回数


"""
# 1 <= A,B <= 50, bitの立ち方が 0...0 ~ 1...1 の2**N
dp = [[INF for _ in range(50 + 1)] for _ in range((1 << N))]
# 0枚選んでいて右端が0は何もしてないのでコスト0
dp[0][0] = 0

for bit in range(1 << N):
    # 現在見ているbit列にいくつ1が立っているか＝カードを何枚既に選んで並べているか
    num_used = bin(bit).count("1")
    
    # bitで１が立っていない＝まだ使われていないカードがどこにあるか
    idx = num_used
    remaining = []
    for i in range(N):
        if not (bit & (1 << i)):
            # 一つ目が初期位置、二つ目は、bitで１が立っているやつらを左に寄せた時にどの位置にいるか
            remaining.append((i, idx))
            idx += 1

    for s in range(51):
        # bitの集合かつ、その右端にsの状態が作れないならスキップ
        if dp[bit][s] >= INF:
            continue

        for ini, curr in remaining:
            """
            ini  : initial position
            curr : current position
            現時点でnum_used-1のインデックスまでカードがソートされて並んでいる
            最初iniの位置にあったカードを最後尾に並べることを考える
            """
            num = A[ini] if abs(ini - num_used) % 2 == 0 else B[ini]

            """
            numが並んでるカードの最後尾より大きければ最後尾につける
            """
            if num >= s:
                # 元の集合と、iniの位置だけ１が立ってるものの論理和で、追加した状態を表す
                # その場合の最小コストは、既に求まっているもの or 新たにnum_usedの位置にiniのカードをあてたとき　の小さいほう
                dp[bit | (1 << ini)][num] = min(dp[bit | (1 << ini)][num], dp[bit][s] + abs(num_used - curr))



# 全てのbitに1が立っている（全て並べ切った）時の最小コストが答え
ans = min(dp[-1][s] for s in range(51))

print(ans if ans < INF else -1)


Measured memory_bytes: 181276
#include<iostream>
using namespace std;
int main(){
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if (u == s) {
		a -= 1;
		cout << a << " " << b;
	}
	else {
		b -= 1;
		cout << a << " " << b;
	}
	return 0;
}

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

using namespace std;

int main() {
	int n; cin >> n;
	string s; cin >> s;
	for (int i = 0; i < s.size(); i++)
		cout << (char)((s[i] - 'A' + n) % 26 + 'A');
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int d[1000];
int main()
{
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	printf("%d\n", max(0, min(b, d) - max(a, c)));
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <deque>
// #include <chrono>
#include <numeric>

using namespace std;
// using namespace std::chrono;

typedef long long int lo;
#define fast ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0);
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define inf (lo)1e9
#define N (lo)1e5 * 5
#define all(x) (x).begin(), (x).end()
#define ii pair<lo,lo>
#define iii pair<lo, pair<lo,lo> >
#define si pair<string,lo>
#define vi vector <lo> 
#define vii vector <ii> 

void solve(){
    lo n;
    cin >> n;
    lo sum = 0;
    for(lo i = 1 ; i <= n ; i++){
        if(i % 3 != 0 && i % 5 != 0){
            sum += i;
        }
    }
    cout << sum << endl;
}
    
int main() {

    #ifndef ONLINE_JUDGE
        // freopen("soru.gir", "r", stdin);
        // freopen("soru.cik", "w", stdout);
    #endif
    
    fast
    
    // auto start = high_resolution_clock::now();

    lo p = 0;

    if(p){
        lo t;
        cin >> t;
        while(t--)
            solve();
    }
    else{
        solve();
    }

    // auto stop = high_resolution_clock::now();
    // auto duration = duration_cast<microseconds>(stop - start);
    
    // #ifndef ONLINE_JUDGE
    //     cout << "Elapsed time is " << duration.count() << " microseconds." << endl;
    // #endif
    
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int a,b;
    cin >> a >> b;
    if(a+b<10){
      cout << a+b;
    }else{
      cout <<"error";
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
//#define NDEBUG
//#define int ll
#define F1R(i, a)     for (int i=1; i<=a; i++)
#define F0R(i, a)     for (int i=0; i<a; i++)
#define FOR(i, a, b)  for (int i=a; i<b; i++)
#define F1Rd(i, a)    for (int i=a; i>0; i--)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a)    for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define whats(x)      cerr << #x << " is " << x << '\n';
#define MOD           1000000007
#define INF           1e18
#define f             first
#define s             second
#define mp            make_pair
#define pb            push_back
#define en(x)         x.end()
#define beg(x)        x.begin()
#define sz(x)         (int)x.size()
#define all(x)        beg(x), en(x)
#define rsz           resize
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
template <class T> using Tree = tree<T,null_type,less<T>,
rb_tree_tag,tree_order_statistics_node_update>;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<ll>  vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
const
int MN = 105;

bool test(int m, int d) {
    return (((d%10) >= 2) && ((d/10) >= 2) && ((d%10)*(d/10) == m));
}

int M, D, sol;

signed main() {
    //ios::sync_with_stdio(0);
    //cin.tie(0), cout.tie(0);
    cin >> M >> D;
    F1R(m,M) F1R(d,D) sol += test(m,d);
    cout << sol << '\n';
    return 0;
}


Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> K(N);
    vector<vector<int>> A(N);
    rep(i, N) {
        cin >> K.at(i);
        rep(j, K.at(i)) {
            int tmp;
            cin >> tmp;
            A.at(i).push_back(tmp);
        }
    }

    map<int, int> preferences;
    rep(i, M) {
        preferences.emplace(i, 0);
    }

    rep(i, N) {
        for(auto a : A.at(i)) {
            preferences[a - 1]++;
        }
    }

    int count = 0;
    rep(i, M) {
        if (preferences.at(i) == N) count++;
    }

    cout << count << endl;

    return 0;
}


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

int main(){
    int h,w;
    while(1){
        cin>>h>>w;
        if(h==0&&w==0){
            break;
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cout<<"#";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <stdlib.h>
 
int main(void)
{

    int N;
    scanf("%d", &N);

    if(!(N == 1 || N == 2)) {
        exit(0);
    }

    if(N == 1) {
        printf("Hello World\n");
    } else {
        int A;
        int B;
        scanf("%d %d", &A, &B);
        if(A < 1 || A > 9 || B < 1 || B > 9) {
            exit(0);
        }
        printf("%d\n", A + B);
    }

    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int N;

struct Solver{
  int _N;
  vector<ll> _height;
  vector<ll> _ans;
  explicit Solver(int N, vector<ll> height) : _N(N), _height(height){
    _ans.resize(_N); 
  }
  ll solve(){
    auto iter=_height.rbegin();
    for(int i=_N-2; i>=0; i--){
      ll prev=*iter; iter++; 
      _ans[i] = (*iter>=prev ? _ans[i+1]+1 : 0);
    }
    return *max_element(_ans.begin(), _ans.end());
  }
};

int main(){
  scanf("%d", &N);
  vector<ll> height(N);
  for(int i=0; i<N; i++) scanf("%d", &height[i]);
  
  Solver solver(N, height);
  printf("%d\n", solver.solve());
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double h,a;
    cin>>h>>a;
    if(h<=a)
    {
        cout<<1<<endl;
        return 0;
    }
    double c;
    c=h/a;
    int d=h/a;
    if(d-c<0) cout<<((int)d)+1<<endl;
    else cout<<(int)d<<endl;
    //system("pause");
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    S = [0 for i in range(N+1)]
    for i in range(1, N+1):
        S[i] = S[i-1] + A[i-1]

    mi = 10**10
    for i in range(1, N):
        S1 = S[i] - S[0]
        S2 = S[N] - S[i]
        d = abs(S1-S2)
        
        if d < mi:
            mi = d
            
    print(mi)
        
if __name__ == "__main__":
    main()

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

long int table[100005];
long int num[100005];
int n;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> num[i];
	}
	for (int i = 0; i < n; i++)
	{
		table[i] = 9999999999;
	}
	for (int i = 0; i < n; i++)
	{
		*lower_bound(table, table + n, num[i]) = num[i];
	}

	cout << lower_bound(table, table + n, 9999999999) - table << endl;

	return 0;
}

Measured memory_bytes: 2720
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int F[110][10];
  for (int i = 0; i < N; i ++) {
    for (int j = 0; j < 10; j ++) {
      cin >> F[i][j];
    }
  }
  int C[110][11];
  for (int i = 0; i < N; i ++) {
    for (int j = 0; j < 11; j ++) {
      cin >> C[i][j];
    }
  }
  int ans = 1e9 + 7;
  ans *= -1;
  int f[10];
  for (int i = 1; i < 1 << 10; i ++) {
    int i_ = i;
    for (int j = 0; j < 10; j ++) {
      f[j] = i_ % 2;
      i_ /= 2;
    }
    int kj = 0;
    for (int j = 0; j < N; j ++) {
      int al = 0;
      for (int k = 0; k < 10; k ++) {
        al += f[k] * F[j][k];
      }
      kj += C[j][al];
    }
    if (ans < kj) {
      ans = kj;
      //cout << i << ' ' << kj << endl;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>
#include <map>

using namespace std;

int main(){
  map<string,int> table;
  string word,ans1,ans2;
  int freq=0,len=0;
  while(cin >> word){


    if(table.find(word)==table.end()){
      table[word] = 1;
    }else{
      table[word]++;
    }
    if(table[word]>freq){
      freq = table[word];
      ans1 = word;
    }
    if(word.size()>len){
      len = word.size();
      ans2 = word;
    }
  }
  cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 1196
n,k=map(int,input().split())
r,s,p=map(int,input().split())
T=input()

rsp={'r':p,'p':s,'s':r}
ans=[-1]*n
for i in range(n):
  if ans[i]==-1:
    p=rsp[T[i]]
    ans[i]=p
    if i+k<n:
      if T[i]==T[i+k]:
        ans[i+k]=0
print(sum(ans))

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

int main(){
    int N, D;
    cin >> N >> D;
    int range = 1 + 2 * D;
    int ans;
    if(N % range == 0){
        ans = N / range;
    } 
    else{
        ans = N / range + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int counter(int z){
    if(z==0) return 0;
    else return counter(z>>1)+(z&1);
}
int main(void)
{
    int n=0,max=0,count=0,flag=1;
    int a[20]={},x[20][20]={},y[20][20]={};
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        for(int j=0;j<a[i];j++){
            scanf("%d %d",&x[i][j],&y[i][j]);
        }
    }
    for(int i=0;i<(1<<n);i++){
        flag=1;
        for(int j=0;j<n;j++){
            if(!(i&(1<<j))) continue;
            for(int k=0;k<a[j];k++){
                if((i>>(x[j][k]-1)&1)^y[j][k]){
                    flag=0;
                    break;
                }
            }
        }
        // 矛盾がなかった時
        if(flag==1){
            count=counter(i);
            if(max<count) max=count;
        }
    }
    printf("%d",max);
    return 0;
}

void zeros(int *a){
    for(int i=0;i<20;i++) a[i]=0;
}


Measured memory_bytes: 1676
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64

int main(){
    int n;
    cin >> n;
    llong ans=0;
    int l,r;
    REP(i,n){
        cin >> l >> r;
        ans+=r-l+1;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        b solver = new b();
        solver.solve(1, in, out);
        out.close();
    }

    static class b {
        public void solve(int testNumber, InputReader in, PrintWriter out) {


            int n = in.nextInt();
            boolean enter = false;
            for (int i = 1; i <= 9; i++) {
                for (int j = 1; j <= 9; j++) {
                    int mult = i * j;
                    if (mult == n)
                        enter = true;
                }
            }

            if (enter)
                out.println("Yes");
            else
                out.println("No");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {

                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 21332
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

a, b, c, d = input_a

while 1
  c = c - b
  if c <= 0
    puts "Yes"
    exit
  end
  a = a - d
  if a <= 0
    puts "No"
    exit
  end
end


Measured memory_bytes: 14332
#include<iostream>
#include<vector>
using namespace std;
int main(){
  vector<int> H(6);
  for(int i = 0;i<6;i++){
    cin >> H[i];
  }
  int count = 0;
  for(int i = 0;i<5;i++){
    for(int j = i+1;j<5;j++){
    if(H[j] -H[i] > H[5])
    {
      cout << ":(" <<endl;
      return 0;
    }
    }

  }

  cout << "Yay!" << endl;

  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N;
	cin >> N;
	V<int> a(N+1);
	rep1(i,N) cin >> a[i];
	V<int> b(N+1);
	for(int i=N;i>0;i--){
		int s = 0;
		for(int j=i;j<=N;j+=i) s += b[j];
		s %= 2;
		if(s != a[i]) b[i] = 1;
	}
	V<int> v;
	rep1(i,N) if(b[i]) v.pb(i);
	cout << v.size() << endl;
	for(int i: v) cout << i << " ";
	cout << endl;
}


Measured memory_bytes: 3192
N = gets.to_i

hash = Hash.new(0)

N.times do
  d = gets.chomp.chars.sort.join('')
  hash[d] += 1
end

def combi(n, k)
  k = n - k if 2 * k > n
  return 1 if k == 0
  ((n - k + 1)..n).reduce(&:*) / ((1..k).reduce(&:*))
end

result = 0
hash.each do |_k, v|
  next if v <= 1
  result += combi(v, 2)
end
p result


Measured memory_bytes: 17020
class UnionFind():
  def __init__(self,n):
    self.n=n
    self.root=[-1]*(n+1)
    self.rank=[0]*(n+1)
  def FindRoot(self,x):
    if self.root[x]<0:
      return x
    else:
      self.root[x]=self.FindRoot(self.root[x])
      return self.root[x]
  def Unite(self,x,y):
    x=self.FindRoot(x)
    y=self.FindRoot(y)
    if x==y:
      return
    else:
      if self.rank[x]>self.rank[y]:
        self.root[x]+=self.root[y]
        self.root[y]=x
      elif self.rank[x]<=self.rank[y]:
        self.root[y]+=self.root[x]
        self.root[x]=y
        if self.rank[x]==self.rank[y]:
          self.rank[y]+=1
  def isSameGroup(self,x,y):
    return self.FindRoot(x)==self.FindRoot(y)
  def Count(self,x):
    return -self.root[self.FindRoot(x)]

n,m=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(m)]
arr=arr[1:]
arr=arr[::-1]
ans=[(n*(n-1))//2]
t=UnionFind(n)
for a,b in arr:
  if t.isSameGroup(a,b):
    ans.append(ans[-1])
  else:
    cnt1=t.Count(a)
    cnt2=t.Count(b)
    ans.append(ans[-1]-cnt1*cnt2)
    t.Unite(a,b)
ans=ans[::-1]
for i in ans:
  print(i)

Measured memory_bytes: 35376
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

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

int main(void){
    int A,B,C;
    cin>>A>>B>>C;
    int ans=max(C-(A-B),0);
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define pb push_back
#define fs first
#define sc second
#define sz size
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 2; i <= (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+7; 

const double PI =  3.141592653589793;

int main(){
	IO;
	double w,h,x,y;
	ll multiple=0;
	cin>>w>>h>>x>>y;
	if(w/2==x && h/2==y)multiple=1;
	printf("%.9f %lld\n",w*h/2.0,multiple);
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


Measured memory_bytes: 256
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
s =s()
print("Yes" if s[2] == s[3] and s[4] == s[5] else "No")

Measured memory_bytes: 3064
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long A, B, C;
            long K;

            long bufA,bufB,bufC;

            string[] input = ReadLine().Split(' ');
            A = long.Parse(input[0]); // Takahashi
            B = long.Parse(input[1]); // Nakahashi
            C = long.Parse(input[2]); // Teihashi
            K = long.Parse(input[3]);

            long limK = (long)Math.Pow(10, 18);
            long Ans = A - B;
            long bufAns = Math.Abs(A - B);
            int count = 0;
            for (long i = 1; i <= K; i++)
            {
                bufA = A;
                bufB = B;
                bufC = C;

                A = bufB + bufC;
                B = bufA + bufC;
                C = bufA + bufB;

                Ans = A - B;
                if (Math.Abs(Ans) > limK)
                {
                    WriteLine("Unfair");
                    break;
                }
                //if (B == C) break;
                if(bufAns == Math.Abs(Ans))
                {
                    if(count < 10)
                    {
                        count++;
                        bufAns = Math.Abs(Ans);
                    }
                    else
                    {
                        if ((K - i) % 2 != 0) Ans = Ans * (-1);
                        break;
                    }
                }
            }

            WriteLine(Ans);
        }
    }
}


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

ll solve() {
    string s;
    cin >> s;
    vector<ll> A(4);
    for ( int i = 0; i < 4; i++ ) {
        A[i] = (int)(s[i] - '0');
    }
    for ( int j = 0; j < 1<<3; j++ ) {
        ll x = A[0];
        for ( int i = 1; i < 4; i++ ) {
            if ( (j >> (i-1)) & 1 ) x -= A[i];
            else x += A[i];
        }
        if ( x == 7 ) {
            cout << A[0];
            for ( int i = 1; i < 4; i++ ) {
                if ( (j >> (i-1)) & 1 ) cout << "-" << A[i];
                else cout << "+" << A[i];
            }
            cout << "=7" << "\n";
            return 0;
        }
    }
    return -1;
}

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;

	void solve() {
		int[] ia = readNums();
		int n = ia[0];
		int m = ia[1];
		int[] ans = new int[n];
		for (int i = 0; i < m; i++) {
			int[] ib = readNums();
			int a = ib[0];
			int b = ib[1];
			ans[a - 1]++;
			ans[b - 1]++;
		}
		for (int i = 0; i < n; i++) {
			pln(ans[i]);
		}
	}

	// -----------------------------------------------------
	// 2018/04/26 r2
	// -----------------------------------------------------
	int abs(int a) {
		return (a >= 0) ? a : -a;
	}

	long abs(long a) {
		return (a >= 0) ? a : -a;
	}

	int max(int a, int b) {
		return (a > b) ? a : b;
	}

	long max(long a, long b) {
		return (a > b) ? a : b;
	}

	int min(int a, int b) {
		return (a < b) ? a : b;
	}

	long min(long a, long b) {
		return (a < b) ? a : b;
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	long readLong() {
		String line = readLine();
		return plong(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++)
			nums[i] = pint(flds[i]);
		return nums;
	}

	long[] readLongs() {
		String[] flds = readFlds();
		long[] nums = new long[flds.length];
		for (int i = 0; i < flds.length; i++)
			nums[i] = plong(flds[i]);
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	void pln(int[] ia) {
		for (int i = 0; i < ia.length; i++)
			pln(ia[i]);
	}

	void pln(long[] la) {
		for (int i = 0; i < la.length; i++)
			pln(la[i]);
	}

	static BufferedReader _in;
	static PrintWriter _out;
	static boolean _bElapsed = false;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (_bElapsed)
			System.err.println((end - start) + "ms");
	}
}


Measured memory_bytes: 21460
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>

int main(){
	long long ans= 0;
	long long mod= 1000000007;
	int n;
	std::cin>>n;

	std::vector<long long> aList(n);
	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	std::vector<std::vector<long long>> pow2List(n);
	std::vector<std::vector<long long>> num0List(n);
	std::vector<std::vector<long long>> num1List(n);
	for(int i=0; i<n; i++){
		pow2List[i].resize(61, 0);
		num0List[i].resize(61, 0);
		num1List[i].resize(61, 0);
	}

	for(int i=0; i<n; i++){
		for(int j=0; j<61; j++){
			if(aList[i] %2 !=0)
				pow2List[i][j]++;

			aList[i]= aList[i]/2;
		}
	}

	for(int i=0; i< 61; i++){
		if(pow2List[0][i]==0){
			num0List[0][i]= 1;
			num1List[0][i]= 0;
		}else{
			num0List[0][i]= 0;
			num1List[0][i]= 1;
		}

	}

	for(int i=1; i<n; i++){
		for(int j=0; j< 61; j++){
			if(pow2List[i][j]==0){
				num0List[i][j]= 1 + num0List[i-1][j];
				num1List[i][j]= 0 + num1List[i-1][j];
			}else{
				num0List[i][j]= 0 + num0List[i-1][j];
				num1List[i][j]= 1 + num1List[i-1][j];
			}
		}
	}

	std::vector<long long> p2(61, 1);
	for(int i=1; i< 61; i++)
		p2[i]= (p2[i-1]*2)%mod;


	for(int i=0; i< n-1; i++){
		for(int j=0; j< 61; j++){
			long long tmp= 0;

			if(pow2List[i][j]==0){
				tmp= ((num1List[n-1][j]- num1List[i][j]) * p2[j])%mod;
				ans= (ans+tmp)%mod;
			}
			else{
				tmp= ((num0List[n-1][j]- num0List[i][j]) * p2[j])%mod;
				ans= (ans+tmp)%mod;
			}

		}
	}

	std::cout<<ans<<std::endl;

	return 0;
}

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


Measured memory_bytes: 80256
import itertools
import copy

h, w, k = map(int, input().split())
c = []
for i in range(h):
    inp = str(input())
    c.append(inp)

cnt = 0
h_l = list(range(0,h,1))
w_l = list(range(0,w,1))

for inum in range(h):
    for ilis in itertools.combinations(h_l, inum):
        ilis = list(ilis)

        for jnum in range(w):
            for jlis in itertools.combinations(w_l, jnum):
                jlis = list(jlis)
                c_list = copy.copy(c)

                if len(ilis) != 0:
                    for i in ilis:
                        c_list[i] = '0' * w
                if len(jlis) != 0:
                    for j in jlis:
                        for i in range(h):
                            if not c_list[i] == '0' * w:
                                c_list[i] = c_list[i][0:j] + '0' + c_list[i][j+1:]
                c_str = ''.join(c_list)
                if c_str.count('#') == k:
                    cnt += 1

print(cnt)




Measured memory_bytes: 9352
H = list(map(int, input().split()))
A = list(map(int, input().split()))
T = input()
P=A[2]
R=A[0]
S=A[1]
k=H[1]
ans = 0
T = list(T)

for i in range(int(H[0])):
    a=i-k
    b=T[0]
    if(a<0):
        if(T[i]=="r"):
                ans+=P
                #print("p")
        if(T[i]=="s"):
                ans+=R
                #print("r")
        if(T[i]=="p"):
                ans+=S
                #print("s")
    else:
        if(T[i]=="r"):
            if(T[a] !="r"):
                ans+=P
                #print("p")
            else:
                T[i]="l"
                #print("n")

        if(T[i]=="s"):
            if(T[a] !="s"):
                ans+=R
                #print("r")
            else:
                T[i]="l"
                #print("n")
        if(T[i]=="p"):
            if(T[a] !="p"):
                ans+=S
                #print("s")
            else:
                T[i]="l"
                #print("n")
print(ans)


Measured memory_bytes: 4084
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>

const int N = 3e2 + 10;

int len, k;
int dp[N][N][N];
char s[N];

int dfs(int L, int R, int p) {
	if (dp[L][R][p] != -1) return dp[L][R][p];
	if (L > R) return dp[L][R][p] = 0;
	if (L == R) return dp[L][R][p] = 1;
	dp[L][R][p] = std::max(dfs(L + 1, R, p), dfs(L, R - 1, p));
	if (s[L] == s[R]) dp[L][R][p] = std::max(dp[L][R][p], dfs(L + 1, R - 1, p) + 2);
	if (p) dp[L][R][p] = std::max(dp[L][R][p], dfs(L + 1, R - 1, p - 1) + 2);
	return dp[L][R][p];
}

int main() {
	memset(dp, -1, sizeof(dp));
	scanf(" %s%d", s + 1, &k), len = strlen(s + 1);
	printf("%d\n", dfs(1, len, k));
	return 0;
}

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

using namespace std;

void shuffle(string& str, int c){
  string tmp = str.substr(0,c);
  str.erase(str.begin(), str.begin() + c);
  str += tmp;
}

int main(void) {
  string input;
  string answer[10];
  int shuffleNum = 0;
  int cutPoint = 0;
  int no = 0;
  while(true){
    cin >> input;
    if(input == "-") break;
    cin >> shuffleNum;
    for(int i = 0; i < shuffleNum; i++){
      cin >> cutPoint;
      shuffle(input, cutPoint);
    }
    answer[no] = input;
    no++;
  }
  for(int i = 0; i < no; i++){
    cout << answer[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3208
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007ll
using namespace std;
ll jc[2000005],njc[2000005];
ll fp(ll x,int k=1000000005){
    ll ans=1;
    while(k){
        if(k&1)ans=ans*x%orz;
        k>>=1,x=x*x%orz;
    }
    return ans;
}
ll c(int x,int y){return jc[x+y]*njc[x]%orz*njc[y]%orz;}
int x[10],y[10];
ll ans;
ll sol(ll L,ll U,ll R,ll D){
    ll ret=0;
    for(int i=x[3];i<=x[4];++i){
        ret-=c(y[3]-U-1,i-L)*c(D-y[3],R-i)%orz*(i+y[3])%orz;
        ret+=c(y[4]-U,i-L)*c(D-y[4]-1,R-i)%orz*(i+y[4]+1)%orz;
    }
    for(int i=y[3];i<=y[4];++i){
        ret-=c(x[3]-L-1,i-U)*c(R-x[3],D-i)%orz*(i+x[3])%orz;
        ret+=c(x[4]-L,i-U)*c(R-x[4]-1,D-i)%orz*(i+x[4]+1)%orz;
    }
    return (ret%orz+orz)%orz;
}
int main(){
    jc[0]=1;
    for(int i=1;i<=2000000;++i)jc[i]=jc[i-1]*i%orz;
    njc[2000000]=fp(jc[2000000]);
    for(int i=2000000;i;--i)njc[i-1]=njc[i]*i%orz;
    for(int i=1;i<=6;++i)scanf("%d",x+i);
    for(int i=1;i<=6;++i)scanf("%d",y+i);
    ans+=sol(x[1]-1,y[1]-1,x[6]+1,y[6]+1);
    ans-=sol(x[1]-1,y[1]-1,x[5],y[6]+1);
    ans-=sol(x[1]-1,y[1]-1,x[6]+1,y[5]);
    ans+=sol(x[1]-1,y[1]-1,x[5],y[5]);
    ans-=sol(x[1]-1,y[2],x[6]+1,y[6]+1);
    ans+=sol(x[1]-1,y[2],x[5],y[6]+1);
    ans+=sol(x[1]-1,y[2],x[6]+1,y[5]);
    ans-=sol(x[1]-1,y[2],x[5],y[5]);
    ans-=sol(x[2],y[1]-1,x[6]+1,y[6]+1);
    ans+=sol(x[2],y[1]-1,x[5],y[6]+1);
    ans+=sol(x[2],y[1]-1,x[6]+1,y[5]);
    ans-=sol(x[2],y[1]-1,x[5],y[5]);
    ans+=sol(x[2],y[2],x[6]+1,y[6]+1);
    ans-=sol(x[2],y[2],x[5],y[6]+1);
    ans-=sol(x[2],y[2],x[6]+1,y[5]);
    ans+=sol(x[2],y[2],x[5],y[5]);
    ans=(ans%orz+orz)%orz;
    printf("%lld\n",ans);
    //system("pause");
    return 0;
}


Measured memory_bytes: 31488
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, K;
ll cnt[110], ans;

int main()
{
  std::cin >> N >> K;

  rep( i, K )
  {
    ll d;
    std::cin >> d;

    rep( j, d )
    {
      ll A;
      std::cin >> A;

      --A;
      ++cnt[A];
    }
  }

  rep( i, N ) if( !cnt[i] )
    ++ans;

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3164
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

//verified AOJ GRL_1
#define MAX_V 301
struct edge{int to,cost;};

void dijkstra(int s, vector<int> &d, vector<edge> G[MAX_V]){
    priority_queue< pii,vector<pii>,greater<pii> > que;
    rep( i,d.size() )d[i]=INF;
    d[s] = 0;
    que.push( pii(0,s) );
    
    while( que.size() ){
        pii p=que.top();
        que.pop();
        
        int v=p.second;
        if(d[v]<p.first)continue;
        
        rep(i,G[v].size()){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(pii(d[e.to],e.to));
            }
        }
    }
}

int main(){
    int n;
    while(cin>>n&&n){
        
        vector<int> v(300,-1);
        rep(i,n)cin>>v[i];
        rep(i,n)cin>>v[i+150];
        
        int S = 300;
        vector<edge> G[301];
        
        int p = 0;
        while(v[p]==1&&v[p+1]==1)p++;
        G[S].pb(edge{p,0});
        
        p = 150;
        while(v[p]==1&&v[p+1]==1)p++;
        G[S].pb(edge{p,0});
        
        rep(i,n){
            int to = i+150;
            rep(j,3){
                p = to+j;
                if(v[p]==0)G[i].pb(edge{p,1});
                else if(v[p]==1){
                    while(v[p]==1 && v[p+1]==1)p++;
                    G[i].pb(edge{p,1});
                }else if(v[p]==2){
                    while(p>0 && v[p]==2)p--;
                    G[i].pb(edge{p,1});
                }
            }
        }
        for(int i=150;i<150+n;i++){
            int to = i-150;
            rep(j,3){
                p = to+j;
                if(v[p]==0)G[i].pb(edge{p,1});
                else if(v[p]==1){
                    while(v[p]==1 && v[p+1]==1)p++;
                    G[i].pb(edge{p,1});
                }else if(v[p]==2){
                    while(p>0 && v[p]==2)p--;
                    G[i].pb(edge{p,1});
                }
            }
        }
        vector<int> d(301);
        dijkstra(S,d,G);
        
        int res = min(d[n-1],d[n-1+150]);
        if(res==INF)cout<<"NA"<<endl;
        else cout<<res<<endl;
    }
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9+7;

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> S(n),T(m);
  rep(i,n) cin >> S[i];
  rep(i,m) cin >> T[i];

  vector<vector<ll> > dp(n+2,vector<ll>(m+2,0)), sdp(n+2,vector<ll>(m+2,0));
  sdp[1][1] = 1;
  dp[0][0] = 1;
  rep(i,n+1) {
    rep(j,m+1) {
      if (i == 0 && j == 0) continue;
      if (i-1 >= 0 && j-1 >= 0 && S[i-1] == T[j-1]) {
        dp[i][j] = sdp[i][j];
      }
      (sdp[i+1][j+1] = sdp[i+1][j] + sdp[i][j+1] - sdp[i][j] + dp[i][j] + mod) %= mod;
    }
  }
  cout << sdp[n+1][m+1] << endl;
  return 0;
}

Measured memory_bytes: 63104
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

int solve(int arr[],int n){

    int dp[n+1];
    memset(dp,0,sizeof(dp));
    dp[1]=0;
    dp[2]= abs(arr[2]-arr[1]);

    for(int i=3;i<=n;i++){

        int op1=abs(arr[i]-arr[i-1])+dp[i-1];
        int op2=abs(arr[i]-arr[i-2])+dp[i-2];
        dp[i]=min(op1,op2);
    }
    return dp[n];
}

int32_t main()
{   

    int n;cin>>n;
    int arr[n+1];
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }

    cout<<solve(arr,n)<<endl;

    return 0;
}


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

int main (){
    int a,b;
    cin >> a >> b ;


    if(a < b){
        cout << "a < b";
    }
    else if(a > b){
        cout << "a > b";
    }
    else{
        cout << "a == b";
        }
        cout << endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll MOD = 1000000007;
ll INF =1<<30;

int main(){
    int n,h,w;
    cin >> n >> h >> w;
    cout << (n-h+1)*(n-w+1) <<endl;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair
/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pii;
///-------------------------

/// problem's variable---------------

const ll mod = 1e9+7;
ll fact[100005];

///--------------------------

void init()
{
    fact[0]=fact[1]=1;
    for(ll i=2; i<=100000; ++i)
        fact[i]=(fact[i-1]*i)%mod;
}


ll lt(ll x)
{
    ll y= mod -2;
    ll res=1;
    x=x%mod;
    while (y>0)
    {
        if (y&1) res=(res*x)%mod;
        y=y>>1;
        x=(x*x)%mod;
    }
    return res;
}

ll calc(ll n, ll m)
{
    ll x = fact[n];
    ll y = lt(fact[m]);
    ll dxy = lt(fact[n-m]);
    x=(x*y)%mod;
    return (x*dxy)%mod;
}

int main()
{
    Phuong_;
    ll n,m;
    init();
    cin >> n >> m;
    vector<int> a(n+1);
    for(int i=1; i<=n; ++i)
        cin >> a[i];
    sort(a.begin()+1, a.end());
    ll smax = 0;
    for(int i=m; i<=n; ++i)
    {
        smax=(smax+(calc(i-1,m-1)*a[i])%mod)%mod;
    }
    reverse(a.begin()+1, a.end());
    ll smin=0;
    for(int i=m; i<=n; ++i)
        smin=(smin + (calc(i-1,m-1)*a[i])%mod)%mod;
    cout << (smax-smin)%mod;
    return 0;
}



Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>

#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){
	
	int a,b;
	cin >> a >> b;

	if(a < b){
		for(int i = 0;i < b;i++){
			cout << a;
		}
		cout << endl;
	}
	else{
		for(int i = 0;i < a;i++){
			cout << b;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
  ll x,i,j,k,l,ans=0;
  cin >> x;
  if(x%500==0)
  {
    ans=2*x;
  	cout << ans << endl;
  }
  else
  {
    k=x/500;
    l=x-(k*500);
    ans+=(k*1000);
    if(l%5==0)
    {
      ans+=l;
      cout << ans << endl;
    }
    else
    {
    	j=l/5;
      	ans+=(j*5);
      cout << ans << endl;
    }
  }
}


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

#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define chinko long long

int main() {
	string s,t;
	cin>>s>>t;
	cout<<t+s<<endl;
	return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);
    ll K;
    string S;
    cin >> K >> S;

    if( S.size() <= K ){
        cout << S << endl;
    }else{
        cout << S.substr(0,K) << "..." << endl;
    }
}


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

using I = long long;

int main() {
  int N;
  cin >> N;
  vector<I> A(N);
  for(auto& i: A) cin >> i;
  for(auto i=1; i<N; ++i) A[i] += A[i-1];
  A.emplace(begin(A), 0);

  auto split = [&](auto l, auto r) {
    auto h = (A[r] - A[l-1]) / 2;
    auto x = upper_bound(begin(A), end(A), A[l-1] + h) - begin(A);
    vector<pair<I, I>> v;
    for(auto i: {x-1, x, x+1}) if(l<=i && i<r) v.emplace_back(A[i] - A[l-1], A[r] - A[i]);
    return *min_element(begin(v), end(v), [](auto l, auto r) {return abs(l.first-l.second) < abs(r.first-r.second);});
  };

  auto ok = [&](auto x) {
    for(auto i=2; i<=N-2; ++i) {
      auto l = split(1, i);
      auto r = split(i+1, N);
      if(x < abs(l.first-l.second))  continue;
      if(x < abs(l.first-r.first))   continue;
      if(x < abs(l.first-r.second))  continue;
      if(x < abs(l.second-r.first))  continue;
      if(x < abs(l.second-r.second)) continue;
      if(x < abs(r.first-r.second))  continue;
      return true;
    }
    return false;
  };

  I l = -1, h = 1e16;
  while(1 < h-l) {
    auto m = (l + h) / 2;
    if(ok(m)) h = m;
    else      l = m;
  }
  cout << h << endl;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
int main () {
    double r;
    cin >> r;
    //cout << r * r * M_PI << " " << 2 * r * M_PI << endl;
    printf("%.8f %.8f\n",r*r*M_PI,2*r*M_PI);
    return 0;
}


Measured memory_bytes: 3292
Module _20191029

    Sub Main()
        'https://atcoder.jp/contests/abc143/tasks/abc143_c

        Dim iCount As Integer = CLng(Console.ReadLine())
        Dim sString As String = Console.ReadLine()

        Dim arrChar As Char() = sString

        Dim sBeforeColor As String = arrChar(0)
        Dim iTotalCount As Integer = 1

        For i As Integer = 1 To iCount - 1

            If arrChar(i) <> sBeforeColor Then

                iTotalCount += 1
                sBeforeColor = arrChar(i)

            End If

        Next

        Console.WriteLine(iTotalCount)

    End Sub

End Module

Measured memory_bytes: 22876