akhauriyash/Code-Regression huggingface dataset:
class Dice:
    def __init__(self, data):
        self.data = data

    def move(self, direction):
        if direction == 'E':
            self.data[0],self.data[3],self.data[5],self.data[2] = \
                    self.data[3],self.data[5],self.data[2],self.data[0]
        elif direction == 'N':
            self.data[0],self.data[4],self.data[5],self.data[1] = \
                    self.data[1],self.data[0],self.data[4],self.data[5]
        elif direction == 'S':
            self.data[0],self.data[1],self.data[5],self.data[4] = \
                    self.data[4],self.data[0],self.data[1],self.data[5]
        elif direction == 'W':
             self.data[0],self.data[2],self.data[5],self.data[3] = \
                    self.data[2],self.data[5],self.data[3],self.data[0]
        elif direction == 'LEFT':
            self.data[2],self.data[4],self.data[3],self.data[1] = \
                    self.data[1], self.data[2],self.data[4],self.data[3]


    def getTop(self):
        return self.data[0]

    def getRight(self):
        return self.data[2]

    def moveTopTo(self, target):
        for i in range(4):
            if self.data[0] == target:
                break
            self.move('W')

            if self.data[1] == target:
                self.move('S')
            elif self.data[4] == target:
                self.move('N')

    def moveFrontTo(self, target):
        for i in range(4):
            if self.data[1] == target:
                break
            self.move('LEFT')

dice = Dice(input().split())
count = int(input())
result = []

for i in range(count):
    (top, front) = [i for i in input().split()]
    dice.moveTopTo(top)
    dice.moveFrontTo(front)
    result.append(dice.getRight())

for s in result:
    print(s)

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

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        Map<String, Long> map = new HashMap<>();
        for (int i = 0; i < n; i ++){
            String str = scan.next();
            if (map.containsKey(str))
                map.put(str, map.get(str) + 1);
            else
                map.put(str, 1L);
        }
        long max = 0;
        List<Map.Entry<String, Long>> list = new ArrayList<>(map.entrySet());
        list.sort(new Comparator<Map.Entry<String, Long>>() {
            @Override
            public int compare(Map.Entry<String, Long> s1, Map.Entry<String, Long> s2) {
                if (s1.getValue().equals(s2.getValue()))
                    return s1.getKey().compareTo(s2.getKey());
                return s2.getValue().compareTo(s1.getValue());
            }
        });
        max = list.get(0).getValue();
        for (Map.Entry<String, Long> stringIntegerEntry : list) {
            if (stringIntegerEntry.getValue() == max)
                System.out.println(stringIntegerEntry.getKey());
            else
                return;
        }
    }
}


Measured memory_bytes: 87880
import sys
from collections import defaultdict, Counter


class UnionFind(object):
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]


def main():
    n, m, k = list(map(int, sys.stdin.readline().strip().split()))

    friends = defaultdict(set)
    blocks = defaultdict(set)

    for i in range(m):
        a, b = list(map(int, sys.stdin.readline().strip().split()))
        a -= 1
        b -= 1
        friends[a].add(b)
        friends[b].add(a)

    for i in range(k):
        c, d = list(map(int, sys.stdin.readline().strip().split()))
        c -= 1
        d -= 1
        blocks[c].add(d)
        blocks[d].add(c)

    uf = UnionFind(n)

    for f_key in friends:
        for child in friends[f_key]:
            # child_cur_group = parents[child]
            uf.union(f_key, child)

    # group_num_set = defaultdict(set)
    # for i in range(n):
    #     group = uf.find(i)
    #     group_num_set[group].add(i)

    ans = [0] * n
    for i in range(n):
        group = uf.find(i)
        size = uf.size(i) - 1
        size -= len(friends[i])
        for block in blocks[i]:
            block_group = uf.find(block)
            if block_group == group:
                size -= 1
        ans[i] = size


        # friend_cand = group_num_set[group]

        # true_friend_cand = friend_cand.difference(blocks[i]).difference(friends[i])
        # ans[i] = len(true_friend_cand) - 1

    return ans


result = main()
print(' '.join([str(num) for num in result]))


Measured memory_bytes: 88824
#include <bits/stdc++.h>
#define int long long
#define N 17
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
int Max(int &a,int b){return a=max(a,b);}
string Min(string &a,string b){return a=min(a,b);}
typedef pair<string,string> P;
int n,K;
string his[N];

string getNx(const string &a, const string &str){
  string res;
  int j = 0,ch[26]={};
  
  for(char s:str)if(s!='?')ch[s-'A']++; 
  for(char s:str){
    if(j<K &&(a[j] == s ||(s == '?' && !ch[a[j]-'A'])))res = a[j++] + res;
    else res += s;
  }
  if(j < K) return "";
  return res;
}

