akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

lint mod = 1e+9 + 7;
int n;
vector<lint> a;

// 素因数分解unordered_map版　O(√n)
template <typename T>
unordered_map<T, T> pf_um(T n) {
    unordered_map<T, T> res;
    for (long long i = 2; i * i <= n; i++)
        while (n % i == 0) res[i]++, n /= i;
    if (n != 1) res[n]++;
    return res;
}

// a^n mod pを計算　O(log n)
long long int pow_mod(long long int a, long long int n, long long int p) {
    if (n == 0) return 1;
    long long int temp = pow_mod(a, n / 2, p);
    return n & 1 ? (((temp * temp) % p) * a) % p : (temp * temp) % p;
}

// Z_pでのaの逆元を計算 O(log p)
// depend:pow_mod
long long int inv_mod(long long int a, long long int p) {
    return pow_mod(a, p - 2, p);
}

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

int main() {
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    unordered_map<lint, lint> lcm;
    for (int i = 0; i < n; i++) {
        auto pf = pf_um(a[i]);
        for (auto e : pf) {
            chmax(lcm[e.first], e.second);
        }
    }
    lint l = 1;
    for (auto e : lcm) {
        l = l * pow_mod(e.first, e.second, mod) % mod;
    }
    lint ans = 0;
    for (int i = 0; i < n; i++) {
        lint temp = l * inv_mod(a[i], mod) % mod;
        ans = (ans + temp) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int64_t N;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	if (N == 0) {
		out << 0 << endl;
		return 0;
	}

	if (N > 0) {
		int64_t add = 0;
		int32_t i = 0;
		for (; i <= 32; i += 2)
		{
			add += int64_t(1) << i;
			if (add >= N) {
				break;
			}
		}

		out << '1';
		--i;
		for (; i >= 0; --i)
		{
			int64_t minus = int64_t(1) << i;
			bool is_minus = (add - N >= minus);
			if (is_minus) {
				add -= minus;
			}

			if ((i % 2 != 0) == is_minus) {
				out << '1';
			}
			else {
				out << '0';
			}
		}
	}
	else {
		int64_t add = 0;
		int32_t i = 1;
		for (; i <= 32; i += 2)
		{
			add += int64_t(1) << i;
			if (add >= -N) {
				break;
			}
		}

		out << '1';
		--i;
		for (; i >= 0; --i)
		{
			int64_t minus = int64_t(1) << i;
			bool is_minus = (add - -N >= minus);
			if (is_minus) {
				add -= minus;
			}

			if ((i % 2 != 0) == is_minus) {
				out << '0';
			}
			else {
				out << '1';
			}
		}
	}

	return 0;
}
#endif

#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
uint64_t M;
uint64_t A[100000];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N >> M;
	uint64_t res = 0;
	for (int32_t i = 0; i < N; i++)
	{
		in >> A[i];
		A[i] %= M;
		if (A[i] == 0) {

		}
	}

	for (int32_t i = 0; i < N; i++)
	{
		A[i + 1] += A[i];
		A[i + 1] %= M;
	}
	std::unordered_map<int32_t, int32_t> num;
	for (int32_t i = 0; i < N; i++)
	{
		++num[A[i]];
	}
	++num[0];


	for (auto& c : num)
	{
		int64_t len = c.second;
		res += len * (len - 1) / 2;
	}
	out << res << endl;

	return 0;
}
#endif


Measured memory_bytes: 3872
x, n = map(int, input().split())
if n == 0:
	print(x)
else:
	line = list(map(int, input().split()))

	for i in range(0, 101):
		a = x-i
		b = x+i
		if a not in line:
			print(a)
			exit()
		if b not in line:
			print(b)
			exit()

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

