akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long int
#define MOD 1000000007
using namespace std;

const int N=100001;
const int M=101;
int dp[N]; int n; int arr[N];
int INF=10000000000000000;
int k;

int go(int index){
	if(index==n-1)
	return 0;
	
	if(dp[index]!=-1)
	return dp[index];
	
	int ans=INF;
	for(int i=1;i<=k;i++){
		if(index+i<=n-1)
		ans=min(ans,abs(arr[index+i]-arr[index])+go(index+i));
	}
	
	return dp[index]=ans;
}

#undef int
int main(){
	#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t=1;
	while(t--){
		cin >> n >> k;
		for(int i=0;i<n;i++){
			cin>>arr[i];
		}
		memset(dp,-1,sizeof(dp));
		cout<<go(0)<<endl;
	}
	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int W = in(),a = in(),b = in();
    cout << max(0,abs(a-b)-W) << "\n";
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(void)
{
	int i,j,a,b,kou[101],cnt,flg;
	while(scanf("%d %d",&a,&b)!=EOF)	{
		for(i=1;i<=100;i++)	kou[i]=0;
		kou[a]++;	kou[b]++;
		while(1)	{
			scanf("%d %d",&a,&b);
			if(a==0 && b==0)	break;
			kou[a]++;	kou[b]++;
		}
		flg=1;
		for(i=3;i<=100;i++)	{
			if(kou[i]%2==1)	{
				flg=0;
				break;
			}
		}
		if(kou[2]%2==0 || kou[1]%2==0)	flg=0;
		if(flg==1)	printf("OK\n");
		else printf("NG\n");
	}	
	return 0;
}


Measured memory_bytes: 1012
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int W = sc.nextInt();
			int H = sc.nextInt();
			int MOD = 100000;
			if (W == 0) break;
			int[][][][] dp = new int[H + 1][W + 1][2][2];
			dp[0][0][0][1] = dp[0][0][1][1] = 1;
			for (int i = 0; i < H; ++i) {
				for (int j = 0; j < W; ++j) {
					dp[i + 1][j][0][0] += dp[i][j][0][0] + dp[i][j][0][1];
					dp[i + 1][j][0][0] %= MOD;
					dp[i][j + 1][1][0] += dp[i][j][1][0] + dp[i][j][1][1];
					dp[i][j + 1][0][0] %= MOD;
					dp[i + 1][j][0][1] += dp[i][j][1][0];
					dp[i + 1][j][0][1] %= MOD;
					dp[i][j + 1][1][1] += dp[i][j][0][0];
					dp[i][j + 1][1][1] %= MOD;
				}
			}
			int ans = 0;
			for (int i = 0; i < 2; ++i) {
				for (int j = 0; j < 2; ++j) {
					ans += dp[H - 1][W - 1][i][j];
				}
			}
			System.out.println(ans % MOD);
		}
	}
}

Measured memory_bytes: 13000
#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;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define endl '\n'
#define loop(a,b,c) for(ll i=a;i<=b;i+=c)
#define intarr(arr,n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i]
#define inparr(arr,n) for(ll i=0;i<n;i++)cin>>arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define newline cout<<endl
#define ump unordered_map<ll,ll>
#define vec vector<ll>
#define mkp make_pair
#define disp(var1,var2) cout<<var1<<" "<<var2<<endl;
#define all(v)             v.begin(),v.end()
#define cout(var) cout<<var<<endl
#define mod2 998244353
#define fbo find_by_order  /// find kth smallest by passing k-1
#define ook order_of_key  //// find no of smaller items less than k
#define teensort(a,r,g,b) a[0]=r;a[1]=g;a[2]=b;sort(a,a+3);
#define ss second
#define ff first
#define displayarray(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
#define pi pair<ll,ll>
#define meramax 1e18
#define meramin -1e18
#define percentile 1000000007
void AcDegaYe() 
{
    string a,b;
    cin>>a>>b;
    b.erase(b.length()-1,1);
    if(a==b)
    {
        cout("Yes");
    }
    else
        cout("No");
}
int main()
{   
    fastio
    //ll t;
    //cin>>t;
    ll t=1;
    while(t--)
    {
        AcDegaYe();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define N 1005
#define M 2005

using namespace std;

int n, m;
int dep[N];
int head[N], nex[M], to[M], e;
int stk[N], top;
bool instack[N], vis[N], G[N][N];
vector<int> res;

inline int Rd() {
	int x = 0; char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	return x;
}
inline void Ae(int u, int v) {
	nex[++e] = head[u], head[u] = e;
	to[e] = v;
}

void calc(int u, int v) {
	do {
		res.push_back(stk[top]);
	} while(stk[top--] != v);
	int ans = res.size();
	printf("%d\n", ans);
	for(int i = 0; i < ans; ++i) printf("%d\n", res[i]);
	exit(0);
}
void dfs(int u) {
	stk[++top] = u;
	instack[u] = vis[u] = true;
	for(int i = head[u]; i; i = nex[i]) {
		int v = to[i];
		if(vis[v]) {
			if(instack[v]) calc(u, v);
		} else {
			dfs(v);
		}
	}
	instack[u] = false, --top;
	return;
}

int main() {
	n = Rd(), m = Rd();
	for(int i = 1; i <= m; ++i) {
		int u = Rd(), v = Rd();
		G[u][v] = true;
		Ae(u, v);
	}
	
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) {
			if(G[i][j] && G[j][i]) {
				puts("2");
				printf("%d\n%d\n", i, j);
				return 0;
			}	
		}
	}
	for(int i = 1; i <= n; ++i)
		if(!vis[i])
			dfs(i);
	puts("-1");
	return 0;	
}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        compare(a, b, c);
    }

    private static void compare(int a, int b, int c) {
        if (a < b && b < c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26208
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
	ll N;
	cin >> N;
	vl b(N);
	FOR(i,0,N)cin >> b[i];
	FOR(i,0,N){
		if(b[i] > i+1){
			cout << -1 << endl;
			return 0;
		}
	}
	vl ans;
	FOR(i,0,N){
		REP(j,0,b.size()){
			if(b[j] == j+1){
				ans.pb(b[j]);
				b.erase(b.begin()+j);
				break;
			}
		}
	}
	reverse(ALL(ans));
	for(auto x:ans)cout << x << endl;
}

Measured memory_bytes: 256
A, B = gets.strip.split.map(&:to_i)

# この観覧車は、 13 歳以上が乗るには B 円 ( B は偶数) かかりますが、 6 歳以上 12 歳以下の人はその半額で乗ることができ、 さらに 5 歳以下の人は無料で乗ることができます。

sum = 0
if A >= 13 
  sum = B
elsif A >= 6 && A <= 12
  sum = B / 2
else
  sum = 0
end

puts sum


Measured memory_bytes: 1788
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v; ll w; };

