akhauriyash/Code-Regression huggingface dataset:
import numpy as np

N = int(input())
A = [int(x) for x in input().split()]

A = np.array(A)

plus = A[A >= 0]
minus = A[A < 0]

if len(minus) % 2 == 0:
    ans = np.sum(plus) - np.sum(minus)
else:
    ans = np.sum(plus) - np.sum(minus) - np.min(np.abs(A)) * 2

print(ans)

Measured memory_bytes: 24436
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe

int getrandom(int min,int max);

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

int a,b;

cin >> a >> b;

if (a <= 2*b)
{
    cout << 0 << endl;
}else
{
    cout << a-b*2 << endl;
}





//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <stdio.h>

int M, N;
char A[51][51], B[51][51];
bool same_flag;

int main(void)
{
	scanf("%d%d", &N, &M);
	for (int i = 0; i < N; ++i) { scanf("%s", &A[i]); }
	for (int i = 0; i < M; ++i) { scanf("%s", &B[i]); }

	for (int i = 0; i <= (N - M); ++i)
	{
		for (int j = 0; j <= (N - M); ++j)
		{
			same_flag = true;
			for (int x = 0; x < M; ++x)
			{
				for (int y = 0; y < M; ++y)
				{
					if (A[i + x][j + y] != B[x][y])
					{
						same_flag = false;
						break;
					}
				}
				if (same_flag == false)
				{
					break;
				}
			}
			if (same_flag == true)
			{
				printf("Yes\n");
				return 0;
			}
		}
	}

	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
#define fr first
#define sc second
#define INF ( 1 << 30 )
typedef pair < int , int > Pi;
typedef pair < int , Pi > Pii;
vector< vector< Pi > > info;
int n, ret, cc, java;
void rec( int now, int cost , int prev){
  if( info[now].size() == 1 && now != 0) return;
  ret += cost * 2, cc += cost;
  java = max( java, cc);
  for(int i = 0 ; i < info[now].size() ; i++ ){
    if(info[now][i].fr != prev ) rec( info[now][i].fr, info[now][i].sc, now);
  }
  cc -= cost;
}
int main(){
  while(cin >> n , n ){
    info.resize(n);
    ret = cc = java = 0;
    for(int i = 0 ; i < n - 1 ; i++ ){
      int a, b, t;
      cin >> a >> b >> t;
      a--, b--;
      info[a].push_back(Pi(b,t));
      info[b].push_back(Pi(a,t));
    }
    rec( 0,  0 , -1);

    cout << ret - java << endl;
    info.clear();
  }
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    int res = n / k;
    n -= k * res;
    res = min(n, abs(n - k));
    cout << res << endl;
    GAME_OVER;
}

Measured memory_bytes: 256
// In the name of Aadi Shakti
    // We are nothing and you are everything
    // Jai Mata Di
     
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int k , length ;
        string str ;
        cin >> k >> str ; 
        length = str.size();
        // cout << length << endl ; 
        if(k < length )
        {
            for (int i = 0; i < k; i++)
            {
                cout << str[i] ;
            }
            cout << "..." << endl ;
        } 
        else cout << str << endl;
        return 0 ;
    }

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];

    sort(a,a+3);
    cout << a[0] + a[1] << endl;

    return 0;
}

Measured memory_bytes: 256
w, h, n = list(map(int, input().split()))
xya_s = [tuple(map(int, input().split())) for i in range(n)]

left = 0
right = w
down = 0
up = h

for xya in xya_s:
    if xya[2] == 1:
        if left < xya[0]:
            left = xya[0]
    elif xya[2] == 2:
        if xya[0] < right:
            right = xya[0]
    elif xya[2] == 3:
        if xya[1] > down:
            down = xya[1]
    else:
        if xya[1] < up:
            up = xya[1]
if right - left > 0 and up - down > 0:
    print((right - left) * (up - down))
else:
    print(0)


Measured memory_bytes: 3064
#include<stdio.h>
#include<algorithm>
#define ll long long
using namespace std;

