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

//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1 ; i <= n ; i++)
        cout << "ACL";
    cout << endl;
    return 0;
}

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

int main(){
    int k;
    cin >> k;
    pair<int, int> c[k];
    for (int i = 0; i < k; i++)
    {
        cin >> c[i].first >> c[i].second;
    }
    
    pair<int, int> q[8];
    int a[8];
    for (int i = 0; i < 8; i++)
    {
        q[i].first = i;
        a[i] = i;
    }
    
    do
    {
        for (int i = 0; i < 8; i++)
        {
            q[i].second = a[i];
        }
        
        bool ok = true;
        for (int i = 0; i < 8; i++)
        {
            for (int j = i + 1; j < 8; j++)
            {
                if(abs(q[i].first - q[j].first) == abs(q[i].second - q[j].second)) ok = false;
            }
        }
        if(ok){
            int e = 0;
            for (int j = 0; j < k; j++)
            {
                bool exist = false;
                for (int l = 0; l < 8; l++)
                {
                    if(c[j] == q[l]){
                        exist = true;
                        e++;
                    }
                }
            }
            if(e == k){
                for (int j = 0; j < 8; j++)
                {
                    for (int l = 0; l < 8; l++)
                    {
                        bool s = false;
                        for (int m = 0; m < 8; m++)
                        {
                            if(make_pair(j, l) == q[m]) s = true;
                        }
                        if(s) cout << "Q";
                        else cout << ".";
                    }
                    cout << endl;
                }
                
            }
        }
        
        
    } while (next_permutation(a, a + 8));
    
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll n;
string s;
ll dp[3009][3009];
ll sum[3009][3009];
int main(){
    cin>>n>>s;
    ll maki=s.length();
    maki++;
    for(ll i=1;i<=n;i++)dp[0][i]=1;
    for(ll i=1;i<maki;i++){
        for(ll j=1;j<=i+1;j++){
            if(s[i-1]=='>')dp[i][j]=dp[i-1][n]-dp[i-1][j-1]+mod;
            else dp[i][j]=dp[i-1][j-1];
            dp[i][j]%=mod;
        }
        for(ll j=1;j<=n;j++)dp[i][j]+=dp[i][j-1],dp[i][j]%=mod;
    }
    cout << dp[n-1][n] <<endl;
    return 0;
}



Measured memory_bytes: 71936
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

V = sum(v)
# dp[i][j]:i番目までの品物から価値がj以上になるよう選んだときの重さの総和の最小値
dp = [[float("inf")] * (V + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
	for j in range(V + 1):
		# i+1番目を選ぶ場合
		if j - v[i] >= 0:
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i])
		# i+1番目を選ばない場合
		dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])

# dp[N][j]がW以下であるようなjの最大値が答えになる
ans = 0
for j in range(V + 1):
	if dp[N][j] <= W:
		ans = j

print(ans)

Measured memory_bytes: 311760
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      (int)1e9+7
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;