const int MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 2;

int main() {
	for (;;) {
		int N; cin >> N;
		if (!N) break;
		vector<int> a(N);
		rep(i, N) scanf("%d", &a[i]);
		vector<vector<int> > as(501);
		for (int x: a) {
			int y;
			for (y = x; y % 2 == 0; y /= 2);
			as[y].pb(x / y);
		}
		int ans = 0;
		for (vector<int> a: as) {
			if (a.empty()) continue;
			int M = 0;
			for (int x: a) M += x;
			vector<int> dp(M + 1, -INF);
			dp[0] = 0;
			for (int x: a)
				for (int S = M / x * x; S >= x; S -= x)
					dp[S] = max(dp[S], dp[S - x] + 1);
			for (int S = 1; S <= M; S *= 2)
				ans = max(ans, dp[S]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3696
#include <stdio.h>
int main(void){
    while(1){
 int n,i;
 scanf("%d",&n);
 if(n==0){
     break;
 }
 int c[2]={n,n},s,b;
 int k[201][2]={};
 for(i=0;i<=2*n;i++){
     k[i][1]=1;
 }
 for(i=0;i<n;i++){
     int x;
     scanf("%d",&x);
     k[x][0]=1;
     k[x][1]=0;
 }
 b=0;
 s=0;
 for(;c[0]&&c[1];){
     for(s++;s<=2*n;s++){
         if(k[s][b]==1){
             c[b]--;
             k[s][b]=0;
             break;
         }
     }
     s=s%(2*n+1);
     b=(b+1)%2;
 }
 printf("%d\n%d\n",c[1],c[0]);
    }
}

Measured memory_bytes: 2600
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<map>
#include<queue>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};



//#define int ll
signed main(){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    cout<<a*b<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(h)]

dp = [[0 for _ in range(w)] for _ in range(h)]

for i in range(h):
    for j in range(w):
        if c[i][j]:
            dp[i][j] = 0
        else:
            dp[i][j] = 1

for i in range(h):
    for j in range(w):
        if c[i][j] == 1:
            dp[i][j] = 0
        elif i > 0 and j > 0:
            dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1

ans = 0
for i in range(h):
    ans = max(ans, max(dp[i]))
print(ans ** 2)


Measured memory_bytes: 55828
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    string s;
    cin>>s;
    string t = "";
    for(ll i=0;i<s.size();++i){
        t += s[s.size()-i-1];
    }
    
    string ans = "YES";
    ll sum = 0;
    while(t.size() > sum){
        string a = t.substr(sum, 7);
        string b = t.substr(sum, 6);
        string c = t.substr(sum, 5);
        if(a == "remaerd"){
            sum += 7;
        }else if(b == "resare"){
            sum += 6;
        }else if(c == "maerd" or c == "esare"){
            sum += 5;
        }else{
            ans = "NO";
            break;
        }
        
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 640
//#pragma GCC optimize("-O3")
/*
				C++
				encoding: UTF-8
				Last Modified: 03/May/20 06:40:21 PM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define		int                    long long
#define		ve                     vector
#define		pb                     push_back
#define		endl                   "\n"
#define		ff                     first
#define		ss                     second
#define		pii                    pair<int, int>
#define		len(v)                 (int)v.size()
#define		all(v)                 v.begin(), v.end()
#define		reset(a, b)            memset(a, b, sizeof(a));
#define		fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define		dfr(i, s, n)           for (int i = s ; i > n ; --i)

template < typename T > void pr (const T& t) {
    cout << t << "\n";
}

template < typename T, typename U, typename... ARGS >
void pr (const T& t, const U& u, const ARGS&... args) {
    cout << t << " ";
    pr (u, args...);
}

// clang-format on

map< pair< string, int >, pair< bool, char > > mp;
int n;
ve< string > arr;

bool solve (int i, int a, int b, int c) {
	if (a < 0 or b < 0 or c < 0) return 0;
	if (i == n) return 1;

	string x = to_string (a) + to_string (b) + to_string (c);

	if (mp.find ({x, i}) != mp.end ()) return mp[{x, i}].ff;
	bool ans = 0;
	char d = 'A';
	if (arr[i] == "AB") {
		ans = solve (i + 1, a - 1, b + 1, c);
		if (ans) {
			d = 'B';
		} else {
			ans = solve (i + 1, a + 1, b - 1, c);
			if (ans) {
				d = 'A';
			}
		}

	} else if (arr[i] == "AC") {
		ans = solve (i + 1, a - 1, b, c + 1);
		if (ans) {
			d = 'C';
		} else {
			ans = solve (i + 1, a + 1, b, c - 1);
			if (ans) {
				d = 'A';
			}
		}

	} else {
		ans = solve (i + 1, a, b - 1, c + 1);
		if (ans) {
			d = 'C';

		} else {
			ans = solve (i + 1, a, b + 1, c - 1);
			if (ans) {
				d = 'B';
			}
		}
	}
	mp[{x, i}] = {ans, d};

	return ans;
}

signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	int a, b, c;
	cin >> n >> a >> b >> c;
	arr.resize (n);
	fr (i, 0, n) cin >> arr[i];
	bool ans = solve (0, a, b, c);
	if (!ans) {
		pr ("No");
		return 0;
	}
	pr ("Yes");
	fr (i, 0, n) {
		string x = to_string (a) + to_string (b) + to_string (c);
		if (arr[i] == "AB" and mp[{x, i}].ss == 'A') { // a added and b subtracted
			pr ('A');
			a++;
			b--;
		} else if (arr[i] == "AB" and mp[{x, i}].ss == 'B') {
			pr ('B');
			b++;
			a--;
		} else if (arr[i] == "AC" and mp[{x, i}].ss == 'A') {
			pr ('A');
			a++;
			c--;
		} else if (arr[i] == "AC" and mp[{x, i}].ss == 'C') {
			pr ('C');
			a--;
			c++;
		} else if (arr[i] == "BC" and mp[{x, i}].ss == 'B') {
			pr ('B');
			b++;
			c--;
		} else {
			pr ('C');
			c++;
			b--;
		}
	}
	return 0;
}

Measured memory_bytes: 51832
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

const long long MOD = 998244353;

struct GCDInfo {
    long long x;
    long long y;
    long long g;
    GCDInfo(long long px, long long py, long long pg) : x(px), y(py), g(pg) {
    }
};

GCDInfo gcd(long long a, long long b) {
    if (b == 0) {
        return GCDInfo(1, 0, a);
    }

    // ax+by = g
    // bx'+(a-a/b*b)y' = g
    GCDInfo v = gcd(b, a%b);
    return GCDInfo(v.y, v.x-(a/b)*v.y, v.g);
}

// Get a * x mod p = 1
long long findInv(long long a, long long p) {
    return gcd(a, p).x;
}

long long mpow(long long b, int p) {
    if (p == 0) {
        return 1;
    }

    if (p == 1) {
        return b%MOD;
    }

    long long half = mpow(b, p/2);
    long long ret = half*half%MOD;

    if (p%2 == 1) {
        ret *= b;
        ret %= MOD;
    }

    return ret;
}

int main() {
    int N;
    int M;
    int K;

    cin >> N >> M >> K;
    long long ans = 0;

    long long comb = 1;
    for (int i = 0; i <= K; ++i) {
        int p = N-i-1; // K <= N-1, p >= 0

        ans += M * mpow(M-1, p) % MOD * comb;
        ans %= MOD;
        //cout << "DEBUG " << ans << " " << comb << endl;

        comb *= (N-i-1);
        comb %= MOD;
        // comb *= pow(i+1, MOD-2);
        comb *= findInv(i+1, MOD);
        comb %= MOD;
    }

    ans = (ans+MOD) % MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#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;
    string s;
    cin >> n >> s;
    int ans = 1;
    char c = s[0];
    rep(i,n){
        if(s[i] != c){
            c = s[i];
            ans++;
        } 
    }
    cout << ans << endl;
}

Measured memory_bytes: 3760
#include <stdio.h>

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

int main() {
    int a,b;

    scanf("%d %d", &a, &b);
    int result = gcd(a, b);

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

    return 0;
}

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

using namespace std;

using int64 = long long;

class UFSet {
 private:
  vector<int> ranks;
  vector<int> prevs;

 public:
  UFSet(int n) : ranks(n), prevs(n) {
    for (int i = 0; i < n; i++) prevs[i] = i;
  }

  // Returns a root of a tree which x belongs to.
  int Find(int x) {
    if (x != prevs[x]) prevs[x] = Find(prevs[x]);
    return prevs[x];
  }

  // Merges a set which x blongs to and a set which y belongs to.
  void Union(int x, int y) {
    int x_root = Find(x);
    int y_root = Find(y);
    if (ranks[x_root] > ranks[y_root]) {
      prevs[y_root] = prevs[x_root];
    } else if (ranks[x_root] < ranks[y_root]) {
      prevs[x_root] = prevs[y_root];
    } else if (prevs[x_root] != prevs[y_root]) {
      prevs[y_root] = prevs[x_root];
      ranks[x_root]++;
    }
  }
};

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

  int n, q;
  cin >> n >> q;
  UFSet uf_set(n);
  for (int i = 0; i < q; i++) {
    int c, x, y;
    cin >> c >> x >> y;
    if (c == 0) {
      uf_set.Union(x, y);
    } else {
      if (uf_set.Find(x) == uf_set.Find(y)) {
        cout << 1 << endl;
      } else {
        cout << 0 << endl;
      }
    }
  }
}


Measured memory_bytes: 3288
def LI(): return list(map(int, input().split()))

n = int(input())
h = LI()

dp = [0] * n
dp[0], dp[1] = 0, abs(h[1] - h[0])
for i in range(n-2):
    dp[i+2] = min(
        dp[i+1] + abs(h[i+2] - h[i+1]),
        dp[i] + abs(h[i+2] - h[i])
    )
    # print('i', i, '1step', abs(h[i+1] - h[i]), 'dp1', dp[i+1], '2step', abs(h[i+2] - h[i]), 'dp', dp[i], 'dp2', dp[i+2])

print(dp[-1])
# print(dp)


Measured memory_bytes: 13928
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
using P = pair<int, int>;
const int INF = 1LL << 60;

signed main(){

  int n; cin >> n;
  vector<P> v(n);
  for(int i = 0; i < n; i++){
    int x, l; cin >> x >> l;
    v[i] = {x - l, x + l};
  }
  sort(v.begin(),v.end(),[&](P x, P y){
    if(x.second == y.second) return x.first < y.first;
    return x.second < y.second;
  });

  int ans = 0, right = -INF;
  for(int i = 0; i < n; i++){
    if(right > v[i].first) continue;
    ans++;
    right = v[i].second;
  }
  cout << ans << endl;

  return 0;
}


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

//int a[110][110]

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> d(k);
  map<int,int> mp;
  for(int i=1;i<=n;++i){
    mp[i]++;
  }
  for(int i=0;i<k;++i){
    cin >> d[i];
    for(int j=0;j<d[i];++j){
      int a;
      cin >> a;
      mp[a]++;
    }
  }
  int ans=0;
  for(auto p : mp){
    if(p.second==1) ans++;
  }
  cout << ans << endl;

}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int a[N],cut[N],n,m;
pair<int,int>d[N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+m+1);
	for(int i=1;i<m;i++)
		d[i]=make_pair(a[i+1]-a[i],i);
	sort(d+1,d+m);
	reverse(d+1,d+m);
	for(int i=1;i<n&&i<m;i++)
		cut[d[i].second]=1;
	int sum=0,last=a[1];
	for(int i=1;i<=m;i++)
	{
		if(cut[i])
		{
			sum+=a[i]-last;
			last=a[i+1];
		}
	}
	printf("%d\n",sum+a[m]-last);
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

bool Simulation(char line[][15], int start, int goal, int m)
{
	int pos = start;
	
	for (int i = 0; i < m; i++){
		if (line[i][pos] == '1'){
			pos++;
		}
		else if (line[i][pos - 1] == '1'){
			pos--;
		}
	}
	return (pos == goal);
}

int main(void)
{
	int n, m;
	int start;
	int goal;
	char line[30][15];
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		scanf("%d", &start);
		scanf("%d", &goal);
		scanf("%d", &m);
		
		for (int i = 0; i < m; i++){
			scanf("%s", line[i] + 1);
			line[i][0] = '0';
			line[i][n] = '0';
		}
		
		if (Simulation(line, start, goal, m) == true){
			puts("0");
			continue;
		}
		
		bool flag = false;
		for (int i = 0; i < m; i++){
			for (int j = 1; j < n; j++){
				if (line[i][j - 1] == '0' && line[i][j + 1] == '0' && line[i][j] == '0'){
					line[i][j] = '1';
					if (Simulation(line, start, goal, m) == true){
						printf("%d %d\n", i + 1, j);
						flag = true;
						break;
					}
					line[i][j] = '0';
				}
			}
			if (flag == true){
				break;
			}
		}
		
		if (flag == false){
			puts("1");
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
#define lo long
const long long lmax=1999999999;
const long long lmx=1999999999999999999;
long long n;
vector<long long>v[100003];
long long dp[100003][2];
void go(long long sad,long long par){
	for(long long i=0;i<v[sad].size();i++){
		long long to=v[sad][i];
		if(to==par)continue;
		go(to,sad);
	}
	dp[sad][0]=1;
	dp[sad][1]=1;
	for(long long i=0;i<v[sad].size();i++){
		long long to=v[sad][i];
		if(to==par)continue;
		dp[sad][1]=dp[sad][1]*dp[to][0]%1000000007;
		dp[sad][0]=dp[sad][0]*(dp[to][1]+dp[to][0])%1000000007;



		dp[sad][0]%=1000000007;
		dp[sad][0]%=1000000007;
		
		
	}
}
int main(){std::ios::sync_with_stdio(false);
cin>>n;
for(long long i=0;i<n-1;i++){
	long long x,y;
	cin>>x>>y;
	v[x].push_back(y);
	v[y].push_back(x);
}
go(1,0);
//	cout<<dp[1][0]<<" "<<dp[1][1]<<endl;
cout<<(dp[1][0]+dp[1][1])%1000000007<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





Measured memory_bytes: 12800
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAX = 1e5+5;
int A, B, M, a[MAX], b[MAX];
int main() {
  scanf("%d %d %d", &A, &B, &M);
  int amin = MAX, bmin = MAX;
  for(int i = 1; i <= A; ++i) scanf("%d", &a[i]), amin = min(amin, a[i]);
  for(int i = 1; i <= B; ++i) scanf("%d", &b[i]), bmin = min(bmin, b[i]);
  int summin = amin+bmin;
  for(int i = 1, x, y, c; i <= M; ++i) {
    scanf("%d %d %d", &x, &y, &c);
    summin = min(summin, a[x]+b[y]-c);
  }
  printf("%d\n", summin);
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vz;
typedef vector<vz> vvz;
typedef pair<ll, ll> pll;
#define sz(x) ll((x).size())
#define fo(i,n) for(ll i=0; i<(n); i++)
#define FO(i,a,b) for(ll i=(a); i!=(b); i+=(b)>(a)?1:-1)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(c) c.begin(), c.end()
#define F first
#define S second
#define os(x) cout<<x<<' '
#define on(x) cout<<x<<"\n"
#define nl cout<<"\n"
#define maxe(x) max_element(all(x))-(x).begin()
#define mine(x) min_element(all(x))-(x).begin()
const ll P=1e9+7;

ll gcd(ll a, ll b)
{
	ll m=min(a, b), M=max(a, b);
	if(m==0) return M;
	return gcd(m, M%m);
}

ll powmod(ll x, ll y)
{
	ll ans=1;
	while(y>0)
	{
		if(y%2) ans=(ans*x)%P;

		x=(x*x)%P;
		y/=2;
	}
	return ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\input1.txt", "r", stdin);
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\output1.txt", "w", stdout);
#endif

	int n;
	cin>>n;
	vector<pair<int, int>> a(n);
	fo(i, n){
		cin>>a[i].F>>a[i].S;
	}
	fo(i, n-2){
		if(a[i].F==a[i].S && a[i+1].F==a[i+1].S && a[i+2].F==a[i+2].S){
			on("Yes");
			return 0;
		}
	}
	on("No");
	cerr << "Time : " << ((double)clock()) / (double)CLOCKS_PER_SEC << "s\n";
	return 0;
}

Measured memory_bytes: 3760
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
//<< setprecision(5)
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<-1<<endl;return 0
const int mod=1000000007;
const llint big=1e9+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	int n,i;cin>>n;
	static int aizu[200300]={0};
	for(i=0;i<n;i++){
		int a,b;cin>>a>>b;
		aizu[a+b]++;
	}
	for(i=0;i<200279;i++){
		aizu[i+1]+=aizu[i]/2;
		aizu[i]%=2;
		if(aizu[i]==1){cout<<i<<" 0"<<endl;}
	}
	return 0;

}

Measured memory_bytes: 3860
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int MAXN = 524300;
const int mo = 924844033;
const int g = 5;

int N,L;
LL a[MAXN],b[MAXN],mi[MAXN];
int n;
LL cnt[MAXN];
LL inv[MAXN],js[MAXN];
struct edge{
	int x,nxt;
}e[MAXN];
int h[MAXN],tot;
int bitr[MAXN];
int siz[MAXN];
LL ny;

LL quickmi(LL x,LL tim){LL ans=1;x%=mo;for(;tim;tim/=2,x=x*x%mo)if (tim&1)ans=ans*x%mo;return ans;}

void inse(int x,int y){e[++tot].x=y;e[tot].nxt=h[x];h[x]=tot;}

void prepare(){
	inv[0]=inv[1]=1;
	fo(i,2,n)inv[i]=1ll*(mo-mo/i)*inv[mo%i]%mo;
	fo(i,1,n)inv[i]=1ll*inv[i]*inv[i-1]%mo;
	js[0]=js[1]=1;
	fo(i,1,n)js[i]=js[i-1]*i%mo;
	N=1,L=0;
	while(N<=n*2)N<<=1,L++;
	fo(i,0,N-1){
		bitr[i]=0;
		fo(j,0,L-1)
		if (((1<<j)&i)>0)bitr[i]+=(1<<(L-1-j));
	}
	LL G=quickmi(g,(mo-1)/N);
	mi[0]=1;
	fo(i,1,N)mi[i]=mi[i-1]*G%mo;
	ny=quickmi(N,mo-2);
}

void dfs(int x){
	siz[x]=1;
	for(int p=h[x];p;p=e[p].nxt)
	if (!siz[e[p].x]){
		dfs(e[p].x);
		siz[x]+=siz[e[p].x];
	}
	if (x>1){
		cnt[siz[x]]++;
		cnt[n-siz[x]]++;
	}
}

LL calc(int n,int m){return 1ll*js[n]*inv[m]%mo*inv[n-m]%mo;}

LL add(LL x,LL y){return x+y>=mo?x+y-mo:x+y;}

LL dec(LL x,LL y){return x>=y?x-y:x+mo-y;}

void DFT(LL *a){
	fo(i,0,N-1)
	if (i<bitr[i])swap(a[i],a[bitr[i]]);
	for(int now=2;now<=N;now<<=1){
		int half=now/2;
		fo(i,0,half-1){
			LL w=mi[N/now*i];
			for(int j=i;j<N;j+=now){
				LL l=a[j],r=w*a[j+half]%mo;
				a[j]=add(l,r);
				a[j+half]=dec(l,r);
			}
		}
	}
}

void IDFT(LL *a){
	fo(i,0,N-1)
	if (i<bitr[i])swap(a[i],a[bitr[i]]);
	for(int now=2;now<=N;now<<=1){
		int half=now/2;
		fo(i,0,half-1){
			LL w=mi[N-N/now*i];
			for(int j=i;j<N;j+=now){
				LL l=a[j],r=w*a[j+half]%mo;
				a[j]=add(l,r);
				a[j+half]=dec(l,r);
			}
		}
	}
	fo(i,0,N-1)a[i]=ny*a[i]%mo;
}

void ntt(LL *a,LL *b){
	DFT(a);DFT(b);
	fo(i,0,N-1)a[i]=1ll*a[i]*b[i]%mo;
	IDFT(a);
}

int main(){
	n=get();
	fo(i,2,n){
		int x=get(),y=get();
		inse(x,y),inse(y,x);
	}
	prepare();
	dfs(1);
	fo(i,0,n)a[n-i]=1ll*cnt[i]*js[i]%mo;
	fo(i,0,n)b[i]=inv[i];
	ntt(a,b);
	fo(i,0,n/2)swap(a[i],a[n-i]);
	fo(i,1,n){
		LL v=1ll*a[i]*inv[i]%mo;
		v=(1ll*calc(n,i)*n%mo+mo-v)%mo;
		printf("%lld\n",v);
	}
	return 0;
}

Measured memory_bytes: 34944
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//char str_1[100002],str_2[100002];
int cmp(const void *a,const void *b)
{
    return strcmp((char*)a,(char*)b);
}
int main()
{
    int len_1,len_2,i,j,count,k,flag,n;//count记录连续的问号数
    char str_T[101],str_S[101],result[101][101];
    scanf("%s",str_S);
    scanf("%s",str_T);
    count=0;
    flag=n=0;
    len_1=strlen(str_S);
    len_2=strlen(str_T);
    if(len_1<len_2)
    {
        printf("UNRESTORABLE\n");
        return 0;
    }
    else
    {
        for(i=len_1-1; i>=0; i--)
        {
            /*if(str_S[i]=='?')
                count++;
            else count=0;
            if(count==len_2)
            {
                strcpy(result[n],str_S);
                for(j=i,k=0; j<len_1; j++)
                {
                    result[n][j]=str_T[k];
                    k++;
                }
                for(j=0; j<len_1; j++)
                {
                    if(result[n][j]=='?')
                        result[n][j]='a';
                }
                n++;
                flag=1;
            }*/
            if(str_S[i]=='?'||str_S[i]==str_T[len_2-1])
            {
                k=i;
                for(j=len_2-1; j>=0; j--)
                {
                    if(str_T[j]==str_S[k]||str_S[k]=='?')
                    {
                        k--;
                    }
                    else
                    {
                        break;
                    }
                }
                if(k==i-len_2)
                {
                    k=i;
                    strcpy(result[n],str_S);
                    for(j=len_2-1; j>=0; j--,k--)
                    {
                        result[n][k]=str_T[j];
                    }
                    for(j=0; j<len_1; j++)
                    {
                        if(result[n][j]=='?')
                            result[n][j]='a';
                    }
                    flag=1;
                    n++;
                }
            }
        }
    }
    if(flag==1)
    {
        qsort(result,n,101*sizeof(char),cmp);
        printf("%s\n",result[0]);
    }
    else printf("UNRESTORABLE\n");
    return 0;
}



Measured memory_bytes: 128
# https://atcoder.jp/contests/abc073/tasks/abc073_d

from itertools import permutations
from collections import defaultdict

N, M, R = map(int, input().split())
G = defaultdict(list)
d =[ [float("inf")] * N for i in range(N)]
listR = list(map(int, input().split()))
for _ in range(M):
    ai, bi, ci = map(int, input().split())
    ai, bi = ai - 1, bi - 1
    G[ai].append((bi, ci))
    G[bi].append((ai, ci))
    d[ai][bi] = d[bi][ai] = ci

# わーしゃるふろいど
for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j],d[i][k] + d[k][j])