int main()
{
    ll h;
    scanf("%lld",&h);
    ll t=h,sum=1,b=1,ans=0;
   while(t/2!=0){
    ans++;
    t/=2;

   }
   for(ll i=0;i<ans;i++){
        b*=2;
    sum+=b;
   }

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

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string a, b, S;
  cin >> a >> b;
  
  for (int i = 0; i < N; i++) {
    char c_a = a.at(i);
    char c_b = b.at(i);
    S = S + c_a + c_b;
  }
  cout << S << endl;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

  bool c = true;
  rep(i, N) {
    int a;
    cin >> a;
    c = (c && (a % 2 != 0 || a % 3 == 0 || a % 5 == 0));
  }
  cout << (c ? "APPROVED" : "DENIED") << endl;
  return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string> 
#include <vector> 
using namespace std;
  
int main(){

    double a,c,i;
    int b,e;
    while(cin >> a){
        if(a < 0){break;}
        string ans[2] = {"",""},aa;
        b = a;
        c  = a - b;
        int co[2] = {0,0},check = 0;
        while(b > 0){
            if(b % 2 == 1){
                ans[0] = "1" + ans[0];
            }else{
                ans[0] = "0" + ans[0];
            }
            b = b / 2;
            co[0]++;

            if(co[0] > 8){check = 1;break;}
        }
        for(int i = co[0];7 >= i;i++){
            ans[0] = "0" + ans[0];
        }
        while(c != 0){
            c = c * 2;
            
            if(c >= 1){
                ans[1] = ans[1] + "1";
                co[1]++;
                if(co[1] > 4){check = 1;break;}
                if(c == 1){break;}
                c = c - 1;
            }else{
                ans[1] = ans[1] + "0";
                co[1]++;
                if(co[1] > 4){check = 1;break;}
            }
            
        }
        for(int i = co[1];3 >= i;i++){
            ans[1] = ans[1] + "0";
        }        
        if(check == 1){
            cout << "NA" << endl;
        }else{
        cout << ans[0] << "." << ans[1] << endl;
    }
    }
}

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

using namespace std;
typedef long long LL;

const int MX=100005,MXT=1<<23|1;

int n,m,a[MX],b[MX],s[MX],L[MX],R[MX],x[MXT],l[MXT],r[MXT];
int p,q;
#define ll(i) (l[i]?l[i]:(l[i]=++q))
#define rr(i) (r[i]?r[i]:(r[i]=++q))
LL f[MX],ans;

inline void upd(int i,int li,int ri,int _l,int _r,int p){
	if(_l<=li&&ri<=_r)x[i]=p;
	else{
		if(x[i])x[ll(i)]=x[rr(i)]=x[i],x[i]=0;
		int mid=(li+ri)>>1;
		if(_l<=mid)upd(ll(i),li,mid,_l,_r,p);
		if(_r>mid)upd(rr(i),mid+1,ri,_l,_r,p);
	}
}
inline int que(int i,int li,int ri,int p){
	if(x[i])return x[i];
	if(!i||li==ri)return 0;
	int mid=(li+ri)>>1;
	return p<=mid?que(l[i],li,mid,p):que(r[i],mid+1,ri,p);
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		if(b[i]==1&&a[i]*2>m){cout<<-1<<endl;return 0;}
		s[i]=(s[i-1]-2*a[i]%m+m)%m;
	}
	for(int i=1;i<=n;i++)
		if(b[i]==2)L[i]=1,R[i]=m;
		else L[i]=s[i-1]+1,R[i]=s[i]+1;
	for(p=1;p<m;p<<=1);q=1;
	for(int i=n,j;i>=2;i--){
		j=que(1,1,p,L[i]);
		if(j)f[i]=f[j]+(L[j]-L[i]+m)%m;
		if(L[i]<=R[i]){
			if(L[i]>1)upd(1,1,p,1,L[i]-1,i);
			if(R[i]<m)upd(1,1,p,R[i]+1,m,i);
		}else upd(1,1,p,R[i]+1,L[i]-1,i);
	}
	ans=1e18;
	for(int i=2,j,k;i<=2*n+1;i++){
		if(i&1)j=L[i>>1];
		else j=R[i>>1];
		if(L[1]<=R[1]&&L[1]<=j&&j<=R[1]||L[1]>R[1]&&(L[1]<=j||j<=R[1])){
			k=que(1,1,p,j);
			if(!k)ans=0;
			else ans=min(ans,f[k]+(L[k]-j+m)%m);
		}
	}
	for(int i=1;i<=n;i++)ans+=a[i]<<1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 39808
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,k,a[N];
int main()
{
    scanf("%d%d",&n,&k);k--;
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    int t=0;
    for(int i=1;i<=n;i++)
        if(a[i]!=1) t++;
    else
    {
        if(k<=t&&k<=n-i)
        {
            int f=t%k+(n-i)%k;
            printf("%d\n",t/k+(n-i)/k+f/k+(f%k?1:0));
        }
        else if(k>=t)
        {
            int f=n-i-(k-t);
            printf("%d\n",1+f/k+(f%k?1:0));
        }
        else
        {
            int f=t-(k-(n-i));
            printf("%d\n",1+f/k+(f%k?1:0));
        }
        return 0;
    }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define pb 	push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define mod 1000000007LL
#define F first
#define S second
#define speed ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)

main()
{
	speed;
	int n;
	cin>>n;
	string s[n];
	for(int i=0;i<n;i++)cin>>s[i];
	for(int i=0;i<n;i++)sort(all(s[i]));
	map<string,int>mp;
	for(int i=0;i<n;i++)mp[s[i]]++;
	int ans=0;
	for(auto it=mp.begin();it!=mp.end();it++)
	{
		ans+=(it->S)*(it->S-1)/2;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 16640
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, D = read_ints()
    count = 0
    for _ in range(N):
        x, y = read_ints()
        if x**2+y**2 <= D**2:
            count += 1
    return count


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 69960
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string.h>
using namespace std;

#define HUNDRED 100
#define THOUSAND 10000
#define TENTHOUSAND 10000
#define HUNDREDTHOUSAND 100000

int kaibun(int number);

int main() {
	int n;
	int k;
	vector<int> l;
	int temp;
	int sum = 0;


	cin >> n >> k;

	for(int i = 0; i < n; i++){
		cin >> temp;
		l.push_back(temp);
	}

	sort(l.begin(), l.end() , greater<int>()); // 昇順ソート

	for(int j =0; j < k; j++){
		sum += l[j];
	}

	cout << sum;


}

int kaibun(int number) {
	int temp[HUNDREDTHOUSAND];
	int temp1;
	int digit = 0;

	temp1 = number;

	for (int i = 0; temp1 > 0; i++) {
		temp[i] = (temp1 % 10);
		temp1 /= 10;
		digit++;
	}

	// initialize
	temp[digit] = -1;

	digit -= 1;

	for (int i = 0; temp[i] != -1; i++) {
		if (temp[i] != (int) (number / pow(10, digit))) {
			return -1;
		}
		int temp2;
		temp2 = (int) pow(10, digit);
		number %= temp2;
		digit--;
	}

	return 1;

}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var s = Console.ReadLine();
            var count0 = s.Where(x => x == '0').Count();
            var count1 = s.Length - count0;
            Console.WriteLine(2 * Math.Min(count0, count1));
        }
    }
}


Measured memory_bytes: 11488
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    long long n, m, L[100005], R[100005];
    cin >> n >> m;

    REP(i, m){
        cin >> L[i] >> R[i];
    }

    long long min = 0, max = 100005;

    REP(i, m){
        if(L[i] >= min)
            min = L[i];
        if(R[i] <= max)
            max = R[i];
    }
    if(min > max){
        cout << 0 << endl;
        return 0;
    }

    cout << max - min + 1 << endl;

    return 0;
}


