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

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final double A = sc.nextDouble();
        final double B = sc.nextDouble();
        final double C = sc.nextDouble();

        double[] D = new double[N];

        for(int i = 0; i < N; ++i)
        {
            D[i] = sc.nextDouble();
        }
        Arrays.sort(D);

        double k = C;
        double d = A;
        for(int i = D.length - 1; 0 <= i; --i)
        {
            if(k / d < (k + D[i]) / (d + B))
            {
                k += D[i];
                d += B;
            }
        }

        System.out.println((int)(k / d));
    }
}

Measured memory_bytes: 20556
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int N;
int a[200010];
int ans;

int main() {
	cin >> N;

	for (int i = 1; i <= N; i++) {
		cin >> a[i];
		if (a[i] != i) {
			i--;
			N--;
			ans++;
		}
	}
	if (N == 0)ans = -1;
	
	for (int i = 1; i <= N; i++) {
		if (a[i] != i) {
			ans = -1;
		}
	}

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

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

int main(){
	char s[100], t[100];
	char c;
	int i, j, ls, lt, x;
	cin >> s;
	cin >> t;
	ls=strlen(s);
	lt=strlen(t);
	
	if(ls!=lt)
	{
		cout << "No" << endl;
		return 0;
	}
	
	int f=0;
	for(i=0; i<ls; i++)
	{
		c=s[ls-1];
		for(j=ls-1; j>0; j--)
		{
			s[j]=s[j-1];
		}
		s[0]=c;
		
		x=strcmp(s,t);
		if(x==0)
		{
			f=1;
			break;
		}
	}
	if(f==1)
	cout << "Yes" << endl;
	else
	cout << "No" << endl;
		
	return 0;
	
	
}
	


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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int MOD = 1'000'000'000 + 7;
const int INF = 1'000'000'000 + 5;

struct combination {
	const static int MAX = 2'000'000;
	ll fac[MAX], finv[MAX], inv[MAX];
	combination() {
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		srep(i, 2, MAX) {
			fac[i] = fac[i - 1] * i % MOD;
			inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
			finv[i] = finv[i - 1] * inv[i] % MOD;
		}
	}
	ll get(int n, int k) {
		if (n < k) return 0;
		if (n < 0 || k < 0) return 0;
		return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}
} comb;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(16);

	int x, y; std::cin >> x >> y;
	int mi = min(x, y), ma = max(x, y);
	int diff = ma - mi;
	int src = ma - diff * 2;
	if (src < 0 || src % 3 != 0)
		std::cout << 0 << "\n";
	else
		cout << comb.get(src / 3 * 2 + diff, src / 3) << "\n";
}


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

typedef long long ll;

ll N, L;
multiset<ll> X;

struct Node {
  ll x;
  Node *kids[2];
  Node(ll x) {
    this->x = x;
    kids[0] = kids[1] = nullptr;
  }
};
Node *Root;

ll R;

void go(const string &s, ll i, Node *node) {
  assert(node != nullptr);
  ll x = node->x;
  assert(x != 0);
  if (i == s.size()) {
    assert(x > 0);
    X.erase(X.find(x));
    node->x = 0;
    return;
  }
  if (x > 0) {
    assert(node->kids[0] == nullptr && node->kids[1] == nullptr);
    X.erase(X.find(x));
    node->x = -1;
    for (ll b : {0, 1}) {
      node->kids[b] = new Node(x - 1);
      X.insert(x - 1);
    }
  }
  go(s, i + 1, node->kids[s[i] - '0']);
}
int main() {
  cin >> N >> L;
  Root = new Node(L + 1);
  X.insert(L + 1);
  for (ll i = 0; i < N; ++i) {
    string s;
    cin >> s;
    go(s, 0, Root);
  }
  for (ll x : X) {
    R ^= x & (-x);
  }
  cout << (R != 0 ? "Alice" : "Bob") << endl;
}


Measured memory_bytes: 17536
// finish date: 2018/04/21

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>

vi totalcost;
int H, W, D;
map<int, pii > mp;

int memo(int t) {
    if (totalcost[t] != 0) return totalcost[t];
    if (t - D <= 0) return 0;
    totalcost[t] = abs(mp[t].first - mp[t - D].first) + abs(mp[t].second - mp[t - D].second);
    totalcost[t] += memo(t - D);
    return totalcost[t];
}

int main() {

    cin >> H >> W >> D;
    totalcost = vi(H * W + 1, 0);
    vvi A(H, vi(W));
    rep(i, H) {
        rep(j, W) {
            cin >> A[i][j];
            mp[A[i][j]] = make_pair(i, j);
        }
    }
    int Q;
    cin >> Q;
    int L, R;
    for (int i = H * W; i > 0; i--) memo(i);
    rep(i, Q) {
        cin >> L >> R;
        cout << totalcost[R] - totalcost[L] << endl;
    }

    return 0;
}

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

