akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception addd) {
					addd.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception addd) {
				addd.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	
	public static FastReader sc = new FastReader();
 
	static int mod = (int) (1e9+7),MAX=(int) (3e5);
	static Set<Integer>[] edges;
    static int n,m;
    static long[][] dp;
    
	public static void main(String[] args) {
		int n = sc.nextInt();
		int m = sc.nextInt();
		char[][] tab = new char[n+1][m+1];
		for(int i=1;i<=n;++i) {
			char[] s = sc.next().toCharArray();
			for(int j=1;j<=m;++j)
				tab[i][j] = s[j-1];
		}
		dp = new long[n+1][m+1];
		for(int i=1;i<=n;++i) {
			if(tab[i][1] == '#') break;
			dp[i][1] = 1;
		}
		for(int i=1;i<=m;++i) {
			if(tab[1][i] == '#') break;
			dp[1][i] = 1;
		}
		
		for(int i=2;i<=n;++i) {
			for(int j=2;j<=m;++j) {
				if(tab[i][j] != '#') {
					dp[i][j] = dp[i-1][j] + dp[i][j-1];
					if(dp[i][j] >= mod) dp[i][j]-=mod;
				}
			}
		}
		out.println(dp[n][m]);
	  out.close();
	 }
	
}


Measured memory_bytes: 38620
// ProblemURL : https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_f
// ---------------------------------------------
package main

import "fmt"

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var t1, t2, a1, a2, b1, b2 int
	fmt.Scan(&t1, &t2, &a1, &a2, &b1, &b2)

	p := (b1 - a1) * t1
	q := (b2 - a2) * t2
	if (p > 0 && q > 0) || (p < 0 && q < 0) {
		fmt.Println(0)
	} else if (p > 0 && q < 0) || (p < 0 && q > 0) {
		if abs(p) > abs(q) {
			fmt.Println(0)
		} else if abs(p) < abs(q) {
			diff := abs(q) - abs(p)
			ct := 1 + abs(p)/diff*2
			if abs(p)%diff == 0 {
				ct--
			}
			fmt.Println(ct)
		} else {
			fmt.Println("infinity")
		}
	} else {
		panic("p == 0 || q == 0")
	}
}


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

