akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N, K;
  std::cin >> N >> K;

  std::unordered_set<i64> answers;
  for (i64 i = 1; i <= N; ++i) {
    answers.insert(i);
  }

  for (i64 i = 0; i < K; ++i) {
    i64 d_i;
    std::cin >> d_i;
    std::vector<i64> A_i;
    tools::read(A_i, d_i);
    for (const i64& A_ij : A_i) {
      answers.erase(A_ij);
    }
  }

  std::cout << answers.size() << std::endl;
  return 0;
}

Measured memory_bytes: 3628
A,B = [int(i) for i in input().split()]
count = 0
for i in range(A,B+1) :
    s = str(i)

    is_ok = True
    # lenが奇数でもいいはず。真ん中は関係ないので
    for n in range(len(s) // 2) :
        if (s[n] != s[-n-1]) :
            is_ok = False
            break
    if (is_ok):
        count += 1

print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <utility>

using namespace std;
int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;

  if (a > b) { swap(a, b);}

  if (a <= c && c <= b) {
    cout << "Yes" << "\n";
  } else {
    cout << "No" << "\n";
  }

  return 0;
}

Measured memory_bytes: 256
def resolve():
    N = int(input())
    g = {}
    for i in range(N-1):
        a, b = list(map(int, input().split()))
        g.setdefault(a-1, [])
        g[a-1].append((b-1, i))
        g.setdefault(b-1, [])
        g[b-1].append((a-1, i))
        
    nodes = [(None, 0)]
    colors = [None for _ in range(N-1)]
    maxdeg = 0
    while nodes:
        prevcol, node = nodes.pop()
        maxdeg = max(maxdeg, len(g[node]))
        color = 1 if prevcol != 1 else 2
        for nxt, colidx in g[node]:
            if colors[colidx] is None:
                colors[colidx] = color
                nodes.append((color, nxt))
                color += 1 if prevcol != color+1 else 2

    print(maxdeg)
    for col in colors:
        print(col)
            



if '__main__' == __name__:
    resolve()


Measured memory_bytes: 107416
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


using pint = pair<int,int>;

int N;
int main() {
    while (cin >> N) {
        vector<pint> res;
        if (N % 2 == 0) {
            int dame = N;
            for (int i = 1; i <= N; ++i) {
                for (int j = 1; j <= N; ++j) {
                    if (j <= i || j == dame) continue;
                    res.push_back(pint(i, j));
                }
                --dame;
            }
        }
        else {
            int dame = N-1;
            for (int i = 1; i <= N; ++i) {
                for (int j = 1; j <= N; ++j) {
                    if (j <= i || j == dame) continue;
                    res.push_back(pint(i, j));
                }
                --dame;
            }
        }
        cout << res.size() << endl;
        for (auto p : res) {
            cout << p.first << " " << p.second << endl;
        }
    }
}
        




Measured memory_bytes: 384
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define ALL(a)  (a).begin(),(a).end()
const int MOD = 1000000007;
int main() {

	vector<int>a(3);
	rep(i, 3) cin >> a[i];
	swap(a[0], a[1]);
	swap(a[0], a[2]);
	rep(i, 2) {
		cout << a[i] << " ";
	}
	cout << a[2] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main() {
    long long N;
    cin >> N;
    map<long long, int> mp;
    for (long long i = 2; i * i <= N; ++i) {
        while (N % i == 0) {
            N /= i;
            ++mp[i];
        }
    }
    if (N != 1) {
        ++mp[N];
    }
    int ans = 0;
    for (auto p : mp) {
        int c = 0, res = 0;
        while (c <= p.second) {
            c += res + 1;
            ++res;
        }
        ans += res - 1;
    }
    cout << ans << "\n";
    return 0;
}




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

int main(){
    int ioi = 0,joi = 0;
    string s,i_memo = "IOI",j_memo = "JOI";
    
    rep(k,0,5){
      	s = "";
        cin >> s;
        if(s == "") return 0;
        ioi = 0;joi = 0;
        
        rep(i,0,s.size()-2){
            rep(j,0,i_memo.size()){
                if(s[i+j] != i_memo[j]){
                    break;
                }
                else if(j == i_memo.size()-1){
                    ioi++;
                    
                }
            }
            
            rep(j,0,j_memo.size()){
                if(s[i+j] != j_memo[j]){
                    break;
                }
                else if(j == j_memo.size()-1){
                    joi++;
                }
            }
        }
        
        cout << joi << endl << ioi << endl;
    }
    return 0;   
}


Measured memory_bytes: 3204
# -*- coding: utf-8 -*-

import sys

days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
while True:
    ans = 3
    m, d = map(int, raw_input().split())
    if m == 0:
        break
    for i in range(1, m):
        if i == 2:
            ans = (ans+1)%7
        elif i == 4 or i == 6 or i == 9 or i == 11:
            ans = (ans+2)%7
        else:
            ans = (ans+3)%7
    ans = (ans+d)%7
    print days[ans]

Measured memory_bytes: 6260
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define all( X ) ( X ).begin(), ( X ).end()

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	bool is_visited = false;
} node;
typedef struct {
	int to;
	int cost;
	P <int, int> change;
} edge;

