akhauriyash/Code-Regression huggingface dataset:
class Trie:
    class Node:
        def __init__(self,c):
            self.c=c
            self.next_c_id={}
            #self.common=0
            self.end=-1

    def __init__(self):
        self.trie=[self.Node('')]
    
    def add(self,id,s):
        i=0
        now=0
        ary=[0]
        while i<len(s) and s[i] in self.trie[now].next_c_id:
            now=self.trie[now].next_c_id[s[i]]
            ary.append(now)
            #self.trie[now].common+=1
            i+=1
        while i<len(s):
            self.trie[now].next_c_id[s[i]]=len(self.trie)
            now=len(self.trie)
            ary.append(now)
            self.trie.append(self.Node(s[i]))
            #self.trie[now].common+=1
            i+=1
        self.trie[now].end=id
        return ary

def main(s):
    tr=Trie()
    s.sort(key=lambda x:len(x))
    ans=0
    for i,x in enumerate(s):
        ary=tr.add(i,x)
        seen=set(())
        while ary:
            id=ary.pop()
            for nv in seen&tr.trie[id].next_c_id.keys():
                if tr.trie[tr.trie[id].next_c_id[nv]].end>=0 and tr.trie[tr.trie[id].next_c_id[nv]].end!=i:
                    ans+=1
            seen.add(tr.trie[id].c)
    print(ans)

if __name__=='__main__':
    a2n=lambda x:ord(x)-ord('a')
    n=int(input())
    s=[list(map(a2n,list(input()))) for _ in range(n)]
    [x.reverse() for x in s]
    main(s)


Measured memory_bytes: 486096
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
sa = sum(A)
sb = sum(B)
if sa>sb:
    print("No")
else:
    d1 = 0
    d2 = 0
    for i in range(N):
        if A[i]>B[i]:
            d1 += A[i]-B[i]
        elif B[i]>A[i]:
            d2 += (B[i]-A[i])//2
    if d2>=d1:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 68384
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    int ans=1e5;
    for(int i=0;i<s.length()-t.length()+1;i++){
        int tmp=0;
        for(int j=0;j<t.length();j++)if(s[i+j]!=t[j])tmp++;
        ans=min(tmp,ans);
    }
    cout << ans;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> a(n+1);
    vector<int> vis(n+1,0);
    for(int i=1;i<=n;i++) cin>>a[i];
    int button=1;
    int c=1;
    while(vis[button]==0)
    {
        vis[button]=c;
        c++;
        button=a[button];
    }
    cout<<vis[2]-1;
    return 0;
}

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