Measured memory_bytes: 1792
# https://atcoder.jp/contests/abc126/tasks/abc126_e

######### Union Find ########
class UnionFind(object):
    def __init__(self, n):
        self.n = n
        self.root = [-1] * n
        self.rnk = [0] * n

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

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return 
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def count(self, x):
        return -self.root[self.find(x)]

if __name__ == '__main__':
    n, m = map(int, input().split())
    uf = UnionFind(n)

    for _ in range(m):
        xi, yi, zi = map(int, input().split())
        xi -= 1
        yi -= 1
        uf.unite(xi, yi)

    count = 0
    for i in range(n):
        if uf.root[i] < 0:
            count += 1
    print(count)


Measured memory_bytes: 73052
#include <iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n,k; //n??¨??????n????´§??????k??¨??????k????´§???
llong T[MAX];

int check(llong P) //????????????P????´§???????£?????°?????´§???
{
    int i=0;
    for(int j=0;j<k;j++)
    {
        llong s=0;
        while(s+T[i]<=P)
        {
            s+=T[i];
            i++;
            if(i==n) return n;
        }
    }
    return i;
}

int solve()
{
    llong left=0;
    llong right=100000*100000;
    llong mid;
    while(right-left>1)
    {
        mid=(left+right)>>1;
        int v=check(mid);
        if(v>=n) right=mid;
        else left=mid;
    }
    return right;
}
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>T[i];
    cout<<solve()<<endl;
}

Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f first
#define s second
long long ans[20000000];
main(){
ll n;
cin>>n;
ll j=1;
for(int i=1;i<=n;i++){
    for(int z=i;z<=n;z+=i){
            ans[z]++;
    }
}
ll sum=0;
j=1;
for(int i=1;i<=n;i++){
 sum+=j*ans[i];
    j++;
}
cout<<sum<<endl;
}


Measured memory_bytes: 81728
N, K, Q = (int(i) for i in input().split())
A = [None] * (Q)
for i in range(Q):
    A[i] = int(input())
    
right_cnt = [0] * (N+1)
for a in A:
    right_cnt[a] += 1
      
for i in range(1, N+1):
    if Q - right_cnt[i] < K:
        print('Yes')
    else:
        print('No')
    

Measured memory_bytes: 52440
#include<stdio.h>

int main()
{
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
 if(x+r>W){
     printf("No\n");
 }else if(x-r<0){
     printf("No\n");
 }else if(y+r>H){
     printf("No\n");
 }else if(y-r<0){
     printf("No\n");
 }else{
     printf("Yes\n");
 }
    return 0;
}



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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

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

void llchmin(ll &a, ll b){
  if(a > b)
    a = b;
}
void llchmax(ll &a, ll b){
  if(a < b)
    a = b;
}

int main(){
  int n;
  cin >> n;
  map<int, int> a;
  bool check = true;
  
  rep(i, 0, n){
    int t;
    cin >> t;
    if(a.count(t)){
      check = false;
      break;
    }
    else
      a[t] = 0;
  }
  
  if(check)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
  return 0;
  
}

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

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

    for(int i = 0; i < n; i++){
        for(int j = 0; j < s.size(); j++){
            if(s[j] == 'Z'){
                s[j] = 'A';
            }
            else{
                s[j]++;
            }
        }
    }

    cout << s << "\n";
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		int a = in.nextInt();
		int b = in.nextInt();
		String s = a > b ? ">" : (a < b ? "<" : "==");
		out.println("a " + s + " b");
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}


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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	long long a, b, c;
	cin >> a >> b >> c;
	long long l = a * b * 4;
	long long r = c - a - b;
	if(r < 0){
		cout << "No" << endl;
	}else{
		r = r * r;
		cout << (l < r ? "Yes" : "No") << endl;
	}
}


Measured memory_bytes: 256
a,b,c,d,e,f = map(int, input().split())
import sys
sys.setrecursionlimit(999999999)

water1=a
water2=b
sugar1=c
sugar2=d