int main(){
	int N, count = 0; cin >> N;
	vector <bool> vec( N );
	rep( i, 0, N ){
		char c; cin >> c;
		vec[ i ] = ( c == 'R' );
	}
	int pos_red = N - 1;
	rep( i, 0, N ){
		if (!vec[ i ]){
			for(; pos_red > i; pos_red--){
				if (vec[ pos_red ]){
					count++;
					pos_red--;
					break;
				}
			}
		}
	}
	cout << count << endl;

}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 3628
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
long long int match(long long int m,long long int n)
{
	int t;
	if(m>=n)
	t=m-n;
	else 
	t=n-m;
	return t;
}
int main()
{
	long long int k,m;
	cin>>m>>k;
	if(m<k&&abs(m-k)>=m)
	cout<<m<<endl;
	else if(k==1&&m%k==0)
	cout<<"0"<<endl;
	else 
	{
		long long int d=m/k;
		long long int c=d+1;
		long long int n=min(abs(m-(d*k)),abs(m-(c*k)));
		cout<<n<<endl;
		}
			
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
int cnt[35], n, m;

int main() {
    cin>>n>>m;
    int k, x;
    for(int i=1;i<=n;i++) {
        cin>>k;
        for(int j=1;j<=k;j++) {
            cin>>x;
            cnt[x]++;
        }
    }

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

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

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
static const int Max =200000;

int main(){
  int R[Max],n;

  cin>>n;
  for(int i=0;i<n;i++)cin>>R[i];
  int maxv=-2000000000;
  int minv=R[0];

  for(int i=1;i<n;i++){
    maxv=max(maxv,R[i]-minv);
    minv=min(minv,R[i]);
  }

  cout<<maxv<<endl;
  return 0;
}



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

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (ll i = 0; i < n; ++i) cin >> a[i];
    for (ll j = 0; j < n; ++j) cin >> b[j];
    if (accumulate(a.begin(), a.end(), (ll)0) < accumulate(b.begin(), b.end(), (ll)0)) {
        cout << -1 << endl;
        return 0;
    }
    ll luck = 0;
    ll ans = 0;
    vector<ll> diff;
    for (ll k = 0; k < n; ++k) {
        if (a[k] < b[k]) {
            luck += b[k] - a[k];
            ans++;
        }
        else diff.emplace_back(a[k] - b[k]);
    }
    sort(diff.rbegin(), diff.rend());
    ll sum = 0;
    for (ll l : diff) {
        if (sum >= luck) break;
        ans++;
        sum += l;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2936
import math
N, D = map(int, input().split())
X = []
c = 0
for i in range(N):
    x = list(map(int, input().split()))
    X.append(x)
for i in range(N - 1):
    for j in range(i + 1, N):
        s = 0
        for k in range(D):
            s += (X[i][k] - X[j][k]) ** 2
        if math.sqrt(s).is_integer():
            c += 1
print(c)


Measured memory_bytes: 3060
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var sL = s.Length;
        var count = 0;
        for (int i = 0; i < sL / 2; i++)
            if (s[i] != s[sL - 1 - i]) count++;
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 11092
import java.util.*;
import java.io.*;
import java.math.*;
import java.awt.geom.*;
public class Main{
    public static void main(String[] args) {
      MyScanner sc=new MyScanner();
      char a[]={'a','b','c'};
      char b[]=(sc.next()).toCharArray();
      Arrays.sort(b);
      if(Arrays.equals(a,b)) System.out.println("Yes");
      else System.out.println("No");
  }
    private static class MyScanner {
      BufferedReader br;
      StringTokenizer st;

      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }

      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }

      int ni() {
          return Integer.parseInt(next());
      }
      float nf() {
        return Float.parseFloat(next());
      }
      long nl() {
          return Long.parseLong(next());
      }

      double nd() {
          return Double.parseDouble(next());
      }

      String nextLine(){
          String str = "";
    try {
       str = br.readLine();
    } catch (IOException e) {
       e.printStackTrace();
    }
    return str;
      }
   }
}

Measured memory_bytes: 21204
N, M = map(int,input().split())
route_1 = set()
route_N = set()

for _ in range(M):
    a, b = map(int,input().split())
    if a == 1:
        route_1.add(b)
    elif b == N:
        route_N.add(a)

if route_1&route_N:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

using namespace std;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()

#define MAX_LOG_N 17

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N; cin >> N;
  vector<vector<int>> hotels(2, vector<int>(N));
  REP(i, N) cin >> hotels[0][i];
  REP(i, N) hotels[1][i] = hotels[0][N-1] - hotels[0][N-1-i];

  int L, Q; cin >> L >> Q;
  vector<int> A(Q), B(Q); REP(i, Q) cin >> A[i] >> B[i], A[i]--, B[i]--;

  // doubling
  vector<vector<vector<int>>> doubling(2, vector<vector<int>>(MAX_LOG_N, vector<int>(N)));
  REP(k, 2) REP(i, N) {
    doubling[k][0][i] = upper_bound(ALL(hotels[k]), hotels[k][i] + L) - hotels[k].begin() - 1;
  }
  REP(k, 2) REP(i, MAX_LOG_N-1) REP(j, N) {
    doubling[k][i+1][j] = doubling[k][i][doubling[k][i][j]];
  }

  REP(q, Q) {
    int k = A[q] > B[q], a = A[q], b = B[q];
    if (a > b) a = N-1 - a, b = N-1 - b;
    assert(a < b);

    int ans = 0;
    for (int i = MAX_LOG_N-1; i >= 0; i--) {
      if (doubling[k][i][a] < b) ans += 1 << i, a = doubling[k][i][a];
    }
    cout << ans+1 << endl;
  }

  return 0;
}


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

