akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static long Mod = (long)1e9 + 7;
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static void Solve()
        {
            var S = ReadLine();
            WriteLine(S.LastIndexOf('Z') - S.IndexOf('A') + 1);
        }
    }
}

Measured memory_bytes: 26584
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>
#include <iomanip> 
#include <algorithm>
#include <queue>
#include <list>
#include <numeric>
#include <stack>
#include <unordered_map>
#include <map>
#include <set>
 
using namespace std;
 
#define sz(a) int((a).size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
#define watch(x) cout << #x << " : " << x << endl;
 
#define FastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef vector<ii> vii;
 
const int N = int(2e5)+10;
const int K = 10005;
// const int MOD = int(1e9)+7;
const int INF = int(1e9)+5;
const ll INF64 = 1e18;

const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }


void solve () {
    ll n,d;cin>>n>>d;
    int cnt = 0;
    for (int i=1;i<=n;i++) {
        ll x,y;cin>>x>>y;
        if (x*x + y*y <= d * d) cnt++;
    }
    cout<<cnt<<endl;
}

int main () {
    FastIO
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int t;
    // cin>>t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>

typedef long long ll;

int main() {
  int N, ans = 0, s = 0;
  cin >> N;
  vi H(N, 0), T(N, 0);
  for (int i = 0; i < N; i++) cin >> H[i];
  while (true) {
    int i = 0, j = 0;
    bool flag = true;
    for (i = 0; i < N; i++) {
      flag = flag * (T[i] == H[i]);
    }
    if (flag) break;
    for (i = 0; i < N; i++) {
      if (T[i] != H[i]) break;
    }
    for (j = i; j < N; j++) {
      if (T[j] < H[j])
        T[j]++;
      else
        break;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    vector<ll> a(m);
    ll sum = 0;
    rep(i,m) {
        cin>>a[i];
        sum += a[i];
    }
    cout << ((n >= sum) ? n - sum : -1) << endl;

    return 0;
}


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

#define MAX_N 100
#define MAX_W 10000

int main() {
    int N, W;
    cin >> N >> W;
    int v[MAX_N + 1], w[MAX_N + 1];
    int dp[MAX_N + 1][MAX_W + 1];

    for(int i = 1; i <= N; i++) {
        cin >> v[i] >> w[i];
    }

    for(int i = 1; i <= N; i++) {
        for(int j = 0; j <= W; j++) {
            if(w[i] > j) {
                dp[i][j] = dp[i - 1][j];
            } else {
                dp[i][j] = max(dp[i - 1][j], v[i] + dp[i - 1][j - w[i]]);
            }
            //cout << "dp[" << i << "][" << j << "] = " << dp[i][j] << endl;
        }
    }
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 7024
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

int v[NMAX];
int dp[NMAX];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i =0 ; i < n; ++i)
    {
        cin >> v[i];
    }
    dp[0] = 0;
    dp[1] = abs(v[1] - v[0]);

    for(int i = 2; i< n;  ++i)
    {
        dp[i] = min(dp[i-1] + abs(v[i] - v[i-1]), dp[i-2] + abs(v[i] - v[i-2]));
    }
    cout << dp[n-1];

    return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a,b,c,cmp=1,cmpp,data,m,h,w,x[10000000],y,xcmp=0,ycmp=0,sum=0;

string s;

vector<int> z;

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

       cin >> n >> a;
       rep(i,n){
           cin >> x[i];
       }
       long long int dp[n+1][n+1][50*a+1];//i枚まで j枚取り 合計がk
       
       rep(i,n+1){
           rep(j,n+1){
               dp[0][i][j]=0;
           }
       }
       dp[0][0][0]=1;
       rep(i,n){
           rep(j,n+1){
               rep(k,50*a+1){
                   if(k>=x[i]){
                       dp[i+1][j][k]=dp[i][j][k]+dp[i][j-1][k-x[i]];
                   }
                   else{
                       dp[i+1][j][k]=dp[i][j][k];
                   }
               }
           }
       }
       rrep(i,1,n+1){
           ans+=dp[n][i][i*a];
       }
       Cout(ans);
return 0;

}


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

int main(){
  int A, B, C, X;//500 100 50
  cin >> A >> B >> C >> X;
  int count = 0;
  
  for(int i = 0; i <= A; i++){
    for(int j = 0; j <= B; j++){
      for(int k = 0; k <= C; k++){
        if(X - 500 * i - 100 * j - 50 * k == 0)count++;
        if(X - 500 * i - 100 * j - 50 * k < 0)break;        
      }
    }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int h,w,x,y;
    cin >> h >> w >> x >> y;
    cout << shosu(10) << h*w/2.0 << " ";
    cout << (x*2 == h && y*2 == w) << endl;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    import time
    START = time.time()
    LIMIT = START + 1.9

    from sys import stdin
    # from collections import defaultdict
    # from collections import deque
    # from collections import Counter
    from copy import deepcopy
    # import numpy as np
    from numpy import random as np_random
    # import math
    import random
    input = stdin.readline

    CONTEST_NUM = 26
    INFTY = 10**9

    D = int(input())
    cc = [0]+list(map(int, input().split()))
    ss = [[0]*(CONTEST_NUM+1) for _ in range(D)]
    for i in range(D):
        ss[i] = [0]+list(map(int, input().split()))

    last_day = [-1]*(CONTEST_NUM+1)
    content = 0

    def count_discontent(content, date):
        for contest in range(1, CONTEST_NUM+1):
            content -= cc[contest]*(date-last_day[contest])
        return content

    def greedy_decide_contest(date):
        point = -INFTY
        for contest in range(1, CONTEST_NUM+1):
            get_point = ss[date][contest]+cc[contest]*(date-last_day[contest])
            if get_point > point:
                point = get_point
                t = contest
        return t

    tt = [0]*D
    for date in range(D):
        # t = int(input())
        t = greedy_decide_contest(date)
        tt[date] = t
        content += ss[date][t]
        last_day[t] = date
        content = count_discontent(content, date)
        # print(t)

    best_content = content
    best_tt = deepcopy(tt)

    P = 0.1

    while time.time() <= LIMIT:
        content = 0
        tt = [0]*(D)
        for date in range(D):
            if np_random.binomial(1, P):
                t = random.randint(1, CONTEST_NUM)
            else:
                t = greedy_decide_contest(date)
            tt[date] = t
            content += ss[date][t]
            last_day[t] = date
            content = count_discontent(content, date)
        if content > best_content:
            best_content = content
            best_tt = deepcopy(tt)
    
    # print(best_content)

    for t in tt:
        print(t)

    
    """
    m = int(input())
    for _ in range(m):
        d, q = map(int, input().split())
        ss_d = ss[d]
        content += (ss_d[q]-ss_d[tt[d]])
        tt[d] = q
    """      




Measured memory_bytes: 27436
import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n, m = map(int, input().split())
    E = [[] for _ in range(n)]
    rev = [[] for _ in range(n)]
    outdeg = [0] * n
    for _ in range(m):
        u, v = map(int, input().split())
        E[u].append(v)
        rev[v].append(u)
        outdeg[u] += 1

    order = []
    used = [False] * n
    # for v in range(n):
    #     if used[v]:
    #         continue
    #     used[v] = True
    #     stack = [(~v, -1), (v, -1)]
    #     while stack:
    #         v, p = stack.pop()
    #         if v >= 0:
    #             for nv in E[v]:
    #                 if used[nv]:
    #                     outdeg[v] -= 1
    #                 else:
    #                     used[nv] = True
    #                     stack.append((~nv, v))
    #                     stack.append((nv, v))
    #         else:
    #             v = ~v
    #             if outdeg[v] == 0:
    #                 order.append(v)
    #             if p != -1:
    #                 outdeg[p] -= 1

    def dfs(v):
        if used[v]:
            return
        used[v] = True
        for nv in E[v]:
            dfs(nv)
        order.append(v)
    any(dfs(v) for v in range(n))
    order.reverse()
    color = [-1] * n
    ans = []
    cnt = -1
    for v in order:
        if color[v] != -1:
            continue
        cnt += 1
        color[v] = cnt
        stack = [v]
        while stack:
            v = stack.pop()
            for nv in rev[v]:
                if color[nv] != -1:
                    continue
                color[nv] = cnt
                stack.append(nv)

    for _ in range(int(input())):
        u, v = map(int, input().split())
        print(int(color[u] == color[v]))
resolve()


Measured memory_bytes: 21616
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
//#include <set>
#include <vector>
//#include <map>
#include <iomanip>
//#include <utility>

#define ii InputInteger()
#define il InputLong()
#define is InputString()
#define f for( int i=0; i<n; i++ )

const int Inf = 2147483647;
const char e = '\n';

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef double d;
typedef vector <int> vi;
typedef vector <string> vs;

int InputInteger()
{
    int n;
    cin >> n;
    return n;
}
ll InputLong()
{
	ll n;
	cin >> n;
	return n;
}
string InputString()
{
	string s;
	cin >> s;
	return s;
}
void Ia( int arr[], int n )
{
    f
    {
        cin >> arr[i];
    }
}
vi Iv( vi& p )
{
	for( int& x: p )
    {
		cin >> x;
	}
	return p;
}
void Pv( vi p )
{
	for( int x: p )
    {
		cout << x << e;
	}
}
void Pa( int arr[], int n )
{
    f
    {
        cout << arr[i] << e;
    }
}
void Sa( int p[], int n )
{
	sort( p, p + n );
}
void Sa( vi& p )
{
	sort( p.begin(), p.end() );
}
bool comdes( int a, int b )
{
	return a > b;
}
void Sd( int p[], int n )
{
	sort( p, p + n, comdes );
}
void Sd( vi& p )
{
	sort( p.begin(), p.end(), comdes );
}
void Ca( int arr[], int n )
{
    f
    {
        arr[ i ] = 0;
    }
}
int main()
{
    ios_base::sync_with_stdio( false );
    // cin.tie( NULL );
    //int t;
    //t = ii;
   // while( t-- )
    {
        double PI = acos(-1.0);
        double a = ii, b = ii, h = ii, m = ii;
        h = (h*60) + m;
        h = h/2;
        double angle = abs((h) - (m * 6));
        angle = (PI * angle)/180;
        double cosa = cos(angle);
        double len = (a * a) + (b * b) - (2 * a * b * cosa);
        len = sqrt(len);
        cout << std :: fixed;
        cout << setprecision(20) << len;
        cout << e;
    }
    return 0;
}
///Kafe's Grandmaster template



Measured memory_bytes: 4220
// ProblemURL : https://atcoder.jp/contests/abc102/tasks/arc100_a
// ---------------------------------------------
package main

import (
	"fmt"
	"sort"
)

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		a[i] -= (i + 1)
	}

	sort.Ints(a)
	med := a[n/2]

	ans := 0
	for i := range a {
		ans += abs(a[i] - med)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 6528
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long
#define PII pair<int, int>
#define debug std::cout << "---debug---" << std::endl;
using namespace std;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;

ll n, k;
ll a[maxn];
ll vis[maxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    //freopen("E:\\myprogram\\data.in", "r", stdin);
    //freopen("E:\\myprogram\\data.out", "w", stdout);
    cin >> n >> k;
    for(int i = 1; i <= n; i++) cin >> a[i];
    vector<int> ans(maxn);
    ll cnt = 0;
    ans[cnt++] = 1;
    ll now = 1;
    vis[1] = 1;
    while(true) {
        now = a[now];
        if(vis[now]) break;
        ans[cnt++] = now;
        vis[now] = 1;
    }
    if(k < cnt) {
        cout << ans[k] << endl;
        return 0;
    }
    ll tmp = a[ans[cnt - 1]];
    ll l = 0, r = cnt;
    for(int i = 0; i < cnt; i++) {
        if(ans[i] == tmp) l = i;
    }
    cout << ans[( (k - l) % (r - l) + (r - l) ) % (r - l) + l] << endl;
    return 0;
}

Measured memory_bytes: 7228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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; }



int calc(ll a){
	int ret = 0;
	while(a){
		ret++;
		a /= 10;
	}
	return ret;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;cin >> n;
	int ans = 20;
	for(ll i = 1; i * i <= n; i++){
		if(n % i == 0){
			ans = min(ans, max(calc(i), calc(n / i)));
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c && c <= b)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";

	}
	cout << endl;
	
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int n,m,box,ans;
    scanf("%d %d\n",&n,&m);
    int A[n][m],b[m];
    for(int i =0;i<n;i++){
        for(int j=0;j<m;j++){
        scanf("%d ",&box);
        A[i][j] = box;
        }
    }
    for(int i=0;i<m;i++){
        scanf("%d\n",&box);
        b[i] = box;
    }
    for(int i=0;i<n;i++){
        ans =0;
        for(int j=0;j<m;j++){
            ans += A[i][j] * b[j];
        }
    printf("%d\n",ans);
    }
    return 0;
}



Measured memory_bytes: 2112
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

ll X[101010];
ll Idx[101010];

int main(){

    set<ll>S;
    ll N;
    cin >> N;
    S.insert(-1);
    S.insert(N + 1);
    S.insert(0);
    S.insert(N + 2);
    for(ll i = 1; i <= N; i++){
        cin >> X[i];
        Idx[X[i]] = i;
    }
    ll ans = 0;
    for(ll i = N; i >= 1; i--){
        ll idx = Idx[i];
        set<ll>::iterator it = (S.lower_bound(idx));
        ll mx = *it;
        it++;
        ll mxx = *it;
        it--;
        it--;
        ll mn = *it;
        it--;
        ll mnn = *it;
        if(mn != 0){
            ans += i * (mx - idx) * (mn - mnn);
        }
        if(mx != N + 1){
            ans += i * (idx - mn) * (mxx - mx);
        }
        S.insert(idx);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const ll inf = 1e18;const double INF = 1e12, EPS = 1e-9;

using VL = vector<ll>;
using VVL = vector<VL>;
int n, a[5000];
vector<vi> e;

VVL rec(int c, int p){
	VVL dp(1, VL(2, inf));
	dp[0][a[c] < 0] = a[c];
	
	for(int cld : e[c]) if(cld != p){
		VVL tmp = rec(cld, c);
		VVL next(dp.size() + tmp.size(), VL(2, inf));
		
		rep(i, tmp.size()) rep(j, 2) rep(k, dp.size()) rep(l, 2){
			if(tmp[i][j] == inf || dp[k][l] == inf) continue;
			
			assert(i + k < next.size());
			assert(i + k + 1 < next.size());
			assert((j | l) < 2);
			
			next[i + k][j | l] = min(next[i + k][j | l], tmp[i][j] + dp[k][l]);
			if(j == 0 || tmp[i][j] < 0) next[i + k + 1][l] = min(next[i + k + 1][l], dp[k][l]);
		}
		
		dp = next;
	}
	return dp;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	cin >> n; e.resize(n);
	rep(i, n) cin >> a[i];
	rep(i, n - 1){
		int u, v; cin >> u >> v; u--; v--;
		e[u].pb(v);
		e[v].pb(u);
	}
	VVL ans = rec(0, 0);
	int res = n - 1;
	rep(i, ans.size()) rep(j, ans[i].size()) if(ans[i][j] < inf) if(j == 0 || ans[i][j] < 0) res = min(res, i);
	cout << res << endl;
	return 0;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    itn n;
    cin >> n;
    if (n % 1000 == 0)
        print(0);
    else
        print(1000 - (n % 1000));

    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, H, W;
  cin>>N>>H>>W;
  int ans = 0;
  int h, w;
  for(int i=0;i<N;++i){
    cin>>h>>w;
    if(h>=H && w>=W) ans++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <cassert>
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <tuple>
#include <limits>
using namespace std;

struct MinCostFlowGraph {
private:
  using ll = long long;
  struct edge {
    int to;
    ll cap, cost;
    int r_idx;
    edge(int t, ll cap, ll cost, int r) :
      to(t), cap(cap), cost(cost), r_idx(r) {}
  };
  vector<vector<edge>> G;
  int sz;
public:
  MinCostFlowGraph(int n) : G(n), sz(n) {}

  void add_edge(int from, int to, ll cap, ll cost){
    int i = G[to].size(), i_ = G[from].size();
    G[from].emplace_back(to,cap,cost,i);
    G[to].emplace_back(from,0,-cost,i_);
  }
  ll min_cost_flow(int from, int to, ll f){
    ll ans = 0;
    while(f > 0){
      const ll INF = numeric_limits<ll>::max();
      vector<ll> dist(sz,INF);
      dist[from] = 0;
      vector<ll> potential(sz);
      vector<int> prev_v(sz,-1);
      vector<int> prev_e(sz,-1);
      priority_queue<pair<ll,int>> pq;
      pq.emplace(0,from);
      while(pq.size()){
        // auto [d, v] = pq.top();
        ll d, v;
        tie(d,v) = pq.top();
        d *= -1;
        pq.pop();
        if(dist[v] < d) continue;
        for(size_t i = 0; i < G[v].size(); ++i){
          const auto& e = G[v][i];
          if(e.cap == 0) continue;
          int v_ = e.to;
          ll d_ = d + e.cost + potential[v] - potential[v_];
          if(dist[v_] <= d_)
            continue;
          dist[v_] = d_;
          prev_v[v_] = v;
          prev_e[v_] = i;
          pq.emplace(-d_,e.to);
        }
      }
      if(dist[to] >= INF) return -1;
      for(int i = 0; i < sz; ++i)
        potential[i] += dist[i];
      int v = to;
      ll flow = f;
      while(v != from){
        int v_ = prev_v[v];
        flow = min(flow,G[v_][prev_e[v]].cap);
        v = v_;
      }
      v = to;
      while(v != from){
        int v_ = prev_v[v];
        auto& e = G[v_][prev_e[v]];
        e.cap -= flow;
        ans += flow*e.cost;
        G[v][e.r_idx].cap += flow;
        v = v_;
      }
      f -= flow;
    }
    return ans;
  }
};

int main(){
  int n, m, f;
  cin >> n >> m >> f;
  MinCostFlowGraph G(n);
  for(int i = 0; i < m; ++i){
    long long u, v, c, d;
    cin >> u >> v >> c >> d;
    G.add_edge(u,v,c,d);
  }
  cout << G.min_cost_flow(0,n-1,f) << endl;
}



Measured memory_bytes: 3208
import math
N = int(input())
 
def Nsinpou(x, base):
    #配列を返す Nsin[0]が上位桁 ex. 56(base=6) => [1,3,2]
    if x == 0: return [0] #log_n(0)の回避
    Nsin = []
    for i in range((int(round(math.log(x,base))//1)+1)):
        ithdigit = x%(base**(i+1)) // (base ** i)
        Nsin.append(ithdigit)
    Nsin.reverse()
    return Nsin
 
ans = N #最大でも1円玉N枚
for i in range(N+1): #分け方全探索
    coins = sum(Nsinpou(i,6)) + sum(Nsinpou(N-i,9))
    if coins < ans:
        ans = coins
    
print(ans)

Measured memory_bytes: 3064
import itertools
A, B, C, D = list(input())

op = ['+','-']

for op1,op2,op3 in itertools.product(op,op,op):
  x = A + op1 + B + op2 + C + op3 + D
  if(eval(x) == 7):
    print(x + "=7")
    break

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

#define INF 0x3f3f3f3f
#define eps 1e-6

typedef long long LL;
const double pi = acos(-1.0);
const long long mod = 1e9;
using namespace std;

int a[100005];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    //freopen("int.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int N;
    cin >> N;
    for(int i = 0;i < N;i++)
        cin >> a[i];
    int cnt = 0;
    for(int i = 0;i < N;i++)
        for(int j = N - 1;j > i;j--)
            if(a[j] < a[j - 1])
            {
                swap(a[j],a[j - 1]);
                cnt++;
            }

    for(int k = 0;k < N - 1;k++)
        printf("%d ",a[k]);
    printf("%d\n%d\n",a[N - 1],cnt);
    return 0;
}



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

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
    cin >> n;
  	int h[n];
  	int index = 0;
  	int highest_view = 0;
  	int o = 0;
  	while(index != n)
    {
      cin >> h[index];
      if(h[index] >= highest_view)
      {
        o++;
        highest_view = h[index];
      }
      index++;
    }
  	
  	cout << o << endl;
  	return 0;
}

Measured memory_bytes: 256
#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>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, a, b;
	ll ans = 0;
	cin >> n >> a >> b;
	vl v(n);
	rep(i, n) {
		cin >> v[i];
		if (i != 0) {
			ans += min(a*(v[i]-v[i-1]),b);
		}
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,t,c=0,ans=0;
    cin>>n;
    t=n;
    while(t>0)
    {
     t/=10;
     c++;
    }
    if(c%2)
    {
        ans+=(n-pow(10,c-1));
        ans++;
        c-=2;
        while(c>0)
        {
            ans+=(9*pow(10,c-1));
            c-=2;
        }
    }
    else
    {
        c--;
        while(c>0)
        {
            ans+=(9*pow(10,c-1));
            c-=2;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).bigin(), (c).end())

typedef long long ll;

int main()
{
    string s;
    int w;
    cin >> s >> w;
    int i = 0;
    while (i < s.size())
    {
        cout << s[i];
        i += w;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long INF = 1e18+5;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int count = 0;
    for (int i = 0; i < n; ++i) {
        int temp;
        cin >> temp;
        while(temp == temp/2 * 2)
        {
            count++;
            temp /= 2;
        }
    }
    long long solution = count * n;
    cout << count;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define N 110
using namespace std;
int sum[N][N],f[N][N][N];
int n,m,sx,sy;
char s[N];
int ans;
int sm(int x1,int y1,int x2,int y2)
{
    return sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1];
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",s+1);
        for(int j=1;j<=m;j++)
        {
            if(s[j]=='o')sum[i][j]++;
            else if(s[j]=='E')sx=i,sy=j;
        }
    }
    for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)sum[i][j]+=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
    memset(f,0xcf,sizeof(f));
    f[0][0][0]=0;
    for(int u=0;u<=n;u++)
    {
        if(sx-u<1)break;
        for(int d=0;d<=n;d++)
        {
            if(sx+d>n)break;
            int up=max(sx-u,d+1);
            int down=min(sx+d,n-u);
            if(up>down)continue;
            for(int l=0;l<=m;l++)
            {
                if(sy-l<1)break;
                for(int r=0;r<=m;r++)
                {
                    if(sy+r>m)continue;
                    int left=max(sy-l,r+1);
                    int right=min(sy+r,m-l);
                    if(left>right)continue;
                    ans=max(ans,f[d][l][r]);
                    if(u+d<n-sx)f[d+1][l][r]=max(f[d+1][l][r],f[d][l][r]+sm(sx+d+1,left,sx+d+1,right));
                    if(l+r<m-sy)f[d][l][r+1]=max(f[d][l][r+1],f[d][l][r]+sm(up,sy+r+1,down,sy+r+1));
                    if(l+r<sy-1)f[d][l+1][r]=max(f[d][l+1][r],f[d][l][r]+sm(up,sy-l-1,down,sy-l-1));
                    if(u+d<sx-1)f[d][l][r]=max(f[d][l][r],f[d][l][r]+sm(sx-u-1,left,sx-u-1,right));
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5504
#include "bits/stdc++.h"
#include <stdint.h>

#pragma optimize("O3")

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

#define sync                    \
ios_base::sync_with_stdio(0); \
cin.tie(0);                   \
cout.tie(0)
#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define fopen freopen("input.txt", "r", stdin); freopen("output.txt","w", stdout)
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, b, a) for(ll i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define REPR(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define MP make_pair
#define endl '\n'

const ll MOD = 998244353;
const ll INF = 1e18+1;
const int base = 2e5+1;
const ll MAX = 1e5+1;
const double EPS = 1e-9;
const double PI = acos(-1.);
const int MAXN = 1000+1;




int main()
{
    int a, b, c, d, e, f;
    cin >> a >> b >> c >>d>> e >> f;
    int sum = 0, sug = 0;
    double mx = 0;
    FOR(x,0,31)
    {
        if(100*a*x > f) break;
        FOR(y,0,31)
        {
            if(100*a*x + 100*b*y > f) break;
            FOR(z,0,3001)
            {
                if(100*a*x + 100*b*y + c*z > f) break;
                FOR(t,0,3001)
                {
                    if(100*a*x + 100*b*y + c*z + d*t > f) break;
                    if((c*z + d*t) <= ((a*x + b*y)*e))
                    {
                        double cur = 100*((c*z+d*t)/(100.*a*x + 100.*b*y + c*z + d*t));
                        if(cur >= mx && (100*a*x + 100*b*y + c*z + d*t) <= f)
                        {
                            mx = cur;
                            sum = 100*a*x + 100*b*y + c*z + d*t;
                            sug = c*z + d*t;
                        }
                    }
                }

            }
        }
    }

    cout << sum<<' '<<sug;

    return 0;
}






Measured memory_bytes: 256
N = int(input())
a_list = []
for i in range(N):
    a_list.append(int(input()))

checked = set()
if a_list[0] == 2:
    print(1)
    exit()

checked.add(a_list[0])
count = 1
btn = a_list[0]
for i in  range(1, N):
    ai = a_list[btn-1]
    count +=1
    if ai in checked:
        print(-1)
        exit()
    else:
        if ai == 2:
            print(count)
            exit()
        else:
            checked.add(ai)
            btn = ai
print(-1)

Measured memory_bytes: 13220
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;


struct Info{
	bool operator<(const struct Info &arg) const{
		return start < arg.start;
	};
	int start,back;
};

struct Train{
	int start,back;
};

void func(int N){

	int hour,minute,second;
	Info info[N];
	char left[10],right[10];
	bool FLG;


	for(int i = 0; i < N; i++){
		scanf("%s %s",left,right);

		hour = 10*(left[0]-'0')+(left[1]-'0');
		minute = 10*(left[3]-'0')+(left[4]-'0');
		second = 10*(left[6]-'0')+(left[7]-'0');

		info[i].start = 3600*hour+60*minute+second;

		hour = 10*(right[0]-'0')+(right[1]-'0');
		minute = 10*(right[3]-'0')+(right[4]-'0');
		second = 10*(right[6]-'0')+(right[7]-'0');

		info[i].back = 3600*hour+60*minute+second;
	}

	sort(info,info+N);

	Train train[N];
	int index = 0;

	train[0].start = info[0].start;
	train[0].back = info[0].back;
	index++;

	for(int i = 1; i < N; i++){

		FLG = false;

		for(int k = 0; k < index; k++){
			if(train[k].back <= info[i].start){
				train[k].start = info[i].start;
				train[k].back = info[i].back;
				FLG = true;
				break;
			}
		}

		if(!FLG){
			train[index].start = info[i].start;
			train[index].back = info[i].back;
			index++;
		}
	}
	printf("%d\n",index);

}

int main(){

	int N;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func(N);
	}

    return 0;
}

Measured memory_bytes: 2708
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

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

const ll MD = 1e9+7;

int n;
string st;


P expr(int &s);

P numb(int &s) {
//    printf("numb %d\n", s);
    while (isdigit(st[s])) s++;
    return P(1, 1);
}

P fact(int &s) {
//    printf("fact %d\n", s);
    P a;
    switch (st[s]) {
    case 'x':
        s++;
        a = numb(s);
        break;
    case '~':
        s++;
        a = fact(s);
        swap(a.first, a.second);
        break;
    case '(':
        s++;
        a = expr(s);
        s++;
        break;
    }
    return a;
}

P term(int &s) {
//    printf("term %d\n", s);
    P p = P(0, 1);
    while (true) {
        P d = fact(s);
//        printf("term_res %lld %lld\n", d.first, d.second);
        p.first = (ll)(p.first+p.second)*(d.first+d.second) % MD;
        p.first -= (ll)p.second*d.second % MD;
        p.first = (p.first % MD + MD) % MD;
        p.second = (ll)p.second*d.second % MD;
        if (s >= n) break;
        if (st[s] != '&') break;
        s++;
    }
    return p;
}

P expr(int &s) {
//    printf("expr %d\n", s);
    P p = P(1, 0);
    while (true) {
        P d = term(s);
        p.second = (ll)(p.first+p.second) * (d.first+d.second) % MD;
        p.second -= (ll)p.first * d.first % MD;
        p.second = (p.second % MD + MD) % MD;
        p.first = (ll)p.first*d.first % MD;
        if (s >= n) break;
        if (st[s] != '|') break;
        s++;
    }
    return p;
}


void main2() {
    cin >> st;
    n = st.size();
    int s = 0;
    cout << expr(s).second << endl;
}

ll eord, enew;
int main() {
    const int SZ = 128*1024*1024;
    void *p = malloc(SZ);
    enew = (long long)p + SZ - 1;

    __asm__("mov %rsp, eord");
    __asm__("mov enew, %rsp");

    main2();

    __asm__("mov eord, %rsp");
}

Measured memory_bytes: 64964
#include<stdio.h>

int main(void) {
        int n, m, l, i, j, k;
        scanf("%d %d %d", &n, &m, &l);
        int a[n][m];
        int b[m][l];
        long c[n][l];
        for(j=0;j<n;j++) {
                for(i=0;i<l;i++) {
                        c[j][i] = 0;
                }
        }

        for(j=0;j<n;j++) {
                for(i=0;i<m;i++) {
                        scanf("%d", &a[j][i]);
                }
        }
        for(j=0;j<m;j++) {
                for(i=0;i<l;i++) {
                        scanf("%d", &b[j][i]);
                }
        }

        for(j=0;j<n;j++) {
                for(i=0;i<l;i++) {
                        for(k=0;k<m;k++) {
                                c[j][i]+=a[j][k]*b[k][i];
                        }
                        printf("%ld", c[j][i]);
                        if(i!=l-1)      printf(" ");
                }
                printf("\n");
        }

        return 0;
}

Measured memory_bytes: 760
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
int n,m;
it gcd(int x,int y){return y==0?x:gcd(y,x%y);}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(m);
	print(1ll*n*m/gcd(n,m));
	return 0;
}

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

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}

typedef vector<int> Node;
typedef vector<Node> Graph;

bool visit(const Graph &g, int v, vector<int> &order, vector<int> &color) {
    color[v] = 1;
    for(int w : g[v]){
        if (color[w] == 2) continue;
        if (color[w] == 1) return false;
        if (!visit(g, w, order, color)) return false;
    }
    order.push_back(v); color[v] = 2;
    return true;
}

bool topological_sort(const Graph &g, vector<int> &order) {
    int n = g.size();
    vector<int> color(n);
    REP(u, n) if (!color[u] && !visit(g, u, order, color))
        return false;
    reverse(order.begin(), order.end());
    return true;
}

int main(){
    iostream_init();

    int N, M;
    cin >> N >> M;
    vector<Node> g(N);
    vector<Node> ps(N);
    REP(i, N + M - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        ps[b].push_back(a);
    }

    vector<int> order(N);
    topological_sort(g, order);
    map<int, int> t;
    for(int i = 0; i < N; i++) {
        t[order[i]] = i;
    }

    vector<int> parent(N, -1);
    for(int i = 0; i < N; i++) {
        int last_order = -1;
        for (int p : ps[i]) {
            last_order = max(last_order, t[p]);
        }
        for (int p : ps[i]) {
            if (t[p] == last_order) {
                parent[i] = p;
            }
        }
    }

    for(int i = 0; i < N; i++) {
        cout << parent[i] + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 21872
n, m = [int(i) for i in input().split()]

matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])

vector = []
for mi in range(m):
    vector.append(int(input()))

b = []
for ni in range(n):
    sum = 0
    for mi in range(m):
        sum += matrix[ni][mi] * vector[mi]

    print(sum)
    

Measured memory_bytes: 8076
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n,m,x;
    cin>>n>>m>>x;
    V price(n);
    VV vec(n,V(m));
    for(int i=0;i<n;i++){
        cin>>price[i];
        rep(j,m){
            cin>>vec[i][j];
        }
    }
    ll res=INF;
    for(int i=0;i<(1<<n);i++){
        V temp;
        for(int j=0;j<n;j++){
            if(i&(1<<j)){
                temp.push_back(1);
            }else{
                temp.push_back(0);
            }
        }
        ll cost=0;
        V master(m,0);
        rep(j,n){
            if(temp[j]){
                cost+=price[j];
                rep(k,m){
                    master[k]+=vec[j][k];
                }
            }
        }
        bool f=true;
        rep(i,m){
            if(master[i]<x){
                f=false;
                break;
            }
        }
        if(f){
            chmin(res,cost);
        }
    }
    if(res==INF){
        cout<<-1<<endl;
    }else{
        cout<<res<<endl;
    }
}


Measured memory_bytes: 3664