akhauriyash/Code-Regression huggingface dataset:
/*
  AOJ 1051
  Title:Citation Format
  @kankichi573
*/
#include <stdio.h>

main()
{
  int N,p,i,c,prev;


  while(scanf("%d ",&N) && N)  
    {
      prev=-1;c=0;
      for(i=0;i<N;i++)
	{
	  scanf("%d",&p);
	  if(p==prev+1)
	    {
	      if(i==N-1)
		{
		if(c==0)
		  printf("-%d",p);
		else
		  printf("%d",p);
		}
	      else if(c==0)
		printf("-");
	      c++;
	    }
	  else
	    {
	      if(i>0 && c>0)
		printf("%d %d",prev,p);
	      else if(i>0)
		printf(" %d",p);
	      else
		printf("%d",p);
	      c=0;
	    }
		prev=p;
	}
      printf("\n");
    }
  return(0);
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n;
    cin>>n;
    double m,oto=0.0;
    string s;
    for(int i=0;i<n;i++){
        cin>>m>>s;
        if(s=="BTC"){
            oto+=m*380000.0;
        }else{
            oto+=m;
        }
    }
    cout<<oto<<endl;
}


Measured memory_bytes: 256
h,w,k = gets.chomp.split(" ").map(&:to_i)
c = Array.new(h).map{Array.new}
h.times do |i|
  c[i] = gets.chomp
end
ans = 0
[0, 1].repeated_permutation(h+w) do |bits|
  sub = Array.new(h).map{Array.new}
  h.times do |i|
    sub[i] = "" + c[i]
  end
  h.times do |i|
    if bits[i] == 1
      for j in 0..w-1
        sub[i][j] = "."
      end
    end
  end
  w.times do |i|
    if bits[h+i] == 1
      for j in 0..h-1
        sub[j][i] = "."
      end
    end
  end
  black = 0
  h.times do |i|
    black += sub[i].count("#")
  end
  ans += 1 if black == k
end
puts ans

Measured memory_bytes: 14360
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;