from functools import lru_cache
@lru_cache(maxsize=None)
def solve(w,s,nokori):
#    print("solve(",w,s,nokori,")")

    if nokori < 0:
        return [-1,w,s]

    max_s = w/100 * e

    if max_s >= s and w+s > 0:
        now = [100*s / (w+s),w,s]
    else:
        now=[-1,w,s]

    res1=solve(w+water1*100,s,nokori-water1*100)
    res2=solve(w+water2*100,s,nokori-water2*100)
    if max_s > s:
        res3=solve(w,s+sugar1,nokori-sugar1)
        res4=solve(w,s+sugar2,nokori-sugar2)
    else:
        res3=[-1,w,s]
        res4=[-1,w,s]

    lis = [now,res1,res2,res3,res4]
    lis.sort()

    return lis[-1]

ans = solve(0,0,f)
print(ans[1]+ans[2],ans[2])

Measured memory_bytes: 8292
//It's time to be who I am, rather than who I am supposed to be.
#include<bits/stdc++.h>
#define int long long
#define sz(x) (int)(x.size())
using namespace std;

const int N = 1e5+10;
const int mod = 998244353;
const int inf = 1e12;
int n, cost[N][3], dp[N][3];

int solve(int curr, int task){
	if(curr < 1)
		return 0;

	int &ans = dp[curr][task];
	if(ans != 0)
		return ans;

	for(int i = 0; i < 3; i++){
		if(i != task){
			ans = max(ans, cost[curr][task] + solve(curr - 1, i));
		}
	}
	/*	Alternative : 
		vector<int> otherTwo;
		for(int i = 0; i < 3; i++)
			if(i != task)
				otherTwo.push_back(i);

		ans = cost[curr][task] + max(solve(curr - 1, otherTwo[0]), solve(curr - 1, otherTwo[1]));
	*/
	return ans;
}

int32_t main(){
	ios::sync_with_stdio(false);
   cin.tie(NULL); cout.tie(NULL);


    cin >> n;
    for(int i = 1; i <= n; i++)
    	cin >> cost[i][0] >> cost[i][1] >> cost[i][2];
    dp[1][0] = cost[1][0],
    dp[1][1] = cost[1][1],
    dp[1][2] = cost[1][2];

    cout << max({solve(n,0), solve(n,1), solve(n,2)}) << '\n';
    
}

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

bool isSquare(int n){
    int k = 1;
    while(true){
        if(k*k == n) return true;
        if(k*k > n) return false;
        k++;
    }
}

int main(){
    int N, D;
    cin >> N >> D;
    int X[N][D];
    for(int i =0; i < N; i++){
        for(int j =0; j < D; j++){
            cin >> X[i][j];
        }
    }
    int res = 0;
    for(int u =0; u < N-1; u++){
        for(int v = u + 1; v < N; v++){
            int dd = 0;
            for(int i =0; i < D; i++){
                dd += pow(X[u][i] - X[v][i],2);
            }
            if(isSquare(dd)) res ++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
import sys
N = int(input())
S = [int(input()) for _ in range(N)]
S.sort()
t = sum(S)
if t % 10 != 0:
    print(t)
    sys.exit()

for s in S:
    if (t - s) % 10 != 0:
        print(t - s)
        sys.exit()
print(0)


Measured memory_bytes: 9128
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)	
#define T int t ;cin >> t;while(t--)
using namespace std ;
typedef long long ll;
typedef unsigned long long ull;
inline ll gcd(ll a,ll b){return b == 0? a:gcd(b, a % b);}
const int maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const double eps = 1e-11;
const ll mod = 1e9 + 7;
int main()
{
    int n;
    ll d;
    scanf("%d%lld",&n,&d);
    ll a,b;
    d *= d;
    int x = 0;
    while (n --) 
	{
        scanf("%lld%lld",&a,&b);
        if (a * a + b * b <= d) 
			x++;
    }
    printf("%lld\n",x);
    return 0;
}

Measured memory_bytes: 3824
//package Contest089;

import java.io.PrintWriter;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        TreeSet<Character> ts = new TreeSet<>();
        int n  = Integer.valueOf(sc.nextLine());
        for(int i=0;i<n;i++)
            ts.add(sc.next().charAt(0));

        if(ts.size()==3)
            out.println("Three");
        else
            out.println("Four");

        out.flush();
    }
}


Measured memory_bytes: 21844
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from collections import Counter
from random import randrange
def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    if Counter(A + B).most_common()[0][1] > n:
        print("No")
        return

    for i in range(n):
        if A[i] != B[i]:
            continue
        while 1:
            j = randrange(0, n)
            if A[i] != B[j] and A[j] != B[i]:
                B[i], B[j] = B[j], B[i]
                break
    print("Yes")
    print(*B)
resolve()