struct work{
    int a;
    int b;
};

int main(){
    int N;
    cin >> N;
    vector<work> w(N);
    for(int i=0; i<N; i++)
        cin >> w[i].a >> w[i].b;
    
    sort(w.begin(), w.end(), [](work a, work b) -> bool { return a.b < b.b; });

    long long int sum = 0;
    bool flag = true;
    for(int i=0; i<N; i++){
        sum += w[i].a;
        if(sum > w[i].b){
            flag = false;
            break;
        }
    }
    
    if(flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;   
    return 0;
}

Measured memory_bytes: 1792
import sys,math
sys.setrecursionlimit(10**9)
from collections import defaultdict
 
IA = lambda: map(int,input().split())
IAS= lambda: map(str,input().split())
 
a,b,c=IA()
temp=c-a-b
if temp<0:
  print("No")
else:
  if temp*temp>4*a*b:
    print("Yes")
  else:
    print("No")

  


Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int a,b,c,ans;
    cin >> a >> b >> c;
    ans=3;
    if(a==b)ans--;
    if(a==c|b==c)ans--;
    cout <<ans;
    return 0;
}


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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line



int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> G[n];
	rep(i,m){
		int a, b;
		cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<int> ans(n);
	ans[0] = 0;
	// 親を受け取る
	queue<int> que;
	que.push(0);
	vector<bool> check(n);
	check[0] = true;
	while(!que.empty()){
		int P = que.front(); que.pop();
		for(auto x:G[P]){
			if(x == P) continue;
			if(check[x]) continue;
			ans[x] = P+1;
			que.push(x);
			check[x] = true;
		}
	}
	cout << "Yes" << endl;
	For(i,1,n){
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 10140
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main{
	static int[] dx = {1, 0, -1, 0};
	static int[] dy = {0, 1, 0, -1};

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if(w==0 && h==0) break;

			int[][] map = new int[2*h+3][2*w+3];
			Deque<Point> q = new ArrayDeque<Point>();

			Arrays.fill(map[1], 1);
			for(int i=2; i<=2*h; i++){
				map[i][1] = 1;
				for(int j = (i%2==0) ? 3 : 2; j<=2*w; j+=2){
					map[i][j] = sc.nextInt();
				}
				map[i][2*w+1] = 1;
			}
			Arrays.fill(map[2*h+1], 1);

			q.offer(new Point(2, 2, 1));
			map[2][2] = 1;
			while(!q.isEmpty()){
				if(map[2*h][2*w]!=0) break;
				Point p = q.poll();
				p.cnt++;

				for(int i=0; i<4; i++){
					if(map[p.y+dy[i]][p.x+dx[i]]==0 && map[p.y+2*dy[i]][p.x+2*dx[i]]==0){
						map[p.y+2*dy[i]][p.x+2*dx[i]] = p.cnt;
						q.offer(new Point(p.x+2*dx[i], p.y+2*dy[i], p.cnt));
					}
				}
			}

			System.out.println((map[2*h][2*w]!=0) ? map[2*h][2*w] : 0);
		}
	}

	static class Point{
		int x, y, cnt;
		Point(int a, int b, int c){
			x = a;
			y = b;
			cnt = c;
		}
	}
}

Measured memory_bytes: 67404
N = int(input())
S = list(input())

C = 0
for i in range(1, N):
  if S[i] == "E":
    C += 1
    
A = C
for i in range(1, N):
  if S[i-1] == "W":
    C += 1
  if S[i] == "E":
    C -= 1
  if A > C:
    A = C
    
print(A)

Measured memory_bytes: 6048
#include<stdio.h>

int N,s[100000];

int solve(int i,int m){
  int res;
  if(m==0)return 1;
  if(i>=N)return 0;
  res=solve(i+1,m)||solve(i+1,m-s[i]);
  return res;
}

int main(){

  int i,j,N2,flag=0,m;

  scanf("%d",&N);

  for(i=0;i<N;i++){
    scanf("%d",&s[i]);
  }

  scanf("%d",&N2);

  for(j=0;j<N2;j++){
    scanf("%d",&m);
    flag=solve(0,m);
    if(flag==1)printf("yes\n");
    else printf("no\n");
  }

  return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)

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

     ll N;
  cin>> N;
   
  
  cout << pow(N,3) <<endl;




return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.println(tenki(scanner.nextLine(), scanner.nextLine()));
		scanner.close();
	}
	
	public static int tenki(String forecast, String weather) {
		int result = 0;
		for(int i = 0; i < 3; i++) {
			if(forecast.charAt(i) == weather.charAt(i)) {
				result++;
			}
		}
		return result;
	}
}

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