template<typename T> void Show(vector<vector<T>> v) {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << " ";
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(vector<T> v) {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<T> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}

int main() {
	string s = "";
	cin >> s;
	auto found = getUniform(false, 26);
	for (int i = 0; i < s.length(); ++i) {
		if (found[s[i] - 'a']) {
			cout << "no" << endl;
			return 0;
		}
		found[s[i] - 'a'] = true;
	}
	cout << "yes" << endl;
}


Measured memory_bytes: 256
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
using System.Timers;

static class MainClass
{
    public static void Main(string[] args)
    {
        var n = Console.ReadLine().ToInt32();
        BigInteger before = 1;
        for (int i = 0; i < n; i++)
        {
            var t = Console.ReadLine().ToBigInteger();
            before = (t * before) / Gcd(t, before);
        }
        Console.WriteLine(before);
        Console.ReadLine();
    }

    #region ライブラリ

    #region 文字列処理

    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();

    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    #endregion
    #region DeepClone
    public static T DeepClone<T>(this T src)
    {
        using (var memoryStream = new MemoryStream())
        {
            var binaryFormatter
              = new BinaryFormatter();
            binaryFormatter.Serialize(memoryStream, src);
            memoryStream.Seek(0, SeekOrigin.Begin);
            return (T)binaryFormatter.Deserialize(memoryStream);
        }
    }
    #endregion

    public static int Gcd(int a,int b)
    {
        if (b == 0)
            return a;
        return Gcd(b, a % b);
    }
    public static BigInteger Gcd(BigInteger a, BigInteger b)
    {
        if (b == 0)
            return a;
        return Gcd(b, a % b);
    }


    public static BigInteger Factorial(int n)
    {
        var dp = new BigInteger[n];
        dp[0] = 1;
        for (int i = 1; i < n; i++)
        {
            dp[i] = dp[i - 1] * (i + 1);
        }
        return dp[n - 1];
    }

    #endregion

}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
    vector<int> P(A), Q(B), R(C);
    for (auto &p : P) cin >> p;
    for (auto &q : Q) cin >> q;
    for (auto &r : R) cin >> r;
    priority_queue<pair<int, int>> H;
    for (auto p : P) H.emplace(p, 0);
    for (auto q : Q) H.emplace(q, 1);
    for (auto r : R) H.emplace(r, 2);
    int x = 0, y = 0, z = 0;
    Int ans = 0;
    while (x + y + z < X + Y) {
        int s, t; tie(s, t) = H.top(); H.pop();
        if (t == 0 && x < X) {
            x++;
            ans += s;
        } else if (t == 1 && y < Y) {
            y++;
            ans += s;
        } else if (t == 2) {
            z++;
            ans += s;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 7536
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int cost = sc.nextInt();
    int money = sc.nextInt();
    int satisfaction = sc.nextInt();
    if(cost * satisfaction <= money){
      System.out.println(satisfaction);
    }else{
      System.out.println(money / cost);
    }
  }
}

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

int main(){
  double n,k;
  cin >>n>>k;
  vector<double> p(n);
  
  for (int i=0;i<n;i++){
    cin>>p.at(i);
  }
  double m=0,t=0;
  
  for (int i=0;i<k;i++){
    t+=p.at(i);
  }
  m=t;
  for (int i=0;i<n-k;i++){
    t=t-p.at(i)+p.at(i+k);
    
    if (m<t){
      m=t;
    }
    
  }

  cout << std::fixed << std::setprecision(10) <<(m+k)/2 << endl;
}




Measured memory_bytes: 1792
n,m,q=map(int,input().split())
a=[0]*q
b=[0]*q
c=[0]*q
d=[0]*q
x=[0]*10
s=0
ans=0
for i in range(q):
  a[i],b[i],c[i],d[i]=map(int,input().split())
for a0 in range(1,m+1):
  x[0]=a0
  for a1 in range(x[0],m+1):
    x[1]=a1
    for a2 in range(x[1],m+1):
      x[2]=a2
      for a3 in range(x[2],m+1):
        x[3]=a3
        for a4 in range(x[3],m+1):
          x[4]=a4
          for a5 in range(x[4],m+1):
            x[5]=a5
            for a6 in range(x[5],m+1):
              x[6]=a6
              for a7 in range(x[6],m+1):
                x[7]=a7
                for a8 in range(x[7],m+1):
                  x[8]=a8
                  for a9 in range(x[8],m+1):
                    x[9]=a9
                    for j in range(q):
                      if x[b[j]-1]-x[a[j]-1]==c[j]:
                        s=s+d[j]
                    ans=max(ans,s)
                    s=0
print(ans)

Measured memory_bytes: 71476
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
i64 xs[100], ys[100], hs[100];
int main() {
  cin >> n;
  for (i64 i = 0; i < n; ++i) cin >> xs[i] >> ys[i] >> hs[i];

  if (hs[0] == 0) {
    for (i64 i = 1; i < n; ++i) {
      if (hs[i] != 0) {
        swap(xs[0], xs[i]);
        swap(ys[0], ys[i]);
        swap(hs[0], hs[i]);
        break;
      }
    }
  }

  i64 cx, cy, ch = 0;
  for (i64 y = 0; y <= 100; ++y) {
    for (i64 x = 0; x <= 100; ++x) {
      i64 ah = hs[0] + abs(x - xs[0]) + abs(y - ys[0]);
      if (ah > ch) {
        bool f = true;
        for (i64 i = 1; i < n; ++i) {
          i64 bh = hs[i] + abs(x - xs[i]) + abs(y - ys[i]);
          if (hs[i] == 0) {
            if (ah > bh) { f = false; break; }
          } else {
            if (ah != bh) { f = false; break; }
          }
        }
        if (f) {
          cx = x;
          cy = y;
          ch = ah;
        }
      }
    }
  }

  cout << cx << ' ' << cy << ' ' << ch << '\n';
  return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10**7)

ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

from collections import defaultdict

n = ni()
xy = nan(n)

dic = defaultdict(int)
for i in range(n):
    cx, cy = xy[i]
    cx += 10 ** 9
    cy += 10 ** 9
    for j in range(n):
        if i == j:
            continue
        nx, ny = xy[j]
        nx += 10 ** 9
        ny += 10 ** 9
        dic[(nx - cx, ny - cy)] += 1

m = 0
for k, v in dic.items():
    m = max(v, m)

ans = n - m
print(ans)

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,S=1,T=1,a;cin>>N;
  for(int i=0;i<N;i++){
    S*=3;cin>>a;
    if(a%2==0)T*=2;
  }
  cout<<S-T<<endl;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loop2(num) for (lli j = 0 ; j < num ; j ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back ()
#define pof pop_front ()

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

signed main ()
{
    fastio
    int x ; cin >> x ; x += x * x + x * x * x;
    cout << x ;
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 3596
//ID:computerbox --> Hajiyev Huseyn
#include <bits/stdc++.h>
#define FAST_READ ios_base::sync_with_stdio(0);/*cin.tie(0); cout.tie(0);*/
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
#define MAXN 200010

using namespace std;

ll r,g;

int main(){
FAST_READ;
cin>>r>>g;
ll gg=g*2;
cout<<gg-r<<endl;






return 0;
} 

Measured memory_bytes: 256
n,t = map(int, input().split())
sh = float("inf")
l = list()

for i in range(n):
    a,b = map(int, input().split())
    if t >= b:
        if a < sh:
            sh = a
if sh == float("inf"):
    print("TLE")
else:
    print(sh)
    

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

using namespace std;
#define ll long long
#define ld long double

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin >> v[i];

    ll ans = 0;
    for(int a=0;a<=min(n, k);a++) {
        for(int b=0;a+b<=min(n, k);b++) {
            vector<int> h;
            ll sum = 0;
            for(int i=0;i<a;i++) {
                h.push_back(v[i]);
                sum += v[i];
            }
            for(int i=0;i<b;i++) {
                h.push_back(v[n-i-1]);
                sum += v[n-i-1];
            }
            sort(h.begin(), h.end());
            for(int i=0;i<min(k-a-b, (int)h.size());i++) {
                if(h[i] < 0) sum -= h[i];
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <climits>
#include <algorithm>
#include <functional>
#include <string.h>
#include <numeric>

#define LOP(N) for(int i=0; i<N; i++)
#define LOOP(i, N) for(int i=0; i<N; i++)
#define LOOP_s(i, start, end) for(int i=start; i<end; i++)

typedef long long ll;

using namespace std;


int main() {
    string S; cin >> S;
    int a = S[0] - '0', b = S[1] - '0', c = S[2] - '0', d = S[3] - '0';
    
    int ans;
    LOOP(i, 8) {
        ans = a;
        ans += i&1 ? b : -b;
        ans += i&2 ? c : -c;
        ans += i&4 ? d : -d;
        // cout << ans << endl;
        if (ans == 7) {
            cout
                << a << (i&1 ? '+' : '-')
                << b << (i&2 ? '+' : '-')
                << c << (i&4 ? '+' : '-')
                << d << "=7";
            return 0;
        }
    }
}


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

int main(){
  int H, W;
  cin>>H>>W;
  vector<vector<char>> data(H, vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>data.at(i).at(j);
    }
  }
  vector<vector<char>> ans(H+2, vector<char>(W+2));
  for(int i=0;i<W+2;i++){
    ans.at(0).at(i) = '#';
    ans.at(H+1).at(i) = '#';
  }
  for(int i=1;i<H+1;i++){
    ans.at(i).at(0) = '#';
    ans.at(i).at(W+1) = '#';
    for(int j=1;j<W+1;j++){
      ans.at(i).at(j) = data.at(i-1).at(j-1);
    }
  }
  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
      cout<<ans.at(i).at(j);
    }
    cout<<endl;
  }
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int w,s,o,c=0;
	scanf("%d%d",&w,&s);
	for(int x=0;x<=w;x++)
	{
		for(int y=0;y<=w;y++)
		{
			int o=s-(x+y);
			if(o>=0&&o<=w)
			c++;
		}
	}
	printf("%d",c);
	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>>E(100);
int ans=0;
int n,m;
void dfs(int now,int vis){
  if(vis==(1<<n)-1){ans++;return;}
  for(auto a:E[now]){
    if(!(vis&(1<<a))){
      dfs(a,vis|(1<<a));
    }
  }
  return;
}
int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b;cin>>a>>b;
    E[--a].push_back(--b);
    E[b].push_back(a);
  }
  dfs(0,1);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

const ll MOD = 998244353;
// const ll MOD = 1e9+7;

//累乗(mod付き)
ll pow_mod(ll a, ll b, ll mod) {
  if (a % mod == 0) {
    return 0;
  }

  ll x = 1;

  while (b > 0) {
    if (b & 1) {
      x = (x * a) % mod;
    }
    a = (a * a) % mod;
    b >>= 1;
  }
  return x;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll m,k;
  std::cin>>m>>k;

  if(m==0){
    if(k==0)std::cout<<"0 0";
    else std::cout<<-1;
  }else if(m==1){
    if(k==0)std::cout<<"0 1 1 0";
    else std::cout<<-1;
  }else{
    ll pow2=pow_mod(2,m,LLONG_MAX);
    if(k<pow2){
      rep(i,0,pow2){
        if(i!=k)std::cout<<i<<" ";
      }
      std::cout<<k<<" ";
      for(ll i=pow2-1;i>=0;i--){
        if(i!=k)std::cout<<i<<" ";
      }
      std::cout<<k;
    }else{
      std::cout<<-1;
    }
  }

  return 0;
}

Measured memory_bytes: 1792
// Author: Mohammad Faisal
#include<iostream>
using namespace std;
int main()
{
  int N; cin >> N;
  if(N<105) cout << 0;
  else if(N<135) cout << 1;
  else if(N<165) cout << 2;
  else if(N<189) cout << 3;
  else if(N<195) cout << 4;
  else cout << 5;
  return 0;
}

Measured memory_bytes: 256
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new File("c:\\0526-input.txt"));

		while (scan.hasNext()) {
			int n = scan.nextInt();
			int k = scan.nextInt();
			if (n == 0)
				break;
			FareList f = new FareList(n);
			for (int i = 0; i < k; i++) {
				int c = scan.nextInt();
				if (c == 0)
					System.out.println(f.answer(scan.nextInt(), scan.nextInt()));
				else if (c == 1)
					f.addRoot(scan.nextInt(), scan.nextInt(), scan.nextInt());

			}
		}
		scan.close();
		System.exit(0);
	}
}