int main(){
    int l, k;
    cin>>l>>k;
    LL ans=0;
    for(int n=0; 1+n*2<=l; n++){
        int m = (l-1-2*n) / (k+1);
        rep(i, m+1){
            LL tmp=1;
            rep(j, i){
                tmp *= n+i-j;
                tmp /= j+1;
            }
            ans += tmp;
        }
    }
    for(int n=0; k+n*2<=l; n++){
        int m = (l-k-2*n) / (k+1);
        rep(i, m+1){
            LL tmp=1;
            rep(j, i){
                tmp *= n+i-j;
                tmp /= j+1;
            }
            ans += tmp;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <stack>
#include <queue>

typedef long long ll;
using namespace std;

int main(){
  ll i,j,k,n,a,b,cnt,cntb;
  cin >> a >> b;
  ll ret = 0;
  /*for(i=50;i>0;i--){
    cnt=max(0,min(a,(1<<i))-(1<<(i-1)));
    if(a&(1<<(i-1)))a-=1<<(i-1);
    cntb = max(0,min(b,(1<<i))-(1<<(i-1)));
    if(b&(1<<(i-1)))b-=1<<(i-1);
    if(cntb-)
  }*/
  /*for(i=1;i<50;i++){
    cntb=(b+(1<<i)-1)/(1<<i)*(1<<(i-1));
    cnt=(a-1+(1<<i)-1)/(1<<i)*(1<<(i-1));
    if((cntb-cnt)%2)ret+=1<<(i-1);
  }*/
  b++;
  for(i=0;i<50;i++){
    ll x=0,y=0;
    cntb = b/(1ll<<i);
    if(cntb%2==1)x+=b%(1ll<<i);
    x+=cntb/2*(1ll<<i);

    cnt = a/(1ll<<i);
    if(cnt%2==1)y+=a%(1ll<<i);
    y+=cnt/2*(1ll<<i);
    //cout << x << " " << y << endl;
    if((x-y)%2==1)ret+=1ll<<i;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>

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

using namespace std;

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

bool memo[55][55];
int d[55][55];

bool can(int y,int x) {
    if(0 <= y && y < h && 0 <= x && x < w) return true;
    return false;
}

void dfs(int y,int x) {
    if(memo[y][x]) return;
    memo[y][x] = true;
    
    rep(i,8) {
        int ny = y + dy[i];
        int nx = x + dx[i];
        
        if(can(ny,nx) && d[ny][nx] == 1) {
            dfs(ny,nx);
        }
    }
}


int main()
{
    while(cin >> w >> h)
    {
        if(w == 0 && h == 0) break;
        
        memset(d,0,sizeof(d));
        memset(memo,0,sizeof(memo));

        rep(i,h) {
            rep(j,w) {
                cin >> d[i][j];
            }
        }
        
        int ans = 0;
        rep(i,h) {
            rep(j,w) {
                if(!memo[i][j] && d[i][j] == 1) {
                    ans++;
                    dfs(i,j);
                }
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
long long n;
vector <long long> v;
vector <long long> dp;

long long f(long long i) {
	if (i == n-2) {dp[n-2]=abs(v[i]-v[i+1]); return dp[n-2];}
	if (i == n-3) {dp[n-3]=abs(v[i]-v[i+1]); return dp[n-3];}
	dp[i] = min (abs(v[i]-v[i+1])+dp[i+1],abs(v[i]-v[i+2])+dp[i+2]);
	return dp[i];
}

int main () {
  cin >> n;
  long long l = n;
  long long ans [n]= {};
  while (l--) {
    long long x;
    cin >> x;
    v.push_back(x);
    dp.push_back(-1);
    ans[l] = -1;
  }
  
  ans [v.size()-2] = abs(v[v.size()-2]-v[v.size()-1]);
  if (n > 2)ans [v.size()-3] = abs(v[v.size()-1]-v[v.size()-3]);
  
  for (int i = v.size()-4;i >= 0;i--)ans[i] = min (ans[i+1]+abs(v[i]-v[i+1]),ans[i+2]+abs(v[i]-v[i+2]));
  
  cout << ans[0];
  return 0;
}

Measured memory_bytes: 5796
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int n,q,tot;
int head[200005],fa[200005],ans[200005];
struct node{
	int to,net;
}e[400005];
void add(int x,int y){
	e[++tot].to=y;
	e[tot].net =head[x];
	head[x]=tot; 
} 
int a[200005];
void dfs(int x,int last){
	for(int i=head[x];i;i=e[i].net ){
		int to=e[i].to ;
		if(to==last) continue;
		fa[to]=x;
		ans[to]+=ans[x];
		dfs(to,x);
	}
}  
int main(){
	scanf("%d%d",&n,&q);
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x); 
	}
	for(int i=1;i<=q;i++){
		int x,v;
		scanf("%d%d",&x,&v);
		ans[x]+=v;
	}
	dfs(1,0);
	for(int i=1;i<=n;i++) printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 17280
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

class UnionFind(n: Int) {
    private val rank = IntArray(n) { 0 }
    private val parent = IntArray(n) { -1 }

    fun find(x: Int): Int {
        if (parent[x] < 0) {
            return x
        }
        parent[x] = find(parent[x])
        return parent[x]
    }

    fun unite(x: Int, y: Int) {
        val x1 = find(x)
        val y1 = find(y)
        if (x1 == y1) {
            return
        }
        if (rank[x1] < rank[y1]) {
            parent[y1] += parent[x1]
            parent[x1] = y1
        } else {
            parent[x1] += parent[y1]
            parent[y1] = x1
            if (rank[x1] == rank[y1]) {
                rank[x1]++
            }
        }
    }

    fun same(x: Int, y: Int): Boolean {
        return find(x) == find(y)
    }

    fun size(x: Int): Int {
        return -parent[find(x)]
    }
}

fun PrintWriter.solve(sc: FastScanner) {
    val s = sc.nextLine()
    val t = sc.nextLine()
    val n = s.length
    val uf1 = UnionFind(n)
    val uf2 = UnionFind(n)
    for (i in 0 until 26) {
        val c = 'a' + i
        val lst1 = mutableListOf<Int>()
        val lst2 = mutableListOf<Int>()
        for (j in 0 until n) {
            if (s[j] == c) lst1.add(j)
            if (t[j] == c) lst2.add(j)
        }
        for (j in lst1) {
            uf1.unite(lst1[0], j)
        }
        for (j in lst2) {
            uf2.unite(lst2[0], j)
        }
    }
    val map1 = mutableMapOf<Int, MutableList<Int>>()
    val map2 = mutableMapOf<Int, MutableList<Int>>()
    for (i in 0 until n) {
        if (!map1.containsKey(uf1.find(i))) {
            map1[uf1.find(i)] = mutableListOf()
        }
        map1[uf1.find(i)]?.add(i)
        if (!map2.containsKey(uf2.find(i))) {
            map2[uf2.find(i)] = mutableListOf()
        }
        map2[uf2.find(i)]?.add(i)
    }
    val v1 = map1.values.sortedBy { it.first() }
    val v2 = map2.values.sortedBy { it.first() }
    if (v1.count() != v2.count()) {
        println("No")
        return
    }
    for (i in 0 until v1.count()) {
        val l1 = v1[i]
        val l2 = v2[i]
        val l3 = l1.union(l2)
        if (l3.count() != l1.count() || l3.count() != l2.count()) {
            println("No")
            return
        }
    }
    println("Yes")
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 75904
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>

constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;

using namespace std;
vector<int> a;
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int l;
	cin >> l;
	double ans = pow((double)l/3,(double)3);
	std::cout << std::fixed;
	std::cout << std::setprecision(6);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <math.h>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)
#define fill(x,t) memset(x,t,sizeof(x))

typedef long long LL;
const int MOD=1000000007;
const int N=200005;

int cnt[27],n;
LL rc[N],ans;

char str[N];

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):(v),ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

void dfs(int dep,LL xs,int c) {
	if (dep==26) {
		if (c==0) return ;
		ans=(ans+xs)%MOD;
		ans=(ans+MOD)%MOD;
		return ;
	}
	if (cnt[dep]) dfs(dep+1,xs*(cnt[dep])%MOD,c+1);
	dfs(dep+1,xs,c);
}

int main(void) {
	scanf("%d",&n); scanf("%s",str+1);
	rc[0]=1; rep(i,1,N-1) rc[i]=rc[i-1]*2LL%MOD;
	rep(i,1,n) cnt[str[i]-'a']++;
	dfs(0,1,0); ans=(ans%MOD+MOD)%MOD;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    string s, t;
    cin >> s >> t;

    int n = s.size();
    int m = t.size();

    int r = n;
    for (int i = 0; i <= n - m; i++) {
        int k = 0;
        for (int j = 0; j < m; j++) {
            k += s[i + j] != t[j];
        }
        r = min(r, k);
    }

    cout << r << endl;

    return 0;
}

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

int main(){
  int N;
  cin >>N;
  vector<int> a(N);
  for(int i=0;i<N;i++)
    cin >>a.at(i);
  sort(a.begin(),a.end());
  cout<<a.at(N-1)-a.at(0) <<endl;
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline().strip()

def main():
    n = int(input())
    A = list(map(int, input().split()))
    if 0 in A:
        print(0)
        return
    x = 1
    for i in A:
        x *= i
        if x > pow(10,18):
            print(-1)
            return
    print(x)

main()

Measured memory_bytes: 21656
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] maze = new char[h][w];
		int[][] distance = new int[h][w];
		Boolean[][] flag = new Boolean[h][w];
		int whiteCount = 0;
		
		for (int i = 0; i < h; i++) {
			String line = sc.next(); 
			for (int j = 0; j < w; j++) {
				char c = line.charAt(j);
				maze[i][j] = c;
				if (c == '.') {
					whiteCount++;
				}
			}
		}
	
		for (int i = 0; i < h; i++) {
			Arrays.fill(distance[i], Integer.MAX_VALUE);
		}
		
		for (int i = 0; i < h; i++) {
			Arrays.fill(flag[i], false);
		}
		
		Deque<Point> queue = new ArrayDeque<>();
		Point start = new Point(0, 0);
		flag[start.y][start.x] = true;
		distance[0][0] = 1;
		queue.addLast(start);
		int dx[] = {1, 0, -1, 0};
		int dy[] = {0, 1, 0, -1};
		
		while (!queue.isEmpty()) {
			Point p = queue.removeFirst();
			
			for (int i = 0; i < 4; i++) {
				int tmpX = p.x + dx[i];
				int tmpY = p.y + dy[i];
				if (tmpX >= 0 && tmpX < w && tmpY >= 0 && tmpY < h && flag[tmpY][tmpX] == false && maze[tmpY][tmpX] == '.') {
					flag[tmpY][tmpX] = true;
					queue.addLast(new Point(tmpX, tmpY));
					int tmpDistance = distance[p.y][p.x] + 1;
					if (distance[tmpY][tmpX] > tmpDistance) {
						distance[tmpY][tmpX] = tmpDistance;
					}
				}
			}
		}
		if (flag[h - 1][w - 1]) {
			System.out.println(whiteCount - distance[h - 1][w - 1]);
		} else {
			System.out.println(-1);
		}
	}
}

class Point {
	public int x, y;
	
	public Point(int x, int y) {
		this.x = x;
		this.y = y;
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}

const int INF = 1e9, MOD = 998244353; /// think
const ll LINF = 1e15;

const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector <int> a(n);
    for (auto &i : a) cin >> i;
    multiset <ld> have(all(a));
    ll ans = 0;
    for (int i = 0; i < m; i++) {
        ld x = *have.rbegin();
        have.erase(--have.end());
        have.insert(x / 2.0);
    }
    for (auto &i : have) {
        ans += int(i);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 9804
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int n;
    cin>>n;
    cout<<n/3<<endl;
    return 0;
}

Measured memory_bytes: 256
N,D=map(int,input().split())
X=[list(map(int, input().split())) for i in range(N)]
c=0
for i in range(N-1):
  for j in range(i+1,N):
    c += (sum((a-b)**2 for a,b in zip(X[i],X[j]))**0.5).is_integer()
print(c)


Measured memory_bytes: 3444
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e4+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);

void solve(){
    string s;
    cin>>s;
    cout<<(s[2]==s[3]&&s[4]==s[5]?"Yes":"No")<<Endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}

Measured memory_bytes: 3628
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        int n,a;
        n=in.nextInt();
        int[] arr = new int[n];
        for(int i=0;i<n;i++){
            arr[i]=in.nextInt();
        }
        a=0;
        int[] dp = new int[n];
        int ans = solver.call(arr , a , dp);
        out.println(ans);
        out.close();
    }

    static class TaskA {
        public int call( int[] arr , int a , int[] dp ) {
            if(arr.length!=2) {
                for (int i = arr.length - 2; i >= arr.length - 3; i--) {
                    dp[i] = Math.abs(arr[i] - arr[arr.length - 1]);
                }
                for (int i = arr.length - 4; i >= 0; i--) {
                    dp[i] = Math.min(Math.abs(arr[i] - arr[i + 1]) + dp[i + 1], Math.abs(arr[i] - arr[i + 2]) + dp[i + 2]);
                }
            }
            else
            {
                dp[0]=Math.abs(arr[0] -arr[1]);
            }
            return dp[0];
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }


    }
}

Measured memory_bytes: 31148
#include <bits/stdc++.h>
#define N 100001
#define INF 0x3f3f3f3f
using namespace std;
typedef pair<int, int> ii;
int n, e, r;
vector<ii> m[N];
int used[N];
int d[N];
void dijkstra(){
    d[r] = 0;
    used[r] = 1;
    priority_queue<ii, vector<ii>, greater<ii> > q;
    q.push(make_pair(0, r));//d[r]=0
    while(!q.empty()){
        ii temp = q.top(); q.pop();
        int u = temp.second;
        for(int i = 0; i < m[u].size(); i++){
            int v = m[u][i].second;
            if(used[v] == 0 && d[u]+m[u][i].first < d[v]){
                d[v] = d[u]+m[u][i].first;
                q.push(make_pair(d[v], v));
            }
        }
    }
}
int main(){
    scanf("%d %d %d", &n, &e, &r);
    for(int i = 0; i < n; i++) {
        used[i] = 0; d[i] = INF;
    }
    int a, b, c;
    for(int i = 0; i < e; i++){
        scanf("%d %d %d", &a, &b, &c);
        m[a].push_back(make_pair(c, b));//m[a][b]=c
    }
    dijkstra();
    for(int i = 0; i < n; i++){
        if(d[i] == INF) printf("INF\n");
        else printf("%d\n", d[i]);
    }
    return 0;
}


Measured memory_bytes: 13424
#include<stdio.h>
#include<string.h>
int main(void)
{
	char a[101],x,y,z;
	char s[101];
	char c[101];
	scanf("%s %s %s",a,s,c);
	x=a[0];
	y=s[0];
	z=c[0];
	printf("%c%c%c\n",x,y,z);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

#define keta setprecision(10) //10桁表示


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x, y;
	cin >> x >> y;
	int ans = 0;
	if (x <= 3)
	{
		ans += 100000;
	}
	if (x <= 2)
		ans += 100000;
	if (x <= 1)
		ans += 100000;
	if (y <= 3)
		ans += 100000;
	if (y <= 2)
		ans += 100000;
	if (y <= 1)
		ans += 100000;

	if (y == 1 && x == 1)
		ans += 400000;

	cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
int main(){
   int n,t,a,k;
   cin>>n>>t>>a;
   double z=999;
   rep(i,0,n){
      int h;
      cin>>h;
      if(abs(t-0.006*h-a)<z){
         z=abs(t-0.006*h-a);
         k=i;
      }
   }
   cout<<k+1;
}

Measured memory_bytes: 256
//BISMILLAHHIR RAHMANIR RAHIM
#include<bits/stdc++.h>
using namespace std;
typedef long long int            ll;
typedef unsigned long long int   ull;
#define min3(a,b,c)              min(a,min(b,c))
#define F                        first
#define S                        second
#define PB                       push_back
#define MP                       make_pair
#define PI                       2*acos(0.0)
#define REP(i,a,b)               for(int i = a; i<=b; i++)
int main()
{
    string s;
    int a=0,b=0;
    cin>>s;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='A')a++;
        else b++;
    }
    if(a==0 || b==0){
        cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;
    return 0;

}


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

using namespace std;

bool IsFirst( int index, int size ) {
	return ( index == 0 );
}

bool IsLast( int index, int size ) {
	return ( index == (size-1) );
}

bool IsFrame( int x, int w, int y, int h ) {
	if( IsFirst( x, w ) ) { return true; }
	if( IsLast( x, w ) ) { return true; }
	if( IsFirst( y, h ) ) { return true; }
	if( IsLast( y, h ) ) { return true; }
	return false;
}

void DrawRect(int h, int w) {
	for( int i=0; i<h; i++ ) {
		string s = "";
		for( int j=0; j<w; j++ ) {
			if( IsFrame( j, w, i, h ) ) {
				s += "#";
			} else {
				s += ".";
			}
		}
		cout << s << endl;
	}
}

int main() {
	int h,w;
	while( true ) {
		cin >> h >> w;
		if( h == 0 && w == 0 ) break;
		DrawRect( h, w );
		cout << endl;
	}
	return 0;
}

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

int main()
{
    int n;cin >> n;
    ll sum=0;
    vector<ll> cnt(100001,0);
    ll A;
    for (int i=0;i<n;i++)
    {
        cin >> A;
        cnt[A]++;
        sum+=A;
    } 
    int q;cin >> q;
    int b,c;
    for (int i=0;i<q;i++)
    {
        cin >> b >> c;
        sum=sum+cnt[b]*(c-b);
        cout << sum << endl;
        cnt[c]+=cnt[b];
        cnt[b]=0;
    }
    return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int N, k;
bool slv(ll x){
	bool f = true;
	rep(i, N - 1){
		x -= x / k + 1;
		if(x < 0){
			f = false; break;
		}
	}
	return f ? true : false;
}

bool ok(ll x){
	rep(i, N - 1){
		x -= x / k + 1;
		if(x < 0){
			break;
		}
	}
	return (x == 0) ? true : false;
}

int main(void){
	cin >> N >> k;
	ll l = 0, r = INFF + 1;
	while(r - l > 1){
		ll m = (l + r) / 2;
		if(slv(m)) r = m; //??§????????????
		else l = m; // ?°?????????????
	}
	while(1){
		if(ok(l)){
			printf("%lld\n", l); break;
		}
		l++;
	}

	return 0;
}

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

int main()
{
  int W, Q;
  while (cin >> W >> Q) {
    if ((W | Q) == 0)
      break;

    vector<int> wall(W, -1);
    for (int q = 0; q < Q; ++q) {
      string op;
      cin >> op;

      if (op == "s") {
	int id, w;
	cin >> id >> w;

	int cnt = 0, left = -1;
	for (int i = 0; i < W; ++i) {
	  if (wall[i] == -1) {
	    if (left == -1)
	      left = i;
	    ++cnt;
	    if (cnt == w)
	      break;
	  } else {
	    cnt = 0;
	    left = -1;
	  }
	}

	if (cnt == w) {
	  for (int i = left; i < left+w; ++i)
	    wall[i] = id;
	  cout << left << endl;
	} else {
	  cout << "impossible" << endl;
	}
      } else {
	int id;
	cin >> id;
	for (int i = 0; i < W; ++i) {
	  if (wall[i] == id)
	    wall[i] = -1;
	}
      }
    }
    cout << "END" << endl;
  }
  return 0;
}

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

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

	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}

	return 0;
}

Measured memory_bytes: 384
#include<iostream>

int main(){
  int r, c;
  std::cin >> r;
  std::cin >> c;

  int** table = new int*[r + 1];
  for(int y = 0; y < r + 1; y++){
    table[y] = new int[c + 1];
    if(y == r) break;
    for(int x = 0; x < c; x++){
      std::cin >> table[y][x];
    }
  }
  
  for(int y = 0; y < r; y++){
    int s = 0;
    for(int x = 0; x < c; x++){
      s += table[y][x];
    }
    table[y][c] = s;
  }
  
  for(int x = 0; x < c + 1; x++){
    int s = 0;
    for(int y = 0; y < r; y++){
      s += table[y][x];
    }
    table[r][x] = s;
  }

  for(int y = 0; y < r + 1; y++){
    for(int x = 0; x < c; x++){
      std::cout << table[y][x] << " ";
    }
    std::cout << table[y][c] << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

/********************Template********************/

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

	string a, b, c;
	cin >> a >> b >> c;

	int flag = 1;	//a...1,b...2,c...3
	string ans;
	bool select = false;
	while(!select){
		if(flag == 1){
			if(a.empty()){
				ans = "A";
				select = true;
				break;
			}
			else{
				if(a[0] == 'a') flag = 1;
				elif(a[0] == 'b') flag = 2;
				else flag = 3;
				a.erase(a.begin()+0);
				continue;
			}
		}
		if(flag == 2){
			if(b.empty()){
				ans = "B";
				select = true;
				break;
			}
			else{
				if(b[0] == 'a') flag = 1;
				elif(b[0] == 'b') flag = 2;
				else flag = 3;
				b.erase(b.begin()+0);
				continue;
			}
		}
		if(flag == 3){
			if(c.empty()){
				ans = "C";
				select = true;
				break;
			}
			else{
				if(c[0] == 'a') flag = 1;
				elif(c[0] == 'b') flag = 2;
				else flag = 3;
				c.erase(c.begin()+0);
				continue;
			}
		}
	}
	cout << ans << endl;
	rtn 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define LL long long
#define INF 1e9
#define eps 1e-9
#define PI acos(-1.0)
#define  Exp 2.7182818284
using namespace std;
const int maxn=123456*2;
char ch[maxn];



void init(){

}

void play(){



}

void Pri(){


}


int n;
int ai[maxn];
bool vis[maxn];
int bi[32];
map<int,int> M;
map<int,int> M1;
int main() {
    bi[0]=1;
    for(int i=1;i<=31;i++)bi[i]=bi[i-1]*2;
    //for(int i=1;i<=31;i++)cout<<bi[i]<<endl;

    while(scanf("%d",&n)!=EOF){
        for(int i=1;i<=n;i++)scanf("%d",&ai[i]);
        for(int i=1;i<=n;i++)M[ai[i]]++;
        sort(ai+1,ai+1+n);
        int sum=0;
        for(int i=n;i>=1;i--){
            if( M1[ai[i]]!=0){
                M1[ai[i]]=M1[ai[i]]-1;
                continue;
            }
            bool flag=0;
            int _find=0;
            for(int j=30;j>=0;j--){
                if(ai[i]==bi[j]){
                    flag=1;
                    break;
                }
                if(ai[i]>bi[j]){
                    _find=bi[j+1]-ai[i];

                    break;
                }
            }
            if(flag)continue;



            if(M[_find]!=0){
                M[_find]=M[_find]-1;
                M1[_find]=M1[_find]+1;
                sum++;
            }


        }
          for(int i=0;i<=30;i++){
                sum+=M[bi[i]]/2;
            }
        printf("%d\n",sum);


    }




    return 0;

}


Measured memory_bytes: 29184
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[] A = cin.ArrayInt(N);
        int[] B = cin.ArrayInt(N);

        long ans = 0;
        for (int t = 0; t < N; t++)
        {
            long tmp = 0;
            for (int i = 0; i <= t; i++)
            {
                tmp += A[i];
            }
            for (int j = t; j < N; j++)
            {
                tmp += B[j];
            }
            ans = Math.Max(tmp, ans);
        }
        Console.WriteLine(ans);

    }
    
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 11092
using namespace std;
typedef long long ll;
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <list>

#define out(S) cout<<(S)<<endl;
#define mod(i) ((i)%(ll)(1000000000 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define For(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFor(i,a,b) for(size_t i=(a)-1;i>=(b);i--)
#define Rep(i,a) for(size_t i=0;i<(a);i++)
#define rRep(i,a) for(size_t i=(a)-1;i>=0;i--)
#define pb(i) push_back(i);
#define Foreach(item,collection) for(auto item:collection)
using vi = vector<int>;


int main() {
	int n;
	list<ll> b;
	cin >> n;
	Rep(i, n) {
		ll ai;
		cin >> ai;
		if (i % 2 == 0) {
			b.push_back(ai);
		}
		else {
			b.push_front(ai);
		}
	}
	if (n % 2 == 1) {
		reverse(b.begin(), b.end());
	}
	Foreach(i, b){
		cout << i << " ";
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}

int main(){
    int n,m;cin >> n >> m;
    vector<P> ans;
    if(n&1){
        for(int l=1,r=n-1;l<r;++l,--r){
            ans.emplace_back(l, r);
        }
    }else{
        bool flag = false;
        for(int l=1,r=n-1;l<r;++l,--r){
            if(!flag && r-l <= n/2){
                --r;
                flag = true;
            }
            ans.emplace_back(l, r);
        }
    }
    rep(i,m) cout << ans[i].first << " " << ans[i].second << "\n"; 
}

Measured memory_bytes: 4296
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;



int main(int argc, char *argv[])
{
        int i;
        int n;
        int tmp;
        vector<int> a;

        cin >> n;
        for (i = 0; i < n; i++) {
                cin >> tmp;
            a.push_back(tmp);
        }

        while (a.size() > 1) {
                sort(a.begin(), a.end());
                for (i = 1; i < a.size(); i++) {
                        a[i] = a[i] % a[0];
                }
                auto itrNewEnd = remove_if(a.begin(), a.end(),
                                                                   [] (int x) -> bool {
                                                                           return x == 0;
                                                                   });
                a.erase(itrNewEnd, a.end());
        }
        cout << a[0] << endl;
        return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
 
#define int long long
 
#define pii pair<int, int>
 
#define x1 x1228
#define y1 y1228
 
#define left left228
#define right right228
 
#define pb push_back
#define eb emplace_back
 
#define mp make_pair                                                                
                                                                                                                                        
#define ff first                                                                  
#define ss second   
 
#define matr vector<vector<int> > 
 
#define all(x) x.begin(), x.end()
 
 
using namespace std;
typedef long long ll; 
typedef long double ld; 
                                                                                                   
const int maxn = 3e5 + 7, mod = 998244353, inf = 1e18, MAXN = 1e6 + 7;
const double eps = 1e-9;
mt19937 rnd(time(0));
int n, k; 
string get(string s, int k) {
    if (k == 0) return s; 
    while (k > 1) {
        int ln = 1; 
        while (ln < n && s[n - ln - 1] == s[n - 1]) {
            ++ln;
        }
        string cur = "";
        for (int i = 0; i < n - ln; ++i)  cur += s[ln + i];
        for (int i = 0; i < ln; ++i) cur += s[n - i - 1]; 
        s = cur; 
        --k; 
    }
    string cur = "";
    int ln = 1; 
    while (ln < n && s[n - ln - 1] == s[n - 1]) {
        ++ln;
    }
    for (int i = 0; i < ln; ++i)  cur += s[n - ln + i];
    for (int i = 0; i < n - ln; ++i) cur += s[n - i - 1]; 
    return cur; 
}

void solve() { 
    string s;
    cin >> n >> k >> s; 
    string ans = s; 
    string a = s;
    reverse(all(a)); 
    string p = s + a; 
    k = min(k, 20ll); 
    for (int i = 0; i <= n; ++i) {
        string cur = "";
        for (int j = 0; j < n; ++j) cur += p[i + j];
        ans = min(ans, get(cur, k - 1)); 
    }
    cout << ans; 
}                                
   
signed main() {
#ifdef LOCAL
    freopen("TASK.in", "r", stdin);
    freopen("TASK.out", "w", stdout);
#else 
    
#endif // LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20); 
    cout << fixed; 
    int t = 1; 
    for (int i = 0; i < t; ++i) {              
        solve();
    }
    return 0;
}  

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll vis[3][3];
    ll arr[3][3];
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++){
                cin>>vis[i][j];
            arr[i][j]=0;
        }
    }
    ll n;
    cin>>n;
    while(n--)
    {
        ll x;cin>>x;
        for(int i=0;i<3;i++)
            for(int j=0;j<3;j++)
            if(vis[i][j]==x)
            arr[i][j]=1;
    }
    if(arr[0][0]+arr[0][1]+arr[0][2]==3 || arr[1][0]+arr[1][1]+arr[1][2]==3 || arr[2][0]+arr[2][1]+arr[2][2]==3)
        cout<<"Yes";
    else if(arr[0][0]+arr[1][0]+arr[2][0]==3 || arr[0][1]+arr[1][1]+arr[2][1]==3 || arr[0][2]+arr[1][2]+arr[2][2]==3)
        cout<<"Yes";
    else if(arr[0][0]+arr[1][1]+arr[2][2]==3 || arr[0][2]+arr[1][1]+arr[2][0]==3)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    int n;
    cin >> n;
    if(n>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
n,q = map(int,input().split())
sco = [0]*(n+1)
edge = [[i] for i in range(n+1)]
for i in range(n-1):
    a,b = map(int,input().split())
    edge[b].append(a)
for i in range(q):
    p,x=map(int,input().split())
    sco[p]+=x
for i in range(1,n+1):
    E=edge[i]
    for e in E:
        if(e==i):continue
        sco[i]+=sco[e]
print(*sco[1:])

Measured memory_bytes: 56408
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <fstream>
#include <typeinfo>
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define I insert
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define repi(i, a, b) for (ll i = a; i < b; i++)
#define repj(j, a, b) for (ll j = a; j < b; j++)
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector<pii>
#define mod 1000000007
#define lim 100001
#define pi 3.14159265

using namespace std;
ll factorial(ll n) { return (n == 1 || n == 0) ? 1 : n * factorial(n - 1); }
int max3(int a, int b, int c) { return max(a, max(c, b)); }
int gcd(int a, int b)
{
    if (a == 0)
    {
        return b;
    }
    else
    {
        return gcd(b % a, a);
    }
}
ll power(ll a, ll n)
{
    if (n == 1)
        return a;
    else if (n == 0)
        return 1;
    else
    {
        ll r = power(a, n / 2);
        if (n % 2 == 0)
            return r * r;
        else
            return r * a * r;
    }
}
ll nCr(ll n, ll r) { return ((factorial(n)) / (factorial(n - r) * factorial(r))); }
void dfs(vector<vector<int>> &v, vi &check, int start)
{
    check[start - 1] = 1;
    repj(j, 0, v[start - 1].size())
    {
        if (!check[v[start - 1][j] - 1])
        {
            dfs(v, check, v[start - 1][j]);
        }
    }
}
bool isPrime(ll n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}
//works under 2 till 1e12

double newPrecision(double n)
{
    return floor(pow(10, 250) * n) / pow(10, 250);
}

ll f( ll arr[][2], ll pos, ll n,ll maxw, ll current, ll rec[][100001]){
   if(pos==n-1){
       if(current+arr[pos][0]> maxw){
           return 0;
       }
       else
           return arr[pos][1];
   }
   else {
       ;
   }

   if(rec[pos][current]!=-1){
       return rec[pos][current];
   }

   if (current + arr[pos][0] > maxw)
   {
       return rec[pos][current]=f(arr, pos + 1, n, maxw, current,rec);
   }
   else{
       return rec[pos][current] = max(
           f(arr, pos + 1, n, maxw, current,rec),
           arr[pos][1] + f(arr, pos + 1, n, maxw, (current+arr[pos][0]),rec)
           );
   }
}

    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        ll n,w;
        cin >> n>>w;
        ll arr[n][2];
        for (ll i = 0; i < n; i++)
        {
            for (ll j = 0; j < 2; j++)
            {
                cin >> arr[i][j];
            }
        }
        ll rec[n][100001];
        for (ll i = 0; i < n; i++)
        {
            for (ll j = 0; j < w+1; j++)
            {
                rec[i][j] = -1;
            }
        }
        cout << f(arr, 0, n, w, 0,rec);

        return 0;
}


Measured memory_bytes: 78336
A,B = map(int,input().split())
S = list(input())
flag = True
L = ['1','2','3','4','5','6','7','8','9','0']
if (S[A] == '-'):
  del S[A]
  for i in range(len(S)):
    if (S[i] not in L):
      flag = False
      break
else:
  flag = False
if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
template<class T>using vv = vector<vector<T>>;

#define in(v) v; cin >> v;
// #define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define repi(i,a,b) for(int i=(a),_i=(b);i<_i;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
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;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}


#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif

int main() {
  ll in(N); ll in(A); ll in(B); ll in(C); ll in(D);

  if (abs(A - B) > (N-1) * D) {
    cout << "NO\n";
    return 0;
  }
  
  int diff = abs(A - B);
  rep(i, N-1) {
    // [-C, -C, -C, ..., C, C, C, ..., C]という状況で、-Cがi個
    // 総和は-C * i + C * (N-1-i) = C*(N-1) - 2C*i
    // それぞれの要素はabs(C-D)だけ増やすことができる。
    // 合計で(N-1)*abs(C-D)だけ増やせる
    if (C * (N-1-i) - D*i <= diff && diff <= -C * i + D * (N - 1 - i)) {
      cout << "YES\n";
      return 0;
    }
  }
  cout << "NO\n";

  return 0;
}


Measured memory_bytes: 256