akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	int a[n];
	rep(i, n) cin >> a[i];
	rep(i, n) {
		if (a[i] % 2) {
			cout << "first" << endl;
			return 0;
		}
	}
	cout << "second" << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 3e18+7
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    double ans = 1;
    double sum = 0;
    REP(i,N){
        double a;
        cin >> a;
        sum += 1/a;
    }
    sum = 1 / sum;
    printf("%.8lf\n",sum);
}


Measured memory_bytes: 256
x = int(input())
dp = [0]*(x + 105 + 1)
dp[100] = 1 
dp[101] = 1
dp[102] = 1
dp[103] = 1
dp[104] = 1
dp[105] = 1

for i in range(100,x-105+12):
    for j in range(100,106):
        dp[i+j] = max(dp[i] , dp[i+j])

print(dp[x])

Measured memory_bytes: 9228
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

vector<int> comb(int N, int mod) {
  N++;
  bitset<30> modbit = mod-2;
  vector<int> comb(N+1, 1);
  rep(i, N) {
    comb[i+1] = (comb[i]*(N-1-i))%mod;
    int x = i+1;
    rep(j, 30) {
      if(j > 0) x *= x;
      x %= mod;
      if(modbit.test(j)) {
        comb[i+1] *= x;
        comb[i+1] %= mod;
      }
    }
  }
  return comb;
}

signed main() {
  int X, Y; cin >> X >> Y;
  if(X < Y) swap(X, Y);
  const int mod = 1000000007;
  
  if(X - Y > Y || (Y - (X-Y))%3 != 0) cout << 0 << endl;
  else {
    int a = X-Y+(Y - (X-Y))/3, b = (Y - (X-Y))/3;
    vector<int> c = comb(a+b, mod);
    cout << c[a] << endl;
  }
    
  
}

Measured memory_bytes: 8532
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int  main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, a;
	cin >> n >> a;
	int l, r;
	l = a ;
	r = n + a - 1;
	int sum = 0;
	if (l >= 0 && r >= 0)
		l++;
	else if (l < 0 && r < 0)
		r--;

	//cout << l << r << endl;

	for (int i = l; i <= r; i++)
	{
		sum += i;
	}
	cout << sum;
}

Measured memory_bytes: 256
s = gets.chomp
if s[0..1].to_i <= 12 && s[2..3].to_i <= 12 && s[0..1].to_i >= 1 && s[2..3].to_i >= 1
    puts "AMBIGUOUS"
elsif s[0..1].to_i <= 12 && s[2..3].to_i > 12 && s[0..1].to_i >= 1
    puts "MMYY"
elsif s[0..1].to_i <= 12 && s[2..3] == "00" && s[0..1].to_i >= 1
    puts "MMYY"
elsif s[0..1].to_i > 12 && s[2..3].to_i <= 12 && s[2..3].to_i >= 1
    puts "YYMM"
elsif  s[0..1] == "00" && s[2..3].to_i <= 12 && s[2..3].to_i >= 1
    puts "YYMM"
elsif  s[0..1].to_i > 12 && s[2..3].to_i > 12
    puts "NA"
elsif s[0..1] == "00" || s[2..3] == "00"
    puts "NA"
end


Measured memory_bytes: 14376
def bubble_sort(A, N):
    flag = True
    c = 0
    i = 0
    while flag:
        flag = False
        for j in range(N-1, i, -1):
            if A[j] < A[j-1]:
                A[j],  A[j-1] = A[j-1], A[j]
                c += 1
                flag = True
        i += 1

    print " ".join(map(str, A))
    print c


N = int(raw_input())
A = map(int, raw_input().split())

bubble_sort(A, N)

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

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

const int N=200005;

LL f(LL n)
{
    //if(n==0)return 0;
    if(n==1)return 1;
    return 1+2*f(n/2);
}

int main()
{
    LL h;
    cin>>h;
    cout<<f(h)<<endl;
    return 0;
}













Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'

//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

using namespace std;
template<class T, class T2> inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);

int n;
string s;

void read()
{
	cin >> s;
	n = s.size();
}

int psz = 0;
int new_node() { return ++psz; }

vector<pair<int, int> > ed;

void add_edge(int u, int v) { ed.push_back({u, v}); }

void solve()
{
	if(s[0] == '0' || s[n - 1] == '1')
	{
		cout << -1 << endl;
		return;
	}

	s.pop_back();

	string rev = s;
	reverse(rev.begin(), rev.end());

	if(rev != s)
	{
		cout << -1 << endl;
		return;
	}

	s = " " + s;

	int last = -1;
	while(psz < n)
	{
		while(s[psz] == '0')
		{
			int x = new_node();
			add_edge(x, last);
		}

		int prv = last;
		last = new_node();
		if(prv != -1)
			add_edge(last, prv);
	}

	for(auto it: ed)
		cout << it.first << " " << it.second << endl;
}

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

	read();
	solve();
	return 0;
}



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