class FareList {
	int[][] fare;

	public FareList(int n) {
		fare = new int[n][n];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				if (i == j)
					fare[i][j] = 0;
				else
					fare[i][j] = -1;
	}

	public void addRoot(int fr, int to, int amt) {
		if (fare[fr - 1][to - 1] != -1 && fare[fr - 1][to - 1] <= amt)
			return;
		this.newFare(fr - 1, to - 1, amt);
	}

	private void newFare(int fr, int to, int amt) {
		fare[fr][to] = amt;
		fare[to][fr] = amt;
		for (int f = 0; f < fare.length; f++)
			for (int t = 0; t < fare[f].length; t++) {
				if (fare[f][fr] != -1 && fare[to][t] != -1) {
					int namt = fare[f][fr] + fare[fr][to] + fare[to][t];
					if (fare[f][t] == -1 || namt < fare[f][t])
						fare[f][t] = namt;
				}
				if (fare[f][to] != -1 && fare[fr][t] != -1) {
					int namt = fare[f][to] + fare[to][fr] + fare[fr][t];
					if (fare[f][t] == -1 || namt < fare[f][t])
						fare[f][t] = namt;

				}
			}
	}

	public int answer(int fr, int to) {
		return fare[fr - 1][to - 1];
	}

}

Measured memory_bytes: 55496
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int m = sc.nextInt();
		String s = sc.next();
		ArrayList<Integer> list = new ArrayList<>();
		int now = -1;
		int last = n;
		for (int i = s.length() - 1; i > 0; i--) {
			if (s.charAt(i) == '0') {
				now = i;
			}
			if (last - i == m) {
				list.add(last - now);
				if (last == now) {
					System.out.println(-1);
					return;
				}
				last = now;
			}
		}
		list.add(last);
		Collections.reverse(list);
		int tmp = list.remove(list.size() - 1);
		for (int ans :
				list) {
			System.out.print(ans + " ");
		}
		System.out.println(tmp);
	}
}