int main(){
  int n,Y;
  cin >> n >> Y;
  
  for(int x=0;x<=n;x++){
    for(int y=0;y<=(n-x);y++){
      int z = n-x-y;
      if(10000*x+5000*y+1000*z==Y){
        cout << x << ' ' << y << ' ' << z << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[derive(Debug)]
struct Load {
    pub weight: i64,
    pub value: i64,
}

fn main() {
    input! {
        n: i64,
        w: i64,
        _loads: [(i64, i64); n as usize]
    }
    let mut loads = vec![];
    for l in _loads {
        loads.push(Load {
            weight: l.0,
            value: l.1,
        })
    }
    let mut cache = vec![vec![None; w as usize + 1]; n as usize];
    let v = max_value(&loads, &mut cache, n - 1, w);
    println!("{}", v)
}

fn max_value(loads: &Vec<Load>, cache: &mut Vec<Vec<Option<i64>>>, k: i64, y: i64) -> i64 {
    if k < 0 || y < 0 {
        0
    } else {
        if let Some(v) = cache[k as usize][y as usize] {
            return v;
        }
        let using = if y - loads[k as usize].weight < 0 {
            0
        } else {
            max_value(loads, cache, k - 1, y - loads[k as usize].weight) + loads[k as usize].value
        };
        let not_using = max_value(loads, cache, k - 1, y);
        let value = i64::max(using, not_using);
        cache[k as usize][y as usize] = Some(value);
        value
    }
}


Measured memory_bytes: 158224
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  rep(i, n) cin >> v[i];
  rep(i, n) cin >> c[i];
  int ans = 0;
  vector<int> g(n);
  rep(i, n) {
    g[i] = v[i] - c[i];
    if (g[i] > 0) ans += g[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ul ans = 0;
  int n;
  cin >> n;
  ul a[n];
  ul n_xor = 0;
  ul sum = 0;
  int l = 0;
  for (int i=0; i<n; ++i) {
    cin >> a[i];
    n_xor = (n_xor^a[i]);
    sum += a[i];
    while (n_xor != sum) {
      n_xor = (n_xor^a[l]);
      sum -= a[l];
      l++;
    }
    ans += i-l+1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;

    auto check = [&](int X) {
        map<int, int> dig;
        auto incr = [&](auto f, int k) -> bool {
            if (X == 1) return false;
            if (k <= 0) return false;

            auto itr = dig.find(k);
            if (itr == dig.end()) {
                dig[k] = 1;
                return true;
            } else if (itr->second < X - 1) {
                itr->second++;
                return true;
            } else {
                if (f(f, k - 1)) {
                    dig[k] = 0;
                } else {
                    return false;
                }
            }
        };

        int len = 0;
        rep(i, 0, N) {
            if (len < A[i]) {
                len = A[i];
            } else {
                auto itr = dig.upper_bound(A[i]);
                while (itr != dig.end()) {
                    itr = dig.erase(itr);
                }
                
                if (!incr(incr, A[i])) {
                    return false;
                }

                len = A[i];
            }
        }
        return true;
    };

    int ok = N;
    int ng = 0;
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (check(mid)) {
            ok = mid;
            dump(ok);
        } else {
            ng = mid;
            dump(ng);
        }
    }
    cout << ok << endl;
    return (0^_^0);
}



Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
  int key;
  struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

Node * treeMinimum(Node *x) {
  while(x->left != NIL)
    x = x->left;
  return x;
}

Node * find(Node *u, int k) {
  while(u != NIL && k != u->key) {
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

Node * treeSuccessor(Node *x) {
  if(x->right != NIL) return treeMinimum(x->right);
  Node *y = x->parent;
  while(y != NIL && x == y->right) {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z) {
  Node *y; // 削除する対象
  Node *x; // yの子

  // 削除する節点を決める
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  // yの子xを決める
  if(y->left != NIL) {
    x = y->left;
  } else {
    x = y->right;
  }

  if(x != NIL) {
    x->parent = y->parent;
  }

  if(y->parent == NIL) {
    root = x;
  } else {
    if(y == y->parent->left) {
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }

  if(y != z) {
    z->key = y->key;
  }
}

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;
  
  z = (Node *)malloc(sizeof(Node));
  z->key   = k;
  z->left  = NIL;
  z->right = NIL;
  
  while(x != NIL) {
    y = x;
    if(z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  
  z->parent = y;
  if(y == NIL) {
    root = z;
  } else {
    if( z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
  
int main(void) {
  int n, i, x;
  char com[16];
  scanf("%d",&n);
  
  for(i=0;i<n;i++) {
    scanf("%s",com);
    if(!strcmp(com,"find")) {
      scanf("%d",&x);
      Node *t = find(root,x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    } else if(!strcmp(com,"insert")) {
      scanf("%d",&x);
      insert(x);
    } else if(!strcmp(com,"print")) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if(!strcmp(com,"delete")) {
      scanf("%d",&x);
      treeDelete(find(root,x));
    }
  }

  return 0;
}


Measured memory_bytes: 20524
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    string s;
    cin>>k;
    cin>>s;
    if(s.size()>k){
        for(int i=0;i<k;i++)
            cout<<s[i];
        cout<<"..."<<endl;
    }
    if(k>=s.size())
        cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	char ch;
	cin >> ch;
	if (islower(ch))
		cout << "a" << endl;
	else
		cout << "A" << endl;
}

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

int main() {
    int N;
    while(cin >> N, N) {
        vector<vector<int>> t(N, vector<int>(N + 1));
        for(int i = 0; i < N; ++i) {
            for(int j = 0; j < N + 1; ++j) {
                cin >> t[i][j];
            }
        }
        vector<int> dp(1 << N, 1e9);
        dp[0] = 0;
        for(int S = 0; S < (1 << N); ++S) {
            for(int i = 0; i < N; ++i) {
                if((S >> i) & 1) {
                    continue;
                }
                int mi = t[i][0];
                for(int j = 0; j < N; ++j) {
                    if((S >> j) & 1) {
                        mi = min(mi, t[i][j + 1]);
                    }
                }
                dp[S | (1 << i)] = min(dp[S | (1 << i)], dp[S] + mi);
            }
        }
        cout << dp[(1 << N) - 1] << endl;
    }
}


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

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mxx=1e6;
int give(string a,string b)
{
	 int ans=0;
	 for(int i=0;i<b.length();i++)
	 {
	 	 if(a[i]!=b[i])ans++;
	 }
	 return ans;
}
int main()
{
   
    fast
 string s,t;
 cin>>s>>t;

   int n=s.length(),m=t.length();

   int ans=mxx;
   for(int i=0;i+m-1<n;i++)
   {
      string cur=s.substr(i,m);
      ans=min(ans,give(cur,t));
   }
   cout<<ans;
   
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <cmath>

#define rep(i,b,e) for (int (i) = (b); (i) < (e); (i)++)
typedef long long ll;

using namespace std;
 

int main() {
    ll n,k;
    cin>>n>>k;
    vector<ll> v(k,0);
    rep(i,1,n+1){
        v[i%k]++;
    }
    ll ans=0;
    ans+=(v[0]*v[0]*v[0]);
    
    if(k%2==0){
        ans+=(v[k/2]*v[k/2]*v[k/2]);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 1792
while True:
  n = int(input())
  s = []
  if n == 0:
    break
  s = list(map(int, input().split()))
  m = sum(s) / n
  v = 0
  for i in s:
    v += (i - m) ** 2
  ans = (v / n) ** (1/2)
  print('{:10f}'.format(ans))


Measured memory_bytes: 5668
//ID:computerbox --> Hajiyev Huseyn
#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define _CRT_SECURE_NO_WARNINGS
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#define FAST_READ ios_base::sync_with_stdio(0);/*cin.tie(0); cout.tie(0);*/
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
#define MAXN 2000

using namespace std;

#define debug(args...)(Debugger()) , args
class Debugger
{
  public:
  Debugger(const std::string& _separator=", ") :
  first(true),separator(_separator){}
  template<typename ObjectType>
  Debugger& operator,(const ObjectType& v)
  {
        if(!first)cerr<<separator;
        cerr<<v;
        first=false;
        return *this;
  }
  ~Debugger() {cerr<<endl;}      
  private:
    bool first;
    string separator;
};
 
template <typename T1, typename T2>
inline ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
   return os<<"("<<p.first<<", "<<p.second<<")";
}
template<typename T>
inline ostream &operator<<(ostream & os,const vector<T>& v)
{
    bool first=true;
    os<<"[";
    for(unsigned ll i=0;i<v.size();i++)
    {
        if(!first)os<<", ";
        os<<v[i];
        first=false;
    }
        return os<<"]";
}
template<typename T>
inline ostream &operator<<(ostream & os,const set<T>&v)
{
    bool first=true;
    os<<"[";
    for(typename set<T>::const_iterator ii=v.begin();ii!=v.end();++ii)
    {
        if(!first)os<<", ";
        os<<*ii;
        first=false;
    }
    return os<<"]";
}
template<typename T1, typename T2>
inline ostream &operator<<(ostream & os,const map<T1, T2>&v)
{
        bool first=true;
        os<<"[";
        for(typename map<T1,T2>::const_iterator ii=v.begin(); ii!=v.end();++ii)
        {
            if(!first)os<<", ";
            os<<*ii;
            first=false;
        }
        return os<<"]";
}

ll A,B,C,D;

int main(){
FAST_READ;
cin>>A>>B>>C>>D;
cout<<min(A,B)+min(C,D)<<endl;








return 0;
} 

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main() {
    int n,cnt=0;
    cin>>n;
    if(n==1){
        cout<<"1"<<"\n";
        return 0;
    }
    else if(n==2){
        cout<<"2"<<"\n";
        return 0;
    }
    else{
        for(int i=1;;i++){
            cnt+=i;
            if(cnt==n){
                for(int j=1;j<i+1;j++){
                cout<<j<<"\n";
                }
                return 0;
            }
            else if(cnt>n){
                cnt=cnt-n;
                for(int k=1;k<i+1;k++){
                    if(k==cnt)
                        continue;
                    else
                        cout<<k<<"\n";
            }
            return 0;
        }
        
    }
    }
    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX_N 10000

int N;

int main(void){
  cin >> N;
  int x, y;
  int prev_x, prev_y;
  int t, prev_t;
  prev_x= prev_y= 0;
  prev_t = 0;
  for (int i=0; i<N; i++){
    cin >> t >> x >> y ;
    if (t < abs(x - prev_x) + abs(y - prev_y)){
      cout << "No" << "\n";
      return 0;
    }
    if ((abs(t - prev_t) & 1) != (( abs(x - prev_x) + abs(y - prev_y) ) & 1 )){
      cout << "No" << "\n";
      return 0;   
    }
    prev_t = t;
    prev_x = x;
    prev_y = y;
  }
  cout << "Yes" << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 100005
#define NIL -1
struct Node{
  int p,l,r;
};
struct Node T[N];
int n,U[N],A[N];
void setD(int u,int w){
  if(u==NIL) return;
  U[u]=w;
  setD(T[u].l,w+1);
  setD(T[u].r,w+1);
}
int setH(int u){
  int t=0,y=0;
  if(T[u].l!=NIL)
    t=setH(T[u].l)+1;
  if(T[u].r!=NIL)
    y=setH(T[u].r)+1;
  return A[u]=(t>y?t:y);
}
int getS(int u){
  if(T[u].p==NIL)  return NIL;
  if(T[T[u].p].l!=u&&T[T[u].p].l!=NIL)  return T[T[u].p].l;
  if(T[T[u].p].r!=u&&T[T[u].p].r!=NIL)  return T[T[u].p].r;
  return NIL;
}
void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("sibling = %d, ",getS(u));
  int deg=0;
  if(T[u].l!=NIL)    deg++;
  if(T[u].r!=NIL)    deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",U[u]);
  printf("height = %d, ",A[u]);
  if(T[u].p==NIL)
    printf("root\n"); 
  else if(T[u].l==NIL&&T[u].r==NIL)
    printf("leaf\n");
  else
    printf("internal node\n");
}
int main(){
  int a,b,c,root=0,i;
  scanf("%d",&n);
  for(i=0;i<=n-1;i++){
    T[i].p=NIL;
  }
  for(i=0;i<=n-1;i++){
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    T[a].l=b;
    T[a].r=c;
    if(b!=NIL)
      T[b].p=a;
    if(c!=NIL)
      T[c].p=a;
  }
  for(i=0;i<=n-1;i++){
    if(T[i].p==NIL)
      root=i;
  }
  setD(root,0);
  setH(root);
  for(i=0;i<=n-1;i++)  print(i);
  return 0;
}



Measured memory_bytes: 2104
import java.util.*;
import java.io.*;

public class Main {
    static class Pair {
        long c;
        long bonus;
        Pair (long c, long bonus) {
            this.c = c;
            this.bonus= bonus;
        }
    }
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc= new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        char[][] arr = new char[m][n];
        int[] row = new int[m];
        int[] col= new int[n];
        sc.nextLine();
        for (int i=0; i<m; i++) {
            String s = sc.nextLine();
            for (int j=0; j<n; j++) {
                arr[i][j] = s.charAt(j);
                if (arr[i][j]=='#') {
                    row[i]=1;
                    col[j]=1;   
                }
            }
        }
        int x=0,y=0;
        for (int i=0; i<m; i++) {
               // System.out.print(row[i]);
                if (row[i]==1)x++;
        }
        //System.out.println();
        for (int i=0; i<n; i++) {
            //System.out.print(col[i]);
            if (col[i]==1)y++;
        }
        char[][] mat = new char[x][y];
        int p=0,q=0;
        List<Character> list = new ArrayList<>();
        for (int i=0; i<m; i++) {
            if (row[i]==1) {
                for (int j=0;j<n;j++) {
                    if (col[j]==1) {
                        list.add( arr[i][j]);
                    }
                }       
            }
        }
        //System.out.println(list.size());
        for (int i=0; i<x;i++) {
            for (int j=0; j<y;j++) {
                mat[i][j]= list.get(p);
                p+=1;
            }
        }
        for (int i=0; i<x; i++) {
            for (int j=0; j<y;j++) {
                System.out.print(mat[i][j]);
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 25684
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,W;
    cin >> N >> W;
    vector<int> v(N), w(N);
    REP(i, N){
        cin >> v[i] >> w[i];
    }
    vector<vector<int>> dp(N+1, vector<int>(W+1,0));
    Rep(i, 1, W+1){
        Rep(j, 1, N+1){
            chmax(dp[j][i], dp[j-1][i]);
            if(i - w[j-1] >= 0){
                chmax(dp[j][i], dp[j-1][i-w[j-1]]+v[j-1]);
            }
        }
    }
    
    pr(dp[N][W]);
}


Measured memory_bytes: 6868
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); i++)

int main() {
  int N; cin>>N;
  vector<double> a(N);
  REP(i,N) cin>>a[i];
  sort(a.begin(), a.end());
  double ans = a[0];
  for(int i = 1; i < N; i++) {
    ans = (ans + a[i])/2.0;
  }
  printf("%0.8f", ans);
  puts("");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define endl '\n'
int sz = 100002;
int n, m;
vector<int>ar;
//vector<int>tree[sz];
int main() {
// freopen("input.txt", "r", stdin); 
// freopen("output.txt", "w", stdout); 
	cin>>n;
	ar.resize(n-1);
	for(int i = 0; i<n-1; i++) {
		cin>>ar[i];
	}
	map<int, int>sub;
	for(int i = 0; i<n-1; i++) {
		sub[ar[i]]++;
	}
	
	for(int i = 1; i<=n; i++) {
		auto it = sub.find(i);
		if(it == sub.end()) cout<<0<<endl;
		else cout<<it->second<<endl;
	}
}


Measured memory_bytes: 13516
#include <cstdint>
#include <cstdio>
#include <vector>

#include <atcoder/convolution>

using mi = atcoder::modint998244353;

int main() {
  int n, m;
  scanf("%d %d", &n, &m);

  std::vector<mi> a(n), b(m);
  for (auto& ai: a) {
    int tmp;
    scanf("%d", &tmp);
    ai = tmp;
  }
  for (auto& bi: b) {
    int tmp;
    scanf("%d", &tmp);
    bi = tmp;
  }

  auto c = atcoder::convolution(a, b);
  for (size_t i = 0; i < c.size(); ++i)
    printf("%u%c", c[i].val(), i+1<c.size()? ' ': '\n');
}


Measured memory_bytes: 19068
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; cin >> s;
    map<char, int> m;
    rep(i,s.size()) m[s[i]]++;
    vector<int> v;
    for(auto val : m) {
        v.push_back(val.second);
    }
    ll ans = 0;
    for(int i = 0; i < v.size()-1; i++) {
        for(int j = i+1; j < v.size(); j++) {
            ans += (ll)v[i]*v[j];
        }
    }
    cout << ans+1 << endl;

    return 0;
}

Measured memory_bytes: 720
#include <iostream>
using namespace std;
int main(){
  int n;
  while(cin >> n){
 
    while(1){
      n = n%39;
      if(n/39 == 0)break;
      n/=39;
    }
    if(n == 0)n = 39;
    if(n/10 == 0 )cout <<"3C0"<< n << endl;
    else cout <<"3C"<< n << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int n = vs[0];
			int m = vs[1];
			List<int>[] graph = new List<int>[n];
			int[] cnt = new int[n];
			for (int i = 0; i < n; i++) {
				graph[i] = new List<int>();
			}
			for (int i = 0; i < m; i++) {
				int[] tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
				graph[tmp[0] - 1].Add(tmp[1] - 1);
				cnt[tmp[1] - 1]++;
			}

			Queue<int> queue = new Queue<int>();
			for (int i = 0; i < cnt.Length; i++) {
				if (cnt[i] == 0) {
					queue.Enqueue(i);
				}
			}
			int[] dp = new int[n];
			while (queue.Count > 0) {
				int v = queue.Dequeue();
				foreach (int nv in graph[v]) {
					cnt[nv]--;
					if (cnt[nv] == 0) {
						queue.Enqueue(nv);
						dp[nv] = Math.Max(dp[nv], dp[v] + 1);

					}
				}
			}
			Console.WriteLine(dp.Max());
		}
	}
}

Measured memory_bytes: 28584
/*input
3
1
*/
/**
    Author: Kristopher Paul
    Date Created: 21-12-2019
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

//Uncomment for File I/O
/*
#define cin fin
#define cout fout

ifstream fin("cowmbat.in");
ofstream fout("cowmbat.out");
*/

using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int a,b;
    cin >> a >> b;
    int arr[4] = {};
    arr[a] = 1;
    arr[b] = 1;
    FOR(i,1,4){
        if(arr[i] == 0){
            cout << i << endl;
            return;
        }
    }
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


Measured memory_bytes: 256
A, B, C, D = map(int, input().split())

def gcd(a, b):
  while b != 0:
    a, b = b, a % b
  return a

def lcm(a, b):
  return a * b // gcd(a, b)

def f(x):
  return x - x // C - x // D + x // lcm(C, D) 

ans = f(B) - f(A - 1)
print(ans)

Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

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

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n;i++){
        int m = i;
        for (int j = 2; j <= i;j++){
            while(m%j==0){
                a[j]++;
                m /= j;
            }
        }
    }
    ll ans = 1;
    ll mod = 1000000007;
    for (int i = 1; i <= n;i++){
        ans *= a[i] + 1;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use std::collections::*;
use std::io::*;
use std::*;
// template {{{
macro_rules! get {
    ($($t:tt),*; $n:expr) => {
        {
            let stdin = std::io::stdin();
            let ret = std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
                let line = line.unwrap();
                let mut it = line.split_whitespace();
                _get!(it; $($t),*)
            }).collect::<Vec<_>>();
            ret
        }
    };
    ($($t:tt),*) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut it = line.split_whitespace();
            _get!(it; $($t),*)
        }
    };
}
macro_rules! _get {
    ($it:ident; [char]) => {
        _get!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; [u8]) => {
        _get!($it; String).bytes().collect::<Vec<_>>()
    };
    ($it:ident; usize1) => {
        $it.next().unwrap().parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap().parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:tt),+) => {
        ($(_get!($it; $t)),*)
    };
}
// }}}

fn main() {
    let (x, k, d) = get!(i64, i64, i64);
    let a = (x / d).abs();
    if k < a {
        println!(
            "{}",
            if x > 0 {
                (x - k * d).abs()
            } else {
                (x + k * d).abs()
            }
        )
    } else {
        let left = k - a;
        if left % 2 == 0 {
            println!("{}", (x % d).abs())
        } else {
            println!(
                "{}",
                if x > 0 {
                    (x % d - d).abs()
                } else {
                    (x % d + d).abs()
                }
            )
        }
    }
}


Measured memory_bytes: 2164
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	static final int INF = 0x3f3f3f3f;
	void main() {
		int m = sc.nextInt();
		int n = sc.nextInt();
		int[] dp = new int[m + 1]; Arrays.fill(dp, INF); dp[0] = 0;
		while (n-- > 0) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			for (int x = 0; x < m; x++) {
				int y = Math.min(x + a, m);
				dp[y] = Math.min(dp[y], dp[x] + b);
			}
		}
		println(dp[m]);
	}
}


Measured memory_bytes: 39904
#include <bits/stdc++.h>
using namespace std;
#define mt make_tuple
#define mp make_pair
#define int long long

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <time.h>
#include <vector>
#include <map>
#include <set>
using namespace std;

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int x,a,b;
	cin>>x>>a>>b;
	x-=a;
	x%=b;
	cout<<x;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e6+50;
int n,l,a[N];
int main() {
	scanf("%d%d", &n, &l);
	REP(i,1,n) scanf("%d",a+i);
	int pos = 0;
	PER(i,1,n-1) if (a[i]+a[i+1]>=l) pos = i;
	if (!pos) return puts("Impossible"),0;
	puts("Possible");
	REP(i,1,pos-1) printf("%d\n",i);
	PER(i,pos+1,n-1) printf("%d\n",i);
	printf("%d\n",pos);
}









Measured memory_bytes: 1152
num = input()
data = input().split()
min = 1000000
max = -1000000
sum = 0

for a in data:
    i = int(a)
    if i >max:
        max = i
    if i < min:
        min = i
    sum = sum + i
print(str(min)+" "+str(max)+" "+str(sum))



Measured memory_bytes: 6284
#include <stdio.h>

int main(void)
{
    int c[3][3];
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
            scanf("%d", &c[i][j]);
    for (int i = 2; i >= 0; i--)
        for (int j = 0; j < 3; j++)
            c[i][j] -= c[0][j];
    for (int j = 2; j >= 0; j--)
        for (int i = 0; i < 3; i++)
            c[i][j] -= c[i][0];
    bool flag = false;
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
            if (c[i][j]) flag = true;
    if (flag) printf("No\n");
    else printf("Yes\n");
}


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

int gcd(int a,int b);

int main(){
  int n;
  cin >> n;
  int a[n+10];
  for (int i =0;i<n;i++) cin >> a[i];
  int g[n],h[n],k=-100000;
  for (int i =0;i<n;i++){
    if (i == 0){
      g[i] = a[i];
    }else{
      if (g[i-1] > a[i]){
	g[i] = gcd(g[i-1],a[i]);
      }else{
	g[i] = gcd(a[i],g[i-1]);
      }
    }
  }
  for (int i =n-1;i>-1;i--){
    if (i == n-1){
      h[i] = a[i];
    }else{
      if (h[i+1] > a[i]){
	h[i] = gcd(h[i+1],a[i]);
      }else{
	h[i] = gcd(a[i],h[i+1]);
      }
    }
  }
  for (int i =0;i<n+1;i++){
    if (i == 0){
      k = max(k,h[1]);
    }else if (i==n){
      k = max(k,g[n-2]);
    }else if (i==n+1){
      k = max(k,g[n-1]);
    }else{
      if (g[i-1] > h[i+1]){
	k = max(k,gcd(g[i-1],h[i+1]));
      }else{
	k = max(k,gcd(h[i+1],g[i-1]));
      }
    }
  }
  cout << k;
}

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

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

const long long mod = 1e9 + 7;

map<long long, long long> prime_factor(long long n) {
  map<long long, long long> ret;
  for (long long i = 2; i * i <= n; i++)  {
    while ( n % i == 0 ) {
      ret[i]++;
      n /= i;
    }
  }
  if ( n != 1 ) { ret[n] = 1; }
  return ret;
}

long long pow_mod(long long n, long long  k) {
  if ( k == 0 ) { return 1; }
  if ( k%2 == 0 ) {
    long long t = pow_mod(n, k/2);
    return t*t % mod;
  }
  return n * pow_mod(n, k-1) % mod;
}

int main() {
  int n;
  cin >> n;
  long long a[n];
  map<long long, long long> lcm_pf;
  for ( int i = 0; i < n; i++ ) {
    cin >> a[i];
    for ( auto p : prime_factor(a[i]) ) {
      lcm_pf[p.first] = max(lcm_pf[p.first], p.second);
    }
  }

  long long lcm = 1;
  for ( auto p : lcm_pf ) {
    lcm *= pow_mod(p.first, p.second);
    lcm %= mod;
  }

  long long ans = 0;
  for ( int i = 0; i < n; i++ ) {
    ans += lcm * pow_mod(a[i], mod-2);
    ans %= mod;
  }

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


Measured memory_bytes: 4096
/*
       ()       ()()()()     ()        ()       ()        ()        ()
      ()()      ()     ()    ()()      ()      ()()       ()()      ()
     ()  ()     ()      ()   ()  ()    ()     ()  ()      ()  ()    ()
    ()()()()    ()      ()   ()    ()  ()    ()()()()     ()    ()  ()
   ()      ()   ()     ()    ()      ()()   ()      ()    ()      ()()
  ()        ()  ()()()()     ()        ()  ()        ()   ()        ()

*/
#include <bits/stdc++.h>
#define MOD 1e9+7
#define SIZE (int)1e5+5
#define all(x) x.begin(),x.end()

#define si(i)  scanf("%d",&i)
#define sf(f)  scanf("%f",&f)
#define pi(i)  printf("%d",i)
#define pd(d)  printf("%lf",d)
#define deb(x) cout<<#x<<" is "<<x<<"\n";
#define lb     lower_bound
#define ub     upper_bound
#define pb     push_back

#define IOfast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

int64_t exponentiation(int64_t base,int exp)
{
    if (exp == 0)
        return 1;

    if (exp == 1)
        return base;

    int64_t t = exponentiation(base, exp / 2);

    t = (t * t);

    if (exp % 2 == 0)
        return t;
    else
        return base * t;
}

int main()
{
  IOfast; 
  int q=1;
  //cin>>q;
  //  memset(dp,-1,sizeof(dp));
  while(q--)
  {
    int n;
    cin>>n;
    vector<int> arr(n),value(n);
    for(auto &item:arr) cin>>item;
    
    value[1]=abs(arr[1]-arr[0]);
    
    for(int i= 2;i<n;i++)
    {
      value[i] = min(abs(arr[i] - arr[i-1]) + value[i-1] ,abs(arr[i] - arr[i-2]) + value[i-2] );
    } 
    cout<<value[n-1];
  }
  
  return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h.at(i);
	}

	string ans = "Yes";
	int level = 0;
	for (int i = 0; i < n; i++) {
		if (h.at(i) > level + 1) {
			level = h.at(i) - 1;
			continue;
		}
		if (h.at(i) < level) {
			ans = "No";
			break;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 640
#include <stdio.h>


int main(void){
    // Your code here!
int n;
//int
long long res=0;
int k=0;
scanf("%d",&n);


for(int i=1; i<n; i++){
 for(int j=n-i; j>0; j-=i){
    
    res++;
    
}   
    
}

/*
for( int i=1; i<n; i++){
 for( int j=n-i; j>0; j-=i){
    
    k=n-i*j;
    if( i*j+k==n && k>0 ) res++;
    //printf("%d %d %d\n",i,j,k);
    
 }   
    
}*/

printf("%lld\n",res);
//printf("%d\n",res);
    
}


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

#define IOS cin.tie(0);ios::sync_with_stdio(0)

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){} //@shibh308's template
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

void OUT(){}
template<class Head,class...Tail>
void OUT(Head&& head,Tail&&...tail){
    cout<<head<<(sizeof...(tail)?' ':'\n');
    OUT(move(tail)...);
}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSUBLE\n");}


//----------------------library------------------------//

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

const int NMAX = 200;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}

signed main(){
    IOS; 
    CIN(N);
    int cnt=0;
    vi H(N);
    rep(i,N) cin>>H[i];
    rep(i,N){
        flag=true;
        rep(j,i){
            if(H[j]>H[i]) {flag=false;break;}
        }
        if(flag)cnt++;
    }
    COUT(cnt);
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
double a, b;
double c;
int d;
cin >> a >> b;
c = (a + b) / 2;
d = c;
if (c - d > 0) {
  c += 1;
}

cout << (int)c << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b,d,r;
    double f;
    scanf("%d%d",&a,&b);
    d=a/b;
    r=a%b;
    f=1.0*a/b;
    printf("%d %d %.5lf\n",d,r,f);
    return 0;
}

Measured memory_bytes: 640
class Union():
  def __init__(me,N):
    me.N = N
    me.up = [-1]*N
    me.down = [ [] for i in range(N) ]
  def union(me,a,b):
    ua = me.up[a] if me.up[a]!=-1 else a
    ub = me.up[b] if me.up[b]!=-1 else b
    if (ua == ub):
      return
    if ( len(me.down[ua]) < len(me.down[ub]) ):
      ub,ua = ua,ub
    for v in me.down[ub]:
      me.up[v] = ua
    me.down[ua].extend( me.down[ub] )
    me.down[ub] = []
    me.up[ub] = ua
    me.down[ua].append( ub )

N,K,L = [ int(it) for it in input().split() ]
uk = Union(N)
for a,b in [ [int(it)-1 for it in input().split()] for i in range(K) ]:
  uk.union(a,b)

ul = Union(N)
for a,b in [ [int(it)-1 for it in input().split()] for i in range(L) ]:
  ul.union(a,b)

pr = [0]*N
for i in range(N):
  ua = uk.up[i] if uk.up[i]!=-1 else i
  ub = ul.up[i] if ul.up[i]!=-1 else i
  pr[i] = (ua*N+ub,i)
pr.sort(key = lambda x:x[0])

li = [0]*N
de = pr[0][0]
s = [pr[0][1]]
for i in range(1,N):
  if (de!=pr[i][0]):
    for v in s:
      li[v] = len(s)
    s=[pr[i][1]]
    de = pr[i][0]
  else:
    s.append(pr[i][1])
for v in s:
  li[v] = len(s)

print ( " ".join( [ str(it) for it in li ]) )
    
    

Measured memory_bytes: 128376
#include<stdio.h>

int main(void){
    int A[3], i;

    scanf("%d %d %d",&A[0],&A[1],&A[2]);

    for(i=0;i<3;i++){
        if(A[i]<1 || A[i]>13){
            printf("Input is uncorrect");
            return -1;
        }
    }
    if((A[0]+A[1]+A[2]) >= 22){
        printf("bust");
    }else{
        printf("win");
    }

}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
		
	public static void main(String args[]){
		  
	    Scanner sc = new Scanner(System.in);
	    
	    int N = sc.nextInt();
	    int M = sc.nextInt();
	    int A[] = new int[M];
	    
	    for(int i = 0; i < N; i++) {
	    	int K = sc.nextInt();
	    	for(int j = 0; j < K; j++) {
	    		int in = sc.nextInt()-1;
	    		A[in]++;
	    	}
	    }
	    
	    int cnt = 0;
	    for(int i = 0; i< M; i++) {
	    	if(A[i] == N) {
	    		cnt++;
	    	}
	    }
	    
	    System.out.println(cnt);
  
	}
	
}

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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

// 約数を求める
vl divisor(ll n){
	vl res;
	for(ll i=1; i*i<=n; ++i){
		if(n%i==0){
			res.push_back(i);
			if(i!=n/i){
				res.push_back(n/i);
			}
		}
	}
	return res;
}

const ll INF=1e18;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n;
	ll k, a[525];
	cin>>n>>k;
	ll sum=0, ma=0;
	REP(i, n){
		cin>>a[i];
		sum+=a[i];
		CHMAX(ma, a[i]);
	}
	sort(a, a+n);
	vl v=divisor(sum);
	ll ans=1;
	for(auto &x : v){
		if(x==1){
			continue;
		}
		if(x==sum){
			if(sum-ma<=k){
				ans=x;
			}
			continue;
		}
		vl b;
		REP(i, n){
			if(a[i]%x==0){
				continue;
			}
			b.push_back(a[i]%x);
		}
		sort(ALL(b));
		int m=b.size();
		ll sum[2][525];
		sum[0][0]=0;
		REP(i, m){
			sum[0][i+1]=sum[0][i]+b[i];
		}
		sum[1][m]=0;
		FORR(i, 0, m){
			sum[1][i]=sum[1][i+1]+x-b[i];
		}
		ll tmp=INF;
		REP(i, m+1){
			if(abs(sum[0][i]-sum[1][i])%x==0){
				CHMIN(tmp, max(sum[0][i], sum[1][i]));
			}
		}
		if(tmp<=k){
			CHMAX(ans, x);
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 384