string DP(){
  map<string,string> dp[1<<N]; // (key = current thread, value = min order)
  dp[0][string(n,'?')] = "";
  
  for(int bit=0;bit<(1<<n);bit++){ //used
    for(int i=0;i<n;i++){ // next use
      if(bit>>i&1)continue;
      for(P p:dp[bit]){
        int nbit = bit | (1<<i);
        string nsta = getNx(his[i],p.first);
        string norder = p.second + char('A'+i);
        if(nsta == "")continue;
        
        if(!dp[nbit].count(nsta)) dp[nbit][nsta] = norder;
        else Min(dp[nbit][nsta],norder);
      }
    }
  }
  string ans(50,'Z');
  for(P p:dp[(1<<n)-1])Min(ans,p.second);
  return ans;
}

signed main(){
  cin>>n>>K;
  for(int i=0;i<n;i++)cin>>his[i];
  cout<<DP()<<endl;
  return 0;
}

Measured memory_bytes: 15884
/*
    ##############################
    #  Author: Pratyush Gaurav   #
    #  College: NIT ROURKELA     #
    ##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define scan(n) scanf("%lld",&n)
#define scan2(a,b) scanf("%lld %lld",&a,&b)
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define print(n) printf("%lld\n",n)
#define scanS(s) scanf("%s",&s)
#define printS(s) printf("%s",s)

#define ff first
#define ss second
#define rep(i,a) for(i = 0 ; i < a ; i++)
#define repr(i,a) for(i = a ; i >= 0 ; i--)
#define REP(i,a,b) for(i = a ; i <= b ; i++)
#define REPR(i,a,b) for(i = a ; i >= b ; i--)
#define mem(a,b)memset(a,b,sizeof(a))
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define pb push_back
#define popb pop_back

#define endl '\n'

const long long INF = 2000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

void solve() {
    string s;
    cin >> s;
    lli k;
    cin >> k;
    lli i = 0, n = s.length();
    lli temp = 0;
    while (i < n) {
        if (s[i] == '0') {
            i++;
            continue;
        }
        if (s[i] == '1') {
            if (i + 1 == k) {
                cout << s[i] << endl;
                return;
            } else {
                i++;
            }
        } else {
            cout << s[i] << endl;
            return;
        }
    }
}

int main()
{
    opt;
    lli t = 1;
    //cin >> t;

    while(t--)
        solve();
    return 0;
}

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

string N;
int main()
{
  cin >> N;
  if ((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3]))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


 
void solve(){
    ll x;
    cin>>x;
    if(x<1200) cout<<"ABC"<<endl;
    else cout<<"ARC"<<endl;
}
 
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    ll Q=1;
    // cin>>Q;
    rep(_,Q){
 
        solve();
 
    }
   
 
 
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
ll days(int y,int m,int d)
{
        return 365*y+(y/4)-(y/100)+(y/400)+((306*(m+1))/10)+d-429;
}
int main()
{
        while(1)
        {
                int y1,m1,d1,y2,m2,d2;
                cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2;
                if(y1==-1)break;
                if(m1<=2)y1--,m1+=12;
                if(m2<=2)y2--,m2+=12;
                //cout << days(y,m,d) << endl;
                cout << days(y2,m2,d2)-days(y1,m1,d1) << endl;
        }
        return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N;
  cin >> N;
  double v[N];
  rep(i, N) cin >> v[i];
  sort(v, v+N);
  reverse(v, v+N);

  double ans = 0;
  double pow2 = 1;
  rep(i, N){
    if(i != N-1) pow2 *= 2;
    ans += v[i] / pow2;
  }
  cout << ans << endl;
  return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

ll dp[100001];

int main() {
  int N, W;
  cin >> N >> W;

  rep (i, W + 1) dp[i] = -1;
  dp[0] = 0;

  rep (i, N) {
    int w, v;
    cin >> w >> v;
    for (int j = W - w; j >= 0; j--) {
      if (dp[j] == -1) continue;
      dp[j + w] = max(dp[j + w], dp[j] + v);
    }
  }

  ll ans = 0;
  rep (i, W + 1) ans = max(ans, dp[i]);

  cout << ans << endl;
}


Measured memory_bytes: 1024
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let i : Vec<f64> = read_vec();
    let x = (i[0] + i[1]) / 2.;
    println!("{}", x.round() );
}


Measured memory_bytes: 4604
s = gets.chomp.split('')

n = s.size

odd_allow = ['R', 'U', 'D']
even_allow = ['L', 'U', 'D']

for i in 0...n
  if (i+1).odd?
    unless odd_allow.include?(s[i])
      puts 'No'
      exit
    end
  else
    unless even_allow.include?(s[i])
      puts 'No'
      exit
    end
  end
end
puts 'Yes'

Measured memory_bytes: 3836
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int insertion_sort(int,int[],int,int);
int shellSort(int,int[]);
void printArray(int[],int);
int main(int argc, char** argv) {
    int size;
    scanf("%d\n", &size);
    int array[size];
    for(int i = 0; i < size; i++)
        scanf("%d", &array[i]);
    
    int count = shellSort(size,array);
    printf("%d\n", count);
    printArray(array,size);
    
    return (EXIT_SUCCESS);
}

int insertion_sort(int size, int array[size], int gap, int count){
    int temp, j;
    for(int i = gap; i < size; i++){
        temp = array[i];
        j = i - gap;
        while(j >= 0 && array[j] > temp){
            array[j+gap] = array[j];
            j -= gap;
            if(size != 1) count++;
        }
        array[j+gap] = temp;
    }
    return count;
}

int shellSort(int size, int array[size]){
    int count = 0;
    int m;
    for(int i = 1; (pow(3,i)-1)/2 <= size; i++)
        m = i;
    int gap[m]; //Pratt 1971 Gap sequence
    for(int i = m; i > 0; i--)
        gap[i-1] = (pow(3,i)-1)/2;
    printf("%d\n", m);
    for(int i = m-1; i >= 0; i--){
        if(size >= gap[i] || gap[i] == 1){
            count = insertion_sort(size, array, gap[i], count);
            if(i != 0)
                printf("%d ", gap[i]);
            else
                printf("%d\n", gap[i]);
        }
    }
    return count;
}

void printArray(int array[], int count){
    for(int i = 0; i < count; i++){
        printf("%d\n", array[i]);
    }
}



Measured memory_bytes: 5800
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
using pii = pair<int, int>;
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
//manip
template<class T> bool chmax(T &a, T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, T &b) {if (a > b) {a = b; return 1;} return 0;}
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power(T a, T b)
{return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
#define brep(i, n) for (int i = n - 1; i >= 0; --i)
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())

/*
 n = 2を考える
 k = 1
 
 2 0
 0 1
 
 k = 2
 操作するとともにk減らしてく
 k = 1で2 0にくるようにすればいい
 
 1 2
 2 0
 0 1
 
 これを続ける
 ただし、n = 2を採用するとai ≤ 10^16 + 1000を満たさない
 
 n = 50に拡張するだけ
 
 */
