akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    int[] input = readln.split.to!(int[]);
    int N = input[0];
    int K = input[1];
    long[][] data = new long[][N];
    bool[long][] aa = new bool[long][3];
    foreach(i; 0..N) {
        data[i] = readln.split.to!(long[]);
        foreach(j; 0..3) {
            aa[j][data[i][j]] = true;
            aa[j][data[i][j+3]] = true;
        }
    }
    long[][] values = new long[][3];
    foreach(i; 0..3) values[i] = aa[i].keys.sort;
    int[long][] keys = new int[long][3];
    foreach(i; 0..3) foreach(k, v; values[i]) keys[i][v] = k.to!int;
    int[][][] imos = new int[][][](keys[0].length, keys[1].length, keys[2].length);
    foreach(e; data) {
        imos[keys[0][e[0]]][keys[1][e[1]]][keys[2][e[2]]]++;
        imos[keys[0][e[3]]][keys[1][e[1]]][keys[2][e[2]]]--;
        imos[keys[0][e[0]]][keys[1][e[4]]][keys[2][e[2]]]--;
        imos[keys[0][e[0]]][keys[1][e[1]]][keys[2][e[5]]]--;
        imos[keys[0][e[3]]][keys[1][e[4]]][keys[2][e[2]]]++;
        imos[keys[0][e[0]]][keys[1][e[4]]][keys[2][e[5]]]++;
        imos[keys[0][e[3]]][keys[1][e[1]]][keys[2][e[5]]]++;
        imos[keys[0][e[3]]][keys[1][e[4]]][keys[2][e[5]]]--;
    }
    foreach(i; 1..keys[0].length) {
        foreach(j; 0..keys[1].length) {
            foreach(k; 0..keys[2].length) {
                imos[i][j][k] += imos[i-1][j][k];
            }
        }
    }
    foreach(i; 0..keys[0].length) {
        foreach(j; 1..keys[1].length) {
            foreach(k; 0..keys[2].length) {
                imos[i][j][k] += imos[i][j-1][k];
            }
        }
    }
    foreach(i; 0..keys[0].length) {
        foreach(j; 0..keys[1].length) {
            foreach(k; 1..keys[2].length) {
                imos[i][j][k] += imos[i][j][k-1];
            }
        }
    }
    long ans = 0;
    foreach(i; 0..keys[0].length) {
        foreach(j; 0..keys[1].length) {
            foreach(k; 0..keys[2].length) {
                if (imos[i][j][k]>=K) {
                    ans += (values[0][i+1]-values[0][i])*(values[1][j+1]-values[1][j])*(values[2][k+1]-values[2][k]);
                }
            }
        }
    }
    ans.writeln;
}

Measured memory_bytes: 7924
#include<stdio.h>
int main(void){
    int i;
    int j;
    int a,b;
    while(1){
        name:scanf("%d%d",&a,&b);
        if(a==0&&b==0){
            break;
        }
        else if(a==0||b==0){
            printf("\n");
            goto name;
        }
        for(i = 1;i <= a;i++){
            if(i%2==1){
                for(j = 1;j <= b;j++){
                    if(j%2==1){
                        printf("#");
                    }
                    else if(j%2==0){
                        printf(".");
                    }
                }printf("\n");
            }
            else if(i%2==0){
                for(j = 1;j <= b;j++){
                    if(j%2==1){
                        printf(".");
                    }
                    else if(j%2==0){
                        printf("#");
                    }
                }printf("\n");
            }
        }printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
n = int(input())
dat = [tuple(list(map(int,input().split()))) for i in range(n)]



from operator import itemgetter
  
dat2 = sorted(dat, key=itemgetter(1))
# print(dat2)




t = 0
for i in range(n):
    t += dat2[i][0]
    if t > dat2[i][1]:
        print("No")
        break
else:
    print("Yes")




Measured memory_bytes: 33476
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    var rank = IntArray(n + 1) { 1 }
    val cities=(1..m).map {
        val (p, y) = readLine()!!.split(" ").map { it.toInt() }
        return@map Triple(it, p, y)
    }.sortedBy { it.third }

    cities.map {
        Pair(
                it.first,
                it.second.toString().padStart(6, '0')
                        + rank[it.second]++.toString().padStart(6, '0'))
    }
            .sortedBy { it.first }
            .forEach { println(it.second) }
}

Measured memory_bytes: 133780
n = int(input())
a = [int(i) for i in input().split()]
x = [0]*n
s = sum(a)//2
tmp = 0
for i in range(1,n,2):
  tmp += a[i]
x[0] = s-tmp
for i in range(n-1):
  x[i+1] = a[i]-x[i]
for i in range(n):
  print(2*x[i],end=" ")

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

int main() {
 char c;
   cin >> c;
   if(c == 'a' || (c == 'e' || (c == 'i' ||
      (c == 'o' || c == 'u')))){
     cout << "vowel" << endl;}
  
   else{
     cout << "consonant" << endl;}
}



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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int n, p;
  while(cin >> n >> p, n || p){
    vector<int> MayorS(n);
    int bowlS = p;
    int player = 0;
    while(1){
      if(bowlS > 1){      //??¨?????????
        MayorS[player]++;
        bowlS--;
      }else {
        if(bowlS == 1){
          MayorS[player]++;
          bowlS--;
          if(MayorS[player] == p){  //??????
            cout << player << endl;
            break;
          }
        }else {         //????????????or????????????
          if(MayorS[player] > 0){
            bowlS += MayorS[player];
            MayorS[player] = 0;
          }
        }
      }
      player++;
      if(player == n)player = 0;
    }
  }  
}

