akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var n     = int.Parse(spl[0]);
        var l     = int.Parse(spl[1]);

        var dd = new int[n];
        var min = int.MaxValue;
        var minI = 0;

        for(int i=0; i<n; i++) {
            dd[i] = l + i;
            var abs = Math.Abs(dd[i]); 
            if (abs < min) {
                min = abs;
                minI = i;
            }
        }

        return dd.Where((x, i) => {
            return i != minI;
        }).Sum();
    }
}

Measured memory_bytes: 13268
#include <cstdio>

using namespace std;

char board[2000][2000];
int N,M;

int main(){
    scanf("%d%d\n",&N,&M);

    for (int i=0;i<N;i++){
        for (int j=0;j<M;j++){
            board[i][j]=getchar();
        }
        getchar();
    }
    int count=0;
    for (int i=0;i<N;i++){
        for (int j=0;j<M;j++){
            if (board[i][j]!=getchar())
                count++;
        }
        getchar();
    }

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

    return 0;
}




Measured memory_bytes: 6656
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    n = int(input())
    a = sorted([int(i) for i in input().split()], reverse=True)

    bob = 0
    alice = 0
    for m in range(len(a)):
        if m % 2 == 0:
            alice += int(a[m])
        else:
            bob += int(a[m])

    print(alice - bob)


Measured memory_bytes: 9092
N, x = [int(x) for x in input().split()]
a = list([int(x) for x in input().split()])

count = 0
for i in range(N):
    if a[i] > x:
        count += a[i] - x
        a[i] -= a[i] - x

    if i - 1 >= 0:
        if a[i] + a[i-1] > x:
            count += (a[i] + a[i-1]) - x
            a[i] -= (a[i] + a[i-1]) - x

print(count)


Measured memory_bytes: 20000
#include <stdio.h>

int s(int i,int m,int A[],int n); 

