akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))
#define N 100005

int h[N];
vector<vi> g;

int main(void) {
	int n, m;
	scanf("%d%d", &n, &m);
	REP(i, n) {
		scanf("%d", &h[i]);
	}

	g.resize(n);

	REP(i, m) {
		int x, y;
		scanf("%d%d", &x, &y);
		x--, y--;
		g[x].pb(y);
		g[y].pb(x);
	}

	int ans = 0;
	REP(i, n) {
		bool ok = 1;
		REP(j, sz(g[i])) {
			int u = g[i][j];
			if (h[i] <= h[u]) {
				ok = 0;
				break;
			}
		}

		if (ok) {
			ans++;
		}
	}

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

Measured memory_bytes: 8836
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;
    cin >> s;

    if(s[0] == '9' or s[1] == '9') cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

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

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

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

int DIGIT_DP(string &str,int K)
{
  int N = str.size();
  vector<vector<vector<int> > > DP(N+1,vector<vector<int> > (2,vector<int>(N+2,0)));

  DP[0][0][0] = 1;//振り分けるための1
  int L =str.size();
  for (int i = 0; i < N; i++)
  {
    int D =str[i] - '0';
    for (int j = 0; j <2; j++)
    {
      for (int k = 0; k < N+1; k++)
      {
        for (int d = 0; d <= (j?9:D); d++)//jがfalseならDまで（未満フラグが立ってないもの） jがtrueなら強制的に桁のMAXまで見る。
        {
          if(d == 0)
          {
            DP[i+1][j||(d<D)][k] += DP[i][j][k];
          }

          else
          {
          DP[i+1][j||(d<D)][k+1] += DP[i][j][k];
          }
          
          /*
          第2インデックス d<Dか未満フラグが立ってるものに関してはDP1にDPの値が入るそうでないものはゼロ
          第3インデックス 0は有効な数字(すでに禁止文字が出ているものk==1)や現在の桁d == 4やd==9が発生しているものは1に入る。
          */
        }
        
      }
      
    }
  }
  cout<<DP[N][0][K] + DP[N][1][K]<<endl;
  return -1;
}

void solve(void)
{
  string str;int K;
  cin>>str;
  cin>>K;

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

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

  return 0;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,a=0,b=0,c=0,d=0;
cin>>n;
string s;
for(int i=0;i<n;i++)
{cin>>s;
if(s=="AC")
    a++;
else if(s=="WA")
    b++;
else if(s=="TLE")
    c++;
else if(s=="RE")
    d++;
}
cout<<"AC x "<<a<<"\nWA x "<<b<<"\nTLE x "<<c<<"\nRE x "<<d;;
}


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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############

N,K,C = inputIL()
S = inputS()

L = []

i = 0
c = 0
while i<N:
  if c == K:
    break
  if S[i]=="o":
    L.append(i)
    c += 1
    i += C+1
  else:
    i += 1

R = []

i = N-1
c = 0
while i>=0:
  if c == K:
    break
  if S[i]=="o":
    R.append(i)
    c += 1
    i -= C+1
  else:
    i -= 1

R = R[::-1]
for i in range(K):
  if L[i] == R[i]:
    print(L[i]+1)


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

#define task "A"
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';}
#define SZ(x) ((int)(x).size())
#define pb push_back
#define pf push_front
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next nextalscjaowjico
#define prev prevoua0wucckjsl
#define y1 y1kscj9u20cjeijc
#define left leftljascjljl
#define right rightsocjolkjl
#define y0 y0cqu3jioajc

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;

int main()
{
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(false);cin.tie(nullptr);
#else
    //freopen(task".in","r",stdin);
    //freopen(task".out","w",stdout);
#endif
    string s;
    cin >> s;
    bool a = 0, b = 0;
    rep(i, 0, 2) if (s[i] == 'A') a = 1;
    else b = 1;
    if (a && b) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
#define ll long long
#define R register
#include <bits/stdc++.h>

using namespace std;

const int maxn = 2e5 + 5;

int n, ans, a[maxn], f[maxn];

int main()
{
	scanf("%d", &n);
	for (R int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for (R int i = 1; i <= n; ++i)
		f[a[i]] = f[a[i] - 1] + 1, ans = max(ans, f[a[i]]);
	printf("%d", n - ans);
	return 0;
}

Measured memory_bytes: 1792
// Sum of Number

import java.util.Scanner;

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

    // Input
    while(true){
      String numStr = sc.nextLine();
      if(numStr.equals("0")){
        break;
      }

      int ans = 0;
      for(int i=0; i<numStr.length(); i++){
        String tmp = String.valueOf(numStr.charAt(i));
        ans += Integer.parseInt(tmp);
      }

      // Output
      System.out.println(ans);

    }
  }
}



Measured memory_bytes: 26880
#include<bits/stdc++.h>
using namespace std;
int cha(int x)
{
	x%=10;
	x=10-x;
	x%=10;
	return x;
}
int main()
{
	int tot=0,n,max=0;
	int time[5+1];
	cin>>time[1];
	cin>>time[2];
	cin>>time[3];
	cin>>time[4];
	cin>>time[5];
	for(int i=1;i<=5;i++)
	{
		if(max<cha(time[i]))
		{
			max=cha(time[i]);
		}
	}
	for(int i=1;i<=5;i++)
	{
		tot+=time[i];
		tot+=cha(tot);
	}
	tot-=max;
	cout<<tot;
	return 0;
 } 

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

#define LOCAL 0

#define lli long long int
#define llu unsigned long long int
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define slli(n) scanf("%lld",&n);
#define ss(n) scanf("%s",n);

const long double EPS = 1e-10;
const lli MOD = 1000000007ll;
const lli mod1 = 1000000009ll;
const lli mod2 = 1100000009ll;
int INF = (int)1e9;
lli INFINF = (lli)1e18;
int debug = 0;
long double PI = acos(-1.0);

using namespace std;

lli bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
lli bit(lli _mask,lli _i){return (_mask&(1<<_i))==0?0:1;}
lli powermod(lli _a,lli _b,lli _m=MOD){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli add(lli a,lli b,lli m=MOD){lli x=a+b;while(x>=m)x-=m;while(x<0)x+=m;return x;}
lli sub(lli a,lli b,lli m=MOD){lli x=a-b;while(x<0)x+=m;while(x>=m)x-=m;return x;}
lli mul(lli a,lli b,lli m=MOD){lli x=a*1ll*b;x%=m;if(x<0)x+=m;return x;}



int main()
{
if(LOCAL){
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    debug = 1;
}
    srand (time(NULL));

    string s;
    cin>>s;
    if(s[0] == s[s.size()-1] && s.size()%2==1)
        cout<<"Second";
    else if(s[0] != s[s.size()-1] && s.size()%2==0)
        cout<<"Second";
    else
        cout<<"First";

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch GuessTheNumber | diff GuessTheNumber.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address GuessTheNumber.cpp && ./a.out

/*
 
 3/1/2020
 
 8:38-8:47 WA
 
 
 */

const int MAX_N=5+1;
int A[MAX_N],S[MAX_N],C[MAX_N];
int N,M;

void no() {
  cout<<-1<<endl;
  exit(0);
}
void solve() {
  MINUS(A);
  REP(i,M) {
    int j=S[i]-1;
    if(A[j]!=-1&&A[j]!=C[i]) no();
    A[j]=C[i];
  }
  if(A[0]==0) {
    if(N==1) {
      cout<<0<<endl;
      return;
    }
    no();
  }
  REP(i,N) if(A[i]==-1) A[i]=N>1&&i==0?1:0;
  string res(N,'?');
  REP(i,N) res[i]='0'+A[i];
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>M;
  REP(i,M) cin>>S[i]>>C[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc054/tasks/abc054_c

int g[15][15];

int main() {
    int N, M; cin >> N >> M;
    REP(i, M) {
        int a, b; cin >> a >> b;
        g[a][b] = 1;
        g[b][a] = 1;
    }

    vector<int> perm(N-1);
    REP(i, N-1) perm[i] = i + 2;
    sort(perm.begin(), perm.end());

    int ans = 0;
    do {
        int now = 1;
        for (int i = 0; i < perm.size(); i++) {
            if (!g[now][perm[i]]) break;
            now = perm[i];
            if (perm.size()-1 == i) ans++;
        }
    } while(next_permutation(perm.begin(), perm.end()));

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		if (0 < a) {
			System.out.println("Positive");
		} else if (a <= 0 && 0 <= b) {
			System.out.println("Zero");
		} else {
			if ((b - a) % 2 == 0) {
				System.out.println("Negative");
			} else {
				System.out.println("Positive");
			}
		}
	}

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


Measured memory_bytes: 8788
#include <iostream>
#include<vector>
#include<map>
#include<string>
#include<stdio.h>
#include<math.h>
#include <algorithm>

#define PI		3.14159265358979
#define IMAX	2147483647

using namespace std;

int main(void) {

	string str;

	cin >> str;
	string ans = "Good";

	for (int i = 1; i < str.size(); i++) {
		if (str[i - 1] == str[i]) {
			ans = "Bad";
			break;
		}
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

struct Node{
  int now;
  //int sub;
  long cost;
};

struct Edge{
  int from;
  int to;
  long cost;
};

bool operator<(const Node &a, const Node &b){
  if(a.cost != b.cost){
    return a.cost < b.cost;
  }else{
    return a.now < b.now;
  }
}
bool operator>(const Node &a, const Node &b){return (b < a);}
bool operator<=(const Node &a, const Node &b){return !(b < a);}
bool operator>=(const Node &a, const Node &b){return !(a < b);}

//vector<vector<Edge>> Graph;

vector<long> Dijkstra(vector<vector<Edge>> &Graph, int s){ //最小コスト
  priority_queue<Node, vector<Node>, greater<Node>> que;
  vector<long> dist(Graph.size(), 1e16);

  dist.at(s) = 0;
  que.push(Node{s, 0});

  while(que.size()){
    Node node = que.top();
    que.pop();
    int v = node.now;
    if(node.cost > dist.at(v)) continue;
    for(Edge edge : Graph.at(v)){
      int nv = edge.to;
      long cost = edge.cost;
      if(dist.at(nv) > dist.at(v) + cost){
        dist.at(nv) = dist.at(v) + cost;
        que.push(Node{nv, dist.at(nv)});
      }
    }
  }
  return dist;
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<Edge>> Graph(n);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    Graph.at(a).push_back({a,b,1});
    Graph.at(b).push_back({b,a,1});
  }
  vector<long> dist = Dijkstra(Graph, 0);
  cout << "Yes" << endl;
  REP(i,1,n){
    long now = dist.at(i);
    for(Edge ed : Graph.at(i)){
      int nv = ed.to;
      if(dist.at(nv) == now - 1){
        cout << nv+1 << endl;
        break;
      }
    }
  }
}

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

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

    char ans;

    for(int i=0;i<N;i++){
        cin>>ans;
        if(ans=='Y'){
            cout<<"Four"<<endl;
            break;
        }
        else{
            if(i==N-1){
                cout<<"Three"<<endl;
            }
        }
    }
}


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

int main()
{
    int a, b;
    cin >> a >> b;

    if (a + b == 3)
    {
        cout << 3 << endl;
    }
    else if (a + b == 4)
    {
        cout << 2 << endl;
    }
    else
    {
        cout << 1 << endl;
    }

    return 0;
}

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

long long n;
vector<vector<long long>> v;
long long sum[70000] = {0};
long long dp[70000] = {0};

void sumset();
long long solve(int now);

int main() {
  cin >> n;
  v.resize(n);
  for(int i = 0; i < n; ++i) {
    v[i].resize(n);
    for(int j = 0; j < n; ++j) cin >> v[i][j];
  }
  sumset();
  for(int i = 0; i < (1 << n); ++i) dp[i] = -1;
  for(int i = 0; i < n; ++i) dp[(1 << i)] = 0;
  cout << solve((1 << n) - 1) << endl;
  return 0;
}

void sumset() {
  for(int i = 0; i < (1 << n); ++i) {
    for(int j = 0; j < n; ++j)
      for(int k = j + 1; k < n; ++k)
        if(((i >> j) & 1) && ((i >> k) & 1))
          sum[i] += v[j][k];
  }
}

long long solve(int now) {
  if(dp[now] != -1) return dp[now];
  long long ans = 0;
  for(int x = now; x > 0; --x &= now) {
    ans = max(ans, sum[x] + solve(now - x));
  }
  return dp[now] = ans;
}

Measured memory_bytes: 1408
import math
N = int(input())
XY = [list(map(int,input().split())) for _ in  range(N)]

ans = 0
L = 10**5
for i in range(L):
    x,y = [math.cos(2*math.pi*i/L),math.sin(2*math.pi*i/L)]
    tmpx,tmpy = 0,0
    for j in range(N):
        xj,yj = XY[j]
        if x*xj + y*yj > 0:
            tmpx += xj
            tmpy += yj
            
    ans = max(ans,math.sqrt(tmpx*tmpx+tmpy*tmpy))
    
print(ans)
            
    
    

Measured memory_bytes: 41804
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int n;
    cin>>n;
    vector<int> vec(n),vec2(n);
    rep(i,n){
        cin>>vec[i];
        vec2[i]=vec[i];
    }
    sort(vec2.rbegin(),vec2.rend());
    rep(i,n){
        if(vec[i]!=vec2[0])cout<<vec2[0]<<endl;
        else cout<<vec2[1]<<endl;
    }
}

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

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string str;
    cin >> str;

    if (n % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    string half = str.substr(0, n / 2);
    string otherHalf = str.substr(n/2, n/2);
    if (half == otherHalf) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

class ITP1_1_C
{
    static void Main(string[] args)
    {
        var str = Console.ReadLine().Split(' ');
        if (str.Length < 2)
            return;
        var x = int.Parse(str[0]);
        var y = int.Parse(str[1]);

        // Console.WriteLine($"{x*y} {2*x+2*y}");
        Console.WriteLine(string.Format("{0} {1}", x * y, 2 * x + 2 * y));
    }
}

Measured memory_bytes: 9100
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    ll N,M;
    cin >> N >> M;
    if(N>M) swap(N, M);
    if(N==1 && M==1){
        cout << 1 << endl;
    } else if(N==1&& M>=2){
        cout << M-2 << endl;
    } else if(N==2){
        cout << 0 << endl;
    } else {
        ll ans = (N-2)*(M-2);
        cout << ans << endl;
    }
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
    int N,max,min;
    cin>>N;
    vector<int>A(N),B(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
        B[i]=A[i];
    }
    sort(A.begin(),A.end());
    max=A[N-1];
    if(A[N-1]==A[N-2]){
        for(int i=0;i<N;i++){
            cout<<max<<endl;
        }
    }else{
        min=A[N-2];
        for(int i=0;i<N;i++){
            if(max!=B[i]){
                cout<<max<<endl;
            }else{
                cout<<min<<endl;
            }
        }
    }

   
    

}

Measured memory_bytes: 3200
N, K = map(int, input().split())
LARGE = 10 ** 9 + 7

# (N - K - 1)Ci * (K - 1)C(i - 1)


def p_inv(k, p):
    return pow(k, p-2, p)


res_list = [0] * K

ncr1 = N - K + 1
ncr2 = 1
res_list[0] = N - K + 1

for i in range(2, min(N - K + 2, K + 1)):

    ncr1 *= N - K + 2 - i
    ncr1 *= p_inv(i, LARGE)
    ncr1 = ncr1 % LARGE

    ncr2 *= K + 1 - i
    ncr2 *= p_inv(i - 1, LARGE)
    ncr2 = ncr2 % LARGE

    res_list[i - 1] = (ncr1 * ncr2) % LARGE

for r in res_list:
    print(r)


Measured memory_bytes: 41200
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, m; cin>>n>>m;
	int a[200020];
	int c[200020]={};
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
		c[a[i]]++;
	}
	int s[200020]={};
	for(int i=1; i<=n; i++){
		s[max(1, i-c[i]+1)]++;
		s[i+1]--;
	}
	for(int i=1; i<=n; i++) s[i]+=s[i-1];
	int ans=0;
	for(int i=1; i<=n; i++) if(s[i]==0) ans++;
	for(int i=0; i<m; i++){
		int x, y; scanf("%d %d", &x, &y); x--;
		if(a[x]>=c[a[x]]){
			if(s[a[x]-c[a[x]]+1]==1) ans++;
			s[a[x]-c[a[x]]+1]--;
		}
		c[a[x]]--;
		a[x]=y;
		c[y]++;
		if(y>=c[y]){
			if(s[y-c[y]+1]==0) ans--;
			s[y-c[y]+1]++;
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << a * b /2 << endl;

    return 0;
}


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

pub 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 s: String = read();
    let mut sc: Vec<char> = s.chars().collect();
    // remove last element
    sc.pop();
    for _ in 0..sc.len() {
        if checker(&sc) {
            println!("{}", sc.len());
            return;
        }
        sc.pop();
    }
}

fn checker(sc: &Vec<char>) -> bool {
    if sc.len() % 2 != 0 {
        return false;
    }

    for i in 0..sc.len() / 2 {
        if sc[i] != sc[i + (sc.len() / 2) as usize] {
            return false;
        }
    }
    return true;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define printd(x) printf("%.12f\n", ans);
#define print(x) cout << (x) << endl;
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
#define all(x) (x).begin(),(x).end()
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main(void) {
    int n;
    cin >> n;
    int a[n + 1], b[n], aa[n + 1], bb[n];
    rep (i, n + 1) cin >> a[i];
    rep (i, n) cin >> b[i];
    rep (i, n + 1) aa[i] = a[i];
    rep (i, n) bb[i] = b[i];

    ll ans1 = 0, ans2 = 0;
    for (int i = 0; i < n; i++) {
        if (b[i] >= a[i]) {
            ans1 += a[i];
            b[i] -= a[i];
        }
        else {
            ans1 += b[i];
            b[i] = 0;
        }
        if (b[i] >= a[i + 1]) {
            ans1 += a[i + 1];
            a[i + 1] = 0;
        }
        else {
            ans1 += b[i];
            a[i + 1] -= b[i];
        }
    }

    for (int i = n - 1; i >= 0; i--) {
        if (bb[i] >= aa[i + 1]) {
            ans2 += aa[i + 1];
            bb[i] -= aa[i + 1];
        }
        else {
            ans2 += bb[i];
            bb[i] = 0;
        }
        if (bb[i] >= aa[i]) {
            ans2 += aa[i];
            aa[i] = 0;
        }
        else {
            ans2 += bb[i];
            aa[i] -= bb[i];
        }
    }
        
    cout << max(ans1, ans2) << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner


object Main {


  def read() = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val p = IndexedSeq.fill(n)(sc.nextInt())
    (n, p)
  }

  def solve(n:Int, p:IndexedSeq[Int]): Long = {
    (1 to n-2).count { i =>
      val t = IndexedSeq(p(i - 1), p(i), p(i + 1)).sorted
      t(1) == p(i)
    }
  }

  def main(args: Array[String]): Unit = {
    val (n, p) = read()
    println(solve(n, p))
  }
}

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

int main(){
	ios::sync_with_stdio(false);
	
	string s; cin>>s;
	s[3] = '8';
	cout << s << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
 
#define lli long long int
#define endl "\n"
 
using namespace std;
 
typedef long long int LLI;
typedef double DB;
 
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
 
 
bool comparator(pair<lli,lli> a,pair<lli,lli> b)
{
    if(a.first>b.first)
        return true;
    else if (a.first==b.second)
    {
        if(a.second>=b.second)
            return false;
        return true;
    }
    return false;
}
 
int mods(int x)
{
    if(x>0)
        return x;
    return -x;
}
 
lli gcd(lli a,lli b)
{
    return __gcd(a,b);
}
 
lli lcm(lli x,lli y,lli z)
{
    lli j=gcd(x,y);
    lli k=gcd(y*x/j,z);
    return (((x*y)/j)*z)/k;
} 

int isprime(int n)
{
    for(int i=2;i<=sqrt(n);++i)
    {
        if(n%i==0) return 0;
    }
    return 1;
}

lli mlkfs(lli n)
{
    if(n>1) return 2*mlkfs(n/2)+1;
    if(n==1) return 1;
}

int main()
{
    fastio();
    lli n,a,b; cin>>n>>a>>b;
    lli z=n/(a+b);
    lli rem=n%(a+b);
    cout<<z*a+min(rem,a);
    return 0;
}

Measured memory_bytes: 256
import collections
n,x,m=map(int,input().split())
if n==1 or x==0:
  print(x)
  exit()
start,end,loopcnt=0,0,0
a={x:0}
wk=x
for i in range(1,m):
  wk=(wk*wk)%m
  if not wk in a:
    a[wk]=i
  else:
    start=a[wk]
    end=i
    break
a=sorted(a.items(),key=lambda x:x[1])
koteiindex=min(n,start)
koteiwa=0
for i in range(koteiindex):
  koteiwa+=a[i][0]
loopcnt=(n-koteiindex)//(end-start)
loopindex=start-1+(n-koteiindex)%(end-start)
loopwa=0
amariwa=0
for i in range(start,end):
  if i<=loopindex:
    amariwa+=a[i][0]
  loopwa+=a[i][0]
ans=koteiwa+loopwa*loopcnt+amariwa
print(ans)


Measured memory_bytes: 18784
import java.util.Scanner;

public class Main {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc =  new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int result = 0;
		int kakudo = 0;
		while(true) {
			result++;
			kakudo += n;
			if (kakudo%360==0) {
				break;
			}
		}
		System.out.println(result);
	}
	
}

Measured memory_bytes: 35692
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.Dwango5
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nk = ReadInts();
            int n = nk[0];
            int k = nk[1];
            int all = n * (n + 1) / 2;
            long[] array = ReadLongs();
            var sums = new List<long>();
            for (int i = 0; i < n; i++)
            {
                sums.Add(array[i]);
                for (int j = i+1; j < n; j++)
                {
                    sums.Add(sums[sums.Count - 1] + array[j]);
                }
            }

            /*
            var sumBits = new bool[all][];
            for (int i = 0; i < all; i++)
            {
                long div = 1;
                long temp = sums[i];
                sumBits[i] = new bool[40];
                for(int j = 0; j< 40; j++)
                {
                    sumBits[i][j] = (temp & div) > 0;
                    div *= 2;
                    Console.Write(sumBits[i][j] ? '1' : '0');
                }
                Console.WriteLine();
            }
            */
            long res = 0;
            for(long i = 40; i >= 0; i--)
            {
                long div = (long)Math.Pow(2, i);
                int cnt = 0;
                for(int j = 0; j < sums.Count; j++)
                {
                    if ((sums[j] & div) > 0) cnt++;
                }
                if (cnt < k) continue;

                res += div;
                var nextList = new List<long>();
                for(int j = 0; j < sums.Count; j++)
                {
                    if ((sums[j] & div) > 0) nextList.Add(sums[j]);
                }
                sums = nextList;
            }

            Console.WriteLine(res);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

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

    ll l[n];
    rep(i, n)cin >> l[i];

    ll dp[n+1];
    rep(i, n+1)dp[i] = LINF;
    dp[0] = 0;

    rep(i, n-1){
        dp[i+1] = min(dp[i+1], dp[i] + abs(l[i]-l[i+1]));

        if(i-1 >= 0)dp[i+1] = min(dp[i+1], dp[i-1]+abs(l[i-1]-l[i+1]));
    }

    cout << dp[n-1];
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Graph;
const int M = 1e9 + 7;
const ll INF = 1e9;
const int MAX_V = 100000 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = n;
  rep(i, n - 1) {
    if (s[i] == s[i + 1]) {
      ans--;
    }
  }
  out(ans);
}


Measured memory_bytes: 512
while True:
    n,x=map(int,input().split())
    if n==0 and x==0:
        break
    a=[]
    for i in range(1,n+1):
        a.append(i)
#    print(a)

    listx=[]
    for j in range(1,n-1):
        for k in range(2,n):
            if k<=j:
                continue
            for l in range(3,n+1):
                if l<=k or l<=j:
                    continue
                if j+k+l==x:
#                    print(j,k,l)
                    jkllist=[j,k,l]
                    jkllist.sort()
                    listx.append(jkllist)
#    print(listx)
    print(format(len(listx),'.0f'))



Measured memory_bytes: 5672
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}
////////////////////////////////////////////////////////////
signed main() {
  int n;
  cin>>n;
  vector<int>a(n);
  vector<int>aa(n);
  rep(i,n){cin>>a[i];aa[i]=a[i];}
  map<int,int>soinsuu;
  rep(i,n){
    map<int,int>tsoin;
    for(int j=2;j<=floor(pow(a[i],0.5));j++){
      while(a[i]%j==0){
        a[i]/=j;
        tsoin[j]++;
      }
    }
    if(a[i]!=1)tsoin[a[i]]++;
    for(auto&&x:tsoin){
      if(x.second>soinsuu[x.first])soinsuu[x.first]=x.second;
    }
  }

int L=1;
  for(auto&&x:soinsuu){
    rep(i,x.second){
      L=L*x.first%MOD;
    }
  }
  int ans=0;
  rep(i,n){
    ans=(ans+L*gyaku(aa[i]))%MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4844
import sys
from collections import defaultdict
input = sys.stdin.readline
sys.setrecursionlimit(10**8)

class UnionFind():
    def __init__(self, n):
        self.par = [-1 for i in range(n)]

    def root(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x]) # contraction
            return self.par[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.par[x] > self.par[y]: # merge technique
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.par[self.root(x)]

n, k, l = map(int, input().split())
uf_r = UnionFind(n)
for i in range(k):
    p, q = map(int, input().split())
    p -= 1
    q -= 1
    uf_r.unite(p, q)
uf_t = UnionFind(n)
for i in range(l):
    r, s = map(int, input().split())
    r -= 1
    s -= 1
    uf_t.unite(r, s)

root_r = defaultdict(set)
root_t = defaultdict(set)
for i in range(n):
    root_r[uf_r.root(i)].add(i)
    root_t[uf_t.root(i)].add(i)

ans = []
memo = defaultdict(int)
for i in range(n):
    memo[(uf_r.root(i), uf_t.root(i))] += 1
for i in range(n):
    ans.append(memo[(uf_r.root(i), uf_t.root(i))])

print(*ans)


Measured memory_bytes: 160196
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
class Main{
  public static void main(String args[]) throws IOException{
   
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   
   while(true){
   String[] token = br.readLine().split(" ");
    int m = Integer.parseInt(token[0]);      
    int f = Integer.parseInt(token[1]);
    int r = Integer.parseInt(token[2]);
    if(m == -1 && f == -1 && r == -1) {break;}
    if(m==-1||f == -1){       
      System.out.println("F");
     }else if(m+f >= 80){  
     System.out.println("A");   
    }else if( m + f >= 65){ 
     System.out.println("B");   
     }else if( m + f >= 50 ){ 
       System.out.println("C");
     }else if( m + f >= 30){
       if(r >= 50){
        System.out.println("C");   
       }else{
         System.out.println("D");
       }
     }else{
       System.out.println("F");
     }

   }
 
  }
}

Measured memory_bytes: 24136
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        for(int i = 0;i < n;i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }
        List<List<Integer>> routes = new ArrayList<>();
        List<Integer> candidate = new ArrayList<>();
        for(int i = 0;i < n;i++) candidate.add(i);

        searchRoute(candidate, new ArrayList<>(), routes);
        
        double totalD = 0;
        for(int i = 0;i < routes.size();i++) {
            List<Integer> route = routes.get(i);
            for(int j = 0;j < route.size() - 1;j++) {
                int x1 = x[route.get(j)];
                int y1 = y[route.get(j)];
                int x2 = x[route.get(j + 1)];
                int y2 = y[route.get(j + 1)];
                totalD += (Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2)));
            }
        }

        double ans = totalD / routes.size();
        System.out.println(ans);
    }

    private static void searchRoute(List<Integer> candidate, List<Integer> route, List<List<Integer>> result) {
        if(candidate.isEmpty()) {
            result.add(route);
        }

        for(int i = 0;i < candidate.size();i++) {
            Integer tmp = candidate.get(i);
            List<Integer> tmpCandidate = new ArrayList<>(candidate);
            List<Integer> tmpRoute = new ArrayList<>(route);
            tmpCandidate.remove(i);
            tmpRoute.add(tmp);
            searchRoute(tmpCandidate, tmpRoute, result);
        }

        return;
    }

}


