akhauriyash/Code-Regression huggingface dataset:
def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod
    
def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

mod=10**9+7
n,k=map(int, input().split())
for i in range(1,k+1):
    if n-k+1<i:
        print(0)
    else:
        print((comb(k-1, i-1, mod)*comb(n-k+1, i, mod)) % mod)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebug(multimap<T1, T2> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mdebugr(map<T1, T2, greater<T1>> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebugr(multimap<T1, T2, greater<T1>> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n;
    string s1, s2;
    cin >> n >> s1 >> s2;

    int flg = 0;
    int start = 0;
    ll res = 1;
    ll mod = 1e9+7;
    if(s1[0] == s2[0]){
        res = 3;
        start = 1;
        flg |= 1<<0;
    }else{
        res = 6;
        start = 2;
        flg |= 1<<1;
    }
    int i = start;
    while(i <= n-1){
        if(s1[i] == s2[i]){
            if(flg & 1<<0){
                res *= 2;
            }else{
                flg &= ~(1<<1);
                flg |= 1<<0;
                res *= 1;
            }
        }else{
            if(flg & 1<<1){
                res *= 3;
            }else{
                flg &= ~(1<<0);
                flg |= 1<<1;
                res *= 2;
            }
            i++;
        }
        res %= mod;
        i++;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long gcd(long long a, long long b);
long long lcm(long long a, long long b);

int main()
{
    long long  a, b;
    
    while (cin >> a >> b) {
        if (a < b) {
            long long temp = a;
            a = b;
            b = temp;
        }
        
        cout << gcd(a, b) << " " << lcm(a, b) << endl;
    } 
    
    return 0;
}

long long gcd(long long a, long long b)
{
    long long r;

    while ((r = a % b) != 0) {
        a = b;
        b = r;
    }

    return b;
}

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

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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    rep(i, N) {
        cin >> vec[i];
    }
    int cnt = 0;
    while (true) {
        rep(i, N) {
            if (vec[i] % 2 != 0) {
                cout << cnt << endl;
                return 0;
            }
            vec[i] = vec[i] / 2;
        }
        cnt += 1;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    static ContestScanner in;static Writer out;static StringBuilder sb=new StringBuilder();
    public static void main(String[] args)
    {try{in=new ContestScanner();out=new Writer();Main solve=new Main();solve.solve();
        in.close();out.flush();out.close();}catch(IOException e){e.printStackTrace();}}
    void solve() throws NumberFormatException, IOException{
        int a = in.nextInt();
        int b = in.nextInt();
        if (a >= 13) {
            System.out.println(b);
        } else if (a >= 6) {
            System.out.println(b / 2);
        } else {
            System.out.println(0);
        }
    }
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}

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

// See debug.cc for usage etc
#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif

ll N;
vector<ll> s;

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> N;
  s.resize(N);
  for (ll i = 0; i < N; i++)  cin >> s.at(i);
  ll answer = 0;
  for (ll t = 1; t <= (N-2)/2; t++) {
    ll lim;
    if ((N-1) % t == 0) {
      lim = ((N-1) / t - 1) / 2;
    }else {
      lim = (N-1) / t - 1;
    }
    ll sum = 0;
    for (ll i = 1; i <= lim; i++) {
      sum += s.at(i*t) + s.at(N-1 - i*t);
      DLOG("t = %lld, i = %lld, sum = %lld", t, i, sum);
      answer = max(answer, sum);
    }
  }
  cout << answer << endl;

  return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
	int i;
	char S[10];
	scanf("%s",S);
	if(S[0]=='Y'&&S[1]=='A'&&S[2]=='K'&&S[3]=='I'){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x)
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

     
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    //start from here

    readc(a, b, n);
    cout << min(b-1, n) * a / b;

    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <cmath>

int main(){
    int N,T,A;
    std::cin >> N >> T >> A;
    int H[1000];
    for(int i=0;i<N;i++) std::cin >> H[i];
    int b = 10000000;
    int out = 0;
    for(int i=0;i<N;i++){
        std::cerr << i << " " << b << " " << abs(A*1000-(T*1000-H[i]*6)) << std::endl;
        if(abs(A*1000-(T*1000-H[i]*6))<b){
            out = i+1;
            b = abs(A*1000-T*1000+H[i]*6);
        }
    }
    std::cout << out << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define pushb push_back()
#define popb pop_back()
#define makep make_pair
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv);
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v);
template<typename T> ll gcd(T a,T b);
template<typename T> ll lcm(T a,T b);

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


// union by size + path compression
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i){
            par[i] = i; // 初期では親は自分自身
        }    
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        if(par[x]==x){
            return x;
        }else{
            return par[x]=root(par[x]);
        }
        // while (par[x] != x) {
        //     x = par[x] = par[par[x]]; // x の親の親を x の親とする
        // }
        // return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    // bool find(ll x, ll y) { // 連結判定
    //     return root(x) == root(y);
    // }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};


int main(){
    ll n,m;cin>>n>>m;
    vector<int> a(m),b(m);
    rep(i,m){
        cin>>a[i]>>b[i];
    }
    UnionFind u(n+1);
    u.init(n+1);

    vector<ll> link(m),ans(m);
    link[0]=0;
    reverse(all(a));
    reverse(all(b));
    rep(i,m-1){
        ll ta=a[i];
        ll tb=b[i];
        // cout<<i<<endl;
        // cout<<ta<<tb<<endl;
        ll na=u.size(ta);
        ll nb=u.size(tb);
        // cout<<na<<nb<<endl;
        // cout<<u.root(ta)<<endl;
        if(u.root(ta)!=u.root(tb)){
            link[i+1]=link[i]+na*nb;
            u.merge(ta,tb);
            // cout<<'F'<<endl;
        }else{
            link[i+1]=link[i];
        }
        // cout<<link[i+1]<<endl;
    }
    // cout<<link<<endl;
    rep(i,m){
        ans[i]=n*(n-1)/2-link[i];
    }
    reverse(all(ans));
    rep(i,m){
        cout<<ans[i]<<endl;
    }

    return 0;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	int len = vv.size();
	for (int i = 0; i < len; ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}

Measured memory_bytes: 5248
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;


int main(void) {
	int n;
	cin >> n;
	vector<int> a(200001);
	for (int i = 0; i < n - 1;i++) {
		int x;
		cin >> x;
		a[x]++;
	}
	for (int i = 1; i <= n; i++) {
		cout << a[i] << '\n';
	}

}

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

int main(){
    vector<int> v(3);
    for(int i=0; i<3;i++){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    for(int i=0; i<3; i++){
        cout << v[i];
if(i <= 1){cout << " ";}
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3104
using System;
using System.Collections.Generic;
using System.Linq;

namespace _0011
{
    class Program
    {
        private static void Main()
        {
            var verticalLines = int.Parse(Console.ReadLine());
            var horizontalLines = int.Parse(Console.ReadLine());
            var numberPairList = new List<int>();
            for (var i = 0; i < horizontalLines; i++)
            {
                var numberPair = Console.ReadLine().Split(',').Select(int.Parse).ToList();
                numberPairList.AddRange(numberPair);
            }
            var swapNumberList = numberPairList.GetEnumerator();

            var verticalNumbers = new int[verticalLines];
            Numbering(ref verticalNumbers);

            while (swapNumberList.MoveNext())
            {
                var leftNumber = swapNumberList.Current - 1;
                swapNumberList.MoveNext();
                var rightNumber = swapNumberList.Current - 1;
                Swap(ref verticalNumbers[leftNumber], ref verticalNumbers[rightNumber]);
            }

            foreach (var verticalNumber in verticalNumbers)
            {
                Console.WriteLine(verticalNumber);
            }
        }

        private static void Swap<T>(ref T leftHandSide, ref T rightHandSide)
        {
            var temp = leftHandSide;
            leftHandSide = rightHandSide;
            rightHandSide = temp;
        }

        private static void Numbering(ref int[] lines)
        {
            var number = 1;
            for (var i = 0; i < lines.Length; i++, number++)
            {
                lines[i] = number;
            }
        }
    }
}

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

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

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

    ll pre[n + 1] = {0};
    for (int i = 1; i <= n; i++) {
        ll num;
        scanf("%lld", &num);
        pre[i] = pre[i - 1] + num;
    }

    // for (int i = 0; i <= n; i++)
    //  printf("%d %d\n", i, pre[i]);

    map<ll, int> cnt;
    ll ans = 0;
    for (int j = 0; j <= n; j++) {
        if (j - k >= 0)
            cnt[(pre[j - k] - (j - k) + k) % k]--;

        ans += cnt[(pre[j] - j + k) % k];

        cnt[(pre[j] - j + k) % k]++;

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

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main(){
  int n;
  ll ans = 0;
  cin >> n;
  
  for(int i = 1; i <=n; i++){
    if (i%3 == 0 || i%5 == 0) continue;
    else ans += i;
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 3592
#include <stdio.h>

int main(void)
{
	int age;
  	scanf("%d",&age);
  	if (age == 3 || age == 5 || age == 7)
    {
    	printf("YES");
    }
  	else
    {
    	printf("NO");
    }  
  	
  	return 0;
}  

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

int N,M;
string S;
vector<int>a;

inline int conv(int k){
    return k/10+k%10;
}

int memo[100000][10];
int calc(int keta,int amari){
    if(keta==N)return amari==0;
    if(~memo[keta][amari])return memo[keta][amari];
    int ret=0;
    if(S[keta]!='*'){
        int val=S[keta]-'0';
        if((keta+N)%2==0)val*=2;
        ret+=calc(keta+1,(amari+conv(val))%10);
    }
    else{
        for(int i=0;i<M;i++){
            int val=a[i];
            if((keta+N)%2==0)val*=2;
            ret+=calc(keta+1,(amari+conv(val))%10);
        }
    }

    return memo[keta][amari]=ret;
}

int main(){
    cin>>N>>S>>M;
    a.resize(M);
    for(int i=0;i<M;i++)cin>>a[i];
    memset(memo,-1,sizeof(memo));
    cout<<calc(0,0)<<endl;
    return 0;
}

Measured memory_bytes: 13060
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;

string s;

int main(){
	cin>>s;
	bool ok=1;
	if((int)s.size()%2==1){
		cout<<"No\n";
		return 0;
	}
	for(int i=0;i<s.size();i++){
		if(i%2==0&&s[i]!='h') ok=0;
		if(i%2==1&&s[i]!='i') ok=0;
	}
	if(ok) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
a,b = gets.strip.chomp.split(" ").map(&:to_i)
#c = b - (a-1)
c = []
(1..a-1).reverse_each do |i|
  c << (b - i)
end
(0..a-1).each do |i|
  c << (b + i)
end
puts c.uniq.join(" ")

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) {cout << x[i] << " "; cout << endl;}
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    map<int,int> mp;
    rep(i,n) {
        int x; cin >> x;
        mp[x]++;
    }
    if (n % 3 != 0) {
        if (mp[0] != n) cout << "No" << endl;
        else cout << "Yes" << endl;
    } else {
        if (mp.size() > 3) cout << "No" << endl;
        else if (mp.size() == 3) {
            bool ok = true;
            int x = 0;
            for (P p : mp) {
                x ^= p.first;
                if (p.second != n/3) ok = false;
            }
            if (ok && x == 0) cout << "Yes" << endl;
            else cout << "No" << endl;
        } 
        else if (mp.size() == 1) {
            if (mp[0] == n) cout << "Yes" << endl;
            else cout << "No" << endl;
        } else {
            bool ok = true;
            for (P p : mp) {
                if (p.first == 0 && p.second != n/3) ok = false; 
                if (p.first != 0 && p.second != (n/3)*2) ok = false;
            }
            if (ok) cout << "Yes" << endl;
            else cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 7144
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
 
int main(){
    int n,x[100], y[100];
    cin>>n;
    for(int i=0; i<n; i++)cin>> x[i];
    for(int i=0; i<n; i++)cin >> y[i];
     
    double d[4];
    for(int i=0;i<4; i++) d[i]=0.0;
     
    for(int p=1; p<=3; p++){
        for(int i=0; i<n; i++){
            d[p] += pow(fabs(x[i] - y[i]), p);
        }
        d[p] = pow(d[p], 1.0/p);
    }
     
    for(int i=0; i<n; i++){
        d[0]= (d[0]<fabs(x[i]-y[i])?fabs(x[i]-y[i]):d[0]);
    }
     
    printf("%lf\n",d[1]);
    printf("%lf\n",d[2]);
    printf("%lf\n",d[3]);
    printf("%lf\n",d[0]);
     
    return 0;
}


Measured memory_bytes: 3356
#coding:utf-8
#1_7_A
class Node():
    def __init__(self, node_id, children):
        self.node_id = node_id
        self.parent = -1
        self.depth = 0
        self.typ = "root"
        self.children = children

    def set_child(self, child):
        """ Overwrite child's attribute """
        child.parent = self.node_id
        child.depth = self.depth + 1
        if child.children:
            child.typ = "internal node"
        else:
            child.typ = "leaf"

    def set_children(self, tree):
        """ Repeat set_child starting from root node """
        stack = []
        stack.append(self.node_id)

        while stack:
            node = tree[stack.pop()]
            for child_id in node.children:
                node.set_child(tree[child_id])
            stack.extend(node.children)

n = int(input())
tree = [None for i in range(n)]
children = []
for i in range(n):
    info = list(map(int, input().split()))
    tree[info[0]] = Node(info[0], info[2:])
    children.extend(info[2:])

root_id = (set([x for x in range(n)]) - set(children)).pop()

tree[root_id].set_children(tree)

for node in tree:
    print("node {}: parent = {}, depth = {}, {}, {}".format(node.node_id, node.parent, node.depth, node.typ, node.children))

Measured memory_bytes: 62856
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define ss(x) (int) x.size()
#define pb push_back
#define ll long long
#define cat(x) cerr << #x << " = " << x << endl
#define FOR(i, n) for(int i = 0; i < n; ++i)

using namespace std;	

int n, mod;
	
int dp[5011][5011];	

int wsp[5011];
			
int main() {
	scanf("%d %d", &n, &mod);
	int k = (n + 1) / 2;
	
	for(int i = 1; i <= n; ++i) {
		if(i <= k)
			wsp[i] = i - 1;
		else if(n - i + 1 < k)
			wsp[i] = n - i + 2;
		else
			wsp[i] = k;
	}
	
	int ans = 0;
	dp[1][0] = 1;
	for(int i = 2; i <= n; ++i) 
		for(int sum = 0; sum <= n; ++sum) 
			for(int x = 0; x <= sum / wsp[i]; ++x) 
				dp[i][sum] = (dp[i][sum] + dp[i - 1][sum - x * wsp[i]]) % mod;
	
	for(int sum = 0; sum <= n; ++sum) {
		ans = (ans + 1ll * (n - sum) * dp[n][sum]) % mod;
	}
	printf("%d\n", ans);	
	
	
	return 0;
}



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

#define MAXN 100010
#define ll long long
#define mod 1000000007

using namespace std;

int n, tot, ans;

int a[MAXN];

string s;

int main() {
	int t;
	cin >> t;
	printf("%.6lf", (double)(t/3.0 * t/3.0 * (double)(t - t/3.0 * 2)));
	return 0;
}

Measured memory_bytes: 256
lst = []
for _ in range(int(input())):
    lst.append(int(input()))

n = sum(lst)
if sum(lst) % 10 != 0:
    print(n)
else:
    ret = 0
    for i in range(len(lst)):
        a = n - lst[i]
        if a % 10 != 0:
            ret = max(ret, a)
    print(ret)


Measured memory_bytes: 3060
//LETS START AGAIN
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define F first 
#define S second
#define int long long int
const int N = 81;
int dp[N][N][N*N];
int a[N][N];
int b[N][N];
int h,w;
int solve(int i,int j,int diff)
{
    if(i == h && j == w)
    {
        int ans = 1e18;
        int d = a[i][j]-b[i][j];
        ans = min(ans,abs(d+diff));
        ans = min(ans,abs(d-diff));
        return ans;  
    }
    if(i<1 || i>h || j<1 || j>w || diff>=(N*N))
        return 1e18;
    if(dp[i][j][diff]!=-1)
        return dp[i][j][diff];
    int ans = 1e18;
    int d = a[i][j]-b[i][j];
    ans = min(ans,solve(i+1,j,abs(diff-d)));
    ans = min(ans,solve(i+1,j,abs(diff+d)));
    ans = min(ans,solve(i,j+1,abs(diff-d)));
    ans = min(ans,solve(i,j+1,abs(diff+d)));
    dp[i][j][diff] = ans;
    return dp[i][j][diff];
}
signed main() 
{ 
    fast;
    cin>>h>>w;
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
            cin>>a[i][j];
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
            cin>>b[i][j];
    cout<<solve(1,1,0);
} 



Measured memory_bytes: 336640
from sys import exit
from collections import defaultdict
n,x = open(0).read().split()
n = int(n)
cnt = x.count('1') 
digits = list(map(int, list(x)))
x = int(x, 2)

d = defaultdict(int)
d[0] = 0
def calc(m):
    if m not in d:
        nxt = m % bin(m).count('1')
        d[m] = calc(nxt) + 1
    return d[m]

if n == 1:
    print(calc(x^1))
    exit()

mmod = cnt - 1
pmod = cnt + 1

if mmod > 0:
    mx = x % mmod
px = x % pmod

mbase = 1
pbase = 1

ans = []
while digits:
    digit = digits.pop()
    
    if digit and mmod <= 0:
        ans.append(0)
    else:
        if digit:
            nx = (mx - mbase)%mmod
        else:
            nx = (px + pbase)%pmod
        ans.append(calc(nx) + 1)

    if mmod > 0:
        mbase = (mbase * 2) % mmod
    pbase = (pbase * 2) % pmod

while ans:
    print(ans.pop())

Measured memory_bytes: 101320
#if defined(LOCAL)
#define PROBLEM_NAME "b"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) debug(x)
#else
#define L(x, ...) (x)
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)

#if defined(LOCAL)
#define L(x...) debug(x)
#else
#define L(x, ...) (x)
#endif

void solve(istream& cin, ostream& cout) {
  l k;
  while (cin >> k) {
    l n = 50;
    vl v(n);
    F(i, 0, n) v[i] = n - i - 1;
    F(i, 0, n) v[i] += k / n;
    F(i, 0, k % n) v[i]++;
    cout << n << lf;
    F(i, 0, n) {
      if (i) cout << ' ';
      cout << v[i];
    }
    cout << lf;
  }
}

bool solution_checker(istream& input, istream& /* expected */,
                      istream& actual, ostream& out) {
  l k;
  while (input >> k) {
    l n; actual >> n;
    l a, b; actual >> a >> b;
    if (a > b) swap(a, b);
    l t = 0;
    while (b >= n) {
      b -= n;
      a++;
      if (a > b) swap(a, b);
      t++;
    }
    if (k != t) {
      out << k << " <> " << t << endl;
      return false;
    }
  }
  return true;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1000;
struct node
{
	int x,y;
	double d;
}e[maxn];
bool cmp(node a,node b)
{
	return a.d<b.d;
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>e[i].x>>e[i].y;
		e[i].d=atan2(e[i].y*1.0,e[i].x*1.0);
	}
	int nxt[1000];
	for(int i=0;i<n-1;i++)
		nxt[i]=i+1;
	nxt[n-1]=0;
//	for(int i=0;i<n;i++)
//		cout<<nxt[i]<<' ';
	sort(e,e+n,cmp);
	ll ans=0;
	for(int i=0;i<n;i++)
	{
		ll dx=e[i].x,dy=e[i].y;
		ans=max(ans,(ll)dx*dx+dy*dy);
		for(int j=nxt[i];j!=i;j=nxt[j])
		{
			dx=dx+e[j].x;dy=dy+e[j].y;
			ans=max(ans,(ll)dx*dx+dy*dy);
		}
	}
	printf("%.15lf",sqrt(ans)); 
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
 /* #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
//ll  t;cin>>t;while(t--)
{
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max(a*b,c*d)<<endl;

}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std ;
int main () {

int a , b ;
cin >> a >> b;

 if (a+b<(a*b) && (a-b)< a*b ){
        cout << a*b;
}
else if (a+b > (a-b)){
    cout << a+b ;
}
else if (a-b > (a+b)){
    cout << a-b ;
}
else if ((a+b)> a*b){
    cout << a+b;
}
else if ((a-b)> a*b){
    cout << a-b;
}

else {
    cout << a*b;
}

return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    long long n,min=1000000,max=-1000000,sum=0;
    cin >> n;

    long long a[n];

    for(int i=0;i<n;i++){
        cin >> a[i];
        
        if(min>a[i]){
            min = a[i];
        }
        if(max<a[i]){
            max = a[i];
        }
        sum = sum + a[i];
    }

    cout << min << " " << max << " " << sum << endl;
    return 0;

}


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

int main() {
    int H,W;
    int x,y;
    cin >> H >> W;
    vector<string> board(50);
    for(int i=0; i<H; i++){
        cin >> board.at(i);
    }

    vector<int> dx = {1,1,0,-1,-1,-1,0,1};
    vector<int> dy = {0,1,1,1,0,-1,-1,-1};

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(board.at(i).at(j) == '.'){
                int cnt = 0;
                for(int k=0; k<8; k++){
                    x = i + dx.at(k);
                    y = j + dy.at(k);
                    if(x >= 0 && x < H && y >= 0 && y < W && board.at(x).at(y) == '#'){
                        cnt++;
                    }
                }
                board.at(i).at(j) = cnt + '0';
            }
        }
        cout << board.at(i) << endl;
    }
}

Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int a = sc.nextInt();
        if (a%1000 == 0)
            System.out.println("0");
        else
            System.out.println(1000-(a%1000));

    }
}


Measured memory_bytes: 35792
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];
    int ans = 0;
    rep(i,n){
        if(i%2==0&&a[i]%2==1)ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	bool x[] = {true, true, true};
	x[a - 1] = false;
	x[b - 1] = false;

	rep(i, 3){
		if(x[i]) cout << i + 1;
	} 
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int ans=0;
  for(int i=1;i<N+1;i+=2){
    int sum=2;
    for(int j=2;j<i;j++){
      if(i%j==0)sum++;
    }
    if(sum==8)ans++;
  }
  cout << ans;
}






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

#define F first
#define S second
#define pb(x) push_back(x)
#define in(x) insert(x)
#define forr(i, a, b) for(int i = a;i <= b;i++)
#define sz(s) int(s.size())
#define ioi ios_base::sync_with_stdio(false)
#define all(x) x.begin(), x.end()
#define tie cin.tie(nullptr);cout.tie(nullptr);
#define int long long

using namespace std;

const int INF =  2147483646;
const int  N = 2e6 + 667;
int n;

vector <int> a;

void input(){
	cin >> n;
	for(int i = 0;i < n;i++){
		int t;
		cin >> t;
		a.pb(t);
	}
}

main() {
	//input();
	int n, m;
	cin >> n >> m;
	int ans = (n * (n - 1)) >> 1;;
	cout <<  (ans + ((m * (m - 1)) >> 1));
	return 0;
}
// (n * (n - 1)) >> 1;
//Coded by LoliThief


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);
using namespace std;
int main(){
	fast;
	char s;
	cin>>s;
	if(s=='A')cout<<'T';
	if(s=='T')cout<<'A';
	if(s=='G')cout<<'C';
	if(s=='C')cout<<'G';
	
}

Measured memory_bytes: 256
from math import *
x = 0
y = 0
a = 0

while True:
    l, r = [int(i) for i in input().split(",")]
    if l == 0 and r == 0:
        break
    
    x += l * sin(radians(a))
    y += l * cos(radians(a))
    
    a = (a+r)%360

print(int(x))
print(int(y))


Measured memory_bytes: 5724
import sys
sys.setrecursionlimit(10**9)
n,m = map(int,input().split())
graph = [[] for _ in range(n)]
for i in range(m):
  x,y = map(int,input().split())
  graph[x-1].append(y-1)
dp = [-1]*(n)
 
def dfs(i):
    if dp[i] != -1:
        return dp[i]
    else:
        res = 0
        for j in graph[i]:
            res = max(res,dfs(j)+1)
        dp[i] = res
        return dp[i]
 
for i in range(n):  
    dfs(i)
print(max(dp))

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

int main(void) {
	int X[5];
	int ans = 0;
	for (int i = 1; i <= 5; ++i) {
		cin >> X[i - 1];
		if (X[i - 1] == 0)
			ans = i;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3520
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int X,Y,A,B,C;
  cin >> X >> Y >> A >> B >> C;
  vector<int> P(A),Q(B),R(C);
  int i;
  for(i=0;i<A;i++)cin >> P[i];
  for(i=0;i<B;i++)cin >> Q[i];
  for(i=0;i<C;i++)cin >> R[i];
  sort(P.begin(),P.end(),greater<int>());
  sort(Q.begin(),Q.end(),greater<int>());
  for(i=0;i<X;i++)R.push_back(P[i]);
  for(i=0;i<Y;i++)R.push_back(Q[i]);
  sort(R.begin(),R.end(),greater<int>());
  long long ans = 0;
  for(i=0;i<X+Y;i++) {
    ans += R[i];
  }
  cout << ans << endl;
}

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

int main(){
  long long N, M;
  cin >> N >> M;
  vector<long long> yaku;
  for (long long i=1; i*i<=M; i++){
    if (M%i==0){
      yaku.push_back(i);
      if (i*i!=M){
        yaku.push_back(M/i);
      }
    }
  }
  sort(yaku.begin(), yaku.end(), greater<long long>());
  for (long long i: yaku){
    if ((M-N*i>=0)&&((M-N*i)%i==0)){
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
N = list(map(int, input().split()))

def is_1794(n):
    if 1 in n:
        if 7 in n:
            if 9 in n:
                if 4 in n:
                    return True
    return False

if(is_1794(N)):
    print("YES")
else:
    print("NO")

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

int main() {
  int n,m; cin>>n>>m;
  int p; string s; 
  
  vector<vector<string>> vec(n);
  int ac=0,pn=0;
  rep(i,m){
    cin>>p>>s;
    vec.at(p-1).push_back(s);}
  rep(i,n){
    int pni=0;
    rep(j,vec.at(i).size()){
      if(vec.at(i).at(j)=="WA"){pni++;}//ACできなかった問題のWAはノーカウント
      else{ac++;break;}
    }
    if(pni!=vec.at(i).size())pn+=pni;
  }
  cout<<ac<<" "<<pn;
}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll x; cin >> x;
  for (ll i = 1; i <= x; i++) {
    if (i * (i+1) / 2 >= x) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}



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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;

inline int updiv(int a,int b){ return (a + b - 1) / b; }
 
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};

signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    int n ,k;
    cin >> n >> k;

    vector<int> a(n);

    rep(i,n){
        cin >> a[i];
    }

    vector table(n+1, vector(64, 0));

    rep(i,n){
        table[i+1][0] = a[i];
    }

    for(int i = 0; i < 63; ++i){
        for(int j = 1; j <= n; ++j){
            table[j][i+1] = table[table[j][i]][i];
        }
    }

    int now = 1;
    for(int i = 0; i < 63; ++i){
        if(1ll << i & k){
            now = table[now][i];
        } 
    }

    cout << now << '\n';

    return (0);
}

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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  for(int i=0; i<N-1; i++){
    if(S[i]==S[i+1]){
      S[i]='0';
    }
  }
  int ans=0;
  for(int j=0; j<N; j++){
    if(S[j]!='0') ans++;
  }
  cout << ans;
  
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(void){
  int n,u,k,v[10000],i,j,Adj[1000][1000];

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      Adj[i][j]=0;
    }
  }
    
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v[k]);
    Adj[i][v[k]-1]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){  
    if(j==n-1)
      printf("%d\n",Adj[i][j]);
    else
     printf("%d ",Adj[i][j]);
  }
  }
  return 0;
}



Measured memory_bytes: 2116
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

W = read().rstrip()

N = len(W)

def Z_algorithm(S):
    # 共通接頭辞の長さを返す
    N=len(S)
    arr = [0]*N
    arr[0] = N
    i,j = 1,0
    while i<N:
        while i+j<N and S[j]==S[i+j]:
            j += 1
        arr[i]=j
        if not j:
            i += 1
            continue
        k = 1
        while i+k<N and k+arr[k]<j:
            arr[i+k] = arr[k]
            k += 1
        i += k; j -= k
    return arr

def is_periodic_left(W):
    Z = Z_algorithm(W)
    is_periodic = [False] * N
    for p in range(1,N//2 + 1):
        if is_periodic[p-1]:
            continue
        for i in range(p,N,p):
            if Z[i] >= p:
                is_periodic[p + i - 1] = True
            else:
                break
    return is_periodic

L = is_periodic_left(W)
R = is_periodic_left(W[::-1])[::-1]

if not L[-1]:
    answer = (1,1)
elif len(set(W)) == 1:
    answer = (N,1)
else:
    x = sum(not(x or y) for x,y in zip(L,R[1:]))
    answer = (2,x)
print('\n'.join(map(str,answer)))

Measured memory_bytes: 31588
/*
********************
Author : Sahil Kundu
********************
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mod 1000000007
#define pb(i) push_back(i)
#define f first
#define s second
#define mk(l,r) make_pair(l,r)
#define vi vector<int>
#define vl vector<ll>
#define vch vector<char>
#define all(vc) vc.begin(),vc.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ms(i,j) memset(i,j,sizeof i)
#define w(t) while(t--)
#define len(s) s.length()
#define rep(i,n) for(ll i=0;i<(n);++i)
#define repa(i,n) for(ll i=n;i>=0;i--)
#define repx(i,x,n) for(ll i=x;i<n;i++)
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define PI 3.14159265358979323846
#define fastIO ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
const ll MAX=1e5+5;
const ll INF=2e18;
int ans=0,l1,l2;
#define INPUT_OUTPUT {\
    freopen("input.txt","r",stdin);\
    freopen("output.txt","w",stdout);\
}

// logical code of program starts here.
void solve()
{
    ll n,m;
    cin>>n>>m;
    char mtx[n+1][m+1];
    rep(i,n)
    rep(j,m)cin>>mtx[i+1][j+1];
    ll dp[n+1][m+1];
    ms(dp,0);
    rep(i,n+1)
    rep(j,m+1)
    {
        if(i==0 or j==0)
            continue;
        if(mtx[i][j]=='#')
            dp[i][j]=0;
        else if(i==1 and j==1)
            dp[i][j]=1;
        else 
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
    }
    cout<<dp[n][m]<<endl;
}


// mian function 
int main()
{
    //INPUT_OUTPUT;//file handling
    fastIO;// fast input output
    clock_t start, end; 
    start = clock();
    int t;
    t=1;
    //cin>>t;
    w(t) solve();
    end = clock();   
    double time_taken = double(end - start)/double(CLOCKS_PER_SEC); 
    clog << "Time taken by program is : " << fixed 
    << time_taken << setprecision(5); 
    clog << " sec " << endl;
    return 0;
}

Measured memory_bytes: 12536
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
	double x, y, det;
	vector<double> a(3);
	vector<double> b(3);
	while(1)
	{
		for (int i = 0; i < 3; i++)
		{
			cin >> a[i];
		}
		for (int i = 0; i < 3; i++)
		{
			cin >> b[i];
		}
		if (cin.eof())
		{
			break;
		}
		det = a[0] * b[1] - a[1] * b[0];
		x = (b[1] * a[2] - b[2] * a[1]) / det + 0;
		y = (-a[2] * b[0] + a[0] * b[2]) / det + 0;
		cout << fixed << setprecision(3) << x << " " << y << endl;
	}
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define loop(i,a,b) for(int i=a; i<b; i++)
#define INF 10000000000099ll
#define mod 1000000007
#define MAX 1000
ll dp[MAX+1][MAX+1];

ll solve(int h, int w)
{
    for(int i=1; i<=w; i++){
        if(dp[1][i]==-1) break;
        dp[1][i]=1;
    }
    for(int i=1; i<=h; i++){
        if(dp[i][1]==-1) break;
        dp[i][1]=1;
    }
    for(int i=2; i<=h; i++){
        for(int j=2; j<=w; j++){
            if(dp[i][j]==-1) continue;
            if(dp[i-1][j]!=-1) {
                dp[i][j]= dp[i-1][j]%mod;
            }
            if(dp[i][j-1]!=-1){
                dp[i][j]= (dp[i][j] + dp[i][j-1])%mod;
            }
        }
    }
    return dp[h][w]%mod;
}

int main()
{
    FASTIO;
    int h,w;
    memset(dp, 0, sizeof dp);
    cin>>h>>w;
    char arr[h+1][w+1];
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cin>>arr[i][j];
            if(arr[i][j]=='#'){
                dp[i][j]= -1;
            }
        }
    }
    cout<<solve(h, w);
    return 0;
}




Measured memory_bytes: 12400
using System;

public class AtCoder
{
    public static void Main()
    {
        int n;
        n = int.Parse(Console.ReadLine().Trim());
        string s = "";
        if (n == 25) s = "Christmas";
        if (n == 24) s = "Christmas Eve";
        if (n == 23) s = "Christmas Eve Eve";
        if (n == 22) s = "Christmas Eve Eve Eve";
        Console.WriteLine(s);
    }
}


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    ll n;
    cin>>n;
    Array a(n);
    map<ll,ll> mp;
    REP(i,n){
        cin>>a[i];
        mp[a[i]]++;
    }
    int id=0;
    for(auto& i:mp){
        i.second = id;
        id++;
    }

    ll ans=0;
    REP(i,n){
        if(i%2!=mp[a[i]]%2) ans++;
    }
    cout<<ans/2<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 7296