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

namespace AtTest.Nomura_2020
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] hmk = ReadInts();
            int h1 = hmk[0];
            int m1 = hmk[1];
            int h2 = hmk[2];
            int m2 = hmk[3];
            int k = hmk[4];

            int a = h1 * 60 + m1;
            int b = h2 * 60 + m2;
            WriteLine(b - a - k);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27536
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int m1,d1,m2,d2;
  cin >> m1 >> d1 >> m2 >> d2;
  cout << (m1!=m2) << endl;

  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=998244353;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)

string s;
vector<long long> N;
int dp[110][2][4];

int main(void){
    cin>>s;
    int k;
    cin>>k;
    int l=s.size();
    rep(i,l) N.push_back(s[i]-'0');
    dp[0][0][0]=1;
    dp[0][0][1]=0;
    dp[0][0][2]=0;
    dp[0][0][3]=0;
    dp[0][1][0]=0;
    dp[0][1][1]=0;
    dp[0][1][2]=0;
    dp[0][1][3]=0;
    rep(i,l){
        rep(smaller,2){
            rep(j,4){
                for(int x=0;x<=(smaller ? 9 : N[i]);x++){
                    if(x==0){
                        dp[i+1][smaller || x<N[i]][j]+=dp[i][smaller][j];
                    }
                    else{
                        if(j!=k){
                            dp[i+1][smaller || x<N[i]][j+1]+=dp[i][smaller][j];
                        }
                    }
                }
            }
        }
    }
    //rep(i,l) cout<<N[i]<<endl;
    //rep(i,l+1) rep(smaller,2) rep(j,4) cout<<i<<" "<<smaller<<" "<<j<<" "<<dp[i][smaller][j]<<endl;
    cout<<dp[l][0][k]+dp[l][1][k]<<endl;
    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>
int Merge(int *A, int left,int mid,int right);
int Sort(int *A, int left, int right);
int main(int argc, char** argv) {
 
    int size;
    scanf("%d",&size);
    int right = size;
    int left = 0;
    int array[size];
    for(int i= 0; i<size; i++)
    {
        scanf("%d", &array[i]);
    }

    int count;
    count = Sort(array, left, right);
    for(int i=0; i<size;i++)
    {
        if(i!=size-1)
        printf("%d ",array[i]);
        if(i==size-1)
        printf("%d\n",array[i]);
    }
    printf("%d\n", count);
    
    return (EXIT_SUCCESS);
}
int Merge(int *A, int left,int mid,int right)
{
    int count = 0;
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1], R[n2];
    for(int i = 0; i<n1;i++)
    { 
        L[i] = A[left + i];
    }
    for( int i= 0 ;i< n2;i++)
    {
        R[i] = A[mid + i];
    }
    int i = 0;
    int j = 0;
    for(int k=left; k<right;k++)
    {
        if(j>=n2||i<n1 && L[i] <= R[j])
        {
            A[k] = L[i];
            i = i + 1;
        }
        else
        {
            A[k] = R[j];
            j = j + 1;
        }
        count++;
    }
    return count;
}
int Sort(int *A, int left, int right)
{   
    int count = 0;
    int mid=(left + right)/2;
    if(left+1 < right)
    {
        count = count + Sort(A, left, mid);
        count = count + Sort(A, mid, right);
        count = count + Merge(A, left, mid, right);
 
    }
    return count;
}



Measured memory_bytes: 5612
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 10e9;
const int MAX_V = 201;
void AdditionandMultiplication() {
	int n, k;
	cin >> n >> k;
	int res = 1;
	for (size_t i = 0; i < n; i++)
	{
		if (res * 2 > res + k) {
			res += k;
		}
		else {
			res *= 2;
		}
	}
	cout << res << endl;
}

int main() {
	AdditionandMultiplication();
	return 0;
}



Measured memory_bytes: 256
def flipping_signs(n, a)
  sum = 0
  odd = false
  lowest = a.first.abs
  a.each do |n|
    sum += n.abs
    lowest = n.abs if lowest > n.abs
    odd = !odd if n < 0
  end

  sum - (odd ? lowest * 2 : 0)
end

n = gets.to_i
a = gets.split.map(&:to_i)
puts flipping_signs(n, a)

Measured memory_bytes: 8580
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll count(ll n)
{
    ll s = 1;
    for(ll i = 2 ; i * i <= n ; i++)
    {
        if(n % i == 0)
        {
            ll a = 0 ;
            while(n % i == 0){
                n /= i;
                a++;
            }
            s = s * (a+1) ;
        }
    }
    if(n > 1) s = s * 2;
    return s;
}
int main()
{
	int N;
	cin>>N;
	ll ans = 0;
	for(int i=1;i<N;i++)
    {
		ans += (count(i));
	}
  
	cout<<ans;
  
	return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int n, m;
    cin >> n >> m;
    VI cnt(n, 1);
    VI r(n, 0);
    r[0] = 1;
    for (i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        cnt[x]--;
        cnt[y]++;
        if (r[x] == 1) r[y] = 1;
        if (cnt[x] == 0) r[x] = 0;
    }
    int ans = 0;
    for (i = 0; i < n; i++) ans += r[i];
    cout << ans << endl;
}

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