Measured memory_bytes: 48612
#include<cstdio>
#include<algorithm>

#define	rep(i,n)	for(int i=0;i<n;i++)

using namespace std;

struct Gate{ int cap,fil,drn,ud; };

int main(){
	for(int m,n,L;scanf("%d%d%d",&m,&n,&L),n;){
		const int OFSET=100;

		Gate gt[100];
		int gtpos[1204];
		rep(i,1204)	gtpos[i]=-1;
		rep(i,m){
			int x;
			scanf("%d%d%d%d%d",&x,&gt[i].cap,&gt[i].fil,&gt[i].drn,&gt[i].ud);
			gtpos[x+OFSET]=i;
		}
		int v[101];
		rep(i,n)	scanf("%d",v+i+1);

		double open[100];
		rep(i,m){
			if(gt[i].ud==0)	open[i]=0;
			else			open[i]=1.*gt[i].cap/gt[i].fil;
		}

		static double dp[101][1204][2];
		rep(j,1204)rep(k,2)	dp[0][j][k]=-1e60;
		for(int i=1;i<=n;i++){
			dp[i][-i+1+OFSET][0]=0;
			dp[i][-i+1+OFSET][1]=0;

			for(int j=-i+2;j<L+OFSET+3;j++){
				dp[i][j+OFSET][0]=max(dp[i  ][j-1+OFSET][1]+1./v[i],
									  dp[i-1][j+1+OFSET][0]);
				if(gtpos[j+OFSET]==-1){
					dp[i][j+OFSET][1]=max(dp[i  ][j  +OFSET][0],
										  dp[i-1][j+1+OFSET][1]);
				}
				else{
					int idx=gtpos[j+OFSET];
					double up  =1.*gt[idx].cap/gt[idx].fil;
					double down=1.*gt[idx].cap/gt[idx].drn;
					double start=max(dp[i][j+OFSET][0],open[idx]);
					double end=start+((gt[idx].ud==0)?up:down);
					open[idx]=start+up+down;
					dp[i][j+OFSET][1]=max(end,dp[i-1][j+1+OFSET][1]);
				}
			}
		}

		printf("%.9f\n",dp[n][L+OFSET][0]);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int N = 200005;

int n;
LL m;
int a[N];
vector<LL> b, c;
LL zero;
bool check(LL x) {
    LL cnt = 0;
    if (x < 0) {
        x = -x;
        for (auto u : b) {
            LL t = (x + u - 1) / u;
            cnt += c.end() - lower_bound(c.begin(), c.end(), t);
        }
        for (auto u : c) {
            LL t = (x + u - 1) / u;
            cnt += b.end() - lower_bound(b.begin(), b.end(), t);
        }
    } else if (x == 0) {
        cnt += zero * (zero - 1) + zero * (n - zero) * 2 + (LL)b.size() * c.size() * 2;
    } else {
        cnt += zero * (zero - 1) + zero * (n - zero) * 2 + (LL)b.size() * c.size() * 2;
        for (auto u : b) {
            LL t = x / u;
            cnt += upper_bound(b.begin(), b.end(), t) - b.begin();
            if (u <= t) cnt--;
        }
        for (auto u : c) {
            LL t = x / u;
            cnt += upper_bound(c.begin(), c.end(), t) - c.begin();
            if (u <= t) cnt--;
        }
    }

    return cnt / 2 >= m;
}
int main() {
    scanf("%d%lld", &n, &m);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        if (a[i] < 0) {
            b.push_back(-a[i]);
        } else if (a[i] > 0) {
            c.push_back(a[i]);
        } else {
            zero++;
        }
    }
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    LL l = -1e18, r = 1e18;
    while (l < r) {
        LL mid = l + (r - l) / 2;
        if (check(mid)) {
            r = mid;
        } else {
            l = mid + 1;
        }
    }
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 2932
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()

typedef pair<int, vector<int> > Paper;
Paper solve(int t, int num){
    string s = to_string(num);
    int L = (int)s.size() - 1;
    vector<Paper> cands;
    rep(i, 1<<L){
        vector<int> parts;
        for(int j=0; j<=L; ++j){
            string d = "";
            for(d+=s[j]; j<=L; ++j, d+=s[j])if(i >> j & 1)break;
            parts.push_back(stoi(d));
        }
        cands.emplace_back(accumulate(all(parts), 0), parts);
    }
    sort(all(cands));
    int k = count_if(all(cands), [&](const Paper& p){return p.first <= t;});
    if(k == 0)throw "error";
    if(count_if(cands.begin(), cands.begin() + k - 1,
                [&](const Paper& p){return p.first == cands[k-1].first;}))throw "rejected";
    return cands[k-1];
}

int main(){
    int t, num;
    while(cin >> t >> num, t|num){
        try{
            Paper ans = solve(t, num);
            cout << ans.first;
            for(const auto e: ans.second)cout << " " << e;
            cout << '\n';
        }catch(const char* mes){
            cout << mes << '\n';
        }
    }
    return 0;
}

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

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

    string ans = "";
    for(char c: S){
        int pos = c - 'A';
        pos = (pos + N)%26;
        ans += 'A' + pos;
    }
    cout << ans << endl;
}

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

int main() {
	int n;
	ll x;
	cin >> n >> x;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	int ans = 0;
	int ai = 0;
	rep(i, n) {
		if (x >= a[ai]) {
			ans++;
			x -= a[ai];
			ai++;
		}
		else {
			cout << ans << endl;
			return 0;
		}
	}
	if (x > 0) cout << ans - 1 << endl;
	else cout << ans << endl;
}

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

lis = sorted(lis)

count = [0]*100001

for i in range(n):
    count[lis[i]] += 1

ans = 0

for j in range(1,100000):
    t = count[j-1]+ count[j]+ count[j+1]
    ans = max(ans, t)
    
print(ans)

Measured memory_bytes: 20876
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define pb push_back
using ll = long long;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main(){
  int BTC = 380000;
  int N;
  string Type;
  double sum = 0;
  cin >>N;
  REP(i,N){
    double temp = 0;
    cin >> temp >> Type;
    
    if(Type[0] == 'J'){
      sum += temp;
    }else if(Type[0] == 'B'){
      sum += temp * BTC;
    }

  }
  cout << sum << endl;

}


Measured memory_bytes: 256