Measured memory_bytes: 3012
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) ((abs((a)-(b)))<EPS)

int a[100001];
int n,l;

bool check(double f){
	double lf=l;
	double rec=0;
	bool flag=false;
	for(int j=0;j<3;j++){
		for(int i=1;i<=86400;i++){
			if(j==1&&a[i]!=0&&!flag){
				rec=lf;
				flag=true;
			}
			else if(j==2&&a[i]!=0){
				if(EQ(rec,lf))return true;
				return false;
			}
			double b=-a[i]+f;
			lf+=b;
			if(EQ(lf,0)||lf<0)return false;
			lf=min(lf,1.0*l);
		}
	}
	return true;
}

int main(){

	while(cin>>n>>l&&!(n==0&&l==0)){
		memset(a,0,sizeof(a));
		int s,t,u;
		for(int j=0;j<n;j++){
			cin>>s>>t>>u;
			for(int i=s+1;i<=t;i++)a[i]=u;
		}
		double ub=10000000;
		double lb=0;
		int cnt=50;
		while(cnt--){
			double mid=(ub+lb)/2;
			if(check(mid))ub=mid;
			else lb=mid;
		}
		printf("%.10f\n",ub);
	}
	return 0;
}

Measured memory_bytes: 1296
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    priority_queue<int> a;
    for(int i= 0; i < N; ++i)
    {
        int ai;
        cin >> ai;
        a.push(ai);
    }

    for(int i = 0; i < M; ++i)
    {
        int m = a.top();
        a.pop();
        a.push(m / 2);
    }

    unsigned long long sum = 0;
    for(int i = 0; i < N; ++i)
    {
        sum += a.top();
        a.pop();
    }

    cout << sum;
    return 0;
}


