akhauriyash/Code-Regression huggingface dataset:
/**
*    created: 09.07.2020 01:17:59
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#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++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<pair<int,int>> v; 
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) v.push_back(make_pair(i,n/i));
    }
    reverse(all(v));
    string a = to_string(v[0].first);
    string b = to_string(v[0].second);
    cout << max(a.size(),b.size()) << endl;
    return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define N 300010
#define inf 1000000000000000ll
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
struct edge
{
	int u,v,next;
	ll w;
}vs[N<<1];
int n,ee,st[N],bg[N],ed[N],las;
int V1[N],V2[N];
ll F1[N],F2[N],vl[N];
inline void addedge(int u,int v,int w)
{
	vs[++ee].v=v; 
	vs[ee].w=w; vs[ee].u=u;
	vs[ee].next=st[u];st[u]=ee;
}
inline void dfs(int rt,int pr)
{
	bg[rt]=las++;
	V1[rt]=V2[rt]=-1;
	F1[rt]=F2[rt]=inf;
	for(int i=st[rt];i;i=vs[i].next)
	{
		if(vs[i].v==pr) continue;
		dfs(vs[i].v,rt);
		int xx=V1[vs[i].v]; ll yy=F1[vs[i].v]+vs[i].w;
		if(yy>vl[vs[i].v]+vs[i].w)
			yy=vl[vs[i].v]+vs[i].w,
			xx=vs[i].v;
		if(F1[rt]>yy) swap(yy,F1[rt]),swap(xx,V1[rt]);
		if(F2[rt]>yy) swap(yy,F2[rt]),swap(xx,V2[rt]);
	}
	ed[rt]=las;
}
inline void DFS(int rt,int pr)
{
	for(int i=st[rt];i;i=vs[i].next)
	{
		if(vs[i].v==pr) continue;
		int xx=V1[rt]; ll yy=F1[rt]+vs[i].w;
		if(bg[vs[i].v]<=bg[xx]&&bg[xx]<ed[vs[i].v])
		{
			xx=V2[rt]; yy=F2[rt]+vs[i].w;
		}
		if(yy>vs[i].w+vl[rt])
			yy=vl[rt]+vs[i].w, 
			xx=rt;
		if(F1[vs[i].v]>yy) swap(yy,F1[vs[i].v]),swap(xx,V1[vs[i].v]);
		if(F2[vs[i].v]>yy) swap(yy,F2[vs[i].v]),swap(xx,V2[vs[i].v]);
		DFS(vs[i].v,rt);
	}
}
int fa[N];
inline int getfa(int x)
{
	return fa[x]==x? x:fa[x]=getfa(fa[x]);
}
int main()
{
	n=read(); for(int i=1;i<=n;i++)
		vl[i]=read();
	for(int i=1;i<n;i++)
	{
		int u=read(), v=read(), w=read();
		addedge(u,v,w); addedge(v,u,w); 
	}dfs(1,0); DFS(1,0);
	for(int i=1;i<=n;i++) fa[i]=i;
	ll Ans=0;
	for(int i=1;i<=n;i++)
	{
		if(V1[V1[i]]==i&&i>V1[i]) continue;
		Ans+=F1[i]+vl[i];
		int f1=getfa(i),f2=getfa(V1[i]);
		fa[f1]=f2;
	}
	for(int i=1;i<n;i++)
	{
		if(getfa(vs[i<<1].u)==getfa(vs[i<<1].v)) continue;
		Ans+=min(vl[vs[i<<1].u],F1[vs[i<<1].u]);
		Ans+=min(vl[vs[i<<1].v],F1[vs[i<<1].v]);
		Ans+=vs[i<<1].w;
	}
	cout << Ans << endl;
	return 0 ;
}

Measured memory_bytes: 29312
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <functional>
using namespace std;

int n, cnt;

int main() {
	cin >> n;
	string S = to_string(n);
	for (int i = 0; i < S.size(); i++) cnt += (S[i] - '0');
	if (n%cnt == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int a,b;
    cin >> a >> b;
    int ans = 0;
    int plug = 1;
    while (plug < b){
        plug--;
        plug += a;
        ans++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(void)
{
	int a, b, c;
	scanf("%d %d", &a, &b);
	c = a + b;
	if (c % 2 == 0)
		printf("%d\n", (a + b) / 2);
	else
		printf("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD1 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


void solve(void)
{
  int N;cin>>N;
  vector<int> vec;
  while(vec.size() < 55)
  {
    static int i = 0;
    if(i%5 == 1 && IsPrime(i))vec.push_back(i);
    i ++;
  }
  for (int i = 0; i < N; i++)
  {
      if(i != 0)cout<<char(32);
      cout<<vec[i];
  }
  cout<<endl;
  

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3616
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
using namespace std;
typedef long long llong;
int M, T, P, R;
class Team {
public:
	int problems[10];
	int ac;
	int number;
	int time;
	int rank;
};

bool f(Team a, Team b) {
	if (a.ac == b.ac&&a.time == b.time)return a.number > b.number;
	else if (a.ac == b.ac)return a.time < b.time;
	else return a.ac > b.ac;
}
int main() {
	while (1) {
		cin >> M >> T >> P >> R;
		if (!M && !T && !P && !R)break;
		vector<int>m(R), t(R), p(R), j(R);

		vector<Team>team(T);
		for (int i = 0; i < T; i++) {
			team[i].number = i + 1;
			team[i].ac = team[i].time = 0;
			for (int j = 0; j < 10; j++) {
				team[i].problems[j] = 0;
			}
		}
		for (int i = 0; i < R; i++) {
			cin >> m[i] >> t[i] >> p[i] >> j[i];
			t[i]--;
			p[i]--;
			if (j[i] == 0) {
				if (team[t[i]].problems[p[i]] == 0) {
					team[t[i]].problems[p[i]] = 1;
					team[t[i]].time += m[i];
					team[t[i]].ac++;
				}
				else if (team[t[i]].problems[p[i]] < 0) {
					team[t[i]].time += (m[i] + 20*(-team[t[i]].problems[p[i]]));
					team[t[i]].problems[p[i]] = 1;
					team[t[i]].ac++;
				}
			}
			else {
				team[t[i]].problems[p[i]]--;
			}

		}
		sort(team.begin(), team.end(), f);
		for (int i = 0; i < T; i++) {
			if (i) {
				if (team[i].ac == team[i - 1].ac&&team[i].time == team[i - 1].time) {
					cout << '=';
				}
				else {
					cout << ',';
				}
			}
			cout << team[i].number;

		}
		cout << endl;
	}
	return 0;
}

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

int kaijo(int i){
   
  if (i > 1) {
    
    return i * kaijo(i - 1);
    
  } else {
      
  return 1;
  }
}


#include <bits/stdc++.h>
using namespace std;

int main(){
  
  int N, M;
  cin >> N >> M;
  
  cout << (N * (N - 1) + M * (M - 1))/2 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int number_of_buttons, i, current_button = 0, count = 0;
  scanf("%d", &number_of_buttons);
  int button[number_of_buttons];
  int button_flag[100000] = {};
  for(i = 0; i < number_of_buttons; i++) {
    scanf("%d", &button[i]);
  }
  for(i = 0; i < number_of_buttons; i++) {
    if(current_button == 1) {
      printf("%d\n", count);
      break;
    }
    if(button_flag[current_button] != 0) {
      printf("-1\n");
      break;
    }
    button_flag[current_button]++;
    current_button = button[current_button] - 1;
    count++;
  }
  return 0;
}


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

int h;

int parent(int i){ //index of parent
  return i / 2;
}

int left(int i){ //index of left child
  return 2 * i;
}

int right(int i){ //index of right child
  return 2 * i + 1;
}

void maxHeapify(int *A, int i){
  int l, r, largest;

  l = left(i);
  r = right(i);

  //update largest value
  if(l <= h && A[l] > A[i]) largest = l;
  else largest = i;

  if(r <= h && A[r] > A[largest]) largest = r;

  //swap the elements to proper places
  if(largest != i){
    swap(A[i], A[largest]);
    maxHeapify(A, largest);
  }
}

void buildMaxHeap(int *A){
  for(int i = h / 2;i >= 1;i--) maxHeapify(A, i);
}

int main(){

  int a[500010];

  //input
  cin >> h;
  for(int i = 1;i <= h;i++) cin >> a[i];

  buildMaxHeap(a);

  //output
  for(int i = 1;i <= h;i++) cout << " " << a[i];
  cout << endl;

  return 0;
}



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

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

    int answer = 0;
    for (int i = n; i <= 999; i++)
    {
        string sn = to_string(i);
        if (sn.at(0) == sn.at(1) and sn.at(1) == sn.at(2))
        {
            answer = i;
            break;
        }
    }
    cout << answer << endl;
}

Measured memory_bytes: 256
R, G, B, N = map(int, input().split())
 
ans = 0
for i in range(N//R + 1):
    for j in range(N//G + 1):
        if i*R + j*G > N:
            break
        if i*R + j*G <= N and (N - (i*R + j*G)) % B == 0:
            ans += 1
print(ans)

Measured memory_bytes: 40556
#include <stdio.h>
int main(void)
{
    char a[200];
    int i;
    scanf("%[^\n]",a);
    for(i=0;a[i]!='\0';i++)
    {
        if(a[i]=='.')
            continue;
        else if(a[i]==' ')
            continue;
        a[i]-=32;
    }
    printf("%s\n",a);
    return 0;

}

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

#define int long long
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vii vector<pi>
#define ps(x,y) fixed<<setprecision(y)<<x
#define w(t) int t;cin>>t;while(t--)solve()
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define f(n) for (int i=0;i<n;++i)
#define init(arr,m,n,value) std::fill(*arr,*arr+m*n,value)
//debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);

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

void solve(){
	
}

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	//clock_t z = clock();
	double d,t,s;
	cin>>d>>t>>s;
	if (d/s<=t)cout<<"Yes";
	else cout<<"No";

}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	long long x;
	cin >> x;
	long long ans = 2 * (x / 11);
	long long rem = x % 11;
	if(rem <= 6 && rem != 0) ans++;
	else if(rem != 0) ans += 2;
	cout << ans << endl;    
	return 0;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a==b) printf("%d\n",c);
  else if(b==c) printf("%d\n",a);
  else if(c==a) printf("%d\n",b);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

using Graph = vector<vector<int>>;

// int の最大値は2147483647
// xとyの最大値は1.0e5だから。
const int maxX = 100005;

vector<bool> seen(maxX*2);

vector<int> nc(2);

void dfs(Graph& _G, int _v){
  seen[_v] = true;
  if(_v < maxX) nc[0] += 1;
  else nc[1] += 1;

  for(auto nv: _G[_v]){
    if(seen[nv]) continue;
    dfs(_G, nv);
  }
}

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

  Graph G(maxX*2);

  for(int i = 0 ; i < N; i++){
    int x,y;
    cin >> x >> y;
    y+=maxX;
    G[x].push_back(y);
    G[y].push_back(x);
  }

  ll counter = 0;
  seen.assign(maxX*2, false);

  for(int i = 0; i < maxX*2; i++){  //Graphのすべてのノードについて
    if(seen[i]) continue;
    nc.assign(2, 0);
    dfs(G, i);
    counter += (ll)nc[0] * nc[1]; //二部グラフのノード数を掛け合わせれば、辺の数がわかる
  }
  counter -= N;

  cout << counter << endl;

  return 0;
}


Measured memory_bytes: 9984
#! env/bin/local python3
# -*- coding: utf-8 -*-

import numpy as np


def fill_red(height, width, table, h, w):
    for hn in range(h):
        if (2 ** hn) & height == (2 ** hn):
            table[hn:hn + 1] = '+'

    for wn in range(w):
        if (2 ** wn) & width == (2 ** wn):
            table[:, wn:wn+1] = '+'

    return table


def count_black(table, k):
    if np.sum(table == "#") == k:
        return True
    else:
        return False


def main():
    h, w, k = map(int, input().split())
    original_table = []

    while True:
        try:
            row = list(input())
            original_table.append(row)
        except EOFError:
            break

    original_table = np.array(original_table)

    counter = 0
    for height in range(2**h):
        for width in range(2**w):
            table = original_table.copy()
            table = fill_red(height, width, table, h, w)
            if count_black(table, k):
                counter += 1

    print(counter)


if __name__ == '__main__':
    main()


Measured memory_bytes: 27140
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n;
    cin >> n;
    int d[n];
    rep(i, n) { cin >> d[i]; }
    sort(d, d + n);
    int ans = 1;
    repd(i, 1, n) {
        if (d[i] != d[i - 1]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

void prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		String st1 = "ABC";
		String st2 = "ARC";

		if(s.equals(st1)) {
			System.out.println("ARC");
		}else if(s.equals(st2)){
			System.out.println("ABC");
		}
	}
}


Measured memory_bytes: 35700
#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; }

typedef long long  ll;

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

int main() {
    string s;
    cin>>s;
    if(s=="A"){
        cout<<"T"<<endl;
    }
    if(s=="T") cout<<"A"<<endl;
    if(s=="C")cout<<"G"<<endl;
    if(s=="G") cout<<"C"<<endl;

    return 0;
}

Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	int n; cin >> n;
	ll x[n], y[n], p[n];
	REP(i, n) cin >> x[i] >> y[i] >> p[i];
	int num = 1 << n;
	ll cost[num] = {};
	REP(i, num){
		cost[i] = LLINF;
		ll nowx, nowy;
		REP(j, n){
			nowx=0;
			nowy=0;
			REP(k, n){
				if(i & (1<<k)){
					nowx += abs(x[k] - x[j]) * p[k];
					nowy += abs(y[k] - y[j]) * p[k];
				}
			}
			cost[i] = min({nowx, nowy, cost[i]});
		}
		//cout << bitset<3>(i) << " " << cost[i] << endl;
	}
	ll dp[num][n+1] = {};
	REP(i, num){
		REP(j, n){
			if(i & (1<<j)) dp[i][0] += min(abs(x[j]), abs(y[j])) * p[j];
		}
		//cout << dp[i][0] << endl;
	}
	REP1(j, n){
		REP(i, num){
			dp[i][j] = LLINF;
			for(int k = i; k >= 0; k--){
				k &= i;
				dp[i][j] = min(dp[i][j], dp[k][j-1] + cost[i^k]);
			}
		}
	}
	REP(i, n+1)	cout << dp[num-1][i] << endl;
}

Measured memory_bytes: 7964
import sys
input = sys.stdin.readline
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD=10**9+7

N,M=rl()
A=rl()
B=[0]*M
C=[0]*M
for i in range(M):
    B[i],C[i]=rl()


D = []
for a in A:
    D.append([a,1])
for b,c in zip(B,C):
    D.append([c,b])

D.sort(reverse=True)

ans = 0
cnt = N
for val,num in D:
    if cnt >= num:
        cnt -= num
        ans += val*num
    else:
        ans += val*cnt
        break
print(ans)


Measured memory_bytes: 36140
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#define For(i,a,b) for(int i=(a);i<(b);i++)
#define Rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

int main() {
	string s;
	cin >> s;
	vector<int> a(4);
	Rep(i, 4) a[i] = (int)s[i]-(int)'0';
	char m[2] = { '+','-' };
	Rep(i, 2)Rep(j, 2)Rep(k, 2) {
		int b = a[0];
		if (i == 0) {
			b += a[1];
			if (j == 0) {
				b += a[2];
				if (k == 0) {
					b += a[3];
				}
				else b -= a[3];
			}
			else {
				b -= a[2];
				if (k == 0) b += a[3];
				else b -= a[3];
			}
		}
		else {
			b -= a[1];
			if (j == 0) {
				b += a[2];
				if (k == 0) {
					b += a[3];
				}
				else b -= a[3];
			}
			else {
				b -= a[2];
				if (k == 0) b += a[3];
				else b -= a[3];
			}
		}
		
		if (b == 7) {
			cout << s[0] << m[i] << s[1] << m[j] << s[2] << m[k] << s[3] << "=7" << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    int z = 999;
    cin >> s;
    for (int i = 2; i < s.length(); i++) {
        int a = stoi(s.substr(i - 2, 3));
        z = min(z, abs(a - 753));
    }
    cout << z;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 3e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;
//#define endl "\n" //インタラクティブでは消す
//ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
ut N, M, K, L, Q, D, H, W,R;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
LL maps[SIZE2][SIZE2];
LL A, B,X,Y;
string s;
LL solve() {
	cin >> N >> A >> B;
	cout << min(A ,B) << " " << max(0LL,A+B-N) << endl;
	return 0;
}




//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	string s;
	solve();
		
	
	//cin >> N;
	return 0;

}


Measured memory_bytes: 8448
import Data.List

main :: IO ()
main = do
  n <- readLn
  s <- getLine
  print $ solve n s

solve :: Int -> String -> Int
solve n s = maximum [ solve' i s | i <- [0 .. n] ]

solve' :: Int -> String -> Int
solve' i s = length $ nub $ uncurry intersect $ splitAt i s

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
const double EPS=1E-8;
////////////////////////////////////////



int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    int p[n];
    rep(i,0,n-1){
        int k;cin>>k;k--;
        p[k]=i+1;
    }
    ll a[n],b[n];
    ll da[n-1],db[n-1];
    rep(i,0,n-2){da[i]=1;db[i]=1;}
    rep(i,0,n-2){
        if(p[i]<p[i+1]){
            da[i]=p[i+1]-p[i]+1;
        }else{
            db[i]=p[i]-p[i+1]+1;
        }
    }
    a[0]=1;rep(i,0,n-2)a[i+1]=a[i]+da[i];
    b[n-1]=1;for(int i=n-2;i>=0;i--)b[i]=b[i+1]+db[i];
    rep(i,0,n-1)cout<<a[i]<<" ";cout<<endl;
    rep(i,0,n-1)cout<<b[i]<<" ";
    
    return 0;
}

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

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

void main() {
    readint;
    string s = read!string;

    string t = s.uniq().to!string;
    writeln(t.length);
}


Measured memory_bytes: 2556
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////




int main() {
	
	ll A, B;
	cin >> A >> B;

	if (B%A == 0) { cout << A + B; }
	else { cout << B - A; }

	system("PAUSE");
}

Measured memory_bytes: 504
import numpy as np
n = int(input())
a= int(input())
b= int(input())
c= int(input())
d= int(input())
e= int(input())

l = [a,b,c,d,e]
m = min(l)

if n <= m:
    print(5)
else:
    if n%m == 0:
        print(int(n/m)+4)
    else:
        print(int(n/m)+5) 

Measured memory_bytes: 18588
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int a, b, c, d;
  a = N / 1000;
  b = (N - a * 1000) / 100 ;
  c = (N - a * 1000 - b * 100 ) /10 ;
  d = N - a * 1000 - b * 100 - c * 10;
  if (( a == b && b == c) || (b == c && c == d)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N;
    cin >> N;
    int a[13] = {0};
    a[0]++;
    for ( int i = 0; i < N; i++ ) {
        int D;
        cin >> D;
        
        a[D]++;
    }
    
    int diff[25][25];
    for ( int i = 0; i <= 24; i++ ) {
    for ( int j = 0; j <= 24; j++ ) {        
        diff[i][j] = min( abs( i-j ), 24-abs( i-j ) );
    }
    }
    
    
    int ans = 0;
    for ( int i = 0; i < (1<<12); i++ ) {
        
        int d = INT_MAX;
        
        vector<int> v;
        for ( int j = 0; j <= 12; j++ ) {            
            if ( a[j] == 1) {
                v.push_back( (1<<j & i) ? j : 24-j );
            }
            else if ( a[j] == 2 ) {
                v.push_back( j );
                v.push_back( 24-j );
            }            
            else if ( a[j] > 2 ) { cout << 0 << endl; return 0; }
        }
        
        for ( int j = 0; j < v.size(); j++ ) {
        for ( int k = j+1; k < v.size(); k++ ) {
            d = min( d, diff[v[j]][v[k]] );
        }
        }
        
        ans = max( ans, d );
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
n=int(input())

import math
sq = math.ceil(math.sqrt(n) )

ans = [0]*(n+1)
for x in range(1,sq):
    for y in range(1,sq):
        for z in range(1,sq):
            k = x**2+y**2+z**2+x*y+y*z+z*x
            if k<=n:
                ans[k]+=1
for i in range(1,n+1):
    print(ans[i])

Measured memory_bytes: 69388
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, m;
  cin >> n >> m;
  vl h(n);
  rep(i, n) cin >> h[i];
  
  ll a, b;
  vector<bool> good(n, 1);
  rep(_, m) {
    cin >> a >> b;
    a--, b--;
    if(h[a]<=h[b]) good[a] = 0;
    if(h[a]>=h[b]) good[b] = 0;
  }
  cout << count(all(good), 1) << newl;
  return 0;
}

Measured memory_bytes: 3992
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */

public class Main {
    public static void main(String[] args) {
        InputStream    inputStream    = System.in;
        OutputStream outputStream = System.out;
        InputReader    in                      = new InputReader(inputStream);
        PrintWriter      out                    = new PrintWriter(outputStream);
        Task                 solver               = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
    	public void solve(int testNumber, InputReader in, PrintWriter out) {
    		int N = in.nextInt();
    		int tmp = N;
    		int len = String.valueOf(N).length();
    		int total = 0;
    		for(int i = 0; i < len; i++) {
    			total += N % 10;
    			N /= 10;
    		}
    		String str = "No";
    		if(tmp % total == 0) {
    			str = "Yes";
    		}
    		out.println(str);
    	}
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22868
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int k = Integer.parseInt(str[1]);
    if(n==1)
      System.out.println(k);
    else
      System.out.println(k*(int)Math.pow(k-1,n-1));
  }
}

Measured memory_bytes: 32652
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;


template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};


const int MOD = 998244353;
using mint = Fp<MOD>;


int main() {
    int N; cin >> N;
    vector<long long> a(N);
    long long S = 0;
    for (int i = 0; i < N; ++i) cin >> a[i], S += a[i];

    vector<vector<mint> > dp(N+1, vector<mint>(S+1, 0));
    dp[0][0] = 1;
    auto dp2 = dp; // 単純な部分和

    for (int i = 0; i < N; ++i) {
        for (int v = 0; v + a[i] <= S; ++v) {
            dp[i+1][v + a[i]] += dp[i][v];
            dp[i+1][v] += dp[i][v] * 2;

            dp2[i+1][v + a[i]] += dp2[i][v];
            dp2[i+1][v] += dp2[i][v];
        }
    }
    mint all = modpow(mint(3), N);
    mint hosyugo = 0;
    for (int i = S/2+1; i <= S; ++i) hosyugo += dp[N][i] * 3;
    if (S % 2 == 0) {
        hosyugo += (dp[N][S/2] - dp2[N][S/2] * 2) * 3;
        hosyugo += dp2[N][S/2] * 3;
    }
    cout << all - hosyugo << endl;
}
    














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