Measured memory_bytes: 154556
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<int> p(N);
  rep(i,N) cin >> p[i];
  int count = 0;
  rep(i,N-2)
  {
    if(p[i]<p[i+1]&&p[i+1]<p[i+2])
    {
      count ++;
    }
    else if(p[i]>p[i+1]&&p[i+1]>p[i+2])
    {
      count ++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3600
#include "bits/stdc++.h"

using namespace std;

#define int long long int
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define se second
#define fi first

typedef pair<int, int> pii;
typedef vector<int> vi;

const int inf = 1e18;
const int mod = 1e9 + 7;

inline int add(int x, int y) { x += y; if (x >= mod) x -= mod; return x;}
inline int sub(int x, int y) { x -= y; if (x < 0) x += mod; return x;}
inline int mul(int x, int y) { return ((x % mod) * (y % mod)) % mod;}
inline int power(int a, int b) {
    int x = 1;
    while (b) {
        if (b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline int inv(int a) { return power(a, mod - 2);}

const int N = 404;
int dp[N][N], a[N], n;

int f(int i, int j) {
    if (i == j) {
        dp[i][j] = 0;
        return 0;
    }
    int &ret = dp[i][j];
    if (ret != -1) return ret;
    ret = inf;
    int sum = 0;
    for (int k = i; k <= j; k++) sum += a[k];
    for (int k = i; k < j; k++) {
        ret = min(ret, f(i, k) + f(k + 1, j) + sum);
    }
    return ret;
}

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

    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 0; i <= n; i++) fill(dp[i], dp[i] + N, -1);

    cout << f(1, n) << endl;

    return 0;
}

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

int main(){
	int n;
	cin>>n;
	int i=1;
	int count=0;
	while(i<=n){
		int count2=0;
		for(int j=1;j<=n;j++){
			if(i%j==0)count2++;
		}
		if(count2==8) count++;
		i+=2;
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
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 c = sc.nextInt();
//		String s = sc.next();
		
		if (c >= a && c <= b){
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
		
		
		

	}

}


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

int main() {

  string S;

  cin >> S ;

  int N=S.size();

  int ans=0;

  rep(i,N/2){
    if(S.at(i)!=S.at(N-i-1)) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}

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

struct TPoint
{
	double x;
	double y;
};

double GetCrossProduct(const TPoint& V1, const TPoint& V2)
{
	return V1.x * V2.y - V1.y * V2.x;
}

TPoint Vector(const TPoint& P1, const TPoint& P2)
{
	return {P2.x - P1.x, P2.y - P1.y};
}

bool IsSameSide(const TPoint& P1, const TPoint& P2, const TPoint& L1, const TPoint& L2)
{
	return GetCrossProduct(Vector(L1, P1), Vector(L1, L2)) * GetCrossProduct(Vector(L1, P2), Vector(L1, L2)) > 0;
}

int main()
{
	while(true){
		TPoint A1, A2, A3, Ap;
		cin >> A1.x >> A1.y >> A2.x >> A2.y >> A3.x >> A3.y >> Ap.x >> Ap.y;
		if(cin.eof() == true) break;
		if(IsSameSide(A3, Ap, A1, A2) && IsSameSide(A1, Ap, A2, A3) && IsSameSide(A2, Ap, A3, A1)){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3120
#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};
// cout << fixed << setprecision(20);

int N,T,A;
int H[110000];
signed main() {
    cin>>N>>T>>A;
    int ans=0;
    for(int i=0;i<N;i++){
        cin>>H[i];
        if(abs(T-H[i]*0.006-A)<abs(T-H[ans]*0.006-A))ans=i;
    }
    cout<<ans+1<<endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
count = 0
for i in range(n):
  if a[i]<=b[i]:
    count+=a[i]
    count+=min(b[i]-a[i],a[i+1])
    a[i+1]-=min(b[i]-a[i],a[i+1])
  else:
    count+=b[i]
print(count)

Measured memory_bytes: 18624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var dic = new Dictionary<int, int>();
        for(var i = 0; i < num; i++)
            for (var j = -1; j < 2; j++)
                if (dic.ContainsKey(ar[i] + j))
                    dic[ar[i] + j]++;
                else dic[ar[i] + j] = 1;
        var max = dic.Values.Max();
        WriteLine(max);
    }
}


Measured memory_bytes: 22240
//copied from PG111002

#include <algorithm>
#include <vector>
//#include <iostream> //goodbye, cin and cout!
#include <cstdio>
#include <cstring>

#define hi(_x) ((_x)>>16)
#define lo(_x) ((_x)&0xffff)
using namespace std;

/*
void rotate(vector<int> &v,const int index){
  int i;
  vector<int> x=v;
  v.clear();
  for(i=0; i<x.size()-index; i++)
    v.push_back(x[i+index]);
  for(i=0; i<index; i++)
    v.push_back(x[i]);
}
*/

#define rotate(v, index) rotate((v).begin(), (v).begin()+(index), (v).end())

//__stdcallは使えないの?しょうがないんでinline。
inline int unite(vector<unsigned int> &u, vector<vector<unsigned int>*> &array){
  int _array, _u, _each;
  while(array.size()){
    for(_array=0; _array<array.size(); _array++){//今まで作ったeuler閉路すべてに対しuと結合できるかどうか調べる
      vector<unsigned int> each = *(array[_array]); //eachはeuler閉路を構成すると仮定する
      for(_u=0; _u<u.size(); _u++){
        for(_each=0; _each<each.size(); _each++){
          if(lo(u[_u])==hi(each[_each])){
            if(_each)rotate(each,_each); //each[_each]が先頭に来るよう頭だし
            u.insert(u.begin()+_u+1,each.begin(),each.end());
            delete array[_array];
            array.erase(array.begin()+_array);
            goto next;
          }
        }
      }
    }
    //fail //Case #8を通すにはfail判定はここでする必要がある。
    return 0;
    next:
    /*continue*/;
  }//while
  return 1;
}

inline int sort(vector<unsigned int>&s,vector<unsigned int>&v){
  int x=hi(v[0]), y=lo(v[0]), i, a=0;
  v.erase(v.begin());
  s.push_back((x<<16)+y);
  while(1){
    for(i=0; i<v.size(); i++){
      if(lo(s[a])==hi(v[i])/*||lo(s[a])==lo(v[i])*/)goto in;//break;
    }
    /*if(i==v.size())*/break;
in:
    x=hi(v[i]), y=lo(v[i]);
    v.erase(v.begin()+i);
    //if(lo(s[a])==y)swap(x,y);
    s.push_back((x<<16)+y);
    a++;
  }//while
  return hi(s[0])==lo(s[a]);
}

char s[99];
int main(){
  int k,l;
  unsigned int x,y;
  vector<unsigned int> vorig;
  vector<vector<unsigned int>*> varray;
  vector<unsigned int> vunite;

  for(;;){
    scanf("%d",&l);//cin >> l;
    if(!l)return 0;

    for(k=0;k<l;k++){
      scanf("%s",s);
      x=s[0]-96,y=s[strlen(s)-1]-96;
      vorig.push_back((x<<16)+y);
    }

    while(vorig.size()){
      vector<unsigned int> *p = new vector<unsigned int>;
      if(!sort(*p,vorig))goto fail;
      varray.push_back(p);
    }

    vunite = *(varray[0]);
    delete varray[0];
    varray.erase(varray.begin());
    if(!unite(vunite,varray))goto fail;

    puts("OK");
    vorig.clear();
    vunite.clear();
    continue;

fail:
    while(varray.size()){
      delete varray[0];
      varray.erase(varray.begin());
    }
    puts("NG");
    vorig.clear();
    vunite.clear();
  }//for
}//main

Measured memory_bytes: 1296
# https://atcoder.jp/contests/abc014/submissions/3935971
class SegmentTree(object):
    __slots__ = ["elem_size", "tree", "default", "op"]

    def __init__(self, a: list, default: int, op):
        from math import ceil, log
        real_size = len(a)
        self.elem_size = elem_size = 1 << ceil(log(real_size, 2))
        self.tree = tree = [default] * (elem_size * 2)
        tree[elem_size:elem_size + real_size] = a
        self.default = default
        self.op = op

        for i in range(elem_size - 1, 0, -1):
            tree[i] = op(tree[i << 1], tree[(i << 1) + 1])

    def get_value(self, x: int, y: int) -> int:
        l, r = x + self.elem_size, y + self.elem_size
        tree, result, op = self.tree, self.default, self.op
        while l < r:
            if l & 1:
                result = op(tree[l], result)
                l += 1
            if r & 1:
                r -= 1
                result = op(tree[r], result)
            l, r = l >> 1, r >> 1

        return result

    def set_value(self, i: int, value: int) -> None:
        k = self.elem_size + i
        self.tree[k] = value
        self.update(k)

    def update(self, i: int) -> None:
        op, tree = self.op, self.tree
        while i > 1:
            i >>= 1
            tree[i] = op(tree[i << 1], tree[(i << 1) + 1])

n, q = map(int, input().split())
seg = SegmentTree([(1<<31)-1]*n, (1<<31)-1, min)
for _ in range(q):
    c, x, y = map(int, input().split())
    if c == 0:
        seg.set_value(x, y)
    else:
        print(seg.get_value(x, y+1))



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

def gcm(a, b):
    if b == 0:
        return a
    return gcm(b, a % b)

ans = gcm(A[0], A[1])
for i in range(2, N):
    ans = gcm(ans, A[i])

print(ans)


Measured memory_bytes: 14224
#include<stdio.h>
int main(void)
{
    int a,b,c,result;
    scanf("  %d %d %d",&a,&b,&c);
    if(a<10 && b<10 && c<10 && a>0 && b>0 && c>0)
    {   if(a==b && b==c)
            result=(a*10)+b+c;
        else if((a>b && a>c)||(a>b && b==c)||(a==b && b>c))
            result=(a*10)+b+c;
        else if((b>c && b>a)||(b>c && a==c)||(b==c && b>a))
            result=(b*10)+c+a;
        else if((c>a && c>b)||(c>a && a==b)||(a==c && a>b))
            result=(c*10)+a+b;
        if(a==b && b==c)
            result=(a*10)+b+c;
    }
    printf("%d",result);
    return 0;

}

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

long long const MOD = 1000000007;

long long powmod(long long x, long long n) {
    long long ret = 1;
    while(n > 0) {
        if(n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

long long pm[210000];

void init() {
    pm[0] = 1;
    for(int i=1; i<210000; ++i) pm[i] = (pm[i - 1] << 1) % MOD;
}

int N;
vector<vector<int>> G;
long long res = 0;

int dfs(int v, int p) {
    int xe = 1;
    for(int to : G[v]) {
        if(to == p) continue;
        xe += dfs(to, v);
    }
    if(p != -1) res = (res + (pm[xe] - 1) * (pm[N - xe] - 1) % MOD) % MOD;
    return xe;
}

int main() {
    init();
    cin >> N;
    G.assign(N, vector<int>());
    for(int i=1; i<N; ++i) {
        int a, b; cin >> a >> b;
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    dfs(0, -1);
    res = (res - 1 + pm[N] - N * pm[N - 1]) % MOD;
    res = (res + MOD) % MOD;
    res = res * powmod(pm[N], MOD - 2) % MOD;
    cout << res << endl;
}

Measured memory_bytes: 19456
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <iterator>
#include <cmath>
#include <deque>
using namespace std;

int main()
{
    {
        if (fopen("input.txt", "r")) {
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        }
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
    }

    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    if (s[0] == '1' || s[n] == '1') {
        cout << -1;
        return 0;
    }
    int i = n;
    vector<int> ans;
    bool reach = true;
    while (i - m > 0) {
        int to = -1;
        for (int j = i - m; j < i; ++j)
            if (s[j] == '0') {
                to = j;
                break;
            }
        if (to < 0) {
            reach = false;
            break;
        }
        ans.push_back(i - to);
        i = to;
    }
    if (reach) {
        ans.push_back(i);
        for (auto it = ans.rbegin(); it != ans.rend(); ++it)
            cout << *it << ' ';
    }
    else
        cout << -1;
    return 0;
}

Measured memory_bytes: 1096
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	
	public static class Walk {
		int bill;
		int pos;
		int time;
		
		public Walk(int bill, int pos, int time) {
			super();
			this.bill = bill;
			this.pos = pos;
			this.time = time;
		}
	}
	
	public static int BFS(int start, final int n, int[][] bill){
		boolean[][] visited = new boolean[2][n];
		LinkedList<Walk> queue = new LinkedList<Walk>();
		queue.add(new Walk(start, 0, 0));
		
		while(!queue.isEmpty()){
			Walk walk = queue.poll();
			
			if(visited[walk.bill][walk.pos]){
				continue;
			}else{
				visited[walk.bill][walk.pos] = true;
			}
			
			//System.out.println(walk.bill + " " + walk.pos + " " + walk.time);
			
			if(bill[walk.bill][walk.pos] == 2){
				queue.addFirst(new Walk(walk.bill, walk.pos - 1, walk.time));
				continue;
			}else if(bill[walk.bill][walk.pos] == 1 && (walk.pos != n - 1 && bill[walk.bill][walk.pos + 1] == 1)){
				queue.addFirst(new Walk(walk.bill, walk.pos + 1, walk.time));
				continue;
			}
			
			if(walk.pos == n - 1){
				return walk.time;
			}
			
			for(int next = 0; next <= 2; next++){
				if(walk.pos + next >= n){
					break;
				}else if(!visited[1 - walk.bill][walk.pos + next]){
					queue.addLast(new Walk(1 - walk.bill, walk.pos + next, walk.time + 1));
				}
			}
		}
		
		return Integer.MAX_VALUE;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while (true) {
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			int[][] bill = new int[2][n];
			
			for(int i = 0; i < 2; i++){
				for(int j = 0; j < n; j++){
					bill[i][j] = sc.nextInt();
				}
			}
			
			int ret = Math.min(BFS(0, n, bill), BFS(1, n, bill));
			
			System.out.println(ret == Integer.MAX_VALUE ? "NA" : (ret + ""));
		}
	}

}

Measured memory_bytes: 28708
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

signed main() {
	IOS;
	int s, w;
	cin >> s >> w;
	if(w >= s)
	cout << "unsafe";
	else
	cout << "safe";	
	return 0;
}


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

typedef long long ll;
using namespace std;

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x);
    for (int i = 0; i < x; i++) {
        cin >> a[i];
    }
    vector<ll> b(y);
    for (int i = 0; i < y; i++) {
        cin >> b[i];
    }
    vector<ll> c(z);
    for (int i = 0; i < z; i++) {
        cin >> c[i];
    }
    vector<ll> sums_ab;
    for (auto aa: a) {
        for (auto bb: b) {
            sums_ab.emplace_back(aa + bb);
        }
    }
    sort(sums_ab.begin(), sums_ab.end(), greater<ll>());
    vector<ll> sums;
    for (int i = 0; i < min(k, (int)sums_ab.size()); i++) {
        for (int l = 0; l < z; l++) {
            sums.emplace_back(sums_ab[i] + c[l]);
        }
    }
    sort(sums.begin(), sums.end(), greater<ll>());
    for (int i = 0; i < k; i++) {
        cout << sums[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 43240
#include <stdio.h>
int main(void){
    int n,z,d,i,all;
    d=0;
    n=0;
    d=0;
    i=0;
    all=0;
    scanf("%d\n",&n);
    for(i=0;i<n;i++){
        scanf("%d",&z);
        all=all+z;
        if(d<z){
            d=z;
        }else{
            
        }
     z=0;   
    }
    
    all=all-d;
    if(d<all){
        printf("Yes");
        
    }else{
        printf("No");
    }
    return 0;
}
    

Measured memory_bytes: 1736
#include <iostream>
#include <math.h>
#include <algorithm>
#include <iomanip>
using namespace std;

int main()
{
    int m,n,o,i,j,k;
    float f,g,h;
    char c;
    //string a;
    //cin>>m;
    //cin>>m>>n>>o>>i>>j>>k;
    //cin>>f>>g;
    cin>>c;
    if(c=='A') cout<<"T";
    else if(c=='T') cout<<"A";
    else if(c=='G') cout<<"C";
    else cout<<"G";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int n;

int main(){
  int i,j,num[101][101],res[101][101] = {};

  scanf("%d",&n);
  
  for(i = 1; i < n+1; i++){
    scanf("%d%d",&num[i][0],&num[i][1]);
    for(j = 0; j < num[i][1]; j++){
       scanf("%d",&num[i][2+j]);
       res[i][num[i][2+j]] = 1;
    }
  }
  
  for(i = 1; i < n+1; i++){
   for(j = 1; j < n+1; j++){
     if(j > 1)printf(" ");
     printf("%d",res[i][j]);
  }
   printf("\n");
  }
  return 0;
}



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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL h, w, b[26];

int main() {
	cin >> h >> w;
	inc(i, h) {
		string s;
		cin >> s;
		inc(j, w) { b[s[j] - 'a']++; }
	}
	
	LL sum = 0;
	bool ans = true;
	inc(i, 26) { sum += b[i] / 4 * 4; b[i] %= 4; }
	if(sum < (h / 2 * 2) * (w / 2 * 2)) { ans = false; }
	inc(i, 26) { sum += b[i] / 2 * 2; b[i] %= 2; }
	if(sum < h * w - (h * w % 2)) { ans = false; }
	
	cout << (ans ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 256
s = input()
t = s.replace('x', '')
if all(t[i] == t[len(t) - i - 1] for i in range(len(t) // 2)):
    l = 0
    r = len(s) - 1
    count = 0
    while r - l > 0:
        if s[l] != s[r]:
            count += 1
            if s[l] == 'x':
                l += 1
            if s[r] == 'x':
                r -= 1
        else:
            l += 1
            r -= 1
    print(count)
else:
    print(-1)


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


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

    long long currentT=T[0], currentA=A[0];
    for(int i=1; i<N; i++){
        long long nextT=T[i], nextA=A[i];
        if(nextT < currentT || nextA < currentA){
            long long scale = max(currentT/nextT, currentA/nextA);

            nextT = T[i]*scale;
            nextA = A[i]*scale;
            if(nextT < currentT || nextA < currentA){
                scale++;
                nextT = T[i]*scale;
                nextA = A[i]*scale;
            }
        }
        currentT = nextT;
        currentA = nextA;
    }
    cout << (currentT + currentA) << '\n';
}


Measured memory_bytes: 3172
#include <stdio.h>

int	main(void)
{
  	int	k;
  	int	a;
  	int	b;
  	int	i;
  
  	scanf("%d\n", &k);
  	scanf("%d %d", &a, &b);
  
  	for(i=1; i<=1000; i++)
    {
      	if(a <= i * k)
          	if (b >= i * k)
          	{
              	printf("OK");
              	return (0);
          	}
    }
  	printf("NG");
  	return (0);
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver2 {
 public:
  int m, d;
  Solver2(LL m, LL d) : m(m), d(d){};

  void solve() {
    int ans = 0;
    for (int i = 1; i <= m; ++i) {
      for (int j = 1; j <= d; ++j) {
        int tmp1 = j / 10;
        int tmp2 = j % 10;
        if (tmp1 >= 2 && tmp2 >= 2 && i == tmp1 * tmp2) ans++;
      }
    }
    cout << ans << endl;
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long m, d;
  std::cin >> m >> d;

  Problem::Solver2 sol(m, d);
  sol.solve();
  return 0;
}


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

int main() {
  int n;
  int count=0;
  string value;
  cin >> n >> value;
  map<char,int> list_i;
  for (int i=0; i<n-2; i++) {
    if (list_i.size()==10) {
      break;
    }
    else if (list_i.count(value.at(i))) {
      continue;
    }
    else {
      list_i[value.at(i)]=1;
      map<char,int> list_j;
      for (int j=i+1; j<n-1;j++) {
        if (list_j.size()==10) {
          break;
        }
        else if (list_j.count(value.at(j))) {
          continue;
        }
        else {
          list_j[value.at(j)]=1;
          map<char,int> list_k;
          for (int k=j+1; k<n; k++) {
            if (list_k.size()==10) {
              break;
            }
            else if (list_k.count(value.at(k))) {
              continue;
            }
            else {
              list_k[value.at(k)]=1;
              count++;
            }
          }
        }
      }
    }
  }
  cout << count;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long res = 0;
		if (a + b >= c - 1) {
			System.out.println(b + c);
			return;
		}
		System.out.println(a + b + 1 + b);
	}
}


Measured memory_bytes: 23636
MOD = 10 ** 9 + 7

def ncr(n, r, mod=MOD):
    return (fct[n] * invf[r] * invf[n - r]) % mod


def make_tables(n, mod=MOD):
    fct = [1 for _ in range(n + 1)]
    invf = [1 for _ in range(n + 1)]

    for i in range(2, n + 1):
        fct[i] = (fct[i - 1] * i) % mod
        invf[i] = divmod(fct[i])
    return fct, invf


def divmod(a, mod=MOD):
    return pow(a, mod - 2, mod)


N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
for i in range(N):
    A[i] %= MOD

fct, invf = make_tables(N, mod=MOD)

ans = 0
for i in range(N - K + 1):
    ans += ((A[-1-i] - A[i]) % MOD * ncr(N - i - 1, K - 1)) % MOD
print(ans % MOD)

Measured memory_bytes: 65576
#include<stdio.h>

int main(){
  int A, B, a, b, c, d, e, p, count = 0;
  
  scanf("%d %d", &A, &B);
  
  for (int i = A; i <= B; i++){
    p = i;
    a = p%10;
    p /= 10;
    b = p%10;
    p /= 10;
    c = p%10;
    p /= 10;
    d = p%10;
    p /= 10;
    e = p%10;
    if(a == e && b == d){
      count++;
    }
  }
  
  printf("%d\n", count);
  
  return 0;
}

Measured memory_bytes: 128