int main() {
    //cast caution
    //look constraints always
    cin.tie(0); ios::sync_with_stdio(false);
    ll K; cin >> K;
    int n = 50;
    cout << n << endl;
    int table[50][50] = {0};
    rep(j, 50) table[0][j] = j;
    rrep(i, 1, 50) {
        int key = -1, val = inf;
        rep(j, 50) {
            if (table[i - 1][j] < val) {
                key = j; val = table[i - 1][j];
            }
        }
        rep(j, 50) {
            if (j == key) table[i][j] = table[i - 1][j] + n;
            else table[i][j] = table[i - 1][j] - 1;
        }
    }
    //rep(i, 50) {rep(j, 50) cout << table[i][j] << " "; cout << endl;}
    if (K < 50) {rep(j, 50) cout << table[K][j] << " "; cout << endl;}
    else {
        rep(j, 50) {if (j) cout << " ";
            ll k = K - j;
            ll b = k / n;
            if (k % n) {b = (k + (n - 1)) / n + n - k % n;}
            cout << b;}
        cout << endl;
    }
}





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

int main(){
    long a, b;
    long d, r;
    double f;

    cin >> a >> b;
    d = a/b;
    r = a%b;
    f = a*1.0/b;

    cout << d << " " << r << " " << fixed << setprecision(6)<< f << endl;

    return 0;
}

Measured memory_bytes: 3268
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
#include<sstream>

using namespace std;
 
int main(){
 
int N; 
  
cin>>N;
  
int P[N];
  for(int i = 0; i < N; i++)
    cin>>P[i];

int min = 200001;
int sum = 0;
  
 for(int i = 0; i < N; i++){
   if(min > P[i]){
     min = P[i];
     sum++;   
   }
 }
  
cout << sum << endl;
 
}

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

std::vector<unsigned> gaps;

unsigned insertion_sort(unsigned a[], unsigned n, unsigned gap = 1){
  unsigned count = 0;
  for(unsigned i = gap; i < n; i++){
    unsigned v = a[i];
    int j = i - gap;
    while(j >= 0 && a[j] > v){
      a[j+gap] = a[j];
      j -= gap;
      count++;
    }
    a[j+gap] = v;
  }
  return count;
}

void make_gap_table(unsigned n){
  unsigned h = 1;
  unsigned i = 1;
  while(h <= n){
    gaps.push_back(h);
    h = pow(4,i) + 3*pow(2,i-1) + 1;
    i++;
  }
  std::reverse(gaps.begin(),gaps.end());
}

void shell_sort(unsigned a[], unsigned n){
  make_gap_table(n);
  unsigned count = 0;
  for(auto const &v : gaps){
    count += insertion_sort(a,n,v);
  }

  std::cout << gaps.size() << '\n';

  for(int i=0;i<gaps.size()-1;i++){
    std::cout << gaps[i] << ' ';
  }
  std::cout << gaps[gaps.size()-1] << '\n';

  std::cout << count << '\n';
}