int main(){

  long H,W;
  cin >> H >> W;

  if(H==1 or W==1){
  
    cout << 1 << endl;
    
  }else if((H*W) % 2 == 0){
  
    cout << H*W/2 << endl;
  
  }else{
    
    cout << (H*W+1)/2 << endl;
    
  }

}

Measured memory_bytes: 256
from collections import Counter
l=input()
s=list(l)
k=0
if s[0]=='A':
    for i in range(2,len(s)-1):
        if s[i]=='C':
            k+=1
    if k==1:
        if l.replace('A', 'a').replace('C', 'c') == l.lower():print('AC')
        else:print('WA')
    else:print('WA')
else:print('WA')

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

#define mod 1000000007

int a[22][22];
/*long mem[22][(1<<22)-1];

long rec(int curr, int mask, int n)
{
  if(curr==n)
    return mask==0;
  if(mem[curr][mask]!=-1)
    return mem[curr][mask];
  long ans=0;
  for(int j=0;j<n;j++)
  {
    bool available=mask&(1<<j);
    if(available&&a[curr][j])
      ans=(ans%mod+rec(curr+1,mask-(1<<j),n)%mod)%mod;
  }
  mem[curr][mask]=ans;
  return ans;
  
}*/

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<n;j++)
      cin>>a[i][j];
  }
  /*memset(mem,-1,sizeof(mem));
  
  cout<<rec(0,(1<<n)-1,n);*/
  
  long dp[(1<<n)]={0};
  dp[0]=1;
  for(int mask=0;mask<(1<<n)-1;mask++)
  {
    int cnt=__builtin_popcount(mask);
    for(int j=0;j<n;j++)
    {
      if(a[cnt][j]&&!(mask&(1<<j)))
      {
        int m2=mask^(1<<j);
        dp[m2]=(dp[m2]%mod+dp[mask]%mod)%mod;
      }     
    }
  }
  cout<<dp[(1<<n)-1];

}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pqueue priority_queue<ll>
#define piqueue priority_queue<ll,vll ,greater<ll>>
#define pinf LLONG_MAX
#define ninf LLONG_MIN
#define all(v) v.begin(),v.end()
#define endl '\n'
#define MOD 1000000007
#define pb push_back
#define ff first
#define ss second
#define pi 3.1415926535897932384
using namespace std;
using namespace __gnu_pbds;
    
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,
tree_order_statistics_node_update> ordered_multiset;
    