using namespace std;

typedef long long LL;

const int N = 1010;

int n, m;
char g[N][N];

int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++)
        scanf("%s", g[i] + 1);

    for(int i = 0; i <= m + 1; i++) g[0][i] = g[n + 1][i] = '#';
    for(int i = 0; i <= n + 1; i++) g[i][0] = g[i][m + 1] = '#';

    for(int i = 0; i <= n + 1; i++)
        puts(g[i]);

    return 0;
}


Measured memory_bytes: 384
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    int max=0;
    for(int i=0;i<6;i++){
      max+=s.charAt(i)-'0';
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 21844
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;



int main(){
	long long N;
	cin >> N;
	vector<long long> L(N);
	for (int i = 0; i < N; i++) {
		cin >> L.at(i);
	}
	sort(L.begin(), L.end());

	if (L.size() < 3) {
		cout << 0 << endl;
		return 0;
	}

	int cnt = 0;
	for (int i = 0; i < N - 2; i++) {
		for (int j = i + 1; j < N - 1; j++) {
			for (int k = j + 1; k < N; k++) {
				if (L.at(i) == L.at(j) || L.at(j) == L.at(k) || L.at(k) == L.at(i)) continue;
				if ((L.at(i) + L.at(j) > L.at(k)) && (L.at(j) + L.at(k) > L.at(i)) && (L.at(k) + L.at(i) > L.at(j))) cnt++;
			}
		}
	}
	cout << cnt << endl;
}



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

int main(){
    using namespace std;
    constexpr unsigned long C = 26;
    unsigned long D;
    cin >> D;
    vector<unsigned long> c(C);
    for(auto&& i : c)cin >> i;
    vector v(D, vector<unsigned long>(C));
    for(auto&& i : v)for(auto&& j : i)cin >> j;

    vector last(C, vector<unsigned long>{0});
    vector<unsigned long> ans(D);

    for(unsigned long i{0}; i < D; ++i){
        unsigned long mx{0}, mxi{0};
        for(unsigned long j{0}; j < C; ++j){
            unsigned long tmp{v[i][j] + c[j] * (i + 1 - last[j].back())};
            if(tmp > mx){
                mx = tmp;
                mxi = j;
            }
        }
        ans[i] = mxi;
        last[mxi].push_back(i + 1);
    }
    for(auto&& i : last)i.push_back(D + 1);

    mt19937_64 mt{random_device{}()};
    uniform_int_distribution<unsigned long> uid(1, D);

    auto start = chrono::system_clock::now();

    for(unsigned long iter{0}; iter < 100000; ++iter){
        unsigned long d{uid(mt)};
        auto f = ans[d - 1];
        unsigned long tmp{c[f] * (*upper_bound(begin(last[f]), end(last[f]), d) - d) * (d - *prev(lower_bound(begin(last[f]), end(last[f]), d))) + v[d - 1][f]};
        unsigned long mx{tmp}, mxi{0};
        for(unsigned long i{0}; i < C; ++i){
            unsigned long temp{c[i] * (*upper_bound(begin(last[i]), end(last[i]), d) - d) * (d - *prev(lower_bound(begin(last[i]), end(last[i]), d))) + v[d - 1][i]};
            if(temp > mx){
                mx = temp;
                mxi = i;
            }
        }
        if(mx > tmp){
            last[f].erase(lower_bound(begin(last[f]), end(last[f]), d));
            last[mxi].insert(upper_bound(begin(last[mxi]), end(last[mxi]), d), d);
            ans[d - 1] = mxi;
        }
        if(!(iter & 65535))if(chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - start).count() > 1600000)break;
    }

    for(const auto& i : ans)cout << i + 1 << endl;

    return 0;
}