long long n,a,m,k,q,b,c=1,a1,a2,b1,b2;
float qq,ww,ff=2,qs;
string ss,s1,s2;
int main(){
    cin>>ss;
    set<char>sss;
    for (int i=0; i<4; i++){
        sss.insert(ss[i]);
    }
    if (sss.size()==2){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}


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

int n,a[200005];
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>q;
int main() {
    while(~scanf("%d",&n)) {
        while(!q.empty())q.pop();
        for(int i=1; i<=n; i++) {
            scanf("%d",&a[i]);
            q.push(make_pair(a[i],i));
            while(q.size()>2)q.pop();
        }
        int secondpos=q.top().second;
//        printf("%d\n",q.top().second);
        q.pop();
        int max1=q.top().first;
        int maxpos=q.top().second;
        for(int i=1; i<=n; i++) {
            if(maxpos==i)printf("%d\n",a[secondpos]);
            else printf("%d\n",max1);
        }
    }
    return 0;
}


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

typedef long long ll;


int main() {
    ll N, K;
    cin >> N >> K;
    ll r = N/K;
    ll ans = min(N - r*K,(r+1)*K - N);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
using namespace std;

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



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

	ll num = min(b - 1, n);

	cout << (num * a) / b << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int[] dx = new int[4];
	static int[] dy = new int[4];

	static int dfs(int x, int y, boolean[][] used) {
		while (used[x][y]) {
			++x;
			if (x == 4) {
				x = 0;
				++y;
				if (y == 4) return 1;
			}
		}
		int ret = 0;
		used[x][y] = true;
		for (int i = 0; i < 4; ++i) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (0 <= nx && nx < 4 && 0 <= ny && ny < 4 && !used[nx][ny]) {
				used[nx][ny] = true;
				ret += dfs(x, y, used);
				used[nx][ny] = false;
			}
		}
		used[x][y] = false;
		return ret;
	}

	static int solve() {
		boolean[][] used = new boolean[4][4];
		return dfs(0, 0, used);
	}

	public static void main(String[] args) {
		while (true) {
			dx[0] = sc.nextInt();
			if (dx[0] > 4) break;
			dy[0] = sc.nextInt();
			for (int i = 1; i < 4; ++i) {
				dx[i] = sc.nextInt();
				dy[i] = sc.nextInt();
			}
			System.out.println(solve());
		}
	}
}

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

#define   ll             long long int
#define   pb             push_back
#define   mp             make_pair
#define   fast           ios_base::sync_with_stdio(false);cin.tie(NULL);
#define   ff             first
#define   ss             second
#define   nil           -10e+9
#define   initial         0
#define   waiting         1
#define   visit           2
#define   inf            10e+9
#define   mx             200005
#define   mxx            1000005
#define   mod            1000000007
#define   pr             pair<ll,ll>
#define   pp_queue       priority_queue<pr,vector<pr>, greater<pr> >
#define   dp_queue       priority_queue<int,vector<int>, greater<int> >
#define   sp_queue       priority_queue<int>
#define   fr(i,p,q)      for(int i=p;i<q;++i)
#define   frr(i,p,q)     for(int i=p;i<=q;++i)
#define   mem(a,b)       memset(a,b,sizeof(a))
#define   len(a)         (int)a.size()
#define   input          freopen("input.txt", "r", stdin);
#define   output         freopen("output.txt", "w", stdout);
#define   debug(arr,j,n) fr(i,j,n) cout<<arr[i]<<" ";

ll power(ll a,ll b){ll aa=1;while(b){if(b&1){aa=aa*a;aa%=mod;}a=a*a;a%=mod;b/=2;}return aa;}

using namespace std;

int main()
{
  int a,b;

  cin>>a>>b;
  int ans=a;
  int cnt=1;

  while(1){
    if(ans<b){
    ans+=a-1;
    cnt+=1;
  }
  else
    break;
  }

  if(b==1) cout<<"0\n";
  else
   cout<<cnt<<"\n";
  return 0;
}


Measured memory_bytes: 256
import java.lang.Long.max

fun main (args:Array<String>){
    val (A, B, K) = readLine()!!.split(" ").map(String::toLong)

    val lastA = max(A - K, 0)
    val lastB = max(B - max((K - A - lastA), 0), 0)

    print(lastA)
    print(" ")
    print(lastB)
}

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

using namespace std;