Measured memory_bytes: 892
#include<iostream>
using namespace std;
int main(){
  int n,s;
  while(cin >>n>>s,n||s){
    int magic[101] = {0};
    long long sum = 0;
    for(int i=0,a; i<n; i++){
      cin >>a;
      magic[a]++;
    }
    for(int i=1; i<101; i++){
      for(int j=i; j<101; j++){
	if(i+j>s){
	  if(i!=j){sum+=magic[i]*magic[j];}
	  else{sum+=magic[i]*(magic[i]-1)/2;}
	}
      }
    }
    cout <<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
// bear.cpp : Defines the entry point for the console application.
//
//#include "stdafx.h"
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <iomanip>
#include <vector>
using namespace std;
bool cmp(int i, int j)
{
	return i < j;
}
int main()
{
	int n;
	cin >> n;
	int predosly1 = 0;
		int predosly2=1;
		int estepredosly1 = 0;
		int estepredosly2 = 1;
		int tri = 0;
	for (int i = 0; i < n; i++)
	{
		int a;
		int b;
		cin >> a >> b;
		if (a==b)
		{
			tri++;
		}
		if (tri>=3)
		{
				cout << "Yes" << endl;
				return 0;
		}
		if (a != b && tri > 0)
		{
			tri = 0;
		}
	}
	cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define endl '\n' 
using namespace std ;

int main() 
{
	int t , d; 
	cin >> t >> d; 
	
	int cnt = 0 ; 
	while(t--){ 
		int a , b ; 
		cin >> a >> b ; 
		
		if(sqrt( pow(a,2) + pow(b,2) ) <= d){
			cnt++ ; 
		}
	}
	
	cout << cnt << endl ; 
	
	return 0 ; 
}


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

using ll = long long;
using P = pair<int, int>;

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

int main() {
  string s;
  cin >> s;

  int zero, one;
  zero = one = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') zero++;
    if (s[i] == '1') one++;
  }

  cout << s.size() - (max(zero, one) - min(zero, one)) << endl;
  return 0;
}


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


int main() {
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double akakudo = 30 *h + 0.5 * m;
	double bkakudo = 6 * m;
	double kakudo = abs(akakudo - bkakudo);
	double rad = kakudo * 3.14159265358979323846263383 / 180;
	double dis = a * a + b * b - 2*a * b * cos(rad);
	cout << setprecision(15) << sqrt(dis) << endl;
	return 0;
}

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

// 負の数にも対応した%演算
ll mod(ll val, ll m) {
  ll res = val%m;
  if (res<0) res += m;
  return res;
}

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  // (A[0]+A[1]+...+A[N-1])%MOD
  ll sum = 0;
  for (int i=0; i<N; i++) {
    sum += A[i];
    sum %= MOD;
  }
  ll res = 0;
  for (int i=0; i<N-1; i++) {
    sum = mod(sum%MOD-A[i]%MOD, MOD);
    res += A[i]*sum%MOD;
    res %= MOD;
  }
  cout << res%MOD << endl;
  return 0;
}

Measured memory_bytes: 4796
#include <stdio.h>

#define INF 100000

int matrixChainOrder();
int min(int, int);

int n;
int r[100];

int main(){
  int i,total;
  int c[100];
  
  scanf("%d", &n);

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

  r[n]=c[n-1];
  
  printf("%d\n",matrixChainOrder());

  return 0;

}

int matrixChainOrder(){

  int m[100][100];
  int i,l,j,k,q;

  n++;  

  for(i=1 ; i<n ; i++){
    m[i][i] = 0;
  }

 
  for(l=2 ; l<=n-1 ; l++){
    for(i=1 ; i<=n-l+1 ; i++){
      j = i+l-1;
      m[i][j] = INF;
      for(k=i ; k<=j-1 ; k++){
	q = m[i][k] + m[k+1][j] + r[i-1]*r[k]*r[j];
	m[i][j] = min(m[i][j],q);
      }
	
    }
  }

  return m[1][n-1];
}

int min(int x, int q){
  if(x<q) return x;
  else return q;
}

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

int main()  
{   
    cin.tie(0); ios::sync_with_stdio(false);  
	string s; cin >> s;
	int a[4];
	a[0] = s[0] - '0';
	a[1] = s[1] - '0';
	a[2] = s[2] - '0';
	a[3] = s[3] - '0';
	
	int fmm = a[2]*10 + a[3];
	int smm = a[0]*10 + a[1];
	if ((fmm > 0 && fmm <=12) && (smm > 0 && smm <=12))
		cout << "AMBIGUOUS\n";
	else if ((fmm > 0 && fmm <=12) && !(smm > 0 && smm <=12))
		cout << "YYMM\n";
	else if (!(fmm > 0 && fmm <=12) && (smm > 0 && smm <=12))
		cout << "MMYY\n";
	else
		cout << "NA\n";
	



	return 0;   
}  

Measured memory_bytes: 256
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_C&lang=jp
#?´???°??????
#x????´???°y???2 < y < sqrt(x)??????????????¨??????

from math import sqrt,ceil

def check_prime_number(n):
    sqrt_num = ceil(sqrt(n))
    
    if n == 2:
        return True
    elif n < 2 or (n % 2) == 0:
        return False

    div = 3
    while div <= sqrt_num:
        if (n % div) == 0:
            return False
        div += 2
        
    return True

def count_prime_numbers(n_list):
    ans = 0
    for n in n_list:
        if check_prime_number(n):
            ans += 1
    return ans

def main():
    num = int(input())
    target_list = [int(input()) for i in range(num)]
    print(count_prime_numbers(target_list))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 7964
let n = stdin.ReadLine() |> int
let a = stdin.ReadLine().Split() |> Array.map int

let countElement2 x =
    let rec countElement2 x i =
        match x%2 with
        |0 -> countElement2 (x/2) (i+1)
        |_ -> i
    countElement2 x 0

a |> Seq.map countElement2 |> Seq.sum |> stdout.WriteLine 


Measured memory_bytes: 14548
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
L = LI()
c = itertools.combinations(L, 3)
ans = 0
for i, j, k in c:
    if i+j > k and j+k > i and i+k > j and i != j and j != k and k != i:
        ans += 1
print(ans)


Measured memory_bytes: 75248
#include <cmath>
#include <vector>
#include <iomanip>
#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <algorithm>
#include <limits>
#include <list>
#include <stack>
#include <tuple>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef vector<ll> VL;
typedef vector<VL> VVL;

string s1, s2;
VVI cnt1, cnt2;

void fillcnt(VVI& cnt, string& s) {
	cnt = VVI(s.size(), VI(26, 0));
	cnt[0][s[0]-'a'] = 1;
	for (int i = 1; i < s.size(); ++i) {
		cnt[i] = cnt[i-1];
		cnt[i][s[i]-'a']++;
	}
}

bool equal_cnt(int i1, int j1, int i2, int j2) {
	for (int k = 0; k < 26; ++k) {
		int d1 = cnt1[j1][k] - (i1 == 0 ? 0 : cnt1[i1-1][k]);
		int d2 = cnt2[j2][k] - (i2 == 0 ? 0 : cnt2[i2-1][k]);
		if (d1 != d2) return false;
	}
	return true;
}

VI vals = { 1, 3, 5, 11, 13, 17, 31, 42, 56, 67, 79, 86, 93, 156, 249, 
					 372, 271, 346, 449, 879, 764, 913, 637, 267, 435, 289 };
int main() {
	ios::sync_with_stdio(false);
	cin >> s1 >> s2;
	fillcnt(cnt1, s1);
	fillcnt(cnt2, s2);
	/*unordered_map<ll, VP> ht;
	for (int i = 0; i < s1.size(); ++i) {
		ll hs = 0;
		for (int j = i; j < s1.size(); ++j) {
			hs += vals[s1[j]-'a'];
			ht[gethash(hs, j-i+1)].emplace_back(i, j);
		}
	}
	int sol = 0;
	for (int i = 0; i < s2.size(); ++i) {
		ll hs = 0;
		for (int j = i; j < s2.size(); ++j) {
			hs += vals[s2[j]-'a'];
			if (ht.count(gethash(hs, j-i+1)) == 0) continue;
			for (auto& pr : ht[gethash(hs, j-i+1)]) {
				if (equal_cnt(pr.first, pr.second, i, j))
					sol = max(sol, j-i+1);
			}
		}
	}*/
	int sol = 0;
	for (int jmp = min(s1.size(), s2.size())-1; jmp >= 0; --jmp) {
		unordered_map<ll, VI> ht;
		ll hs = 0;
		for (int i = 0; i < jmp; ++i) hs += vals[s1[i]-'a'];
		for (int i = 0; i+jmp < s1.size(); ++i) {
			hs += vals[s1[i+jmp]-'a'];
			ht[hs].push_back(i);
			hs -= vals[s1[i]-'a'];
		}
		hs = 0;
		for (int i = 0; i < jmp && i < s2.size(); ++i) hs += vals[s2[i]-'a'];
		for (int i = 0; i+jmp < s2.size(); ++i) {
			hs += vals[s2[i+jmp]-'a'];
			if (ht.count(hs) != 0) {
				for (int i1 : ht[hs]) {
					if (equal_cnt(i1, i1+jmp, i, i+jmp))
						sol = max(sol, jmp+1);
				}
			}
			hs -= vals[s2[i]-'a'];
		}
		if (sol > 0) break;
	}	
	cout << sol << '\n';
}

Measured memory_bytes: 4328
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

Q,H,S,D = imn()
N = iin()

min1L = min(Q*4, H*2, S)
min2L = min(min1L*2, D)

if N % 2 == 1:
    print(N//2*min2L + min1L)
else:
    print(N//2*min2L)


Measured memory_bytes: 5300
N, K = [int(x) for x in input().split()]

d = []
A = []
for i in range(K):
    _d = int(input())
    d.append(_d)
    _a = [int(x) for x in input().split()]
    A.append(_a)

res = []
for i in range(1, N+1):
    res.append(i)

for a in A:
    for _a in a:
        if _a in res:
            res.remove(_a)
print(len(res))


Measured memory_bytes: 9192
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int m[11][331],b[10],n,s;
void f(int s,int d){
  int i;
  if(d==n)
    m[n][s]++;
  else{
    for(i=0;i<10;i++){
      if(b[i]==-1){
	b[i]=1;
	f(s+(d+1)*i,d+1);
	b[i]=-1;
      }
    }
  }
  return;
}
int main(){
  memset(m,0,sizeof(m));
  memset(b,-1,sizeof(b));
  for(n=1;n<10+1;n++)
    f(0,0);
  while(cin>>n>>s){
    if(n>10||s>330)
      cout<<0<<endl;
    else
      cout<<m[n][s]<<endl;
  }
  return 0;
}

Measured memory_bytes: 820
N = int(input())
nums = [  list(map(int,input().split(" "))) for _ in range(N) ]

for i in range(N):
    a,b = nums[i]
    nums[i].append(a + b)
nums =sorted(nums,key = lambda x:-x[2])

takahasi = [nums[i][0] for i  in  range(N) if i % 2 == 0]
aokis= [nums[i][1] for i  in  range(N) if i % 2 != 0]
print(sum(takahasi) - sum(aokis))

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int n1 = 0, n2 = 0, n4 = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] % 2) n1++;
    else if (a[i] % 4) n2 ++;
    else n4++;
  }
  cout << (n1 + !!n2 <= n4 + 1 ? "Yes" : "No") << "\n";
  return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
  int w, h, x, y;

  cin >> w >> h >> x >> y;

  cout << 0.5 * w * h << endl;
  if (2*x == w && 2*y == h) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    cout << a * b << '\n';
    return 0;
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 10 21:04:16 2020