int main(){
    int m, d;
    int days[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int mod;
    cin >> m >> d;
    while(m){
        for(int i=m-2;i>=0;i--){
            d += days[i];
        }
        mod = d % 7;
        if(mod == 0){
            cout << "Wednesday" << endl;
        }else if(mod == 1){
            cout << "Thursday" << endl;
        }else if(mod == 2){
            cout << "Friday" << endl;
        }else if(mod == 3){
            cout << "Saturday" << endl;
        }else if(mod == 4){
            cout << "Sunday" << endl;
        }else if(mod == 5){
            cout << "Monday" << endl;
        }else if(mod == 6){
            cout << "Tuesday" << endl;
        }
        cin >> m >> d;
    }
    return 0;
}

Measured memory_bytes: 0
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		String S = nextString();


		ArrayList<Integer> list = new ArrayList<>();
		for(int i=0;i<S.length();i++){
			int x = S.charAt(i)=='0'?-1:1;
			if(list.size()!=0&&list.get(list.size()-1)+x==0){
				list.remove(list.size()-1);
			}else{
				list.add(x);
			}
		}

		System.out.println(S.length()-list.size());
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

bool loop(string s)
{
    bool ans = true;
    for(int i=0;i<s.size();i++)
    {
        if(s.at(i)!=s.at(s.size()-1-i)) ans = false;
    }
    return ans;
}

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

    bool ans = true;

    if(!loop(s)) ans = false;

    string s2;
    for(int i=0;i<(s.size()-1)/2;i++)
    {
        s2.push_back(s.at(i));
    }

    if(!loop(s2)) ans = false;

    string s3;
    for(int i=(s.size()+3)/2-1;i<s.size();i++)
    {
        s3.push_back(s.at(i));
    }

    if(!loop(s3)) ans = false;

    if(ans) cout << "Yes" << endl;
    else    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
	float n;
	cin>>n;
	float ans;
	if(n==1){
		cout<<1<<'\n';
		return 0;
	}
	if((int)n&1){
		ans=((int)(n/2)+1)/n;
	}
	else{
		ans=0.5;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        while (true) {
            c -= b;
            if (c <= 0) break;
            a -= d;
            if (a <= 0) break;
        }
        System.out.println(c <= 0 ? "Yes" : "No");
    }
}