int main() {

int n;
cin>>n;
int len=0;
int d=n;
while(d!=0)
{
    
    len++;
    d=d/10;
}
int sum=0;
if(len%2==0)
{
    int lo=len-1;
    while(lo>0)
    {
        sum+=pow(10,lo-1)*9;
        lo-=2;
        
    }
    
}
else
{
sum+=n-pow(10,len-1)+1;
int lo=len-2;
    while(lo>0)
    {
        sum+=pow(10,lo-1)*9;
        lo-=2;
        
    }
    
    
}

cout<<""<<sum;

return 0;  
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int fanc(int x){
  if(x % 2 == 0) return x/2;
  else return 3*x + 1;
}

int main(){
  int a[100001], f[100001], flag[100001], i;
  cin >> a[1];
  for(i=2; i<=100000; i++) a[i] = fanc(a[i-1]);
  for(i=1; i<=100000; i++) flag[i] = 0;
  for(i=1; i<=100000; i++){
    if(flag[a[i]] != 0){
      cout << i << "\n";
      break;
    }
    flag[a[i]] = 1;
  }
  return 0;
}


Measured memory_bytes: 1024
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1000000007
#define mxval 1e9 + 7
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/*********FUNCTIONS**************/
int powom(int a,int b) {
    int result = 1;
    while (b > 0) {
        if (b & 1)
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	vector<int> a(n),b(n),c(n-1);
	for(auto &x : a){
		cin>>x;
	}
	int ans = 0;
	for(auto &x : b){
		cin>>x;
		ans += x;
	}
	for(auto &x : c){
		cin>>x;
	}
	for(int i=0;i<(n-1);i++){
		if((a[i]-a[i+1])==-1){
			ans+=c[a[i]-1];
		}
	}
	cout<<ans;
	return 0;
}
//.........

Measured memory_bytes: 256
#include<stdio.h>
#define NIL -1
#define MAX 100000

typedef struct{
  int p,l,r;
}Node;

Node T[MAX];
int n;

int depth(int a){
  
  int num=0,s=T[a].p;
  
  while(s!=NIL){
    num++;
    s=T[s].p;
  }
  return num;
}

int main(){

  int i,j,x,d,c,l;

  scanf("%d",&n);
  
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;

  for(i=0;i<n;i++){
    scanf("%d %d",&x,&d);
    for(j=0;j<d;j++){
      scanf("%d", &c);
      if(j==0) T[x].l=c;
      else T[l].r =c;
      l=c;
      T[c].p=x;
    }
  }
  for(i=0;i<n;i++){
  printf("node %d: parent = %d, depth = %d, ", i, T[i].p,depth(i));

  if(T[i].p==NIL) printf("root, ");
  else if(T[i].l!=NIL) printf("internal node, ");
  else printf("leaf, ");

  printf("["); 

  for(j=0, c=T[i].l; c!=NIL; j++, c=T[c].r){
    if(j==0) printf("%d", c);
    else printf(", %d", c);
  }
  printf("]\n");
  }
  return 0;
}
  

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define ioS            ios::sync_with_stdio(false);cin.tie(0);
#define li             long int
#define ll            long li
#define ull            unsigned ll
#define pi             pair<int,int>
#define vi             vector<int>
#define vli            vector<li>
#define vll           vector<ll>
#define vvi            vector<vector<int>>
#define pb             push_back
#define mp             make_pair
#define forn(i,s,n)    for(auto i=s;i<n;++i)               
#define forr(i,s,n)    for(auto i=s;i>=n;--i) 
const ll mx = 1e6;
void solve() 
{
    int n;
   cin>>n;
   string s;
   cin>>s;
   int w = 0;
   for(auto i : s) w += i=='W';
   int limit = s.size()-w;
   w = 0;
   forn(i,0,limit)
       w += s[i]=='W';
   cout<<w<<endl; 
}
int main() {
    ioS
    int t;
    // cin>>t;
    // while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3776
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>inline void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);	
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
const int maxn=2e5+5;
int n,m,ans;
pa p[maxn];
int maxi[maxn<<2],tag[maxn<<2];
void U(int x){
	maxi[x]=max(maxi[ls],maxi[rs]);
}
void B(int x,int l,int r){
	if(l==r){
		maxi[x]=l;
		return;
	}
	B(ls,l,mid);B(rs,mid+1,r);
	U(x);
}
void M(int x,int num){
	tag[x]+=num;
	maxi[x]+=num;
}
void PD(int x){
	M(ls,tag[x]);M(rs,tag[x]);
	tag[x]=0;
}
void M(int x,int l,int r,int ll,int rr){
	if(l==ll&&r==rr){
		M(x,1);
		return;
	}
	PD(x);
	if(rr<=mid)M(ls,l,mid,ll,rr);
	else if(ll>mid)M(rs,mid+1,r,ll,rr);
	else M(ls,l,mid,ll,mid),M(rs,mid+1,r,mid+1,rr);
	U(x);
}
int main(){
	read(n);read(m);
	rep(i,1,n)read(p[i].w1),read(p[i].w2);
	sort(p+1,p+n+1);
	B(1,0,m+1);
	ans=n-m;
	rep(i,1,n){
		int s=p[i].w1;
		M(1,0,m+1,0,p[i].w2);
		ans=max(ans,maxi[1]-(m+1+s));
	}
	printf("%d\n",max(ans,0));
	return 0;
}

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

using namespace std;

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

    int n, k;
    cin >> n >> k;
    int ps[n+1];
    ps[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> ps[i];
        ps[i] += ps[i-1];
    }

    int smax = 0;
    for (int i = 0; i <= n - k; i++) {
        smax = max(smax, ps[i+k] - ps[i]);
    }

    cout << (k + smax) / 2 << "." << (k + smax) % 2 * 5 << endl;

    return 0;
}


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

int GCD( int x, int y) {
    if(x==0)
        return y;
    return GCD(y%x,x);
}

int main()
{
    int x;
    cin>>x;
    int gcd = GCD(x,360);
    int lcm = (x*360)/gcd;
    int ans = lcm/x;
    cout<<ans<<"\n";
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 1e5+17;
int a[MAXN],b[MAXN];
map<int,int > mp;
int main(int argc ,char const *argv[])
{
    #ifdef noob
    freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
    #endif      
    int n,ans=0;
    cin>>n;
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b, b+n);
    for (int i = 0; i < n; ++i)
    {
        mp[b[i]] = i+1;
    }
    for (int i = 0; i < n; ++i)
    {
        if(abs(i+1-mp[a[i]])&1) ans++;
    }
    cout<<ans/2<<endl;
    return 0;   
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
int H,W;
int h,w;
int ans = 0;
int main() {
    cin >> H >> W;
    cin >> h >> w;

    ans = H*W - (h*W + w*H - h*w);

    cout << ans << endl;
    return 0;
}

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

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

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> x(n),y(n),z(n);
  for(Int i=0;i<n;i++) cin>>x[i]>>y[i]>>z[i];

  Int ans=0;
  for(Int b=0;b<8;b++){
    vector<Int> d(n);
    for(Int i=0;i<n;i++){
      d[i]=x[i]+y[i]+z[i];
      if(b&1) d[i]-=x[i]*2;
      if(b&2) d[i]-=y[i]*2;
      if(b&4) d[i]-=z[i]*2;
    }
    sort(d.rbegin(),d.rend());
    Int res=0;
    for(Int i=0;i<m;i++) res+=d[i];
    chmax(ans,res);
  }

  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define int long long int
using namespace std;

void desperate_optimization(bool submitting=true,int precision=10)
{
  if(!submitting) return;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(precision);
}
int32_t main()
{
  desperate_optimization(true);
  int n,k;
  cin>>n>>k;
  vector<int> input(n);
  for(auto& x:input) cin>>x;
  vector<bool> victory(k+1,false);
  for(int i=1;i<=k;i++)
  {
    for(auto x:input)
    {
      if(x<=i) {if(victory[i-x]==false) victory[i]=true;}
      else break;
    }
  }
  if(victory[k]) cout<<"First";
  else cout<<"Second";

  



  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
#EDPC A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
h = LI()
dp = [inf]*(n)
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2,n):
    dp[i] = min(dp[i],dp[i-1] + abs(h[i-1] - h[i]), dp[i-2] + abs(h[i-2] - h[i]))
print(dp[-1])


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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);
//----------------------------------------------------------------

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


// auto MOD int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


// combination MOD prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < MOD);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(int n, int k) {
    return fact[n]*ifact[n-k];
  }
} comb(1000005);

