akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE OverloadedLists     #-}
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}

import           Control.Monad
import           Data.IORef
import           Data.Maybe
import qualified Data.Text     as T
import qualified Data.Text.IO  as T
import           GHC.Base
import           System.IO

import qualified Data.Array    as A
import qualified Data.IntMap   as I
import           Data.List
import qualified Data.Map      as M
import qualified Data.Set      as S
import qualified Data.Vector   as V

-- main
main :: IO ()
main = march

march :: IO ()
march = do
  n  :: Int <- readLn
  ss :: V.Vector T.Text <- V.replicateM n T.getLine
  let ms  = V.filter (\s -> T.head s /= 'M') ss
      lms = V.length ms
      m   = V.length ss - lms
      as  = V.filter (\s -> T.head s /= 'A') ms
      las = V.length as
      a   = lms - las
      rs  = V.filter (\s -> T.head s /= 'R') as
      lrs = V.length rs
      r   = las - lrs
      cs  = V.filter (\s -> T.head s /= 'C') rs
      lcs = V.length cs
      c   = lrs - lcs
      hs  = V.filter (\s -> T.head s /= 'H') cs
      lhs = V.length hs
      h   = lcs - lhs
      rc = r + c
      ma = m + a
  print $ m * a * (rc + h) + r * c * (ma + h) + h * rc * ma

