akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

int main(){
    std::string S, ans;
    std::cin >> S;

    if(S.at(2) == S.at(3) && S.at(4) == S.at(5)){
        ans = "Yes";
    }
    else{
        ans = "No";
    }

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

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n, a, b,tmp=0,ans=1e9;
	cin >> n;
	REP(i, n/2) {
		a = n - i;
		b = i;
		tmp = 0;
		while(a >= 10){
			tmp += a % 10;
			a /= 10;
		}
		tmp += a;
		while (b >= 10) {
			tmp += b % 10;
			b /= 10;
		}
		tmp += b;
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3552
#include<stdio.h>
int MAX(int a,int b){return a<b?b:a;}
int main(){
  int n,m,c=0,i;
  char s[100010];
  scanf("%d %d %s",&n,&m,s);
  for(i=1;i<n;i++){
    if(s[i-1]-s[i])c++;
  }//printf("%d\n",c);
  printf("%d\n",n-MAX(0,c-m*2)-1);
  return 0;
}


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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
typedef vector<int> vi;typedef vector<vi> vvi;typedef pair<int,int> pii;typedef vector<pii> vpii;
typedef long long ll;

void Main() {
  int N;
  scanf("%d", &N);
  vi A(N);
  rep(i, N) scanf("%d", &A[i]);
  sort(ALL(A));
  reverse(ALL(A));

  int d = 0;
  for (d = 0; d < N; d++) {
    if (A[d] <= d) break;
  }
  d--;

  int u = A[d] - d - 1;
  int r = d;
  for (r = d; r < N; r++) {
    if (A[r] <= d) break;
  }
  r = r - d - 1;

  //cout<<"d: "<<d<<endl;
  //cout<<"r: "<<r<<endl;
  //cout<<"u: "<<u<<endl;
  if (r % 2 == 0 && u % 2 == 0) puts("Second");
  else puts("First");

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


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX=100001;
int main()
{
  int n,a,q,b,c,i;
  int d[N_MAX];
  long long s=0;
  fill(d+1,d+N_MAX,0);
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a;
    d[a]++;
    s+=a;
  }
  cin >> q;
  for(i=0;i<q;i++){
    cin >> b >> c;
    s+=(c-b)*d[b];
    cout << s << endl;
    d[c]+=d[b];
    d[b]=0;
  }
  return 0;
}

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

using namespace std;

#define rep(i, a, b)  for(int i = (a); i < (b); i++)
#define rrep(i, a, b) for(int i = (a); i > (b); i--)
#define sq(x) ((x) * (x))
#define bit(x) bitset<32>(x)
#define vsort(v)  sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<llint>())
#define debug(x) cout << #x << " " << (x) << endl
#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


template<typename Tn> Tn __lcm(Tn a, Tn b)
{
    return a / __gcd(a, b) * b;
}

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

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

    if(13 <= a)
	co << b << en;
    else if(6 <= a && a <= 12)
	co << b / 2 << en;
    else
	co << 0 << en;
  
    return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
l = [[] for _ in range(n)]
ac,wa = (0,0)
for i in range(m):
  p,s = input().split()
  p = int(p)
  if s == "AC":
    if s not in l[p-1]:
      l[p-1].append(s)
      ac += 1
      wa += l[p-1].count("WA")
  else:
    l[p-1].append(s)
print(ac,wa)

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

int main(){
  long A,B,a,b,r=2;
  
  cin>>A>>B;
  if(B<A){
    a=A;b=B;
  } else{
    a=B;b=A;
  }
  
    while(r!=0){
      r=a%b;	a=b;	b=r;
    }
    cout<<(A*B)/a;
}

 

Measured memory_bytes: 256
// C - Synthetic Kadomatsu

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

int N, A, B, C;
int ans = INF;
vector<int> l;
vector<int> A_l, B_l, C_l;

int calc_mp(vector<int> X_l, int X) {
	int total_l = 0;
	for (int x : X_l) {
		total_l += x;
	}

	return abs(X - total_l);
}

void calc() {
	if (A_l.size() == 0 || B_l.size() == 0 || C_l.size() == 0) return;

	int total_mp = 0;

	total_mp += calc_mp(A_l, A) + 10 * (A_l.size() - 1);
	total_mp += calc_mp(B_l, B) + 10 * (B_l.size() - 1);
	total_mp += calc_mp(C_l, C) + 10 * (C_l.size() - 1);

	ans = min(ans, total_mp);
}

// 竹k(0-index)をA〜Cのどれかに割り当てるか、どれにも割り当てない
void synth(int k) {
	if (k == N) {
		calc();
		return;
	}

	A_l.push_back(l[k]);
	synth(k+1);
	A_l.pop_back();

	B_l.push_back(l[k]);
	synth(k+1);
	B_l.pop_back();

	C_l.push_back(l[k]);
	synth(k+1);
	C_l.pop_back();

	synth(k+1); // 割り当てない
}

int main() {
	cin >> N >> A >> B >> C;

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

	synth(0);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}


//for(int i = ; i < ; i++){}

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int ans = min(b,d)-max(c,a);
  if(ans<0)cout<<0<<endl;
  else cout<<ans<<endl;

  return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a,b;
	char op;
	
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		
		if(op=='+'){
			printf("%d\n",a+b);
			}
		else if(op=='-'){
			printf("%d\n",a-b);
			}
		else if(op=='*'){
			printf("%d\n",a*b);
		}
		else if(op=='/'){
			printf("%d\n",a/b);
		}
		else {
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 1964
function main(lines) {
  const N = s();
  
  let sum = 0;
  for (let n of N) {
    sum += Number(n);
  }
  const ans = sum % 9 == 0 ? 'Yes' : 'No';
  
  return ans;
}



const lines = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");

let lineCount = 0;
const s = () => lines[lineCount++];
const n = () => Number(s());
const b = () => BigInt(s());
const sa = () => s().split(' ');
const na = () => sa().map(Number);
const ba = () => sa().map(BigInt);

const ans = main(lines);
console.log( ans );

Measured memory_bytes: 35608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    ll n;
    cin >> n;
    ll sum = 0;
    ll a[n];
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    if(sum % (n * (n + 1) / 2) != 0){
        cout << "NO" << endl;
        return 0;
    }
    ll cnt = 0;
    ll k = sum / (n * (n + 1) / 2);
    for(int i = 0; i < n; i++){
        ll d = a[(i + 1) % n] - a[i];
        if((k - d) % n != 0 || k < d){
            cout << "NO" << endl;
            return 0;
        }
        cnt += (k - d) / n;
    }
    cout << "YES" << endl;
    return 0;
}

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

int main()
{
    int k=0,len,i;
    char a[100000];
    scanf("%s",a);
    len=strlen(a);
    for(i=0;i<len-1;i++)
    {
        if(a[i]==a[i+1])
        {
            if(a[i]=='0')
                a[i+1]='1';
            else
                a[i+1]='0';
            k++;
        }
    }
    printf("%d",k);
    return 0;
}

Measured memory_bytes: 384
// Oh damn, cann't you see I'm fine?

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'

const int max_n = 2e5 + 5;

int a[max_n], b[max_n], x[max_n], y[max_n];

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

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

	if(n > 2000) {

		sort(a, a+n, [&] (int i, int j) {
			return (x[i] + y[i] < x[j] + y[j]);
		});

		sort(b, b+n, [&] (int i, int j) {
			return (x[i] - y[i] < x[j] - y[j]);
		});

		vector <int> v;
		for(int i=0; i<500; i++) {
			v.push_back(a[i]);
			v.push_back(a[n-1-i]);
			v.push_back(b[i]);
			v.push_back(b[n-1-i]);
		}

		int ans = 0;
		for(int i=0; i<v.size(); i++) {
			for(int j=i+1; j<v.size(); j++) {
				ans = max(ans, abs(x[v[i]] - x[v[j]]) + abs(y[v[i]] - y[v[j]]));
			}
		}
		cout << ans << endl;
		return 0;

	}

	int ans = 0;
	for(int i=0; i<n; i++) {
		for(int j=i+1; j<n; j++) {
			ans = max(ans, abs(x[i] - x[j]) + abs(y[i] - y[j]));
		}
	}
	cout << ans << endl;


	return 0;
}

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

int main() {
  long long n,a;
  cin>>n;
  long long b=1001001001001001;
  bool ok=false;
  for(long long i=1;i*i<=n;i++){
    if(n%i==0){
     a=i+n/i;
      ok=true;
    }
    b=min(a,b);
  }
  
  if(ok)cout<<b-2<<endl;
  else cout<<b-1<<endl;
  
    
 
}


Measured memory_bytes: 256
n = gets.chop.to_i

s = []
cnt = Hash.new{0}


allow_pre = ['M', 'A', 'R', 'C', 'H']

n.times do
  s = gets.chop
  if allow_pre.include?(s[0])
    cnt[s[0]] +=1
  end
end




case cnt.size
when 0,1,2 then
  puts 0
when 3 then
  tmp = 1
  cnt.each{ |key, value|
    tmp = tmp * value
  }
  puts tmp

when 4, 5 then
  ans = 0

  cnt.keys.combination(3) { |a, b, c |
    ans += cnt[a] * cnt[b] * cnt [c]
  }

  puts ans

end


Measured memory_bytes: 2044
#include<iostream>
#include<vector>
#include<map>
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n";
#pragma GCC optimize "trapv"
using namespace std;
typedef long long int ll;
int main()
{
    ll x,k,d;
    cin>>x>>k>>d;
    x = abs(x);
    ll val = x/d;
    if(val>= k)
    {
        ll ans = x - k*d;
        cout<<ans<<endl;
    }
    else{
        ll rem = x%d;
         k = k-val;
        ll rem2 = rem -d;
        // cout<<rem<<" "<<rem2<<" "<<k<<" "<<val<<endl;
        if(k&1){
            cout<<abs(rem2)<<endl;
        }
        else{
            cout<<abs(rem)<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3580
#include <stdio.h>

int main()
{
    int i;

    //入力
    int n;
    scanf("%d", &n);
    int R[n];
    for( i = 0; i < n; ++i )
        scanf("%d", &R[i]);

    //minが最小になるようにmaxを選ぶ
    int min = R[0], max = R[1] - R[0];
    for( i = 1; i < n; ++i ){
        max = max < R[i] - min ? R[i] - min : max;
        min = min > R[i] ? R[i] : min; //minは後から更新しないと R[i]-min == min-min になる
    }

    printf("%d\n", max);

    return 0;
}

Measured memory_bytes: 1376
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int count=0;


        int N = sc.nextInt();
        int A[] = new int[N];
        for(int i=0; i<N; i++) A[i]=sc.nextInt();

        for(int i=0;i<N;i++)
        {
            for(int k=0; k<N-i-1; k++)
            {
                if(A[k+1]<A[k])
                {
                    int c;
                    c=A[k+1]; A[k+1]=A[k]; A[k]=c;
                    count++;
                }
            }
        }

        for(int i=0; i<N-1; i++) System.out.printf("%d ",A[i]);
        System.out.printf("%d\n",A[N-1]);
        System.out.println(count);

        sc.close();
    }
}


Measured memory_bytes: 26444
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
using namespace std;

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

    /* day => pays [1, 2, 3] */
    map<int, vector<int>> jobs;
    priority_queue<int> can;;

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

    int sum = 0;
    for (int r = 1; r <= m; r++) {
        for (int p: jobs[r]) {
             can.push(p);
        }
        if (can.empty())
            continue;
        sum += can.top();
        can.pop();
    }

    cout << sum << endl;
}

Measured memory_bytes: 10880
x,y,z=map(int,input().split())
s=x*y*(z//2)
ss=x*y*(z-z//2)
l=abs(s-ss)
c=y*z*(x//2)
cc=y*z*(x-x//2)
r=abs(c-cc)
d=z*x*(y//2)
dd=z*x*(y-y//2)
p=abs(d-dd)
print(min(r,l,p))


Measured memory_bytes: 61616
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

using graph = vector<vector<int>>;

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

  graph g(n);
  vector<int> d(n, 0);
  REP(i, m){
    int x, y, z; cin >> x >> y >> z;
    --x; --y;

    g[x].push_back(y);
    d[x] += 1;
    g[y].push_back(x);
    d[y] += 1;
  }

  vector<pair<int, int>> vp(n);
  REP(i, n) vp[i] = make_pair(d[i], i);
  sort(vp.begin(), vp.end(), greater<pair<int, int>>());

  vector<bool> vis(n, false);
  function<void(int)> dfs = [&](int v){
    vis[v] = true;

    for(int nv : g[v]){
      if(!vis[nv]) dfs(nv);
    }
  
    return;
  };

  int ans = 0;
  REP(i, n){
    int v = vp[i].second;
    if(!vis[v]){
      dfs(v);
      ans += 1;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11648
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int a,b;
string s;

signed main(){
    cin>>a>>b;
    cin>>s;
    if(s[a] == '-'){
        s[a] = '0';
        for(int i = 0; i<s.size(); ++i){
            int p = s[i] - 48;
            if(p>9||p<0){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    cout << ((n >= 10) ? r : r + 100 * (10 - n)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int X;
  scanf("%d", &X);
  
  int i,j;
  
  for(i=X;;i++) {
  	for(j=2; j<i; j++){
      if(i%j == 0){
        break;
      }
    }
    if(j==i){
      break;
    }
  }
  printf("%d", i);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int Q=sc.nextInt();
		while(sc.hasNext()) {
			int X=sc.nextInt();
			int Y=sc.nextInt();
			int min=Math.min(Math.min(X, Y),Math.min(N+1-X, N+1-Y));
			//pl(min);
			if(min%3==0) {
				pl(3);
			}
			else {
				pl(min%3);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}


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

template <typename T> void chmin(T&x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long s64;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i)
#define gc (c=getchar())
int read()
{
	char c;
	while(gc<'-');
	if(c=='-')
	{
		int x=gc-'0';
		while(gc>='0')x=x*10+c-'0';
		return -x;
	}
	int x=c-'0';
	while(gc>='0')x=x*10+c-'0';
	return x;
}
#undef gc

const int N=3000+5,D=1e9+7;
s64 mi(s64 x,int y=D-2)
{
	s64 ans=1;
	while(y)
	{
		if(y&1)ans=ans*x%D;
		x=x*x%D;y>>=1;
	}
	return ans;
}
const s64 mi_2=mi(2);
int a[N],x[N],y[N];s64 dp[N][N],dp0[N][N];

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
#endif
	int n,q;
	cin>>n>>q;
	rep(i,1,n)a[i]=read();
	rep(i,1,q){x[i]=read();y[i]=read();}
	rep(i,1,n)
	rep(j,i+1,n)dp[i][j]=1;
	per(tmp,q,1)
	{
		int x=::x[tmp],y=::y[tmp];
		rep(i,1,n){dp0[x][i]=dp[x][i];dp0[i][x]=dp[i][x];dp0[y][i]=dp[y][i];dp0[i][y]=dp[i][y];}
		rep(i,1,n)
		{
			((dp[x][i]+=dp0[y][i])*=mi_2)%=D;((dp[i][x]+=dp0[i][y])*=mi_2)%=D;
			((dp[y][i]+=dp0[x][i])*=mi_2)%=D;((dp[i][y]+=dp0[i][x])*=mi_2)%=D;
		}	
		dp[x][y]=dp[y][x]=(dp0[x][y]+dp0[y][x])*mi_2%D; 
	}
	s64 ans=0;
	rep(i,1,n)
	rep(j,1,n)
	if(a[i]>a[j])ans+=dp[i][j];
	cout<<ans%D*mi(2,q)%D;
}


Measured memory_bytes: 141312
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var (
	sc = bufio.NewReader(os.Stdin)
)

func main() {
	N := scanInt()
	L := make([]int, N)
	for i := 0; i < N; i++ {
		L[i] = scanInt()
	}
	sort.Ints(L)

	c := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			if L[i] == L[j] {
				continue
			}
			for k := j + 1; k < N; k++ {
				if L[k] == L[i] || L[k] == L[j] {
					continue
				}
				if L[i]+L[j] > L[k] {
					c++
				}
			}
		}
	}
	fmt.Println(c)
}

func abs(a int) int         { return int(math.Abs(float64(a))) }
func scan(a ...interface{}) { _, err := fmt.Fscan(sc, a...); pnc(err) }
func scanStr() (s string)   { scan(&s); return }
func scanInt() int          { i, err := strconv.Atoi(scanStr()); pnc(err); return i }
func scanFloat() float64    { f, err := strconv.ParseFloat(scanStr(), 64); pnc(err); return f }
func pnc(err error) {
	if err != nil {
		panic(err)
	}
}


Measured memory_bytes: 1844
/*
    Problem 16
    https://atcoder.jp/contests/abc150/tasks/abc150_c
*/
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <bitset>

using namespace std;
/* typedef */
typedef long long ll;
/* constant */
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<int> A(N), B(N), v(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    for (int i = 0; i < N; i++) v[i] = i + 1;
    int indA, indB;
    int cnt = 0;
    do {
        if (A == v) indA = cnt;
        if (B == v) indB = cnt;
        cnt++;
    } while (next_permutation(v.begin(), v.end()));

    cout << abs(indA - indB) << '\n';
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = (1ll<<31)-1;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    PRINT(n/3);
}


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

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

  sort(L, L+n, greater<int>());

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

  if(L[0] < otherSum) {
    cout << "Yes" << endl;
    return 0;
  } else {
    cout << "No" << endl;
    return 0;
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws Exception {

//		System.setIn(new FileInputStream("D:\\Workspace\\SW\\src\\c\\tt"));
//		long startTime = System.currentTimeMillis();
		// strat

		// C - 点蜡烛
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		StringTokenizer st = new StringTokenizer(br.readLine());

		int N = Integer.parseInt(st.nextToken());
		int K = Integer.parseInt(st.nextToken());
		int[] xArr = new int[N + 1];

		st = new StringTokenizer(br.readLine());

		for (int i = 1; i <= N; i++) {
			xArr[i] = Integer.parseInt(st.nextToken());
		}

		int minRoute = 0;

		for (int i = 1; i <= N - K + 1; i++) {

			int start = xArr[i];
			int end = xArr[i + K - 1];

			int route = 0;

			if (end <= 0) {
				route = -start;
			} else if (start >= 0) {
				route = end;

			} else {
				route = end - start + Math.min(end, -start);
			}

			if (minRoute > route || minRoute == 0) {
				minRoute = route;
			}

		}

		System.out.println(minRoute);

		// end
//		long endTime = System.currentTimeMillis();
//		System.out.format("%.3f  ms", (endTime - startTime) / 1000.0);
	}

}


Measured memory_bytes: 37844
N = int(input())
M = 150
for A in range(1,int(round(N/2+2))):
    B = N - A
    AS = sum([int(x) for x in list(str(A))])
    BS = sum([int(x) for x in list(str(B))])
    S = AS+BS
    if(S<M):
        M=S
print(M)

Measured memory_bytes: 3060
#include <stdio.h>
void swap_variable(int* x, int* y) {
    int temp;
    temp = *x;
    *x = *y;
    *y = temp;
}
void swap(int* array, int i, int j) {
    int temp;
    temp = array[i];
    array[i] = array[j];
    array[j] = temp;
}
void sort(int* array, int n, int mode) {
    int i, j;
    if (mode) {  //昇順
        for (i = 0; i < n - 1; i++) {
            for (j = 0; j < n; j++) {
                if (array[i] > array[j]) {
                    swap(array, i, j);
                }
            }
        }
    } else {
        for (i = 0; i < n - 1; i++) {
            for (j = 0; j < n; j++) {
                if (array[i] < array[j]) {
                    swap(array, i, j);
                }
            }
        }
    }
}
int max(int x, int y) {
    if (x > y) {
        return x;
    } else {
        return y;
    }
}
int min(int x, int y) {
    if (x > y) {
        return y;
    } else {
        return x;
    }
}
int main(void) {
    int a, b, c;
    int temp;
    scanf("%d %d %d", &a, &b, &c);
    if (a > b) {
        swap_variable(&a, &b);
    }
    if (b > c) {
        swap_variable(&b, &c);
    }
    if (a > c) {
        swap_variable(&a, &c);
    }
    if (a + b == c) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()

ll power(ll b,ll e,ll m)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}

   
 bool isPowerOfTwo(ll x)
    {
        // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
        return (x && !(x & (x - 1)));
    }

ll ldd(ll n)
{
  for (ll i=3;i*i<=n;i+=2)
    if(n%i==0)
      return i;
}

void solve()
{
  ll n;
  cin>>n;
  string ans;
  while(n)
  {
    ans+=char('a'+(n-1)%26);
    n=(n-1)/26;
  }
  reverse(all(ans));
  cout<<ans<<"\n";
}


int main()       
{
  fastio
  ll t=1;
  while(t--)
    solve();
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) \
    do           \
    {            \
    } while (0)
#define dump(x) \
    do          \
    {           \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

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

LL gcd(LL m, LL n)
{
    if (m < n)
        swap(m, n);
    while (n)
    {
        m %= n;
        swap(m, n);
    }
    return m;
}

void solve()
{
    int n;
    cin >> n;
    VLL t(n);
    REP(i, 0, n)
    cin >> t[i];

    if (n == 1)
    {
        cout << t[0] << endl;
        return;
    }
    LL prev = t[0] / gcd(t[0], t[1]) * t[1];
    REP(i, 2, n)
    {
        LL g = gcd(prev, t[i]);
        prev = prev / g * t[i];
    }
    cout << prev << endl;
}

int main()
{
    solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

int main() {

	string S;
	cin >> S;

	S[5] = ' ';
	S[13] = ' ';

	cout << S << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int h,w;
  cin>>h>>w;
  vector<string> s(h);
  for(Int i=0;i<h;i++) cin>>s[i];

  for(Int i=0;i<h;i++){
    for(Int j=0;j<w;j++){
      if(s[i][j]=='x'){
	for(Int a=-1;a<=1;a++){
	  for(Int b=-1;b<=1;b++){
	    Int y=i+a,x=j+b;
	    if(!(0<=y&&y<h&&0<=x&&x<w)) continue;
	    if(s[y][x]=='-') s[y][x]='.';
	  }
	}
      }
      if(s[i][j]=='o'){
	for(Int b=-1;b<=1;b++){
	  Int y=i,x=j+b;
	  if(!(0<=y&&y<h&&0<=x&&x<w)) continue;
	  if(s[y][x]=='-') s[y][x]='.';	  
	}
      }
    }
  }
  
  Int ans=0;
  for(Int i=1;i<h;i++)
    for(Int j=0;j<w;j++)
      ans+=s[i][j]=='-';
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3216
X , K , D = map(int,input().split())
ans = 0
tmp = 0
tmp2 = 0
if abs(X) >= abs(D) * K:
	ans = abs(X) - abs(D) * K
else:
	tmp = abs(X) // abs(D)
	tmp2 = abs(X) - tmp * abs(D)

	if (K - tmp) % 2 ==0:
		ans = tmp2
	else:
		ans = abs(tmp2 -abs(D))
print(ans)

Measured memory_bytes: 9204
n,a,b = map(int,input().split())
if n < 2:
    if a == b:
        print("1")
        exit()
    else:
        print("0")
        exit()
if a > b:
    print("0")
    exit()
print(((b*(n-1)+a) - (a*(n-1)+b))+1)


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

int main()
{
	int n, m, days = 0;

	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int x;
		cin >> x;
		days += x;
	}

	if (n-days < 0)
		cout << -1 << endl;
	else
		cout << n-days << endl;

}


Measured memory_bytes: 3616
N = int(input())
D = []
for i, a in enumerate(map(int, input().split())):
    D.append((a<<11) + i)
D.sort(reverse=True)
dp = [0]*(N+1)
for i, d in enumerate(D,start=1):
    x, a = d%(1<<11),d>>11
    for j in reversed(range(0, i+1)):
        dp[j] = max((dp[j-1]+a*abs(x-(j-1)))*(j-1>=0), (dp[j]+a*abs(N-(i-j)-x))*(j<=i-1))
print(max(dp))

Measured memory_bytes: 74840
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){return *(ll *)a - *(ll *)b;}

int main(void){
    char s[10],t[10],u[10];
    ll a,b;
    scanf("%s%s%lld%lld%s",s,t,&a,&b,u);
    ll an,bn,cn;
    an = strlen(s);
    bn = strlen(t);
    cn = strlen(u);
    if(an!=bn){
        if(an==cn){
            printf("%lld %lld\n",a-1,b);
        }else{
            printf("%lld %lld\n",a,b-1);
        }
    }else{
        for(ll i=0;i<min2(an,bn);i++ ){
            if(s[i]!=u[i]){
                printf("%lld %lld\n",a,b-1);
                break;
            }
            if(t[i]!=u[i]){
                printf("%lld %lld\n",a-1,b);
                break;
            }
        }
    }


    // printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<unordered_map>
#include<vector>
#include<set>

using namespace std;

int main(){
  int N,M,output=0;
  vector<int> obs;
  unordered_map< int,set<int> > map;
  cin>>N>>M;
  for(int i=0;i<N;i++){
    map[i] = set<int>();
    int ob;
    cin>>ob;
    obs.push_back(ob);
  }
  for(int i=0;i<M;i++){
    int ob1,ob2;
    cin>>ob1>>ob2;
    map[ob1-1].insert(ob2-1);
    map[ob2-1].insert(ob1-1);
  }
  for(auto p : map){
    if(p.second.size()==0){
      output++;
    }
    else{
      int isGood = 1;
      for(auto v : p.second){
        if(obs[p.first]<=obs[v]){
          isGood = 0;
          break;
        }
      }
      if(isGood)
        output++;
    }
  }
  cout<<output<<endl;
  return 0;
}


Measured memory_bytes: 22188
N, M = map(int, input().split())

graph = [[] for i in range(N)]

for i in range(M):
    ai, bi = map(lambda x: int(x) - 1, input().split())
    graph[ai].append(bi)
    graph[bi].append(ai)

low = [N] * N
rank = [N] * N
visited = [False] * N


def dfs(k, pos, parent):
    low[pos] = k
    rank[pos] = k

    k += 1

    visited[pos] = True

    for i in graph[pos]:
        if not visited[i]:
            k = dfs(k, i, pos)
            low[pos] = min(low[pos], low[i])
        elif i != parent:
            low[pos] = min(low[pos], low[i])

    return k


def main():
    dfs(0, 0, -1)

    print(sum(
        [1 for i in range(N) for j in graph[i] if rank[j] < low[i]]))

    return


main()


Measured memory_bytes: 3064
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>
#define MAXN 100000
#define pii pair<int,int>

using namespace std;
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	printf("%d",max(a*b,c*d));
	return 0;
}

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

template <class T> T modpow(T a, T b) {
    if (b == 0) return T(1);
    if (b % 2 == 0) {
        long long d = modpow(a, b / T(2));
        return (d * d) % mod;
    } else {
        return (a * modpow(a, b - 1) % mod);
    }
}
signed main(){
    string L; cin >> L;
    Int L_size = (Int)L.size();
    // 0-index
    vector<Int>dp(L_size ,0LL);
    dp[0] = 2LL; dp[1] = 4LL;
    for(Int i = 2 ; i < dp.size(); ++i){
        Int res = modpow(3LL,i);
        dp[i] = (res + 1) % mod;
    }
    Int cnt = 0;
    Int ans = 0;
    Int id = L_size - 1;
    for(auto c : L){
        if(c == '1'){
            ans += ( modpow(2LL,cnt) * dp[id]);
            ans %= mod;
            ++cnt;
        }
        --id;
    }
    cout << (ans + 1) % mod<< endl;
}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
  int N, K;
  cin >> N >> K;
  vector<int> memo(N);
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    vector<int> A(d);
    for (int j = 0; j < d; j++) {
      cin >> A.at(j);
      memo.at(A.at(j) - 1) = 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (memo.at(i) == 0) {
      ans++;
    }
  }
  cout << ans << endl;
 
}

Measured memory_bytes: 3612
//tt89 ;)
#include<bits/stdc++.h>
using namespace std;
//typedef long long ll;
#define int long long
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
void testcase(int t) { cout<<"Case #"<<t<<": "; }
void online() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif //ONLINE_JUDGE
}
const int mod= 1e9+7;

int n,m,ans;
set<pair<int,int>> s;
vector<int> row,col,x,y;

int getAns() {
    int ans=0;
    for(int i: x) {
        for(int j: y) {
            int c= row[i]+col[j];
            if(s.find({i,j})!=s.end()) c--;
            else return c;
            ans= max(ans,c);
        }
    }
    return ans;
}


signed main() {
    fastIO;
    cin>>n>>m;
    ans=0;
    row.resize(n,0); col.resize(m,0);
    int t; cin>>t;

    while(t--) {
        int a,b; cin>>a>>b;
        row[a-1]++; col[b-1]++;
        s.insert({a-1,b-1});
    }
//    vector<int> x,y;
    int a=0,b=0;

    for(int i=0;i<n;i++) {
        if(row[i]==a) x.push_back(i);
        else if(row[i]>a) {
            x= {i}; a= row[i];
        }
    }
    for(int i=0;i<m;i++) {
        if(col[i]==b) y.push_back(i);
        else if(col[i]>b) {
            y= {i}; b= col[i];
        }
    }
    int ans= getAns();
    cout<<ans;

    return 0;
}


Measured memory_bytes: 34972
n = int(input())
a, *b = map(int,input().split())
mask = 0
for i in b:
    mask = mask | (1<<i)
for i in range(1<<n):
    ans = []
    _i = i
    cnt = 0
    if (i & mask) == mask:
        while i:
            if i&1:
                ans.append(cnt)
            cnt += 1
            i=i>>1
        print(f'{_i}:',end = '')
        if _i == 0:
            print()
        else:print("",*ans)


Measured memory_bytes: 6256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define rn return
#define fi first
#define se second
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;

int main(){
    int h,w; cin >> h >> w;
    vector<string> grid(h);
    rep(i,h) cin >> grid[i];
    
    vector<vector<int>> dist(h,vector<int>(w,-1));
    vector<pair<int,int>> que;
    
    rep(i,h){
        rep(j,w){
            if (grid[i][j] == '#') {
                que.emplace_back(i,j);
                dist[i][j] = 0;
            }
        }
    }
    
    
    rep(b,(int)que.size()){
        FOR(dx,-1,2){
            FOR(dy,-1,2){
                if (dx*dx + dy*dy == 1){
                    int xk = que[b].first + dx;
                    int yk = que[b].second + dy;
                    if (xk >= 0 && yk >= 0 && xk < h && yk < w && dist[xk][yk] == -1){
                        que.emplace_back(xk,yk);
                        dist[xk][yk] = dist[que[b].first][que[b].second] + 1;
                                            
                    }
                }
            }
        }
    }
    
    cout << dist[que.back().first][que.back().second];
}

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

int main() {
  int N, A, B=0;
  cin >> N;
  rep(i, N){
    cin >> A;
    if(A%2==0){
      if(A%3!=0 && A%5!=0){
        B=1;
        break;
      }
    }
  }
  if(B==1) cout << "DENIED" << endl;
  else cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<bits/stdc++.h>
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n)  for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e18
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  int n,k;  cin >> n >> k;
  vi h(n);  rep0(i,n)cin>>h[i];
  vll dp(n+1,INF);
  dp[0] = 0;
  rep0(i,n){
    rep1(j,k){
  	  if(i+j < n){
  	    chmin(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
  	  }
    }
  }
  cout << dp[n-1];
}


Measured memory_bytes: 1408
/**
 * Contest : AtCoder Beginner Contest 163
 * Contest URL : https://atcoder.jp/contests/abc163/tasks
 * Problem : A - Circle Pond
 * Problem URL : https://atcoder.jp/contests/abc163/tasks/abc163_a
 */

#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
using pii = pair < int, int >;

// This section is for Policy Based Data Structure, more precisely Ordered Set.
// All Functions of set works here, in addition we have order_of_key() and find_by_order() function. find_by_order() returns iterator
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace __gnu_pbds;

// 1. Custom Set
template < class T, class COMP >
using custom_set = tree < T, null_type, COMP, rb_tree_tag, tree_order_statistics_node_update >;

// 2. Ordered Set
template < class T >
using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;

// 3. Ordered Multi Set
// For storing multiple occurance of same value we need to use pair. In pair first value is our key and second is useless count variable.
// order_of_key(make_pair(key, 0)) returns first occurance of a value, order_of_key(make_pair(key, INT_MAX)) returns last occurance.
template < class T >
using ordered_multiset = tree < pair < T, int >, null_type, less < pair < T, int > >, rb_tree_tag, tree_order_statistics_node_update >;

// 4. Ordered Map
template < class T, class U >
using ordered_map = tree < T, U, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
// Policy End

void solve() {
	int R; cin >> R;
	double c = 2 * M_PI * R;
	cout << c << endl;
}

int main() {
	ios_base::sync_with_stdio (false);
	cin.tie (0); cout.tie (0);
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


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

typedef long long ll;

ll gcd(ll x, ll y)
{
	return (y == 0 ? x : gcd(y, x % y));
}

int main()
{
	ll x, y;
	scanf("%lld%lld", &x, &y);
	printf("%lld\n", 3 * (x - gcd(x, y)));

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int n;
    cin>>n;
    int a[n];
    int pre[n] , suffix[n];
    for(int i = 0 ;i< n; i++){
        cin>>a[i];
    }
    pre[0] = a[0];
    for(int i = 1 ; i < n; i++){
        pre[i] = __gcd(pre[i-1] , a[i]);
    }
    suffix[n-1] = a[n-1];
    for(int i = n-2 ; i>=0 ; i--){
        suffix[i] = __gcd(suffix[i+1] , a[i]);
    }
    if(n == 1)
        cout<<a[0]<<endl;
    else if(n == 2){
        cout<<max(a[0] , a[1])<<endl;
    }else {
        int ans = max(pre[n-2] , suffix[1]);
        for(int i = 1 ; i < n-1 ; i++){
            int gcd = __gcd(pre[i-1] , suffix[i+1]);
            ans = max(gcd , ans);
        }
        cout<<ans<<endl;
    }
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int M;
	cin >> M;
	vector<pair<int, ll>> dc(M);
	for(int i=0; i<M; i++) cin >> dc[i].first >> dc[i].second;

	vector<int> rev;
	ll ans = 0;
	while(dc.size()>0){
		int d = dc[dc.size()-1].first;
		ll c = dc[dc.size()-1].second;
		dc.pop_back();
		if(c == 1){
			rev.push_back(d);
			continue;
		}
		if(c%2){
			rev.push_back(d);
			c--;
		}
		c /= 2;
		d = 2*d;
		ans += c;
		if(d>=10){
			d -= 9;
			ans += c;
		}
		dc.push_back({d, c});
	}

	debugv(rev);
	debug(ans);

	while(rev.size()>1){
		int d1 = rev[rev.size()-1];
		rev.pop_back();
		int d2 = rev[rev.size()-1];
		rev.pop_back();
		int d = d1+d2;
		ans++;
		rev.push_back(d%10);
		if(d>=10){
			rev.push_back(1);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 20840
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long ans = 0;
		long sum = 0;
		long sqSum = 0;

		final long MOD = 1000000007;

		for (int i = 0; i < n; i++) {
			long a = sc.nextLong();
			sum = (sum + a) % MOD;
			sqSum = (sqSum + (a * a) % MOD) % MOD;
		}

		ans = ((sum * sum) % MOD - sqSum) % MOD;

		if (ans < 0) {
			ans = ans + MOD;
		}

		ans = ans * (MOD + 1) / 2;
		ans = ans % MOD;

		System.out.println(ans);

		sc.close();

	}

}

Measured memory_bytes: 60296
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	int n, m, x,cnt=0,cnt2=0;
	cin >> n >> m >> x;
	vector<int>a(m);
	for (int&  p : a)cin >> p;

	for (int i = x; i <= n; i++) {
		if (count(a.begin(), a.end(), i) == 1)cnt += 1;
	}
	for (int i = x; i >=0; i--) {
		if (count(a.begin(), a.end(), i) == 1)cnt2 += 1;
	}

	cout << min(cnt, cnt2) << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    String s = scan.next();
    if(a<3200) {
      System.out.println("red");
    }else{
      System.out.println(s);
    }
  }
}

Measured memory_bytes: 23636
#include <stdio.h>

int is_true(int c[3][3])
{
    int i, j;

    for (i = 0; i < 2; i++) {
        for (j = 0; j < 2; j++) {
            if (c[i][j] - c[i + 1][j] != c[i][j + 1] - c[i + 1][j + 1]) {
                return 0;
            }
        }

        for (j = 0; j < 2; j++) {
            if (c[j][i] - c[j][i + 1] != c[j + 1][i] - c[j + 1][i + 1]) {
                return 0;
            }
        }
    }

    return 1;
}

int main(void)
{
    int c[3][3];

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            scanf("%d", &c[i][j]);
        }
    }

    if (is_true(c)) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128