Measured memory_bytes: 35712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;

namespace AtCoder.ABC
{
    class QuestionA
    {
        public static void Main(string[] args)
        {
            var abc = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();

            var hash = new HashSet<int>();
            foreach(var a in abc) {
                if(hash.Contains(a) == false) {
                    hash.Add(a);
				}
			}

            Console.WriteLine(hash.Count);
        }
    }
}



Measured memory_bytes: 27992
import sys
import os
import math


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

    H, W = list(map(int, sys.stdin.readline().split()))

    if H == 1 or W == 1:
        print(1)
    else:
        print(int(((W*H)+1)/2) if (H*W)/2 != 0 else int((W*H)/2) )


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,k=map(int, readline().rstrip().split())
    arr=list(map(int, readline().rstrip().split()))
    for _ in range(k):
        tmp=[0]*n
        for i in range(n):
            x = i - arr[i]
            y = i + arr[i] + 1
            if x<0:
                x=0
            if y<n:
                tmp[y]-=1
            tmp[x]+=1
        sm=tmp[0]
        arr[0]=tmp[0]
        for i in range(1,n):
            arr[i]=arr[i-1]+tmp[i]
            sm+=abs(tmp[i])
        if tmp[0]==n and sm==n:
            break
    print(" ".join(map(str,arr)))
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------


Measured memory_bytes: 131212
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;

class UnionFind {
public:
vector<int> Parent;
UnionFind(int N) {
Parent = vector<int>(N, -1);
}
int root(int A) {
if (Parent[A] < 0) return A;
return Parent[A] = root(Parent[A]);
}
int size(int A) {
return -Parent[root(A)];
}
bool connect(int A, int B){
A = root(A);
B = root(B);
if(A == B) {
return false;
}
if(size(A)<size(B)) swap(A,B);
Parent[A] += Parent[B];
Parent[B] = A;
return true;
}
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    std::vector<long long> C(K);
    std::vector<long long> D(K);
    for(int i = 0 ; i < K ; i++){
        scanf("%lld",&C[i]);
        scanf("%lld",&D[i]);
    }
    UnionFind uf(N);
    vector<int> ans(N,0);
    REP(i,M){
        uf.connect(A[i]-1,B[i]-1);
        ans[A[i]-1]--;
        ans[B[i]-1]--;
    }
    REP(i,N){
        ans[i]+=uf.size(i)-1;
    }
    REP(i,K){
        if(uf.root(C[i]-1)==uf.root(D[i]-1)){
            ans[C[i]-1]--;
            ans[D[i]-1]--;
        }
    }
    REP(i,N-1) cout<<ans[i]<<" ";
    cout<<ans[N-1]<<endl;
    return 0;
}


Measured memory_bytes: 5504
#include <set>
#include <iostream>
#include <vector> 
#include <algorithm> 
#include <cmath> 

typedef std::pair<double,int> P;

