akhauriyash/Code-Regression huggingface dataset:
# 最初に入れておくとinputが早くなる
import sys
import numpy as np
input = sys.stdin.readline

# スタック最大数をセット
sys.setrecursionlimit(10**6)

n = int(input())
a = list(map(int, input().split()))
ans = [0]*n
b = 0
for i in range(1, n-1, 2):
    b += a[i]
ans[0] = sum(a)-2*b

tempa = [0]*n
for j in range(n):
    tempa[j] = ans[j % n] // 2
    if(j+1 != n):
        ans[(j + 1) % n] = (a[j] - tempa[j]) * 2
    #print(a, tempa, ans)
print(*ans)

Measured memory_bytes: 26696
#include <iostream>

using namespace std;

int c[12];
int add[12][12];

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

    for (int i = 0; i < n; ++i)
    {
        cin >> c[i];
        for (int j = 0; j < m; ++j)
        {
            cin >> add[i][j];
        }
    }

    int ans = 100000 * 13;
    bool yes = false;
    int l[m];
    int num;

    for (int i = 1; i < (1 << n); ++i)
    {
        int cans = 0;
        for (int j = 0; j < m; ++j)
        {
            l[j] = 0;
        }
        for (int j = 0; j < n; ++j)
        {
            if (i & (1 << j))
            {
                cans += c[j];
                for (int a = 0; a < m; ++a)
                {
                    l[a] += add[j][a];
                }
            }
        }

        num = 0;
        for (int j = 0; j < m; ++j)
        {
            if (l[j] >= x)
            {
                num++;
            }
        }

        if (num == m && cans < ans)
        {
            ans = cans;
            yes = true;
        }
    }

    if (yes)
    {
        cout << ans << "\n";
    }
    else
    {
        cout << "-1\n";
    }

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int mod=998244353;
  long long int n;
  cin>>n;
  long long int k;
  cin>>k;
  vector<pair<long long int,long long int>> hoge(k);
  for(long long int i=0; i<k; i++){
    cin>>hoge.at(i).first>>hoge.at(i).second;
  }
  vector<long long int> dp(n,0);
  vector<long long int> rui(n,0);
  rui.at(0)=0;
  dp.at(0)=1;
  vector<long long int> imos(n,0);
  for(long long int i=0; i<n; i++){
    for(long long int j=0; j<k; j++){
      if(i+hoge.at(j).first<n)imos.at(i+hoge.at(j).first)+=dp.at(i);
      if(i+hoge.at(j).second+1<n)imos.at(i+hoge.at(j).second+1)-=dp.at(i);
      if(i!=n-1){
        rui.at(i+1)%=mod;
        rui.at(i+1)=rui.at(i)+imos.at(i+1);
        dp.at(i+1)=rui.at(i+1);
        dp.at(i+1)%=mod;
      }
    }
  }
  cout<<dp.at(n-1)<<endl;
}

Measured memory_bytes: 7916
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io, flush := NewIO()
	defer flush()
	n := io.ScanInt()
	coords := io.ScanInts(n)
	min := 100 * 100 * 100
	for i := 1; i <= 100; i++ {
		var total int
		for _, coord := range coords {
			total += (coord-i) * (coord-i)
		}
		if total < min {
			min = total
		}
	}
	fmt.Println(min)
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 1000005), 1000005)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#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, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s, t;
  cin >> s >> t;
  s += t;
  int n = stoll(s);
  for (int i = 1; i*i <= n; i++) {
    if (i*i == n) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}

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

int a[41], b[41], c[41];
unsigned dp[41][401][401];

int main()
{
    int n, ma, mb; cin>>n>>ma>>mb;
    for(int i=0; i<n; ++i) cin>>a[i]>>b[i]>>c[i];

    memset(dp, -1, sizeof(dp));
    dp[0][0][0]=0;
    dp[0][a[0]][b[0]]=c[0];
    for(int i=1; i<n; ++i) {
        for(int j=0; j<=401; ++j)
            for(int k=0; k<=401; ++k) {
                if (j>=a[i] and k>=b[i] and ~dp[i-1][j-a[i]][k-b[i]])
                    dp[i][j][k]=min(dp[i-1][j][k], dp[i-1][j-a[i]][k-b[i]]+c[i]);
                else
                    dp[i][j][k]=dp[i-1][j][k];
            }
    }

    
    unsigned res=-1;
    for(int j=1; j<=401; ++j)
        for(int k=1; k<=401; ++k)
            if (j*mb==k*ma and ~dp[n-1][j][k] and res>dp[n-1][j][k])
                res=dp[n-1][j][k];
    cout<<(int)res<<endl;
}