class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

using namespace std;

unsigned long long x;
unsigned long long y;

int main(void)
{
	scanf("%llu", &x);
	
	y = 100;
	
	for(unsigned long long i = 1 ;  ; i++)
	{	
		y = y + y / 100;
		
		if(y >= x)
		{
			printf("%llu", i);
			return 0;
		}
	}
	
	printf("3760");
	return 0;
}

Measured memory_bytes: 3868
#include<stdio.h>
#define ROOM 10
#define FLOOR 3
#define BUILD 4

int main(){
   int n;
   int b, f, r, v;
   int House[BUILD][FLOOR][ROOM]={0};

   int i, j, k;

   scanf("%d", &n);

   for(i=0;i<n;i++){
      scanf("%d %d %d %d", &b, &f, &r, &v);
      House[b-1][f-1][r-1] += v;
   }

   for(i=0;i<BUILD;i++){
      for(j=0;j<FLOOR;j++){
         for(k=0;k<ROOM;k++){
            if(k==ROOM-1) printf(" %d\n", House[i][j][k]);
            else printf(" %d", House[i][j][k]);
         }
      }
	  if(i!=BUILD-1) printf("####################\n");
   }

   return 0;
}

Measured memory_bytes: 608
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<assert.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 2e5+10, M = 1e6+10;
int n, q;
struct SGT {
	struct node {
		int l, r;
		int mn, add;
	}tr[N * 4];
	void pushup(int u) {
		tr[u].mn = min(tr[u << 1].mn, tr[u << 1 | 1].mn);
	}
	void pushdown(int u) {
		if(tr[u].add != INF) {
			tr[u << 1].mn = min(tr[u << 1].mn, tr[u].add);
			tr[u << 1].add = min(tr[u << 1].add, tr[u].add);
			tr[u << 1 | 1].mn = min(tr[u << 1 | 1].mn, tr[u].add);
			tr[u << 1 | 1].add = min(tr[u << 1 | 1].add, tr[u].add);
			tr[u].add = INF;
		}
	}
	void build(int u, int l, int r) {
		if(l == r) {
			tr[u] = {l, r, n, INF};
		} else {
			int mid = l + r >> 1;
			tr[u] = {l, r, 0, INF};
			build(u << 1, l, mid);build(u << 1 | 1, mid + 1, r);
			pushup(u);
		}
	}
	void modify(int u, int l, int r, int d) {
		if(tr[u].l >= l&&tr[u].r <= r) {
			tr[u].mn = min(tr[u].mn, d);
			tr[u].add = min(tr[u].add, d);
		} else {
			int mid = tr[u].l + tr[u].r >> 1;
			pushdown(u);
			if(l <= mid) modify(u << 1, l, r, d);
			if(r > mid) modify(u << 1 | 1, l, r, d);
			pushup(u);
		}
	}
	int query(int u, int l, int r) {
		if(tr[u].l >= l&&tr[u].r <= r) {
			return tr[u].mn;
		} else {
			int mid = tr[u].l + tr[u].r >> 1;
			pushdown(u);
			int res = INF;
			if(l <= mid) res = min(res, query(u << 1, l, r));
			if(r > mid) res = min(res, query(u << 1 | 1, l, r));
			pushup(u);
			return res;
		}
	}
}x, y;
int main() {
	cin>>n>>q;
	x.build(1, 1, n);
	y.build(1, 1, n);
	ll num = (ll)(n - 2) * (n - 2);
	while(q--) {
		int op, cur;
		cin>>op>>cur;
		//cout<<"                        ";
		if(op == 1) {
			int tmp = y.query(1, cur, cur);
			num -= max(0, (tmp - 2));
			x.modify(1, 1, tmp, cur);
			y.modify(1, cur, cur, 1);
			//cout<<tmp<<" ";
		} else {
			int tmp = x.query(1, cur, cur);
			num -= max(0, (tmp - 2));
			x.modify(1, cur, cur, 1);
			y.modify(1, 1, tmp, cur);
			//cout<<tmp<<" ";
		}
		//cout<<num<<"\n";
	}
	cout<<num;
	return 0;
}