void pv(vector<auto> &v,ll start = 0, ll end = 0){
    if(end != v.size() - 1) end = v.size() - 1;
    for(ll i = start; i <= end; i++) cout << v[i] << " "; cout << endl;
}
void inline pp(pair<auto, auto> p) { cout << p.ff << " " << p.ss << endl; }
void inline in(vector<auto> &v, ll n) {
    v.resize(n); for(ll i = 0; i < n; i++) cin >> v[i];
}
void inline sortv(vector<auto> &v) { sort(all(v)); }
void inline sortvr(vector<auto> &v) { sort(v.rbegin(), v.rend()); }
bool inline isVowel (char c) {
    return (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
}
void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int solve();
int main(){
    fast();
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}
vector<ll> prime(1000500, 1);
void sieve(ll n){
    for(ll i = 0; i <= n; ++i)
        prime[i] = i;
    for(ll p = 2; p * p <= n; p++){
        if(prime[p] == p){
            for (ll i = p; i <= n; i += p)
                if(prime[i] == i)
                    prime[i] = p;
        }
    }
}
int solve(){
    sieve(1000050);
    ll n;
    cin >> n;
    vll a;
    in(a, n);
    map<ll,ll> m;
    for(auto i: a){
        ll x = i;
        while(prime[x] != 1){
            m[prime[x]]++;
            ll d = prime[x];
            while(x % d == 0){
                x /= d;
            }
        }
    }
    ll mx = LLONG_MIN;
    for(auto i: m)
        mx = max(mx, i.ss);
    if(mx >= n)
        cout << "not coprime" << endl;
    else if(mx > 1)
        cout << "setwise coprime" << endl;
    else
        cout << "pairwise coprime" << endl;
    return 0;
}

Measured memory_bytes: 23660
import java.util.GregorianCalendar;
import java.util.Scanner;

//What day is today?
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = {"","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
		while(true){
			int m = sc.nextInt();
			int d = sc.nextInt();
			if(m==0)break;
			GregorianCalendar g = new GregorianCalendar(2004, m-1, d);
			System.out.println(s[g.get(GregorianCalendar.DAY_OF_WEEK)]);
		}
	}
}

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