int main(){

  int n,q,m,i=0,c;
  int A[20];
  scanf("%d",&n);
  while(i<n){
    scanf("%d",&A[i]);
    i++;
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(s(0,m,A,n)==1) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

int s(int i,int m,int A[],int n){
  int r;
  if(m==0) return 1;
  if(i>=n) return 0;
  if(s(i+1,m,A,n)==1||s(i+1,m-A[i],A,n)==1) r=1;
  else r=0;
  return r;
}



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

int main(){
	std::vector<int> a(3);
	std::cin >> a[0] >> a[1] >> a[2];
	std::sort(a.begin(), a.end());
	int s = a[2]*10+a[1]+a[0];
	std::cout << s << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
    int n,a;
    int maxa = 10000;
    while(~scanf("%d",&n)){
        int sum = 0,t = 1;
        for(int i = 1; i <= n; i++){
            scanf("%d",&a);
            sum += a;
            if(a % 10 != 0 && a < maxa)
                maxa = a;
        }
        if(sum % 10 == 0) printf("%d\n",max(sum - maxa,0));
        else printf("%d\n",sum);
    }
}

Measured memory_bytes: 256
#!/user/bin/env pypy3
import sys
from typing import NamedTuple, List


def fast_input():
    return sys.stdin.readline()[:-1]


class Position(NamedTuple):
    t: int
    x: int
    y: int

    def _calc_diff_move(self, position) -> int:
        diff_x = self.x - position.x
        diff_y = self.y - position.y
        return abs(diff_x) + abs(diff_y)

    def can_move_from(self, prev) -> bool:
        diff_t = self.t - prev.t
        diff_move = self._calc_diff_move(prev)
        # 奇数のときはその場禁止
        if not diff_t % 2 == diff_move % 2:
            return False
        return diff_t >= diff_move


def result_format(b: bool) -> str:
    return "Yes" if b else "No"


def solve(positions: List[Position]) -> bool:
    positions = [Position(t=0, x=0, y=0)] + positions
    for p_ind in range(len(positions) - 1):
        p_curr = positions[p_ind]
        p_next = positions[p_ind + 1]
        if not p_next.can_move_from(p_curr):
            return False
    return True


def main():
    n = int(fast_input())
    positions = []
    for _ in range(n):
        t, x, y = list(map(int, fast_input().split()))
        positions.append(Position(t=t, x=x, y=y))
    result = solve(positions)
    print(result_format(result))


main()


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

const int num[10]={0,2,5,5,4,5,6,3,7,6};


void chmax(int &a,int b){
  if(a<b)a=b;
}

int main(){
  int n,m;cin>>n>>m;
  map<int,int>a;
  for(int i=0;i<m;++i){
	int x;cin>>x;
	chmax(a[num[x]], x);
  }

  int dp[10010];
  fill(dp,dp+10010,-1.0e+9);
  dp[0]=0;
  for(int i=1;i<=n;++i){
	for(auto it=a.begin();it!=a.end();++it){
	  if(i-it->first>=0)
		chmax(dp[i],dp[i-it->first]+1);
	}
  }
  for(int i=n;i>0;){
	int x=-1;
	for(auto it=a.begin();it!=a.end();++it)
	  if(i-it->first>=0&&dp[i-it->first]==dp[i]-1)
		chmax(x,it->second);
	cout<<x; i-=num[x];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,m,d;
  cin>>n>>m>>d;
  int x=1,ans=0;
  while(d*x<=m){
    if(d*x>=n&&d*x<=m)
      ans++;
    x++;
  }
  cout<<ans<<endl;
}
    

Measured memory_bytes: 3604
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    そう甘くはないんだな〜w
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::convert::TryInto;
use std::mem::swap;
use std::ops::*;
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, One, Pow, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

pub const MOD: usize = 1000000007;
pub const MAX: usize = 1usize << 63usize;
pub const MIN: i64 = i64::MIN;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 'A' as u8;

use std::time::{Duration, Instant};

// code...
// #[fastout]
fn main() {
    input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d]
    }

    let start = Instant::now();

    let mut ans = Vec::new();
    for _ in 0..d {
        ans.push(random::<usize>() % 26 + 1);
    }
    let mut scr = score(d, &c, &s, &ans);

    // dbg!(scr);

    while start.elapsed().as_millis() < 1900 {
        let prev = ans.clone();
        ch(&mut ans);
        let new = score(d, &c, &s, &ans);
        if new <= scr {
            ans = prev;
        } else {
            scr = new;
        }
    }

    // dbg!(score(d, &c, &s, &ans));

    for i in ans {
        println!("{}", i);
    }
}

fn score(d: usize, c: &Vec<i64>, s: &Vec<Vec<i64>>, ans: &Vec<usize>) -> i64 {
    let mut last = vec![0usize; 26];
    let mut a = 0i64;

    for day in 0..d {
        a += s[day][ans[day] - 1];
        last.iter_mut().for_each(|x| *x += 1);
        last[ans[day] - 1] = 0;
        a -= last
            .iter()
            .enumerate()
            .map(|(i, l)| c[i] * *l as i64)
            .sum::<i64>();
    }
    a
}

fn ch(ans: &mut Vec<usize>) {
    for i in ans.iter_mut() {
        if random::<bool>() {
            *i = random::<usize>() % 26 + 1;
        }
    }
}


Measured memory_bytes: 2760
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
const ll INF=1000000010;
const ll MOD=1000000007;
const ll LINF=1000000000000000000;
//解を二分探索しXを決め打ち？
//X未満が存在しない世界でK以上の長さをQ回以上取れるか？
int n,k,qu;
ll a[2010];
bool check(ll s){
	for(int i=0;i<n;i++){
		ll x=a[i];
		vector<ll> v,vv;
		for(int j=0;j<n;j++){
			if(a[j]<x){
				if(v.size()==0)continue;
				sort(all(v));
				for(int l=0;l<(int)v.size()-k+1;l++){
					vv.push_back(v[l]);
				}
				v.clear();
			}else{
				v.push_back(a[j]);
			}
		}
		sort(all(v));
		for(int l=0;l<(int)v.size()-k+1;l++){
			vv.push_back(v[l]);
		}
		if(vv.size()<qu)continue;
		sort(all(vv));
		if(vv[qu-1]<=x+s){
			return true;
		}
	}
	return false;
}
int main(){
	cin>>n>>k>>qu;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int ok=INF,ng=-1;
	while(ok-ng>1){
		int mid=(ok+ng)/2;
		if(check(mid)){
			ok=mid;
		}else{
			ng=mid;
		}
	}
	cout<<ok<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

LL gcd(LL val1, LL val2);

int main(){
    int N;
    LL X;
    cin >> N >> X;
    vector<LL> x(N);
    REP(i,N)cin>>x[i];

    vector<LL> diff(N);
    REP(i,N){
        diff[i] = abs(x[i] - X);
    }

    set<LL> s(diff.begin(), diff.end());
    LL ans = diff[0];
    for(auto itr = s.begin(); itr!=s.end(); itr++){
        ans = gcd(ans, *itr);
    }
    cout << ans << endl;

    return 0;
}

LL gcd(LL min_val, LL max_val){
    LL r = max_val % min_val;
    if(r == 0){
        return min_val;
    }
    return gcd(r, min_val);
}

Measured memory_bytes: 9324
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

const int MAX_C = 1000;
long long Com[MAX_C][MAX_C];

void calc_com() {
    memset(Com, 0, sizeof(Com));
    Com[0][0] = 1;
    for (int i = 1; i < MAX_C; ++i) {
        Com[i][0] = 1;
        for (int j = 1; j < MAX_C; ++j) {
            Com[i][j] = (Com[i-1][j-1] + Com[i-1][j]);
        }
    }
}
int main(){
    calc_com();
    int n,p;
    cin>>n>>p;
    int a[n];
    int ev=0,od=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]%2) od++;
        else ev++;
    }
    ll t1=0,t2=0;
    for(int i=0;i<=ev;i++){
        t1+=Com[ev][i];
    }
    for(int i=p;i<=od;i+=2){
        t2+=Com[od][i];
    }
    cout<<t1*t2<<endl;
    return 0;
}


