akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

constexpr long long mod = 1e9 + 7;

long long pow_mod(long long n, long long p) {
    long long ret = 1;
    while (p > 0) {
        if (p & 1) ret = (ret * n) % mod;
        n = (n * n) % mod;
        p >>= 1;
    }
    return ret;
}

vector<pair<long long, long long>> fact(long long n) {
    vector<pair<long long, long long>> arr;
    for (LL i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            LL cnt = 0;
            while (n % i == 0) cnt++, n /= i;
            arr.push_back(make_pair(i, cnt));
        }
    }
    if (n != 1) arr.push_back(make_pair(n, 1));
    return arr;
}

long long ncr_mod(long long n, long long r) {
    long long nominator = 1;
    long long dominator = 1;
    if (n / 2 < r) r = n - r;
    for (LL i = 0; i < r; i++) {
        nominator *= (n - i);
        nominator %= mod;
        dominator *= (i + 1);
        dominator %= mod;
    }
    return nominator * pow_mod(dominator, mod - 2) % mod;
}

int main() {

    LL N, M;
    cin >> N >> M;

    auto factors = fact(M);

    LL ans = 1;
    for (int i = 0; i < factors.size(); i++) {
        LL d = factors[i].second;
        LL dd = ncr_mod(N + d - 1, d);
        ans *= dd;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}





























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

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

using namespace std;

vector<string> G;

const int H = 12, W = 6;

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

bool in_range(int y, int x) {
  return 0<=x&&x<W && 0<=y&&y<H;
}

void drop() {
  vector<vector<char>> vs(W);
  rep(j, W) rep(i, H) {
    if(G[H-1-i][j] != '.')
      vs[j].push_back(G[H-1-i][j]);
  }
  rep(i, W) {
    while((int)vs[i].size() < H) vs[i].push_back('.');
  }
  rep(j, W) rep(i, H) {
    G[H-1-i][j] = vs[j][i];
  }
}

bool vis[H][W];

int counte(int y, int x, char c) {
  int r = 1;
  rep(k, 4) {
    int ny = y + dy[k], nx = x + dx[k];
    if(!in_range(ny, nx)) continue;
    if(G[ny][nx] != c) continue;
    if(vis[ny][nx]) continue;
    vis[ny][nx] = 1;
    r += counte(ny, nx, c);
  }
  return r;
}

void erase(int y, int x, char c) {
  G[y][x] = '.';
  rep(k, 4) {
    int ny = y + dy[k], nx = x + dx[k];
    if(!in_range(ny, nx)) continue;
    if(G[ny][nx] == 'O') {
      G[ny][nx] = '.';
    }
  }
  rep(k, 4) {
    int ny = y + dy[k], nx = x + dx[k];
    if(!in_range(ny, nx)) continue;
    if(G[ny][nx] == c) {
      erase(ny, nx, c);
    }
  }
}

int simulate() {
  int ret = 0;
  while(1) {
    bool ok = 0;
    rep(i, H) rep(j, W) {
      if(G[i][j] != '.' && G[i][j] != 'O') {
	memset(vis, 0, sizeof vis);
	vis[i][j] = 1;
	if(counte(i, j, G[i][j]) < 4) continue;
	ok = 1;
	erase(i, j, G[i][j]);
      }
    }
    if(ok) {
      ret ++, drop();
      ///      rep(i, H) cout << G[i] << endl; cout << endl;
    }
    else break;
  }
  return ret;
}

int main() {
  
  int T; cin >> T;
  rep(_, T) {
    G.clear();
    G.resize(H);
    rep(i, H) cin >> G[i];
    cout << simulate() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

ll fact[N];
ll ifact[N];

ll nCr(ll n, ll r) {
  if (n < r)
    return 0;
  return fact[n] * ifact[r] % mod * ifact[n - r] % mod;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  fact[0] = ifact[0] = 1;
  for (ll i = 1; i < N; i++) {
    fact[i] = (i * fact[i - 1]) % mod;
    ifact[i] = power(fact[i], mod - 2, mod);
  }
  ll n, m, k;
  cin >> n >> m >> k;

  ll res = 0;
  for (ll i = 1; i <= n; i++) {
    for (ll j = 1; j <= m; j++) {
      ll L = i - 1;
      ll R = n - i;

      ll valL = (L * (L + 1) / 2) % mod;
      ll valR = (R * (R + 1) / 2) % mod;
      res += m * nCr(n * m - 2, k - 2) % mod * valL % mod;
      res %= mod;
      res += m * nCr(n * m - 2, k - 2) % mod * valR % mod;
      res %= mod;
    }
  }

  swap(n, m);
  for (ll i = 1; i <= n; i++) {
    for (ll j = 1; j <= m; j++) {
      ll L = i - 1;
      ll R = n - i;

      ll valL = (L * (L + 1) / 2) % mod;
      ll valR = (R * (R + 1) / 2) % mod;
      res += m * nCr(n * m - 2, k - 2) % mod * valL % mod;
      res %= mod;
      res += m * nCr(n * m - 2, k - 2) % mod * valR % mod;
      res %= mod;
    }
  }

  res *= power(2, mod - 2, mod);
  res %= mod;
  cout << res << en;

  return 0;
}

Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;

namespace _0028
{
    class Program
    {
        static void Main(string[] args)
        {
            var modeValues = new Dictionary<int, int>();

            while (true)
            {
                var input = Console.ReadLine();
                if (string.IsNullOrEmpty(input))
                {
                    break;
                }

                if (modeValues.ContainsKey(int.Parse(input)))
                {
                    modeValues[int.Parse(input)]++;
                }
                else 
                {
                    modeValues.Add(int.Parse(input), 1);
                }
            }
            var sortedModeValues = modeValues.OrderBy(a =>a.Key).OrderByDescending(a => a.Value);

            foreach(var modeValue in sortedModeValues)
            {
                if (modeValue.Value == sortedModeValues.First().Value)
                {
                    Console.WriteLine(modeValue.Key);
                }else
                {
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 6536
n = int(input())
a = list(map(int,input().split()))

def devide(a,c,n):
    even = True
    for i in range(n):
        if a[i] % 2 != 0:
           even = False
        else:
            a[i] = int(a[i] / 2)
    return devide(a,c+1,n) if even else c
print(devide(a,0,n))

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
long long int k,l,m,x,y,z,flag,cvp=1,ar[10005];
int main()
{
	scanf("%lld %lld",&k,&l);
	for(int i = 1; i <= k; i++)
	{
		scanf("%lld",&x);
		cvp*=2;
		if(x%2==1)
		{
			flag=1;
		}
	}
	if(flag==1)
	{
		printf("%lld",cvp/2);
		return 0;
	}
	if(l==1 && flag==0)
	{
		printf("0");
		return 0;
	}
	printf("%lld",cvp);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    int N,K;
    cin >> N >> K;
    vector<int> a(N);
    rep(i,N) cin >> a[i];
    rep(i,N-K){
        if(a[i] < a[i+K]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 4004
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
        String str2 = str.toLowerCase();
        if(str.equals(str2)){System.out.println("a");}
		else{System.out.println("A");}
	}
}

Measured memory_bytes: 35612
#include<iostream>
#include<string.h>

int array[100001];
int n, k;

void add( int i, int x )
{
 	while( i <= n ){
		array[i] += x;
		i += i & (-i);
	}	
	
	return;
}

int sum( int i )
{
	int s = 0;
 	
	while( i > 0 ){
	 	s += array[i];
		i -= i & (-i);
	}
	
	return s;
}

int main()
{
	while( std::cin >> n >> k, n, k ){
		memset( array, 0, sizeof( array ) );
		
		for( int i = 1; i <= n; i++ ){
			int x;
			std::cin >> x;
			add( i, x );
		}
		
		int ans = -10001;
		for( int i = 1; i + k <= n; i++ ){
			ans = std::max( ans, sum( i + k ) - sum( i ) );
		}
		
		std::cout << ans << std::endl;
	}

 	return 0;	
}

Measured memory_bytes: 1556
#include <bits/stdc++.h>
using namespace std;
int f(long int a,long int b,long int c,long int d){
  return max(a,c)+max(b,d)-min(a,c)-min(b,d);
}
int main(){
  long int N,M,x;
  cin>>N>>M;
  vector<long int>a(N),b(N),c(M),d(M);
  for(int i=0;i<N;i++)cin>>a.at(i)>>b.at(i);
  for(int i=0;i<M;i++)cin>>c.at(i)>>d.at(i);
  for(int i=0;i<N;i++){
    x=0;
    for(int j=1;j<M;j++){
      if(f(a.at(i),b.at(i),c.at(x),d.at(x))>f(a.at(i),b.at(i),c.at(j),d.at(j)))x=j;
    }
    cout<<x+1<<endl;
  }
}

Measured memory_bytes: 256
N, K = map(int, input().split())
p = 0
l = N
i = 0
while l > 0:
  b = -(-K // (2 ** i))
  _p = max(l - b + 1, 0)
  p += _p / (N * (2 ** i))
  l -= _p
  i += 1
print(p)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

const int MAXN = 100000;

int a[MAXN+1];
int b[MAXN+1];

bool isprime(int x) {
    bool ok = 1;
    for (int i = 3; i * i <= x; i++) {
        if (x % i == 0) ok = 0;
    }
    return ok;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int q;
    cin >> q;

    a[2] = 1;
    for (int i = 3; i <= MAXN; i += 2) {
        if (isprime(i)) a[i] = 1;
    }

    for (int i = 3; i <= MAXN; i += 2) {
        if (a[i] && a[(i + 1) / 2]) b[i] = 1;
    }

    REP(i, 1, MAXN+1) {
        b[i] += b[i - 1];
    }

    rep(i, q) {
        int l, r;
        cin >> l >> r;
        cout << b[r] - b[l-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 1408
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())
    D = [list(map(int,input().split())) for i in range(N)]

    res = 'No'
    cnt = 0

    for i in range(N):
        if D[i][0] == D[i][1]:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            res = 'Yes'
            break

    print(res)



main()


Measured memory_bytes: 9180
n = int(input())
h = list(map(int,input().split()))

a1 = h[0] - 1
flag = True
for i in range(1,n):
    a2 = h[i]
    if a2 - a1 < 0:
        flag = False
        break
    elif a2 - a1 > 0:
        a2 -= 1
    
    a1 = a2

if flag:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 14396
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0

for l in range(a + 1):
    for m in range(b + 1):
        for n in range(c + 1):
            s = 500 * l + 100 * m + 50 * n
            if s == x:
                ans += 1

print(ans)


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

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

    for(int i = 0; i < 1<<n; i++){
        vector<int> res;
        for(int j = 0; j < n; j++){
            if(i & 1<<j)    res.push_back(j);
        }
        cout << i << ":";
        for(int j : res)    cout << " " << j;
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3152
abc = list(map(int, input().split()))

odds = list(filter(lambda x: x % 2 == 1, abc))
ans = 0
if len(odds) == 1:
    for i in range(len(abc)):
        if abc[i] % 2 == 0:
            abc[i] += 1
    ans = 1
elif len(odds) == 2:
    for i in range(len(abc)):
        if abc[i] % 2 == 1:
            abc[i] += 1
    ans = 1

abc.sort()
print((abc[2] * 2 - abc[0] - abc[1]) // 2 + ans)


Measured memory_bytes: 3064
y,m,d = map(int, input().split('/'))

result = 'TBD'

if y<=2018:
    result='Heisei'
elif y==2019:
    if m<=3:
        result='Heisei'
    elif m==4:
        if d<=30:
            result='Heisei'

print(result)


Measured memory_bytes: 3060
p = int(input())
a = list(map(int,input().split()))

ans = [0]*p

for i in range(p):
    if a[i] == 0:
        continue
    ans[0] -= p-1
    m = 1
    for k in range(p):
        ans[p-1-k] -= m
        ans[p-1-k] %= p
        m *= i
        m %= p

print(*ans)


Measured memory_bytes: 43868
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
const lli mod=1e9+7;
const lli pINF=LLONG_MAX;
const lli nINF=-LLONG_MAX;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define printli(n) printf("%lld\n",n)
#define all(v) v.begin(),v.end()
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}

int main() 
{
    int n;
    si(n);
    
    int rev=0;
    
    int temp=n;
    
    while(temp!=0){
        int t=temp%10;
        
        rev=rev*10 + t;
        temp/=10;
    }
    
    if(rev==n) cout<<"Yes\n";
    else cout<<"No\n";
	return 0;
}

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

# define PI 3.14159265359

int main() {
	long double a, b, c;

	cin >> a >> b >> c;
	c *= (PI/180);

	cout << fixed << setprecision(10);
	cout << (1.0 / 2.0) * a * b * sin( c ) << endl;
	cout << a + b + sqrt( pow(a, 2) + pow(b, 2) - 2.0 * a * b * cos( c ) ) << endl;
	cout << b * sin( c ) << endl;

	return 0;
}

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

int main() {
  
  int d;
  cin >> d;
  vector<int> a(26);
  for(int i=0; i<26; i++) {
    cin >> a[i];
  }
  
  int s[d][26];
  for(int i=0; i<d; i++) {
    for(int j=0; j<26; j++) {
      cin >> s[i][j];
    }
  }
  
  int mx = 0; int pos = 1;
  for(int i=0; i<26; i++) {
    if(a[i] > mx) {
      pos = i+1;
      mx = a[i];
    }
  }
  
  for(int i=0; i<d; i++) {
    cout << pos << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		long sum = 1;
		
		n  =sc.nextInt();
		while (0 < n) {
			sum *= n;
			n--;
		}
		
		System.out.println(sum);
	}
}

Measured memory_bytes: 11000
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
#define MOD 1000000007
using namespace std;

int main() {
	int n;
	ll x;
	ll count = 0, ans = 0;
	cin >> n >> x;
	vector<ll>a(n);
	REP(i, n) {
		cin >> a[i];
	}
	REP(i, n - 1) {
		if (a[i] + a[i + 1] > x) {
			count += a[i] + a[i + 1] - x;
			if (a[i+1]>=count) {
				a[i + 1] -= count;
			}
			else {
				a[i] -= count - a[i + 1];
				a[i + 1] = 0;
			}
		}
		ans += count;
		count = 0;
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    string S;
    int y, m, d;

    cin >> S;

    y = atoi(S.substr(0, 4).c_str());
    m = atoi(S.substr(5, 2).c_str());
    d = atoi(S.substr(8, 2).c_str());

    if( y < 2020 && m < 5 && d < 31){
        cout << "Heisei" << endl;
    }
    else{
        cout << "TBD" << endl;
    }

}


Measured memory_bytes: 256
n,k=map(int,input().split())
L=[]
for i in range(1,n+1):
      s=i
      c=0
      while s<k:
            s=s*2
            c+=1
      L.append(c)
ans=0
for i in range(n):
      ans+=(1/n)*((1/2)**L[i])
print(ans)

Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int A[100000];
int res;
int ress;
int resx[100000];
int resy[100000];
int doit(int x, int y){
  resx[ress] = x;
  resy[ress++] = y;
  return x - y;
}
int main(){
  int i, j, k;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  sort(A, A+N);
  if(A[0] >= 0){
    for(i=1;i<N-1;i++){
      A[0] = doit(A[0], A[i]);
    }
    A[N-1] = doit(A[N-1], A[0]);
  }
  else if(A[N-1] <= 0){
    for(i=0;i<N-1;i++){
      A[N-1] = doit(A[N-1], A[i]);
    }
  }
  else{
    for(i=N-2;i>=0;i--){
      if(i && A[i] >= 0){
        A[0] = doit(A[0], A[i]);
      }
      else{
        A[N-1] = doit(A[N-1], A[i]);
      }
    }
  }
  res = A[N-1];
  wt_L(res);
  wt_L('\n');
  for(i=0;i<ress;i++){
    wt_L(resx[i]);
    wt_L(' ');
    wt_L(resy[i]);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190609-2 [beta]

// --- original code ---
// int N, A[1d5];
// 
// int res, ress, resx[1d5], resy[1d5];
// 
// int doit(int x, int y){
//   resx[ress] = x;
//   resy[ress++] = y;
//   return x - y;
// }
// 
// {
//   int i, j, k;
//   rd(N,A(N));
//   sort(A, A+N);
// 
//   if(A[0] >= 0){
//     rep(i,1,N-1) A[0] = doit(A[0], A[i]);
//     A[N-1] = doit(A[N-1], A[0]);
//   } else if(A[N-1] <= 0) {
//     rep(i,N-1) A[N-1] = doit(A[N-1], A[i]);
//   } else {
//     for(i=N-2;i>=0;i--){
//       if(i && A[i] >= 0) A[0] = doit(A[0], A[i]);
//       else               A[N-1] = doit(A[N-1], A[i]);
//     }
//   }
//   res = A[N-1];
// 
//   wt(res);
//   rep(i,ress) wt(resx[i], resy[i]);
// }


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

#define ll long long
#define NIL 0
#define INF 1e18
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vl vector<ll>
#define vvl vector<vector<ll>> 
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define pb push_back
#define F first
#define S second
#define pp pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define rpk(i,k,n) for(int i=k;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++) 
#define RPK(i,k,n) for(int i=k;i<=n;i++) 
#define ritr(i,gr) for(auto i=gr.begin();i!=gr.end();i++)

const int M = 1e9+7;

int V, E, i, j, k, u, v, x, y, p, q, r, t, n;
vi *g;
vb sn;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    int h[n];
    rep(i,n) cin>>h[i];
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    RPK(i,2,n-1) {
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
}
    
    
    

Measured memory_bytes: 4824
#include<iostream>
 
using namespace std;
 
typedef long long ll;

ll gcd(int a, int b) {
    if(a < b) {
        if(b % a == 0)
            return (ll)a;
        return gcd(b%a, a);
    } else {
        if(a % b == 0)
            return (ll)b;
        return gcd(a%b, b);
    }
}

ll gcd_t(int a, int b, int c) {
    return gcd(a, gcd(b, c));
}

int main() {
    ll k, sum = 0ll;
    cin >> k;

    for(int i = 1; i <= k; i++) {
        for(int j = 1; j <= k; j++) {
            for(int l = 1; l <= k; l++)
                sum += gcd_t(i, j, l);
        }
    }
    cout << sum << "\n";
}

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


int main()
{
ll N;
cin >> N;
ll ans = 0;
rep(i,N) {
    ans += i;
}
cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

vector<vector<T>> G(100010);

int main(){
    ll n, m, c; cin>>n>>m>>c;
    ll sum = 0;
    for(int i=0; i<m; i++){
        ll a, b, c; cin>>a>>b>>c;
        a--, b--;
        G[a].eb(T(b, c,i));
        G[b].eb(T(a, c,i));
        sum += c;
    }

    bool checkedNode[100010];
    for(int i=0; i<=100005; i++){
        checkedNode[i] = false;
    }

    vector<ll> dist(100010, INF);
    priority_queue<P, vector<P>, greater<P>> que;
    dist[0] = 0;
    que.push(P(0, 0));

    ll res=INF;

    while(!que.empty()){
        ll ccost, cv;
        tie(ccost, cv) = que.top();
        que.pop();

        if(dist[cv] < ccost) continue;
        checkedNode[cv]=true;

        for(auto x : G[cv]){
            ll nv, ncost, id;
            tie(nv, ncost, id) = x;
            
            if(dist[cv] + ncost < dist[nv]){
                dist[nv] = dist[cv] + ncost;
                que.push(P(dist[nv], nv));
            }

            if(checkedNode[nv]&&checkedNode[cv]){
                sum-=ncost;
            }
        }

        ll tmp=c*ccost+sum;
        //if(!que.empty() && que.top().first == ccost) continue;
        res=min(res,tmp);
    }

    cout<<res<<endl;
}



Measured memory_bytes: 21592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;


using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(int)(n);i++)
#define foi(i,k,n) for(int i=(k); i<(int)(n); i+=1)
#define fod(i,n,k) for(int i=k; i>=(int)n; i-=1)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define endl "\n"

#define int long long
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef long long llint;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<llint> VL;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
llint toint(string s) {stringstream ss(s); llint x; ss >> x; return x;}
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//gp_hash_table<string, llint> table;


int mpow(llint base, llint exp) {
  base %= MOD;
  llint result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((llint)result * base) % MOD;
    base = ((llint)base * base) % MOD;
    exp >>= 1;
  }
  return result;
}


//void makegraph(int n, int m){
	//int i, u, v;
	//while(m--){
		//cin>>u>>v;
		//u--, v--;
		//g[u].pb(v);
		//g[v].pb(u);
	//}
//}

//void dfs(int u, int par){
	//for(int v:g[u]){
		//if (v == par) continue;
		//dfs(v, u);
	//}
//}


// ------------------------------------------------------------------ILB----------------------------------------------------------------  //

const int MX = 1e6 + 100;

//(n - 2)! * nP2

//int mpow(int x, int k){
	//x %= MOD;
	//int res = 1;
	//while(k){
		//if(k & 1) res *= x;
		//res %= MOD;
		//x *= x;
		//x %= MOD;
		//k >>= 1;
	//}
	//return (res%MOD);
//}


void solve(){
	int n;
	cin >> n;
	
	int ans = mpow(10, n) - 2 * mpow(9, n) + mpow(8, n);
	
	while(ans < 0) ans += MOD;
	
	cout << ans % MOD;
}




int32_t main() {
	fast_io;
    int t = 1;
    //cin >> t;
    //int xx = 0
    while(t--) {
		//xx++;
		//cout << "Case ";
      solve();
    }
    return 0;
}



Measured memory_bytes: 3624
import sys
input()
arr = list(map(int, input().split()))
qn = int(input())
queries = sys.stdin.readlines()
for i in range(qn):
    com, b, c = queries[i].split()
    if com == '0':
        print(min(arr[int(b):int(c)]))
    elif com == '1':
        print(max(arr[int(b):int(c)]))
    else:
        raise AssertionError


Measured memory_bytes: 5776
import random


class Cube:
    def __init__(self, u, s, e, w, n, d):
        self.u = u
        self.s = s
        self.e = e
        self.w = w
        self.n = n
        self.d = d

    def rotate(self, dic):
        if dic == "N":
            tmp = self.u
            self.u = self.s
            self.s = self.d
            self.d = self.n
            self.n = tmp
        elif dic == "E":
            tmp = self.u
            self.u = self.w
            self.w = self.d
            self.d = self.e
            self.e = tmp
        elif dic == "W":
            tmp = self.u
            self.u = self.e
            self.e = self.d
            self.d = self.w
            self.w = tmp
        else:
            tmp = self.u
            self.u = self.n
            self.n = self.d
            self.d = self.s
            self.s = tmp


def main():
    u, s, e, w, n, d = map(int, input().split())
    cube = Cube(u, s, e, w, n, d)
    q = int(input())
    for i in range(q):
        upper, front = map(int, input().split())
        while True:
            cube.rotate(random.choice("NWES"))
            if upper == cube.u and front == cube.s:
                print(cube.e)
                break


if __name__ == '__main__':
    main()


Measured memory_bytes: 8188
#include <stdio.h>

int main(void)
{
    
    int i,n,t,count=0;
    static int a[100001]={0};
    
    scanf("%d",&n);
    
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    
    t=1;
    for(i=0;i<=n;i++){
        count++;
        if(a[t]==2){
            printf("%d\n",count);
            count=0;
            break;
        }
        t=a[t];
    }
    
    if(count!=0)printf("-1\n");
    
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
    int n, i;
    double x1, y1, x2, y2, x3, y3, x4, y4;
    double e;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
        if (x1 == x2 || x3 == x4) {
            printf("%s\n", x1 == x2 && x3 == x4 ? "YES" : "NO");
        } else {
            e = (y2 - y1) * (x4 - x3) - (y4 - y3) * (x2 - x1);
            printf("%s\n", (-1e-8 < e && e < 1e-8) ? "YES" : "NO");
        }
    }

    return 0;
}

Measured memory_bytes: 620
a, b, c, x, y = map(int, input().split())
if a + b <= 2 * c:
    print(a * x + b * y)
elif c <= min(a, b):
    if x < y:
        if b < 2 * c:
            print(2 * c * x + b * (y - x))
        else:
            print(2 * c * y)
    else:
        if a < 2 * c:
            print(2 * c * y + a * (x - y))
        else:
            print(2 * c * x)
else:
    if x < y:
        print(2 * c * x + b * (y - x))
    else:
        print(2 * c * y + a * (x - y))

Measured memory_bytes: 3064
n = gets.chomp.to_i
arr = gets.chomp.split(' ').map(&:to_i)

def selection_sort(arr, n)
  swap_times = 0
  (0..n-2).each do |i|
    minj = i
    (i..n-1).each do |j|
      if arr[j] < arr[minj]
        minj = j
      end
    end
    tmp = arr[i]
    arr[i] = arr[minj]
    arr[minj] = tmp
    if i != minj
      swap_times += 1
    end
  end
  print "#{arr.join(' ')}\n#{swap_times}\n"
end

selection_sort(arr, n)



Measured memory_bytes: 6868
// AOJ 3040 U and U
// 2019.4.2 bal4u

#include <stdio.h>

int main()
{
	long long N, M;

	scanf("%lld%lld", &N, &M);
	if (N >= (M << 1)) puts("0");
	else if (M >= (N << 1)) puts("1");
	else if (M <= N) puts("2");
	else if ((M<<1)+M+(M>>1) >= (N<<2)) puts("3");
	else puts("4");
	return 0;
}


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

int main(void){
    int h,n;
    cin >> h >> n;
    int a[n];
    int sum = 0;
    rep(i,n){
        int x;
        cin >> x;
        a[i] = x;
        sum += x;
    }
    if(h>sum){
        cout << "No" <<endl;
    }
    else{
        cout << "Yes" <<endl;
    }
    
    
    return 0;
    
}
























































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

int main() {
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
        ll k;
        cin>>k;
     
        ll a,b;
        cin>>a>>b;
        if(a%k == 0 || b%k == 0)
            {
                cout<<"OK";
                
            }
        else{
            if(b/k > a/k )
                cout<<"OK";
            else cout<<"NG";
        }
        
    
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <complex>

int main() {
  long a, b, c, d;

  std::cin >> a;
  std::cin >> b;
  std::cin >> c;
  std::cin >> d;

  if (std::abs(a-c)<=d)
    std::cout << "Yes" << std::endl;
  else if (std::abs(a-b)<=d && std::abs(b-c)<=d)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bitset>
using namespace std;
const int range = 2000 * 2000 + 10;

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

	bitset<range> bs;
	bs.set(0);

	for (int i = 0; i < N; i++) {
		cin >> A;
		sum += A;

		bitset<range> temp;
		temp |= bs;
		bs <<= A;
		bs |= temp;
	}

	for (int i = (sum + 1) / 2;; i++) {
		if (bs[i]) {
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, K; cin >> N >> K;
    vec p(N); cin >> p;
    vec s(N + 1);
    s[0] = 0;
    REP(i, N) s[i + 1] = s[i] + p[i];

    int m = 0;
    FOR(i, K, N + 1){
        Max(m, s[i] - s[i - K]);
    }
    Out((double)(m + K) / 2.0);

    return 0;
}


Measured memory_bytes: 3456
N, W = map(int, input().split())
ws = []
vs = []
for _ in range(N):
    w, v = map(int, input().split())
    ws.append(w)
    vs.append(v)
ans = 0
memo = {0: 0}
for i in range(N):
    w = ws[i]
    v = vs[i]
    tmp = {}
    for w0, v0 in memo.items():
        if w0 + w <= W:
            ans = max(ans, v0 + v)
            if w0 + w in tmp:
                tmp[w0 + w] = max(tmp[w0 + w], v0 + v)
            else:
                tmp[w0 + w] = v0 + v
    for w0, v0 in tmp.items():
        if w0 in memo:
            memo[w0] = max(memo[w0], tmp[w0])
        else:
            memo[w0] = tmp[w0]
print(ans)

Measured memory_bytes: 45936
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

const int MAX_N = 110;
const int MAX_V = 100100;

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

int n, m;
vector<vector<int>> G;

int dp[100100];

int rec(int v) {
	//メモされていればそれを使う
	if (dp[v] != -1)return dp[v];

	//矢印の先に順番に下っていて
	//葉は自動的に深さ0

	int res = 0;

	//子へ遷移
	//子のなかで一番深いのを採用
	for (auto nv : G[v]) {
		chmax(res, rec(nv) + 1);
	}

	//メモして次へ
	return dp[v] = res;
}

int main() {
	cin >> n >> m;
	G.assign(n, vector<int>());
	for (int i = 0; i < m; i++) {
		int x, y; cin >> x >> y;
		x--; y--;
		G[x].push_back(y);
	}

	for (int i = 0; i < n; i++) {
		dp[i] = -1;
	}

	int res = 0;

	//連結でないので全部の頂点からスタートする

	for (int v = 0; v < n; v++) {
		chmax(res, rec(v));
	}
	cout << res << endl;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
using namespace std;
const int INF=INT_MAX;

int main()
{
	int n;cin>>n;
	int dp[n][3];
	
	for (int i=0;i<n;i++)
		for (int j=0;j<3;j++)
			cin>>dp[i][j];
	
	for (int i=1;i<n;i++)
		for (int j=0;j<3;j++)
		{
			int y=INT_MIN;
			for (int k=0;k<3;k++)
			{
				if (k!=j)
					y=max(y,dp[i-1][k]);
			}
			dp[i][j]=y+dp[i][j];
		}
		
	int ans=INT_MIN;
	for (int i=0;i<3;i++)
		ans=max(ans,dp[n-1][i]);
	cout<<ans;
}




Measured memory_bytes: 1408
#include <cstdio>

long long N;
int a[20];
int aL;
int res;

void solve()
{
	int i;
	aL = 0;
	while(N>0){
		a[aL] = N % 10;
		aL ++;
		N /= 10;
	}
	int ok=1;
	for(i=0; i<aL-1; i++){
		if(a[i]!=9){
			ok = 0;
			break;
		}
	}
	if(ok==1){
		for(i=0; i<aL; i++)
			res += a[i];
	}
	else{
		for(i=0; i<aL-1; i++)
			res += 9;
		res += a[aL-1]-1;
	}
	printf("%d\n", res);
}

int main()
{
	scanf("%lld", &N);
	solve();
}

Measured memory_bytes: 128
#include <iostream>

int main() {
    int a, b;
    std::cin >> a >> b;
    if(a < b)
        std::cout << "a < b";
    else if(a > b)
        std::cout << "a > b";
    else
        std::cout << "a == b";
    std::cout << std::endl;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
const int MOD=998244353;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> l(k),r(k),dp(n+5),sum(n+5);
    rep(i,k) cin>>l[i]>>r[i];
    dp[1]++;sum[1]++;
    for(int i=2;i<=n;i++){
        rep(j,k){
            int a=i-r[j];
            int b=i-l[j];
            a=max(a,1);
            if(b<0) continue;
            dp[i]+=sum[b]-sum[a-1];
            dp[i]=(dp[i]%MOD+MOD)%MOD;
        }
        sum[i]=dp[i]+sum[i-1];
        sum[i]=(sum[i]%MOD+MOD)%MOD;
    }
    cout<<(dp[n]+MOD)%MOD<<endl;
    return 0;
}

Measured memory_bytes: 4824
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

int main() {
    int W,H,N;cin>>W>>H>>N;
    
    int minx=W;
    int maxx=0;
    int miny = H;
    int maxy = 0;
    for(auto i=0;i<N;i++){
        int x,y,a;
        cin>>x>>y>>a;
        if(a==1)maxx=max(maxx,x);
        if(a==2)minx=min(minx,x);
        if(a==3)maxy=max(maxy,y);
        if(a==4)miny=min(miny,y);
    }
    
    if(minx < maxx || miny < maxy){
        cout << 0 << endl;
        return 0;
    }
    
    int ans = (minx-maxx)*(miny-maxy);
    cout << ans << endl;
    return 0;
}






Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
const int MAXN = 100;
vector<int> X(MAXN), Y(MAXN);
vector<ll> H(MAXN);
int n;

bool f(ll h, int cx, int cy) {
  rep(i, n) {
    ll now = h - abs(X[i] - cx) - abs(Y[i] - cy);
    if(H[i] <= now) return true;
  }
  return false;
}

bool check(ll h, int cx, int cy) {
  rep(i, n) {
    ll now = h - abs(X[i] - cx) - abs(Y[i] - cy);
    if(H[i] != max(now, 0LL)) return false;
  }
  return true;
}

int main() {
  cin >> n;
  rep(i, n) cin >> X[i] >> Y[i] >> H[i];
  ll h;
  int x, y;
  rep(i, 101) rep(j, 101) {
    x = i;
    y = j;
    ll ok = 10000000000;
    ll ng = 0;
    while(abs(ok - ng) > 1) {
      ll mid = (ok + ng) / 2;
      if(f(mid, x, y))
        ok = mid;
      else
        ng = mid;
    }
    h = ok;
    if(check(h, x, y)) {
      printf("%d %d %lld\n", x, y, h);
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<map>
#include<deque>
#include<string>
#include<vector>
#include<iostream>

#define	pb	push_back

using namespace std;

struct Rect{
	int l,r,u,b;
	bool isInside(int x,int y){
		return (l<=x && x<=r && u<=y && y<=b);
	}
};

struct Button:Rect{
	string link;
};

struct Page{
	string title;
	int bnum;
	vector<Button> btn;
};

int main(){
	for(int n;cin>>n,n;){
		int w,h;	cin>>w>>h;
		Page pg[100];
		for(int i=0;i<n;i++){
			cin>>pg[i].title>>pg[i].bnum;
			pg[i].btn=vector<Button>(pg[i].bnum);
			for(int j=0;j<pg[i].bnum;j++){
				cin>>pg[i].btn[j].l>>pg[i].btn[j].u
				   >>pg[i].btn[j].r>>pg[i].btn[j].b>>pg[i].btn[j].link;
			}
		}

		map<string,int> f;
		for(int i=0;i<n;i++)	f[pg[i].title]=i;

		int m;	cin>>m;
		deque<Page> dq;	dq.pb(pg[0]);
		int ptr=0;
		while(m--){
			string cmd;	cin>>cmd;
			if(cmd=="click"){
				int x,y;	cin>>x>>y;
				int on=-1;
				for(int i=0;i<dq[ptr].bnum;i++){
					if(dq[ptr].btn[i].isInside(x,y)){
						on=f[dq[ptr].btn[i].link];
						break;
					}
				}
				if(~on){
					dq.erase(dq.begin()+ptr+1,dq.end());
					dq.pb(pg[on]);
					ptr++;
				}
			}
			else if(cmd=="back"){
				if(ptr>0)	ptr--;
			}
			else if(cmd=="forward"){
				if(ptr<dq.size()-1)	ptr++;
			}
			else	cout<<dq[ptr].title<<endl;
		}
	}

	return 0;
}

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

int main()
{
   int n;
   cin>>n;
   string s , t;
   cin>>s>>t;
   ll ans =2*n;
   for(int i=0;i<n;i++)
   {
       int len = n -i;
       string temp = t.substr( 0 , len);
       string temp2 = s.substr( i ,len);
       if( temp == temp2 )
       {
           ans = ans - len;
           break;
       }
   }
   cout<<ans;
}

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

public class Main {
	/*??¶?´???????????????????*/
	public static void judge(int parse[],int leng){
		for(int j=0;j<leng;j++){
			if(parse[j]<0||parse[j]>100){
				System.out.println("??\?????????0~100??\???????????§???.???????????????.");
				System.exit(0);
			}
		}
	}

	 public static void main(String[] args) throws IOException{
		int a,b,c;
		String str;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		str = br.readLine();

		/*???????????£?¨?*/
		String[] st = str.split(" ");
		int len=st.length; //?????????????´???°
		int parse[] = new int[len]; //String???int????????¨??????

		for(int p=0;p<len;p++){
			parse[p]=Integer.parseInt(st[p]); //String???int??????
		}

		a=parse[0]; b=parse[1]; c=parse[2];

		judge(parse,len); //??¶?????????.????????????????????°????????????


		 /*for(int i=0;i<st.length;i++){
		 System.out.println("st["+i+"]="+st[i]); //?????????????´??¢????
		 }*/

		/*????????¨????????????*/
			if(a<b&&b<c)
				System.out.println("Yes");
			else
				System.out.println("No");



	}

}

Measured memory_bytes: 24272
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out); 
		
		int N = Integer.parseInt(sc.next());
		int input;
		int first = 0, second = 0;
		int first_i = 0;
		
		for(int i = 0; i < N; i++) {
			input = Integer.parseInt(sc.next());
			if (first < input) {
				second = first;
				first = input;
				first_i = i;
				
			} else if (second < input) {
				second = input;
			}
		}
		
		for (int i = 0; i < N; i++ ) {
			if (i == first_i) {
				out.println(second);
			} else {
				out.println(first);
			}
		}
		
		out.flush();
		sc.close();
	}

}


Measured memory_bytes: 50276
#include <iostream>
#include <stdlib.h>
using namespace std;

int card[4][13]={};

int main(){

#if 0
  for(int i=0; i<4; i++){
	  for(int j=0; j<13; j++){
      cout << card[i][j] << endl;
    }
  }
#endif
  
  int n;
  cin >> n;

  char kind;
  int b;

  for(int i=0; i<n; i++){
    cin >> kind >> b;

    switch(kind){
    case 'S':
      card[0][b-1]=1;
      break;
    case 'H':
      card[1][b-1]=1;
      break;
    case 'C':
      card[2][b-1]=1;
      break;
    case 'D':
      card[3][b-1]=1;
      break;
    default:
      cout << "ERROR: Please Input S/H/C/D." << endl;
      exit(1);
    }
  }

  for(int i=0; i<4; i++){
	  for(int j=0; j<13; j++){
      if(card[i][j]==0){
        switch(i){
        case 0:
          cout << "S " << j+1 << endl;
    		  break;
	  	  case 1:
          cout << "H " << j+1 << endl;
    	  	break;
	    	case 2:
          cout << "C " << j+1 << endl;
 	    	 	break;
  	  	case 3:
        default:
          cout << "D " << j+1 << endl;
   	  	 	break;
        }
      }
    }
  }

  
}

Measured memory_bytes: 1164
S = list(input())
T = ['1' if s in ['A', 'C', 'G', 'T'] else '0' for s in S]

max_count = 0
count = 0
for c in T:
    if c == "1":
        count += 1
        max_count = max(max_count, count)
    else:
        count = 0
print(max_count)


Measured memory_bytes: 9040
#include <stdio.h>

int main(void)
{
        int x,a,b;
        scanf("%d%d%d",&x,&a,&b);
        int la = (x-a)*(x-a);
        int lb = (x-b)*(x-b);
        if(la < lb)
                {printf("A\n");}
        else
                {printf("B\n");}
        return 0;
}


Measured memory_bytes: 128