int main(){
	int n;
	cin>>n;
	
	vi v(8,0);
	int cnt=0;
	REP(i,n){
		int a;
		cin>>a;
		if(a>=3200) cnt++;
		else v[a/400]++;
	}
	
	int cntt=0;
	REP(i,8) if(v[i]) cntt++;
	
	int ans=(cntt)?cntt:1;
	int anss=cntt+cnt;
	
	cout<<ans<<' '<<anss<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> cum(n);
    rep(i,n) cum[i]=a[i];
    for(int i=n-2;i>=0;i--) cum[i]=(cum[i]+cum[i+1])%MOD;
    //rep(i,n) cout << cum[i] << " ";
    //cout << endl;
    ll ans = 0;
    rep(i,n-1){
        ans += (a[i] * cum[i+1])%MOD; 
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6424
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#define INF 100000000
typedef long long int lli;
using namespace std;
int dc[101][101];
int dt[101][101];

int main(){
	int n,m;
	while(cin>>n>>m&&n&&m){
		for(int i=0; i<101; ++i){
			for(int j=0; j<101; ++j){
				if(i==j){
					dc[i][j]=0;
					dt[i][j]=0;
				} else {
					dc[i][j]=INF;
					dt[i][j]=INF;
				}
			}
		}
		for(int i=0; i<n; ++i){
			int a,b,cost,time;
			cin >> a >> b >> cost >> time;
			dc[a][b]=cost;
			dc[b][a]=cost;
			dt[a][b]=time;
			dt[b][a]=time;
		}
		for(int k=1; k<=m; ++k){
			for(int i=1; i<=m; ++i){
				for(int j=1; j<=m; ++j){
					dc[i][j]=min(dc[i][j],dc[i][k]+dc[k][j]);
					dt[i][j]=min(dt[i][j],dt[i][k]+dt[k][j]);
				}
			}
		}
		int K;
		cin >> K;
		for(int i=0; i<K; ++i){
			int p,q,r;
			cin >> p >> q >> r;
			if(r==0){
				cout << dc[p][q] << "\n";
			} else {
				cout << dt[p][q] << "\n";
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
int main(){
while(true){
	int a,b,c,d;
	cin >> a;
	if(a==0){
		break;
	}
	int syo[a]={};
	c=0;
	for(int n=0;a>n;n++){
		cin >> b;
		syo[n]=b;
		c=c+b;
		}
	int hei=c/a;
	d=0;
	for(int m=0;a>m;m++){
		if(syo[m]<=hei){
			d++;
		}
	}
	printf("%d\n",d);
	}
}


Measured memory_bytes: 3204
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse = True)
q.sort(reverse = True)
del p[x:]
del q[y:]
t = p + q + r
t.sort(reverse = True)
del t[(x + y):]
print(sum(t))   

Measured memory_bytes: 22720
// Problem : B - I miss you...
// Contest : AtCoder Beginner Contest 154
// URL : https://atcoder.jp/contests/abc154/tasks/abc154_b
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define ll                    long long int
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define MOD                   1000000007
#define vi                    vector<int>
#define vll                   vector<ll>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define eb                    emplace_back
#define ull                   unsigned long long
#define bug(x)				  cout<<"  [ "#x<<" = "<<x<<" ]"<<endl;
#define KAMEHAMEHA            ios_base::sync_with_stdio(0);
#define RASENGAN              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
    KAMEHAMEHA
//    #ifdef _soumik
//        freopen("input.txt", "r", stdin);
//    #endif
	string s;
	cin>>s;
	for(auto i:s)
		cout<<'x';
	cout<<endl;
    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,mmx,sse,sse2")

#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << "[DBG] " << #X << "=" << (X) << '\n';
	#define SAY(X) cout << "[SAY] " << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void research(const vector<int>& arr) {
	int n = len(arr);
	vector<int> sum(1<<n, 0);
	for(int i = 1; i < (1<<n); ++i) {
		for(int j = 0; j < n; ++j) {
			int b = 1<<j;
			if(i&b) {
				sum[i] = arr[j] + sum[i^b];
				break;
			}
		}
	}
	sort(sum.begin(), sum.end());
	DBG(sum);
}

const int MAXN = 2007;
bitset<MAXN * MAXN> can;

void solve() {
	int n = fetch<int>();
	auto a = fetch_vec<int>(n);
#ifdef __LOCAL
	research(a);
#endif
	can[0] = 1;
	int sum = 0;
	for(auto& el: a) {
		sum += el;
		can |= can << el;
	}
	int answ = sum;
	for(int i = sum - 1; i >= sum - i; --i) {
		if(can[i]) answ = i;
	}
	cout << answ << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


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

int main()
{
    vector<ll> A(3);
    cin >> A[0] >> A[1] >> A[2];
    sort(A.begin(),A.end());

    ll maxhour = 10000;

    do
    {
        ll hour;
        hour = A[0]+A[1];
        maxhour = min(maxhour,hour);
    } while (next_permutation(A.begin(),A.end()));

    cout << maxhour << endl;   
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <stack>
#include <queue>
#include <set>

#define mod 1000000007
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;
int x[1000001];
int main(){
    string S;
    cin >> S;
    int a=0;
    rep(i,S.size()) a+= (S[i]-'0');
    if(a%9==0||a==0) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 3748
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()


N, W = LI()
L = [LI() for _ in range(N)]
V = 0
for i in range(N): V += L[i][1]

# dp[v]: 価値vを詰め込んだナップザックの重量の最小値
dp = [INF] * (V + 1)
dp[0] = 0
for weight, value in L:
    for v in range(V + 1)[::-1]:
        if v - value < 0:
            continue
        dp[v] = min(dp[v], dp[v - value] + weight)

for i in range(V + 1)[::-1]:
    if dp[i] <= W:
        print(i)
        exit()


Measured memory_bytes: 94164
#include <iostream> 
#include <cstdio> 
#include <cstring> 
#include <algorithm> 
#include <cmath> 

using namespace std; 

#define N 100010
#define M 65540

int n, s[N], x, ans, u, v, w; 
int f[M], inf, sum[20]; 

int dfs(int S) {
    if(!S)return 0; 
    if(f[S] < inf) return f[S]; 
    for(int i = 0; i < 16; i++) {
        if ((S >> i) & 1) {
            for(int j = 0; j < 16; j++) {
                if (i != j && (S >> j) & 1) {
                    int p = i^j, x = S^(1 << i)^(1 << j)^(1 << p); 
                    if (S >> p & 1)f[S] = min(f[S], dfs(x) + 2); 
                    else f[S] = min(f[S], dfs(x) + 1); 
                }
            }
        }
    }   
    return f[S]; 
}

int main() {
    scanf("%d",&n); 
    for(int i = 1 ; i < n ; i++) {
        scanf("%d%d%d",  & u,  & v,  & w); 
        s[u] ^= w, s[v] ^= w; 
    }
    for(int i = 0 ; i < n ; i++) sum[s[i]]++; 
    for(int i = 1 ; i < 16 ; i++) {
        ans += (sum[i] >> 1); 
        x += (1 << i) * (sum[i] & 1); 
    }
    memset(f, 127, sizeof(f)); 
    inf = f[0]; 
    printf("%d\n", ans + dfs(x)); 
    //system("pause");
    return 0; 
}

Measured memory_bytes: 896
l,r = map(int,input().split())
if r-l>=2019:
    print(0)
elif sum(i%2019==0 for i in range(l,r+1)) !=0:
    print(0)
else:
    print(min( (i*j)%2019 for i in range(l,r) for j in range(i+1,r+1)) )

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll,int>pii;
//struct _IO { _IO() { ios::sync_with_stdio(0); cin.tie(0); } }_io;
const ll mod=1e9+7;
const int maxn=2e5+10;
int fa[maxn],sz[maxn];
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++) fa[i]=i,sz[i]=1;
	int mx=1;
	for(int i=1;i<=m;i++){
		int x,y;
		cin>>x>>y;
		int fx=find(x);
		int fy=find(y);
		if(fx!=fy){
			fa[fx]=fy;
			sz[fy]+=sz[fx];
			mx=max(mx,sz[fy]);
		}
	}
	cout<<mx<<'\n';


}

Measured memory_bytes: 5172
N = gets.to_i
obj = Array.new(N+1)
obj[0] = [0,0,0]
pos = true
for i in 1..N
	obj[i] = gets.split(/\s/).map(&:to_i)
	d = obj[i][1] + obj[i][2] - obj[i-1][1] - obj[i-1][2]
	dt = obj[i][0] - obj[i-1][0]
	if (d > dt) or (d-dt)%2==1
		pos = false
	end
end

if pos==true
	puts "Yes"
else puts "No"
end

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

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

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
using namespace std;

const int MAX_N = 4005;

char s[10], S[MAX_N];
int st[MAX_N], top;

int query(int a, int b) {
  printf("? %d %d\n", a, b);
  fflush(stdout);
  scanf("%s", s);
  if (*s == 'Y') return 1;
  return 0;
}

int main() {
  int A, B, N;
  scanf("%d%d", &A, &B), N = A + B;

  if (A <= B) {
    puts("Impossible");
    fflush(stdout);
    return 0;
  }
  
  for (int i = 0; i < N; ++i) {
    if (top) {
      int x = query(st[top], i);
      if (!x) top--;
      else st[++top] = i;
    } else {
      st[++top] = i;
    }
  }

  int good = st[top];

  S[good] = '1';

  for (int i = 0; i < N; ++i)
    if (i != good)
      S[i] = query(good, i) + '0';

  printf("! ");
  for (int i = 0; i < N; ++i)
    putchar(S[i]);
  puts("");
  
  fflush(stdout);
  return 0;
}


Measured memory_bytes: 628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{
	int a,ans=0;
	for(int i=0;i<2;i++)
	{
		cin>>a;
		if(a==1)ans+=300000;
		else if(a==2)ans+=200000;
		else if(a==3)ans+=100000;
	}
	if(ans==600000)ans+=400000;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int m = s.size();
	int n = 1<<(m-1);
	
	long long ans = 0;
	for(int i = 0;i < n;i++)
	{
		long long t = s[0] - '0';
		for(int j = 0;j < m;j++)
		{
			if(j==m-1||i&1<<j)
			{
				ans+=t;
				t = 0;
				if(j==m-1)
				break;
			}
			t*=10;
			t+=s[j+1] - '0';
		}
	}
	cout << ans << endl;
	return 0;
}

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

///--->>> CONTAINERS <<<---///
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vector< ll > >;
using vpi = vector<pair<ll,ll> >;
using pi = pair<ll,ll>;
using st = set<ll>;
using stk = stack<ll>;
using kiwi = queue<ll>;
using pkiwi = priority_queue<ll>;
using mp = map<ll,ll>;
using ump = unordered_map<ll,ll>;

///--->>> MACROS<<<---///
const ll mx = 1e5+123;
#define MOD 1000000007
#define REP(i,n) for (ll i=1;i<=n;++i)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

///--->>>OPTIMIZE<<<---///
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

///--->>> DEBUGGER<<<---///
#define dbg(args...) do {cerr<<#args<<" : "; diraf(args); } while(0)
void diraf ()  {        cerr << endl;}
template < typename T, typename ... hello>void diraf( T arg, const hello &... rest) {cerr<<arg<< ' ';diraf(rest...);}

int main(){
    fastio;
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    string str; cin>>str; ll ans=0;
    for(auto& x:str)
        ans+=(x-'0');
    cout<<((ans%9)?"No":"Yes")<<endl;
return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define LL long long


using namespace std;

int a[15][15],vis[15][15];

struct node
{
    int x,y;
    node(int x,int y):x(x),y(y){}
};

queue<node>q;
int n,m;

int main()
{
    std::ios::sync_with_stdio(false);
    while (cin>>n>>m)
    {
        if (n==0 && m==0) break;
        int ans=0;
        for (int i=1;i<=n;i++)
            for (int j=1;j<=m;j++)
                cin>>a[i][j];
        for (int i=1;i<=n;i++)
            for (int j=1;j<=m;j++)
            {
                for (int ii=n;ii>=i+2;ii--)
                    for (int jj=m;jj>=j+2;jj--)
                    {
                        int H=1e9;
                        for (int x=i;x<=ii;x++) H=min(a[x][j],min(a[x][jj],H));
                        for (int y=j;y<=jj;y++) H=min(a[i][y],min(a[ii][y],H));

                        int flg=1,res=0;
                        for (int x=i+1;x<ii;x++)
                            if (flg) for (int y=j+1;y<jj;y++)
                            {
                                if (a[x][y]>=H) {res=0;flg=0;break;}
                                else res=res+H-a[x][y];
                            }
                        ans=max(ans,res);
                    }
            }
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef int64_t Int;
typedef pair<int,int> pii;
const int INF = 999999999;

vector<vector<int>> G(300010);
vector<int> dist(300010, INF);

void dijkstra(int s){
    // first:最短距離 second:頂点番号
    priority_queue<pii, vector<pii>, greater<pii>> q;
    dist[s] = 0;
    q.push(pii(0, s));

    while (!q.empty()){
        int cur_d = q.top().first;
        int cur_v = q.top().second;
        q.pop();

        if (cur_d > dist[cur_v]) continue;

        for (int i = 0; i < G[cur_v].size(); i++){
            int to = G[cur_v][i];
            if (dist[cur_v] + 1 < dist[to]){
                dist[to] = dist[cur_v] + 1;
                q.push(pii(dist[to], to));
            }
        }
    }
}


int main(){
    int N, M, S, T;
    cin >> N >> M;
    rep(i, M){
        int u, v; cin >> u >> v; u--; v--;
        G[3*u].push_back(3*v+1);
        G[3*u+1].push_back(3*v+2);
        G[3*u+2].push_back(3*v);
    }
    cin >> S >> T; S--; T--;

    dijkstra(3*S);

    if (dist[3*T] == INF){
        cout << -1 << endl;
    } else {
        cout << dist[3*T]/3 << endl;
    }    
}

Measured memory_bytes: 17792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,c,ans=0;cin>>a>>b>>c;
  if(a%2==0||b%2==0||c%2==0) ans=0;
  else {
    if(a>=b&&a>=c) ans=b*c;
    else if (b>=a&&b>=c) ans=c*a;
    else if (c>=a&&c>=b) ans=a*b;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <list>
#include <string>
#include <numeric>
#include <utility>
#include <cfloat>
#include <set>
 
using namespace std;

long long A[100000];
pair <long long, long long> CB[100000];
int main(){
    int N;
    int M;
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    sort(A, A + N);
    for(int i = 0; i < M; i++){
        int B;
        long long C;
        cin >> B >> C;
        CB[i] = make_pair(-C, B);
    }
    sort(CB, CB + M);

    int cur = 0;
    bool done = false;
    for(int i = 0; i < M; i++){
        for(int j = 0; j < CB[i].second; j++){
            if(A[cur] < - CB[i].first && cur < N){
                A[cur] = (-CB[i].first);
                cur ++;
            } else {
                done = true;
                break;
            }
        }
        if(done){
            break;
        }
    }
    cout << accumulate(A, A + N, (long long) 0) << endl;
    


    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000

int main(){
  char buf[1024];
  int H,W,h,w;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d %d", &H, &W);

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d %d", &h, &w);

  int ans=H*W-(h*W+w*H-h*w);
  printf("%d\n", ans);

  return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n*a, b) << endl;
	return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
int main(){
  int X;
  cin >> X;
  if(X == 2){
    cout << 2 << endl;
    return 0;
  }
  while(true){
    bool is_prime = true;
    for(int i = 2; i < sqrt(X) + 1; i++){
      if(X % i == 0){
        is_prime = false;
      }
    }
    if(is_prime){
      cout << X << endl;
      return 0;
    }
    X++;
  }
  return 0;
}


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

#define REP(i,n) for(int i=0; i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VC vector<char>
#define FOREACH(x,a) for(auto& (x) : (a) )
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << ((b - a)*(b - a - 1)) / 2 - a << 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)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

int main() {
    string s;
    cin >> s;
    int n = s.size() + 1;
    vector<int> l(n), r(n);
    for (int i=1; i<n; ++i) {
        if (s[i-1] == '<') l[i] = l[i-1] + 1;
    }
    for (int i=n-2; i>=0; --i) {
        if (s[i] == '>') r[i] = r[i+1] + 1;
    }
    long long ans = 0;
    rep(i, n) {
        ans += max(l[i], r[i]);
    }
    cout << ans << endl;
}

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

int main(){
	string s;
	while(cin>>s){
		int a[2]={0};
		for(int i=0;i+2<s.size();i++)
			if(s[i+1]=='O'&&s[i+2]=='I')
				if(s[i]=='J'||s[i]=='I')
					a[s[i]-'I']++;
		cout<<a[1]<<endl<<a[0]<<endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
const ll mod=998244353;
const double pi=acos(-1); 
int main()
{
	int k,a,b;
	sc(k);sc(a);sc(b);
	int biaoji=0;
	rep(i,a,b){
		if(i%k==0)biaoji=1;
	}if(biaoji==1){
		pf("OK\n");
	}else pf("NG\n");
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  ll A[N];
  ll ans = -1;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  ll GCD[N];
  ll revGCD[N];
  GCD[0] = A[0];
  revGCD[N-1] = A[N-1];
  for (int i = 1; i < N; i++) {
    GCD[i] = __gcd(GCD[i-1],A[i]);
  }
  for (int i = N - 2; i >= 0; i--) {
    revGCD[i] = __gcd(revGCD[i+1],A[i]);
  }
  for (int i = 0; i < N; i++) {
    ll res;
    if (i == 0) {
      res = revGCD[1];
    } else if (i == N - 1) {
      res = GCD[N-2];
    } else {
      res = __gcd(GCD[i-1],revGCD[i+1]);
    }
    ans = max(ans,res);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
const int size = 51;
int a[size];
int main ()
{
	int n; cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
		{
			ans += a[i] * a[j];
		}
	cout << ans << '\n';
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main(){
  int A,B,X;
  string ans;
  cin >> A >> B >> X;
  if (A<=X){
  if (X<=A+B)
    ans = "YES";
  else
    ans = "NO";
  }else
    ans = "NO";
  cout << ans <<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int k, x;
  cin >> k >> x;
  if (500*k >= x) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3576
#include <iostream>
 
constexpr int MOD = 1000000007;
 
int arr[200005];
long long pre_sum[200005];
 
int main()
{
	using std::cin;
	cin.sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n >> arr[0];
	pre_sum[0] = arr[0];
	long long ans = 0;
	for (int i = 1; i < n; i++)
	{
		cin >> arr[i];
		pre_sum[i] = pre_sum[i - 1] + arr[i];
	}
	for (int i = 0; i < n - 1; i++)
	{
		const long long sum_j = pre_sum[n - 1] - pre_sum[i];
		ans += arr[i] * (sum_j % MOD) % MOD;
		ans %= MOD;
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 5988
// ABC_123_A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
using namespace std;

#include <iostream>
#include <algorithm>

int main()
{
	int a = 0, b = 0, c = 0, d = 0, e = 0, ap = 0, bp = 0, cp = 0, dp = 0, ep = 0;
	cin >> a >> b >> c >> d >> e;
	while (1) {
		if (a % 10 != 0) {
			a++;
			ap++;
		}
		else
			break;
	}
	while (1) {
		if (b % 10 != 0) {
			b++;
			bp++;
		}
		else
			break;
	}
	while (1) {
		if (c % 10 != 0) {
			c++;
			cp++;
		}
		else
			break;
	}
	while (1) {
		if (d % 10 != 0) {
			d++;
			dp++;
		}
		else
			break;
	}
	while (1) {
		if (e % 10 != 0) {
			e++;
			ep++;
		}
		else
			break;
	}

	cout << a + b + c + d + e - max({ ap, bp, cp, dp, ep });

}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

int main(){
  int N, M; cin >> N >> M;
  int ans = 0;
  vector<int> s(M, 0);
  vector<int> p(M);
  for(int i = 0; i < M; i++){
    int k; cin >> k;
    for(int j = 0; j < k; j++){
      int tmp; cin >> tmp;
      s[i] = (s[i] | (1 << (tmp - 1)) );
    }
  }
  for(int i = 0; i < M; i++){
    cin >> p[i];
  }
  
  for(int bi = 0; bi < (1 << N); bi++){
    
    bool al = true;
    for(int i = 0; i < M; i++){
      int num = bi & s[i];
      int od = 0;
      for(int j = 0; j < N; j++){
        if((num >> j) & 1) od++;
      }
      if(od % 2 != p[i]) {
        al = false;
        break;
      }
    }
    if(al) ans++;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#!/usr/bin/perl

use strict;
use warnings;

my $n = <STDIN>;
my $s = <STDIN>;
chomp $s;

my $ans = 0;
for (my $i=0; $i<$n-2; $i++) {
    $ans++ if substr($s, $i, 3) eq "ABC";
}

print "$ans\n";

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T = ll> constexpr T TEN(int n) {return (n==0)?1:10*TEN<T>(n-1);}

ll calc(ll a, ll b, ll c) {
    if (a % 2 == 0) return 0;
    return b*c;
}

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans = min(min(calc(a, b, c), calc(b, c, a)), calc(c, a, b));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
N, M = map(int, input().split())
missed = {str(i): 0 for i in range(1, N + 1)}
answered = {}
for _ in range(M):
    idx_q, status = input().split()
    if status == 'AC':
        answered[idx_q] = 'AC'
    else:
        if idx_q not in answered:
            missed[idx_q] += 1
answered_num = len(answered)
missed_num = 0
for idx in answered.keys():
    missed_num += missed[str(idx)]
print(answered_num, missed_num)


Measured memory_bytes: 31844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;

int main() {
    ll A, B, M; cin >> A >> B >> M;
    ll AMIN=1e9, BMIN=1e9;
    vector<ll> a(A), b(B);
    for(int i = 0; i < A; i++) {cin >> a[i]; AMIN = min(a[i], AMIN);}
    for(int i = 0; i < B; i++) {cin >> b[i]; BMIN = min(b[i], BMIN);}
    set<pair<pair<ll, ll>, ll> > S;
    ll ans = AMIN + BMIN; 
    for(int i = 0; i < M; i++){
        int x, y, c; cin >> x >> y >> c;
        ll tmp = a[x-1] + b[y-1] - c;
        ans = min(ans, tmp);
    }
    cout << ans << endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define MAX 128
#define fst first
#define sec second
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define bit(n) (1LL<<(n))
#define int long long
const double PI = 3.141593;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double EPS = 1e-9;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }     //最小公倍数
ll combination(ll n, ll r)
{
  if (r * 2 > n)
    r = n - r;
  ll dividend = 1;
  ll divisor = 1;
  for (ll i = 1; i <= r; ++i)
  {
    dividend *= (n - i + 1);
    divisor *= i;
  }
  return dividend / divisor;
}


signed main()
{
  int dice[7];
  rep(i, 6)
  {
    cin >> dice[i + 1];
  }
  string s;
  cin >> s;
  rep(i, s.length())
  {
    char tmp= dice[1];
    if (s[i]== 'E')
    {
      dice[1] = dice[4];
      dice[4] = dice[6];
      dice[6] = dice[3];
      dice[3] = tmp;
    }
    else if (s[i]== 'N')
    {
      dice[1] = dice[2];
      dice[2] = dice[6];
      dice[6] = dice[5];
      dice[5] = tmp;
    }
    else if (s[i]== 'S')
    {
      dice[1] = dice[5];
      dice[5] = dice[6];
      dice[6] = dice[2];
      dice[2] = tmp;
    }
    else
    {
      dice[1] = dice[3];
      dice[3] = dice[6];
      dice[6] = dice[4];
      dice[4] = tmp;
    }
  }
  cout << dice[1] << endl;
  return 0;
}

/*
signed main()
{
  dice[7];
  rep(i, 6)
  {
    cin >> dice[++i];
  }

  int t;
  cin >> t;
  int top, front,right[t];
  rep(i, t)
  {
    cin >> top >> front;
    
  }

  return 0;
}
*/


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

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

int main(){
  ll A,B;
  cin >> A >> B;
  ll x=gcd(A,B);
  ll num=1;
  for(ll i=2;i*i<=x;i++){
    if(x%i==0){
      num++;
      while(x%i==0){
        x/=i;
      }
    }
  }
  if(x>1)num++;
  cout << num << endl;
      
}
      
  
  
  

Measured memory_bytes: 256
n, m = gets.chomp.split(" ").map(&:to_i)
h = gets.chomp.split(" ").map(&:to_i)
root = Array.new(n).map{Array.new}
ans = 0
m.times do
    a, b = gets.chomp.split(" ").map(&:to_i)
    root[a-1] << b
    root[b-1] << a
end

root.each_with_index do |arr, idx|
    if arr.empty? then
        ans += 1
        next
    end
    flag = true
    arr.uniq.each do |j|
        flag = false if h[idx] <= h[j-1]
    end
    if flag then
        ans += 1
    end
end

puts ans

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    int a;
    double sum = 0;
    rep(0, n) {
        cin >> a;
        sum += 1.0 / double(a);
    }

    cout << (1.0 / sum) << endl;

    return 0;
}


Measured memory_bytes: 384
//33
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>

using namespace std;

struct S{
  int t;
  vector<int> v;
  bool operator<(S a)const{
    return t>a.t;
  }
};

int fact(int x){
  return (x==1)?1:x*fact(x-1);
}

int dec(vector<int> v){
  vector<int> n(v.size());
  for(int i=0;i<n.size();i++){
    n[i]=i;
  }
  int r=0;
  for(int i=0;i<v.size();i++){
    r*=n.size();
    vector<int>::iterator it=find(n.begin(),n.end(),v[i]);
    r+=it-n.begin();
    n.erase(it);
  }
  return r;
}

int main(){
  int n;
  cin>>n;
  int cs[8][8];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin>>cs[i][j];
    }
  }
  vector<int> v(n);
  for(int i=0;i<n;i++){
    v[i]=i;
  }
  bool p[50000]={};
  int r=fact(n);
  S is={0,v};
  priority_queue<S> que;
  que.push(is);
  int lt;
  while(r){
    S c=que.top();
    que.pop();
    if(p[dec(c.v)]++)continue;
    r--;
    lt=c.t;
    for(int i=0;i<n;i++){
      for(int j=0;j<i;j++){
	S n=c;
	n.t+=cs[i][j];
	swap(n.v[i],n.v[j]);
	if(!p[dec(n.v)])
	que.push(n);
      }
    }
  }
  cout<<lt<<endl;
  return 0;
}

Measured memory_bytes: 44016
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int xs,ys,n,m;
ll a[200003];
ll b[2003];
bool vis[1009][1009];
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
    cin>>n;
    bool f=0;
    int nz=0;
    set<int>s;
    map<int,int>mp;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        int x=(a[i]+n-1)/2,y=n-1-x;
        if(x+y!=n-1)
            f=1;
        if(a[i]==0)
            nz++;
        if(a[i]!=0)
            s.insert(a[i]);
        mp[a[i]]++;
        if(mp[a[i]]>2)
            f=1;
    }
    if(f||nz>1)
        return cout<<0,0;
    ll ans=1;
    for(int i=1;i<=s.size();i++)
    {
        ans*=2;
        ans%=mod;
    }
    cout<<ans;

}


Measured memory_bytes: 10304
#include<cstdio>
#include <iostream>
using namespace std;
long long n,m,a[1015];
long long sum=0;
int num;
int main() {
	cin>>n>>m;
	n%=m;
	if(n-m>0)n=min(n,n-m);
	else n=min(n,m-n);
	cout<<n;
	return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

bool dp[100010];

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

    string word[4] = {"dream", "dreamer", "erase", "eraser"};
    dp[0] = true;
    rep(i, S.size()) {
        if (!dp[i]) continue; // i文字目までをうまく分割することができない

        for (string w: word) {
            if (S.substr(i, w.size()) == w) dp[i + w.size()] = true;
        }
    }
    cout << (dp[S.size()] ? "YES" : "NO") << endl;
}

Measured memory_bytes: 512
// #include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

typedef long long ll;
typedef pair<ll ,ll> pll;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

const ll mod = 1000000009;
const ll INF = 1e18;//1*10^18

ll powll(ll a,ll n){
  if(n==0)
  {
    return 1;
  }
  return powll(a,n-1)*a;
}

int ReturnDigit(ll num)
{
  string number=to_string(num);
  return number.length();
}

int main() {
  ll i,j,k,l;
  string n;
  cin >>n; 
  rep(i,3)
  {
    if(n[i]=='7')
    {
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"  <<endl;
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, k, a, z;
vector<int> neg, pos;
int l, r;
long long ans;

long long quickpow(long long b, int e)
{
	return e ? ((e & 1 ? b : 1)*quickpow(((b%MOD)*(b%MOD)) % MOD, e >> 1)) % MOD : 1;
}

void fun(int x, int y)
{
	long long tmp = 1;
	for (int i = 0; i < x; i++) {
		tmp *= -neg[i];
		tmp %= MOD;
	}
	for (int i = 0; i < y; i++) {
		tmp *= pos[i];
		tmp %= MOD;
	}
	ans = tmp;
}

void gun(int x, int y)
{
	ans *= -neg[x - 1];
	ans %= MOD;
	ans *= -neg[x - 2];
	ans %= MOD;
	ans *= quickpow(pos[y], MOD - 2);
	ans %= MOD;
	ans *= quickpow(pos[y + 1], MOD - 2);
	ans %= MOD;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a < 0) neg.pb(a);
		else if (a > 0) pos.pb(a);
		else z++;
	}
	int psz = pos.size();
	int nsz = neg.size();
	if (psz + nsz < k) {
		cout << 0 << E;
		return 0;
	}
	sort(neg.begin(), neg.end());
	sort(pos.begin(), pos.end());
	reverse(pos.begin(), pos.end());
	l = max(k - psz - z, 0);
	r = min(k, nsz);
	bool ok = false;
	for (int i = l; i <= r; i++) {
		if (i % 2) continue;
		int tmp = k - i;
		if (tmp > psz) continue;
		if (!ok) {
			ok = true;
			fun(i, tmp);
		}
		else {
			long long tn = neg[i - 1] *1LL* neg[i - 2];
			//tn = -tn;
			long long tp = pos[tmp] *1LL* pos[tmp + 1];
			if (tn > tp) gun(i, tmp);
			else break;
		}
	}
	if (ok) {
		cout << ans << E;
	}
	else if (z > 0) {
		cout << 0 << E;
	}
	else {
		reverse(neg.begin(), neg.end());
		reverse(pos.begin(), pos.end());
		for (int i = l; i <= r; i++) {
			if (i % 2 == 0) continue;
			int tmp = k - i;
			if (tmp > psz) continue;
			if (!ok) {
				ok = true;
				fun(i, tmp);
			}
			else {
				long long tn = neg[i - 1] *1LL* neg[i - 2];
				//tn = -tn;
				long long tp = pos[tmp] *1LL* pos[tmp + 1];
				if (tn > tp) break;
				else gun(i, tmp);
			}
		}
		if (ans > 0) ans = MOD - ans;
		cout << ans << E;
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 4204
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 1000001;
const int MOD =  998244353;
const int INV2 = (MOD+1)/2;

     signed main(){
       
        int a=100,x;
        cin>>x;
        int t=0;
        while(x>a){
          a=(a*1.01);
          t++;
        }
        cout<<t<<endl;
 




}


        


Measured memory_bytes: 3632
#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>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
void p753() {
	int x;
	cin >> x;
	if (x == 5 || x == 7 || x == 3) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;
}
int main() {

	p753();
	return 0;
}


Measured memory_bytes: 256
/**
 *	@file: A.cpp
 *	@author: Huy Le
 *	@created: 08-17-2020 10:29:18
**/


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

#define ll long long
#define ld long double
#define sz(x) (int)(x).size()
const char newl = '\n';

int ts;
string s;

void solve() {
	cin >> s;
	int cnt=0, ans=0;
	for(int i=0; i<sz(s); ++i) {
		if(s[i] == 'R')
			++cnt;
		else {
			ans = max(ans, cnt);
			cnt=0;
		}
	}
	ans = max(ans, cnt);
	cout << ans << newl;
}

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

	//cin >> ts;
	//while(ts--)
		solve();
}


Measured memory_bytes: 3652
#include<stdio.h>

#define H 251
#define NIL 2000000001

main(){
  int i,n,heap[H];

  for(i=0;i<H;i++){
    heap[i]=NIL;
  }
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&heap[i]);
  }

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,heap[i]);
    if(heap[i/2]!=NIL) printf("parent key = %d, ",heap[i/2]);
    if(2*i<=n && heap[2*i]!=NIL) printf("left key = %d, ",heap[2*i]);
    if(2*i+1<=n && heap[2*i+1]!=NIL) printf("right key = %d, ",heap[2*i+1]);
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
  char suit;
  int value;
} Card;


void ChkIfStable(Card *c1, Card *c2, int n)
{
  int v, k;
  char a1[n];
  char a2[n];
  int len1, len2;
  len1 = len2 = 0;
  for (v=1; v<10; v++) {
    len1=0;
    for (k=0; k<n; k++) {
      if (c1[k].value == v) a1[len1++] = c1[k].suit;
    }
    a1[len1]=0;
    len2=0;
    for (k=0; k<n; k++) {
      if (c2[k].value == v) a2[len2++] = c2[k].suit;
    }
    a2[len2]=0;
    if (strcmp(a1,a2)) {
      fputs("Not stable\n", stdout);
      return;
    }
  }
  fputs("Stable\n", stdout);
}


void BubbleSort(Card *c, int n)
{
  int i, j;
  for (i=0; i<n; i++) {
    for (j=n-1; j>=i+1; j--) {
      if (c[j].value < c[j-1].value) {
	Card tmp = c[j];
	c[j] = c[j-1];
	c[j-1] = tmp;
      }
    }
  }
}


void  SelectionSort(Card *c, int n)
{
  int i, j, mini;
  for (i=0; i<n; i++) {
    mini = i;
    for (j=i; j<n; j++) {
      if (c[j].value < c[mini].value)	mini = j;
    }
    if (i!=mini) {
      Card tmp = c[i];
      c[i] = c[mini];
      c[mini] = tmp;
    }
  }
}

int main()
{
  int i, n;
  char buf[128];
  fgets(buf, 128, stdin);
  if (buf[1]=='\n') {
    n = buf[0]-'0';
  } else {
    n = (buf[0]-'0')*10+buf[1]-'0';
  }
  Card *cc = (Card*)malloc(sizeof(Card)*n);
  Card *bs = (Card*)malloc(sizeof(Card)*n);
  Card *ss = (Card*)malloc(sizeof(Card)*n);
  fgets(buf, 128, stdin);
  char *p = buf;
  for (int i=0; i<n; i++) {
    cc[i].suit = bs[i].suit = ss[i].suit = *p;
    cc[i].value = bs[i].value = ss[i].value = *(p+1)-'0';
    p+=3;
  }

  BubbleSort(bs, n);
  
  for (i=0; i<n-1; i++)
    fprintf(stdout, "%c%d ", bs[i].suit, bs[i].value);
  fprintf(stdout, "%c%d\n", bs[i].suit, bs[i].value);

  ChkIfStable(cc, bs, n);
  
  SelectionSort(ss, n);

  for (i=0; i<n-1; i++)
    fprintf(stdout, "%c%d ", ss[i].suit, ss[i].value);
  fprintf(stdout, "%c%d\n", ss[i].suit, ss[i].value);
  
  ChkIfStable(cc, ss, n);
  return 0;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;cin>>n;
	vector<int> v(n + 1);
	for(int i = 0; i < n; i++) {
		int a,b;cin>>a>>b;
		v[i] = a;
		if (i == n - 1){
			v[i + 1] = b;
		}
	}
	vector<vector<int>> dp(n,vector<int>(n,INF));
	for(int i = 0; i < n; i++) {
		dp[i][i] = 0;
	}

	for(int l = 1; l < n; l++) {//連鎖の大きさ(iとｊの幅)(j - i)
		for(int i = 0; i < n - l; i++) {
			int j = i + l;
			for(int k = i; k < j; k++) {
				dp[i][j] = min(dp[i][j],dp[i][k] + dp[k + 1][j] + v[i] * v[k + 1] * v[j + 1]);
			}
		}
	}
	cout << dp[0][n - 1] << endl;
	// for(int i = 0; i < n; i++) {
	// 	for(int j = 0; j < n; j++) {
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	return 0;
}


Measured memory_bytes: 3192
function Main(input) {
	input = input.split("\n");
	var a = parseInt(input[0], 10);
	var b = parseInt(input[1], 10);
	var h = parseInt(input[2], 10);
	var s = (a+b)*h/2;
	console.log('%d',s);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

template<class T>
void printcontainer(T& con) {
	bool first = true;
	for (auto &t : con) {
		if (first)
			first = false;
		else
			cout << " ";
		cout << t;
	}
	cout << endl;
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	FOR(i, 0, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	int t = -1;
	int cnt = 1;
	int syu = 0;
	int total = 0;
	FOR(i, 0, n) {
		if (a[i] != t) {
			t = a[i];
			total += cnt - 1;
			cnt = 0;
		}
		cnt++;
	}
	total += cnt - 1;

	cout << n - (total + 1) / 2 * 2 << endl;
	return 0;
}

Measured memory_bytes: 640
input_number = int(input())
walk_count = int(1000000000000)
number_list_A = range(1,1000001)
#number_list_B = number_list_A

for a in number_list_A:
	if input_number % a == 0:
		b = input_number / a
		new_walk_count = int(a + b - 2)
	if new_walk_count < walk_count:
		walk_count = new_walk_count
	new_walk_count = 1000000000000

print(walk_count)


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

using namespace std;

const int INF = 1 << 29;


int N, M;
int A[2000], B[2000], C[2000];
int g[100][100];

int main()
{
  fill_n(*g, 100 * 100, INF);

  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    cin >> A[i] >> B[i] >> C[i];
    g[--A[i]][--B[i]] = C[i];
    g[B[i]][A[i]] = C[i];
  }

  for(int k = 0; k < N; k++) {
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < N; j++) {
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }

  int vv = 0;
  for(int i = 0; i < M; i++) {
    if(g[A[i]][B[i]] != C[i]) ++vv;
  }
  cout << vv << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long int ll;
int main()
{
  string S; cin >> S;
 
  const int N = 13;
  ll dp[N]{0};
  dp[0] = 1;
  ll digit = 1;
  for (ll i = S.size()-1; i>=0; i--) 
  {
    ll nextdp[N]{0};
 
    if (S.at(i) == '?') {
      //?の場合
      for (int k=0; k<10; k++) {
        for (ll j=0; j<N;j++) {
         nextdp[(k*digit+j)%N] += dp[j];
         nextdp[(k*digit+j)%N] %= MOD;
        }
      }
    } else {
      int k = (S.at(i) - '0');
      for (int j=0; j<N;j++) {
        nextdp[(k*digit+j)%N] += dp[j];
        nextdp[(k*digit+j)%N] %= MOD;
      }
    }
    
    for (int i=0; i<N; i++) {
      dp[i] = nextdp[i];
    }
    digit *= 10;
    digit %= N;
  }
  
  stringstream ss;
  for (auto num : dp) ss << num;
  cout << dp[5] << endl;
}

Measured memory_bytes: 512