using namespace std;
vector<int> adj[60];
vector<int> query[60];
vector<int> qx[60];
int mu[60], mv[60];
int lca[60][60];
int head[60];
int cum[60];

int find(int u){
    return head[u] == u ? u : (head[u] = find(head[u]));
}

void dfs(int u, int p){
    head[u] = u;
    for(int v:adj[u]){
        if(v != p){
            dfs(v, u);
            head[v] = u;
        }
    }

    for(int v:qx[u]){
        lca[v][u] = lca[u][v] = find(v);
    }

    for(int v:query[u]){
        qx[v].push_back(u);
    }
}

int cover(int u, int p){
    int cnt = 0;
    for(int v:adj[u]){
        if(v != p){
            cnt += cover(v, u);
            cum[u] += cum[v];
        }
    }

    if(cum[u] > 0){
        cnt++;
    }
    return cnt;
}

int main(){
    int n, m;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int u, v;
        cin >>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    cin >>m;
    for(int i = 0;i<m;i++){
        int u, v;
        cin >>u>>v;
        mu[i] = u;
        mv[i] = v;
        query[u].push_back(v);
        query[v].push_back(u);
    }

    dfs(1, 0);

    long long ans = 1LL << (n-1);

    for(int mask = 1;mask < 1<<m;mask++){
        int sign = 1;
        memset(cum, 0, sizeof(cum));

        for(int i=0;i<m;i++){
            if((1<<i) & mask){
                int u = mu[i];
                int v = mv[i];

                cum[u]++;
                cum[v]++;
                cum[lca[u][v]] -= 2;

                sign *= -1;
            }
        }

        int cnt = cover(1, 0);
        ans += sign * (1LL << (n-1-cnt));
    }

    cout << ans <<endl;

}


Measured memory_bytes: 256
import java.util.*;

import org.ietf.jgss.Oid;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int N = sc.nextInt();
        int x[] = new int[N];
        int y[] = new int[N];
        int a[] = new int[N];

        for (int i = 0; i < N; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            a[i] = sc.nextInt();
        }
        int xmin = 0;
        int xmax = W;
        int ymin = 0;
        int ymax = H;
        for (int i = 0; i < N; i++) {
            switch (a[i]) {
            case 1:
                xmin = Math.max(x[i], xmin);
                break;
            case 2:
                xmax = Math.min(x[i], xmax);
                break;
            case 3:
                ymin = Math.max(y[i], ymin);
                break;
            case 4:
                ymax = Math.min(y[i], ymax);
                break;
            }
        }

        if (xmax <= xmin || ymax <= ymin) {
            System.out.println(0);
        } else {
            System.out.println((xmax - xmin) * (ymax - ymin));
        }
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n;
double a,ans;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        ans+=1/a;
    }
    cout<<setprecision(10)<<1/ans<<endl;
}


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

int main(){
	int n, a[15], sum = 0;
	cin >> n;
	for(int i = 0 ; i < n ; i++)
		cin >> a[i];
	
	sort(a, a+n);

	for(int i = 0 ; i < n-1 ; i++)
		sum += a[i];

	if(a[n-1] < sum) cout << "Yes";
	else cout << "No";
	cout << endl;
	return 0;
}

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

using namespace std;



#define MAXN 100001
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, inc[MAXN]={};
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    inc[u]++;
    inc[v]++;
  }
  for (int i = 1; i <= n; ++i) {
    if (inc[i]%2) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 640
h,w = map(int, input().split())
s = []
for i in range(h):
  s.append(input())

l = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w):
    if j == 0:
      if s[i][j] == '#':
        l[i][j] = 0
      else:
        l[i][j] = 1
    else:
      if s[i][j] == '#':
        l[i][j] = 0
      else:
        l[i][j] = l[i][j-1] + 1

r = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w-1, -1, -1):
    if j == w-1:
      if s[i][j] == '#':
        r[i][j] = 0
      else:
        r[i][j] = 1
    else:
      if s[i][j] == '#':
        r[i][j] = 0
      else:
        r[i][j] = r[i][j+1] + 1

u = [[0 for i in range(w)] for j in range(h)]
for j in range(w):
  for i in range(h):
    if i == 0:
      if s[i][j] == '#':
        u[i][j] = 0
      else:
        u[i][j] = 1
    else:
      if s[i][j] == '#':
        u[i][j] = 0
      else:
        u[i][j] = u[i-1][j] + 1