int main(){
    int n,m; cin >> n >> m;
    int x;
    for(int i = 0; i < m; i++){
        cin >> x;
        n -= x;
    }
    if(n<0){
        cout << "-1" << endl;
    }
    else{
        cout << n << endl;
    }


    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 1000002
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d ", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000007
#define mod 998244353
#define PI acos(-1.0)
#define eps 1e-9
#define mem(a, b) memset(a, b, sizeof(a))
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

void solve()
{
    int n;
    cin>>n;
    vector<ll>a(n);
    for(int i = 0; i < n; i++)
        cin>>a[i];
    sort(a.begin(), a.end());
    ll ans = infLL;
    for(ll i = a[0]; i <= a[n-1]; i++)
    {
        ll tot = 0;
        for(int j = 0; j < n; j++)
            tot = tot + ((i - a[j]) * (i - a[j]));
        ans = min(ans, tot);
    }
    cout<<ans<<endl;
}

int main()
{
    FASTIO;
    solve();

    return 0;
}


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

int main() {
    int v, e, r;
    cin >> v >> e >> r;
    vector<vector<pair<int, int>>> edges(v, vector<pair<int, int>>(0));
    for (int i = 0; i < e; ++i) {
        int s, t, d;
        cin >> s >> t >> d;
        edges[s].emplace_back(mp(d, t));
    }
    vector<int> dist(v, 1001001001);
    vector<bool> seen(v);
    seen[r] = true;
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> pq;
    dist[r] = 0;
    pq.push(mp(0, r));
    while (!pq.empty()) {
        auto x = pq.top();
        seen[x.second] = true;
        pq.pop();
        for (auto nv : edges[x.second]) {
            if (seen[nv.second]) continue;
            if (dist[x.second] + nv.first < dist[nv.second]) {
                dist[nv.second] = dist[x.second] + nv.first;
                pq.push(mp(dist[nv.second], nv.second));
            }
        }
    }
    for (int i = 0; i < v; ++i) {
        if (dist[i] == 1001001001) cout << "INF" << endl;
        else cout << dist[i] << endl;
    }
}



Measured memory_bytes: 12976
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }

        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < N-K; i++) {
            ans.append(A[i] < A[i+K] ? "Yes" : "No").append('\n');
        }

        System.out.print(ans);
    }
}