Measured memory_bytes: 26492
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main() {
	int n;
	cin >> n;
	int a[n];
	rep (i, n) cin >> a[i];

	int ans = 0;
	rep (i, n) ans = __gcd(ans, a[i]);

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import math

line_1= input().split(' ')
A= int(line_1[0])
B= int(line_1[1])
H= int(line_1[2])
M= int(line_1[3])

M_ang=M/60*2*math.pi
H_ang= (H+M/60)*2*math.pi/12
angle= abs(H_ang-M_ang)
l= (A**2+B**2-2*A*B*math.cos(angle))**0.5

print(l)

Measured memory_bytes: 9380
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll n,ans=0,A[401],dp[401][401][2]={0},inf=1e18;
int main(){
    cin>>n;
    rep(i,n) cin>>A[i];
    rep(i,n)rep(j,n-i){
        if(i==0) dp[1][j][0]=A[j];
        else dp[i+1][j][1]=inf;
        rep(k,i){
            ll x=dp[i+1][j][1];
            dp[i+1][j][1]=min(dp[i+1][j][1],dp[i-k][j][0]+dp[k+1][j+i-k][0]+dp[i-k][j][1]+dp[k+1][j+i-k][1]);
            if(x!=dp[i+1][j][1]) dp[i+1][j][0]=dp[i-k][j][0]+dp[k+1][j+i-k][0];
        }
    }
    cout<<dp[n][0][1]<<"\n";
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n, m;
		int map[], xi;
		int a;
		int count;

		n = sc.nextInt();
		m = sc.nextInt();
		while (n + m != 0) {
			count = 0;
			a = 0;
			map = new int[n];
			for (int i = 0; i < n; i++) {
				map[i] = sc.nextInt();
			}
			for (int i = 0; i < m; i++) {
				xi = sc.nextInt();
				if (a < n - 1) {
					count++;
				}
				a += xi;
				if (a < n - 1) {
					a += map[a];
				}
			}
			System.out.println(count);
			n = sc.nextInt();
			m = sc.nextInt();
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll money=1000,kabu=0;
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    rep(i,n-1){
        if(a[i]<a[i+1]){
            kabu=money/a[i];
            money%=a[i];
            money+=kabu*a[i+1];
        }
    }
    cout<<money<<endl;
}

Measured memory_bytes: 3592
//Awwawa! Dis cold yis ratten buy waxberry!
#include <bits/stdc++.h>
#define ll long long
#define maxn 100005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

using namespace std;
char inp[30]; 
int main() {
	scanf("%s", inp + 1);
	inp[4] = '\0';
	cout << inp + 1 << endl;
	return 0;
}


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

int main() {
    string o,e,ans="";
    cin>>o>>e;
    int n=o.size()+e.size();
    rep(i,n) {
        if (i%2==0) {
            ans.push_back(o[0]);
            o.erase(0,1);
        } else {
            ans.push_back(e[0]);
            e.erase(0,1);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

bool a[111];

int main(void){
	int n,i,d[2];
	std::cin >> n;
	for(i=0; i<n; ++i){
		std::cin >> d[0] >> d[1];
		a[i] = (d[0]==d[1]);
	}
	for(i=2; i<n; ++i){
		if(a[i-2]&&a[i-1]&&a[i]){
			std::cout << "Yes" << std::endl;
			return 0;
		}
	}
	std::cout << "No" << std::endl;
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
//struct area

//function area

//main area
int main(){
    int x;
    cin >> x;
    int ans = 1;
    for(int i=2; i<32; i++){
        int kari_ans = i*i;
        while(kari_ans <= x){
            ans = max(ans, kari_ans);
            kari_ans *= i;
        }
    }
    cout << ans << endl;
}
/*



*/

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

int main()
{
    int x, y;

    while (cin >> x >> y) {
        if (x == 0 && y == 0) {
            break;
        }

        if (x >= y) {
            cout << y << " " << x << endl;
        }
        else {
            cout << x << " " << y << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3076
s = input()
t = input()

max_val = 0
index = 0
for i in range(len(s)- len(t) + 1):
    val = 0
    for c in range(len(t)):
        if s[i + c] == t[c]:
            val += 1
            if val > max_val:
                max_val = val
                index = [i]

print(len(t) - max_val)

Measured memory_bytes: 9060
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.reverse()
ans = 0

for i in range(n):
    ab[i][0] += ans
    cnt = ab[i][1] - (ab[i][0] % ab[i][1])
    if ab[i][0] % ab[i][1] != 0:
        ans += cnt
print(ans)

Measured memory_bytes: 31348
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vi  vector<int>
#define pb  push_back
#define mp  make_pair
#define ALL(x) x.begin(),x.end()
#define M(a,x) memset(a,x,sizeof(a))
#define sci(x) scanf("%d",&x);
#define scl(x) scanf("%lld",&x);
#define scs(x) scanf("%s",x);
#define SZ(x) (int)x.size()
#define print(x) printf("%d",x);
#define nl printf("\n")
#define fr first
#define se second
#define printl(x) printf("%lld",x)
#define F(i,a,n) for(int i=a;i<n;i++)
#define INF 100000000000000000LL
#define LL long long

const int N = 1e5+5;
int a[N];
int main() {
  int n;
  cin >> n;
  n = 2*n;
  F(i,0,n) cin >> a[i];
  int ans = 0;
  sort(a,a+n);
  for(int i = 0 ; i < n ; i+=2) {
    ans += min(a[i],a[i+1]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>

int main(void){
    int N;
    std::cin >> N;

    int rr = N % 10;

    switch(rr){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            std::cout << "hon" << std::endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            std::cout << "pon" << std::endl;
            break;
        case 3:
            std::cout << "bon" << std::endl;
            break;
    }

    return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>

int main(void)
{
    for (;;) {
        int n, i, j, a[5000];
        int max = -1000000;

        scanf("%d", &n);
        if (n == 0) break;

        for (i = 0; i < n; i++)
            scanf("%d", &a[i]);

        for (i = 0; i < n; ++i) {
            int sum = 0;
            for (j = i; j < n; ++j) {
                sum += a[j];
                if (sum > max) max = sum;
            }
        }

        printf("%d\n", max);
    }

    return 0;
}

Measured memory_bytes: 620
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    ll a, b, c, n, k, x;
    string s, t;
    ll ans = 0;
    double dans = 0;
    string sans = "";



    cin  >> a >> b;
    ll length = max(a,b) - min(a,b);
    if(length%2 == 1) cout << "IMPOSSIBLE";
    else {
        ll ans1 = max(a,b) - length/2;
        ll ans2 = max(a,b) + length/2;

        ll tmp1 = max(min(a,b) - ans1, ans1 - min(a,b));
        ll tmp2 = max(min(a,b) - ans2, ans2 - min(a,b));

        if(tmp1 == length/2) std::cout << ans1 << endl; 
        else if(tmp2 == length/2) std::cout << ans2 << endl; 
        else  cout << "IMPOSSIBLE";
    }




    // std::cout << ans << endl; 
    // std::cout << sans << endl; 
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	int a,b;
	std::cin >> a >> b;
	if (a == b) {
		std::cout << "Draw" << '\n';
	}
	else if (a == 1) {
		std::cout << "Alice" << '\n';
	}
	else if (b == 1) {
		std::cout << "Bob" << '\n';
	}
	else if (a > b) {
		std::cout << "Alice" << '\n';
	}
	else {
		std::cout << "Bob" << '\n';
	}
	return 0;
}


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

int main() 
{
    string S, T;
    cin >> S >> T;
    
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (S[i] == T[i]) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <cstdlib>
using namespace std;
// #define int long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

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

const int N = 110;
pii v[N], pos{0, 0};
int n;

double norm(pii p) {return sqrt((ll)p.first*p.first+(ll)p.second*p.second);}

signed main() {
	srand(time(NULL));
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cin >> n;
    REP(i, n) cin >> v[i].first >> v[i].second;
    const int trials = 1e4;
    double best = 0;
    REP(t, trials) {
    	random_shuffle(v, v+n);
    	pos = {0, 0};
    	REP(i, n) {
    		if(norm({pos.first+v[i].first, pos.second+v[i].second}) > norm(pos)) {
    			pos.first += v[i].first;
    			pos.second += v[i].second;
    		}
    	}
    	best = max(best, norm(pos));
    }
    cout << best << endl;

    return 0;
}

// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE)
// - .size()-k underflow (WA, RTE, TLE)
// - small n edge cases (WA)

// Rare mistakes made in the past:
// - division by 0 (WA)
// - integer division (WA)
// - setprecision (WA)
// - INF not big enough using ll (WA)
// - setting max to 0 instead of -INF/min to 0 instead of INF (WA)
// - outputting debug (WA)
// - allocating too much memory (locRTE, MLE)
// - stack size (locRTE)
// - round announcements (WA)
// - multiset::erase (WA)



Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

ans=0
for i in range(n-1):
  ans+=abs(a[i]-a[i+1])
ans+=abs(a[0])+abs(a[-1])

a.insert(0,0)
a.append(0)

for i in range(1,n+1):
  tmp=ans
  x=abs(a[i+1]-a[i-1])
  y=abs(a[i+1]-a[i])+abs(a[i]-a[i-1])
  tmp-=y-x
  print(tmp)

Measured memory_bytes: 14048
#include <stdio.h>
int main(void){
  int n,i,cnt=0,a[101000];
  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d",&a[i]);
  for(i=1;i<=n;i++) if(a[a[i]]==i) cnt++;
  printf("%d",cnt/2);
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n,q;
  cin>>n>>q;
  vll s(n),t(n),x(n);
  REP(i,n)cin>>s[i]>>t[i]>>x[i];

  vll d(q);
  REP(i,q)cin>>d[i];

  //-1:insert
  //0:delete
  //1:ans
  vector<tuple<ll,ll,ll>> v;
  REP(i,n){
    s[i]-=x[i];
    t[i]-=x[i];
    v.push_back(forward_as_tuple(s[i],-1,x[i]));
    v.push_back(forward_as_tuple(t[i],0,x[i]));
  }
  REP(i,q)
    v.push_back(forward_as_tuple(d[i],1,i));

  sort(v.begin(), v.end());

  vll dist(q,-1);
  multiset<ll> se;
  REP(i,v.size()){
    ll l,q,w;
    tie(l,q,w) = v[i];
    if(q==-1)se.insert(w);
    if(q==0)se.erase(se.lower_bound(w));
    if(q==1 && !se.empty())
      dist[w] = *se.begin();
  }

  REP(i,q)
    cout<<dist[i]<<endl;

}


Measured memory_bytes: 34148
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LLong_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;



int main() {
     ll a,b,r,x,tmp;
    cin >> a >> b;
    x = a*b;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }

    /* ユークリッドの互除法 */
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    cout << x/b << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    ll n, k;
    cin>>n>>k;
    vector<ll> as(n);
    ll s = 0;
    rep(i, n) {
        cin>>as[i];
        s += as[i];
    }

    vector<ll> div;
    for (int i = 1; i * i <= s; ++i) {
        if (s % i == 0) {
            div.push_back(i);
            if (i * i != s) div.push_back(s / i);
        }
    }

    sort(div.rbegin(), div.rend());
    ll ans = 0;
    for (auto d : div) {
        vector<ll> bs(n);
        copy(as.begin(), as.end(), bs.begin());
        rep(i, n) bs[i] %= d;
        sort(bs.rbegin(), bs.rend());
        ll s = 0;
        rep(i, n) s += bs[i];

        ll cnt = 0;
        rep(i, n) {
            s -= bs[i];
            s -= d - bs[i];
            cnt += d - bs[i];
            if (s == 0 && cnt <= k) {
                cout<<d<<endl;
                return 0;
            }
        }
    }
    cout<<1<<endl;
}

Measured memory_bytes: 256
module IntSet = Set.Make (struct
  type t = int
  let compare = compare
end)

let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let abcs = Array.init (n - 1) (fun _ -> Scanf.scanf "%d %d %d\n" (fun a b c -> a, b, c)) in
  let q, k = Scanf.scanf "%d %d\n" (fun q k -> q, k) in
  let xys = Array.init q (fun _ -> Scanf.scanf "%d %d\n" (fun x y -> x, y)) in
  let es = Array.make n [] in
  Array.iter (fun (a, b, c) ->
    es.(a - 1) <- (b - 1, c) :: es.(a - 1);
    es.(b - 1) <- (a - 1, c) :: es.(b - 1)) abcs;
  let d = Array.make n 0 in
  let rec dfs vs v =
    List.fold_left (fun vs (u, c) ->
      if (IntSet.mem u vs)
      then vs
      else (d.(u) <- c + d.(v); dfs vs u)) (IntSet.add v vs) es.(v) in
  ignore (dfs IntSet.empty (k - 1));
  Array.iter (fun (x, y) ->
    Printf.printf "%d\n" (d.(x - 1) + d.(y - 1))) xys

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

using namespace std;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    string sep;
    for (const auto &x : v)
        os << sep << x, sep = ", ";
    return os << '}';
}
template <typename T, size_t size>
ostream &operator<<(ostream &os, const array<T, size> &arr)
{
    os << '{';
    string sep;
    for (const auto &x : arr)
        os << sep << x, sep = ", ";
    return os << '}';
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}

// #define DEBUG
#ifdef DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main()
{
    ios::sync_with_stdio(false);
#ifndef DEBUG
    cin.tie(nullptr);
#endif
    int n;
    cin >> n;
    int count = 0;
    for (int B = 1; B < n; B++)
    {
        int countA = n / B;
        if (n % B == 0)
        {
            countA--;
        }
        countA = min(B, countA);
        count += 2 * countA - (countA == B ? 1 : 0);
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

using namespace std;

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0)
  {
    if(y%2) res=(x*res)%hell;
    x=(x*x)%hell;
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();

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

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);


/*class CompareDist
{
public:
    bool operator()(pair<ll,int> a,pair<ll,int> b) {
        if(a.F!=b.F)
        return a.F<b.F;
        else
        return a.S>b.S;
    }
};*/

bool comp(pair<ll,ll> a,pair<ll,ll> b){
  if(a.S!=b.S)
  return (a.S<b.S);
  else
  return a.F<b.F;
}

void solve(){

  int test;
  //cin>>test;
  test=1;

  while(test--){
    int n,m;
    cin>>n>>m;

    string s;
    cin>>s;

    n++;
    vi vec;
    int start=n-m-1;
    int end=n-1;
    bool flag=true;

    while(end>=0){
        bool f=false;

        for(int i=start;i<end;i++){
          if(s[i]=='0'){
            vec.pb(end-i);
            //cout<<i<<" ";
            end=i;
            start=max(0,i-m);
            f=true;
            break;
          }
        }
        if(!f)
        {
          flag=false;
          break;
        }
        if(end==0)
        break;
    }
    if(!flag)
    {
      cout<<-1;
    }
    else
    {
      for(int i=vec.size()-1;i>=0;i--){
        cout<<vec[i]<<" ";
      }
    }
  }

}



/*bool issafe(int x,int y){
  return (x>=0 && y>=0 && x<n && y<m);
}*/

///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll x,ll y){
  if(x==0)
  return y;
  else
  return gcd(y%x,x);
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}

/*void sieve(){

  for(int i=2;i<=1000000;i++){
    if(prime[i]==true){
      for(int j=i*i;j<=1000000;j+=i)
      prime[j]=false;
    }
  }

}*/


Measured memory_bytes: 1096
N,M=map(int,input().split())
sums=[[]for _ in[0]*8]
for _ in[0]*N:
    c=list(map(int,input().split()))
    for t in range(8):
        sums[t]+=[sum(c[i]*[-1,1][t&(1<<i)>0]for i in range(3))]
if M:print(max(sum(sorted(x)[-M:])for x in sums))
else:print(0)

Measured memory_bytes: 3316
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
const int INF = 1e9;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
//typedef pair<int, int> P;

/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */


/** 幾何ライブラリ **/
#include <complex>

#define X real()
#define Y imag()

const double EPS = 1e-11;

typedef double D;
typedef complex<D> P; // Point

struct L { // Line
	P a, b;
	L(){}
	L(P aa, P bb) : a(aa), b(bb){}
};

// 共役複素数 conj(a);

// 符号
int sig(D a, D b=0) { return a < b - EPS ? -1 : (a > b + EPS ? 1 : 0); }

// 内積
D dot(P a, P b) { return (conj(a)*b).real(); }

// 外積
D cross(P a, P b) { return (conj(a)*b).imag(); }

// 線分abに対する点cの位置
enum CCW{LEFT=1, RIGHT=-1, BACK=2, FRONT=-2, ON=0};
int ccw(P a, P b, P c)
{
	b -= a, c -= a;
	D s = sig(cross(b, c));
	if (s) return s>0 ? LEFT : RIGHT;
	if (sig(dot(b, c))<0) return BACK;
	if (sig(abs(c), abs(b))>0) return FRONT;
	return ON;
}

// 直線lに対する点pの写像
P projection(L l, P p)
{
	return l.a + (l.b-l.a)/abs(l.b-l.a) * dot(l.b-l.a, p-l.a)/abs(l.b-l.a);
}

// 直線lに対する点pの反射
P reflection(L l, P p)
{
	return p + (projection(l, p)-p)*P(2, 0);
}

// 直線abと点cの距離
D distLP(L l, P c)
{
	return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
}

// 線分abと点cの距離
D distSP(L l, P c)
{
	if (sig(dot(l.b-l.a, c-l.a))<0) return abs(c-l.a);
	if (sig(dot(l.a-l.b, c-l.b))<0) return abs(c-l.b);
	return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
}

// 線分と線分の交差判定
bool iSS(L s, L t)
{
	return (ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0)
			&& (ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0);
}

// 線分と線分の距離
D distSS(L s, L t)
{
	if (iSS(s, t)) return 0;
	return min(min(distSP(t, s.a), distSP(t, s.b)), min(distSP(s, t.a), distSP(s, t.b)));
}

// 線分と線分の交点 (公差していることが前提)
P cSS(L s, L t)
{
	D d1 = distLP(t, s.a);
	D d2 = distLP(t, s.b);
	D tmp = d1 / (d1 + d2);
	return s.a + (s.b-s.a)*tmp;
}

// 直線と直線の交差判定
bool iLL(L s, L t)
{
	return sig(cross(s.b-s.a, t.b-t.a))!=0;
}


/** Problem CGL1_B : Reflecton **/
int main()
{
	P a, b, c;
	cin>>a.X>>a.Y;
	cin>>b.X>>b.Y;
	
	int q; cin>>q;
	rep(i, q) {
		cin>>c.X>>c.Y;
		cout << fixed << setprecision(15);
		cout << reflection(L(a, b), c).X << " " << reflection(L(a, b), c).Y << endl;
	}
}

Measured memory_bytes: 1320
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	static int lower_bound(int a[],int key) {
		int right=a.length;
		int left=0;
		while(right-left>1) {
			int mid=(right+left)/2;
			if(a[mid]<key) {
				left=mid;
			}
			else {
				right=mid;
			}
		}
		return left;
	}
	static int upper_bound(int a[],int key) {
		int right=a.length;
		int left=0;
		while(right-left>1) {
			int mid=(right+left)/2;
			if(a[mid]<=key) {
				left=mid;
			}
			else {
				right=mid;
			}
		}
		return left;
	}

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

		int n = stdIn.nextInt();

		int[] L = new int[n];

		for(int i = 0; i < n; i++) {
			L[i] = stdIn.nextInt();
		}

		Arrays.parallelSort(L);

		long cnt = 0;

		for(int i = 0; i < n; i++) {
			for(int j = i+1; j < n-1; j++) {

				int a = L[i] + L[j];

				cnt += lower_bound(L,a) - j;

			}
		}
		System.out.println(cnt);


	}

}



Measured memory_bytes: 26592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

int main(){
  string s;
  cin>>s;
  ll k;
  cin>>k;
  int L=s.length();
  for(int i=0;i<L;i++){
    int x='z'-s[i]+1;
    if(x==26) continue;
    else{
      if(k>=x){
        s[i]='a';
        k-=1LL*x;
      }
    }
  }
  k%=26;
  while(k>0){
    k--;
    if(s[L-1]=='z') s[L-1]='a';
    else{
      char x=s[L-1]+1;
      s[L-1]=x;
    }
  }
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

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

  ll ans=0;
  ll i=1;
  while(1){
    if(H==1){
      ans+=i;
      break;
    }
    ans+=i;
    H=H/2;
    i*=2;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
s = input()
if s=='SAT':
    print(1)
elif s=='SUN':
    print(7)
elif s=='MON':
    print(6)
elif s=='TUE':
    print(5)
elif s == 'WED':
    print(4)
elif s == 'THU':
    print(3)
elif s == 'FRI':
    print(2)


Measured memory_bytes: 2940
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAXN 100010
int Adj[MAXN],V[MAXN*2],nxt[MAXN*2],c;
void AddEdge(int u,int v)
{
	c++;V[c]=v,nxt[c]=Adj[u];Adj[u]=c;
}
int vis[MAXN],st[MAXN],col[MAXN],dis[MAXN],cnt,sd[MAXN];
void BFS(int s,int d,int C)
{
	if(dis[s]>=d) return;
	dis[s]=d,vis[s]=cnt;
	if(col[s]==0) col[s]=C;
	int l=0,r=0;
	st[r]=s;
	sd[r++]=0;
	while(l<r)
	{
		int u=st[l];
		if(sd[l++]==d) continue;
		int nd=d-sd[l-1]-1;
		for(int i=Adj[u];i;i=nxt[i])
			if(vis[V[i]]!=cnt)
			{
				int v=V[i];
				vis[v]=cnt;
				if(dis[v]>=nd) continue;
				if(col[v]==0) col[v]=C;
				dis[v]=nd;
				st[r]=v;
				sd[r++]=sd[l-1]+1;
			}
	}
}
int n,m,s[MAXN],d[MAXN],C[MAXN];
int main()
{
	scanf("%d%d",&n,&m);
	memset(dis,-1,sizeof dis);
	int u,v;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		AddEdge(u,v);
		AddEdge(v,u);
	}
	scanf("%d",&cnt);
	for(int i=1;i<=cnt;i++)
		scanf("%d%d%d",&s[i],&d[i],&C[i]);
	while(cnt)
	{
		BFS(s[cnt],d[cnt],C[cnt]);
		cnt--;
	}
	for(int i=1;i<=n;i++)
		printf("%d\n",col[i]);
}

Measured memory_bytes: 5632
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
using namespace std;
using vi = vector<int>;
int main(){
  int a,b;
  vi c = {1,3,5,7,8,10,12};
  vi d = {4,6,9,11};
  vi e = {2};
  cin >> a >> b;
  bool flag = false;
  if(find(ALL(c),a) != c.end() && find(ALL(c),b) != c.end()) flag = true;
  if(find(ALL(d),a) != d.end() && find(ALL(d),b) != d.end()) flag = true;
  if(find(ALL(e),a) != e.end() && find(ALL(e),b) != e.end()) flag = true;
  if(flag) puts("Yes");
  else puts("No");
}



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

const int N=100;

int main(){
	int n;
	long m[N+1][N+1], p[N+1];
	
	scanf(" %d", &n);
	for(int i=1; i<=n; ++i)
		scanf(" %ld %ld", &p[i-1], &p[i]);
		
	for(int i=1; i<=n; ++i) m[i][i]=0;
	
	for(int s=2; s<=n; ++s){
		for(int i=1; i+s-1<=n; i++){
			int j=i+s-1;
			m[i][j]=100000000;
			for(int k=i; k<=j-1; ++k){
				m[i][j]=min(m[i][j], m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
			}
		}
	}
	
	printf("%ld\n", m[1][n]);
}


Measured memory_bytes: 3284
import atexit
import io
import sys

buff = io.BytesIO()
sys.stdout = buff


@atexit.register
def write():
    sys.__stdout__.write(buff.getvalue())


s = raw_input()
x = int(s[0] + s[1])
y = int(s[2] + s[3]) 
if x >= 1 and x <= 12:
	if y >= 1 and y <= 12:
		print 'AMBIGUOUS'
	else:
		print 'MMYY'
else:
	if y >= 1 and y <= 12:
		print 'YYMM'
	else:
		print 'NA'  

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

// 重み付きグラフ
// できてほしいこと
// DFS, BFS, bellman-ford, サイクル検出、トポロジカルソートなど
struct Graph {
	struct Edge {
		int to;
		int weight;
	};
	vector<vector<Edge>> g;

	// 初期化
	Graph(int N) { g.assign(N, vector<Edge>()); }
	// 辺追加
	Edge add(int from, int to, int weight = 1) {
		Edge e = { to, weight };
		g[from].push_back(e);
		return e;
	}
	// 深さ優先探索（startからの全点への距離を返す）
	vector<int> dfs(int start) {
		vector<int> dist(g.size(), INF);
		vector<int> seen(g.size(), false);

		stack<int> s;
		s.push(start);
		seen[start] = true;

		while (!s.empty()) {
			int u = s.top(); s.pop();
			for (Edge e : g[u]) {
				if (seen[e.to]) continue;
				else {
					dist[e.to] = min(dist[e.to], dist[u] + e.weight);
					s.push(e.to);
					seen[e.to] = true;
				}
			}
		}
		return dist;
	}
	// 深さ優先探索（再帰バージョン）（startからの全点への距離を返す）
	void dfs2_internal(int v, vector<int>& seen, vector<int>& dist) {
		seen[v] = true;
		for (Edge e : g[v]) {
			if (seen[e.to]) continue;
			else {
				dist[e.to] = min(dist[e.to], dist[v] + e.weight);
				dfs2_internal(e.to, seen, dist);
				seen[e.to] = true;
			}
		}
	}
	vector<int> dfs2(int start) {
		vector<int> dist(g.size(), INF);
		vector<int> seen(g.size(), false);
		dist[start] = 0;
		dfs2_internal(start, seen, dist);

		return dist;
	}
	// Dijkstra法（蟻本）
	vector<int> dijkstra(int start) {
		vector<int> dist(g.size(), INF);
		priority_queue<P, vector<P>, greater<P>> q;

		dist[start] = 0;
		q.push({ 0,start });
		while (!q.empty()) {
			int d, v;
			tie(d, v) = q.top(); q.pop();
			if (dist[v] < d) continue;  // 枝刈り
			for (Edge e : g[v]) {
				if (dist[e.to] <= dist[v] + e.weight) continue; // 枝刈り
				dist[e.to] = dist[v] + e.weight;
				q.push({ dist[e.to], e.to });
			}
		}
		return dist;
	}
	// Bellman-Ford
	pair<vector<int>, bool> BellmanFord(int start) {
		vector<int> dist(g.size(), INF);
		int N = g.size();

		dist[start] = 0;

		bool negative_cycle = false;

		for (int i = 0; i < N; i++) {
			for (int v = 0; v < N; v++) {
				for (Edge e : g[v]) {

					if (dist[v] != INF && dist[e.to] > dist[v] + e.weight) {
						dist[e.to] = dist[v] + e.weight;
						// N回目にも更新があれば負サイクルあり
						if (i == N - 1) {
							dist[e.to] = -INF;
							negative_cycle = true;
						}
					}
				}
			}
		}
		return { dist, negative_cycle };
	}

};


signed main() {

	int N, M, start;
	cin >> N >> M >> start;
	Graph g(N);
	rep(i, M) {
		int s, t, d;
		cin >> s >> t >> d;
		g.add(s, t, d);
	}
	vector<int> result;
	bool negative;
	tie( result, negative) = g.BellmanFord(start);

	if (negative)
		cout << "NEGATIVE CYCLE" << endl;
	else {
		rep(i, N) {
			if (result[i] == INF) cout << "INF" << endl;
			else cout << result[i] << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3180
s = list(input())
if ('W' in s and 'E' not in s) or\
   ('N' in s and 'S' not in s) or\
   ('W' not in s and 'E' in s) or\
   ('N' not in s and 'S' in s):
   print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 510000;
const int MOD = 1000000007;

/*long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}*/
int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N + 1);
    for (int i = 1; i <= N; i++)
    {
        cin >> h[i];
    }

    int dp[1000000];

    for (int i = 0; i < 1000000; i++)
    {
        dp[i] = 1000000000;
    }
    dp[1] = 0;
    for (int i = 1; i <= N; i++)
    {
        for (int j = 1; j <= K; j++)
        {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
        
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 7520
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
inline ll in() { ll x; cin >> x; return x; }

#define INIT (-1)
#define move(a,b) ((a == INIT && b != INIT) ? a = b : a = a)
int main() {
  int h = in(), w = in(), k = in();
  vvi ans(h, vi(w, INIT));
  rep(i,h) {
    string s;
    cin >> s;
    rep(j,w) if (s[j] == '#') ans[i][j] = k--;
  }
 
  rep(i,h-1)rep(j,w) move(ans[i+1][j], ans[i][j]); // 下へ
  drep(i,h-1)rep(j,w) move(ans[i][j], ans[i+1][j]); // 上へ
  rep(i,h)rep(j,w-1) move(ans[i][j+1], ans[i][j]); // 右へ
  rep(i,h)drep(j,w-1) move(ans[i][j], ans[i][j+1]); // left

  rep(i,h)rep(j,w) cout << ans[i][j] << (j==w-1 ? "\n" : " ");
}


Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<queue>
#define INF 2e9
using namespace std;

void Dikstra(const vector<vector<pair<int, int> > >& G, vector<int>& d){
    d[0] = 0;
    priority_queue<pair<int, int> , vector<pair<int, int> >, greater<pair<int, int> > > PQ;
    PQ.push(make_pair(0, 0));
    vector<bool> is_black(d.size(), false);
    is_black[0] = true;
    while (!PQ.empty()) {
        int t = PQ.top().second;
        PQ.pop();
        is_black[t] = true;
        for (int i = 0; i < G[t].size(); i++) {
            int v = G[t][i].first;
            int w = G[t][i].second;
            if (!is_black[v] && d[t] + w < d[v]) {
                d[v] = d[t] + w;
                PQ.push(make_pair(d[v], v));
            }
        }
    }

}

int main(){
    int n;
    cin >> n;
    vector<vector<pair<int, int> > > G(n);
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v, c;
            cin >> v >> c;
            G[u].push_back(make_pair(v, c));
        }
    }
    vector<int> d(n, INF);
    Dikstra(G, d);
    for (int i = 0; i < n; i++) {
       cout << i << " " << d[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 7748
import java.io.*;

public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
            String line = reader.readLine();
            String[] num = line.split(" ", -1);
            int a = Integer.parseInt(num[0]);
            int b = Integer.parseInt(num[1]);
            int c = Integer.parseInt(num[2]);
            if (a <= b && b <= c && a <= c) {
                int x = a;
                int y = b;
                int z = c;
                System.out.println(x + " " + y + " "  + z);
            } else if (a <= b && b >= c && a <= c) {
                int x = a;
                int y = c;
                int z = b;
                System.out.println(x + " " + y + " "  + z);
            } else if (a >= b && b <= c && a <= c) {
                int x = b;
                int y = a;
                int z = c;
                System.out.println(x + " " + y + " "  + z);
            } else if (a <= b & b >= c && a >= c) {
                int x = c;
                int y = a;
                int z = b;
                System.out.println(x + " " + y + " "  + z);
            } else if (a >= b && b <= c && a >= c) {
                int x = b;
                int y = c;
                int z = a;
                System.out.println(x + " " + y + " "  + z);
            } else if (a >= b && b >= c && a >= c) {
                int x = c;
                int y = b;
                int z = a;
                System.out.println(x + " " + y + " "  + z);
            }
        } catch (IOException e) {
            System.out.println(e);
        } catch (NumberFormatException e) {
            System.out.println("error");
        }
    }
}

Measured memory_bytes: 24468
N, Y =map(int, input().split())
X = [-1,-1,-1]
for i in range(2001):
  y = (Y-1000*N-9000*i)/4000
  if not float.is_integer(y):
    continue
  if 0<= N-i-y <= 2000 and 0<= y <= 2000:
    X=[i, y, N-i-y]
    X=list(map(int, X))
    break
print(*X)


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

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

  if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
    cout << 0 << endl;
  } else {
    if (A > B) swap(A, B);
    if (B > C) swap(B, C);
    if (A > B) swap(A, B);
    cout << A * B << endl;
  }
}

Measured memory_bytes: 256
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define int ll
ll po(ll a, ll x, ll m) { if (x == 0) {return 1;} ll ans = 1; ll k = 1;  while (k <= x) {if (x & k) {ans = ((ans * a) % m);} k <<= 1; a *= a; a %= m; } return ans; }
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE
int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n;
	cin >> n;
	if (n >= 30) {
		cout << "Yes\n";
	}   else {
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 3608
# test!!!!!!!!!!!

from bisect import bisect_left, bisect_right

N = int(input())

S = list(input())

Q = int(input())

memo = {chr(ord('a') + i): [] for i in range(26)}

for key,val in enumerate(S):
    memo[val].append(key)

for q in range(Q):
    query = list(input().split())
    if query[0] == '1':
        i, x = int(query[1])-1, query[2]
        now = S[i]
        if now == x:
            continue
        memo[now].remove(i)
        next_i = bisect_left(memo[x], i)
        memo[x].insert(next_i, i)
        S[i] = x
    else:
        start, end = int(query[1])-1, int(query[2])-1
        tmp_cout = 0
        for alf_array in memo.values():
            if len(alf_array) == 0:
                continue
            ss = bisect_left(alf_array, start)
            gg = bisect_right(alf_array, end)
            if gg- ss > 0:
                tmp_cout += 1
        print(tmp_cout)


Measured memory_bytes: 134820
MOD = 10**9 + 7
list_size = 500001

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size-1):
	f_list[i+1] = (f_list[i] * (i+1)) % MOD

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(list_size-2, -1, -1):
	f_r_list[i] = (f_r_list[i+1] * (i+1)) % MOD

def comb(n, r):
	if n < r or r < 0:
		return 0
	elif n == 0 or r == 0 or n == r:
		return 1
	else:
		return (f_list[n] * f_r_list[n-r] * f_r_list[r]) % MOD 

n, m = map(int, input().split())
ans = 0
for i in range(n+1):
	res = comb(n, i) * f_list[m-i] * f_r_list[m-n]
	res %= MOD
	if i%2:
		res *= -1
	ans += res
	ans %= MOD

ans *= (f_list[m] * f_r_list[m-n])
print(ans%MOD)

Measured memory_bytes: 92416
#include <iostream>
#include <vector>
#include <functional>
using namespace std;
const int inf = (1LL << 31) - 1;

// 0 - indexed
template <typename Monoid>
struct Segmenttree
{
	using F = function<Monoid(Monoid, Monoid)>;
	const Monoid e;
	const F f;

	int sz;
	vector<Monoid> seg;

	// size, operator, unit
	Segmenttree(int N, const F &f, const Monoid &e) : f(f), e(e)
	{
		sz = 1;
		while (sz < N)
			sz *= 2;
		seg.assign(2 * sz - 1, e);
	}

	void set(int k, const Monoid &x) { seg[k + sz - 1] = x; }

	void build()
	{
		for (int k = sz - 2; k >= 0; k--)
		{
			seg[k] = f(seg[2 * k + 1], seg[2 * k + 2]);
		}
	}

	void update(int k, const Monoid &x)
	{
		k += sz - 1;
		seg[k] = x;
		while (k > 0)
		{
			k = (k - 1) / 2;
			seg[k] = f(seg[k * 2 + 1], seg[k * 2 + 2]);
		}
	}

	void add(int k, const Monoid &x)
	{
		k += sz - 1;
		seg[k] = f(x, seg[k]);
		while (k > 0)
		{
			k = (k - 1) / 2;
			seg[k] = f(seg[k * 2 + 1], seg[k * 2 + 2]);
		}
	}

	Monoid sub_query(int a, int b, int k, int l, int r)
	{
		if (r <= a || b <= l)
			return e;

		if (a <= l && r <= b)
			return seg[k];
		else
		{
			Monoid vl = sub_query(a, b, k * 2 + 1, l, (l + r) / 2);
			Monoid vr = sub_query(a, b, k * 2 + 2, (l + r) / 2, r);
			return f(vl, vr);
		}
	}

	// [l, r)
	Monoid query(int l, int r)
	{
		return sub_query(l, r, 0, 0, sz);
	}

	Monoid operator[](const int &k) const
	{
		return seg[k + sz - 1];
	}
};

auto Range_Minimum_Query = [](int a, int b) { return min(a, b); }; // unit = inf
auto Range_Maximum_Query = [](int a, int b) { return max(a, b); }; // unit = -inf
auto Range_Sum_Query = [](int a, int b) { return a + b; };		   // unit = 0

int main()
{
	int N, Q;
	cin >> N >> Q;
	Segmenttree<int> seg(N, Range_Sum_Query, 0);

	while (Q--)
	{
		int f;
		cin >> f;

		if (f == 0)
		{
			int i, a;
			cin >> i >> a;
			i--;
			seg.add(i, a);
		}
		if (f == 1)
		{
			int l, r;
			cin >> l >> r;
			l--, r--;
			cout << seg.query(l, r + 1) << "\n";
		}
	}
}



Measured memory_bytes: 3908
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,u,k,v,i,j,tt,n;
int M[200][200],d[200],f[200],c[200];

void visit(int u){
  int v;
  c[u] = GRAY;
  d[u] =++tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0)continue;
    if(c[v]==WHITE){
      visit(v);
    }
  }
  c[u]=BLACK;
  f[u]=++tt;
}

int main(){

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

  for(i = 0;i < n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }


  for (u=0;u<n;u++)c[u] = WHITE;
  tt=0;

  for(u=0;u<n;u++)if(c[u]==WHITE)visit(u);
  for(u=0;u<n;u++)printf("%d %d %d\n",u + 1,d[u],f[u]);

  return 0;
}

Measured memory_bytes: 676
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])
def sortx(x,n,k):
    if k == 0:x.sort(key=lambda y:y[1,n])
    else:x.sort(reversed=True, key=lambda y:y[1,n])

def graphm():
    n,m=inpm()
    g=[[] for _ in range(n)]
    for _ in range(m):
        a,b,w=inpm()
        a-=1
        b-=1
        g[a].append((w,b))
        g[b].append((w,a))
    return n,m,g

def warshall_floyd(): # d[i][j]: iからjへの最短距離
    n,m,r = map(int,input().split()) #n:頂点数　w:辺の数
    R=inpl()
    d=[[10**10 for _ in range(n)] for _ in range(n)]
    for i in range(m):
        x,y,z = inpm()
        x -= 1
        y -= 1
        d[x][y] = z
        d[y][x] = z
    for i in range(n):
        d[i][i] = 0 #自身のところに行くコストは0
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    ans = float('inf')
    for com in permutations(R,r):
        ans_pre = 0
        for i in range(r-1):
            ans_pre += d[com[i]-1][com[i+1]-1]
        ans = min(ans,ans_pre)
    print(ans)

def main(): 
    warshall_floyd()

if __name__ == "__main__":
    main()

Measured memory_bytes: 44632