d = [[0 for i in range(w)] for j in range(h)]
for j in range(w):
  for i in range(h-1, -1, -1):
    if i == h-1:
      if s[i][j] == '#':
        d[i][j] = 0
      else:
        d[i][j] = 1
    else:
      if s[i][j] == '#':
        d[i][j] = 0
      else:
        d[i][j] = d[i+1][j] + 1

ans = 0
for i in range(h):
  for j in range(w):
    a = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3
    ans = max(ans, a)

print(ans)

Measured memory_bytes: 185988
#include <stdio.h>

int main(){
	int a[3],i;
	for(i = 0;i < 3;i++){
	scanf("%d",&a[i]);
	}
	if(a[0] + a[1] + a[2] == 17)
		printf("YES");
	else
		printf("NO");
	return 0;
}

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

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

    int result = 0;
    for (int i = 0; i < str.length(); i++)
    {
        if (str[i] == '+')
            result++;
        else
            result--;
    }

    cout << result << endl;
}

Measured memory_bytes: 256
n,C = gets.chomp.split(" ").map(&:to_i)
s = []
t = []
c = []
max_t = 0
n.times do |i|
  s[i],t[i],c[i] = gets.chomp.split(" ").map(&:to_i)
  max_t = t[i] if max_t < t[i]
end
arr = Array.new(C+1){Array.new(max_t+1,0)}
n.times do |i|
  s[i].upto(t[i]) do |j|
    arr[c[i]][j] += 1 if arr[c[i]][j] == 0
  end
end
max = 0
max_t.times do |i|
  sum = 0
  C.times do |j|
    sum += arr[j+1][i+1]
  end
  max = sum if max < sum
end
puts max

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