int main(){
    int N;
    cin >> N;
    ll A[N];
    rep(i,N) {
        ll a;
        cin >> a;
        A[i] = a;
    }

    map<ll,ll> M;

    rep(i,N) {

        auto F = prime_factorize(A[i]);
        rep(j,F.size()) {
            M[F[j].first] = max(M[F[j].first], F[j].second);
        }
    }

    mint tmp = 1;

    for (auto m:M) {
        mint t = m.first;
        t = t.pow(m.second);
        tmp *= t;
    }

    mint ans = 0;

    rep(i,N) {
        mint t = tmp/A[i];
        ans += t;
    }
    cout << ans << endl;


}


Measured memory_bytes: 19476
#include <iostream>
#include <vector>
using namespace std;
const long long int MOD = 1000000007;

int main(){
    long long int n, k;
    cin >> n >> k;
    vector<int> a(n+1);
    for(int i = 0; i < n; i++) cin >> a[i];

    long long int ans_in = 0;
    long long int ans_out = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i == j) continue;
            if(a[i] > a[j]){
                if(i < j) ans_in++;
                ans_out++;
            }
        }
    }

    long long int ans = 0;
    ans = ans_in * k;
    ans %= MOD;
    long long int c = k * (k-1);
    c /= 2LL;
    c %= MOD;
    ans += ans_out * c;
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
class comb():
  F = [1, 1]
  Fi = [1, 1]
  I = [0, 1]
  def __init__(self, num, mod):
    self.MOD = mod
    for i in range(2, num + 1):
      self.F.append((self.F[-1] * i) % mod)
      self.I.append(mod - self.I[mod % i] * (mod // i) % mod)
      self.Fi.append(self.Fi[-1] * self.I[i] % mod)
  def com(self, n, k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return self.F[n] * (self.Fi[k] * self.Fi[n - k] % self.MOD) % self.MOD


N, M = list(map(int, input().split()))
MOD = 998244353

com = comb(M * 3 + N, MOD)

t = com.com(M * 3 + N - 1, N - 1)
t -= com.com(M - 1 + N - 1, N -1) * N

while t < 0:
  t += MOD
if N > M:
  for k in range(M + 2, N + 1, 2):
    i = (M * 3 - k) // 2
    t -= com.com(N, k) * com.com(N - 1 + i, i) % MOD
  while t < 0:
    t += MOD

print(t)

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int H, W;
VI2 C(10, VI(10));
VI2 A;

void warshallFloyd() {
    int n = C.size();
    REP(k, n) REP(i, n) REP(j, n) {
        REP(k, n) REP(i, n) REP(j, n) {
            C[i][j] = std::min(C[i][j], C[i][k] + C[k][j]);
        }
    }
}

int main() {
    std::cin >> H >> W;
    A.resize(H, VI(W));
    REP(i, 10) {
        REP(j, 10) {
            std::cin >> C[i][j];
        }
    }

    warshallFloyd();

    long ans = 0L;
    REP(i, H) {
        REP(j, W) {
            int A;
            std::cin >> A;
            if(A == -1 || A == 1) continue;
            ans += C[A][1];
        }
    }
    std::cout << ans << std::endl;


}

Measured memory_bytes: 384
#include <stdio.h>

  /* 配列の要素を交換する */
void Swap(long x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

void QSort(long x[ ], long y[], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                      /* ソートする配列の一番小さい要素の添字 */
    j = right;                     /* ソートする配列の一番大きい要素の添字 */

    pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

    while (1) {                    /* 無限ループ */

        while (x[i] < pivot)       /* pivot より大きい値が */
            i++;                   /* 出るまで i を増加させる */

        while (pivot < x[j])       /* pivot より小さい値が */
            j--;                   /*  出るまで j を減少させる */
        if (i >= j)                /* i >= j なら */
            break;                 /* 無限ループから抜ける */

        Swap(x, i, j);             /* x[i] と x[j]を交換 */
        Swap(y, i, j);  
        i++;                       /* 次のデータ */
        j--;
    }

    if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
        QSort(x, y, left, i - 1);     /* 左の配列を Q ソートする */
    if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
        QSort(x, y, j + 1, right);    /* 右の配列を Q ソートする */
}



int main(void){
    // Your code here!
    long money = 0;
    int N,M;
    long A[100000], B[100000];
    
    scanf("%d %d",&N,&M);
    for(int i = 0; i < N; i++)
    {
        scanf("%ld %ld",&A[i], &B[i]);
    }
    QSort(A,B,0,N-1);
    
    int j = 0;
    while(M>0)
    {
        if(B[j] < M)
        {
            money += A[j]*B[j];
            M -= B[j];
        }
        else
        {
            money += A[j]*M;
            M = 0;
        }
        j++;
    }
    printf("%ld\n",money);
}


Measured memory_bytes: 1664
#include<stdio.h>
#include<stdlib.h>
#define N 500000
#define SENTINEL 1000000000

void mergesort( int,int);
void merge(int,int,int);

int A[N],count=0;
main()
{
  int left,right,mid,i,n;

  scanf("%d",&n);
 
  left = 0;
  right = n;
  mid = (left + right)/2;

  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }
  mergesort(left,mid);  /*????????§DEVIDE??????*/
  mergesort(mid,right);
  merge(left,mid,right);

  for(i=0;i<n;i++)
    {
      printf("%d",A[i]);
      if(i == n-1)break;
      printf(" ");
    }
  printf("\n%d\n",count);
  return 0;
}


void mergesort(int l,int r )
{
  int m;

  if(l+1<r)
    {
      m = (l + r)/2;
      mergesort(l,m);
      mergesort(m,r);
      merge(l,m,r);
    }
}


void merge(int l,int m,int r)
{
  int n1,n2,k,j,i;
  int *L,*R;
  n1 = m - l;
  n2 = r - m;

  L = malloc(sizeof(int)*(n1+1));/*SENTINEL??????????????????????????????*/
  R = malloc(sizeof(int)*(n2+1));

  for(i=0;i<n1;i++)
    {
      L[i] = A[l+i];
    }

  L[n1] = SENTINEL;

  for(i=0;i<n2;i++)
    {
      R[i] = A[m+i];
    }

  R[n2] = SENTINEL;

  j = 0;
  k = 0;

  for(i=l;i<r;i++)
    {
      if(L[j] <=R[k])
	{
	  A[i] = L[j];
	  j++;
	  count++;
	}
      else
	{
	  A[i] = R[k];
	  k++;
	  count++;
	}

    }

}

Measured memory_bytes: 63344
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

int main() {
  int a, b, c;
  int count;
  cin >> a >> b >> c;
  for(int i=a; i<=b; i++) {
    if(c % i == 0) count++;
  }
  printf("%d\n", count);
  return 0;
}

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

#define INF 1LL<<60



  int main(){
    int A, B;
    cin >> A >> B;
    if(10 <= A || 10 <= B) print(-1);
    else print(A * B); 
  }


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

ll dp[5005][5005];

void Main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    ll ans = 0;
    rep(i, N) {
        rep(j, N) {
            if (S[i] == S[j]) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            }
            if (i + dp[i + 1][j + 1] < j + 1) {
                ans = max(ans, dp[i + 1][j + 1]);
            }
        }
    }
    cout << ans << endl;

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 195840
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7

cnt = [0] * (max(A) + 2)
cnt[-1] = 1
ans = 1
for a in A:
    if a == 0:
        cnt[0] += 1
        continue
    ans = (ans * (cnt[a - 1] - cnt[a])) % mod
    cnt[a] += 1

if max(cnt) == 1:
    print((ans*3) % mod)
elif max(cnt) == 3:
    print((ans * 6) % mod)
elif max(cnt) == 2:
    print((ans * 6) % mod)
else:
    print(0)


Measured memory_bytes: 52804
#include <bits/stdc++.h>
#define IOS                 ios::sync_with_stdio(false); cin.tie(nullptr)
#define deb(x)              cout << #x << " = " << x << endl
#define deb2(x, y)          cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define f0(i, a, n)         for(i = a; i < n; i++)
#define f1(i, a, n)         for(i = a; i <= n; i++)
#define tc(t)               int t; cin >> t; while(t--)
#define ini(x, y)           memset(x, y, sizeof(x))
#define all(x)              x.begin(),x.end()
#define sz(x)               x.size()
#define ll                  long long int
#define vi                  vector<int>
#define si                  set<int>
#define pb                  emplace_back
#define ppb                 pop_back
#define mp                  make_pair
#define M                   1000000007
#define endl                '\n'
#define bits(x)             __builtin_popcountll(x)
#define zrbits(x)           __builtin_ctzll(x)

using namespace std;

void solve() {
        ll a, b, c, d, i;
        cin >> a >> b >> c >> d;
        cout << max(max(a*c, a*d), max(b*c, b*d)) << endl;
}

int main () {
        IOS;
        // tc(t)
        solve();
        return 0;
}

Measured memory_bytes: 3644
#include <iostream>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;
ll N, X;
ll nums[51];
ll ps[51];

ll dfs(ll X, ll N){
    if(N == 0) return 1;
    if(X == 1) return 0;
    else if(X >= 2 && X <= nums[N-1] + 1) dfs(X-1, N-1);
    else if(X == nums[N-1] + 2) return ps[N-1] + 1;
    else if(X >= nums[N-1] + 3 && X <= nums[N-1] * 2 + 2) return ps[N-1] + 1 + dfs(X-nums[N-1]-2, N-1);
    else return ps[N];
}

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

    nums[0] = 1;
    ps[0] = 1;
    for(int i=1; i<=N; i++){
        nums[i] = 2ll*nums[i-1] + 3;
        ps[i] = 2ll*ps[i-1] + 1;
    }

    ll ans = dfs(X, N);
    cout << ans << endl;
    
    return 0;
}


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

int main(){
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            printf("%dx%d=%d\n", i, j, i*j);
        }
    }
    return 0;
}



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