Measured memory_bytes: 60396
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl

using namespace std;
typedef long long  ll;

const long long MOD = 1e9+7;

int main(){

    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A);
    REP(i, 0, A){
        cin >> a.at(i);
    }
    vector<int> b(B);
    REP(j, 0, B){
        cin >> b.at(j);
    }

    int min = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());

    int x, y, c;
    int sum;
    REP(i, 0, M){
        cin >> x >> y >> c;
        sum = a.at(x - 1) + b.at(y - 1) - c;
        if(sum < min){
            min = sum;
        }
    }

    p(min);

}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	
	int N; cin >> N;
	int A, B; cin >> A >> B;
	int ans = min(N*A, B);
	cout << ans << endl;


	return 0;

}


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

int main(){
  int n, m;
  cin >> n >> m;
  if(n % 2) {
    for(int i = 1; i <= m; i++) cout << i << " " << n+1-i << endl;
  } else {
    int k = 0;
    while(k < m) {
      if(n-1-2*k <= n/2) break;
      cout << k+1 << " " << n-k << endl;
      k++;
    }
    m -= k;
    for(int i = 1; i <= m; i++) {
      cout << n/2+1-i << " " << n/2+1+i << endl;
    }
  }
  return 0;
}


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

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

  int ans = 0;
  for (int i = 0; i < 3; ++i) {
    int rem = num % 10;
    if (rem) ++ans;
    num /= 10;
  }

  cout << ans << endl;

  return 0;
}


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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 110;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;