int main(){
 long long a,b,c,d,ans,ans2,p;
cin>>a>>b>>c;
  if(a%2==0||b%2==0||c%2==0){
    cout<<0<<endl;
    return 0;
  }
    cout<<min(a*b,min(b*c,c*a))<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define req(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define qer(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=998244353;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=200000;
ll S[N+1];
int X[11],Y[11];
int main(){
	int n,m;cin>>n>>m;rep(i,0,m)cin>>X[i]>>Y[i];
    ll ans=0;S[1]=1;
    req(i,2,n){
        ll num=0;
        rep(j,0,m){
            int x=max(0,i-1-Y[j]),y=max(0,i-X[j]);
            num=(num+S[y]-S[x]+mod)%mod;
        }
        S[i]=(S[i-1]+num)%mod;if(i==n)cout<<num;
    }
    return 0;
}

Measured memory_bytes: 5156
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    map<string,int>m;
    string s;
    for (int i=0;i<x;i++){
        cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;
    return 0;
}


Measured memory_bytes: 3664
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc087/tasks/arc090_b
# x0を0に固定したときに各点への最短距離が求められて、それが矛盾しなければ良さそう
# 任意の点から初めて距離を埋めていく

N, M = read_ints()
LRD = []
graph = defaultdict(lambda: [])
for _ in range(M):
    l, r, d = read_ints()
    l -= 1
    r -= 1
    LRD.append((l, r, d))
    graph[l].append((r, d))
    graph[r].append((l, -d))


D = [INF] * N  # 各点の位置


def bfs(start):
    now, dist = start, 0
    que = deque([(now, dist)])
    D[now] = dist
    while que:
        now, dist = que.popleft()
        for to, co in graph[now]:
            to_dist = dist + co
            if D[to] != INF:
                if D[to] != to_dist:
                    print("No")
                    exit()
                continue
            D[to] = to_dist
            que.append((to, to_dist))


for i in range(N):
    if D[i] != INF:
        continue
    bfs(i)

print('Yes')


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

using namespace std;
using ll = long long;

int main() {
    ll x, k, d;
    cin >> x >> k >> d;

    x = abs(x);
    if (x / d >= k) {
        cout << x - d*k << endl;
    }
    else
    {
        long r1 = x % d;
        if ((k - (x - r1) / d) % 2 == 0)
        {
            cout << r1 << endl;
        }
        else
        {
            cout << (d - r1) << endl;
        }
    }
        /*else {
        ll r = x % d;
        if ((k - (x - r) / d) % 2 == 0) cout << r << endl;
        else cout << d - r << endl;
    }*/
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int i;
    for(i = 0; i < n; i++){
        cin >> a.at(i);
    }
    int ans = 0; 
    int cnt = 1;
    for(i = 0; i < n; i++){
        if(a.at(i) != cnt){
            ans++;
        }
        else{
            cnt++;
        }
    }
    if(cnt-1 == n){
        cout << 0 << endl;
    }
    else if(ans == n){
        cout << -1 << endl;
    }
    else{
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
int main() {
    int a, b;
    std::cin >> a >> b;
    std::cout << (a / b) << ' '
              << (a % b) << ' '
              << std::setprecision(8) << std::fixed
              << (static_cast<double>(a) / static_cast<double>(b))
              << std::endl;
    return 0;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

const int MAX = 200000;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    ll blue = k;
    ll red = n - k;
    COMinit();
    for (int i = 1; i <= k; i++)
    {
        ll H = COM(blue - 1, i - 1);
        ll ans = COM(red + 1, i);
        ans = ans * H % MOD;
        cout << ans << endl;
    }
}

Measured memory_bytes: 4992
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const long long mod = 1e9 + 7;

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 powMod(ll n, ll k, ll m) {
	if (k == 0) {
		return 1;
	} else if (k % 2 == 1) {
		return powMod(n, k - 1, m) * n % m;
	} else {
		ll t = powMod(n, k / 2, m);
		return t * t % m;
	}
}

int main() {
	ll a, b;
	cin >> a >> b;
	
	ll ans=0;

	for (ll i = 1; i < 2000; i++) {
		ll n = i*0.08;
		ll m = i*0.1;
		if (a == n && b == m) {
			cout << i << endl;
			return 0;
		}
	}

	cout << -1 << endl;
}

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

struct xy {
	int x, y;
};

xy a[6] = {
	{0,-1},
	{1,-1},
	{-1,0},
	{1,0},
	{0,1},
	{1,1}
};

xy b[6] = {
	{ -1,-1 },
	{ 0,-1 },
	{ -1,0 },
	{ 1,0 },
	{ -1,1 },
	{ 0,1 }
};


int main() {
	int w, h;
	cin >> w >> h;

	vector<vector<int> > map(h+2, vector<int>(w+2, -1));

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> map[i + 1][j + 1];
		}
	}

	int ans = 0;

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (map[i + 1][j + 1] == 1 || map[i + 1][j + 1] == -1)continue;

			bool flag = false;
			vector<vector<bool> > used(h + 2, vector<bool>(w + 2, false));
			used[i + 1][j + 1] = true;
			xy pos = { j + 1,i + 1 };
			queue<xy> q;
			q.push(pos);

			vector<xy> root;
			while (!q.empty()) {
				xy u = q.front(); q.pop();
				if (u.y % 2 == 0) {
					for (int k = 0; k < 6; k++) {
						if (map[u.y + b[k].y][u.x + b[k].x] == 0 && used[u.y + b[k].y][u.x + b[k].x] == false) {
							xy temp = { u.x + b[k].x , u.y + b[k].y };
							q.push(temp);
							used[temp.y][temp.x] = 1;
						}
						else if (map[u.y + b[k].y][u.x + b[k].x] == -1) {
							flag = true;
							goto loop;
						}
					}
				}
				else {
					for (int k = 0; k < 6; k++) {
						if (map[u.y + a[k].y][u.x + a[k].x] == 0 && used[u.y + a[k].y][u.x + a[k].x] == false) {
							xy temp = { u.x + a[k].x , u.y + a[k].y };
							q.push(temp);
							used[temp.y][temp.x] = 1;
						}
						else if (map[u.y + a[k].y][u.x + a[k].x] == -1) {
							flag = true;
							goto loop;
						}
					}
				}
				root.push_back(u);
			}
		loop:
			if (flag) {
				map[i + 1][j + 1] = -1;
				for (int k = 0; k < root.size(); k++) {
					map[root[k].y][root[k].x] = -1;
				}
			}
			else {
				map[i + 1][j + 1] = 1;
				for (int k = 0; k < root.size(); k++) {
					map[root[k].y][root[k].x] = 1;
				}
			}
		}
	}

	for (int i = 1; i < h + 1; i++) {
		for (int j = 1; j < w + 1; j++) {
			if (map[i][j] != 1) continue;
			for (int k = 0; k < 6; k++) {
				if (i % 2 == 0) {
					if (map[i + b[k].y][j + b[k].x] == -1) ans++;
				}
				else {
					if (map[i + a[k].y][j + a[k].x] == -1) ans++;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <string>
#include <cstdio>
#define ULL unsigned long long
using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int F = a * b;
    int L = c * d;
    if (F < L)
        cout << L << endl;
    else
        cout << F << endl;
    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	ll N, K;
	cin >> N >> K;
	vecl(A);
	vecl(F);
	ll sum = 0;
	fx(N) {
		vecpl(A);
	}
	fx(N) {
		vecpl(F);
	}
	sorts(A);
	sorts(F);
	reverses(F);
	ll maxi = 0;
	fx(N) {
		maxi =max( F[x] * A[ x],maxi);
	}
	ll left = 0, right = maxi;
	ll ans = (left + right) / 2;
	ll k = K;
	fx(60) {
		bool flag = true;
		ans = (left + right) / 2;
		K = k;
		fy(N) {
			if (F[y]*A[y]>ans) {
				if (K< A[y] - ans/F[y]) {
					flag = false;
					break;
				}
				K -=A[y] - ans / F[y];
			}
		}
		if (flag) {
			right = ans;
		}
		else {
			left = ans;
		}

	}
	ce(right)
    return 0;
}



Measured memory_bytes: 4848
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int minC = 1001;
		for(int i=0,l=N; i<l; i++){
			int c = sc.nextInt();
			int t = sc.nextInt();
			if(t<=T && c<minC){
				minC = c;
			}
		}
		if(minC == 1001){
			System.out.println("TLE");
		}else{
			System.out.println(minC);
		}
		return;
	}
}

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

int main(){
	int n,m,i=0,j=0,k=0;
	char rule[50][2],data[100000];
	
	while(j<5){
		cin>>n;
		if(n==0){break;}
		for(i=0;i<n;i++){
			cin>>rule[i][0];
			cin>>rule[i][1];
		}
		
		cin>>m;
		for(i=0;i<m;i++){
			cin>>data[i];
			for(k=0;k<n;k++){
				if(data[i]==rule[k][0]){
					data[i]=rule[k][1];
					break;
				}
			}
		}
			
			for(i=0;i<m;i++){
				cout<<data[i];
		}
		cout<<endl;
		j++;
		
		}
	return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    string s; cin>>s;
    vector<vector<int>> dp(n+1, vector<int>(n+1, 0));

    int ans = 0;
    for (int i = n-1; i >= 0; --i) {
        for (int j = n-1; j >= 0; --j) {
            if (s[i] == s[j]) {
                chmax(dp[i][j], min(dp[i+1][j+1]+1, abs(i-j)));
                chmax(ans, dp[i][j]);
            }
        }
    }

    cout << ans << '\n';
    return 0;
}

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

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair

using namespace std;

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

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int k, x;
  cin >> k >> x;
  for (int i = x - k + 1; i < x + k; i++) cout << i << ' '; cout << '\n';
  return (0);
}


Measured memory_bytes: 256
#include<iostream>
#include<numeric>

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int main(){
    int n;
    double m;
    int a[10000];
    cin >> n >> m;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    double sum = accumulate(a,a+n,0.0);
    
    double kijun = sum/(4*m);
    int flg = 0;
    for(int j=0;j<n;j++){
        if(a[j] >= kijun){
            flg += 1;
        }
    }
    if(flg>=m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

	int D, G;
	cin >> D >> G;
	vector<int> p, c;
	int problem_num = 0;
	rep(i, 0, D) {
		int tmp_p, tmp_c;
		cin >> tmp_p >> tmp_c;
		p.push_back(tmp_p);
		c.push_back(tmp_c);
		problem_num += tmp_p;
	}

	int dp[D + 1][problem_num + 1];
	rep(i, 0, D + 1) rep(j, 0, problem_num + 1) dp[i][j] = 0;

	rep(i, 0, D) rep(j, 0, problem_num + 1) {
		rep(k, 0, p[i]) {
			if(j - k >= 0 and j - k <= problem_num) {
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - k] + 100 * (i + 1) * k);
			}
		}
		if(0 <= j - p[i] and j - p[i] <= problem_num) {
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - p[i]] + 100 * (i + 1) * p[i] + c[i]);
		}
	}

	rep(i, 0, problem_num + 1) {
		if(dp[D][i] >= G) {
			cout << i << endl;
			return 0;
		}
	}


}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