@author: masat
"""

N = int(input())
S = input()

counter = 0
for i in range(N):
    if S[i:i+3] == "ABC":
        counter += 1
    else:
        pass

print(counter)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  string ans = "";
  for(ll i = 0; i < ty - sy; i++) ans += 'U';
  for(ll i = 0; i < tx - sx; i++) ans += 'R';
  for(ll i = 0; i < ty - sy; i++) ans += 'D';
  for(ll i = 0; i < tx - sx; i++) ans += 'L';
  ans += 'L';
  for(ll i = 0; i < ty - sy + 1; i++) ans += 'U';
  for(ll i = 0; i < tx - sx + 1; i++) ans += 'R';
  ans += 'D';
  ans += 'R';
  for(ll i = 0; i < ty - sy + 1; i++) ans += 'D';
  for(ll i = 0; i < tx - sx + 1; i++) ans += 'L';
  ans += 'U';
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
    ll n,x; cin >> n >> x;

    vector<ll> m(n);
    int sum = 0;
    rep(i,n){
        cin >> m[i];
        sum += m[i];
    }
    x -= sum;
    int ans = n;

    int min = *min_element(m.begin(),m.end());
    while(min <= x){
        x -= min;
        ans++;
    }
    print(ans);
}

Measured memory_bytes: 256
while True:
    s = input()
    if s == '.': break
    pl = [c for c in s if c == '(' or c == ')' or c == '[' or c == ']']
    flag = False
    while True:
        if len(pl) == 0:
            flag = True
            break
        if len(pl) == 1: break
        flag2 = False
        for i in range(len(pl) - 1):
            if (pl[i] == '(' and pl[i + 1] == ')') or (pl[i] == '[' and pl[i + 1] == ']'):
                del pl[i + 1]
                del pl[i]
                break
            elif i == len(pl) - 2:
                flag2 = True
        if flag2: break
    print('yes' if flag else 'no')

Measured memory_bytes: 6724
package main

import (
	"fmt"
)

func main() {
	var a, b string
	fmt.Scan(&a, &b)
	if len(a) > len(b) {
		fmt.Println("GREATER")
		return
	}
	if len(a) < len(b) {
		fmt.Println("LESS")
		return
	}
	for i := 0; i < len(a); i++ {
		if a[i] > b[i] {
			fmt.Println("GREATER")
			return
		} else if a[i] < b[i] {
			fmt.Println("LESS")
			return
		}
	}
	fmt.Println("EQUAL")
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();

			if (n % 2 == 0) {
				System.out.println(n);
			} else {
				System.out.println(2 * n);
			}
		}

	}

}

Measured memory_bytes: 21844
from itertools import accumulate

n, k = map(int,input().split())

a = list(map(int,input().split()))

for j in range(k):
    if j > 41:
        break

    b = [0] * n

    for i in range(n):
        b[max(0, i - a[i])] += 1
        
        if i + a[i] + 1 < n:
            b[i + a[i] + 1] -= 1

    a = list(accumulate(b))

print(*a)

Measured memory_bytes: 183560
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int f[20];
long long T;
int p[]={3,5,7};
int dfs(int a,long long cur){
	if(cur>T)return 0;
	int key=0;
	int ret=0;
	for(int i=0;i<a;i++){
		if(f[i]==3)key|=1;
		if(f[i]==5)key|=2;
		if(f[i]==7)key|=4;
	}
	if(key==7)ret++;
	for(int i=0;i<3;i++){
		f[a]=p[i];
		ret+=dfs(a+1,cur*10+p[i]);
	}
	return ret;
}
int main(){
	long long a;scanf("%lld",&a);T=a;
	printf("%d\n",dfs(0,0LL));
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
using namespace std;
int main(){
int N;
cin>>N;
int a[N+1];
int b[N+1];
int c[N+1];
a[0]=0;
b[0]=0;
c[0]=0;
for (int i=1;i<=N;++i)cin>>a[i]>>b[i]>>c[i];

int dp [3][100100];

dp[0][0]=0;
dp[1][0]=0;
dp[2][0]=0;
for (int i=1;i<=N;i++){
dp[0][i]=max(dp[1][i-1],dp[2][i-1])+a[i];
dp[1][i]=max(dp[0][i-1],dp[2][i-1])+b[i];
dp[2][i]=max(dp[0][i-1],dp[1][i-1])+c[i];
};
int ans=max(dp[0][N],dp[1][N]);
ans=max(dp[2][N],ans);
cout<<ans<<endl;
}

Measured memory_bytes: 2560
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = list(iss())
    ret = 0
    tmp = 0
    for s in S:
        if s == 'I':
            tmp += 1
        else:
            tmp -= 1
        ret = max(ret, tmp)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3832
#include <iostream>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <set>
using namespace std;

int main(){
    int N;
    string S[200010];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> S[i];
    }

    set<string> kosuu;
    for(int i = 0; i < N; i++){
        kosuu.insert(S[i]);
    }

    cout << kosuu.size() << endl;


}

Measured memory_bytes: 25508
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


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



int main() {
	ll N, K;
	cin >> N >> K;

	ll ans = K;
	repn(i, N - 1) { ans *= (K - 1); }

	cout << ans;
	system("PAUSE");
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define x first
#define y second
const int M=1e6+7;

vector<ll> e[200];

int main() {
 ll n,k,ans=0,m=0;
 cin>>n>>k;
 ll cur=2;

 for(;cur<=n;cur++)
 {
     if(e[1].size()+ans<=k)
        e[1].pb(cur),ans+=e[1].size()-1,m++;
    else
        break;

 }
 

    if(cur<=n)
    {
        if(cur<=n && ans<k)
        {
            ans+=e[1].size();
            e[1].pb(cur);
            m++;
        for(int i=2;i<cur;i++)
                {

                    if(ans==k)
                        break;
                    e[cur].pb(i);
                    ans--;
                    m++;
                }
        cur++;
        }
        while(cur<=n)
        {
            for(int i=1;i<cur;i++)
                e[i].pb(cur),m++;;
            cur++;
        }
            
    }
     
 
 if(ans==k)
 {
     cout<<m<<endl;
     for(int i=1;i<=n;i++)
        for(auto j:e[i])
            cout<<i<<" "<<j<<endl;

 }
 else
 cout<<-1;



}



Measured memory_bytes: 384
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#define INF 100000000
#define ll long long
using namespace std;
int main(){
  int n;
  cin >> n;
  vector< vector< pair<int,int> > > edges(n);
  for(int i = 0; i < n; i++){
    int id = 0;
    cin >> id;
    int k;
    cin >> k;
    for(int j = 0; j < k; j++){
      int v, c;
      cin >> v >> c;
      edges[id].push_back(make_pair(v,c));
    }
  }

  priority_queue< pair<int,int>, vector< pair<int,int> > , less< pair<int,int> > > pq;
  pq.push(make_pair(0,0));
  vector<long long> dist(n, INF);
  dist[0] = 0;
  while(!pq.empty()){
    ll source = pq.top().second;
    pq.pop();
    for(pair<int,int> edge: edges[source]){
      if(dist[edge.first] > dist[source] + edge.second){
	dist[edge.first] = dist[source] + edge.second;
	pq.push(make_pair(dist[edge.first], edge.first));
      }
    }
  }
  for(int i = 0; i < n; i++){
    cout << i << ' ';
    cout << dist[i] << endl;
  }
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin>>n>>s;
  int m=0;
  for(int i=1;i<n;i++){
    set<char> f;
    set<char> b;
    for(int j=0;j<n;j++){
      if(j<i)
        f.insert(s.at(j));
      else
        b.insert(s.at(j));
    }
    int c=0;
    for(char x:f)
      for(char y:b)
        if(x==y)
          c++;
    m=max(m,c);
  }
  cout<<m<<endl;
}

Measured memory_bytes: 256
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)

num_lcm = lcm(*a)
lst = [num_lcm//a_i for a_i in a]

for i in lst:
    if i % 2 == 0:
        print(0)
        exit()

harf_lcm = num_lcm // 2
if m < harf_lcm:
    print(0)
else:
    print(1+(m-harf_lcm)//num_lcm)

Measured memory_bytes: 24812
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

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

  int N, K;
  cin >> N >> K;
  int ans = K;
  rep(i,N-1){
    ans *= K-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()
typedef long long ll;
#define rep(i, z, n) for(int i = z; i < n; i++)
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    string S, T;
    cin >> S >> T;
    int count = 0;
    rep(i, 0, 3){
        if(S.at(i) == T.at(i)) count++;
    }
    
    cout << count << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
using ll = long long;
const int INF = 1e9 + 5;

int main()
{
    string s,t;
    ll cnt=0;
    cin>>s>>t;
    if(s.size()+1==t.size())
    {
        for(ll i=0;i<s.size();i++)
        {
            if(s[i]!=t[i])
                cnt++;
        }
        if(cnt>0)
            cout<<"No";
        else
            cout<<"Yes";
    }
    else
        cout<<"No";
    return 0;
}


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

using namespace std;

struct posi {
	int y;
	int x;
};

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

int maxdepth;
int depth;

void dfs(vector<vector<int>> &mapp, posi &s, vector<vector<bool>> &seen) {
	//if (G[s].size() == 0) {
	//	return;
	//}

	seen[s.y][s.x] = true;
	depth++;
	//if (maxdepth < depth) { 
	//	maxdepth = depth; 
	//	cout << s.x << " " << s.y << " " << maxdepth << endl;
	//}
	maxdepth = max(maxdepth, depth);

	for (int i = 0; i < 4; i++) {

		posi n;
		n.y = s.y + dy[i];
		n.x = s.x + dx[i];
		if (mapp[n.y][n.x]==1 && seen[n.y][n.x] == false) {
			dfs(mapp, n, seen);
		}


	}
	depth--;
	seen[s.y][s.x] = false;

}

int main() {

	while (1) {
		maxdepth = 0;
		int m, n;
		cin >> m >> n;
		if (m == 0 && n == 0) { return 0; }
		vector <vector<int>> mapp(n + 2, vector<int>(m + 2));

		//マップ読み込み
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				cin >> mapp[i][j];
			}
		}

		vector<vector<bool>> seen(n + 2, vector<bool>(m + 2, false));

		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				if (mapp[i][j] == false) { continue; }
				posi s;
				s.y = i;
				s.x = j;
				dfs(mapp, s, seen);
			}
		}

		cout << maxdepth << endl;
	}
	return 0;

}


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

int main(){
  int n,m,ans=0;
  cin>>n>>m;
  vector<vector<int>> edges(n+1,vector<int>(n+1,0));
  for (int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    edges.at(a).at(b)++;
    edges.at(b).at(a)++;
  }
  vector<int> vertex={};
  for (int i=1;i<=n;i++){
    vertex.push_back(i);
  }
  do{
    if (vertex.at(0)!=1) continue;
    int tmp=100000;
    for (int i=0;i<n-1;i++){
      int x=vertex.at(i),y=vertex.at(i+1);
      tmp=min(tmp,edges.at(x).at(y));
    }
    ans+=tmp;
  }while(next_permutation(vertex.begin(),vertex.end()));
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    int mi=INF;
    int ans=0;
    rep(i,N){
        int a; cin >> a;
        if(mi>a) ans++;
        chmin(mi,a);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ans = 0
num = ["a"] * n
for _ in range(m):
    s, c = map(int, input().split())
    if s == 1 and c == 0:
        ans = -1
        break
    if num[s - 1] != "a" and num[s - 1] != c:
        ans = -1
        break
    num[s - 1] = c

numStr = ""

if n == 1 and num[0] == "a":
    numStr = ""
    ans = 0

elif num[0] == "a":
    num[0] = "1"

for l in range(n):
    if num[l] == "a":
        numStr += "0"
    else:
        numStr += str(num[l])

print(ans if ans == -1 else numStr)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m;
    cin >> n >> m;
    vector<int> p(m);
    int q[12][12];
    rep(i,m){
        cin >> q[i][0];
        for(int j=1;j<=q[i][0];++j){
            int y; cin >> y;
            --y;
            q[i][j]=y;
        }
    }
    rep(i,m) cin >> p[i];
    int ans=0;
    for (int bit = 0; bit < (1<<n); ++bit) {
        bool ok=true;
        rep(j,m){
            int x=0;
            for (int i=1; i<=q[j][0]; ++i) {
                if (bit & (1 << q[j][i])) {
                    ++x;
                }
            }
            if(x%2!=p[j]){
                ok=false;
                break;
            }
        }
        if(ok) ++ans;
    }
    cout << ans << "\n";
    return 0;
}   

Measured memory_bytes: 3596
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		char[] sChar=s.toCharArray();
		
		if(sChar[2]==sChar[3] && sChar[4]==sChar[5])System.out.println("Yes");
		else System.out.println("No");
		
		sc.close();
	}
}


Measured memory_bytes: 35660
a=[]
for q in range(4):
  g=int(input())
  a.append(g)
#a,b,c,x=map(int,input().split())
ans=0
for i in range(a[0]+1):
   for j in range(a[1]+1):
      for k in range(a[2]+1):
      	if a[3]==500*i+100*j+50*k:
        	ans+=1
print(ans)

Measured memory_bytes: 3060
use std::io::{self, Read};
use std::str::FromStr;
pub struct Scanner<R: Read> {
    reader: R,
}
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let s = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.expect("failed to read char") as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        s.parse::<T>().ok().expect("failed to parse token")
    }
}

fn main() {
    let sin = io::stdin();
    let sin = sin.lock();
    let mut sc = Scanner::new(sin);

    let n: usize = sc.read();

    // 隣接リストの作成
    let mut adj_list: Vec<Vec<usize>> = vec![];

    for _ in 0..n {
        let _i: usize = sc.read();
        let k: usize = sc.read();
        
        let ls: Vec<usize> = if k == 0 { 
            vec![]
        } else {
            // 0開始のindexに修正
            (0..k).map(|_| sc.read::<usize>()-1).collect()
        };
        adj_list.push(ls); 
    }

    // println!("{:?}", adj_list);

    // 隣接行列の作成
    let mut adj_mat: Vec<Vec<usize>> = vec![vec![0; n]; n];

    for i in 0..n {
        for j in adj_list[i].iter(){
            adj_mat[i][*j] = 1;
        }
    }

    // println!("{:?}", adj_mat);
    for v in adj_mat.iter() {
        let s = v.iter()
            .map(|a| a.to_string())
            .collect::<Vec<String>>()
            .join(" ");
        println!("{}", s);
    }
}



Measured memory_bytes: 5040
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main() {
  string s;
  cin>>s;
  
  bool b=true;
  int cnt=0,x;
  if(s[0]!='A') b=false;
  for(int i=2;i<s.size()-1;i++){
    if(s[i]=='C'){
      cnt++;
      x=i;
    }
  }
  if(cnt!=1) b=false;
  for(int i=1;i<s.size();i++){
    if(i==x) continue;
    if(s[i]<'a' || s[i]>'z') b=false;
  }
  if(b) cout<<"AC"<<endl;
  else cout<<"WA"<<endl;

  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;

signed main(){
    int a,b;
    cin >> a >> b >> n;
    int x = min(b-1,n);
    double d = (double)x/b;
    d *= a;
    int ans = (int)d;
    print(ans);

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

//key以上の初めてのitr
int nibul(auto a,auto b){return lower_bound(All(a),b) - a.begin();}
//key以下の最後のitr
int nibuu(auto a,auto b){return upper_bound(All(a),b) - a.begin()-1;}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 3636
float h,k;char*H="9=BHV`~17=CS^~";main(i){for(;~scanf("%f%f",&h,&k);puts("AAA\0B\0C\0D\0E\0NA"+i+(i-2)*(i>2)))for(i=0;i<7&&(h>=H[i]/2.+7||k-H[7+i]>=22);i++);}

Measured memory_bytes: 0
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    X, Y = map(int, input().split())

    ret = 'No'
    for n in range(X+1):
        m = X-n
        if Y==(2*n+4*m):
            ret = 'Yes'
            break

    print(ret)

if __name__ == '__main__':
    main()

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


int main() {

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

	bool can = false;
	for (int i = 1;i <= B;i++) {
		if (A * i % B == C) {
			can = true;
			break;
		}
	}
	if (can)
		cout << "YES";
	else
		cout << "NO";
}

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

typedef long long ll;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()

int main(void)
{
  ll N,size;
  ll ans = 0;

  cin >> N;

  size = (int)log10(N);
  for(int i=1;i<=size;i+=2){
    ans += 9*(int)pow(10,i-1);
  }
  if(size%2==0)
  {
    ans += N - (int)pow(10,size) + 1;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 2000;

int aa[N + 1], dp[N], dq[N];

int main() {
	int n, z, w; cin >> n >> z >> w;
	aa[0] = w;
	for (int i = 1; i <= n; i++)
		cin >> aa[i];
	for (int i = n - 1; i >= 0; i--) {
		dp[i] = dq[i] = abs(aa[i] - aa[n]);
		for (int j = i + 1; j < n; j++) {
			dp[i] = max(dp[i], dq[j]);
			dq[i] = min(dq[i], dp[j]);
		}
	}
	cout << dp[0] << '\n';
	return 0;
}


Measured memory_bytes: 3624
x, y = map(int, input().split())
if y > 0:
  if x < - y:
    ans = - y - x + 1
  elif -y <= x < 0:
    ans = y + x + 1
  elif 0 <= x <= y:
    ans = y - x
  else:
    ans = x - y + 2
elif y < 0:
  if x < y:
    ans = y - x
  elif y <= x < 0:
    ans = - y + x + 2
  elif 0 <= x <= - y:
    ans = - y - x + 1
  else:
    ans = y + x + 1
else:
  if x <= 0:
    ans = abs(x)
  else:
    ans = x + 1

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

int main(){
	int c[9];
	int i;
	int flag=0;
	for(i=0;i<3;i++){
		scanf("%d%d%d",&c[3*i],&c[3*i+1],&c[3*i+2]);
	}
	
	if(c[0]-c[1]==c[3]-c[4] && c[0]-c[1]==c[6]-c[7] && c[1]-c[2]==c[4]-c[5] && c[1]-c[2]==c[7]-c[8] && c[0]-c[3]==c[1]-c[4] && c[0]-c[3]==c[2]-c[5] && c[3]-c[6]==c[4]-c[7] && c[3]-c[6]==c[5]-c[8]){
		flag=1;
	}
	if(flag==1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
fun main() {
    val (n, x, t) = readInts()
    val segs = n/x + (if (n % x == 0) 0 else 1)
    println(segs * t)
}

// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")
private fun readInts() = readStrings().map { it.toInt() }


Measured memory_bytes: 36472
n,k,*a=map(int,open(0).read().split())

for _ in range(k):
    tab=[0]*n
    for i in range(n):
        q=a[i]
        l=max(0,i-q)
        tab[l]+=1
        r=i+q+1
        if r<n:
            tab[r]-=1
    b=[tab[0]]
    for i in range(n-1):
        b.append(b[-1]+tab[i+1])
        
    if a==b:
        break
    else:
        a=b[:]
print(*a)

Measured memory_bytes: 186408
#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 = 1e9;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> x(n);

  rep(i, n) cin >> x[i];

  ll ans = INF;
  for (int i = 0; i < n - k + 1; ++i)
    ans = min({abs(x[i]) + abs(x[i + k - 1] - x[i]),
               abs(x[i + k - 1]) + abs(x[i + k - 1] - x[i]), ans});

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 5;
const int INF = 1e9 + 7;

int n;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	cout << (n ? 0 : 1);
	return 0;
}
//13-09-2020 17:31:19

Measured memory_bytes: 3608
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
	
	
int main(){
	ll a;
	double b;
	cin>>a>>b;
	ll ans,b2;
	b2=round(b*100);
	ans=(a*b2)/100;
	cout<<ans<<endl;
	
}

Measured memory_bytes: 3760
/*
Submitted With (^^) by -> Hossam ^_^
 _____________________
|     ___     ___     |
|    (^_^)   (^_^)    |
|   /( | )\_/( | )\   |
|_____|_|_____|_|_____|
*/

#include <bits/stdc++.h>

using namespace std;

inline void prep()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
}

#define X first
#define Y second
#define ll long long
#define inf (0x7fffffffffffffff)
#define all(x) x.begin(), x.end()
#define ZXC cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl;

const int mod = (int)1e9 + 7;
const int MX = (int)2e5 + 5;

const int MAX_NODES = 5000 * 1000;

int n, k;
string res;

int main()
{
    prep();

    string s;

    cin >> s >> k;
    n = s.size();

    // for(int i = 0; i < n; ++i){
    //     string cur = s.substr(i);
    //     // cerr << cur << endl;
    //     trie.insert(cur);
    // }

    // trie.find(0);

    vector<string> vv;
    for(int i = 0; i < n; ++i){
        for(int len = 1; len <= 5 && i + len <= n; ++len){
            vv.push_back(s.substr(i, len));
        }
    }

    sort(all(vv));
    auto it = unique(all(vv));
    // for(auto x : vv){
    //     cout << x << endl;
    // }
    cout << vv[k - 1] << endl;
    
    // ZXC
    return 0;
}


Measured memory_bytes: 1660