long long int mini(long long int a, long long int b) {

	return ((b==0)?a:(a < b)? a : b);
}
int main() {
	long long int a[5] = {}, N = 0;
	long long int ans = 0;
	long long int min = 1000000000000001;
	//int minum = 0,tmp = 0;
	cin >> N;
	for (int i = 0; i < 5; i++)
	{
		cin >> a[i];
		//min = tmp;
		min = mini(min, a[i]);
		//minum = (min != tmp)?i: minum;
	}
	/*for (int i = 0; i < minum; i++)
	{

	}*/
	ans = 4 + N / min + ((N % min == 0)?0:1);
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
using namespace std;
int n,cnt,mp[300005],del[300005],siz[300005];
long long ans[300005];
int main()
{
	scanf("%d",&n);
	for(int i=1,a;i<=n;i++)
	{
		scanf("%d",&a);
		if(!mp[a])mp[a]=++cnt;
		siz[mp[a]]++;
	}
	sort(siz+1,siz+1+cnt);
	for(int i=1;i<=cnt;i++)del[1]++,del[siz[i]+1]--;
	for(int i=1,nw=0;i<=n;i++)nw+=del[i],ans[i]=ans[i-1]+nw;
	for(int k=1;k<=n;k++)
	{
		int l=0,r=n,mid,ans1;
		while(l<=r)
		{
			mid=(l+r)/2;
			if(ans[mid]>=1ll*mid*k)ans1=mid,l=mid+1;
			else r=mid-1;
		}
		printf("%d\n",ans1);
	}
}

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

int N, A[1 << 18], B[1 << 18], C[1 << 18], dist[1 << 18];
vector<pair<int, int>> X[1 << 18];

void dfs(int pos, int dep) {
	if (dist[pos] != -1) return;
	dist[pos] = dep;
	for (int i = 0; i < X[pos].size(); i++) dfs(X[pos][i].first, dep ^ X[pos][i].second);
}

int main() {
	cin >> N;
	for (int i = 1; i <= N - 1; i++) {
		cin >> A[i] >> B[i] >> C[i]; C[i] %= 2;
		X[A[i]].push_back(make_pair(B[i], C[i]));
		X[B[i]].push_back(make_pair(A[i], C[i]));
	}
	for (int i = 1; i <= N; i++) dist[i] = -1;
	dfs(1, 0);
	for (int i = 1; i <= N; i++) cout << dist[i] << endl;
	return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll const mod=1000000007;
ll const md=998244353;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);
for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ifstream in("txt.in");
ofstream out("txt.out");

#define mp make_pair
#define pb push_back
#define fi first
#define se second

int f[100005];
int dp[100005];

int main()
{
    cout<<fixed<<setprecision(12);
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cout.tie(0);

    ll n,k;cin>>n>>k;
    for(int i=1;i<=n;++i){
        cin>>f[i];
    }
    ll cnt=0;
    for(int i=1;i<=n;++i)dp[i]=2e9;
    dp[1]=0;
    for(int i=2;i<=n;++i){
        for(int j=1;j<=k;++j){
            if(i-j>0)dp[i]=min(dp[i],dp[i-j]+abs(f[i]-f[i-j]));
        }
    }
    cout<<dp[n]<<'\n';


    return 0;
}


Measured memory_bytes: 1024
using System;
public class Hello{

    public static void Main(){

      int[] abc = new int[26];

      while(true){

        string line = Console.ReadLine();
        if(line==null)break;

        for(int i=0; i<line.Length; i++){
          if(char.IsLetter(line[i])){
              if(char.IsUpper(line[i])){
                  int sum = char.ToLower(line[i])-'a';
                  abc[sum]++;
              }else{
                int num = line[i]-'a';
                abc[num]++;
                //Console.WriteLine(num);
              }
          }
        }
        


      }
      char moji;
        int j =0;
        for(moji='a'; moji<='z'; moji++){
          Console.WriteLine(moji+" : "+abc[j]);
          j++;
          }

    }
  //#####################
    public static int[] LineToInt(){
      string line = Console.ReadLine();
      string[] arrStr = line.Split(' ');
      int[] arrInt = new int[arrStr.Length];

      for(var i=0; i<arrStr.Length;i++){
        arrInt[i] = int.Parse(arrStr[i]);
      }
      return arrInt;
  }
}



Measured memory_bytes: 17856
#include<stdio.h>
int main(void)
{
	int x, y, s,i,j,k,max=0,white=0;
	int fild[10][10] = {0};

	while (scanf("%d,%d,%d", &x, &y, &s) != EOF) {
		if (fild[x][y] == 0)white++;
		if (s == 1) {
			for (i = x - 1; i < x + 2; i++) {
				if (i >= 0 && i < 10) {
					if (i != x && fild[i][y] == 0)white++;
					fild[i][y] += 1;
				}
			}
			for (i = y - 1; i < y + 2; i++) {
				if (i >= 0 && i < 10) {
					if (i != y && fild[x][i] == 0)white++;
					fild[x][i] += 1;
				}
			}
			fild[x][y] -= 1;
		} 
		else if (s == 2) {
			for (i = x - 1; i < x + 2; i++) {
				for (j = y - 1; j < y + 2; j++) {
					if (i >= 0 && i < 10 && j >= 0 && j < 10) {
						if ((i != x || j != y) && fild[i][j] == 0)white++;
						fild[i][j] += 1;
					}
				}
			}
		}
		else if (s == 3) {
			k = 0;
			for (j = y - 2 + k; j <= y - 2 + k; j++) {
				for (i = x - k; i <= x + k; i++) {
					if (i >= 0 && i < 10 && j >= 0 && j < 10) {
						if ((i != x || j != y) && fild[i][j] == 0)white++;
					
						fild[i][j] += 1;
					}
				}
				k++;
				if (k == 3)break;
			}
			k = 0;
			for (j = y + 1 + k; j <= y + 1 + k; j++) {
				for (i = x -1 + k; i <= x+1-k; i++) {
					if (i >= 0 && i < 10 && j >= 0 && j < 10) {
						if (fild[i][j] == 0)white++;
						fild[i][j] += 1;
					}
				}
				k++;
				if (k == 2)break;
			}
		}
	}
	for (i = 0; i < 10; i++) {
		for (j = 0; j < 10; j++) {
			if (max < fild[i][j])
				max = fild[i][j];
		}
	}
	printf("%d\n", 100-white);
	printf("%d\n", max);

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    
    sort(a.begin(), a.end());
    sort(c.begin(), c.end());
    
    ll res = 0;
   
    rep(i, n){
        auto a_num = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        auto c_num = c.end() - upper_bound(c.begin(), c.end(), b[i]);
        res += a_num * c_num;
    }
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//library zone!!!!!
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ld mod_pow(ld x, ll n, ll p) {
	ld res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	string s;
	cin>>s;
	if(s.size()==2){
		cout<<s<<endl;
		return 0;
	}
	for(int i=2;i>=0;i--){
		cout<<s[i];
	}
	cout<<endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class A
{
    static void Main()
    {
        int[] i = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        int A = i[0];
        int B = i[1];

        if (A <= B) Console.WriteLine("unsafe");
        else Console.WriteLine("safe");
    }
}

Measured memory_bytes: 27484
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, k;
	cin >> a >> b >> k;
	int cnt = 0;
	for(int i = 100; i >= 1; i--){
		if(a%i == 0 && b%i == 0) cnt++;
		if(cnt == k){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
#include <utility>
#include <string>
#include <queue>
#include <cmath>
#include <array>

typedef long long ll;

int swap(const std::string s_orig)
{
    std::string s = s_orig;
    int l_ptr = 0;
    int r_ptr = s.length() - 1;
    int ans = 0;

    while(l_ptr != r_ptr) {
        if (s[l_ptr] != 'W') {l_ptr++; continue;}
        if (s[r_ptr] != 'R') {r_ptr--; continue;}
        
        s[l_ptr] = 'R';
        s[r_ptr] = 'W';
        ans++;
    }

    return ans;
}

int main(int argc, char *argv[])
{
    int n;
    std::string s;

    std::cin >> n;
    std::cin >> s;

    int ans = swap(s);

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

    return 0;
}

Measured memory_bytes: 3852
A, B, C, D = map(int, input().split())
cnt = 0
while True:
    if cnt % 2 == 0:
        C -= B
        cnt += 1
        if C <= 0:
            print('Yes')
            break
    else:
        A -= D
        cnt += 1
        if A <= 0:
            print('No')
            break


Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
string S, T;
string s[26] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
bool ans = false;
int main() {
  cin >> S >> T;
  for (int i = 0; i < 26; i++) {
    if (S + s[i] == T) {
      ans = true;
      break;
    }
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3624
from collections import Counter

# print('input >>')

S = input()
S = S[::-1] + '0'

mod = 0
mods = [0] * 2019
mods[0] += 1

i_mod = 1

for i in range(len(S)-1):
    # mods[i+1] = (int(S[i+1]) * 10 ** (i+1) + mods[i]) % 2019
    i_mod %= 2019
    mod = (int(S[i]) * i_mod + mod) % 2019
    # print(mod)
    mods[mod]+=1
    i_mod *= 10

# print(mods)

ans = 0

# counter = Counter(mods)

# for n in counter.values():
#     if n > 1:
#         ans += (n * (n-1)) // 2

# print('-----output-----')

for m in mods:
    if m > 1:
        ans += (m * (m-1)) // 2

print(ans)

Measured memory_bytes: 9584
// a template for main.cpp
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, k;
    cin >> k >> a >> b;
    for (int i = a; i <= b; i++) {
    	if ((i % k) == 0) {
    		cout << "OK\n";
    		exit(0);
    	}
    }
    cout << "NG\n";
}


Measured memory_bytes: 3628
//たてH cm よこ W cm の枠を描くプログラムを作成して下さい。 

#include<stdio.h>
int main()
{
  int a,b,i,j;
  while(1)
       {
  scanf("%d%d",&a,&b);
  if(a==0&&b==0){break;}
 
  for(i=1;i<=a;i++)
    {
      for(j=1;j<=b;j++)
    {
      if(i>1&&i<a&&j<b&&j>1)printf(".");
      else printf("#");
    }
      printf("\n");
    }
  printf("\n");
     
       }
  return 0;
}


Measured memory_bytes: 2112
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_left # bisect_left(list, value)
#from fractions import gcd

sys.setrecursionlimit(10**7)
N, M, K = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0]*(n)
        self.size = [1]*(n)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def get_size(self, x):
        x = self.find(x)
        return self.size[x]

#uni = UnionFind(10)
#print('par', uni.par)
#print('1-4', uni.same_check(1,4))
#print('union', uni.union(1,4))
##print('par', uni.par)
##print('1-4', uni.same_check(1,4))

uni = UnionFind(N)
for ab in AB:
    a, b = ab[0]-1, ab[1]-1
    uni.union(a, b)

res = [uni.get_size(x)-1 for x in range(N)]

for ab in AB:
    a, b = ab[0]-1, ab[1]-1
    res[a] -= 1
    res[b] -= 1

for cd in CD:
    c, d = cd[0]-1, cd[1]-1
    if uni.same_check(c, d):
        res[c] -= 1
        res[d] -= 1

print(*res)



Measured memory_bytes: 64552
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] ary = sc.nextLine().split(" ");
		Arrays.parallelSort(ary);
		System.out.println(Integer.parseInt(ary[2]+ary[1]) + Integer.parseInt(ary[0]));
	}
}

Measured memory_bytes: 21844