Measured memory_bytes: 3740
#include <stdio.h>
int main(){
  int a,b,c,result=0;
  
  scanf("%d %d %d",&a,&b,&c);
  
  if(b>c){
    result=c*2;
    b=b-c;
    result+=b;
  } else {
    result=b*2;
    c=c-b;
    if(a>c){
      result+=c;
    } else {
      result+=a;
      c=c-a;
      if(c!=0){
        result++;
      }
    }
  }
  
  printf("%d",result);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <queue>
#include <sstream>
using namespace std;

const int MAX_V = 108;
const int H = 106;
const int D = 107;

int m, n, k, d, calorie[6];

struct Edge { int to, cost, cakeFlag; };
vector<Edge> G[MAX_V];

int dist[64][108];

int toInt(string s) {
	stringstream ss(s);
	int ret = 0;
	ss >> ret;
	return ret;
}

int makeKey(string s) {
	if (s[0] == 'C') return toInt(s.substr(1)) - 1;
	if (s[0] == 'L') return toInt(s.substr(1)) + 5;
	if (s == "H") return H;
	return D;
}

void addEdge(string a, string b, int cost) {
	int ak = makeKey(a);
	int bk = makeKey(b);
	if (b[0] == 'C') {
		G[ak].push_back((Edge){bk, cost - calorie[bk], 1 << bk});
	} else {
		G[ak].push_back((Edge){bk, cost, 0});
	}
	if (a[0] == 'C') {
		G[bk].push_back((Edge){ak, cost - calorie[ak], 1 << ak});
	} else {
		G[bk].push_back((Edge){ak, cost, 0});
	}
}

int shortestPath(int from, int to) {
	for (int i=0; i<64; ++i) {
		for (int j=0; j<108; ++j) {
			dist[i][j] = INT_MAX;
		}
	}
	dist[0][from] = 0;
	queue<pair<int,int> > q;
	q.push(make_pair(from, 0));
	while ( ! q.empty()) {
		int now = q.front().first;
		int flag = q.front().second;
		q.pop();
		for (int i=0; i<(int)G[now].size(); ++i) {
			Edge &e = G[now][i];
			if (flag & e.cakeFlag) continue;
			if (dist[flag][now] + e.cost < dist[flag | e.cakeFlag][e.to]) {
				dist[flag | e.cakeFlag][e.to] = dist[flag][now] + e.cost;
				q.push(make_pair(e.to, flag | e.cakeFlag));
			}
		}
	}
	int ret = INT_MAX;
	for (int i=0; i<64; ++i) {
		ret = min(ret, dist[i][to]);
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	while (cin >> m >> n >> k >> d, m) {
		fill(G, G+MAX_V, vector<Edge>());
		for (int i=0; i<m; ++i) {
			cin >> calorie[i];
		}
		string a, b;
		int cost;
		for (int i=0; i<d; ++i) {
			cin >> a >> b >> cost;
			addEdge(a, b, cost * k);
		}
		cout << shortestPath(H, D) << endl;
	}
	return 0;
}

Measured memory_bytes: 1348
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void){
	int N=0,team[101]={0},a=0,b=0,c=0,d=0,cnt=1,e=0;
	cin>>N;
	e=(N*N-N)/2;
	for(int i=1;i<=e;i++)
	{
		cin>>a>>b>>c>>d;
		if(c>d){team[a]=team[a]+3;}
		else if(c<d){team[b]=team[b]+3;}
		else{team[a]++;team[b]++;}
	}
	for(int i=1;i<=N;i++){
		for(int j=1;j<=N;j++){
			if(team[i]<team[j])
			{
				cnt++;
			}
		}
		cout<<cnt<<endl;
		cnt=1;
	}
	return 0;
}


Measured memory_bytes: 3092
object Main extends App { 
	val sc = new java.util.Scanner (System.in)
	val matrix:List[List[Int]] = List(List.fill(3)(sc.nextInt),List.fill(3)(sc.nextInt),List.fill(3)(sc.nextInt))
	val n = sc.nextInt
	val b = for ( i <- 1 to n) yield (sc.nextInt)
	val c = matrix.map(x => x.map( y => if( b.indexOf(y) == -1) y else -1 ) )

	if (c(0)(0) == -1 & c(0)(1) == -1 & c(0)(2) == -1){
		println("Yes")
	}else if (c(0)(0) == -1 & c(1)(1) == -1 & c(2)(2) == -1){
		println("Yes")
	}else if (c(0)(0) == -1 & c(1)(0) == -1 & c(2)(0) == -1){
		println("Yes")
	}else if (c(0)(2) == -1 & c(1)(1) == -1 & c(2)(0) == -1){
		println("Yes")
	}else if (c(2)(0) == -1 & c(2)(1) == -1 & c(2)(2) == -1){
		println("Yes")
	}else if (c(0)(2) == -1 & c(1)(2) == -1 & c(2)(2) == -1){
		println("Yes")
	}else if (c(0)(1) == -1 & c(1)(1) == -1 & c(2)(1) == -1){
		println("Yes")
	}else if (c(1)(1) == -1 & c(1)(2) == -1 & c(1)(0) == -1){
		println("Yes")
	}else{
		println("No")
	}
}



Measured memory_bytes: 27340
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=1<<14|2,mod=998244353,G=3;
ll ksm(ll a,int b){
	int ans=1;
	for(;b;b>>=1){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}
struct ffter{
	int rev[N],n,L;
	int wn[N],WN[N];
	void zheng(poly &a){
		//for(auto &i:a)i=(i+mod)%mod;
	}
	void dft(poly &a){
		int n=a.size();
		for(int i=0;i<n;i++)if(rev[i]<i)swap(a[rev[i]],a[i]);
		zheng(a);
		for(int d=1,len=L-1;d<n;d<<=1,len--){
			for(int i=0;i<d;i++)WN[i]=wn[i<<len];
			for(int i=0;i<n;i+=d<<1){
				for(int j=0;j<d;j++){
					int t=(ll)WN[j]*a[i+j+d]%mod;
					a[i+j+d]=a[i+j]-t<0?a[i+j]-t+mod:a[i+j]-t;
					a[i+j]=a[i+j]+t>=mod?a[i+j]+t-mod:a[i+j]+t;
				}
			}
		}
	}
	void idft(poly &a){
		dft(a);
		reverse(a.begin()+1,a.end());
		int x=ksm(a.size(),mod-2);
		for(auto &i:a)i=(ll)i*x%mod;
	}
	void init(int N){
		n=1; L=0; while(n<N)n<<=1,L++;
		int w=ksm(G,(mod-1)/n);
		for(int i=0;i<n;i++){
			wn[i]=i?(ll)wn[i-1]*w%mod:1; rev[i]=(rev[i>>1]>>1)|((i&1)<<(L-1));
		}
	}
}T;

void FFT(poly &a,poly &b){
	int sz=a.size()+b.size()-1;
	T.init(sz);
	a.resize(T.n); b.resize(T.n);
	T.dft(a); T.dft(b);
	for(int i=0;i<T.n;i++)a[i]=(ll)a[i]*b[i]%mod;
	T.idft(a);
	a.resize(sz);
}
const int M=8005;
ll fac[M],ni[M],dp[M];
int main(){
	int n=read(),m=read();
	For(i,fac[0]=1,n+2)fac[i]=fac[i-1]*i%mod;
	ni[n+2]=ksm(fac[n+2],mod-2);
	Rep(i,n+2,1)ni[i-1]=ni[i]*i%mod;
	dp[0]=1;
	For(i,1,m){
		poly zs(n+1),jb(n+1);
		For(i,1,n)zs[i]=ni[i+2];
		For(i,0,n)jb[i]=dp[i]*ni[i]%mod;
		FFT(jb,zs);
		For(i,0,n)dp[i]=(dp[i]*(i*(i+1)/2+1)+jb[i]*fac[i+2])%mod;
	}
	ll ans=0;
	For(i,0,n)ans=(ans+fac[n]*ni[i]%mod*ni[n-i]%mod*dp[i])%mod;
	cout<<ans<<endl;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=998244353;
const ll mod=1e9+7;
signed main(){
    ll n,m;cin>>n>>m;
    vector<ll>a(n+3);
    vector<ll>dp(n+3);
    rep(i,m){
        ll b;cin>>b;
        a[b]=1;
    }
    dp[0]=1;
    rep(i,n){
        if(a[i])continue;
        dp[i+1]=(dp[i+1]+dp[i])%mod;
        dp[i+2]=(dp[i+2]+dp[i])%mod;
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  string S; cin >> S;
  if(S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N (500009)
using namespace std;

struct Node{int id,val;}p[N];
struct Sgt{int ls,rs;}Segt[N<<2];
struct Edge{int to,next;}edge[N<<1];
int n,x,y,sgt_num,a[N],pos[N],Root;
int DFN[N],Low[N],Vis[N],Color[N];
int Stack[N],top,col_num,dfs_num;
int head[N],num_edge;
bool cmp(Node a,Node b) {return a.val<b.val;}

void add(int u,int v)
{
	edge[++num_edge].to=v;
	edge[num_edge].next=head[u];
	head[u]=num_edge;
}

int Build(int l,int r)
{
	if (l==r) return pos[((p[l].id-1)^1)+1];
	int now=++sgt_num;
	int mid=(l+r)>>1;
	Segt[now].ls=Build(l,mid);
	Segt[now].rs=Build(mid+1,r);
	add(now,Segt[now].ls); add(now,Segt[now].rs);
	return now;
}

void Add_Edge(int now,int l,int r,int l1,int r1,int p)
{
	if (l>r1 || r<l1 || l>r) return;
	if (l1<=l && r<=r1) {add(p,now); return;}
	int mid=(l+r)>>1;
	Add_Edge(Segt[now].ls,l,mid,l1,r1,p);
	Add_Edge(Segt[now].rs,mid+1,r,l1,r1,p);
}

void Clear()
{
	memset(head,0,sizeof(head));
	memset(DFN,0,sizeof(DFN));
	memset(Low,0,sizeof(Low));
	memset(Vis,0,sizeof(Vis));
	col_num=dfs_num=num_edge=top=0;
	sgt_num=2*n;
}

void Tarjan(int x)
{
	DFN[x]=Low[x]=++dfs_num;
	Vis[x]=1; Stack[++top]=x;
	for (int i=head[x]; i; i=edge[i].next)
		if (!DFN[edge[i].to])
		{
			Tarjan(edge[i].to);
			Low[x]=min(Low[x],Low[edge[i].to]);
		}
		else if (Vis[edge[i].to])
			Low[x]=min(Low[x],DFN[edge[i].to]);
	if (DFN[x]==Low[x])
	{
		Vis[x]=0; Color[x]=++col_num;
		while (Stack[top]!=x)
		{
			Color[Stack[top]]=col_num;
			Vis[Stack[top--]]=0;
		}
		--top;
	}
}

bool check(int lim)
{
	Clear();
	Root=Build(1,2*n);
	for (int i=1; i<=2*n; ++i)
	{
		int l=upper_bound(a+1,a+2*n+1,p[i].val-lim)-a;
		int r=lower_bound(a+1,a+2*n+1,p[i].val+lim)-a-1;
		Add_Edge(Root,1,2*n,max(l,1),i-1,i);
		Add_Edge(Root,1,2*n,i+1,min(r,2*n),i);
	}
	for (int i=1; i<=2*n; ++i)
		if (!DFN[i]) Tarjan(i);
	for (int i=1; i<=2*n; i+=2)
		if (Color[pos[i]]==Color[pos[i+1]]) return false;
	return true;
}

int main()
{
	cin>>n;
	for (int i=1; i<=n; ++i)
	{
		cin>>x>>y;
		p[i*2-1]=(Node){i*2-1,x};
		p[i*2]=(Node){i*2,y};
	}
	sort(p+1,p+2*n+1,cmp);
	for (int i=1; i<=2*n; ++i)
		pos[p[i].id]=i, a[i]=p[i].val;
	int l=0,r=1000000000,ans=-1;
	while (l<=r)
	{
		int mid=(l+r)>>1;
		if (check(mid)) ans=mid, l=mid+1;
		else r=mid-1;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 27776
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
using ll = long long;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repp(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)


int main() {
  ll a, b, c, d;  cin >> a >> b >> c >> d;
  ll e = a*c, f = a*d, g = b*c, h = b*d;

  cout << max({e, f, g, h}) << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int N; cin >> N;
    int a[3 * N];
    rep(i, 3 * N) {
        cin >> a[i];
    }
    sort(a, a + 3 * N, greater<int>());
    ll ans = 0;
    int count = 0;
    for(int i = 1; count != N; i += 2) {
        ans += a[i];
        ++count;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
   int a,b;
   cin >> a >> b;
   if((a+b)%2==0)
   cout << (a+b)/2 << endl;
   else 
   cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
using namespace std;

int main(){
	char c; cin>>c;
	switch(c) {
	case 'a':
	case 'e':
	case 'i':
	case 'o':
	case 'u':
		cout<<"vowel"<<endl;
		break;
	default:
		cout<<"consonant"<<endl;
	}


	return 0;
}



Measured memory_bytes: 256
N = int(input())
A = [0]*(N-1)
B = [0]*(N-1)
C = [0]*(N-1)
for i in range(N-1):
  A[i],B[i],C[i] = map(int, input().split())
  
#A秒で着く、B秒後に最初、c秒感覚で運行
def arrive_time(i,s): #i駅からN駅, s秒後から
  if i == N-1:
    return s
  if s>B[i]:
    #print(i,s,B[i],C[i])
    start = (s-B[i]+C[i]-1)//C[i]*C[i]+B[i]
  else:
    start = B[i]
  return arrive_time(i+1,start+A[i])
ans = [0]*(N)
for i in range(N):
  ans[i] = arrive_time(i,0)

print(*ans,sep='\n')

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

int main(){
	while(1){
		int N, M, n[1000], p = 0, ans = -1;
		cin >> N >> M;
		if(N == 0 && M == 0) break;
		for(int i = 0;i < N;i++){
			cin >> n[i];
		}
		for(int i = 0;i < M;i++){
			int m;
			cin >> m;
			p += m;
			if(p < N - 1) p += n[p];
			if(p >= N - 1 && ans == -1) ans = i + 1;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import numpy
 
N = int(input())
A = list(map(int, input().split()))

ans = 0
res = [0] * N
res[0] = A[0]
for i in range(len(A)-1):
    res[i+1] = res[i] + A[i+1]

sum_A = sum(A)

for i in range(N-1):
  ans += A[i]*(sum_A-res[i])
  
mod = 10**9 + 7
print(ans%mod)

Measured memory_bytes: 49924
#include<iostream>
#include<vector>

using namespace std;

class DisjointSet{
	public:
		vector<int> rank, p;

		DisjointSet(){}
		DisjointSet(int size){
			rank.resize(size,0);
			p.resize(size,0);
			for(int i=0;i < size;i++) makeSet(i);
		}

		void makeSet(int x){
			p[x] = x;
			rank[x] = 0;
		}

		bool same(int x, int y){
			return findSet(x) == findSet(y);
		}
		void unite(int x, int y){
			link(findSet(x), findSet(y));
		}

		void link(int x, int y){
			if(rank[x] > rank[y]){
				p[y] = x;
			}else{
				p[x] = y;
				if(rank[x] == rank[y]){
					rank[y]++;
				}
			}
		}

		int findSet(int x){
			if(x != p[x]){
				p[x] = findSet(p[x]);
			}
			return p[x];
		}
};

int main(){
	int n, a, b, q;
	int t;

	cin >> n >> q;
	DisjointSet ds = DisjointSet(n);

	for(int i=0;i<q;i++){
		cin >> t >> a >> b;
		if(t == 0) ds.unite(a,b);
		else if(t==1){
			if(ds.same(a,b)) cout << 1 << endl;
			else cout << 0 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3184
#include <iostream>
#include <algorithm>

using namespace std;

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

	long long X = min(A, K);
	A -= X;
	K -= X;

	long long Y = min(B, K);
	B -= Y;
	K -= Y;

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


Measured memory_bytes: 256
import java.util.*;
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=b;
		if(b<0){
			c*=-1;
		}
		
		c+=a;//和ここにいれる
		a*=b;//積ここに入れる
		if(c>a){a=c;}
		
		System.out.println(a);
	}
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main(void){
    int n;
    long long a[10001] = {0};
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    long long min = 1000000, max = -1000000, sum = 0;
    for(int i = 0; i < n; i++){
        if(a[i]<min){
            min = a[i];
        }
        if(max<a[i]){
            max = a[i];
        }
        sum = sum + a[i];
    }
    cout << min << " " << max << " " << sum;
    cout << endl;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a1, a2,a3;
    cin >> a1 >> a2 >> a3;
    if(a1+a2+a3>=22){
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 5001;


int main(){
    int n;
    scanf("%d",&n);
    int an = 0; 
    for(int i = 0; i<n; ++i){
         for(int j = 0; j<n; ++j){
            for(int k = 0; k<n; ++k){
                 ++an;
            }
         }
    }
    cout << an;
}

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

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
   	int n = sc.nextInt();
    String stack;
    char cstack;
    List words = new ArrayList();
    boolean con = true;
    
    stack = sc.next();
    cstack = stack.charAt(stack.length()-1);
   	words.add(stack);
    
    for(int i = 1;i < n && con;i++){
      	stack = sc.next();
    	if(words.contains(stack) || stack.charAt(0) != cstack) con = false;
      	else{
        	cstack = stack.charAt(stack.length()-1);
   			words.add(stack);
        }
    }
    
    if(con) System.out.println("Yes");
    else System.out.println("No");

  }
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main(){
    gearup;
    int h,w; cin >> h >> w;
    vvc c(h,vc(w));
    vvl dist(h,vl(w,-1));
    queue<pair<int,int>> que;
    rep(i,h)rep(j,w){
        cin>>c[i][j];
        if(c[i][j] == '#'){
            dist[i][j] = 0;
            que.push(make_pair(i,j));
        }
    }

    while(!que.empty()){
        int x = que.front().first;
        int y = que.front().second;
        que.pop();
        for(int i=0;i<8;i+=2){
            int ex = x+dx[i];
            int ey = y+dy[i];
            if(ex < 0 || ex >= h || ey < 0 || ey >= w)continue;
            if(c[ex][ey] == '.'){
                c[ex][ey] = '#';
                dist[ex][ey] = dist[x][y]+1;
                que.push(make_pair(ex,ey));
            }
        }
    }
    ll res = 0;
    rep(i,h)rep(j,w) res = max(dist[i][j],res);
    out(res);
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  string s;cin>>s;
  ll a=0,b=0,c=0,d=0;
  rep(i,0,s.size()){
    if(s[i]=='N')a++;
    else if(s[i]=='W')b++;
    else if(s[i]=='S')c++;
    else d++;
  }
  if(a&&!c)judge=false;
  if(!a&&c)judge=false;
  if(b&&!d)judge=false;
  if(!b&&d)judge=false;
  ans1(judge);
  return 0;
}

Measured memory_bytes: 256
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int n,m;
int cost[1005];
int bitval[1005];
int cache[1005][5000];
int dp(int pos,int bit)
{
    if(pos==m)
    {
        if(bit+1==(1<<n))
            return 0;
        return 1e18;
    }
    int &ans=cache[pos][bit];
    if(ans!=-1)
        return ans;
    ans=min(cost[pos]+dp(pos+1,bit|bitval[pos]),dp(pos+1,bit));
    return ans;
}
int32_t main() 
{
    IOS;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        cost[i]=a;
        int val=0;
        for(int j=0;j<b;j++)
        {
            int c;
            cin>>c;
            c--;
            val|=(1ll<<c);
        }
        bitval[i]=val;
    }
    memset(cache,-1,sizeof(cache));
    print(dp(0,0)>1e17?-1:dp(0,0));
}

Measured memory_bytes: 42976
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define Set set<int>
#define int long long
#define P pair<int,int>
const int maxn = 8e4+5;
const int INF = 1e17 +6;
using namespace std;
int n,m,a[maxn],b[maxn],c[maxn],ans;
int sum[maxn];
int32_t main()
{
    IOS;
    cin>>n;
    fu(i,1,n)
    {
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
        ans+=a[i];
    }
    int mm=INF;
    fu(i,1,n)
    {
        mm=min(mm,abs(ans-sum[i]*2));
    }
    cout<<mm;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

typedef long long int llint;

int main(void){

  int k;
  std::string s;
  std::cin >> k >> s;
  if(k >= s.size()){
    std::cout << s << std::endl;
    return 0;
  }

  for(int i=0; i<k; i++){
    std::cout << s[i];
  }
  std::cout << "..." << std::endl;
  
  return 0;
}


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

int main() {
  int N,M;
  cin>>N>>M;
  int point=0,penalty=0;
  vector<int> wrong(N,0);
  vector<bool> ac(N,false);
  rep(i,M){
    int x;
    string y;
    cin>>x>>y;
    x--;
    if(y=="WA"){
      if(ac.at(x)==false){
        wrong.at(x)++;
      }
    }
    else{
      if(ac.at(x)==false){
        point++;
        penalty+=wrong.at(x);
      }
      ac.at(x)=true;
    }
  }
  cout<<point<<" "<<penalty<<endl;
}




Measured memory_bytes: 640
import java.util.*;

class Main
{
    public static  void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int x = sc.nextInt();
        int a = sc.nextInt();
        
        if (x < a) {
            System.out.println(0);
        } else {
            System.out.println(10);
        }
        
    }
}

Measured memory_bytes: 24148
def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    XY = [[int(i) for i in input().split()] for j in range(N)]
    XY.sort()
    from collections import Counter
    c = Counter()
    for i in range(N-1):
        for j in range(i+1, N):
            p = XY[j][0] - XY[i][0]
            q = XY[j][1] - XY[i][1]
            c[(p, q)] += 1
    ans = N - (c.most_common()[0][1] if c else 0)
    print(ans)


if __name__ == '__main__':
    main()


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

void dfs(vector<vector<pair<int,int>>> &G, vector<pair<int,int>> &P, int u, vector<int> &ans, int &K){
  int c=1;
  for(int i=0;i<G[u].size();i++){
    int v = G[u][i].first;
    if(P[v].first!=-2) continue;
    P[v].first = u;
    if(P[u].second==c) ++c;
    P[v].second = c;
    int j = G[u][i].second;
    ans[j] = c;
    K = max(K,c);
    ++c;
    dfs(G,P,v,ans,K);
  }
  return;
}

int main() {
  int N,K=0;
  cin >> N;
  vector<vector<pair<int,int>>> G(N,vector<pair<int,int>>(0));
  for(int i=0;i<N-1;i++){
    int a,b;
    cin >> a >> b;
    --a;
    --b;
    G[a].push_back(make_pair(b,i));
    G[b].push_back(make_pair(a,i));
  }
  
  vector<int> ans(N-1);
  vector<pair<int,int>> P(N,make_pair(-2,-1));
  P[0].first = -1;
  dfs(G,P,0,ans,K);
  
  cout << K << endl;
  for(int i=0;i<N-1;i++) cout << ans[i] << endl;
  return 0;
}


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

int n,h,ret=0,mx=0;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>h;
		if(i==0){
			mx=h;
			ret++;
		}
		else if(h>=mx){
			mx=h;
			ret++;
		}
	}
	cout<<ret;
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, i321) => {
        read_value!($next, i32) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

//
// # Examples
//
// # integers
// input! { n: i32, m: i32, ... }
//
// # array
// input! { n: i32, v: [i32; n], }
//
// # matrix
// input! { n: i32, m: i32, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: i32,
//     w: i32,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: i32, b: i32, c: i32,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}
fn main() {
    input! { n: i32, a: i32 }
    println!("{}", n*n - a);
}

Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
 
using namespace std;
 
typedef long long ll;
 
#define limit int(1e5 + 99)
ll wei[ limit ], val[ limit ];
ll dp[ limit ];
 
int main() {
	ll n, w;
	scanf("%lld%lld", &n, &w);
 
	for(ll i = 0; i < n; i++) {
		scanf("%lld%lld", &wei[ i ], &val[ i ]);
	}
 
	for(int i = 0; i < n; i++) {
		for(int j = w; j >= wei[ i ]; j--) {
			//printf("%i ? %i\n", dp[ j ], dp[ j - wei[ i ] ] + val[ i ]);
			dp[ j ] = max(dp[ j ], dp[ j - wei[ i ] ] + val[ i ]);
		}
	}

	/*
	for(int i = 0; i < w + 1; i++) {
		printf("%lld ", dp[ i ]);
	}*/
 
	printf("%lld ", dp[ w ]);
}

Measured memory_bytes: 1024
n,x = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
b,ans = [0],float("inf")
for i in range(n): b.append(b[-1]+a[i])
def f(k):
	m = 5*(b[n]-b[max(0,n-2*k)])
	for i in range((n-k)//k): m+=(2*i+7)*(b[n-(2+i)*k]-b[max(0,n-(3+i)*k)])
	return m+k*x
for i in range(1,(n+1)//2+1): ans = min(f(i),ans)
print(ans+n*x)

Measured memory_bytes: 25836
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int cnt[10][10];
int n;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		string s=to_string(i);
		cnt[s[0]-'0'][s[s.size()-1]-'0']++;
	}
	ll ans=0;
	for(int i=1;i<=n;i++){
		string s=to_string(i);
		ans+=(cnt[s[s.size()-1]-'0'][s[0]-'0']);
	}
	cout<<ans<<endl;
}

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

using namespace std;

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

    double ans = 0.0000000000;
    int n;
    cin >> n;
    while (n--) {
        double x;
        string c;
        cin >> x >> c;
        if (c == "BTC")
            x *= 380000.0;
        ans += x;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 2100

int main() {
  int n; cin >> n;
  vector<vector<int>> G(n, vector<int>(n));
  rep(i, n)rep(j, n) cin >> G.at(i).at(j);

  vector<int> color(n); vector<int> mindis(n);
  rep(i, n) mindis.at(i) = INF;
  vector<int> par(n);
  int ans = 0;
  mindis.at(0) = 0;
  color.at(0) = GRAY;
  par.at(0) = -1;

  while (true) {
    int m = INF;
    int now = 0;
    rep(i, n) {
      if (color.at(i) == GRAY && mindis.at(i) < m) {
        m = mindis.at(i);
        now = i;
      }
    }

    if (m == INF) break;

    color.at(now) = BLACK;
    if (par.at(now) != -1) {
      ans += G.at(par.at(now)).at(now);
    }

    rep(i, n) {
      if (G.at(now).at(i) < mindis.at(i) && G.at(now).at(i) != -1 && color.at(i) != BLACK) {
        mindis.at(i) = G.at(now).at(i);
        color.at(i) = GRAY;
        par.at(i) = now;
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3192
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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() 
{
  ll N,K; cin>>N>>K;
  vector<ll> A(N);
  rep(i,N) cin>>A.at(i);
  rep(i,N-K){
    if(A.at(i)<A.at(i+K)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }  
  return 0;
}


Measured memory_bytes: 4824
class Combination:

    def __init__(self, n, MOD):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % MOD)
        self.inv_fact = [pow(self.fact[i] ,MOD - 2 ,MOD) for i in range(n + 1)]
        self.MOD = MOD

    def factorial(self, k):
        '''k!を求める'''
        return self.fact[k]

    def inverse_factorial(self, k):
        '''k!の逆元を求める'''
        return self.inv_fact[k]

    def combination(self, k, r):
        '''kCrを求める'''
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD
      
h, w, k = map(int, input().split())
MOD = 10**9 + 7
comb = Combination(h*w, MOD)

kumi = comb.combination(h*w - 2, k - 2)
ans = 0

for d in range(0, h):
    ans += d * (h - d) * kumi * w * w
    ans %= MOD

for d in range(0, w):
    ans += d * (w - d) * kumi * h * h
    ans %= MOD

print(ans)

Measured memory_bytes: 55280
x,y = map(int, input().split())

absx = abs(x)
absy = abs(y)

ans = abs(absx - absy)

if absx < absy :
    if x < 0 :
        ans += 1
    if y < 0 :
            ans += 1
elif absx > absy :
    if x > 0 :
        ans += 1
    if y > 0 :
            ans += 1
else :
    if x != y :
        ans =1

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll mod = 1e9+7;
ll f[1000009], fi[1000009];
ll e (ll b, ll E){
    if(!E) return 1;
    if(1&E) return b*e(b, E-1) % mod;
    return e(b * b % mod, E/2);
}
ll C(ll n, ll m){
    if( n < m  || m < 0) return 0;
    return f[n] * fi[m] % mod * fi[n - m] % mod;
}
main(){
    ll n;
    cin >> n;
    f[0] = 1;
    if(n == 2) {
        cout << 1 << endl;
        return 0;
    }
    for (ll i= 1; i <= n; i++)
        f[i] = (f[i-1]*i) % mod;
    for (ll i= 0; i <= n; i++)
        fi[i] = e(f[i], mod-2);
    ll ans = 0;
    ll X = 0;
    for (ll i= 2; i <= n-1; i++){
        ll K = 2*(i-1) - n + 2;
        ll No = C(i-1, K);
         No = No * f[n-1-i]  % mod;
         No = No * f[i] % mod;
         No = (No-X+ mod ) % mod;
         X  = (X + No) % mod;
         ans = (ans + No * i) % mod;

    }
    cout << ans << endl;

}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 
using namespace std;
int main()
{
    int n,sum,x,mx;
    while (~scanf("%d", &n)) {
        sum = 0;
        mx = -1;
        REP(i,1,n) {
            scanf("%d", &x);
            sum += x;
            mx = max(mx, x);
        }
        printf("%d\n", sum - mx/2);
    }
    return 0;
}


Measured memory_bytes: 256