Measured memory_bytes: 25984
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(a) a.begin(), a.end()

const int MAX = 1000000;
int N, M;
vector<pair<int, int>> X;

void abc121c() {
  ll ans = 0, sum = 0;
  sort(ALL(X));
  for (int i = 0; i < N; i++) {
    ll a = X[i].first, b = X[i].second;
    if (sum < M) {
      ll dist = M - sum;
      if (b <= dist) {
        ans += a * b;
        sum += b;
      }
      else {
        ans += a * dist;
        sum += dist;
      }
    }
    if (sum == M) {
      cout << ans << '\n';
      return;
    }
  }
}

int main() {
  cin >> N >> M;
  X.resize(N);
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    X[i].first = a;
    X[i].second = b;
  }
  abc121c();
  return 0;
}

Measured memory_bytes: 1024
program minor_change
  implicit none
  character(200000) :: s, t
  integer :: n, i, x = 0
  read(*,*) s
  read(*,*) t
  n = len_trim(s)
  do i = 1, n
    if (s(i:i) /= t(i:i)) x = x + 1
  end do
  write(*,'(i0)') x
end program minor_change

Measured memory_bytes: 3508
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;

inline int add(int a,int b){return (a%mod + b%mod)%mod;}
inline int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
inline int mul(int a,int b){a%=mod;b%=mod;return a*b%mod;}
inline int power(int a,int b,int MOD){a%=mod;int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}
signed main()
{
     SPEED;
     int n;
     cin>>n;
     string a,b;
     cin>>a>>b;
     for(int i=0;i<n;i++)
        cout<<a[i]<<b[i];
    cout<<endl;
     time();
     return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    print(n - k + 1)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int a[] = {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 main() {
    int K; cin >> K;
    cout << a[K - 1] << '\n';
}

Measured memory_bytes: 256
n, m, r = map(int, input().split())
rs = list(map(int, input().split()))
rs = [i-1 for i in rs]
d = [[float('inf')] * n for i in range(n)]
for i in range(m):
    x, y, r = map(int, input().split())
    x -= 1
    y -= 1
    d[x][y] = r
    d[y][x] = r

for i in range(n):
    d[i][i] = 0

def warshall_floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

d = warshall_floyd(d)

ans = float('inf')
from itertools import permutations
for i in permutations(rs):
    di = 0
    for j in range(len(rs) - 1):
        di += d[i[j]][i[j + 1]]
    ans = min(ans, di) 

print(ans)

Measured memory_bytes: 75040
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

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

int main(){
    int n;
    cin>>n;
    vector <int> a(n);
    double ave=0;
    rep(i,n){
        cin>>a.at(i);
        ave+=a.at(i);
    }
    int v=round(ave/n);
    int64_t sum=0;
    rep(i,n)
    sum+=pow(v-a.at(i),2.0);
    cout<<sum<<endl;
    return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vl;typedef vector<vl> vvl;typedef pair<ll,ll> pl;typedef vector<pl> vp;const ll INF=1001001001;const ll LINF=1001001001001001001;const ll D4[]={0,1,0,-1,0};const ll D8[]={0,1,1,0,-1,-1,1,-1,0};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;}
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()

void solve(long long N, std::vector<long long> A){
    ll sum=0,cnt0=0,cntM=0,mi=LINF;
    rep(i,N){
        sum+=abs(A[i]);
        if(A[i]==0)cnt0++;
        if(A[i]<0)cntM++;
        chmin(mi,abs(A[i]));
    }
    if(cnt0||cntM%2==0){
        cout<<sum<<endl;
    }else{
        cout<<sum-2*mi<<endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n; cin >> n;
    cout << 3*n*n << endl;
}

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

int main()
{
    int n, m, x, y;
    int a[21][21];
    char c;

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

        for( int i = 0; i < 21; i++ )
            for( int j = 0; j < 21; j++ )
                a[i][j] = false;

        for( int i = 0; i < n; i++ )
        {
            cin >> x >> y;
            a[20-y][x] = true;
        }

        cin >> m;

        int cnt = 0, s = 10, t = 10;
        for( int i = 0; i < m; i++ )
        {
            cin >> c >> x;
            while( x-- )
            {
                if( c == 'N' )
                    s--;
                else if( c == 'S' )
                    s++;
                else if( c == 'E' )
                    t++;
                else
                    t--;
                if( a[s][t] == true )
                {
                    a[s][t] = false;
                    cnt++;
                }
            }
        }
        if( cnt == n )
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long int
// #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

int main() 
{
    // fastio;

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif

    int n;
    cin>>n;
    int k;
    cin>>k;
    vector<int> h(n);
    for(int i=0;i<n;i++)
        cin>>h[i];

    vector<int> dp(n,INT_MAX);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    
    for(int i=2;i<n;i++)
        for(int j=i-1;j>=0 && (i-j)<=k;j--)
            dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
    
    cout<<dp[n-1]<<endl;
    return 0;
}        

Measured memory_bytes: 1024
// Fuwa Fuwa Time!

#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef pair<int, int> pii;

const int MAXN = (int) 1e3, MAXM = (int) 5e3;

int n;

vector<int> adj[MAXN + 5];

int w[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 2; i <= n; ++i)
	{
		int fa = read<int>();
		adj[fa].push_back(i);
	}
	for(int i = 1; i <= n; ++i) w[i] = read<int>();
}

const int INF = (int) 1e9;

int M, f[MAXN + 5];

inline void dfs(int u)
{
	for(auto v : adj[u]) dfs(v);

	static int g[MAXM + 5];
	for(int i = 0; i <= w[u]; ++i) g[i] = INF;

	g[0] = 0;
	for(auto v : adj[u])
	{
		static int res[MAXM + 5];
		for(int i = 0; i <= w[u]; ++i) res[i] = INF;

		for(int i = 0; i <= w[u]; ++i)
		{
			if(i + f[v] <= w[u]) chkmin(res[i + f[v]], g[i] + w[v]);
			if(i + w[v] <= w[u]) chkmin(res[i + w[v]], g[i] + f[v]);
		}
		for(int i = 0; i <= w[u]; ++i) g[i] = res[i];
	}

	f[u] = INF;
	for(int i = 0; i <= w[u]; ++i) chkmin(f[u], g[i]);
}

inline void solve()
{
	M = w[1];
	dfs(1);
	puts(f[1] < INF ? "POSSIBLE" : "IMPOSSIBLE");
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("E.in", "r", stdin);
	freopen("E.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 384
N = int(input())
s = list(input())
t = list(input())
N2 = N * 2
ans = 0
for i in range(N):
    temp = 0
    ns = s[i:]
    for j, k in zip(ns, t):
        if j == k:
            temp += 1
        else:
            break
    else:
        ans = max(ans, temp)

print(N2 - ans)

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a,b; cin >> a >> b;
  if(a+b>=10) cout << "error" << endl;
  else cout << a+b << endl;
  
  return 0;
}


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

int main()
{
	int64_t n, m, mod = 1000000007;
	cin >> n >> m;
	vector<int64_t> as(m);
	for (auto &a : as)
	{
		cin >> a;
	}

	vector<int64_t> dp(n + 1, 0);
	dp[0] = 1;

	for (int64_t i = 1; i <= n; i++)
	{
		{
			auto itr = lower_bound(as.begin(), as.end(), i);
			if (itr != as.end() && (*itr) == i)
			{
				continue;
			}
		}
		(dp[i] += dp[i - 1]) %= mod;
		if (2 <= i)
		{
			(dp[i] += dp[i - 2]) %= mod;
		}
	}

	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 1792
x = list(map(int, input().split()))
x.sort()
a, b, c = x
ans = 0
if (c - a) % 2 == (c - b) % 2:
    print((2 * c - a - b)//2)
else:
    print((2 * c + 1 - a - b)//2 + 1)


Measured memory_bytes: 2940
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

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

	int R, C, K;
	cin >> R >> C >> K;

	vector<vector<int>> V(R, vector<int>(C, 0));

	int y, x, v;
	rep(i, 0, K)
	{
		cin >> y >> x >> v;
		y--, x--;
		V[y][x] = v;
	}

	vector < vector<vector<int>>> DP(R+1, vector<vector<int>>(C+1, vector<int>(4, 0)));

	rep(i, 0, R)rep(j, 0, C)
	{
		int ni = i + 1, nj = j + 1;
		int res = 0;
		rep(k, 0, 4)chmax(res, DP[i][nj][k]);
		rep(k, 0, 4)
		{
			chmax(DP[ni][nj][k], max(DP[ni][j][k], res));
			if (k < 3)chmax(DP[ni][nj][k + 1], max(DP[ni][j][k], res) + V[i][j]);
		}
	}

	int ans = 0;
	rep(i, 0, 4)chmax(ans, DP[R][C][i]);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 707096
def get_neg(neg_list, k, mod):
    ans = 1
    neg_list.sort(reverse=True)
    for num in neg_list[:k]:
        ans = ans * num % mod
    return ans


def get_pos(pos_list, neg_list, k, mod):
    ans = 1
    nums = []
    neg_iter = iter(sorted(neg_list))
    pos_iter = iter(sorted(pos_list, reverse=True))
    if k % 2 == 1:
        ans *= pos_iter.__next__()
        k -= 1
        
    for a, b in zip(pos_iter, pos_iter):
        nums.append(a * b)

    for a, b in zip(neg_iter, neg_iter):
        nums.append(a * b)

    nums.sort(reverse=True)
    for num in nums[:k//2]:
        ans *= num
        ans %= mod
    return ans


def get_all(num_list, mod):
    ans = 1
    for num in num_list:
        ans = ans * num % mod
    return ans


def main():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    
    if n == k:
        ans = get_all(A, mod)
        print(ans)
        return
    
    pos_list = []
    neg_list = []

    for a in A:
        if a >= 0:
            pos_list.append(a)
        else:
            neg_list.append(a)

    if k % 2 and not pos_list:
        ans = get_neg(neg_list, k, mod)
    else:
        ans = get_pos(pos_list, neg_list, k, mod)

    print(ans)


if __name__ == "__main__":
    main()


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

int cnt = 0;

void insertionSort(int a[], int n, int g) {
  for (int i=g; i<n; i++) {
    int v = a[i];
    int j = i - g;
    while (j >= 0 && a[j] > v) {
      a[j+g] = a[j];
      j -= g;
      cnt++;
    }
    a[j+g] = v;
  }
}

void shellSort(int a[], int n) {
  vector<int> G;
  int h = 1;
  while (h <= n) {
    G.push_back(h);
    h = 3 * h + 1;
  }

  for (int i=G.size()-1; i>=0; i--)
    insertionSort(a, n, G[i]);

  // print info
  cout << G.size() << endl;
  if (G.size() > 0) {
    for (int i=G.size()-1; i>0; i--)
      cout << G[i] << " ";
    cout << G[0] << endl;
  }
}

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

  shellSort(a, n);

  cout << cnt << endl;

  for (int i=0; i<n; i++) cout << a[i] << endl;;

  return 0;
}



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

bool check(int n, int* arr1, vector<int> r)
{
    bool same = true;
    for (int i=0; i<n; ++i) {
        if (arr1[i] != r[i]) {
            same = false;
        }
    }
    return same;
}

int main()
{
    int n, p[10], q[10], a, b, count = 1;
    cin >> n;
    for (int i=0; i<n; ++i) {
        cin >> p[i];
    }
    for (int i=0; i<n; ++i) {
        cin >> q[i];
    }
    vector<int> r(n);
    for (int i=0; i<n; ++i) {
        r[i] = i+1;
    }

    do {
        if (check(n, p, r)) {
            a = count;
        }
        if (check(n, q, r)) {
            b = count;
        }
        count++;
    } while (next_permutation(r.begin(), r.end()));

    cout << abs(a - b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main()
{
  int x;
  
  scanf("%d",&x);
  
  int ans=1;
  int i,j;
  
  for(i=1;i<=x;i++)
  {
    for(j=2;j<=10;j++)
    {
      if(x>=pow(i,j)&&ans<=pow(i,j))
      {
        ans=pow(i,j);
      }
    }
  }
  
  printf("%d\n",ans);
  
  return 0;
}

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

using namespace std;
typedef long long Int;
int main(){
	Int n, res;
	Int p[108000], j[108000];
	while(cin >> n, n){
		Int sum = 0;
		for(int i = 0;i < n;i++)cin >> p[i], sum += p[i];
		for(int i = 0;i < n - 1;i++)cin >> j[i];
		sort(j, j + n - 1);
		res = sum * n;
		for(int i = n - 2;i >= 0;i--){
			sum += j[i];
			res = max(res, sum * (i + 1));
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 2196
a = input()
b = []
c = int(len(a))
import collections

for i in range(c):
  b.append(a[i])

d = collections.Counter(b)
e = []

for i in d.values():
  e.append(i)

f = int(len(e))
g = int(0)

for i in range(f):
  if int(e[i]) % 2 == 0:
    pass
  else:
    g = g + 1

if g == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9240
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << (x) << ", "
#define de(x) cout << #x << " = " << (x) << "\n"
#define endl "\n"

//-----
const int N = 1e2 + 7;
int n, a[N];
int Sqr(int d) { return d * d; }
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> n;
	rep(i, 0, n) cin >> a[i];
	int ans = INT_MAX;
	rep(mid, -100, 101) {
		int tmp = 0;
		rep(i, 0, n) tmp += Sqr(a[i] - mid);
		ans = min(ans, tmp);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

void omit_LF (void)
{
  char c;
  int  cnt;
  
  cnt = scanf("%c", &c);
  return;
}

char *get_S (int64 n)
{
  char *buf;
  int  i;
  int  cnt;

  buf = malloc((size_t)(n * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  return buf;
}

int main()
{
  int64 N = 22;
  char *str;
  char *str1;
  char *str2;
  char *strU;
  int64 A,B;
  
  str1 = get_S(N);
  str2 = get_S(N);

  get_NK(&A, &B);

  strU = get_S(N);

  if (strcmp(strU, str1) == 0) {
    A--;
  } else if (strcmp(strU, str2) == 0) {
    B--;
  }
  printf("%lld %lld", A, B);

  return 0;
}



Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(In));
        }

        public long Min(params long[] a)
        {
            var min = a[0];
            for (int i = 1; i < a.Length; i++)
            {
                if (min > a[i]) min = a[i];
            }
            return min;
        }

        public long Max(params long[] a)
        {
            var max = a[0];
            for (int i = 1; i < a.Length; i++)
            {
                if (max < a[i]) max = a[i];
            }
            return max;
        }

        public void Solve(ConsoleInput input)
        {
            var n = input.ReadInt;
            var m = input.ReadInt;
            var x = input.ReadIntArray(m);

            var xsorted = x.OrderBy(i => i).ToArray();
            var dx = new int[m - 1];
            for (var i = 0; i < m - 1; i++)
            {
                dx[i] = xsorted[i + 1] - xsorted[i];
            }

            WriteLine($"{dx.OrderByDescending(i => i).Skip(n - 1).Sum()}");

            //Solve(input);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private readonly char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            _separator = separator;
            _stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


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

#define int long long

using namespace std;

int b[100001];
int a[100001];

 main () {
    int n, m;
    cin >> n >> m;
    for (int i = 1;i <= n + n;i ++) b[i] = 1e18 + 7;
    for (int i = 1;i <= n;i ++) cin >> a[i];
    for (int i = 1;i <= n;i ++) a[i + n] = a[i];
    int ans = 1e18 + 7;
    for (int k = 0;k <= n;k ++) {
        int cur = k * m;
    	for (int i = n + 1;i <= n + n;i ++) {
			b[i] = min (b[i], a[i - k]);
			cur += b[i]; 
    	}
    	ans = min (ans, cur);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
MyString=Union{String,SubString{String},Char}
MyStringArray=Union{Array{String,1},Array{SubString{String},1},Array{Char,1}}
parseInt(x::MyString) = parse(Int, x)
parseInt(x::Real) = trunc(Int, x)
parseBigInt(x::MyString) = parse(BigInt, x)
parseBigInt(x::Real) = trunc(BigInt, x)
parseFloat(x::MyString) = parse(Float64, x)
parseFloat(x::Real) = trunc(Float64, x)
parseBigFloat(x::MyString) = parse(BigFloat, x)
parseBigFloat(x::Real) = trunc(BigFloat, x)
parseMap(x::MyStringArray) = map(parseInt, x)
parseMapBig(x::MyStringArray) = map(parseBigInt, x)

function main()
    n,k=parseMap(split(readline()))
    d=split(readline())
    for i in n:10n
        s=string(i)
        flg=true
        for j in s
            if string(j) in d
                flg=false
            end
        end
        if flg
            println(i)
            break
        end
    end
end
main()

Measured memory_bytes: 151660
using System;

namespace Aizu {
    public class OnlineJudge {
        static void Main() {
            var くコX彡 = new[] { int.Parse(Console.ReadLine()), Console.ReadLine().IndexOf("xx") + 1 };
            Console.WriteLine(くコX彡[くコX彡[1] == 0 ? 0 : 1]);
        }
    }
}


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

#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];


int check(llong P) {
  int i = 0;
  for ( int j = 0; j < k; j++ ) {
    llong s = 0;
    while ( s + T[i] <= P ) {
      s += T[i];
      i++;
      if ( i == n ) return n;
    }
  }
  return i;
}

int solve() {
  llong left = 0;
  llong right = 100000 * 10000;
  llong mid;
  while ( right - left > 1 ) {
    mid = (left + right) / 2;
    int v = check(mid);
    if ( v >= n ) right = mid;
    else left = mid;
  }

  return right;
}

int main() {
  cin >> n >> k;
  for ( int i = 0; i < n; i++ ) cin >> T[i];
  llong ans = solve();
  cout << ans << endl;
}

Measured memory_bytes: 3884
//Prime number search

#include<stdio.h>

int era(int e)
{
  int i;
  
  //delert 0 and 1
  if(e < 2) return 0;
  else if(e == 2) return 1;
  if(e % 2 == 0) return 0;

  //search
  for(i = 3; i*i <= e; i+=2)
    {
      if(e % i == 0) return 0;
    }

  return 1;
}

int main()
{
  int n,i,e,count;

  //input data
  scanf("%d",&n);
  for(i = 0; i < n; i++)
    {
      scanf("%d",&e);

      //work
      if(era(e)) count++;
    }

  //output data
  printf("%d\n",count);

  
  return 0;
}



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

typedef long long                   ll;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<string , string>       pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define F                           first
#define S                           second
#define sep                         ' '
#define file_io                     freopen("input.txt" , "r+" , stdin) ; freopen("output.txt" , "w+" , stdout);
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(x)                    cerr << "$$$ " << x << '\n';
#define error2(x,y)                 cerr << "#F : " << x << "      #S : " << y << '\n';
#define pb                          push_back

const ll MX5 = 3*1e5+3;
const ll MX6 = 2*1e6+3;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
const ll MOD2= 998244353;
const ll Div3= -157;

ll power(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));
}
ll bmm(ll a,ll b){
    return (a%b==0 ? b : bmm(b,a%b));
}
ll A[MX5];
ll B[MX5];
ll Min[MX5];
ll Max[MX5];
bool is[MX5];
int main(){
    fast_io
    //file_io
    ll n,k;
    cin >> n >> k;
    for(int i=0;i<n;i++) cin >> A[i];

    deque<pll> dq;
    for(int i = 0; i < n; i++){
        while(!dq.empty() && i - dq.front().S >= k){
            dq.pop_front();
        }
        while(!dq.empty() && dq.back().F < A[i]){
            dq.pop_back();
        }
        dq.pb({A[i],i});
        Max[i] = dq.front().F;
    }

    dq.clear();
    for(int i=0;i<n;i++){
        while(!dq.empty() && i - dq.front().S >= k){
            dq.pop_front();
        }
        while(!dq.empty() && dq.back().F > A[i]){
            dq.pop_back();
        }
        dq.pb({A[i],i});
        Min[i] = dq.front().F;
    }
    /*
    for(int i=0;i<n;i++){
        cout << i << " : " << Min[i] << sep << Max[i] << endl;
    }
    */
    ll p=0;
    for(ll i=0;i<n;i++){
        p=max(p,i);
        ll t=0;
        ll la=A[p];
        while(A[p]>=la && p<n){
            t++;
            p++;
            la=A[p-1];
        }
        p--;
        B[i]=p;
    }
    ll men=0;
    ll ans=0;
    for(int i=0;i<n-k+1;i++){
        is[i]=1;
        if(B[i]-i+1>=k){
            ans++;
            is[i]=0;
        }
        else if(i>=1){
            if(is[i-1]){
                    //error(i);
                    //error2(i-1+k-1,i+k-1)
                    //error2(Min[i-1+k-1],Max[i+k-1])
                if(Min[i-1+k-1] == A[i-1] && Max[i+k-1]==A[i+k-1]) men++;
            }
        }
    }
    ll ex=0;
    if(ans) ex++;
    //error(ans);
    cout << n-k+1-ans+ex-men;
    return 0;
}
/// A japanese friend told me that reaching blue in a div3 (and yellow in a div2) is dishonorable.
//! N.N


Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define COut(s) cout << s << endl;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

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

    int w = 0, b = 0;
    int n = s.length();
    int ans = s.size();

    for (int i = 0; i < 2; ++i)
    {
        int cnt = 0;

        for (int j = 0; j < n; ++j)
        {
            // (char)(0+'0') -> '0';
            // (char)(1+'0') -> '1';
            // if ((j % 2 == 0) ^ (s[i] == (char)(i + '0')))                cnt++;
            if (j % 2 == 0 && s[j] != (i + '0'))
                cnt++;
            if (j % 2 == 1 && s[j] == (i + '0'))
                cnt++;
        }
        ans = min(ans, cnt);
    }

    COut(ans);
    return 0;
}

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

using namespace std;

#define allof(x) (x).begin(), (x).end()

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



int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    int N, K;
    cin >> N >> K;

    cout << (N - 1 + (K - 1) - 1) / (K - 1);
}


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

class Main{
    static private node t = null;
    final static private StringBuilder sb = new StringBuilder();
    public static void main(String[] Args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        String in;
        for(int i = 0; i<n; i++){
            in = br.readLine();
            if(in.charAt(0)=='p'){
                inorder(t);
                sb.append('\n');
                preorder(t);
                sb.append('\n');
            }else{
                insert(new node(Integer.parseInt(in.substring(7))));
            }
        }
        System.out.print(sb);
    }
    static void inorder(node t){
        if(t==null) return;
        inorder(t.left);
        sb.append(' ').append(t.key);
        inorder(t.right);
    }
    static void preorder(node t){
        if(t==null) return;
        sb.append(' ').append(t.key);
        preorder(t.left);
        preorder(t.right);
    }
    static void insert(node z){
        node y = null;
        node x = t;
        while(x!=null){
            y = x;
            if(z.key<x.key){
                x = x.left;
            }else{
                x = x.right;
            }
        }
        if(y==null){
            t = z;
        }else if(z.key<y.key){
            y.left = z;
        }else{
            y.right = z;
        }
    }
}
class node{
    final public int key;
    public node left;
    public node right;
    node(int key){
        this.key = key;
        left = right = null;
    }
}

Measured memory_bytes: 94644
use proconio::input;

fn main() {
    input! {
        n: usize,
        mut d: [u64; n + 1],
    }
    let depth = n + 1;

    let mut lim = vec![0 as u64; n + 1];
    for i in (1..depth).rev() {
        lim[i - 1] = lim[i] + d[i];
    }

    let mut node = 1;
    let mut r: i64 = 1;
    for i in 0..depth {
        if d[i] > node {
            r = -1;
            break;
        }

        node = std::cmp::min((node - d[i]) * 2, lim[i]);
        r += node as i64;
    }

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


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

using namespace std;

int main()
{
    int n, m;

    cin >> n;
    cin >> m;

    vector<vector<int>> A(m + 1);
    priority_queue<int> pq;
    int result = 0;

    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        if (a <= m)
        {
            A[a].push_back(b);
        }
    }

    for (int i = 1; i <= m; i++)
    {
        sort(A[i].begin(), A[i].end(), greater<int>());
    }

    for (int i = 1; i <= m; i++)
    {
        int mi = min((int)A[i].size(), m);
        for (int j = 0; j < mi; j++)
        {
            pq.push(A[i][j]);
        }

        if (!pq.empty())
        {
            result += pq.top();
            pq.pop();
        }
    }

    cout << result << endl;

    return 0;
}

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

int main() {
	vector<int> grp = { 0, 1 , 3, 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1 };	// 0-12のグループを表す配列
	int x, y;
	cin >> x >> y;
	if (grp.at(x) == grp.at(y)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
w, h, n = map(int, input().split())
wmin = w
hmin = h
wmax = 0
hmax = 0
for i in range(n):
    x, y, a = map(int, input().split())
    if a==1:
        wmax = max(wmax,x)
    elif a==2:
        wmin = min(wmin,x)
    elif a==3:
        hmax = max(hmax,y)
    elif a==4:
        hmin = min(hmin,y)
if wmin-wmax<0 or hmin-hmax<0:
    print(0)
else:
    print((wmin-wmax)*(hmin-hmax))
    

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int a,b,c;
	string s="dangerous";
	cin >> a; cin >> b; cin >> c;
	//a[0]==a[2]?cout << "Yes"<< endl: cout << "No" << endl;
	//if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)s = "Possible";
	if (c <= a + b)s = "safe";
	if (c <= b)s = "delicious";
	cout << s << endl;
	
}

Measured memory_bytes: 256
// 2011/04/02 Tazoe

#include <iostream>
using namespace std;

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

		int sum = 0;
		for(int i=5; n/i; i*=5)
			sum += n/i;

		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,c;
  cin >>a>>b>>c;
  if(a+b+c == 17 && a*b+b*c+c*a == 95 && a*b*c == 175){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  map<string, int> day;
  day["SUN"] = 7,day["MON"] = 6,day["TUE"] = 5,day["WED"] = 4,day["THU"] = 3,day["FRI"] = 2,day["SAT"] = 1;
  string S; cin >> S;
  cout << day.at(S) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main() {
	char s[100001];
	scanf("%s", s);
	for (int i = 0; i < strlen(s); i++) {
		if (i % 2 == 0) {
			printf("%c", s[i]);
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - (int)1e8;
const ll INFLL = numeric_limits<ll>::max() - (ll)1e17;

int main() {
    int N;
    cin >> N;
    vector<int> a(N, 0);
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
        int temp;
        cin >> temp;
        a[i] |= (temp<<j);
    }
    vector<int> dp(1<<N, 0);
    dp[0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = (1<<N) - 1; j >= 0; j--) {
            if (dp[j] == 0) continue;
            for (int k = 0; k < N; k++) {
                if (((a[i]>>k)&1) == 0) continue;
                if ((j>>k)&1) continue;
                int next = j | (1<<k);
                dp[next] += dp[j];
                if (dp[next] > MOD) dp[next] %= MOD;
            }
        }
    }
    cout << dp[(1<<N) - 1] << endl;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
int n, m, x, y;
vector<int> a[100020];
long long A[100020];
long long B[100020];
long long g[100020];
int f[100020];
int r[100020];
int v[100020];
int F(int x) {
	return f[x] != x ? f[x] = F(f[x]) : x;
}
int cmp(int x, int y) {
	return A[x] < A[y];
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf("%lld%lld", &A[i], &B[i]);
		A[i] = max(A[i] - B[i], 0LL);
		r[i] = i;
	}
	sort(r + 1, r + 1 + n, cmp);
	for (int i = 0; i < m; i++) {
		scanf("%d%d", &x, &y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	for (int i = 1; i <= n; i++) {
		v[r[i]] = 1;
		f[r[i]] = r[i];
		g[r[i]] = A[r[i]];
		for (int j: a[r[i]]) {
			j = F(j);
			if (v[j] && j != r[i]) {
				B[r[i]] += B[j];
				g[r[i]] = min(g[r[i]], max(g[j], A[r[i]] - B[j]));
				f[j] = r[i];
			}
		}
	}
	printf("%lld\n", g[F(1)] + B[F(1)]);
	return 0;
}

Measured memory_bytes: 9468
#include <iostream>
#include <algorithm>

using namespace std;

int arr[100001];
int parent[100001];

int find(int a)
{
	if (a == parent[a])
		return a;
	return parent[a] = find(parent[a]);

}

void Union(int a, int b)
{
	int num1 = arr[a];
	int num2 = arr[b];
	num1 = find(num1);
	num2 = find(num2);
	parent[num1] = num2;
	arr[a] = num2;
}
int main()
{

	ios_base::sync_with_stdio(0);

	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		cin >> arr[i];
		parent[i] = i;
	}
	for (int i = 1; i <= m; i++)
	{
		int a, b;
		cin >> a >> b;
		Union(a, b);
	}
	for (int i = 1; i <= n; i++)
		parent[i] = find(i);
	
	int ans = 0;
	for (int i = 1; i <= n; i++)
		if (find(arr[i]) == parent[i])
			ans++;
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1e9 + 7;
ll bin_pow(ll x, ll y) { 
    ll res = 1;
    while (y > 0) { 
        if (y & 1) res = (res*x) % mod; 
        y >>= 1; 
        x = (x * x) % mod; 
    } 
    return res; 
} 
ll nCr(ll n, ll r) { 
    if (!r) return 1; 
    ll x = 1;
    for (ll i = n - r + 1; i <= n; ++i) {
        x = (x * i) % mod; 
    }
    ll y = 1;
    for (ll i = 2; i <= r; ++i) y = (y * i) % mod;
    return (x * bin_pow(y, mod-2)) % mod; 
} 
void solve(){
    ll n, a, b;
    cin >> n >> a >> b;
    cout << (bin_pow(2, n) + mod - (nCr(n, a) + nCr(n, b)) % mod - 1) % mod;
}
int main(){
    speed;
    ll t = 1;
    //cin >> t;
    for (ll i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 256
W, H, N = map(int, raw_input().split())
w, h = 0, 0
 
for i in xrange(N):
    x, y, a = map(int, raw_input().split())

    if a == 1 and w < x:
        w = x
    elif a == 2 and W > x :
        W = x
    elif a == 3 and h < y:
        h = y
    elif a == 4 and H > y:
        H = y
 
print max(W-w, 0) * max(H-h, 0)

Measured memory_bytes: 2568
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#include <bitset>
#include <queue>


#define Z class
#define ln cout<<'\n'
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
// sort(vec.begin(), vec.end()); std::greater<>()
// reverse(vec.begin(), vec.end());
// scanf("%s",s);
// printf("%d\n",end-start+1);
// ceil (a + (b - 1)) / b

using namespace std;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
using pll = pair<long long, long long>;

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<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
pair<pair<string, int>, int> p[110];

int main(){
    int N; cin >> N;
    int sum = 0;
    int n = N;

    while(N > 0) {
        sum += N%10;
        N /= 10;
    }
    if (n % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}





Measured memory_bytes: 256