int main()
{
	int N;
	cin>>N;
	if(N%2==1)
	{
		cout<<0<<endl;
	}
	vector<int> d(N);

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

	sort(d.begin(),d.end());

	int result = d[d.size()/2] - d[d.size()/2 -1];
	cout<<result<<endl;
	return 0;
}

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

int main() {
    string S;
    cin >> S;
    char left = S.at(0);
    int ans = 0;
    rep(i,S.size()) {
        if (S.at(i) != left) {
            ++ans;
            left = S.at(i);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=1e9;
const int mod=1e9+7;



void solve()
{
   string s,t;
    cin>>s>>t;
    int n=s.length();
    int cnt=0;
    for(int i=0;i<n;i++)
    {
     if(s[i]!=t[i])cnt++;   
    }
    cout<<cnt<<endl;
}


int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--)
        solve();
}
    
    
    
    


Measured memory_bytes: 3768
def nCk(n,k):
    res = 1
    for i in range(k,0,-1):
        res = res*(n+1-i)/i
    return int(res)

N = input()
K = int(input())
ans = 0
dp_mikakutei = [[0 for i in range(0,K+1,1)] for j in range(0,len(N),1)]#Nより小さいかまだわからん
dp_kakutei = [[0 for i in range(0,K+1,1)] for j in range(0,len(N),1)]

dp_mikakutei[0][1]=1#その桁がまさにNのその桁と同じ
dp_kakutei[0][0]=1
dp_kakutei[0][1]=int(N[0])-1#1~N[0]-1

for i in range(1,len(N),1):
    dp_kakutei[i][0]=dp_kakutei[i-1][0] + dp_mikakutei[i-1][0]
    for j in range(1,K+1,1):
        if N[i] =="0":
            dp_mikakutei[i][j] = dp_mikakutei[i-1][j]
            dp_kakutei[i][j] = 9*dp_kakutei[i-1][j-1] +dp_kakutei[i-1][j]
        else:
            dp_mikakutei[i][j] = dp_mikakutei[i-1][j-1]
            dp_kakutei[i][j] = 9*dp_kakutei[i-1][j-1] + (int(N[i])-1)*dp_mikakutei[i-1][j-1] + dp_kakutei[i-1][j] + dp_mikakutei[i-1][j]
print(dp_mikakutei[len(N)-1][K] + dp_kakutei[len(N)-1][K])


Measured memory_bytes: 38384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	if n == 1 {
		fmt.Println(1)
		return
	}

	for i := 0; i <= n; i++ {
		if i * i > n {
			fmt.Println((i-1)*(i-1))
			return
		}
	}
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000009
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

// 嫌いな数字リストを好きな数字リストにしてうまくできないか考えたが思い浮かばなかった
func main() {
	N := nextInt()
	K := nextInt()
	D := make([]int, K)
	// d := nextInt()
	// count := 1
	// for i := 0; i < 10; i++ {
	// 	if d != i {
	// 		L = append(L, i)
	// 	} else if i != 9 && count != K {
	// 		d = nextInt()
	// 		count++
	// 	}
	// }
	for i := range D {
		D[i] = nextInt()
	}
	for i := 0; i < N*10; i++ {
		ok := true
		for _, num := range strconv.Itoa(i) {
			for _, d := range D {
				if num == rune(d+'0') {
					ok = false
				}
			}
		}
		if ok && i >= N {
			fmt.Println(i)
			return
		}
	}
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 32512
#include<stdio.h>

int main(){
  int i,j;
  int n,u,k,v;

  scanf("%d",&n);

  int A[n][n];

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

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

  return 0;
}



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

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

    string ans("");
    for (int i = 0; i < (int)s.length(); ++i) {
        char key = s[i];

        if (key == 'B') {
            if (!ans.empty()) {
                ans.pop_back();
            }
        } else {
            ans += key;
        }
    }

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

Measured memory_bytes: 3604
#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 RSort(a) reverse(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 Lower(a,t) lower_bound(All(a),t)
using namespace std;
int max_int = 1000000007;
void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int gcd(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

signed main(){
    int n;
    cin >> n;
    int ans;
    cin >> ans;
    REP(i,n-1){
        int t;
        cin >> t;
        ans = gcd(ans,t);
    }
    cout << ans << endl;

    return 0;
}



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

int kaijo(int n)
{
	if (n == 1)
		return 1;
	return (n * kaijo(n - 1));
}

int main()
{
	int n,k;
	cin >> n >> k;
	cout << k * (int)pow(k-1,n-1) << endl;
	return (0);
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main{
	void main() {
		try(Scanner sc=new Scanner(System.in)) {
			for(;;) {
				int x=sc.nextInt();
				int y=sc.nextInt();
				if(x==0&&y==0)break;
				if(x<y) {
					System.out.println(x+" "+y);
				}
				else {
					System.out.println(y+" "+x);
				}
			}
		}
	}
	public static void main(String[] args) {
		new Main().main();
	}

}


Measured memory_bytes: 33892
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int a[100];

int main(){
    int n;
    cin >> n;
    rep(i, n){
        cin >> a[i];
    }
    vector<int> price;
    price.push_back(a[0]);
    rep(i, n-1){
        if(a[i] != a[i+1]) price.push_back(a[i+1]);
    }

    if (price.size() == 1){
        cout << 1000 << endl;
        return 0;
    }


    ll ans = 1000;
    ll cash = 1000;
    ll stock = 0;
    bool flag;

    if (price[0] < price[1]) {
        flag = true;
        stock += cash / a[0];
        cash = cash % a[0];
    }
    else {
        flag = false;
    }

    int m = price.size();
    price.push_back(-100);

    for(int i = 1; i < m; i++){
        if (flag){
            if (price[i] > price[i+1]){ // 売り
                cash += price[i] * stock;
                stock = 0;
                ans = max(ans, cash);
                flag = false;
            }
        }
        else {
            if (price[i] < price[i+1]){ // 買い
                stock += cash / price[i];
                cash %= price[i];
                flag = true;
            }
        }
    }
    cout << cash << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int i,j,k;
	for(i=0;i<7;i++) {
		cin>>j>>k;
		if(j<0&&k<0) cout<<j-k<<endl;
		else if(j<0||k<0) cout<<abs(j)+abs(k)<<endl;
		else cout<<j-k<<endl;
	}
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  ll x = min(K, A);
  A -= x;
  K -= x;

  ll y = min(K, B);
  B -= y;
  K -= y;

  cout << A << " " << B << endl;
  
  return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
int a[110000], b[110000], dp[110000];


signed main() {
    int mod = 1e9 + 7;

    cin >> N;
    for (int i = 0; i < N; i++)cin >> a[i];
    for (int i = 0; i < N; i++)cin >> b[i];
    sort(a, a + N); sort(b, b + N);
    dp[0] = 1;
    for (int i = 0; i < N; i++) {
        if (a[i] == b[i]) {
            dp[i + 1] = dp[i];
            continue;
        }
        
        int n;
        if (a[i] > b[i])n = i - (lower_bound(a, a + N, b[i]) - a);
        else n = i - (lower_bound(b, b + N, a[i]) - b);
        
        dp[i + 1] = (dp[i] * (n + 1) % mod) % mod;
    }
    cout << dp[N] << endl;
}

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

int main()
{
  string S;

  cin >> S;

  if (S.at(0) == 'R')
  {
    if (S.at(1) == 'R')
    {
      if (S.at(2) == 'R')
      {
        cout << 3 << endl;
      }
      else
      {
        cout << 2 << endl;
      }
    }
    else
    {
      if (S.at(2) == 'R')
      {
        cout << 1 << endl;
      }
      else
      {
        cout << 1 << endl;
      }
    }
  }
  else
  {
    if (S.at(1) == 'R')
    {
      if (S.at(2) == 'R')
      {
        cout << 2 << endl;
      }
      else
      {
        cout << 1 << endl;
      }
    }
    else
    {
      if (S.at(2) == 'R')
      {
        cout << 1 << endl;
      }
      else
      {
        cout << 0 << endl;
      }
    }
  }
}


Measured memory_bytes: 3596
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String word1 = sc.next();
    String word2 = sc.next();
    int word1Cnt = sc.nextInt();
    int word2Cnt = sc.nextInt();
    String word3 = sc.next();
    
    if(word1.equals(word3)){
      word1Cnt--;
    }else if(word2.equals(word3)){
      word2Cnt--;
    }else {
    }
    
    System.out.println(word1Cnt +" "+ word2Cnt);
  }
}


Measured memory_bytes: 21844
input = gets.chomp.split
n = input[0].to_i
m = input[1].to_i

sw = []
for i in 1..m do
    sw.push(gets.chomp.split.map(&:to_i))
end

ps = gets.chomp.split(" ").map(&:to_i)

switch = Array.new(n,0)

light = true

for i in 1..m do
    if sw[i-1][0] == 1
        tar = sw[i-1][1]
        if ps[i-1] == 0
            if switch[tar-1] == 1
                light = false
            else
                switch[tar-1] = -1
            end
        else
            if switch[tar-1] == -1
                light = false
            else
                switch[tar-1] = 1
            end
        end
    end
end

def tansaku(i,n,m,sw,ps,switch)
    count = 0
    if i > n
        lt = true
        for j in 1..m do
            cnt = 0
            k = sw[j-1][0]
            for j2 in 1..k do
                tar = sw[j-1][j2]
                if switch[tar-1] == 1
                    cnt += 1
                end
            end
            if cnt % 2 != ps[j-1]
                lt = false
            end
        end
        if lt 
            return 1
        else
            return 0
        end

    else
        if switch[i-1] == 0
            # print i, " = " "on\n" 
            switch[i-1] = 1
            count += tansaku(i+1,n,m,sw,ps,switch)
            # print i, " = " "off\n"
            switch[i-1] = -1
            count += tansaku(i+1,n,m,sw,ps,switch)
            switch[i-1] = 0
        else
            # print i," = ", switch[i-1],"\n"
            count += tansaku(i+1,n,m,sw,ps,switch)
        end
    end
    return count
end 

if light
    puts tansaku(1,n,m,sw,ps,switch)
else
    puts "0"
end

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 入力
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int X = sc.nextInt();

		// 出力
		if ((X - A) >= 0 && (X - A) <= B) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

		sc.close();
	}
}


Measured memory_bytes: 22868