void solve(int testCase){

    scanf("%d" , &n);
    printf("%d\n" , n*n);


}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
int a[110];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	int tmp=1,ans=a[0];
	int sum=0;
	for(int i=1;i<n;i++)
	{
		if(a[i]==ans) tmp++;
		else
		{
			sum+=tmp/2;
			tmp=1;
			ans=a[i];
		}
	}
	cout<<sum+tmp/2<<endl;
	return 0;
}

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

int a,b,c,aa,bb,cc,ans,x[3];

int main() {
	
	cin >> a >> b >> c;
	x[0] = a;
	x[1] = b;
	x[2] = c;
	sort(x,x+3);
	aa = x[0] % 2;
	bb = x[1] % 2;
	cc = x[2] % 2;
	
	if(aa == bb && bb == cc && cc == aa){
		ans = (x[2] - x[1]) / 2 + (x[2] - x[0]) / 2;
	}
	
	else{
		if(bb == aa){
			ans = (x[2] - x[1] - 1) / 2 + (x[2] - x[0] - 1) / 2 + 1;
		}
		else{
			ans = (x[2] - x[1] + 1) / 2 + (x[2] - x[0] + 1) / 2 + 1;
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

V = list(map(int, input().split()))

ans = 0
for l in range(min(N+1,K+1)):
    for r in range(min(N+1,K+1)-l):
        left = V[:min(l, N+1)] # 左からとったもの
        right = V[max(0, N-r):] # 右からとったもの

        if len(left) + len(right) > N: # 元の個数を超えているならそれはできないのでスキップ
            continue
        else:
            gem = left + right

        gem.sort()

        #捨てられる回数
        drop = min(K-l-r, len(gem))
        idx = 0
        total = sum(gem)
        while idx < drop:
            if gem[idx] < 0:
                total -= gem[idx]
                idx += 1
            else:
                break
        ans = max(ans, total)

print(ans)

Measured memory_bytes: 3188