// #define ANS  //for answer
#define CMP  //for compe
#ifdef CMP
using namespace std;
#else
#endif

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define nv(x) #x, (x)
#define ncv(x) #x, ":", (x)
#define ncvc(x) #x, ":", (x), ","
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>
void pPRINT(std::ostream& ost, const T t, const U... u) {
  ost << t << " ";
  pPRINT(ost, u...);
}
template <class... T>
void PRINT(const T... t) { pPRINT(std::cout, t...); }
template <class... T>
void PRINTl(const T... t) {
  pPRINT(std::cout, t...);
  std::cout << "\n";
}
template <class T>
void PRINTa(const T* const t, const ll size) {
  REP(i, size)
  PRINT(t[i]);
  PRINTl();
}
template <class T>
void PRINTal(const T* const t, const ll size) {
  REP(i, size)
  PRINTl(i, ":", t[i]);
}
#ifndef DBG
#define DEBUG(...)
void init() {}
#else
#define DEBUG(...)                                                     \
  {                                                                    \
    PRINT("##DEBUG##", "file :", __FILE__, ", line :", __LINE__, "["); \
    PRINT(__VA_ARGS__);                                                \
    PRINTl("]");                                                       \
  }
void init() {
  DEBUG("INIT");
  cin.tie(0);
  ios::sync_with_stdio(false);
}
#endif
#ifdef ANS
#else
#endif

void solve();

int main(int argc, char* argv[]) {
  DEBUG("MAIN");
  init();
  solve();

  return 0;
}

void solve() {
  DEBUG("SOLVE START");

  ll n, k;
  cin >> n >> k;

  string s;
  ll v[n];
  cin >> s;
  REP(i, s.size()) {
    if (s[i] == 'L') {
      v[i] = -1;
    } else {
      v[i] = 1;
    }
  }

  // PRINTa((ll*)v, n);
  vector<ll> vv{0};
  ll count = 0;
  FOR(i, 1, n) {
    if (v[i] != v[0]) {
      ll j = i;
      while (j < n - 1 && v[j + 1] != v[0]) {
        j++;
      }
      DEBUG("change is called!", ncv(i), ncv(j));
      FOR(k, i, j + 1) {
        v[k] = v[0];
      }
      count++;
    }
    if (count >= k) break;
  }
  ll ans = 0;
  if (v[0] == 1 && v[1] == 1) ans++;
  FOR(i, 1, n - 1) {
    if (v[i] == v[i + v[i]]) ans++;
  }
  if (v[n - 1] == -1 && v[n - 2] == -1) ans++;

  // PRINTa(v, n);
  PRINT(ans);

  // PRINTa(v, n);
  // PRINTa(&vv[0], vv.size());

  return;
}

Measured memory_bytes: 1280
N,A,B = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(1,N):
  if (a[i] - a[i-1])*A < B:
    ans += (a[i] - a[i-1])*A
  else:
    ans += B
print(ans)
  

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

const int C = 1e5 + 1;
vector<vector<int>> fg(C);
vector<vector<int>> bg(C);
vector<int> parent(C, -1);

int root(int num) {
    return parent[num] == -1 ? num : root(parent[num]);
}

void merge(int a, int b) {
    int p1 = root(a);
    int p2 = root(b);
    if (p1 == p2) return;
    if (p1 < p2) {
        parent[p2] = p1;
    } else { // p1 > p2
        parent[p1] = p2;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    fg.clear();
    bg.clear();
    parent.clear();

    int N, M, K;
    cin >> N >> M >> K;

    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        fg[a].push_back(b);
        fg[b].push_back(a);
        merge(a, b);
    }

    for (int i = 0; i < K; ++i) {
        int c, d;
        cin >> c >> d;
        bg[c].push_back(d);
        bg[d].push_back(c);
    }

    vector<int> island(N + 1, 0);
    for (int i = 1; i <= N; ++i) {
        if (fg[i].size() > 0) {
            island[root(i)]++;
        }
    }

    for (int i = 1; i <= N; ++i) {
        int cnt = 0;
        if (fg[i].size() > 0) {
            int p1 = root(i);
            cnt = island[p1] - fg[i].size() - 1;
            for (int b : bg[i]) {
                int p2 = root(b);
                if (p1 == p2) cnt--;
            }
        }
        cout << cnt << " ";
    }
}


Measured memory_bytes: 12664
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define md 1000000007
double PI=3.1415926535;
const int N =  (int)(1 * 1e6 + 10);
using namespace std;

