akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

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

  ll N;
  cin >> N;

  vl h(N, -1);
  FOR(i, 0, N){
    cin >> h[i];
  }

  ll cur = 0;
  ll m = 0;
  FOR(i, 1, N){
    if(h[i] > h[i-1]){
      m = max(m, cur);
      cur = 0;
    }
    else{
      cur++;
    }
  }
  
  m = max(m, cur);

  cout << m << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  
  if(a==0){
    cout<<"1"<<endl;
  }
  else if (b==0){
    cout<<"2"<<endl;
  }
  else if (c==0){
    cout<<"3"<<endl;
  }
  else if (d==0){
    cout<<"4"<<endl;
  }
  else{
    cout<<"5"<<endl;
  }
}

Measured memory_bytes: 3592
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

abc='abcdefghijklmnopqrstuvwxyz'

n=int(input())

ans=''
while n!=0:
  t_ans=n%26
  ans+=str(abc[t_ans-1])

  if abc[t_ans-1]=='z':
    n-=1

  n//=26

#  print(ans[::-1],n)

print(ans[::-1])

Measured memory_bytes: 9188
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int>powers(N);

    for (int i=0; i<N; i++)cin >> powers[i];
    vector<int> last_powers(N);
    for (int i=0; i<K; i++){
        vector<int>IO(N*2);
        vector<int>total(N*2);
        for (int j=0; j<N; j++){
            int dj = powers[j];
            IO[max((j-dj)*2-1,0)]++;
            IO[min((j+dj)*2+1,N*2-1)]--;
        }
        for (int j=0; j<N*2; j++){
            if (j==0)total[j] = IO[j];
            else total[j] = total[j-1] + IO[j];
        }
        for (int j=0; j<N; j++)powers[j] = total[j*2];
        
        /*
        cout << "k_" << i+1 << ": ";
        for (int j=0; j<N; j++){
            cout << total[j*2] << " ";
            powers[j] = total[j*2];
        }*/
        bool is_same = true;
        if (i > 0){
            for (int j=0;j <N; j++){
                if (powers[j] != last_powers[j]){
                    is_same = false;
                    break;
                }
            }
            if (is_same){
                for (int k=0; k<N; k++)cout << powers[k] << " ";
                cout << endl;
                exit(0);
            }
        }
        last_powers = powers;
    }

    for (int k=0; k<N; k++)cout << powers[k] << " ";
    cout << endl;
    exit(0);    
}

Measured memory_bytes: 8340
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		final Scanner sc = new Scanner(System.in);
		
		while(true){
			final int Y = sc.nextInt();
			final int Q = sc.nextInt();
			
			if(Y == 0 && Q == 0){
				break;
			}
			
			String names[] = new String[Y];
			int[] dec = new int[Y];
			int[] years = new int[Y];
			
			for(int i = 0; i < Y; i++){
				names[i] = sc.next();
				dec[i] = sc.nextInt();
				years[i] = sc.nextInt();
			}
			
			for(int i = 0; i < Q; i++){
				final int y = sc.nextInt();
				
				boolean found = false;
				int pos = -1;
				for(int j = 0; j < Y; j++){
					if((years[j] - dec[j]) < y && y <= years[j]){
						pos = j;
						found = true;
						break;
					}
				}
				
				if(!found){
					System.out.println("Unknown");
				}else{
					System.out.println(names[pos] + " " + (y - (years[pos] - dec[pos])));
				}
			}
		}
		
		
	}

}

Measured memory_bytes: 14000
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string s;
    cin >> s;
    map<char,int> mp;
    REP(i,s.size()) {
        if(s[i] == 'A') {
            if(mp.count(s[i])) chmin(mp[s[i]],i);
            else mp[s[i]] = i;
        } else if(s[i] == 'Z') {
            if(mp.count(s[i])) chmax(mp[s[i]],i);
            else mp[s[i]] = i;
        }
    }
    cout << mp['Z'] - mp['A'] + 1 << endl;
}

Measured memory_bytes: 640
N,W = map(int, input().split())
wvs = []
for i in range(N):
    w,v = map(int, input().split())
    wvs.append((w,v))
# dp : n個入っていて、合計がwのときの最大値
w0 = wvs[0][0]
dp = [[[-1]*(330) for i in range(110)] for k in range(110)]
dp[0][0][0] = 0
for i in range(N):
    w, v = wvs[i]
    dw = w-w0
    for j in range(i+1):
        for k in range(310):
            # if k - dw >= 0:
            if dp[i][j][j] == -1:continue
            dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k])
            dp[i+1][j+1][k+dw] = max(dp[i][j][k]+v, dp[i+1][j+1][k+dw])

d = dp[N]
ans = 0
for j in range(N+1):
    if W-j*w0 >= 0:
        a = max(d[j][:W-j*w0+1])
        ans = max(ans, a)
print(ans)

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