# print(d)

# 全てのpermutations (of R)を試す
ans = float("inf")
for perm in permutations(listR):
    cost_perm = 0
    for i in range(len(perm) - 1):
        pi, pj = perm[i] - 1, perm[i + 1] - 1
        cost_perm += d[pi][pj]
    ans = min(ans, cost_perm)
print(ans)

Measured memory_bytes: 77196
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] L = new int[N];
        for(int i = 0; i < N; i++){
            L[i] = sc.nextInt();
        }
        Arrays.sort(L);
        long result = 0;
        for(int i = N - 1; i > 1; i--){
            int firstIndex = 0;
            int lastIndex = i - 1;
            while(lastIndex - firstIndex > 0){
                if(L[firstIndex] + L[lastIndex] <= L[i]){
                    firstIndex++;
                }else{
                    result += lastIndex - firstIndex;
                    lastIndex--;
                }
            }
        }
        System.out.println(result);
    }
}



Measured memory_bytes: 25860
#include <iostream>
 
using namespace std;
 
int main()
{
    int w, h, n, ox = 0, oy = 0;
    cin >> w >> h >> n;
 
    for (int i = 0; i < n; ++i) {
        int x, y, a;
        cin >> x >> y >> a;
 
        if (a == 1) ox = max(ox, x);
        if (a == 2) w = min(w, x);
        if (a == 3) oy = max(oy, y);
        if (a == 4) h = min(h, y);
    }
    cout << ((w > ox) && (h > oy) ? (w - ox) * (h - oy) : 0) << endl;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    from bisect import bisect_left, bisect_right


    W, H = map(int, input().split())
    P = [int(input()) for _ in range(W)]
    P.sort()

    Q = [int(input()) for _ in range(H)]
    Q.sort()

    ans = 0
    for q in Q:
        tmp = bisect_right(P, q)
        # print ('tmp=', tmp)
        ans += q * (1 + W - tmp)
        # print (ans)

    for p in P:
        tmp = bisect_left(Q, p)
        ans += p * (1 + H - tmp)

    print (ans)
    # print ('P:', P)
    # print ('Q:', Q)

if __name__ == '__main__':
    main()

Measured memory_bytes: 11592
#include <cstdio>
#include <vector>
#include <algorithm>

static const int di[]={-1, 0, 1, 0};
static const int dj[]={0, -1, 0, 1};

int count(std::vector<std::vector<int> > &p, int i=0, int j=0) {
  int res=1;
  const int H=p.size(), W=p[0].size();
  int orig=p[i][j];
  p[i][j] = 0;
  for (int k=0; k<4; ++k) {
    int ni=i+di[k], nj=j+dj[k];
    if (!(0 <= ni && ni < H && 0 <= nj && nj < W))
      continue;

    if (p[ni][nj] == orig)
      res += count(p, ni, nj);
  }

  return res;
}

void fill(std::vector<std::vector<int> > &p, int c, int i=0, int j=0) {
  const int H=p.size(), W=p[0].size();

  int orig=p[i][j];
  p[i][j] = c;

  for (int k=0; k<4; ++k) {
    int ni=i+di[k], nj=j+dj[k];
    if (!(0 <= ni && ni < H && 0 <= nj && nj < W)) 
      continue;

    if (p[ni][nj] == orig && p[ni][nj] != c)
      fill(p, c, ni, nj);
  }
}

int rec(std::vector<std::vector<int> > p, int c, int n=0) {
  if (n == 4) {
    fill(p, c);
    return count(p);
  }

  int res=0;
  for (int i=1; i<=6; ++i) {
    if (p[0][0] == i) continue;

    std::vector<std::vector<int> > q=p;
    fill(q, i);
    res = std::max(res, rec(q, c, n+1));
  }

  return res;
}

int solve_testcase() {
  int h, w, c;
  scanf("%d %d %d", &h, &w, &c);
  if (h == 0 && w == 0 && c == 0)
    return 1;

  std::vector<std::vector<int> > p(h, std::vector<int>(w));
  for (int i=0; i<h; ++i)
    for (int j=0; j<w; ++j)
      scanf("%d", &p[i][j]);

  printf("%d\n", rec(p, c));
  return 0;
}

int main() {
  while (!solve_testcase());

  return 0;
}

Measured memory_bytes: 2736
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int N;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;

  int ans = 1;
  while (ans <= N) {
    ans *= 2;
  }
  ans /= 2;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        int a =(int) Math.Sqrt(int.Parse(Console.ReadLine()));
        Console.WriteLine(a*a);
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        for (long i = 2; i < n; i++) { if (n % i == 0) return false; }
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back
 
void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
void No(){cout<<"NO"<<endl;exit(0);}
void Yes(){cout<<"YES"<<endl;exit(0);}
 
typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[0] << c[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000
 
typedef struct node * Node;
#define NIL NULL

int main(){
	int i,j,n;
	int A[MAX+1];
	scanf("%d",&n);
	for(i=1; i<n+1; i++){
		scanf("%d",&A[i]);
	}
	for(i=1;i<n+1;i++){
		printf("node %d: key = %d, ",i,A[i]);
		if(i>1)printf("parent key = %d, ",A[i/2]);
		if(i*2<n+1)printf("left key = %d, ",A[i*2]);
		if(i*2+1<n+1)printf("right key = %d, ",A[i*2+1]);
		printf("\n");
	}
}


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


int main(){
    int A,B;
    cin >> A >> B;
    int flag = 0;
    int ta,tb,ans;
    for (int i = 0;i < 2000;i++){
        ta = i * 0.08;
        tb = i * 0.1;
        if (A == ta && B == tb){
            flag = 1;
            ans = i;
            break;
        }
    }
    if (flag == 0) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,ans=1e9,a[2][N];
char s[N];
int zh(int x,int l,int r)
{
	if(l>r)
		return 0;
	return a[x][r]-a[x][l-1];
}
int main()
{
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n;i++)
	{
		int x=s[i]=='W';
		a[0][i]=a[0][i-1],a[1][i]=a[1][i-1];
		a[x][i]++;
	}
	for(int i=0;i<=n;i++)
	{
		int v1=zh(1,1,i),v2=zh(0,i+1,n);
		ans=min(ans,max(v1,v2));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5580
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] ryuka = new long[N	+1];
		ryuka[0] = 2;
		ryuka[1] = 1;
		for (int i = 2; i <= N; i++) {
			ryuka[i] = ryuka[i - 1] + ryuka[i - 2];
		}
		System.out.print(ryuka[N]);
	}
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	while (N) {
		if (N % 10 == 7) {
			cout << "Yes" << "\n";
			return 0;
		}
		N /= 10;
	}
	cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 3640
main(require("fs").readFileSync("/dev/stdin", "utf8").replace(/\r?\n$/, "").split(/\r?\n/));

function main(lines){
	var list = [];
	for(var i=0;i<4;i++) for(var j=1;j<=13;j++){
		list.push("SHCD"[i]+" "+j);
	}
	lines.slice(1).forEach(function(line){
		list.splice(list.indexOf(line), 1);
	});
	if(list.length) console.log(list.join("\n"));
}

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

long long cnt;
int n;
int A[1000000];
vector<int> G;

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

}

void shellSort(int A[], int n) {
	for (int i = 1; ;) {
		if (i <= n) {
			G.push_back(i);
		}
		else {
			break;
		}
		i = 3 * i + 1;
	}
	for (int i = G.size() - 1; i >= 0; i--) {
		insertionSort(A, n, G[i]);
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	cnt = 0;
	shellSort(A, n);
	cout << G.size() << endl;
	for (int i = G.size() - 1; i >= 0; i--) {
		cout << G[i];
		if (i > 0) {
			cout << " ";
		}
	}
	cout << endl;
	cout << cnt << endl;
	for (int i = 0; i < n; i++) {
		cout << A[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 7052
#include <stdio.h>
#include <stdlib.h>
int main(){
	int N;
	
	int x[111], y[111], h[111];
	int H=0;
	int i,j,k;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d %d %d",&x[i],&y[i],&h[i]);
	}
	for(i=0;i<=100;i++){
		for(j=0;j<=100;j++){
			int f=1;
			int flag=0;
			for(k=0;k<N;k++){
				if(h[k]!=0){
					if(flag==0){
						H = h[k] + abs(x[k] - i) + abs(y[k] - j);
						flag = 1;
					}else{
						if(H!= h[k]+abs(x[k]-i)+abs(y[k]-j)){
							flag=2;
							break;
						}
					}
				}
			}
			for(k=0;k<N;k++){
				if(h[k]==0){
					if(h[k]<H-abs(x[k]-i)-abs(y[k]-j)){
						flag=2;
					}
				}
			}
			if(flag==1){
				printf("%d %d %d",i,j,H);
				return 0;
			}
		}
	}
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

ll fastpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  vector<ll> nums(15);
  for (ll i = 0; i < nums.size(); i++) {
    nums[i] = -1;
  }
  nums[0] = 1;

  for (ll i = 0; i < N - 1; i++) {
    // +1
    for (ll j = 0; j < nums.size(); j++) {
      if (nums[j + 1] == -1 || nums[j] <= nums[j + 1]) {
        if (nums[j] == -1) {
          nums[j] = 1;
        } else {
          nums[j] += 1;
        }
        if (nums[j] <= 9) {
          break;
        }
      } else {
        nums[j] = 10;
      }
    }
    // adjust
    for (int i = nums.size() - 2; i >= 0; i--) {
      if (nums[i] == 10) {
        if (nums[i + 1] >= 1) {
          nums[i] = nums[i + 1] - 1;
        } else {
          nums[i] = 0;
        }
      }
    }
  }

  ll ans = 0;
  for (ll i = 0; i < nums.size(); i++) {
    if (nums[i] == -1) {
      break;
    }
    ll plus = nums[i] * fastpow(10LL, i, MOD);
    ans += plus;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

if B == 1:
	print(0)
	exit()

ins = 1
for i in range(B):
	ins = ins + A - 1
	if ins >= B:
		print(i + 1)
		exit()

Measured memory_bytes: 5196
/*input
0101
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
    out<<'('<<P.F<<','<<P.S<<')';
    return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        
        b>>=1;
    }
    return res;
}

int main(){
    IOS;
    string s;
    cin>>s;
    REP(i,SZ(s)-1){
        if(s[i]==s[i+1]){
            cout<<"Bad\n";
            return 0;
        }
    }
    cout<<"Good\n";
    return 0;
}


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

using namespace std;

int main() {
	string S;
	cin >> S;
	if ((S[2]==S[3])&&(S[4]==S[5])) {
		cout << "Yes"<< endl;
	}
	else{
		cout <<"No"<<endl;
	}

	return 0;
}

Measured memory_bytes: 3608
A = []
b = []

row, col = (int(x) for x in input().split())

for i in range(row):
    A.append([int(x) for x in input().split()])

for i in range(col):
    b.append(int(input()))

for i in range(row):
    print(sum(A[i][j]*b[j] for j in range(col)))

Measured memory_bytes: 8036
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  std::cin.tie(nullptr); std::ios::sync_with_stdio(false);
  int N;
  std::cin >> N;
  std::cout << (N / 100 == N % 10 ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 256