int main() {
  int N, Q;
  auto ops = std::vector<P>(0);
  std::cin >> N >> Q;
  for(int i = 0; i < N; ++i) {
    int s,t,x;
    std::cin >> s >> t >> x;
    ops.push_back(std::make_pair(s - 0.1 - x,  x)); 
    ops.push_back(std::make_pair(t - 0.2 - x, -x)); 
  }

  std::sort(
    ops.begin(), 
    ops.end(), 
    [&](P x, P y){return x.first < y.first; }
  );

  auto st = std::set<int>();
  int k = 0;
  for(int i = 0; i < Q; ++i) {
    double x; std::cin >> x;
    while (k < ops.size()) {
      auto time = ops[k].first;
      if (x < time) { break; }
      auto sx = ops[k].second;
      //std::cout << k << ", " << time << ", " << sx << std::endl;
      if (sx > 0) {
        st.insert(sx);
      } else {
        st.erase(-sx);
      }
      k += 1;
    }
    std::cout << (st.empty() ? -1 : *st.begin()) << std::endl;
  }
}


Measured memory_bytes: 17640
#include<stdio.h>
int min(int ,int);
int main(){
  int i,j,k,l,n,m[101][101],x[101];
  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d %d",&x[i-1],&x[i]);
  for(i=1;i<=n;i++) m[i][i]=0;
  for(j=2;j<=n;j++){
    for(i=0;i<=n-j+1;i++){
      l=i+j-1;
      m[i][l]=(1<<21);
      for(k=i;k<=l-1;k++){
        m[i][l]=min(m[i][l],m[i][k]+m[k+1][l]+x[i-1]*x[k]*x[l]);
      }
    }
  }
  printf("%d\n",m[1][n]);
  return 0;
}

int min(int x,int y){
  return x<y ? x:y;
}






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

namespace agc030_a
{
    class Program
    {
        static void Main(string[] args)
        {
            var text = Console.ReadLine();
            var list = text.Split(' ').Select(x => int.Parse(x)).ToList();

            var n = list[0];
            var l = list[1];

            var mindata = int.MaxValue;

            var total = 0;
            for(var i = 0; i < n; i++){
                var val = l + (i + 1) - 1;
                if (Math.Abs(mindata) > Math.Abs(val)){
                    mindata = val;
                }
                total = total + val;
            }

            total = total - mindata;
            Console.WriteLine(total.ToString());
        }
    }
}


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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CN cout<<"No\n"
#define CY cout<<"Yes\n"

using namespace std;
using ll = long long;
ll recur(ll w,ll i,ll v[][2],ll n)
{
    if(i==n||w==0) return 0;
    ll ans=recur(w,i+1,v,n);
    if(v[i][0]<=w)
    ans=max(v[i][1]+recur(w-v[i][0],i+1,v,n),ans);
    return ans;
}
void solve()
{
   ll n; cin>>n;
   ll w; cin>>w;
   ll v[n][2];
   rep(i,n) cin>>v[i][0]>>v[i][1];
   ll dp[n+1][w+1]={0};
   rep(i,n+1) rep(j,w+1) dp[i][j]={0};
   repA(i,1,n)
   {
        repA(j,1,w)
        {
            dp[i][j]=dp[i-1][j];
            if(j-v[i-1][0]>=0)
                dp[i][j]=max(dp[i][j],dp[i-1][j-v[i-1][0]]+v[i-1][1]);
        }
   }
   ll ans=0;
   rep(i,n) ans=max(ans,dp[i+1][w]);
   cout<<ans;   
}
int main()
{
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    int t;t=1;
    //cin>>t;
    while(t--)
        {solve();}
    return 0;
}

Measured memory_bytes: 82484
#include <bits/stdc++.h>
//#include<fstream>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

/*ofstream fout("bcount.out");
ifstream fin("bcount.in");*/
const int maxn = 1e5+5;
vector<int>g[maxn];
vector<bool>vis(maxn,false);

void dfs(int src)
{
    vis[src] = true;
    for(auto i : g[src])
        if(!vis[i])
            dfs(i);
}
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    int n,m;
    cin>>n>>m;
    rep(i,0,m)
    {
        int a,b;
        cin>>a>>b;
        g[a].pb(b);
        g[b].pb(a);
    }
    int cnt = 0;
    for(int i = 1;i<=n;i++)
    {
        if(!vis[i])
        {
            dfs(i);
            cnt++;
        }
    }
    cout<<max(cnt-1,0)<<endl;
    return 0;
}
//1. Always consider edge cases like n = 1
//2. Do something or the other rather than just wasting time