int main()
{   
    ll n , m , k;
    cin>>n>>m>>k;
    ll a[n+1] , b[m+1];
    ll A[n+1] , B[m+1]; 
    A[0]=0;
    B[0]=0;
    for(ll i = 1  ; i <= n ; i++)
    {
        cin>>a[i];
        A[i]=A[i-1]+a[i];
    }
    for(ll i = 1 ; i <= m ; i++)
    {
        cin>>b[i];
        B[i]=B[i-1]+b[i];
    }
    ll j = m , ans = 0;
    for(ll i = 0 ; i<=n ;i++)
    {   
        if(A[i]>k)break;
        while(A[i]+B[j]>k)j--;

        ans = max(ans,i+j);
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 9876
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define INF 1000000000007
#define MOD 1000000007
#define ARRAY_MAX 3005

double dp[ARRAY_MAX][ARRAY_MAX];//dp[i][j]:i回投げて表がj回出る確率


int main(){

    int n;
    cin >> n;
    vector<double> a(n);
    REP(i,n){
        cin >> a[i];
    }
    dp[1][1] = a[0];//1回目に表が出る確率
    dp[1][0] = 1-a[0];
    for(int i = 2;i <= n;i++){
        dp[i][0] = dp[i-1][0]*(1-a[i-1]);
    }

    for(int i = 2;i <= n;i++){//i回投げる
        for(int j = 1;j <= n;j++){//j回表が出る(最大n回)
            dp[i][j] = dp[i-1][j]*(1-a[i-1]) + dp[i-1][j-1]*a[i-1];
        }
    }

    double ans = 0;
    for(int i = 0;i <= n;i++){
        if(i > n-i){
            ans += dp[n][i];
        }
    }
    printf("%.12f\n",ans);

    return 0;
}

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

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

    int cnt = 0, idx = 0;
    for(int i = 2; i < s.size()-1; i++){
        if(s[i] == 'C'){
            cnt++;
            idx = i;
        }
    }
    if(s[0] != 'A' || cnt != 1){
        cout << "WA" << endl;
        return 0;
    }
    for(int i = 1; i < s.size(); i++){
        if(i != idx && isupper(s[i])){
            cout << "WA" << endl;
            return 0;
        }
    }
    cout << "AC" << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().strip().split(" "))
if n == 1 and m == 1:
    print(1)
elif n == 1 or m == 1:
    print(max(n - 2, m - 2))
elif n == 2 or m == 2:
    print(0)
else:
    print((n - 2) * (m - 2))


Measured memory_bytes: 3316
/**
 * Luck Manipulator
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n, a, b, c, x;
			StringTokenizer st = new StringTokenizer(line);
			n = parseInt(st.nextToken());
			a = parseInt(st.nextToken());
			b = parseInt(st.nextToken());
			c = parseInt(st.nextToken());
			x = parseInt(st.nextToken());
			if ((n | a | b | c | x) == 0) break;

			st = new StringTokenizer(br.readLine());
			int count = 0;
			int y = parseInt(st.nextToken());
			while (count <= 10000) {
				if (y == x) {
					if (st.hasMoreTokens()) {
						y = parseInt(st.nextToken());
					} else {
						break;
					}
				}
				x = (a * x + b) % c;
				count++;
			}
			System.out.println(count > 10000 ? -1 : count);
		} //end while
	} //end main
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  string s; cin>>s;
  int l = s.size();
  cout << s[0] << l-2 << s.back() << endl;
}

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


Measured memory_bytes: 256
import java.util.Scanner;

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

    int sum = 0;
    for (int i = 0; i < 3; i++) {
      sum += scanner.nextInt();
    }
    if (sum > 21) {
      System.out.println("bust");
    } else {
      System.out.println("win");
    }
  }
}


Measured memory_bytes: 23380
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <cfenv>
#include <cinttypes>
#include <cstdint>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <forward_list>
#include <initializer_list>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#if __cplusplus >= 201402L
#include <shared_mutex>
#endif

#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;

const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};

int main(){
    int n;
    cin >> n;
    vector<int> ans(100000,0);
    rep(x,120){
        rep(y,120){
            rep(z,120){
                if(x == 0 || y == 0 || z == 0) continue;
                int temp;
                temp = x*x+y*y+z*z+x*y+y*z+z*x;
                ans[--temp]++;
            }
        }
    }
    rep(i,n){
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3388
S = input()
N = len(S)
ans = []
check = []
for i in range(N):
    if S[i] != 'x':
        ans.append(S[i])
        check.append(i)
if len(ans) == 0:
    print(0)
    exit()
if ans != ans[::-1]:
    print(-1)
    exit()
if len(ans)%2:
    cl,cr = check[len(ans)//2],check[len(ans)//2]
else:
    cl,cr = check[len(ans)//2-1],check[len(ans)//2]
cnt = 0
while 0 <= cl and cr <= N-1:
    if S[cl] == S[cr]:
        cl -= 1
        cr += 1
    elif S[cl] == 'x':
        cnt += 1
        cl -= 1
    else:
        cnt += 1
        cr += 1
cnt += max(cl+1,N-cr)
print(cnt)


Measured memory_bytes: 8736
n = int(input())
ss = "abcdefghijklmnopqrstuvwxyz"
dmin = {}
for s in ss:
  dmin[s] = 51

for i in range(n):
  S = input()

  d ={}
  for s in S:
    if s not in d.keys():
      d[s] = 1
    else:
      d[s] += 1
  
  for s in ss:
    if s not in d.keys():
      dmin[s] = 0

  for s in d.keys():
    dmin[s] = min(dmin[s], d[s])
for k in dmin.keys():
  print(k*dmin[k],sep="",end="")
print()

Measured memory_bytes: 9204
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<functional>

using namespace std;

const int infty = 1 << 28;

struct Edge{
  int src;
  int dst;
  int dist;
  int cost;
  Edge(){}
  Edge(int s, int d, int di, int c):
    src(s),dst(d),dist(di),cost(c){}
};

struct Node{
  vector<int> eid;
};

struct State{
  int n;
  int dist;
  State(){}
  State(int now, int d):n(now),dist(d){}
  bool operator>(const State &t)const{
    return dist > t.dist;
  }
};

typedef vector<Node> Graph;

int solve(Graph &G, vector<Edge> &E){
  int ret=0;
  int A[G.size()];
  vector<int> F[G.size()];
  set<int> U;
  priority_queue< State,vector<State>,greater<State> > Q;
  State init(0,0);
  Q.push(init);

  for(int i = 0; i < (int)G.size(); ++i){
    A[i]=infty;
  }
  A[0]=0;
  
  while(!Q.empty()){
    State nst = Q.top(); Q.pop();
    for(int i = 0; i < (int)G[nst.n].eid.size(); ++i){
      int eid = G[nst.n].eid[i];
      int from = (E[eid].src == nst.n) ? E[eid].src : E[eid].dst;
      int to = (E[eid].dst == nst.n) ? E[eid].src : E[eid].dst;
      int dist = nst.dist + E[eid].dist;
      if( A[to] > dist ){
	A[to] = dist;
	F[to].clear();
	F[to].push_back( eid );
	Q.push(State(to,dist));
      }else if( A[to] == dist ){
	F[to].push_back( eid );
      }
    }
  }

  for(int i = 1; i < (int)G.size(); ++i){
    //cout << "Node : " << i+1 << " MIN DIST : " << A[i] << " FROM :" <<  endl;
    int mini = infty;
    int use = -1;
    for(int j = 0; j < (int)F[i].size(); ++j){
      //cout << F[i][j]+1 << ' ';
      if( mini > E[F[i][j]].cost ){
	mini = E[F[i][j]].cost;
	use = F[i][j];
      }
    }
    U.insert(use);
    //cout << endl;
  }
  //cout << endl;

  for(set<int>::iterator its = U.begin(); its != U.end(); ++its){
    ret += E[*its].cost;
  }
  
  return ret;
}

int main()
{
  while(true){
    int N,M;
    cin >> N >> M;
    vector<Edge> E;
    Graph G(N);
    if(N==0&&M==0)break;
    for(int i = 0; i < M; ++i){
      int src, dst, dist, cost;
      cin >> src >> dst >> dist >> cost;
      --src;--dst;
      E.push_back(Edge(src,dst,dist,cost));
      G[src].eid.push_back(i);
      G[dst].eid.push_back(i);
    }

    cout << solve( G, E ) << endl;
  }
  return 0;
}

Measured memory_bytes: 2116
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
  int A,B,X;
  cin>>A>>B>>X;
  if(A<=X&&X<=A+B){
    YES(1);
  }else{
    YES(0);
  }
  return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)


signed main(){

	string s;
	cin>>s;
	lli a,b,c,d;

	a=s.at(0)-'0';
	b=s.at(1)-'0';
	c =s.at(2)-'0';
	d=s.at(3)-'0';


	REP(i,0,2)REP(j,0,2)REP(k,0,2){
		lli sum=a;
		char ii,jj,kk;
		if(i==0){
			sum-=b;ii='-';
		}
		else {sum+=b;ii='+';}
		if(j==0){sum-=c;jj='-';}
		else {sum+=c;jj='+';}
		if(k==0){sum-=d;kk='-';}
		else {sum+=d;kk='+';}
		if(sum==7){
			cout<<a<<ii<<b<<jj<<c<<kk<<d<<"=7"<<endl;
			return 0;

		}
	}


	return 0;
}

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

public class Main {

    int[] a;

    void solve() {
	int N = sc.nextInt();
	int[] a = new int[N+1];
	for (int i = 1; i < N+1; i++) {
	    a[i] = sc.nextInt();
	}

	int ans = 0;
	for (int i = 1; i < N+1; i++) {
//	    System.out.println("debug" + a[a[i]] + " " + a[i]);
	    if (i == a[a[i]]) {
		ans++;
		a[a[i]] = 0;
	    }
	}
	System.out.println(ans);
    }

    void print(int[] a) {
	out.print(a[0]);
	for (int i = 1; i < a.length; i++) out.print(" " + a[i]);
	out.println();
    }

    public static void main(String[] args) throws Exception {
	new Main().run();
    }

    MyScanner sc = null;
    PrintWriter out = null;
    public void run() throws Exception {
	sc = new MyScanner(System.in);
	out = new PrintWriter(System.out);
	for (;sc.hasNext();) {
	    solve();
	    out.flush();
	}
	out.close();
    }

    class MyScanner {
	String line;
	BufferedReader reader;
	StringTokenizer tokenizer;

	public MyScanner(InputStream stream) {
	    reader = new BufferedReader(new InputStreamReader(stream));
	    tokenizer = null;
	}
	public void eat() {
	    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
		try {
		    line = reader.readLine();
		    if (line == null) {
			tokenizer = null;
			return;
		    }
		    tokenizer = new StringTokenizer(line);
		} catch (IOException e) {
		    throw new RuntimeException(e);
		}
	    }
	}
	public String next() {
	    eat();
	    return tokenizer.nextToken();
	}
	public String nextLine() {
	    try {
		return reader.readLine();
	    } catch (IOException e) {
		throw new RuntimeException(e);
	    }
	}
	public boolean hasNext() {
	    eat();
	    return (tokenizer != null && tokenizer.hasMoreElements());
	}
	public int nextInt() {
	    return Integer.parseInt(next());
	}
	public long nextLong() {
	    return Long.parseLong(next());
	}
	public double nextDouble() {
	    return Double.parseDouble(next());
	}
	public int[] nextIntArray(int n) {
	    int[] a = new int[n];
	    for (int i = 0; i < n; i++) a[i] = nextInt();
	    return a;
	}
    }
}


Measured memory_bytes: 22864
#include<stdio.h>

int main()
{
    char s[4];
    scanf("%s",s);


    int i,sum=0;
    for(i=0;i<4;i++)
    {
        if(s[i]=='+')
            sum++;
        else
            sum--;
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n,m;
vvi G;
vi color;
bool dfs(int a){
	rep(i,G[a].size()){
		int to=G[a][i];
		if(color[to]+1){
			if(color[to]==color[a])return false;
		}else{
			color[to]=color[a]^1;
			if(!dfs(to))return false;
		}
	}
	return true;
}
int main(){
	cin>>n>>m;
	G=vvi(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	color=vi(n,-1);
	color[0]=0;
	bool h=dfs(0);
	if(!h){
		cout<<(ll)n*(n-1)/2-m<<endl;
	}else{
		int a=0,b=0;
		rep(i,n)if(color[i])a++;else b++;
		cout<<(ll)a*b-m<<endl;
	}
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

vector<pair<ll, int>> factorize(ll n) {
    vector<pair<ll, int>> res;
    for(ll i=2; i*i<=n; i++) {
        if (n % i) continue;
        res.emplace_back(i, 0);
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    map<ll, int> facmap;
    for(int i=1; i<=n;i++){
        vector<pair<ll, int>> tmp = factorize(i);
        for(auto a : tmp){
            facmap[a.first] += a.second;
        }
    }
    int p = 0, q = 0, r = 0, s=0, t=0;
    for(auto a : facmap){
    //    cerr<<a.first<<" "<<a.second<<endl;
        if(a.second >= 74){
            t++;
        }
        if(a.second >= 24){
            s++;
        }
        if(a.second >= 14){
            r++;
        }
        if(a.second >= 4){
            q++;
        }
        if(a.second >= 2){
            p++;
        }
    }
    ll ans = q*(q-1)*(p-2)/2 
          +  r * (q-1)
          + s*(p-1)
          + t;
    cout<<ans<<endl;
 }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#include <stack>
#include <random>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

int N,M;
vector<int> g[100010];

int countCycles(){
    vector<int> deg(N,0);
    rep(i,N) deg[i]=g[i].size();

    int res=0;
    map<pair<int,int>,int> mp;
    vector<int> used(N,0);
    vector<int> pos(N,0);
    for(int i=0;i<N;i++){
        if(deg[i]==0) continue;

        stack<int> st;
        st.push(i);
        used[i]=1;
        while(1){
            int now=st.top();
            int nex=-1;
            for(;pos[now]<g[now].size();pos[now]++){
                int tar=g[now][pos[now]];
                if(mp.count(mkp(now,tar))) continue;
                
                nex=tar;
                pos[now]++;
                break;
            }

            if(nex==-1) break;
            if(used[nex]){
                deg[now]--;deg[nex]--;
                mp[mkp(now,nex)]=1;mp[mkp(nex,now)]=1;
                while(st.top()!=nex){
                    int tmp=st.top();
                    st.pop();
                    used[tmp]=0;
                }
                res++;
                continue;
            }else{
                st.push(nex);
                deg[now]--;deg[nex]--;
                used[nex]=1;
                mp[mkp(now,nex)]=1;mp[mkp(nex,now)]=1;
            }
        }
        used[i]=0;
    }
    return res;
}

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

  cin>>N>>M;
  rep(i,M){
      int a,b;
      cin>>a>>b;
      a--;b--;
      g[a].push_back(b);
      g[b].push_back(a);
  }

  rep(i,N){
      if(g[i].size()%2){
          cout<<"No"<<endl;
          return 0;
      }
  }

  for(int k=0;k<10;k++){
      random_device rg;
      mt19937 engine(rg());
      rep(i,N) shuffle(g[i].begin(),g[i].end(),engine);
      int cycles=countCycles();
      if(cycles>=3){
          cout<<"Yes"<<endl;
          return 0;
      }
  }

  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 19676
#include <bits/stdc++.h>
 
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0) (__VA_ARGS__)
#define rep_0(i, end) for (int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for (int i = (fr); i <= (ba); ++i)
#define overload_rep(arg_0, arg_1, arg_2, name, ...) name
#define all(box) box.begin(), box.end()
 
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }

template <class Container>
std::vector<int> z_algorithm(const Container& str) {
  int size = str.size();
  std::vector<int> result(size);
  result[0] = size;
  int i = 1, j = 0;
  while (i < size) {
    while (i + j < size && str[i + j] == str[j]) {
      ++j;
    }
    result[i] = j;
    if (j == 0) { 
      ++j; 
      continue; 
    }
    int k = 1;
    while (i + k < size && k + result[k] < j) { 
      result[i + k] = result[k];
      ++k; 
    }
    i += k;
    j -= k;
  }
  return result;
}

int main() {

  int N;
  std::cin >> N;
  std::vector<int> A(N), B(N);
  rep (i, N) std::cin >> A[i];
  rep (i, N) std::cin >> B[i];

  std::vector<int> rotate(N * 3 + 1);
  rep (i, N - 1) {
    rotate[i] = B[i] ^ B[i + 1];
    rotate[N + i + 1] = rotate[N + N + i + 1] = A[i] ^ A[i + 1];
  }
  rotate[N - 1] = B[N - 1] ^ B[0];
  rotate[N + N] = rotate[N + N + N] = A[N - 1] ^ A[0];
  rotate[N] = -1;

  std::vector<int> checker = z_algorithm(rotate);
  rep (i, N) {
    if (checker[N + i + 1] >= N) {
      int k = i, x = A[i] ^ B[0];
      std::cout << k << ' ' << x << '\n';
    }
  }

}


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

#define ll long long

int main() {
	
	int n,W;
	cin >> n >> W;
	
	ll int weight[n+1],value[n+1];
	for(int i=1;i<=n;i++)
	{
		cin >> weight[i] >> value[i];
	}
	
	ll int dp[n+1][W+1];
	memset(dp,0,sizeof dp);
	
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=W;j++)
		{
			if(i==0||j==0)
			{
				dp[i][j]=0;
			}
			else
			{
				if(weight[i]<=j)
				dp[i][j]=max(dp[i-1][j],value[i]+dp[i-1][j-weight[i]]);
				else
				dp[i][j]=dp[i-1][j];
			}
		}
	}
	
	cout << dp[n][W] << endl;
	
	return 0;
}

Measured memory_bytes: 79104
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
using namespace std;

int n,r,p,c;
int before[50],after[50];

void init(){
	for(int i=0;i<50;i++)
		before[i]=after[i]=0;
}

bool input(){	
	int i;
	cin>>n;
	cin>>r;
	if((n==0) && (r==0))
		return false;
	for(i=0;i<n;i++){
		before[i]=n-i;
		after[i]=n-i;
	}
	return true;
}

void Shuffle(int b[], int a[]){
	int j;
	for(j=0;j<c;j++)
		a[j]=b[p-1+j];
	for(j=0;j<p-1;j++)
		a[c+j]=b[j];
	for(j=0;j<n;j++)
		b[j]=a[j];
}


int solve(){
	for(int i=0;i<r;i++){
		cin>>p>>c;
		Shuffle(before,after);
	}
	return after[0];
}


int main(){
  while(init(),input()){
	cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def main():
    n = II()
    a = LI()
    b = [(a[i], i) for i in range(n)]
    b.sort()
    b.reverse()
    r = [0] * n
    s = sum(a)
    t = inf
    for i in range(n):
        ai,bi = b[i][0],b[i][1]
        if bi == 0:
            r[0] += s
            break
        ti = (ai - b[i+1][0]) * (i+1)
        if t > bi:
            t = bi
        r[t] += ti
        s -= ti
    return '\n'.join(map(str, r))

print(main())


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

#define FOR(i, j, k) for(int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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;
}

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for(T &x : vec)
        is >> x;
    return is;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, a, b;
    cin >> n >> a >> b;

    cout << min(a * n, b) << endl;

    return 0;
}


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

int main(){
  vector<string> c(3);
  for(int i = 0; i < 3; i++){
    cin >> c[i];
  }

  cout << c[0][0] << c[1][1] << c[2][2] << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>

using namespace std;
int main(){
  double r,menseki,ensyu;
  cin>>r;
  menseki=3.141592653589*r*r;
  ensyu=3.141592653589*2*r;
  printf("%f %f\n",menseki,ensyu);
 return 0;
}

Measured memory_bytes: 1232
c = [[int(i) for i in input().split()] for _ in range(3)]

h1 = c[1][0] - c[0][0] == c[1][1] - c[0][1] == c[1][2] - c[0][2]
h2 = c[2][0] - c[1][0] == c[2][1] - c[1][1] == c[2][2] - c[1][2]
w1 = c[0][1] - c[0][0] == c[1][1] - c[1][0] == c[2][1] - c[2][0]
w2 = c[0][2] - c[0][1] == c[1][2] - c[1][1] == c[2][2] - c[2][1]

if h1 and h2 and w1 and w2 :
    print('Yes')
else :
    print('No')

Measured memory_bytes: 38384
#include <stdio.h>

int N;
int A, B;
int P[128];

int main(void) {
	int i;
	int asumi = 0, iguti = 0, ogura = 0, hikasa;
	if (scanf("%d", &N) != 1) return 1;
	if (scanf("%d%d", &A, &B) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &P[i]) != 1) return 1;
	}

	for (i = 0; i < N; i++) {
		if (P[i] <= A) asumi++;
		else if (P[i] <= B) iguti++;
		else ogura++;
	}

	hikasa = asumi;
	if (hikasa > iguti) hikasa = iguti;
	if (hikasa > ogura) hikasa = ogura;
	printf("%d\n", hikasa);

	return 0;
}


Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

char grid[1005][1005];
ll dp[1005][1005];

int main() 
{
    fastio();

    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++) cin>>grid[i][j];

    dp[0][0] = 1;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if( grid[i+1][j] != '#' )
            {
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] = mod(dp[i+1][j]);
            }
            if( grid[i][j+1] != '#' )
            {
                dp[i][j+1] += dp[i][j];
                dp[i][j+1] = mod(dp[i][j+1]);
            }
        }
    }
    cout<<dp[h-1][w-1],nl;

    return 0;
}

Measured memory_bytes: 9088
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;

int main(){
    int max=0;
    int h,w;
    cin>>h>>w;
    int n;
    cin>>n;
if(h<w){
    max=w;
}
else{
    max=h;
}
if(n%max>0){
cout<<n/max+1<<endl;
}
else{
    cout<<n/max<<endl;
}
}













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

typedef long long ll;

int main() {
    int mn, n, pos, sum;
    vector<int> time(5);

    f(i, 5) cin >> time.at(i);

    mn = 128;
    f(i, 5) {
        n = time.at(i) % 10;
        if(n != 0) {
            if(mn > n) {
                mn = n;
                pos = i;
            }
        }
    }


    sum = 0;
    f(i, 5) {
        n = time.at(i);
        if (i == pos) {
            sum += n; 
        } else if(n % 10 != 0) {
            sum += n + (10 - (n % 10));
        } else {
            sum += n;
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a=0,b=0;

	scanf("%d %d",&a,&b);

	if( a > b ){
		printf("a > b\n");
	}
	else if( a < b ){
		printf("a < b\n");
	}
	else{
		printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 1008
import sys
from collections import deque as dq
input = sys.stdin.readline
H, W = map(int, input().split())
S = [list(input())[: -1] for _ in range(H)]
sm = 0
for i in range(H): sm += S[i].count(".")
Q = dq([0])
dp = [H * W] * (H * W)
dp[0] = 1
d = [-1, 0, 1, 0]
while len(Q):
  p = Q.popleft()
  y = p // W
  x = p % W
  for k in range(4):
    u = y + d[k]
    v = x + d[-1 - k]
    if u in range(H) and (v in range(W)):
      if S[u][v] == "#": continue
      if dp[u * W + v] == H * W:
        dp[u * W + v] = dp[p] + 1
        Q.append(u * W + v)

if dp[-1] == H * W: print(-1)
else: print(sm - dp[-1])

Measured memory_bytes: 40560
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let k: usize = read();
    let c: usize = read();

    let s: String = read();
    let ci: Vec<char> = s.chars().collect();

    let mut l = vec![0; k+1];
    let mut r = vec![0; k+1];

    let mut i = 0;
    let mut cnt = 0;
    while i < n && cnt < k {
        if ci[i] == 'o' {
            cnt += 1;
            l[cnt] = i+1;
            i += c+1;
        } else {
            i += 1;
        }
    }
    // println!("{:?}", l);

    let mut i: i32 = n as i32 - 1;
    let mut cnt = k + 1;
    while i >= 0 && cnt > 0 {
        if ci[i as usize] == 'o' {
            cnt -= 1;
            r[cnt] = i as usize + 1;
            i -= c as i32 + 1;
        } else {
            i -= 1;
        }
    }
    // println!("{:?}", r);

    for i in 1..k+1 {
        if l[i] == r[i] {
            println!("{}", l[i]);
        }
    }
}


Measured memory_bytes: 9724
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


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

	ll a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;

	return 0;

}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long N = long.Parse(str[0]);
		long M = long.Parse(str[1]);
		long ans = N*M;
		if(N>=10 || M>=10){
			ans = -1;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 312345
int a[N] = {}, b[N] = {};
vpii v;

int main(){
	int h, w, m; scanf("%d%d%d", &h, &w, &m);
	REP(i, m){
		int y, x; scanf("%d%d", &y, &x);
		a[y]++;
		b[x]++;
		v.EB(y, x);
	}
	int p = *max_element(a+1, a+h+1), q = *max_element(b+1, b+w+1);
	int k = 0;
	for(auto [i, j] : v){
		if(a[i] == p && b[j] == q){
			k++;
		}
	}
	ll t = 1LL * count(a+1, a+h+1, p) * count(b+1, b+w+1, q);
	int ans = p + q;
	if(t == k) ans--;
	printf("%d\n", ans);
}


Measured memory_bytes: 9832
#include <bits/stdc++.h>
using namespace::std;
#define int long long

#define all(x) (x).begin(), (x).end()
#define inf (sizeof(int) == 4 ? (int)1E9 : (int)1E18)

template<class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}



void _main() {
        int n; cin >> n;
        string str;
        while (n) {
                n--;
                str += char('a' + n % 26);
                n /= 26;
        }

        reverse(all(str));
        cout << str;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

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

for i in range(1,3 * int(n ** 0.5)):
    n -= i
    if n < i + 1:
        maximum = i + 1
        no = i + 1 - n
        break

for i in range(maximum):
    if i + 1 == no:
        continue
    print(i + 1)


Measured memory_bytes: 3408
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define fo(x,a,b) for(register int x=a;x<=b;x++)
#define dfo(x,a,b) for(register int x=a;x>b;x--)
#define inf 2147483647
using namespace std;
int a[2000000],en,n,x,xx;
int main ()
{


	scanf("%d",&n);
	en=0;
	fo(i,1,n)
	{
		scanf("%d",&x);
		if (x==1) scanf("%d",&xx),printf("%d\n",a[xx]);
		if (x==2) if(en>0) a[en--]=0;
		if (x==0) scanf("%d",&xx),a[en++]=xx;
		
	}

	return 0;
}





Measured memory_bytes: 4012
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;
typedef vector<ll> vel;
typedef vector<string> ves;
typedef vector<int> vei;
typedef vector<vector<ll>> vvel;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main() {
    vei v(5);
    rep(i,5){
        cin>>v[i];
        if(v[i]==0) {cout<<i+1<<endl;
        break;}
    }
}

Measured memory_bytes: 3616
#include<cstdio>
#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<deque>
#include<cmath>
#include<set>
#include<cstring>
#include<string.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
//----------------
#define int long long
//----------------
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-')f = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') {x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar();}
    return x * f;
}
#define sdf(x) x=read()
#define For(i, a, b) for (int i = (a); i <= (b); i++)
#define FFor(i, a, b) for (int i = (a); i >= (b); i--)
#define me(a, b) memset(a, b, sizeof(a))
#define mid ((l + ((r - l)/2)))
#define random(a, b) ((a) + rand() % ((b) - (a) + 1))
#define bg1(x) cout<<(#x)<<":"<<(x)<<" "<<endl
#define bg2(x,y) cout<<(#x)<<":"<<(x)<<" "<<(#y)<<":"<<(y)<<" "<<endl
#define bg3(x,y,z) cout<<(#x)<<":"<<(x)<<" "<<(#y)<<":"<<(y)<<" "<<(#z)<<":"<<(z)<<" "<<endl
#define bg4(x,y,z,w) cout<<(#x)<<":"<<(x)<<" "<<(#y)<<":"<<(y)<<" "<<(#z)<<":"<<(z)<<" "<<(#w)<<":"<<(w)<<" "<<endl
#define bg5(x,y,z,w,k) cout<<(#x)<<":"<<(x)<<" "<<(#y)<<":"<<(y)<<" "<<(#z)<<":"<<(z)<<" "<<(#w)<<":"<<(w)<<" "<<(#k)<<":"<<(k)<<" "<<endl
#define call(x) cout<<x<<":"
#define lll cout<<"\n------\n"
int die = 0;
#define Die die++;if(die>100000){cout<<"dead!!!";exit(0);}
#define mk make_pair
#define pb push_back
const double eps = 1e-8;
// srand((unsigned)time(NULL));
const int mod = 1e9 + 7;
const int N = 1e6 + 5;

int n, m;
int fa[N];

int find(int x) {return fa[x] == x ? fa[x] : fa[x] = find(fa[x]);}

void sol1() {

}

void rd() {
    sdf(n), sdf(m);
    int x, y, z;
    For(i, 1, n)fa[i] = i;
    For(i, 1, m) {
        sdf(x), sdf(y), sdf(z);
        int tx = find(x), ty = find(y);
        if (tx != ty)fa[tx] = ty;
    }
    int ans = 0;
    For(i, 1, n)if (fa[i] == i)ans++;
    cout << ans;
    sol1();
}

signed main()
{

    rd();
}




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

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define EPS (1e-7)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;

int main(){
	ll n;
	cin>>n;
	vector<int> d;
	int sum=0;
	while(n>0){
		int x=n%10;
		d.push_back(x);
		sum+=x;
		n/=10;
	}
	int ans=d[d.size()-1]-1+(d.size()-1)*9;
	ans=max(ans,sum);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256