Measured memory_bytes: 19964
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
const ll INF=99999999999999999;
ll a,b,c,d,e,f,ans=0;
int main(){
    ll n;
  cin>>n;
    vl x(n),y(n),z;

    rep(i,n){
        cin>>x[i];
        y[i]=i+1;
    }

    while(1){

        for(int i=n-1;i>-1;i--){
            if(y[i]==x[i]){
                z.push_back(x[i]);
                y[i]=-1;
                for(int j=i+1;j<n;j++){
                    y[j]--;
                }
                goto next;
            }
        }
        break;
        next:
        a=0;
    }

    if(z.size()==n){
        rep(i,z.size()){
            cout<<z[n-1-i]<<endl;
        }
    }
    else{
        cout<<-1<<endl;
    }

}

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	string s, t; cin >> s >> t;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int main()
{
    char a[12];
    cin>>a;
    int i;
    for(i=0; i<4; i++)
        cout<<a[i];
    cout<<" ";
    for(i=4; i<12; i++)
        cout<<a[i];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int D, T, S;
    in3(D, T, S);

    if (D <= T * S)
    {
        outl("Yes");
    }
    else
    {
        outl("No");
    }

    return 0;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-

from math import atan, pi

def readInts():
  return [int(s) for s in input().split(" ")]

def to_degree(rad):
  return 180.0 * (rad / pi)

def main():
  a, b, x = readInts()

  theta = atan(b / a)
  theta1 = atan(2 * ((a ** 2) * b - x) / (a ** 3))

  if 0 <= theta1 <= theta:
    print(to_degree(theta1))
  else:
    theta2 = atan((a * (b ** 2)) / (2 * x))
    print(to_degree(theta2))

if __name__ == "__main__":
  main()


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

using namespace std;

int main() { 
	int n, m;
	cin >> n >> m;
	int b = n / 2, o = b + 1;
	int oo = 1, k = n - 1;
	for(int i = 0; i < m; i++)
		if(i & 1) cout << oo++ << " " << k-- << endl;
		else cout << b-- << ' ' << o++ << endl;
}

Measured memory_bytes: 3592
sx,sy,tx,ty = map(int,input().split())
ans = 'U'*(ty-sy)+'R'*(tx-sx)+'D'*(ty-sy)+'L'*(tx-sx)
ans += 'L' + 'U'*(ty-sy+1) + 'R'*(tx-sx+1) + 'DR' + 'D'*(ty-sy+1) + 'L'*(tx-sx+1) + 'U'
print(ans)

Measured memory_bytes: 3060
x,y,a,b,c = (int(x) for x in input().split())
list_p = list(map(int,input().split()))
list_q = list(map(int,input().split()))
list_r = list(map(int,input().split()))
list_p.sort()
list_q.sort()
list_p.reverse()
list_q.reverse()
for i in range(x):
    list_r.append(list_p[i])
for i in range(y):
    list_r.append(list_q[i])
list_r.sort()
list_r.reverse()
sum=0
for i in range(x+y):
    sum+=list_r[i]
print(sum)


Measured memory_bytes: 111340
#!/usr/bin/env ruby
def read_input()
  edge_num = gets(chomp: true).to_i
  edges = []
  graph = {}
  (1...edge_num).reduce([edges,graph]) do |acc,_|
    edges, graph = acc
    edge = gets(chomp: true).split()
    edges << edge
    a,b = edge
    if (!graph.has_key?(a))
      graph[a] = []
    end
    graph[a] << b
    [edges, graph]
  end
end

def solve(graph, node, base_color, color_edge, max)
  children = graph[node]
  return [max, color_edge] if children.nil?
  edge_num = children.length
  edge_num += 1 unless (base_color.nil?)
  max = edge_num if (edge_num > max)
  color = 0
  children.reduce([max, color_edge]) do |acc, child|
    max, color_edge = acc
    color += 1
    color += 1 if (color == base_color)
    color_edge[node] = {} if (color_edge[node].nil?)
    color_edge[node][child] = color
    solve(graph, child, color, color_edge, max)
  end
end

edges, graph = read_input
max, color_edge = solve(graph, "1", nil, {}, -1)

puts max
edges.each do |a,b|
  puts color_edge[a][b]
end


Measured memory_bytes: 209480
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define mod (int)1e9+7
#define inf (int)1e16
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
int h, w;
char c[2222][2222];
int d[2222][2222];
vector<P>o;
signed main() {
	cin >> h >> w;
	rep(i, h) {
		rep(j, w) {
			cin >> c[i][j];
			if (c[i][j] == '.') o.push_back(P(i, j));
		}
	}
	rep(i, h) {
		int cnt = 0;
		rep(j, w) {
			if (c[i][j] == '#') {
				if (cnt) {
					Rep(k, j - 1) {
						if (c[i][k] == '#') break;
						d[i][k] += cnt;
					}
				}
				cnt = 0;
			}
			else if (j == w - 1) {
				cnt++;
				Rep(k, j) {
					if (c[i][k] == '#') break;
					d[i][k] += cnt;
				}
			}
			else {
				cnt++;
			}
		}
	}
	rep(i, w) {
		int cnt = 0;
		rep(j, h) {
			if (c[j][i] == '#') {
				if (cnt) {
					Rep(k, j - 1) {
						if (c[k][i] == '#') break;
						d[k][i] += cnt;
					}
				}
				cnt = 0;
			}
			else if (j == h - 1) {
				cnt++;
				Rep(k, j) {
					if (c[k][i] == '#') break;
					d[k][i] += cnt;
				}
			}
			else {
				cnt++;
			}
		}
	}
	int ans = 0;
	rep(i, o.size()) {
		ans = max(ans, d[o[i].first][o[i].second] - 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 104796
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int H, W;
	cin >> H >> W;
	vector<vector<LL>> cost(10, vector<LL>(10,INF));
	for (int i = 0; i < 10; ++i) {
		for (int j = 0; j < 10; ++j) {
			cin >> cost[i][j];
		}
	}
	for (int k = 0; k < 10; ++k) {
		for (int i = 0; i < 10; ++i) {
			for (int j = 0; j < 10; ++j) {	
				cost[i][j] = min(cost[i][j],
					cost[i][k] + cost[k][j]);
			}
		}
	}
	
	LL ans = 0;//200^2 * 10^3
	for (int h = 0; h < H; ++h) {
		for (int w = 0; w < W; ++w) {
			int ter;
			cin >> ter;
			if (ter >= 0) {
				ans += cost[ter][1];
			}
		}
	}
	cout << ans << endl;
	
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


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

int main(){
  int a,b,c,d,cnt1=0,cnt2=0;
  cin >> a >> b >> c >> d;
  while(a>0){
    a-=d;
    cnt1++;
  }
  while(c>0){
    c-=b;
    cnt2++;
  }
  if(cnt1>=cnt2){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

using namespace std;
#define MAX 100

void push (int);
int pop (void);
int isempty (void);


int stack[MAX];
int idx = 0;

int main () {
  string c;
  int a, b,cnt=0;
  

  while (cin >>c) {



	    
	    // is num
	    
	    


    if (c == "+") {
      push(pop()+pop());
    } else if (c == "-") {
      a = pop();
      b = pop();
      push(b-a);
    } else if (c == "*") {
      push(pop()*pop());
    } else if (c == "/") {
      push(pop()/pop());
    } else{ //if (atoi(c.c_str()) >= 0 && atoi(c.c_str()) <= 9) {

      push (atoi(c.c_str()));
    } /*else {
      printf ("Unsupported charactor!\n");
    }
      */
    
    

  }
  
  
  printf("%d\n",stack[0]);
  return 0;
}
void push (int x) {
  //printf ("push v:%d idx:%d\n", x, idx);
  stack[idx] = x;
  idx ++;
  return;
}
int pop () {
  if (isempty() == 1) return NULL;
  idx --;
  //printf ("pop  v:%d idx:%d\n", stack[idx], idx);
	int t = stack[idx];
	stack[idx] = NULL;
	return t;
}
int isempty () {
  if (idx == 0) return 1;
  else return 0;
}

Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  vector<ll> p(n);
  for(ll i = 0; i < n; ++i) cin >> p[i];
  ll ans = 0;
  for(ll i = 1; i < n-1; ++i){
    if(p[i] > p[i-1] and p[i] < p[i+1]) ++ans;
    else if(p[i] < p[i-1] and p[i] > p[i+1]) ++ans;
  }
  cout << ans;
  return 0;
}

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

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)


#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
 
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
 
typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*1000 + 11;

int arr[NMAX];
int n,m,p,q,k,a,b,c,ans;
string s,str;
char ch;
vector<int> v;

void solve()
{
    cin>>n;
    int d = n%10;
    if(d == 2 or d == 4 or d == 5 or d==7 or d==9){
        cout<<"hon";
    }else if(d==3){
        cout<<"bon";
    }else
    cout<<"pon";
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3652
package main

import (
	"bufio"
	"container/list"
	"fmt"
	"log"
	"os"
	"strconv"
)

const abcd = "abcdefghijklnmopqrstuvwxyz"
const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
const MAX = 1e9

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

func main() {
	log.SetFlags(log.Lshortfile)
	scn := newScanner()
	N := scn.nextInt()
	M := scn.nextInt()
	edges := make([]Edge, 0)
	g := make([][]int, N+1)
	for i := 0; i < M; i++ {
		a := scn.nextInt()
		b := scn.nextInt()
		edges = append(edges, Edge{u: a, v: b})
		g[a] = append(g[a], len(edges)-1)
		edges = append(edges, Edge{u: b, v: a})
		g[b] = append(g[b], len(edges)-1)
	}
	vis := make([]bool, N+1)
	s := edges[0].u
	t := edges[0].v
	ans := list.New()
	for !vis[s] || !vis[t] {
		if !vis[s] {
			ans.PushFront(s)
		}
		if !vis[t] {
			ans.PushBack(t)
		}
		vis[s] = true
		vis[t] = true
		for _, edgeIdx := range g[s] {
			v := edges[edgeIdx].v
			if !vis[v] {
				s = v
				break
			}
		}
		for _, edgeIdx := range g[t] {
			v := edges[edgeIdx].v
			if !vis[v] && v != s {
				t = v
				break
			}
		}
	}
	fmt.Println(ans.Len())
	for ans.Len() > 0 {
		fmt.Println(ans.Remove(ans.Front()))
	}
}

type Edge struct {
	u int
	v int
}

///////////////////////////////////////////////////
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) nextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) nextInt() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) nextInt64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 17920
var
  n,l,i,j:longint;
  t:string;
  a:array[0..101] of string;
begin
  readln(n,l);
  for i:=1 to n do readln(a[i]);
  for i:=1 to n-1 do
    for j:=i+1 to n do
      if a[i]>a[j] then 
        begin
          t:=a[i]; a[i]:=a[j]; a[j]:=t;
        end;
  for i:=1 to n do write(a[i]);
end.

Measured memory_bytes: 128
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979

int main()
{
	ll storeNum, drink, ans = 0, sum = 0;
	cin >> storeNum >> drink;
	vector<pair<ll, ll>> a(storeNum);
	rep(i, storeNum)
	{
		cin >> a[i].first >> a[i].second;
	}
	sort(a.begin(), a.end());
	
	rep(i, storeNum)
	{
		if (sum + a[i].second <= drink)
		{
			ans += a[i].first * a[i].second;
			sum += a[i].second;
		}
		else
		{
			ans += (drink - sum) * a[i].first;
			sum += drink - sum;
		}
		if (sum >= drink) break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4824
#include "bits/stdc++.h"
#define   LF      '\n'
#define   ALL(x)  x.begin(), x.end()
#define   LEN(x)  (int)x.size()
#define   iostreamBooster()  do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

int N;
i64 a_[200100], *a = a_ + 5;

signed main()
{
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    a[i] += a[i-1];
  }

  unordered_map<i64, int> cnt;

  ++cnt[0];
  for (int i = 0; i < N; ++i) {
    ++cnt[a[i]];
  }

  i64 ans = 0;
  for (const auto &e : cnt) {
    i64 k = e.second;
    ans += k * (k-1) / 2;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 10056
#include<bits/stdc++.h>
#define fi first
#define se second
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
#define pb push_back
#define IT iterator
#define SZ(a) ((int)a.size())
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20,mod=998244353,inf=2e9;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

//math
ll mult(ll a,ll b,ll p) {
	a=(a%p+p)%p; b=(b%p+p)%p;
	ll c=(ld)a*b/p;
	return a*b-c*p;
}
ll gcd(ll a,ll b) {return !a?b:gcd(b%a,a);}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
ll power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=c*a%mod;
		b /= 2; a=a*a%mod;
	}
	return c;
}
ll Power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=mult(c,a,mod);
		b /= 2; a=mult(a,a,mod);
	}
	return c;
}

int n,m,a[N];

int main() {
	qr(n); qr(m);
	for(int i=1,x;i<=n;i++)qr(a[i]);
	for(int i=m+1;i<=n;i++)
		if(a[i]>a[i-m]) puts("Yes");
		else puts("No");
	return 0;
}




Measured memory_bytes: 4412
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
    
int top, S[1000];
    
void push(int x){
  S[++top]=x;
}
    
int pop(){
  top--;
  return S[top+1];
}
    
int main(){
    
int a,b;
top=0;
char s[100];
    
while (scanf("%s",s)!=EOF){
  if (s[0] == '+') {
  a=pop();
  b=pop();
  push(a+b);
  }
  else if (s[0] == '-'){
  b=pop();
  a=pop();
  push(a-b);
  }
  else if (s[0]=='*'){
  a=pop();
  b=pop();
  push(a*b);
  }
  else {
  push(atoi(s));
  }
}
    
    
printf("%d\n", pop());
return 0;
    
}


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

int main()
{
    long long int N,M,i,sum=0;
    cin>>N>>M;

    int a[M];
    for(i=0;i<M;i++)
        cin>>a[i];

    for(i=0;i<M;i++)
    {
        sum+=a[i];
    }

    if(sum>N)
        cout<<-1<<endl;
    else
        cout<<N-sum<<endl;

    return 0;
}


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

char vowel[] = {'a', 'i', 'u', 'e', 'o'};
 int main(){
   char c;
   cin >> c;
   int j = 0;
   for(int i = 0; i < sizeof vowel; i++){
     if(vowel[i]==c)j=1;
   }
   if(j)cout << "vowel" << endl;
   else cout << "consonant" << endl;
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int a[N], b[N], n;
inline int read () {
    int tot = 0, f = 1; char c = getchar ();
    while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar (); }
    while (c >= '0' && c <= '9') { tot = tot * 10 + c - '0'; c = getchar ();}
    return tot * f;
}
signed main () {
    n = read ();
    for (int i = 1; i <= n; i++) a[i] = read ();
    for (int i = 1; i <= n; i++) b[i] = read ();
    reverse (b + 1, b + 1 + n);
    int l = 0, r, t, L, R;
    for (int i = 1; i <= n; i++) {
        if (a[i] == b[i]) {
            if (l == 0) l = i, r = i, t = b[i];
            else r++;
        }
        else if (l != 0) break;
    }
    if (l == 0) {
        printf ("Yes\n");
        for (int i = 1; i <= n; i++)
            printf ("%d ", b[i]);
        return puts(""), 0;
    }
    //l~r为交集
    //L~R为并集
    for (int i = 1; i <= n; i++) if (a[i] == t || b[i] == t) { L = i - 1; break; }
    for (int i = n; i >= 1; i--) if (a[i] == t || b[i] == t) { R = i + 1; break; }
    // cout<<t<<" "<<L<<" "<<R<<endl;
    if (n - (R - L) < R - L) return puts("No"), 0;
    int pos = 1;
    for (int i = l; i <= r; i++) {
        if (pos == L + 1) pos = R;
        swap(b[i], b[pos]);
        pos++;
    }
    printf ("Yes\n");
    for (int i = 1; i <= n; i++)
        printf ("%d ", b[i]);
    return puts(""), 0;
}


Measured memory_bytes: 5292