Measured memory_bytes: 9528
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
int n;
char c;
vector<int> ga[220],nxt,cur;
int co[220];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>c;
			if(c=='1'){
				ga[i].push_back(j);
			}
		}
	} 
	int res=-1;
	for(int fst=1;fst<=n;fst++){
		memset(co,0,sizeof(co));
		bool ok=true;
		nxt.clear();
		nxt.push_back(fst);
		int remain=n-1;
		int curid=1;
		while(remain){
			cur.clear();
			for(int i=0;i<nxt.size();i++){
				co[nxt[i]]=curid;
				cur.push_back(nxt[i]);
			}
			nxt.clear();
			for(int i=0;i<cur.size();i++){
				for(int j=0;j<ga[cur[i]].size();j++){
					int cc=co[ga[cur[i]][j]];
					if(cc!=0&&cc==curid-1||cc==curid+1)
						continue;
					if(cc==0){
						nxt.push_back(ga[cur[i]][j]);
						remain--;
						co[ga[cur[i]][j]]=curid+1;
					}
					else
					{
						ok=false;
						break;
					}
				}
				if(ok==false)
					break;
			}
			if(ok==false)
				break;
			curid++;
		}
		if(ok==false)
			goto en;
		for(int i=1;i<=n;i++){
			for(int j=0;j<ga[i].size();j++){
				if(abs(co[ga[i][j]]-co[i])!=1){
					ok=false;
					break;
				}
			} 
			if(ok==false)
				break;
		} 
		en:
		if(!ok)
			curid=-1;
		res=max(res,curid);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

#define M 1000000007

int main( int argc, char *argv[] )
{
    long long n, k;
    long long t = 0;
    long long min, max;

    scanf( "%lld %lld", &n, &k );

    for( int i=k; i<=n+1; i++ ) {

        min = (long long)(i-1)*i/2;
        max = (n+n-i+1)*i/2;
//        for( int j=0; j<i; j++ ) {
//            min += j;
//            max += n-j;
//        }
//printf( "%lld %lld \n", min, max );
        t += (max - min + 1) % M;
        t = t % M;
    }

    printf( "%lld\n", t );
}


Measured memory_bytes: 1728
#include<iostream>
using namespace std;
int main(){
  int r,c,arr[105][105],i,j,k;
  cin >> r >>c;

  for(i=1;i<=r;i++)
  {
      k=0;
      for(j=1;j<=c;j++)
      {
          cin>>arr[i][j];
          k=k+arr[i][j];
          arr[i][c+1]=k;
      }
  }




for(i=1;i<=c+1;i++)
  {
      k=0;
      for(j=1;j<=r;j++)
      {
          k=k+arr[j][i];
          arr[r+1][i]=k;
      }
  }
for(i=1;i<=r+1;i++)
  {
      for(j=1;j<=c+1;j++)
      {
          if(j==c+1)
            cout<<arr[i][j];
          else
            cout<<arr[i][j]<<" ";
      }

      cout<<endl;
  }

  return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define tam 10000010
 
using namespace std;
 
typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <ll, ll> dl;
typedef pair <int, int> ii;
typedef vector <ii> vii;
typedef vector <set <int> > graph;
 
bool comp(int a, int b) {
	return a > b;
}
 
int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
 
	ll n;
	ll copia;
	cin >> n;
	copia = n;
	if (n == 1) {
		cout << "0\n";
		return 0;
	}
	vl primos;
	if ((n & 1) == 0) {
		primos.push_back(2);
	}
	while ((n & 1) == 0) {
		n >>= 1;
	}
	for (ll i = 3; i * i <= n; i += 2) {
		if (n % i == 0) {
			primos.push_back(i);
			while (n % i == 0) {
				n /= i;
			}
		}
	}
	if (n > 1) {
		primos.push_back(n);
	}
	n = copia;
	ll in;
	ll cont = 0;
	for (int i = 0; i < (int)primos.size(); i++) {
		in = primos[i];
		while (n % in == 0) {
			n /= in;
			in *= primos[i];
			cont++;
		}
	}
	cout << cont << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

int main(void){
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);

  if(a != b && b != c && c != a)
    puts("No");
  else{
    if(a == b && b == c && c == a)
      puts("No");
    else
      puts("Yes");
  }
  
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pll pair<LL,LL>
#define pii pair<int,int>
#define y second
#define x first
#define LL long long 
#define MEM(x) memset(x,0,sizeof(x))
using namespace std;
struct node{
    node *n[26];
    int cnt[26];
    node(){
        fill(cnt,cnt+26,0);
        for(int i = 0;i<26;i++){
            n[i]=NULL;
        }
    }
}*root;
int cnt[26];
void add(node *&n,const char *c){
    if(!n){
        n=new node();
    }
    if(*c==0)return ;
    add(n->n[*c-'a'],c+1);
    cnt[*c-'a']=1;
    for(int i = 0;i<26;i++){
        n->cnt[i]+=cnt[i];
    }
}
int query(const char *c){
    node *n=root;
    int last=c[strlen(c)-1]-'a';
    for(int i = 0;c[i+1]!=0;i++){
        n=n->n[c[i]-'a'];
        if(!n)return 0;
    }
    return n->cnt[last];
}
int main(){
    int n;
    scanf("%d",&n);
    string s[200005];
    LL ans=0;
    for(int i = 0;i<n;i++){
        char c[1000005];
        scanf("%s",c);
        reverse(c,c+strlen(c));
        s[i]=string(c);
    }
    root = new node();
    for(int i = 0;i<n;i++){
        ans+=query(s[i].c_str());
        fill(cnt,cnt+26,0);
        add(root,s[i].c_str());
   //  printf("%lld\n",ans);
    }
   //  printf("!%lld\n",ans);
    reverse(s,s+n);
    root = new node();
    for(int i = 0;i<n;i++){
        ans+=query(s[i].c_str());
        fill(cnt,cnt+26,0);

        add(root,s[i].c_str());
     //    printf("!%lld\n",ans);
    }
    printf("%lld\n",ans);
}
/*
100
5
5 4
4 2
4 2 3
5 4 2 3 1
*/

Measured memory_bytes: 658668
use io::*;

fn main() {
    let con = read_string();
    let mut sc = Scanner::new(&con);

    let t: usize = sc.next();

    for _ in 0..t {
        let a: i64 = sc.next();
        let b: i64 = sc.next();
        let c: i64 = sc.next();
        let d: i64 = sc.next();
        println!("{}", if solve(a, b, c, d) { "Yes" } else { "No" });
    }
}

fn solve(a: i64, b: i64, c: i64, d: i64) -> bool {
    if b > a {
        return false;
    }
    if d < b {
        return false;
    }
    if c >= b {
        return true;
    }

    // a-n*b <= c
    // n*b>=a-c
    // n >= (a-c)/b

    let n = (a - c + b - 1) / b;
    let a = a - n * b;

    if a < 0 {
        return false;
    }

    if d % b == 0 {
        return true;
    }

    // let m = (c + 1 - a + (d % b - 1)) / (d % b);
    // let a = a + m * (d % b);

    let g = gcd(b, d);

    let n = (c - a) / g;
    let a = a + n * g;
    a + g >= b
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

//-----

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll X;
    cin >> X;

    vector<bool> A(1001, false);
    A[1] = true;
    REP(i,2,1000) {
        ll a = i;
        REP(j,0,11) {
            a *= i;
            if(a <= 1000) A[a] = true;
            else break;
        }
    }
    for(ll i=X; i>=1; --i) {
        if(A[i]) {
            PR(i);
            break;
        }
    }

    return 0;
}

/*



*/

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
  int n,m;
  cin >>n >>m;
  VI a(m);
  ll sum=0;
  rep(i,m){
    cin >> a.at(i);
    sum+=a.at(i);
  }
  if(sum> n)cout << -1 << endl;
  else cout << n-sum << endl;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main()
{
    int n, p[21], i, cnt=0;
    cin >> n;
    for(i=0;i<n;i++){
        cin >>p[i];
    }
    for(i=1;i<n-1;i++){
        if((p[i-1]<p[i] && p[i]<p[i+1]) || (p[i+1]<p[i] && p[i]<p[i-1])){
            cnt++;
        }
    }
    cout << cnt <<endl;

    return 0;
}
    


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
odd_A = A[::2]
odd_sum = sum(odd_A)
even_A = A[1::2]
even_sum = sum(even_A)

y0 = odd_sum-even_sum
ans_list = []
ans_list.append(y0)
temp = y0
for i in range(N-1):

    y_i = 2*A[i] - temp
    ans_list.append(y_i)
    temp = y_i

print(*ans_list)

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

using namespace std;

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, w;
    cin >> n >> w;
    //weight, value
    vector<pair<int, int>> nums;
    int temp1, temp2;
    for(int x = 0; x < n; ++x)
    {
        cin >> temp1 >> temp2;
        nums.push_back({temp1, temp2});
    }
    sort(nums.begin(), nums.end(), greater<pair<int, int>>());
    vector<vector<long long>> dp (n, vector<long long>(w + 1, -1));
    dp[0][0] = 0;
    dp[0][nums[0].first] = nums[0].second;
    for(int i = 1; i < n; ++i)
    {
        dp[i][0] = 0;
        for(int j = 0; j < w + 1; ++j)
        {
            if(dp[i - 1][j] != -1 && j + nums[i].first <= w)
            {
                dp[i][j + nums[i].first] = max(nums[i].second + dp[i - 1][j], dp[i][j + nums[i].first]);
            }
            dp[i][j] = max(dp[i - 1][j], dp[i][j]);
        }
    }
    long long finMax = INT_MIN;
    for(int i = 0; i < w + 1; ++i)
    {
        finMax = max(finMax, dp[n - 1][i]);
    }
    cout << finMax;
    // for(vector<long long> i : dp)
    // {
    //     for(long long j : i)
    //     {
    //         cout << j << " ";
    //     }
    //     cout << "\n";
    // }
    return 0;
}

Measured memory_bytes: 79488
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	sort(all(in));
	cout<<in[n-1]-in[0]<<endl;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
int main()
{
	int n,i,a[4]={0,0,0,0},s=0;
	char a1;
	scanf("%d",&n);
	getchar();
	for(i=0;i<n;i++)
	{
		scanf("%c",&a1);
		getchar();
		if(a1=='P')
		{
			a[0]=1;
		}
		if(a1=='W')
		{
			a[1]=1;
		}
		if(a1=='G')
		{
			a[2]=1;
		}
		if(a1=='Y')
		{
			a[3]=1;
		} 
	}
	for(i=0;i<4;i++)
	{
		if(a[i]==1)
		{
			s++; 
		}
	}
	if(s==3)
	{
		printf("Three");
	}
	else if(s==4)
	{
		printf("Four");
	}
	return 0;
} 

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

int main() {

	long long  a, b, c;
	cin >> a >> b >> c;


	if ((c-a-b)*(c-a-b) > 4*a*b && c-a-b>0)
		cout << "Yes";

	else
		cout << "No";
}



Measured memory_bytes: 256
function main(arg) {
	arg = arg.trim().split(' ');
  	arg = arg.map(str => parseInt(str, 10));
  	var out = '-1';
  	if (arg[0] > 9 || arg[1] > 9) {
		console.log(out);    
    } else {
    	out = arg[0] * arg[1]
      	console.log(out);
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

#define int long long
#define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Printv(v)                                                              \
    {                                                                          \
        REP(x, v.size()) { cout << v[x] << (x == v.size() - 1 ? "\n" : " "); } \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = atan(1.0) * 4.0;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

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

ll dp[3030][3030];

VVL G;
VL in;
ll d[100000];

ll dfs(ll now) {
    if(d[now]) return d[now];
    ll &res = d[now];
    FOREACH(to, G[now]) res = max(res, dfs(to) + 1);
    return res;
}

signed main() {
    LCIN(N, M);
    G.resize(N);
    in.resize(N);
    REP(i, M) {
        LCIN(x, y);
        x--, y--;
        in[y]++;
        G[x].emplace_back(y);
    }
    ll ans = 0;
    REP(i, N) {
        if(in[i] == 0) {
            ans = max(ans, dfs(i));
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 10368