Measured memory_bytes: 8192
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,w,k;cin>>h>>w>>k;
  vector<string>hw(h);
  vector<vector<ll>>c(h,vector<ll>(w));
  vector<ll>empty(h);

  rep(i,h){
    cin>>hw[i];
  }
  rep(i,h){
    ll f=1;
    rep(j,w)if(hw[i][j]=='#')f=0;
    if(f)empty[i]=1;
  }
  ll col=1;
  ll f=0;
  rep(i,h){
    if(empty[i])continue;
    rep(j,w){
      if(hw[i][j]=='#'){
        if(f){
          col++;
          f=1;
        }
        else{
          f=1;
        }
      }
      c[i][j]=col;
    }
    col++;
    f=0;
  }
  vector<ll>id(h);
  ll ti=-1;
  rep(i,h){
    if(!empty[i])ti=i;
    if(ti!=-1&&empty[i])id[i]=ti;
  }
  ti=-1;
  rrep(i,h){
    if(!empty[i])ti=i;
    if(ti!=-1&&empty[i])id[i]=ti;
  }
  rep(i,h){
    if(empty[i]){
      rep(j,w)c[i][j]=c[id[i]][j];
    }
  }
  rep(i,h){
    rep(j,w){
      cout<<c[i][j]<<" ";
    }
    cout<<endl;
  }
  return 0;

}


Measured memory_bytes: 1664
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int A, B;

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

  int ans = 0;
  if (A > 9 || B > 9) {
    ans = -1;
  } else {
    ans = A * B;
  }

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

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

using namespace std;

int main() {
    // Input
    int K, A, B;
    cin >> K;
    cin >> A >> B;

    // Process
    bool ans = false;
    for (int n = A; n <= B; n++) {
        if (n % K == 0) {
            ans = true;
            break;
        }
    }

    // Output
    if (ans)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;

    return 0;
}


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