int main(){

    int n;
    cin >> n;
    int h[n];
    repeat(n) cin >> h[i];

    int res = 0;
    for(int i = 0; i < n; i++){
        bool isCandidate = true;
        for(int j = 0; j < i; j++){
            if(h[j] > h[i]){
                isCandidate = false;
                break;
            }
        }
        if(isCandidate)
            res++;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
//                  Allah_Almost3aan       
//      *{ربى..  كنْ لىِ خيرَ مدبر فإنى لا احسنُ التدبير}*
#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define endl "\n"
#define mod 1e9+7
#define INF 1e9
#define SZ 200001
const lli  OO = 1e18;
void fast() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE //freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#endif 
}
lli di[8] = { -1, 1, 0, 0, -1, 1, -1, 1 };
lli dj[8] = { 0, 0, -1, 1, 1, 1, -1, -1 };
lli cnt , frq[SZ], n, m, k;
vector<vector<pair<lli, lli>>>adj;
vector<bool>vis;
int main() {
	lli q;  // cin >> q;
	q = 1;
	while (q--)
	{
		string s, temp, last="#"; cin >> s;
		temp = s[0];
		for (int i = 1; i < s.size(); i++)
		{
		    	if (temp != last)
			{
			    //	cout<<temp<<" ";
				cnt++;
					last = temp;
				temp.clear();
			}
		    temp += s[i];
		}
		if (temp != last) cnt++;
		cout << cnt << endl;
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int P ,Q ,R;
    cin >> P >> Q >> R;
    if ( min({P+Q, Q+R, R+P}) == P+Q ){
        cout << P+Q;
    }
    else if ( min({ P+Q, Q+R, R+P }) == Q+R ){
        cout << Q+R;
    }
    else {
        cout << R+P;
    }
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define endl "\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

ll const inf = 1e18;
ll const maxn = 1e6+5;
ll const mod = 1e9+7;

// code begins here

int main(){
    fast;

    ll n;
    cin>>n;
    
    cout<<(1000 - (n%1000))%1000<<endl;

    return 0;
}


Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.function.Function;

public class Main {

    long INF = 1L << 50;

    void solve() {

    }

    void run() {
        int n = 0, m = 0, s = 0, t = 0;
        E[] g = null;

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String[] sp = br.readLine().split(" ");

            n = Integer.parseInt(sp[0]);
            m = Integer.parseInt(sp[1]);
            s = Integer.parseInt(sp[2]) - 1;
            t = Integer.parseInt(sp[3]) - 1;

            g = new E[n];

            for (int i = 0; i < n; i++) {
                g[i] = new E();
            }

            for (int i = 0; i < m; i++) {
                sp = br.readLine().split(" ");

                int u = Integer.parseInt(sp[0]) - 1;
                int v = Integer.parseInt(sp[1]) - 1;
                long a = Long.parseLong(sp[2]);
                long b = Long.parseLong(sp[3]);

                g[u].add(new V(v, a, b));
                g[v].add(new V(u, a, b));

            }
        } catch (Exception e) {
        }

        long init = (long) 1e15;

        long[] yen = dijkstra(n, s, g, v -> v.a);
        long[] snk = dijkstra(n, t, g, v -> v.b);
        long[] ans = new long[n + 1];

        for (int i = n - 1; i >= 0; i--) {
            ans[i] = Math.max(ans[i + 1], init - yen[i] - snk[i]);
        }

        PrintWriter pw = new PrintWriter(System.out);

        for (int i = 0; i < n; i++) {
            pw.println(ans[i]);
        }
        pw.flush();
    }

    public long[] dijkstra(int n, int s, E[] g, Function<V, Long> f) {
        PriorityQueue<P> pq = new PriorityQueue<>();
        long[] visit = new long[n];
        Arrays.fill(visit, INF);
        visit[s] = 0;
        pq.add(new P(s, 0));

        while (!pq.isEmpty()) {
            P cur = pq.remove();
            if (cur.c != visit[cur.p]) continue;

            for (V next : g[cur.p])
                if (visit[next.to] > cur.c + f.apply(next)) {
                    visit[next.to] = cur.c + f.apply(next);
                    pq.add(new P(next.to, cur.c + f.apply(next)));
                }
        }
        return visit;
    }

    private static class E extends ArrayList<V> {
    }

    private static class V {
        int to;
        long a, b;

        public V(int to, long a, long b) {
            this.to = to;
            this.a = a;
            this.b = b;
        }
    }

    private static class P implements Comparable<P> {
        int p;
        long c;

        public P(int p, long c) {
            this.p = p;
            this.c = c;
        }

        @Override
        public int compareTo(P o) {
            return o.c > c ? -1 : 1;
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 81592
#include<cstdio>
#include<algorithm>
using namespace std;
int N,M,S[100005],T[100005],P[100005],i,j,s,t,l,r;
long long int R=0,sum[100005];

long long int d(int i,int j)
{
	if(i>j)return 0;
	return sum[i]-sum[j+(j-i)%2];
}

int main()
{
	scanf("%d%d",&N,&M);
	for(i=0;i<N;i++)scanf("%d%d",&S[i],&T[i]);
	for(i=0;i<M;i++)scanf("%d",&P[i]);
	sort(P,P+M);
	sum[M-2]=P[M-1]-P[M-2];
	for(i=M-1;i>1;i--)sum[i-2]=sum[i]+P[i-1]-P[i-2];
	for(i=0;i<N;i++)
	{
		s=min(S[i],T[i]);t=max(S[i],T[i]);
		l=lower_bound(P,P+M,s)-P;
		r=lower_bound(P,P+M,t)-P-1;
		if(l==M||r==-1||l>r)
		{
			R+=t-s;
			continue;
		}
		if(S[i]<T[i]||(r-l)%2==1)R+=P[l]-s;
		if(S[i]>T[i]||(r-l)%2==1)R+=t-P[r];
		if(S[i]<T[i])R+=d(l+1,r);
		else R+=d(l+(l+r)%2,r);
	}
	printf("%lld\n",R);
	return 0;
}

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

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

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

#define MAX 500005

int main(int, char**)
{
  int n, s;
  cin >> n >> s;

  vector<int> a(n);
  rep(i,n) cin >> a[i];

  int l = 0, r = 0, sum = 0;
  int ans = n + 1;
  for (;;) {
    while (r < n && sum < s) sum += a[r++];
    if (sum < s) break;
    ans = min(ans, r-l);
    sum -= a[l++];
  }
  if (ans > n) ans = 0;
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3124
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<set>
using namespace std;
const int MA=50000;
int p[100000],tcnt,ans[100000];
int main(){
	for(int i=2;i<=60000;i++){
		bool f=1;
		for(int j=2;j*j<=i;j++)if(i%j==0)f=0;
		if(f)p[tcnt]=i,tcnt++;
	}
	for(int i=0;i<MA;i++){
		if(p[i]>MA)break;
		for(int j=0;j<MA;j++){
			if(p[i]+p[j]>MA)break;
			if(i>j)continue;
			ans[p[i]+p[j]]++;
		}
	}
	
	int n;
	while(cin>>n,n)cout<<ans[n]<<endl;
	
}

Measured memory_bytes: 1384
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
 
int main()
{
    string W;
    cin >> W;
 
    for(int i=0; i<W.size(); i++){
        W[i] = tolower(W[i]);
    }
 
    int cnt = 0;
 
    while(true){
        string T;
        cin >> T;
 
        if(T=="END_OF_TEXT")
            break;
 
        for(int i=0; i<T.size(); i++){
            T[i] = tolower(T[i]);
        }
 
        if(T==W){
            cnt++;
        }
    }
 
    cout << cnt << endl;
 
    return 0;
}

Measured memory_bytes: 1192
#include<stdio.h>
int main(void) {
	int a, b;
	char im[101][101];
	scanf("%d %d", &a, &b);
	for (size_t i = 0; i < a; i++)
	{
		scanf("%s", &im[i]);
	}
	for (size_t i = 0; i < a; i++)
	{
		printf("%s\n%s\n", im[i], im[i]);
	}
	return 0;
}

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

int main() {
  int N,ans=0;
  string S;
  cin >> N >> S;
  vector<vector<int>> V(N+1,vector<int>(N+1,0));
  
  for(int i=N-1;i>=0;i--){
    for(int j=i-1;j>=0;j--){
      if(S[i]==S[j]){
        V[i][j] = min((i-j),(V[i+1][j+1]+1));
        ans = max(ans,V[i][j]);
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 98176
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define m0(x) memset(x,0,sizeof(x))
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

map<ll, ll> primeFactors(ll n)
{
    map<ll, ll> ret;
    while (n % 2 == 0)
    {
        if( ret.find(2) != ret.end() ) {
            ret[2]++;
        }
        else
        {
            ret[2] = 1;
        }
        n = n / 2;
    }
    for (ll i = 3; i <= sqrt(n); i = i+2)
    {
        while (n%i == 0)
        {
            if( ret.find(i) != ret.end() ) {
            ret[i]++;
        }
        else
        {
            ret[i] = 1;
        }
            n = n / i;
        }
    }
    if (n > 2)
        {
            if( ret.find(n) != ret.end() ) {
            ret[n]++;
        }
        else
        {
            ret[n] = 1;
        }
        }
    return ret;
}

void print_map(map<ll, ll> mp){
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        std::cout << "key = " << itr->first           // キーを表示
                        << ", val = " << itr->second << "\n";    // 値を表示
    }
}

// Returns nCr % p
ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
    ll arr[1000100];
    ll s;
    cin >> s;
    ll count = 1;
    rep(i, 1000100) {
        arr[i] = 0;
    }
    while (true)
    {
        if (arr[s] == 0) {
            arr[s] += 1;
        } else if (arr[s] == 1) {
            cout << count << endl;
            return 0;
        }
        if (s % 2 == 0) {
            s >>= 1;
        } else {
            s = 3 * s + 1;
        }
        count++;
    }
    return 0;
}



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

using Lint=long long;

class UnionFind
{
 public:
    vector<int> par,sz;
    UnionFind(int N):par(N),sz(N){
        for(int i=0;i<N;i++){
            par[i]=i; sz[i]=1;
        }
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x); y=find(y);
        if(x==y) return;
        if(sz[x]<sz[y]) swap(x,y);
        par[y]=x;
        sz[x]+=sz[y];
    }
    bool same(int x,int y){ return find(x)==find(y); }
    int size(int x){ return sz[find(x)]; }
    bool root(int x){ return par[x]==x; }
};

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

    int N,Q; cin>>N>>Q;
    UnionFind tree(N);
    while(Q--){
        int q,x,y; cin>>q>>x>>y;
        if(q==0) tree.unite(x,y);
        else cout<<tree.same(x,y)<<endl;
    }
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> B(N-1);
    int i;
    for(i=0;i<N-1;i++) cin >> B[i];
    int ans;
    ans = B[0];
    for(i=0;i<N-2;i++){
        ans += min(B[i], B[i+1]);
    }
    ans += B[i];
    cout << ans << endl;
    return 0;
}

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

bool flag[1000010];

int main(){
	int n, p;
	cin >> n;
	p = n;
	cout << n << ":";
	while (1){
		if (n == 1){
			cout << endl;
			break;
		}
		for (int i = 2;i< 1000010; i++){
			if (n%i == 0){
				cout << " " << i;
				n /= i;
				break;
			}
		}
		if (n == p){
			cout << " " << p << endl;
			break;
		}
	}
}

Measured memory_bytes: 1168
#include <algorithm>
#include <cmath>
#include <cstring>  // memset()
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define ll long long
#define For(i, a, b) for (int i = (int)(a), sz = (int)(b); i < sz; i++)
#define rFor(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(0), cin.tie(0)

const int MAX = 1e5 + 5;

int main() {
    IO;
    int n, k, ans = 0;
    cin >> n >> k;
    vector<int> v(n);
    For(i, 0, n) cin >> v[i];
    sort(all(v));
    For(i, 0, k) ans += v[i];
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3716
n, c = map(int, input().split())
XV = [list(map(int, input().split())) for _ in range(n)]
X, V = zip(*XV)
dp_I_r = [0]*n
dp_U_r = [0]*n
dp_I_l = [0]*n
dp_U_l = [0]*n
dp_I_r[0] = V[0] - X[0]
dp_U_r[0] = V[0] - 2*X[0]
dp_I_l[n-1] = V[n-1] - (c - X[n-1])
dp_U_l[n-1] = V[n-1] - 2*(c - X[n-1])
for i in range(n-1):
  dp_I_r[i+1] = dp_I_r[i] + V[i+1] - (X[i+1] - X[i])
  dp_U_r[i+1] = dp_U_r[i] + V[i+1] - 2*(X[i+1] - X[i])
  dp_I_l[n-2-i] = dp_I_l[n-1-i] + V[n-2-i] - (X[n-1-i] - X[n-2-i])
  dp_U_l[n-2-i] = dp_U_l[n-1-i] + V[n-2-i] - 2*(X[n-1-i] - X[n-2-i])
for i in range(n-1):
  dp_I_r[i+1] = max(dp_I_r[i], dp_I_r[i+1])
  dp_U_r[i+1] = max(dp_U_r[i], dp_U_r[i+1])
  dp_I_l[n-2-i] = max(dp_I_l[n-1-i], dp_I_l[n-2-i])
  dp_U_l[n-2-i] = max(dp_U_l[n-1-i], dp_U_l[n-2-i])
ans = 0
for i in range(n):
  ans = max(ans, dp_I_r[i])
  ans = max(ans, dp_I_l[i])
  if i < n-1:
    ans = max(ans, dp_U_r[i] + dp_I_l[i+1])
  if i > 0:
    ans = max(ans, dp_U_l[i] + dp_I_r[i-1])
print(ans)

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

int calc(int h, int w, int k, string[] S) {
    int ans = int.max;
    auto g = new int[h];
    for (int mask = 0; mask < (1 << (h - 1)); mask++) {
        int num = 0;
        foreach (i; 0..h) {
            g[i] = num;
            if ((mask >> i) & 1) num++;
        }
        num++; // +1 することでグループ総数になる

        int cut = num - 1; // カット回数
        int[10] cnt; // グループごとの 1 の個数
        for (int col = 0; col < w; col++) {
            for (int row = 0; row < h; row++) {
                if (S[row][col] == '1') cnt[g[row]]++;
            }
            foreach (i; 0..num) {
                if (cnt[i] > k) { // 溢れるので、ここで縦にカット
                    cut++;
                    cnt[] = 0;
                    for (int r = 0; r < h; r++) {
                        if (S[r][col] == '1') cnt[g[r]]++;
                    }
                    break;
                }
            }
            // 1 列のみでも溢れるかチェック
            foreach (i; 0..num) {
                if (cnt[i] > k) {
                    cut = int.max/2;
                    break;
                }
            }
        }
        ans = min(ans, cut);
    }
    return ans;
}

void main() {
    int h, w, k; scan(h, w, k);
    string[] S;
    foreach (_; 0..h) S ~= read!string;
    writeln(calc(h, w, k, S));
}

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


Measured memory_bytes: 380
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <unordered_map>
//#include <string>
//typedef long long LL;
//typedef long double LD;
using namespace std;

int main() {
    char c;
    int tmp;
    char ans;
    cin >> c;
    c++;
    cout << c << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main()
{
	int r, c;
	cin >> r >> c;

	int i, j;
	int table[100][100] = {};
	for (i = 0; i < r; i++) {
		for (j = 0; j < c; j++) {
			cin >> table[i][j];
		}
	}

	int line[100] = {};
	int column[100] = {};
	int sum = 0;
	for (i = 0; i < r; i++) {
		for (j = 0; j < c; j++) {
			line[j] += table[i][j];
			column[i] += table[i][j];
			sum += table[i][j];
		}
		
	}

	for (i = 0; i <= r; i++) {
		for (j = 0; j <= c; j++) {
			if (i == r && j == c) {
				cout << sum << endl;
			}
			else if (i == r) {
				cout << line[j] << " ";
			}
			else if (j == c) {
				cout << column[i] << endl;
			}
			else cout << table[i][j] << " ";
		}

	}

	return 0;
}



Measured memory_bytes: 3156
#include<iostream>
#include<string>
#include<stdio.h>
#include<cmath>
using namespace std;

#define max(a,b) a > b ? a : b

int main() {

    int A, B, C;

    cin >> A >> B >> C;

    if ((A == B && A != C)
        || (A != B && A == C)
        || (A != B && B == C))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


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

int main(){
  int N;
  int A;
  int S;
  
  cin>>N;
  cin>>A;
  
  S=N%500;
  
  if(S<=A){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

int findN(int n){
    int sum = 0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}
int main(){
    int N,A,B;
    cin >> N >> A >>B;
    int total = 0;
    for(int i = 1; i<=N;++i){
        int sum = findN(i);
        if(sum>= A && sum<=B){
            if(sum>=A && sum <= B){
                total += i;
            }
        }
    }
    cout << total << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9

vector<pair<ll,ll>> prime_factorize(ll n){
    vector<pair<ll,ll>> res;
    for(ll p=2;p*p<=n;p++){
        if(n%p!=0) continue;
        int num=0;
        while(n%p==0){
            num++;
            n/=p;
        }
        res.push_back(make_pair(p,num));
    }
    if(n!=1) res.push_back(make_pair(n,1));
    return res;
}

const int MAX=210000;

ll fac[MAX],finv[MAX],inv[MAX];
void 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;
    }
}

ll 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(){
    int N,M;
    COMinit();
    cin>>N>>M;
    auto vec=prime_factorize(M);
    ll res=1;
    for(auto pa : vec){
        int num=pa.second;
        ll tmp=COM(num+N-1,N-1);
        res=(res*tmp)%MOD;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 5120
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int itemCount = int.Parse(Reader.ReadLine());

        long[] itms = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        
        bool isBigger = true;
        bool isSmaller = true;
        int ans = 1;
        for (int i = 1; i < itms.Length; i++)
        {
            if (itms[i - 1] > itms[i])
            {
                isBigger = false;
            }
            else if (itms[i - 1] < itms[i])
            {
                isSmaller = false;
            }
            if ((!isBigger) && (!isSmaller))
            {
                ans++;
                isBigger = true;
                isSmaller = true;
            }
        }
        Console.WriteLine(ans);
    
    }






    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"



";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 22880
N = int(input())
A = []
B = []
for i in range(N):
    a = int(input())
    A.append(a)
    B.append(a)
B.sort(reverse = True)
for i in range(N):
    if A[i] == B[0]:
        print(B[1])
    else:
        print(B[0])

Measured memory_bytes: 14180
# coding: utf-8
from fractions import gcd 
from functools import reduce
# my functions here!
def pin(type=int):
    return map(type,input().split())
#input
N,K =pin()
H = list(pin())
#solution
H.sort()
#print(H)
ans=0
if N > K:
    for i in range (K):
        H.pop()
    print(sum(H))
else:
    print(0)
#output
#print(ans)

Measured memory_bytes: 27804
W, H, x, y = map(int, input().split())

#正方形なら複数　これも面積半分?
#長方形なら一つ 点対称の線を引けば面積半分にできる

if W/2 == x and H/2 == y:
    print(W*H/2, 1)
else:
    print(W*H/2, 0)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,k,ans=1e18+7;
int a[200005];
int up(int a,int b){
	if (a%b==0) return a/b;
	else return (a/b)+1;
}
bool check(int len){
	int tot=0;
	for (int i=1;i<=n;i++)
	    tot=tot+up(a[i],len)-1;
	if (tot<=k) return true;
	else return false;
}
int Binary_search(int l,int r){
	if (l==r||l+1==r){
		if(check(l)) ans=min(ans,l);
		if(check(r)) ans=min(ans,r);
		return ans; 
	}
	int mid=(l+r)/2;
	if(check(mid)){
		ans=min(ans,mid);
		return Binary_search(l,mid);
	}
	else return Binary_search(mid+1,r);
}
signed main(){
	cin>>n>>k;
	for (int i=1;i<=n;i++)
	    cin>>a[i];
	cout<<Binary_search(1,1e9)<<endl;
	return 0;
}

Measured memory_bytes: 5124
n,q = map(int, input().split())
s = list(input())
lr_list = [list(map(int,input().split())) for _ in range(q)]
tmp_list = [0]*(n+1)

for i in range(1,n):
    if s[i-1]=='A' and s[i]=='C':
        tmp_list[i] = tmp_list[i-1]+1
    else:
        tmp_list[i] = tmp_list[i-1]

for l,r in lr_list:
    print(tmp_list[r-1]-tmp_list[l-1])


Measured memory_bytes: 31392
n=int(input())
a=[int(input()) for i in range(n)]
max_a=max(a)
max_a_index=a.index(max_a)
a.pop(max_a_index)
semimax_a=max(a)
for i in range(n):
  if i!=max_a_index:
    print(max_a)
  else:
    print(semimax_a)

Measured memory_bytes: 12512
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        string s = Console.ReadLine();

        bool res = true;

        for (int i = 0; i < a; i++)
            if (s[i] == '-')
                res = false;

        if (s[a] != '-')
            res = false;

        for (int i = a + 1; i < 1 + a + b; i++)
            if (s[i] == '-')
                res = false;

        Console.WriteLine(res ? "Yes" : "No");

    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#define ll long long int
using namespace std;
int main(){
  int n,sum=0;cin>>n;
  vector<int> s(n);
  for(int i=0;i<n;++i)cin>>s[i],sum+=s[i];
  sort(s.begin(),s.end());
  if(sum%10!=0){
    cout<<sum<<endl;
    return 0;
  }else{
    for(int i=0;i<n;++i){
      if(s[i]%10!=0){
        sum-=s[i];
        cout<<sum<<endl;
        return 0;
      }
    }
    cout<<0<<endl;
    return 0;
  }  
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    long long a[100010];
    long long b[100010];
    long long ans = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        cin >> b[i];
    }
    for(int i = n; i >= 1; i--){
        if((a[i] + ans) % b[i] == 0){
            continue;
        }
        ans += b[i] - ((a[i] + ans) % b[i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int C[400][4];
map<long long, int> E;
long long enc(int a, int b, int c, int d) {
  return 1000LL*1000LL*1000LL*a + 1000LL*1000LL* b + 1000LL*c + d;
}
void add(int i, int x) {
  E[enc(C[i][0], C[i][1], C[i][2], C[i][3])] += x;
  E[enc(C[i][1], C[i][2], C[i][3], C[i][0])] += x;
  E[enc(C[i][2], C[i][3], C[i][0], C[i][1])] += x;
  E[enc(C[i][3], C[i][0], C[i][1], C[i][2])] += x;
}

void add(int a, int b, int c, int d, int x) {
  E[enc(a, b, c, d)] += x;
  E[enc(b, c, d, a)] += x;
  E[enc(c, d, a, b)] += x;
  E[enc(d, a, b, c)] += x;
}

int t[4][4];
long long solve(int x1, int x2, int k) {
  rep(i, 4) {
    t[i][0] = C[x2][(i+1+k)%4];
    t[i][1] = C[x2][(i+k)%4];
    t[i][2] = C[x1][(4-i)%4];
    t[i][3] = C[x1][(8-(i+1))%4];
    if (E.find(enc(t[i][0], t[i][1], t[i][2], t[i][3])) == E.end()) return 0;
  }
  long long r = 1;
  rep(i, 4) {
    r *= E[enc(t[i][0], t[i][1], t[i][2], t[i][3])];
    add(t[i][0], t[i][1], t[i][2], t[i][3], -1);
  }
  rep(i, 4) {
    add(t[i][0], t[i][1], t[i][2], t[i][3], 1);
  }
  return r;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) {
    rep(j, 4) {
      cin >> C[i][j];
    }
  }
  rep(i, N) add(i, 1);
  long long ctr = 0;
  for (int x1=0; x1<N; x1++) {
    add(x1, -1);
    for (int x2=0; x2<N; x2++) {
      if (x1 == x2) continue;
      add(x2, -1);
      rep(k, 4) {
        ctr += solve(x1, x2, k);
      }
      add(x2, 1);
    }
    add(x1, 1);
  }
  cout << ctr/6 << "\n";
  return 0;
}


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

int main(){
  string s,t;
  cin>>s>>t;
  int ans=0;
  rep(i,s.size()){
    if(s[i]!=t[i]) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3836
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main(){
	int n;
	cin >> n;
	string s="";
	for(int i=0;i<n;i++){
		cin >> s[i];
		if(s[i]=='Y'){
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;
	return 0;
}


Measured memory_bytes: 256
N,K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
ans = 100000000000
for i in range(N-K+1):
  le = l[i]
  ri = l[i+K-1]
  ans = min(ans,abs(le)+abs(ri-le),abs(ri)+abs(ri-le))
print(ans)

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N,K;
vector<ll> v;

int main(){
    cin >> N >> K;
    for(int i=0;i<N;i++){
        ll tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    sort(v.begin(),v.end());
    ll sum = 0;
    for(int i=0;i<K;i++) sum += v[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3588
W, H, x, y, r = map(int, input().split())

flg = False
for X in [x - r, x + r]:
    for Y in [y - r, y + r]:
        if not 0 <= X <= W:
            flg = True
        if not 0 <= Y <= H:
            flg = True

print(["Yes", "No"][flg])


Measured memory_bytes: 5600
require 'pp'

nums = gets.chomp!.chars.map(&:to_i)

add = ->(x, y) { x + y }
sub = ->(x, y) { x - y }

operations = ['+', '+', '+', '-', '-','-'].permutation(3).to_a.uniq.map {|ops|
    ops.map {|op| op == '+' ? [add, '+'] : [sub, '-'] }
}
operations.each do |op1, op2, op3|
    if op3[0].call(op2[0].call(op1[0].call(nums[0], nums[1]), nums[2]), nums[3]) == 7
        puts "#{nums[0]}#{op1[1]}#{nums[1]}#{op2[1]}#{nums[2]}#{op3[1]}#{nums[3]}=7"
        exit 0
    end
end


Measured memory_bytes: 2172
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double angle;
    angle = abs((H * 60. + M) / 2 - (M * 6));
    angle = min(angle, 360 - angle);
    double ans;
    ans = sqrt((A * A) + (B * B) - (2 * A * B * cos(angle / 180 * M_PI)));
    cout << fixed << setprecision(20) << ans << endl;
    return 0;
}




Measured memory_bytes: 4200
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

H,N = II()
A,B = Line(N,2)

dp = [float('inf')]*(H+1)
dp[0] = 0
for i in range(1,H+1):
    for j in range(N):
        temp = i-A[j]
        if temp>=0:
            dp[i] = min(dp[i],dp[i-A[j]]+B[j])
        else:
            dp[i] = min(dp[i],dp[0]+B[j])

print(dp[-1])

Measured memory_bytes: 42476
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

ll bo[30][100010];

int main() {
    ll N, C;
    cin >> N >> C;
    REP(i, 0, C) {
        fill(bo[i], bo[i] + 100010, 0);
    }
    REP(i, 0, N) {
        ll s, t, c;
        cin >> s >> t >> c;
        bo[c - 1][s - 1]++;
        bo[c - 1][t]--;
    }
    REP(i, 0, C) {
        REP(j, 0, 100005) {
            bo[i][j + 1] += bo[i][j];
        }
    }
    ll ans = 0;
    REP(i, 0, 100005) {
        ll tmp = 0;
        REP(j, 0, C) {
            if (bo[j][i] > 0) {
                tmp++;
            }
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 23680
import collections

n = int(input())
v = [int(i) for i in input().split()]
odd = collections.Counter(v[1::2])
even = collections.Counter(v[0::2])
# print(odd)

max_odd = max(odd, key=odd.get)
# print(max_odd)
max_even = max(even, key=even.get)
# print(max_even)

max_odd_v = odd[max_odd]
max_even_v = even[max_even]

if max_odd == max_even:
    if len(odd) > 1:
        max_2nd_odd = odd.most_common(2)[1][0]
        max_2nd_odd_v = odd[max_2nd_odd]
    else:
        max_2nd_odd_v = 0
    if len(even) > 1:
        max_2nd_even = even.most_common(2)[1][0]
        max_2nd_even_v = even[max_2nd_even]
    else:
        max_2nd_even_v = 0
    if (max_odd_v + max_2nd_even_v) < (max_even_v + max_2nd_odd_v):
        print(n - (max_even_v + max_2nd_odd_v))
    else:
        print(n - (max_odd_v + max_2nd_even_v))
else:
    print(n - (max_odd_v + max_even_v))

Measured memory_bytes: 18656
#include<stdio.h>

int keisan(int* N){
  if(*N%2==0){
    *N /=-2;
    return 0;
  }
  else{
   if(*N>0){
   *N /= -2;
   return 1;
  }
  else{
    *N /= -2;
    *N +=1;
    return 1;
  }
}
}


int main(void){
  int N;
  scanf("%d",&N);
  if(N==0){
    printf("0");
  }
  
  int x[1000000];
  int i=0;
  while(N!=0){
    x[i]=keisan(&N);
    i++;
  }
  for(int j=i-1;j>=0;j--){
    printf("%d",x[j]);
  }
  return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3

def main():
    N,K = map(int, input().split())
    
    N = N % K

    def sousa(num):
        before = num
        after = abs(N - K)
        if after >= before:
            return before
        else:
            return sousa(after)

    print(sousa(N))

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
use std::io;


fn main() {
    let n = read_one::<usize>();
    let hn = read::<usize>();

    let mut ans = hn[0];
    for i in 1..n {
        if hn[i] > hn[i - 1] { ans += hn[i] - hn[i - 1]; }
    }
    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

class Program {


    static void Main(string[] args) {
        
        int ln = int.Parse(Console.ReadLine());
        var g = new List<List<int>>();

        for (int i = 0; i < ln; i++) {
            g.Add(Enumerable.Repeat(0, ln).ToList());
        }

        for (int i = 0; i < ln; i++) {
            int[] ip = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();

            for (int j = 2; j < ip.Length; j++) {
                g[ip[0] - 1][ip[j] - 1] = 1;
            }
        }

        foreach (var v in g) {
            string s = "";
            for (int i = 0; i < v.Count; i++) {
                if (i > 0) s += " ";
                s += v[i];
            }
            Console.WriteLine(s);
        }
        
    }
    
}



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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b < c) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int D[1001][1001];

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


	int N, K;
	cin >> N >> K;

	int gyaku = 0;
	rep(i, N) {
		int x, y;
		char c;
		cin >> x >> y >> c;
		int k = x / K ^ y / K;
		x = x % K;
		y = y % K;
		if (c == 'W' ^ (k & 1)) {
			gyaku++;
			D[x][y]--;
		}
		else D[x][y]++;
	}

	for (int i = K - 1; i >= 0; i--) {
		for (int j = K - 1; j >= 0; j--) {
			D[i][j] += D[i][j + 1];
		}
	}
	for (int i = K - 1; i >= 0; i--) {
		for (int j = K - 1; j >= 0; j--) {
			D[i][j] += D[i + 1][j];
		}
	}
	int saidai = -1e9;
	rep(i, K) rep(j, K) {
		int kari = D[i][0] + D[0][j] - D[i][j] - D[i][j];
		saidai = max(saidai, kari);
		saidai = max(saidai, D[0][0] - kari);
	}
	co(gyaku + saidai);

	Would you please return 0;
}

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

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

class Program
{
    static void Main(string[] args)
    {
        var A = sc.ReadStr();
        var B = sc.ReadStr();
        var C = sc.ReadStr();
        Console.WriteLine(A[0].ToString() + B[1].ToString() + C[2].ToString());
    }

    static int MOD = (int)1e9 + 7;
    static int INF = (int)1e7 + 1;
    static long LINF = (long)1e13 + 1;
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    string A;
    cin >> A;
    int n = A.size();

    int next[n+1][26]; // i文字目以降で最初に文字cが登場するindex(存在しないときはn)
    fill(next[0], next[n+1], n);
    for (int i = n-1; i >= 0; i--) {
        for (int j = 0; j < 26; j++) next[i][j] = next[i+1][j];
        next[i][A[i] - 'a'] = i;
    }

    int dp[n+1]; // i文字目以降について、部分文字列とならない最短の文字列長
    fill(dp, dp+n+1, 1 << 30);

    vector < pair<char, int> > restoration(n+1, make_pair('?', n)); // 復元用テーブル

    dp[n] = 1;
    for (int i = n-1; i >= 0; i--) {
        for (int j = 0; j < 26; j++) {
            if (next[i][j] == n) {
                if (dp[i] > 1) {
                    dp[i] = 1;
                    restoration[i] = make_pair('a'+j, n);
                }
            } else if (dp[i] > dp[next[i][j] + 1] + 1) {
                dp[i] = dp[next[i][j] + 1] + 1;
                restoration[i] = make_pair('a'+j, next[i][j] + 1);
            }
        }
    }

    string ret = "";
    int idx = 0;
    while (idx < n) {
        auto p = restoration[idx];
        ret += p.first;
        idx = p.second;
    }

    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 23292
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld double
long double PI =3.14159265;
using ll = long long;

const ll modo=1e9+7;
const ll ms=2e5+5;
const ll inf=1e17;


ll ar[ms];


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


int main()
{
    //idfc;
  //  freopen("h1.txt","r",stdin);

    int n;
    ll m;
    cin>>n>>m;
    int i;


    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
    }
    sort(ar+1,ar+n+1);
    ll num=ar[1];
    ll kk=2e9;
    ll pp=1e9;
    kk*=pp;
   // cout<<kk<<"\n";
    ll lim=m*2;
    for(i=2;i<=n;i++)
    {
        num=(num*ar[i])/gcd(num,ar[i]);
        //cout<<num<<"\n";
        if(num>lim)
        {
            cout<<0;
            return 0;
        }
    }
    int x;
    for(i=1;i<=n;i++)
    {
        x=num/ar[i];
        if(x%2==0)
        {
            cout<<0;
            return 0;
        }
    }

    n=num/2;

    ll ans=(m/n)-(m/num);

    cout<<ans;

    return 0;
}

Measured memory_bytes: 4380