int main(){
  unsigned n;
  unsigned buf;
  std::vector<unsigned> a;
  std::cin >> n;
  for(unsigned i = 0; i < n; i++){
    std::cin >> buf;
    a.push_back(buf);
  }

  shell_sort(a.data(),a.size());
  for(auto &v : a){
    std::cout << v << '\n';
  }
}

Measured memory_bytes: 5932
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


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

int main(void) {
	int n, k, i, a[100003], agcd, amax;

	scanf("%d%d", &n, &k);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	agcd = 0;
	amax = 0;
	for (i = 0; i < n; i++) {
		agcd = gcd(agcd, a[i]);
		amax = max(amax, a[i]);
	}

	if (k% agcd == 0 && k <= amax) {
		printf("POSSIBLE\n");
	}
	else {
		printf("IMPOSSIBLE\n");
	}

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
#define NIL -1
  
struct Node{int p,l,r;};
Node T[MAX];
int n,D[MAX];

void print(int u){
  int i,c;
  cout<<"node "<<u<<": ";
  cout<<"parent = "<<T[u].p<<", ";
  cout<<"depth = "<<D[u]<<", ";
  
  if(T[u].p==NIL) cout<<"root, ";
  else if(T[u].l==NIL) cout<<"leaf, ";
  else cout<<"internal node, ";
  
  cout<<"[";
  
  for (i = 0,c= T[u].l; c!= NIL; i++,c=T[c].r){
    if (i) cout<<", ";
    cout<<c;
  }
  cout<<"]"<<endl;
}

int rec(int u, int p){
  D[u]=p;
  if(T[u].r !=NIL) rec (T[u].r,p);
  if(T[u].l !=NIL) rec (T[u].l,p+1);
}

int main() {
  int i,j,d,v,c,l,r;
  cin >>n;
  for( i=0;i<n;i++){
    T[i].p=T[i].l=T[i].r=NIL;
  }
  for ( i=0;i<n;i++){
      cin >>v>>d;
      for(j=0;j<d;j++){
        cin>>c;
        if(j==0) T[v].l=c;
        else T[l].r=c;
        l=c;
        T[c].p=v;
      }
  }
  for(i=0;i<n;i++){
      if(T[i].p==NIL) r=i;
    }
    rec(r,0);
    for(i=0;i<n;i++) print(i);
  
     return 0;
}



 


Measured memory_bytes: 7680
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;


signed main(){
    int h;
    int w;

    while(1){
        std::cin >> h;
        std::cin >> w;

        if (h==0 & w == 0){
            break;
        }

        for(auto i = 0; i < h; i++){
            for(auto j = 0; j < w; j++){
                std::cout << "#";
            }
            std::cout << "" << std::endl;
        }
        std::cout << "" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define re register
#define ull unsigned long long
std::unordered_map<ull,int>mp[1000100];
const ull bs=19260817;
char ss[2001000],*s1[200100];
int len[200100],pp[200100],bl[1001000];
inline bool cmp(re int a,re int b){return len[a]<len[b];}
int main()
{
	re int n;
	scanf("%d",&n);
	s1[1]=ss;
	for(re int i=1;i<=n;i++)
	{
		scanf("%s",s1[i]+1);
		len[i]=strlen(s1[i]+1);
		pp[i]=i;
		s1[i+1]=s1[i]+len[i]+3;
	}
	std::sort(pp+1,pp+n+1,cmp);
	re long long ans=0;
	for(re int i=1;i<=n;i++)
	{
		re int x=pp[i];
		re int b1=0;
		for(re int i1=1;i1<=len[x];i1++)
		{
			b1|=1<<(s1[x][i1]-'a');
			bl[i1]=b1;
		}
		re ull hs=0;
		for(re int i1=len[x];i1>=1;i1--)
		{
			re int xx=mp[len[x]-i1][hs];
			ans+=__builtin_popcount(bl[i1]&xx);
			if(i1!=1)hs=hs*bs+(s1[x][i1]-'a');
		}
		mp[len[x]-1][hs]|=1<<(s1[x][1]-'a');
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 124472
N = int(input())
S = (input())
sum_count = 0
RGB_counter = [0,0,0]
total_pattern = 0


for i in range(3):
    if S[N-i-1] == "R":
        RGB_counter[0] += 1
    elif S[N-i-1] == "G":
        RGB_counter[1] += 1
    else:
        RGB_counter[2] += 1



for i in range(N-3):
    if S[N-i-4] == "R":
        RGB_counter[0] += 1
        if min(RGB_counter) == 0:
            pass
        else:
            total_pattern = RGB_counter[1] * RGB_counter[2]
 
            for j in range((i + 3) // 2):
                if (S[N-i-4+(j+1)] == "B" and S[N-i-4+2*(j+1)] == "G") or (S[N-i-4+(j+1)] == "G" and S[N-i-4+2*(j+1)] == "B"):
                    total_pattern -= 1
    elif S[N-i-4] == "G":
        RGB_counter[1] += 1
        if min(RGB_counter) == 0:
            pass
        else:
            total_pattern = RGB_counter[0] * RGB_counter[2]

            for j in range((i + 3) // 2):
                if (S[N-i-4+(j+1)] == "R" and S[N-i-4+2*(j+1)] == "B") or (S[N-i-4+(j+1)] == "B" and S[N-i-4+2*(j+1)] == "R"):
                    total_pattern -= 1
    else:
        RGB_counter[2] += 1
        if min(RGB_counter) == 0:
            pass
        else:
            total_pattern = RGB_counter[0] * RGB_counter[1]

            for j in range((i + 3) // 2):
                if (S[N-i-4+(j+1)] == "R" and S[N-i-4+2*(j+1)] == "G") or (S[N-i-4+(j+1)] == "G" and S[N-i-4+2*(j+1)] == "R"):
                    total_pattern -= 1  
    sum_count += total_pattern

print(sum_count)        

Measured memory_bytes: 9348
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int not_mon_sat_prime[3000001];//initialized to zero

int is_mon_sat(int num)
{
    if(num % 7 == 1 || num % 7 == 6){
        return 1;
    }else{
        return 0;
    }
}


int next_mon_sat(int num)
{
    num++;
    for(; !is_mon_sat(num); num++) ;

    return num;
}

void mon_sat_prime(int num)
{
    int i;
    int limit = sqrt(num);

    not_mon_sat_prime[1] = 1;

    for(i = 2; i <= num; i++){//mon_sat number is 0 others are 1
        if(!is_mon_sat(i)){
            not_mon_sat_prime[i] = 1;
        }
    }

    for(i = 6; i <= limit; i = next_mon_sat(i)){
        int j;
        for(j = 2; j <= num / i; j++){
            not_mon_sat_prime[i * j] = 1;//not a mon_sat_prime number
        }
    }

}

int main(void)
{
    mon_sat_prime(3000000);

    while(1){
        int num;
        int i;

        scanf("%d", &num);

        if(num == 1)
            break;

        printf("%d:", num);

        for(i = 1; i <= num; i++){
            if(!not_mon_sat_prime[i] && num % i == 0){
                printf(" %d", i);
            }
        }

        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 12316
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#define ll long long
using namespace std;



int main(){
  ll N,A,B,ans;
  cin>>N>>A>>B;
  ll c;
  c=A+B;
  ans=A*(N/c);
  ans+=min(N%c,A);

  cout<<ans<<endl;
 


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int A, B, C;
    cin >> A >> B >> C;

    cout << MAX(0, C - A + B) << "\n";

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
using namespace std;
#define ll long long
#define int ll
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define TOAD
#ifdef TOAD
#define bug(x) cerr<<__LINE__<<": "<<#x<<" is "<<x<<endl
#define IOS() 
#else
#define bug(...)
#define IOS() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#endif
const ll inf = 1ll<<60;
const int iinf=2147483647;
const ll mod = 1e9+7;
signed main (){
  IOS();
  int n; cin>>n;
  vector<int> vc(n);
  int xr=0;
  REP(i,n) cin>>vc[i];
  REP(i,n) xr^=vc[i];
  if (xr==0) cout<<"Yes\n";
  else cout<<"No\n";

}

Measured memory_bytes: 1024
#include<cstdio>
using namespace std;
int main()
{
    int n,t,x,y;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&t,&x,&y);
        if(x+y>t)
        {
            printf("No\n");
            return 0;
        }
        if((x+y)%2==0&&t%2==1)
        {
            printf("No\n");
            return 0;
        }
        if((x+y)%2==1&&t%2==0)
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> x(N), y(N), h(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> h[i];
  }

  // [0, 100] に座標があるので MAX を定義すると楽
  int MAX = 100;

  // y -> x 縦横にすると配列の順番に合うので扱いやすい
  for (int posY = 0; posY <= MAX; posY++) {
    for (int posX = 0; posX <= MAX; posX++) {
      // 頂上がどれくらいの高さであってほしいか
      // -1はまだよくわからないとき, 0以上は確定しているとき
      // -2はダメだとわかったとき
      int needH = -1;

      for (int i = 0; i < N; i++) {
        if (h[i] > 0) {
          // この頂点から見て, 頂上が posX, posY の時に
          // どれくらいの高さがあってほしいか求める
          int tmp = h[i] + abs(posY - y[i]) + abs(posX - x[i]);
          if (needH == -1) {
            needH = tmp;
          } else if (needH != tmp) {
            needH = -2;
            break;
          }
        }
      }
      // ダメだったら別の場所を探す
      if (needH == -2) continue;

      for (int i = 0; i < N; i++) {
        // 高さが0の場合に矛盾していないか調べる
        if (h[i] == 0) {
          int dist = abs(posY - y[i]) + abs(posX - x[i]);
          if (needH > dist) {
            needH = -2;
            break;
          }
        }
      }

      // ダメだったら別の場所を探す
      if (needH == -2) continue;

      cout << posX << " " << posY << " " << needH << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 500
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
        	int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int d = sc.nextInt();
            int e = sc.nextInt();
            if((e <= c && c <= a - e) && (e <= d && d <= b - e)) { 
            	System.out.println("Yes");
            }else {
            	System.out.println("No");
            }
        }
    }
}



Measured memory_bytes: 26264
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
	ll A,B;cin>>A>>B;
	ll a[4]={0,A-1,1,(A-1)^1},b[4]={0,B,1,B^1},ans=a[A%4]^b[(B+1)%4];
	cout<<ans;
}

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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> p;

int main(){
	string s;
	cin>>s;
	s[5]=' ';
	s[13]=' ';
	cout<<s<<endl;
}
	 


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

public class Main{

     public static void main(String []args){
       Scanner scanner = new Scanner(System.in);
       int n1 = 0;
       int n2 = 0;
      
       
       for(int i=0;i<3;i++) 
       {
           int temp=scanner.nextInt();
           if(temp==5)
           n1++;
           else if(temp==7)
           n2++;
       }
       
       if(n1==2 && n2==1)
       System.out.println("YES");
       else System.out.println("NO");
       
       
     }
}

Measured memory_bytes: 35632
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

////////////////////////////////////////////////////////////////////////

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val S = sc.next()
        pw.println(S.replace(",", " "))
    }
}


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

//104025503物理系林彥彤 

int main(int argc, char *argv[]) 
{
	int dataNum, i, j, k, npos1[50], npos2[50], output[50][100]={}, temp[1], temp1[1], temp2=0, digit[50]={}, flag;
	char num1[50][100]={}, num2[50][100]={};
	
	while(scanf("%d", &dataNum) != EOF) 
	{
		for(i=0;i<=49;i++)
		{
			for(j=0;j<=99;j++)
			{
				output[i][j]=0;
				num1[i][j]='0';
				num2[i][j]='0';
			}
		}
		temp2=0;
		
		for(i=0;i<=49;i++)
		{
			digit[i]=0;
			npos1[i]=0;
			npos2[i]=0;
		}
		
	    for(i=0;i<=dataNum-1;i++)
	    {
	    	scanf("%s %s",num1[i],num2[i]);
		}
		for(i=0;i<=dataNum-1;i++)
		{
			j=0;
			while(num1[i][j]!='\0')
			{
				npos1[i]=j;
				j++;
			}
			j=0;
			while(num2[i][j]!='\0')
			{
				npos2[i]=j;
				j++;
			}
		}
		for(i=0;i<=dataNum-1;i++)
		{
			
			for(j=npos1[i],k=npos2[i];(j>=-2) || (k>=-2);j--,k--)
			{
				if(npos1[i]>=npos2[i])
				{
					if(k<-2)
					{
						strcpy(temp1,"0");
					}
					else
					{
						temp1[0]=num2[i][k];
					
					}
					
					if(j<-2)
					{
						strcpy(temp,"0");
					}
					else
					{
						temp[0]=num1[i][j];
					}

					

					output[i][j+2]=(temp2+atoi(temp)+atoi(temp1))%10;
					temp2=(temp2+atoi(temp)+atoi(temp1))/10;
					digit[i]++;
				}
				else
				{
					if(k<-2)
					{
						strcpy(temp1,"0");
					}
					else
					{
						temp1[0]=num2[i][k];
					
					}
					
					if(j<-2)
					{
						strcpy(temp,"0");
					}
					else
					{
						temp[0]=num1[i][j];
					}

					

					output[i][k+2]=(temp2+atoi(temp)+atoi(temp1))%10;
					temp2=(temp2+atoi(temp)+atoi(temp1))/10;
					digit[i]++;
				}

			}

		}
		

		
		for(i=0;i<=dataNum-1;i++)
	    {
	    	flag=0;
			if(output[i][1]!=0)
			{	
				digit[i]++;
				flag=1;
			}
	    	if((digit[i]-2)>80 || strlen(num1[i])>80 || strlen(num2[i])>80)
	    	{
	    		printf("overflow\n");
	    		
			}
			else
			{
				if(flag==1)
				{
					for(j=1;j<=digit[i]-2;j++)
		    		{
		    			printf("%d",output[i][j]);	
					}
		    		printf("\n");					
				}
				else
				{
					for(j=2;j<=digit[i]-1;j++)
		    		{
		    			printf("%d",output[i][j]);	
					}
		    		printf("\n");	
				}
			}

		}
	
	}
	
	return 0;
}




Measured memory_bytes: 2024
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,s=1e9,a;
main(){
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>a;
    s=min(s,a);
    m-=a;
  }
  cout<<n+m/s<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sci(n)               scanf("%d",&n)
#define scl(n)               scanf("%lld",&n)
#define scd(n)               scanf("%lf",&n)
#define FOR(i,n)             for(ll i=1;i<=n;i++)
#define LOOP(i,n)            for(ll i=0;i<n;i++)
#define loop(a,b)            for(ll i=a;i<=b;i++)
#define ll long long
struct Node
{
    ll u,cost;
    Node(ll _u,ll _cost)
    {
        u=_u;
        cost=_cost;
        //cout << "X" << endl;
    }
};
bool operator<(Node A,Node B)
{
    return A.cost>B.cost;
}
priority_queue<Node>PQ;
ll dist[100005];
vector<ll>graph[100005];
ll nodes,edges,s;
vector<ll>cost[100005];
//cout << "Y" << endl;
void dijkstra(ll s)
{
    //cout << "Z" << endl;
    for(ll i=0;i<nodes;i++)
    {
        dist[i]=10000000000;
    }
    //cout << "Z" << endl;
    dist[s]=0;
    PQ.push(Node(s,0));
    while(!PQ.empty())
    {
        Node top=PQ.top();
        PQ.pop();
        ll u=top.u;
        for(ll i=0;i<graph[u].size();i++)
        {
            ll v=graph[u][i];
            if(dist[u]+cost[u][i]<dist[v])
            {
                dist[v]=dist[u]+cost[u][i];
                PQ.push(Node(v,dist[v]));
            }
        }
    }
    LOOP(i,nodes)
    {
        if(dist[i]==10000000000)
        {
            cout << "INF" << endl;
        }
        else
        {
            cout << dist[i] << endl;
        }
    }
}
int main()
{

    scl(nodes);
    scl(edges);
    scl(s);
    ll x,y,z;
    LOOP(i,edges)
    {
        scl(x);
        scl(y);
        scl(z);
        graph[x].push_back(y);
        //graph[y].push_back(x);
        cost[x].push_back(z);
        //cost[y].push_back(z);
    }
    dijkstra(s);
}





Measured memory_bytes: 23312
a = input()
n = len(a)
s = [[0, 0] for i in range(n+1)]
MOD1 = 3
MOD2 = 673
u = [[0 for i in range(MOD2)] for j in range(MOD1)]
ret = 0
c1 = pow(10, MOD1-2, MOD1)
c2 = pow(10, MOD2-2, MOD2)
for i in range(n):
    s[i+1] = [(s[i][0]*10+int(a[i]))%MOD1, (s[i][1]*10+int(a[i]))%MOD2]
    x, y = s[i][0]*pow(c1, i, MOD1)%MOD1, s[i][1]*pow(c2, i, MOD2)%MOD2
    u[x][y] += 1
    x, y = s[i+1][0]*pow(c1, i+1, MOD1)%MOD1, s[i+1][1]*pow(c2, i+1, MOD2)%MOD2
    ret += u[x][y]
print(ret)

Measured memory_bytes: 109168
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
    IO;
    int n;
    cin >> n;
    double sum = 0;
    for(int i = 0; i < n; i++)
    {
        double a;
        cin >> a;
        sum += 1/a;
    }
    cout << fixed << setprecision(12) << 1 / sum;
    return 0;
}


Measured memory_bytes: 256
//Deep Godhani
//DAIICT

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

#define N 100000000000
#define PI acos(-1)
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define ll long long int
#define ld long double
#define precision(x,d) cout << fixed << setprecision(d) << x
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))

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

const ll M = 1e9+7;

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

int main()
{
    FAST;
    ll t=1;
    //cin >> t;
    while(t--)
    {
      solve();
    }
		return 0;
}


Measured memory_bytes: 3640
#ifdef lolipop
#define _GLIBCXX_DEBUG
#endif

/*
    This ain't a milly rock
    This a money dance
    And my D' ain't hard
    That's a .30 in my pants
*/

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <ctime>
#include <map>
#include <random>
#include <iomanip>
#include <cmath>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <bitset>
#include <deque>
#include <utility>

#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ld long double

using namespace std;

// mt19937 rnd(time(nullptr));

inline void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

void solve() {
    int n;
    cin >> n;
    n %= 10;
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
        cout << "hon";
    } else if (n == 3) {
        cout << "bon";
    } else {
        cout << "pon";
    }
}

signed main() {
#ifdef lolipop
    freopen("input.txt", "r", stdin);
#else
    fastio();
#endif

    int T = 1;
//    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3100
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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


fn solve() {
    input!(
        n: usize,
        m: usize,
        uv: [[usize1; 2]; m],
        s: usize1,
        t: usize1,
    );

    let mut edge = Vec::new();
    edge.resize(n, Vec::new());

    for e in &uv {
        edge[e[0]].push(e[1]);
    }

    let mut vis = Vec::new();
    vis.resize(n, Vec::new());
    for i in 0..n {
        vis[i].resize(3, 0);
    }

    let mut qu: VecDeque<usize> = VecDeque::new();
    qu.push_back(s);

    vis[s][2] = 0;

    for cnt in 2..3*n+4 {
        if qu.len() == 0 {
            break;
        }
        let mut n_qu: VecDeque<usize> = VecDeque::new();
        let q_size = qu.len();
        for _ in 0..q_size {
            let front = qu.pop_front().unwrap();
            for x in &edge[front] {
                if vis[*x][(cnt+1)%3] > 0 {
                    continue;
                  }

                vis[*x][(cnt+1)%3] = cnt+1;

                n_qu.push_back(*x);
            }
        }
        qu = n_qu;
    }

    println!("{}", if vis[t][2] == 0 { -1 } else { vis[t][2] as i32 / 3 });
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 27004
N , M , C  = map(int,input().split())
B = list(map(int,input().split()))
count = 0
for _ in range(N):
	A = list(map(int,input().split()))
	temp = 0
	for i in range(M):		
		temp += A[i]*B[i]
	temp += C
	if temp > 0:
		count += 1

print(count)

Measured memory_bytes: 3064
def solve(n, k, H):
    dp = [0] * n
    dp[0] = 0
    for i in range(1, n):
        dp[i] = min(dp[i - j - 1] + abs(H[i] - H[i - j - 1]) for j in range(min(k, i)))
    return dp[n - 1]

_n, _k = map(int, input().split())
_H = list(map(int, input().split()))
print(solve(_n, _k, _H))


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        y >>= 1;
    }
    return res;
}

ll inv(ll n){
    return fast(n,mod-2);
}


void pre(){



}


void solve(){

    ll l,r,d;
    cin >> l >> r >> d;
    ll c=0;
    for(ll i=l;i<=r;i++){
        if(i%d==0){
            c++;
        }
    }
    cout << c;

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define debug(args...){string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
#define endl "\n"
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(NULL)
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> ii;

void err(istream_iterator<string> it){}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args){
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define maxn 100006

int n, h[maxn];
int dp[maxn];

int solve(){
  for(int i=1;i<n;i++){
      dp[i] = dp[i-1] +abs(h[i]-h[i-1]);
      if(i-2>=0){
          dp[i] = min(dp[i], dp[i-2] + abs(h[i]-h[i-2]));
      }
  }
  return dp[n-1];
}

int solve(int i){
  if(i==n-1)
    return dp[n-1] = 0;
  if(dp[i+1]==-1)
    solve(i+1);
  if(i+2<=n-1 && dp[i+2]==-1)
    solve(i+2);
  dp[i] = dp[i+1] + abs(h[i]-h[i+1]);
  if(i+2<=n-1)
    dp[i] = min(dp[i],dp[i+2]+abs(h[i]-h[i+2]));
  return dp[i];
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> h[i];
    dp[i] = -1;
  }
  cout << solve(0) << '\n';
  return 0;
}

Measured memory_bytes: 9056
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N; cin >> N;
		ULL SC, SB; SC = 0; SB = 0;
		vector<UL> A(N), B(N);
		rep(i, N) cin >> A[i];
		rep(i, N) cin >> B[i];
		rep(i, N) { SC += A[i]; SB += B[i]; }
		if (SB > SC) { cout << -1 << endl; return; }
		LL K = 0;
		vector<UL> Sp;
		UL ans = 0;
		rep(i, N) {
			if (A[i] < B[i]) { K += (B[i] - A[i]); ans++; }
			if (A[i] > B[i]) Sp.push_back(A[i] - B[i]);
		}
		sort(Sp.begin(), Sp.end());
		while (K > 0) {
			UL p = Sp.back(); Sp.pop_back();
			K -= p;
			ans++;
		}
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int h, w, cnt[26]{}, cnt2[3]{};
    bool used[105][105]{}, ok = true;;
    cin >> h >> w;
    REP(i,h){
        string a;
        cin >> a;
        REP(j,w){
            cnt[a[j]-'a']++;
        }
    }

    REP(i,(h-1)/2+1){
        REP(j,(w-1)/2+1){
            if(used[i][j])continue;
            int t=0;
            if(i!=h-i-1)t++;
            if(j!=w-j-1)t++;
            cnt2[t]++;
        }
    }

    REP(i,26){
        if(cnt[i]%2){
            if(cnt2[0]==0){
                ok = false;
                break;
            }
            cnt[i]--;
            cnt2[0]--;
        }
    }
    REP(i,26){
        if(cnt[i]%4){
            if(cnt2[1]==0){
                ok = false;
                break;
            }
            cnt[i]-=2;
            cnt2[1]--;
        }
    }

    cout << (ok?"Yes":"No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repe(i,n) for(int i=0;i<n;i++)
#define repa(i,j,n) for(int i=j;i<n;i++)
//#define v.all() v.begin(),v.end()
#define repr(i,n) for(int i=n;i>=0;i--)
#define int long long int
#define vi vector<int>
#define vpi vector<pair<int,int>>

signed  main(){
	int test=1;
	//cin>>test;
	rep(tt,test) {
		int n;
		cin>>n;
		int t=n*(n-1);
      	t/=2;
      cout<<t<<endl;
	}
	return 0;
}


Measured memory_bytes: 3568