int main() {
  long long N, M;
  cin >> N >> M;

  long long ans = 0;
  if (2 * N <= M) {
    ans += N;
    ans += (M - 2 * N) / 4;
  } else {
    ans += M / 2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

const mod = 10^^9 + 7;

long modPow(long x, long k, long m) {
    if (k == 0) return 1;
    if (k % 2 == 0) return modPow(x * x % m, k / 2, m);
    return x * modPow(x, k - 1, m) % m;
}

long nck(long n, long k, long mod) {
    long x = 1;
    long y = 1;
    for (int i = 0; i < k; i++) {
        x = x * (n - i) % mod;
        y = y * (i + 1) % mod;
    }
    return (x * modPow(y, mod - 2, mod)) % mod;
}

long calc(long n, long a, long b) {
    long ans = modPow(2, n, mod);
    ans = (ans - nck(n, a, mod) + mod) % mod;
    ans = (ans - nck(n, b, mod) + mod) % mod;
    ans--;
    return ans;
}

void main() {
    int n, a, b; scan(n, a, b);
    writeln(calc(n, a, b));
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <tuple>
#include <queue>
using namespace std;

typedef long long ll;

#define INF 100000000;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define eps 1.0e-14;

queue<pair<int,int>> que;
string s[1005];
ll ans = 0;

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

int main(){
	int n,m; cin >> n >> m;
	ll h[100005];
	int a[100005],b[100005];
	vector<vector<int>> vec(n);
	rep(i,n) cin >> h[i];
	rep(i,m){
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--; //0indexed
		vec[a[i]].emplace_back(b[i]);
		vec[b[i]].emplace_back(a[i]);
	}
	ll ans = 0;
	rep(i,n){
		//cout << vec[i].size() << endl;
		if (vec[i].empty()){
			ans++;
			continue;
		}
		rep(j,vec[i].size()){
			if(h[i] <= h[vec[i][j]]) break;
			if(j == vec[i].size() - 1) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 10108
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
 
class DandA {
    static void Main(string[] args) {
        int[] nm = ReadLineIntArray();
        int[] aList = ReadLineIntArray();
        int[] resultArray = aList.Distinct().ToArray();
        Array.Sort(resultArray);
      　int intMax = resultArray.Max();
        int half = intMax / 2;
        int product = 0;
        int cnt = 0;
        int i = 1;
        while (nm[1] >= half + product) {
            bool flg = true;
            for (int wk = resultArray.Length - 2; wk >= 0;wk--) {
                if (((half + product) - (resultArray[wk] / 2)) % resultArray[wk] != 0) {
                    flg = false;
                    break;
                }
            }
            if (flg) {cnt++;}
            product = intMax * i;
            i++;
        }
        Console.WriteLine(cnt);
    }
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}
}

Measured memory_bytes: 26460
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;




int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll a, b, c;
	cin >> a >> b >> c;
	cout << a / (b + c) * b + min(b, a % (b + c));
}

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

const int MOD = 1000000007;


int main()
{
    string s,t;
    cin>>s>>t;
    int ls = s.length();
    int ts = t.length();
    int res=0,cnt=0;
    for(int i=0;i<=ls-ts;i++)
    {
        cnt=0;
        int curr=i;
        for(int j=0;j<ts;j++,curr++)
        {
            if(t[j]==s[curr])
            {
                cnt++;
            }
        }
        res = max(cnt,res);
    }
    cout<<ts-res<<endl;
    return 0;
}





Measured memory_bytes: 3468
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 4e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 200005;
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
ll sqr(ll x)
{
    return x*x;
}
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;  cin>>n;
    vi v(n);  f(n)cin>>v[i];
    int ans = 0;
    for(int i =1;i<n-1;i++){
       vi vv;
       vv.pb(v[i-1]); vv.pb(v[i]);  vv.pb(v[i+1]);
       sort(all(vv));
       if(vv[1] == v[i])ans++;
    }
    cout << ans;


    return 0;
}
    


Measured memory_bytes: 256
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	VLL x(n);
	REP(i, n) { cin >> x[i]; }
	VLL diff(n, 0);
	REP(i, n - 1) { diff[i + 1] = x[i + 1] - x[i]; }
	ll result = 0;
	REP(i, n) { result += min(a * diff[i], b); }
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 4856
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printaa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ for(int j = 0; j < (sizeof(x[0])/sizeof(x[0][0])); j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    if(N%K == 0){
        print("0");
    }else{
        print("1");
    }
}


Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <unordered_map>
using namespace std;

int main(){
    int n;
    cin >> n;
    if(n < 1200){
        cout << "ABC" << endl;
    }else if(n < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
}


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

int main(void)
{
    long long n,q,a,b,c;
    cin >> n;
    long long isum=0;
    long long list[100001]={};

    for(int i=0;i<n;i++)
    {
        cin >> a;
        isum+=a;
        list[a]++;
    }
    cin >> q;
    long long sum[q]={};

    for(int i=0;i<q;i++)
    {
        cin >> b >> c;
        list[c]+=list[b];
        sum[i]=isum+(c-b)*list[b];
        list[b]=0;
        isum=sum[i];
    }
    for(int i=0;i<q;i++)
    {
        cout << sum[i] << endl;
    }
    return 0;
}


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

int main() {
  int a,b,c,d,e,k;
  
  cin >> a >> b >> c >> d >> e >> k;
  
  if(b-a<=k&&c-a<=k&&d-a<=k&&e-a<=k&&c-b<=k&&d-b<=k&&e-b<=k&&d-c<=k&&e-c<=k&&e-d<=k){
    cout << "Yay!";
  }else{
    cout << ":(";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, n) for (int i = 1; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

int main() {
    string S;
    cin >> S;
    cout << S.substr(0, 3) << "\n";
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 100;
const int mod = (int)1e9 + 7;
long long t[5 * N];
long long binpow(long long a,long long n){
    long long res = 1;
    while(n){
        if(n & 1)res = res * a,res %= mod;
        n >>= 1;
        a *= a;
        a %= mod;
    }
    return res;
}
long long inv(long long a){
    return binpow(a, mod - 2);
}
long long f(long long a,long long b){
    return (t[a + b - 2] * ((inv(t[a - 1]) * inv(t[b - 1])) % mod)) % mod;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    long long h,w,a,b;
    cin >> h >> w >> a >> b;
    t[0] = 1;
    for(int i = 1;i <= 3 * N;++i)t[i] = (t[i - 1] * i) % mod;
    long long ans = 0;
    for(long long i = b + 1;i <= w;++i){
       
        ans += (f(i, h - a) * f(a, w - i + 1)) % mod;
        ans %= mod;
    }
    cout << ans;
  	return 0;
} 

Measured memory_bytes: 5972
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

int main() {
  ll L, A, B, M;
  cin >> L >> A >> B >> M;

  P digit = P(1, 1);
  ll tmp = 10;
  while (A >= tmp) {
    tmp *= 10;
    ++digit.first;
  }

  ll last = A + B * (L-1);
  tmp = 10;
  while (last >= tmp) {
    tmp *= 10;
    ++digit.second;
  }

  ll init = A;
  ll ans = 0;
  ll pow10 = pow(10, digit.first);

  for (int k=digit.first; k<=digit.second; ++k) {
    if (pow10 <= init) {
      pow10 *= 10;
      continue;
    }

    ll num = (min(pow10 - 1, last) - init) / B + 1;
    
    vl rem(64), dp(64), dp2(64), power(64);
    rem[0] = pow10 % M;
    dp[0] = 1;
    dp2[0] = 1;
    power[0] = 1;

    rep(i,63) {
      rem[i+1] = rem[i] * rem[i] % M;
      dp[i+1] = dp[i] * (1 + rem[i]) % M;
      dp2[i+1] = (dp2[i] * (1 + rem[i]) + dp[i] * power[i]) % M;
      power[i+1] = power[i] * 2 % M;
    }

    ll expo = 1, sigma_a = 0;
    ll expo2 = 1, sum = 0, sigma_b = 0;

    for (int i=63; i>=0; --i) {
      if ((num >> i) & 1) {
        (sigma_a += expo * dp[i]) %= M;
        (expo *= rem[i]) %= M;
      }

      if (((num - 1) >> i) & 1) {
        (sigma_b += sum * power[i] + expo2 * dp2[i]) %= M;
        (sum += expo2 * dp[i]) %= M;
        (expo2 *= rem[i]) %= M;
      }
    }

    (ans *= expo) %= M;
    (ans += (init % M) * sigma_a + (B % M) * sigma_b) %= M;
    init += B * num;

    pow10 *= 10;
  }

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


Measured memory_bytes: 256
#include <stdio.h>

#define N 100
#define INF 1000000

void Matrix_Chain_Order(int *);
int Mini(int , int );

int r[N], c[N], p[N], mat[N][N], n;

int main() {
  
  int i,j; 
  
  scanf("%d", &n);
  if(n < 0 || N < n){
    return 0;
  }
  
  for(i = 0; i < n; i++){
    scanf("%d %d", &r[i], &c[i]);
  }
  
  for(i = 0; i < n; i++){
    if(i == 0) {
      p[i] = r[i];
      p[i+1] = c[i];
    }
    else p[i+1] = c[i];
  }
  
  Matrix_Chain_Order(p);
  
  printf("%d\n", mat[1][n]);
  
  return 0;
}


void Matrix_Chain_Order(int *p){
  int i,j,k;
  int l,q=0;
  
  for(i=1;i <= n;i++){
    mat[i][i] = 0;
  }
  
  for(l = 2; l <= n; l++){
    for(i = 1; i <= n-l+1; i++){

      j = i+l-1;
      mat[i][j] = INF;

      for(k = i+1; k <= j; k++){
	q = mat[i][k-1]+mat[k][j]+(p[i-1]*p[k-1]*p[j]);
	if(q < mat[i][j]){
	  mat[i][j] = q;
	}
      }

    }
  }
}

Measured memory_bytes: 636
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
typedef long long ll;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

int main(){
    int n,k;
    cin >> n >> k;
    ll ans = 0;
    for(int i=1;i<=n;i++){
        int p = n/i;
        int r = n%i;
        ll res = p*max(0,i-k)+max(0,r-k+1);
        ans += res;
    }
    if(k==0)ans-=n;
    cout << ans << endl;
    return 0;
}

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

int factors[10000007];

int main()
{
	int n;
	cin >> n;
	
	for(int i = 1; i <= n; i++) {
		for(int j = i; j <= n; j += i) {
			factors[j]++;
		}
	}
	
	long long answer = 0;
	
	for(int i = 1; i <= n; i++) {
		answer += (long long) factors[i] * (long long) i;
	}
	
	cout << answer;
}


Measured memory_bytes: 42652
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            int N = int.Parse(Console.ReadLine());
            int K = int.Parse(Console.ReadLine());
            int X = int.Parse(Console.ReadLine());
            int Y = int.Parse(Console.ReadLine());

            Console.WriteLine(X * Math.Min(N, K) + Y * Math.Max(0, N - K));

            Console.Out.Flush();
        }
    }
    


    public class Calculation
    {
        
    }

    public class Graph
    {

    }
}
    

Measured memory_bytes: 13140
#include <vector>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

typedef long long ll;

#define REP(var,n) for(int var=0;var<(n);var++)
#define REPP(var,n) for(int var=1;var<(n);var++)
#define ALL(c) (c).begin(),(c).end()

int main(){
    ll N;
    ll ans = 0;
    int K; 
    
    cin >> N >> K;

    vector<ll> zero;
    vector<ll> two;

    for(ll i=1; i<=N; i++){
        if(i % K == 0){
            zero.push_back(i);
        }
        else{
            if(i % K == K/2 && K % 2 == 0){
                two.push_back(i);
            }
        }
    }
    // two,zeroの中から選んで並べる
    //zeroについて 
    ll M = zero.size();
    ans += M;
    ans += M*(M-1)*3;
    ans += M*(M-1)*(M-2);

    M = two.size();
    ans += M;
    ans += M*(M-1)*3;
    ans += M*(M-1)*(M-2);

    cout << ans << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort(all(v))
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF 1000000007
#define fcout cout << fixed << setprecision(15)
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill( (T*)array, (T*)(array+N), val );};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};



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

  int n;
  cin >> n;
  int h[n + 10];
  rep(i, n) cin >> h[i];
  int dp[n + 10];
  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);
  REP(i, 2, n) {
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  cout << dp[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 1024
def solve(s: str) -> int:
    if s == 'SUN':
        return 7
    elif s == 'MON':
        return 6
    elif s == 'TUE':
        return 5
    elif s == 'WED':
        return 4
    elif s == 'THU':
        return 3
    elif s == 'FRI':
        return 2
    elif s == 'SAT':
        return 1


s = input().strip()
print(solve(s))


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		scan.close();

		int[] array = new int[n+1];
		int ans = 0;

		for(int x=1;x<100;x++) {
			for(int y=1;y<100;y++) {
				for(int z=1;z<100;z++) {
					ans = (x*x)+(y*y)+(z*z)+(x*y)+(y*z)+(z*x);
					if(ans <= n) {
						array[ans]++;
					}
				}
			}
		}
		for(int i=1;i<array.length;i++) {
			System.out.println(array[i]);
		}
	}

}

Measured memory_bytes: 39264
#include<bits/stdc++.h>
using namespace std;
int main(){
    int sum=0,i,n;cin>>n;
    int L[n];
    for(i=0;i<n;i++)cin>>L[i];
    sort(L,L+n);
    for(i=0;i<n-1;i++)sum+=L[i];
    cout<<(sum>L[n-1]?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	
	int m;
	cin >> m;
	ll sum = 0LL;
	ll ans = 0LL;
	rep(i, m){
		ll d, c;
		cin >> d >> c;
		sum += (d * c);
		ans += c;
	}
	ans += (sum - 1) / 9LL;
	ans--;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll a,ll b){
  if(a%b==0){
    return(b);
  }else{
    return(gcd(b,a%b));
  }
}
int main(){
  ll N,X,ans=0;
  cin>>N>>X;
  vector<ll> vec(N+1);
  vec.at(N)=X;
  for(ll i=0;i<N;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  vector<ll> dist(N);
  for(ll i=0;i<N;i++){
    dist.at(i)=vec.at(i+1)-vec.at(i);
  }
  if(N==1){cout<<dist.at(0)<<endl;return 0;}
  for(ll i=0;i<N-1;i++){
    if(i==0){ans=gcd(dist.at(0),dist.at(1));}
    else{ans=gcd(dist.at(i+1),ans);}
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
# -*- coding:utf-8 -*-
from operator import itemgetter

N = int(input())
A_list = list(map(int,input().split()))
A_list2 = []
for i in range(N):
    A_list2.append([str(i+1), A_list[i]])

A_list_sorted = sorted(A_list2, key=itemgetter(1))
B = [x[0] for x in A_list_sorted]
L = " ".join(B)
print(L)

Measured memory_bytes: 82668
def getlist():
	return list(map(int, input().split()))

H, W, N = getlist()
h, w = getlist()
S = list(input())
T = list(input())

sl, sr, su, sd = 0, 0, 0, 0
tl, tr, tu, td = 0, 0, 0, 0
judge = "YES"

for i in range(N):

	if S[i] == "L":
		sl += 1
		if sl >= tr + w:
			judge = "NO"
			break
	elif S[i] == "R":
		sr += 1
		if sr >= W - w + tl + 1:
			judge = "NO"
			break
	elif S[i] == "U":
		su += 1
		if su >= td + h:
			judge = "NO"
			break
	else:
		sd += 1
		if sd >= H - h + tu + 1:
			judge = "NO"
			break
			
	if T[i] == "L":
		tl += 1
	elif T[i] == "R":
		tr += 1
	elif T[i] == "U":
		tu += 1
	else:
		td += 1

	if tl >= sr + w:
		tl -= 1
	if tr >= sl + W - w + 1:
		tr -= 1
	if tu >= sd + h:
		tu -= 1
	if td >= su + H - h + 1:
		td -= 1

	
print(judge)

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

int main() {
  int N;
  cin >> N;
  
  int count = 0;
  
  for(int i=0; i<N; i++)
  {
    int l, n;
    cin >> l >> n;
    
    count += n - l + 1;
    
  }
  
    cout << count << endl;
}


Measured memory_bytes: 256
function main(input) {
  const lines = input.trim().split("\n");
  const X = lines[0];

  let d = 100;
  let res = 0;
  while (d < X) {
    d += Math.floor(d / 100);
    res++;
  }

  console.log(res);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29740
a=int(input())
str_list=[str(input()) for i in range(a)]
x=[]
for i in range(len(str_list[0])):
  check=True;
  for j in range(1,a):
    if str_list[0][i] in str_list[j]:
      str_list[j] = str_list[j].replace(str_list[0][i],'',1);
    else:
      check=False;
  if check:
    x.append(str_list[0][i])
if len(x) > 0:
  print(''.join(sorted(x)))
else:
  print('')

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

int main(){
    int N; cin >> N;
    int k = 0, tmpN = N;

    while(tmpN > 0){
        k++;
        tmpN /= 2;
    }

    for(int i = 1; i <= N; i++){
        for(int j = i + 1; j <= N; j++){
            int tmpi = i, tmpj = j;
            int cnt = 1;
            //cout << (tmpi ^ tmpj) << endl;
            while(((tmpi ^ tmpj) & 1) == 0){
                tmpi >>= 1;
                tmpj >>= 1;
                cnt++;
            }
            cout << cnt << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 512
# include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+5],b[n+5],t[n+5];
	for(int i=0;i<n;i++)
	cin>>t[i]>>a[i]>>b[i];
	if((a[0]+b[0])>t[0]||((a[0]+b[0]-t[0]))%2!=0)
	{
		cout<<"No";
		return 0;
	}
	for(int i=1;i<n;i++)
	{
		if((abs(a[i]-a[i-1])+abs(b[i]-b[i-1]))>t[i]-t[i-1]||(((abs(a[i]-a[i-1])+abs(b[i]-b[i-1]))-(t[i]-t[i-1]))%2!=0))
		{
			cout<<"No";
			return 0;	
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 1408
n, k = gets.chomp.split(' ').map {|v| v.to_i}

s = []
n.times do |i|
  r = gets.chomp.to_i
  s.push(r)
end

s.sort!
m1 = s[-1]
cnt = s.length - k + 1
cnt.times do |i|
  v = s[i + k - 1] - s[i]
  if v < m1
    m1 = v
  end
end

puts m1



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

using namespace std;

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


int main() {
	int N;
	cin >> N;
	rep(i, N) {
		int p, q;
		cin >> p >> q;
		if (p * p + q * q <= 1) {
			cout << "C" << endl;
			continue;
		}
		set<pair<int, int>> se;
		se.insert(make_pair(0, 0));
		se.insert(make_pair(1, 0));
		se.insert(make_pair(0, 1));
		se.insert(make_pair(-1, 0));
		se.insert(make_pair(0, -1));
		se.insert(make_pair(p, q));
		se.insert(make_pair(-q, p));
		se.insert(make_pair(-p, -q));
		se.insert(make_pair(q, -p));
		
		int sum = abs(p) + abs(q);
		bool ok = true;
		for (int m = -sum; m <= sum; m++) {
			for (int n = -sum; n <= sum; n++) {
				if (se.count(make_pair(m, n)))continue;
				if ((m * p + n * q) % (m * m + n * n) == 0 &&
					(m * q - n * p) % (m * m + n * n) == 0) {
					ok = false;
				}
			}
		}
		if (ok) {
			cout << "P" << endl;
		}
		else {
			cout << "C" << endl;
		}

	}

	return 0;
}

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

using namespace std;

int main(){
    int n, n_primes=0;
    cin >> n;
    vector<int> array(n);
    for(int i=0;i<n;i++) cin >> array[i];
    
    int s = 0;
    for(int i=0;i<array.size(); i++){
        s = floor(sqrt(array[i]));
        for(int j=2;j<=s; j++){
            if(array[i]%j==0){
                n_primes--;
                break;
            }
        }
        n_primes++;
        
    }
    
    cout << n_primes << endl;
    
    return 0;
}


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

int main() {
	int N, X, L[100];
    cin >> N >> X;
    for (int i = 0; i < N; ++i){
        cin >> L[i];
    }
    int ans = 0;
    int addr = 0;
    int i = 0;
    while(addr <= X){
        ans++;
        addr += L[i++];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>

using namespace std;

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

	int n;
	cin >> n;

	int g[n][n] = {};
	for(int i=0;i<n;i++){
		int u, nume;
		cin >> u >> nume;

		int v;
		for(int j=0;j<nume;j++){
			cin >> v;
			g[u-1][v-1]= 1;
		}

	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cout << g[i][j];
			if(j != n-1) cout << " ";
		}
		cout << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 3100
//Code by : Abhishek Tiwari
//codechef.com/users/devil_within || hackerearth.com/@devil_within
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pii pair<int,int> 
#define ff first
#define ss second 
#define mod 1000000007
#define gcd __gcd
#define lcm(a,b) ((a)*(b))/gcd(a,b)
using namespace std;

/*******************************************************************************************/
/*******************************************************************************************/
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { 
    os<<"["; for(int i=0;i<v.size()-1; ++i)os<<v[i]<<", ";os<<v[v.size()-1]<<"]\n"; return os; 
} 
template <typename T> ostream& operator<<(ostream& os, const set<T>& v) { 
    os<<"{"; for(auto it : v) { os<<it; if(it!=*v.rbegin()) os<<", "; } os<<"}\n"; 
    return os; 
}
template <typename T, typename S> ostream& operator<<(ostream& os, const map<T, S>& v) { 
    os<<"{"; for(auto it:v){ os<<"("<<it.first<<" : "<<it.second<<")"; if(it!=*v.rbegin()) os<<", "; } os<<"}\n"; 
    return os; 
}
template <typename T, typename S> ostream& operator<<(ostream& os, const pair<T, S>& v) { 
    os<<"("; os<<v.first<<", "<< v.second<<")"; 
    return os; 
} 
/*******************************************************************************************/
/*******************************************************************************************/
int fpow(int x, int y, int p); 


int32_t main()  
{
#ifndef ONLINE_JUDGE
//freopen("input.txt" , "r" , stdin);freopen("output.txt" , "w" , stdout);freopen("error.txt" , "w" , stderr);
#endif
fio;
int tcases = 1;
//cin>>testcases;
for(int tcase = 1 ; tcase <= tcases ; ++tcase)
{
    int n;
    cin>>n;
    int a[n];
    FOR(i , 0 , n) cin>>a[i];
    vector<int> dp(n , mod );
    dp[0] = 0;
    for(int i = 0; i < n ;++ i)
    {   
        if(i+1 < n)
        dp[i+1] = min(dp[i+1] , abs(a[i]- a[i+1]) + dp[i]);
        if(i+2 < n)
        dp[i+2] = min(dp[i+2] , abs(a[i]- a[i+2]) + dp[i]);
    }    
    cout<<dp[n-1]<<"\n";
    //cout<<"Case #"<<tcase<<": ";
}
return 0;
}



//Functions 

int fpow(int x, int y, int p) { 
    int res = 1; 
   x = x % p;  
   while (y > 0) { 
     if (y & 1) 
        res = (res * x) % p; 
     y = y >> 1; 
        x = (x * x) % p; 
    } 
    return res; 
} 


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

const int mod = 1e9+7;

int main(){
    ll N;
    cin >> N;
    string S1,S2;
    cin >> S1 >> S2;
    ll res;
    int cur,is_v;
    if(S1[0]==S2[0]){
        res=3;
        cur = 1;
        is_v=1;
    }
    else{
        res=6;
        cur=2;
        is_v=0;
    }
    while(cur<N){
        if(is_v==1){
            if(S1[cur]==S2[cur]){
                res*=2;
                cur+=1;
            }else{
                res*=2;
                cur+=2;
                is_v=0;
            }
        }else{
            if(S1[cur]==S2[cur]){
                cur+=1;
                is_v=1;
            }else{
                res*=3;
                cur+=2;
                is_v=0;
            }
        }
        res%=mod;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
//Have a nice day:)
#include<bits/stdc++.h>
using namespace std;
#define LL long long

inline int read();

const int N=2000+2;
const int M=1e9+7;
int n, k;
int frac[N*N], inv[N*N];
int f[N][N];

int Pow(int a, int b) 
{ 
	int ans=1; 
	for(; b; b>>=1, a=1ll*a*a%M) if(b&1) ans=1ll*a*ans%M; 
	return ans;
}
int C(int a, int b) 
{ 
	if(a<0 || b<0) return 0;
	if(!a || !b) return 1;
	assert((__int128)frac[b]*inv[a]*inv[b-a]%M>=0);
	return (1ll*frac[b]*inv[a]%M)*inv[b-a]%M;
}
void Work()
{
    n=read(), k=read(); frac[0]=1; inv[0]=1; f[0][0]=1;
	if(k==1) { printf("1"); return; }
	for(int i=1, lim=n*k; i<=lim; ++i) frac[i]=1ll*frac[i-1]*i%M, inv[i]=Pow(frac[i], M-2);
	for(int i=1; i<=n; ++i)
		for(int j=0; j<=i; ++j)
		{
			if(j) f[i][j]=(f[i-1][j]+1ll*f[i][j-1]*C(k-2, n*k-i-(k-1)*(j-1)-1)%M)%M;
            else f[i][j]=f[i-1][j];
		}
	printf("%d", 1ll*f[n][n]*frac[n]%M);
}

int main()
{
    #ifdef gc
    freopen("002f.in","r",stdin);
    freopen("002f.out","w",stdout);
    #endif

    Work();

    return 0;
}

inline int read()
{
    char c; bool type=1;
    while((c=getchar())<'0' || c>'9')
        if(c=='-') type=0;
    int ans=c^48;
    while((c=getchar())>='0' && c<='9')
        ans=(ans<<3)+(ans<<1)+(c^48);
    return type?ans:-ans;
}



Measured memory_bytes: 46336
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c,d,t;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    if(a>b)
    {
        a=b;
    }
    if(c>d)
    {
        c=d;
    }
    printf("%d\n",a+c);
    return 0;
}


Measured memory_bytes: 128
def solve(string):
    s, t = map(list, string.split())
    ans = len(t)
    for i in range(len(s)-len(t)+1):
        c = 0
        for j, _ in enumerate(t):
            c += 1 if s[i + j] != t[j] else 0
        ans = min(ans, c)
    return str(ans)

    pass


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 8972
//Prime Number ?
#include<bits/stdc++.h>
using namespace std;

vector<int> p;

int main(){
  int n;
  p.push_back(2);
  for(int i=3; i<=60000; i+=2){
    bool flag=true;
    for(int j=0; j<p.size(); j++){
      if(i%p[j]==0){
        flag=false;
        break;
      }
    }
    if(flag) p.push_back(i);
  }
  while(cin>>n){
    int i;
    for(i=0; i<p.size(); i++){
      if(n<p[i])break;
    }
    cout<<(n==p[i-1] ? p[i-2] : p[i-1])<<' '<<p[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1272
/*
Created on Thu Aug 27 21:32:39 2020

@author: roastedcoder

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long int ull;
const int mod = 1e9+7;
const int INF = INT_MAX;
#define endl "\n"
#define append push_back
#define roastedcoder ios_base::sync_with_stdio(false); cin.tie(NULL);
//__________________________________________________________________


int main() {
	roastedcoder
	ll n; cin>>n;
	ll a[n], dp[n] = {0};
	cin>>a[0];
	dp[0] = a[0];
	for(int i = 1; i<n; i++) {
		cin>>a[i];
		dp[i] = dp[i-1]+a[i];
	}
	ll res = 0;
	for(int i = 0; i<n; i++) {
		res += (((dp[n-1] - dp[i])%mod)*a[i])%mod;
	}
	cout<<res%mod<<endl;
}

//__________________________________________________________________
/*
Sample Input:


Sample Output:


*/

Measured memory_bytes: 6768
#直積を使った方法
from itertools import product
s = input()
n = len(s)
su = 0
l = list(product(["+",""], repeat=n-1))
for i in range(2**(n-1)):
  a = "0+"
  for j,k in zip(s,l[i]):
    a += j+k
  a += s[-1]
#  print(a)
  su += eval(a)
print(su)

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

int main(){
    int n;
    cin >> n;
    int p[n]={};

    for(int i=0;i<n;i++){
        cin >> p[i];
    }

    int count=0;

    for(int i=0;i<n-2;i++){
        int a,b,c;
        a=p[i];
        b=p[i+1];
        c=p[i+2];
        if((a>b)&&(a>c)){
            if(b>c){
                count++;
            }
        }
        if((c>a)&&(c>b)){
            if(b>a){
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256