akhauriyash/Code-Regression huggingface dataset:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    n = int(input())
    numbers=[]
    numbers=list(map(int,input().split()))
    print(*numbers)
    for i in range(1,n):
        #key is numbers value.when starting numbers[1].
        key = numbers[i]
        #j is numbers startpoint.when starting 0.
        j=i-1
        while j>= 0 and numbers[j] > key:
            # insert key in back of numbers[j+1]
            numbers[j+1] = numbers[j]
            j-=1
        numbers[j+1]=key
        print(*numbers)

if __name__=="__main__":
    main()


Measured memory_bytes: 5992
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    vector<int> h(n);
    for(int& i: h)
    {
        scanf("%d",&i);
    }
    const int INF=1e9+5;
    vector<int> dp(n,INF);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+2;j++)
        {
            if(j<n)
            {
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
            }
        }
    }

    cout<<dp[n-1]<<endl;

}

Measured memory_bytes: 1024
N,M = map(int, input().split())
if N <= 1 or M <= 1:
  if N == 1 and M == 1:
    print(1)
    exit(0)
  else:
    m = max(N,M)
    if m == 2:
      print(0)
      exit(0)
    else :
      print(m-2)
      exit(0)
print((N-2)*(M-2))
exit(0)

Measured memory_bytes: 38512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int> a(n);rep(i,n){
    cin>>a[i];
  }
  vector<int> l(n+2,0),r(n+2,0); 
  rep(i,n){
    l[i+2] = gcd(l[i+1],a[i]);
  }
  for(int i = n;i > 0;--i){
    r[i] = gcd(r[i+1],a[i-1]);
  }
  int ans = 0;
  rep(i,n){
    ans = max(ans,gcd(r[i+2],l[i+1]));
  }
  print(ans);

  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B,i,j;
  cin>>N>>A>>B;
  int ans = 0;
  
  for(i=1;i<=N;i++){
    int sum = 0;
    j=i;
    while(j>=1){
      sum = sum + j % 10;
      j /= 10;
    }
    if(A<=sum && sum<=B){
      ans += i;
      //cout << i << endl;
    }

  }
  
  cout << ans;

}

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

int main(){
  int x;
  rep(i, 5){
    cin >> x;
    if (x == 0){
      cout << i+1 << endl;
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3596
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*



fun solve() {
    val N = rd.readLong()
    
    var cnt = 0L
    for (a in 1L until N) {
        val cMin = 1L
        val cMax = N-1L
        val bMax = min((N - cMin)/a, N-1L)
        val bMin = max((N - cMax)/a, 1L)

        cnt += bMax - bMin + 1L
    }

    val ans = cnt
    println(ans)
}


//val rd = debug.Reader("abc", "179", "c", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
const val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)
data class To(val idx: Int, val cost: Long)
typealias ALI = ArrayList<Int>
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readDouble: () -> Double = { br.readLine().toDouble() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readIntArray: () -> IntArray = { readListInt().toIntArray() }
    val readLongArray: () -> LongArray = { readListLong().toLongArray() }
    val readListStringCol: (Int) -> List<String> = { N -> (0 until N).map { readString() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListIntCols: (Int) -> List<List<Int>> = { N -> (0 until N).map { readListInt() } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val readListLongCols: (Int) -> List<List<Long>> = { N -> (0 until N).map { readListLong() } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


Measured memory_bytes: 34788
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  long ret = 0;
  long count = 0;
  string S;
  cin >> S;
  rep (i, S.size()) {
    if (S[i] == 'A' or S[i] == 'T' or S[i] == 'C' or S[i] == 'G') {
      count ++;
    } else {
      ret = max(ret, count);
      count = 0;
    }
  }
  ret = max(ret, count);
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
using namespace std;
bool isThere(int arr[], int len, int x){
	for (int i=0;i<len; i++){
		if (x==arr[i]) return true;
	}
	return false;
}

int main(){
  int x, n;
  cin >> x >> n;
  if (n==0){
  	cout << x << endl;
  	return 0;
  }
  int arr[n];
  for (int i=0; i<n; i++){
    cin >> arr[i];
  }
  for (int i=0; i<101;i++){
    if (!isThere(arr, n, x-i)){
    	cout << x-i << endl;
    	return 0;
    } 
    else if (!isThere(arr, n, x+i)){
    	cout << x+i << endl;
    	return 0;
    }
  }
}


Measured memory_bytes: 3184
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[1010][1010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1010][1010];
vector<ll> va,vb,vc;

int main(){
    cin>>a>>b>>c;
    aa[a]++;
    aa[b]++;
    aa[c]++;
    C (aa[5]==2 and aa[7]==1 ? "YES":"NO") E;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int N,M; cin >> N >> M;
    if(N == M) cout << "Yes" << endl;
    else cout << "No" << endl;
}
    



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(void) {
  int n;
  int a[200001];
  int b[200001];
  cin>>n;
  for(int i=1; i<=n; i++) {
    int x;
    cin>>x;
    a[i]=x;
    b[i]=x;
  }
  sort(a+1, a+n+1);
  for(int i=1; i<=n; i++) {
    if(b[i]<=a[n/2]) cout<<a[(n/2)+1]<<endl;
    else cout<<a[n/2]<<endl;
  }
  return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,s=0;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=0;i<n;i++)
	for(int j=0;j<n-i-1;j++)
	if(a[j]<a[j+1])
	swap(a[j],a[j+1]);
	for(int i=0;i<k;i++)
	s+=a[i];
	cout<<s;
} 

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
 
int main(){
int a,b,result;
char op;



while(1){
	cin >> a >> op >> b;
if(op == '+'){
	result = a+b;
	cout << result << endl;
}else if(op == '-'){
	result = a-b;
	cout << result << endl;
}else if(op == '*'){
	result = a*b;
	cout << result << endl;
}else if(op == '/'){
	result = a/b;
	cout << result << endl;
}else if(op == '?'){
	break;
}

}

return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=0;
  int N=s.size();
  int i=0;int a=2;
  while(i<N-1){
  if(a==2){ans++; a=1;i++;}
    else{
    if(s.at(i)==s.at(i-1)){ans++; a=2; i+=2;}
      else{ans++; i++;}
    }
  }if(i==N-1 &&(a==2 || s.at(N-1)!=s.at(N-2)))ans++;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3740
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                int[][] ebishu = new int[2][n];
                long yono = 0;
                for(int vip = 0 ; vip < n ; vip++){
                        for(int pct = 0 ; pct < 2 ; pct++){
                                ebishu[pct][vip] = sc.nextInt();
                        }
                        yono += ebishu[1][vip] - ebishu[0][vip];
                        yono++;
                }
                System.out.println(yono);
        }
}
//変数宣言で遊べるの楽しいですね
//twitterフォロー推奨:@Ebishu_

Measured memory_bytes: 39456
#include<stdio.h> 
#include<iostream> 
#include<string.h>
#include<cstring>
#include<string>
#include<math.h>
#include<algorithm>
#include<bits/stdc++.h>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#define cuttime ios::sync_with_stdio(false)
#define swap(x, y) x ^= y, y ^= x, x^= y
#define INF 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define scan1(x) scanf("%d",&x)
#define scan2(x,y) scanf("%d%d",&x,&y)
#define scan3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scanll1(x) scanf("%lld",&x)
#define scanll2(x,y) scanf("%lld%lld",&x,&y)
#define scanll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define lowbit(x) (x&(-x))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define debug(x) cout <<#x<<": "<<x<<endl
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=2e5+20;
const int MAX=10000007;
inline ll read() {
    char c=getchar();ll x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0',c=getchar();}
    return x*f;
}
inline void out(ll x) {   
    if(x>9) out(x/10);   
    putchar(x%10+'0'); 
} 

int q[N];
int mp[1000005];
bool mp1[1000005];
int main(){
    int n;
    int x;
    int y;
    scan2(x,y);
    int a,b;
    b=(y-2*x)/2;
    a=x-b;
    if((y-2*x)%2!=0){
        puts("No");
        return 0;
    }
    if(a<0||b<0){
        puts("No");
    }
    else {
        puts("Yes");
    }
    return 0;
}
/*
 */

Measured memory_bytes: 3760
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int X = stdIn.nextInt();
		int A = stdIn.nextInt();
		if(X < A) {
			System.out.println(0);
		}
		else {
			System.out.println(10);
		}

	}

}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr ll MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

template <typename T>
T mypow(T a, T b)
{
    if (b == 0)
        return 1;
    T tmp = mypow(a, b / 2);
    if (b % 2)
        return (((tmp * tmp) % MOD) * a) % MOD;
    else
        return (tmp * tmp) % MOD;
}

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

    vector<ll> inv(100010, 1), sum(100010, 1);
    for (ll i = 2; i <= 100000; i++)
    {
        inv[i] = mypow(i, MOD - 2);
        sum[i] = (sum[i - 1] + inv[i]) % MOD;
    }
    int N;
    cin >> N;
    ll res = 0;
    vector<ll> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        ll p = (sum[N - i] + sum[i + 1] + MOD - 1) % MOD;
        res += A[i] * p;
        res %= MOD;
    }
    for (int i = 0; i < N; i++)
    {
        res *= (i + 1);
        res %= MOD;
    }
    cout << res << endl;
}


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

using namespace std;

using i64 = int64_t;

const i64 MOD = (i64)1e9 + 7;

const i64 INF = (i64)1e18 + 7;



int solve(int _count){

    int n = 0, m = 0;
    cin >> n >> m;
    vector<vector<int>> edges(n);
    for(int i = 0; i < m; ++i){
        int u, v;
        cin >> u >> v;
        edges[--u].emplace_back(--v);
    }
    int s, t;
    cin >> s >> t;

    if(!static_cast<bool>(cin))
        return MOD;
#ifdef TEST
    cout << "Case: " << _count << endl;
#endif

    vector<vector<int>> p(n, vector<int>(3, MOD));
    queue<pair<int,int>> que;
    --s, --t;
    p[s][0] = 0;
    que.emplace(s, 0);
    while(!que.empty()){
        int pos, dist;
        tie(pos, dist) = que.front();
        int d2 = dist + 1;
        que.pop();
        for(auto& y : edges[pos])
            if(p[y][d2 % 3] > d2){
                p[y][d2 % 3] = d2;
                que.emplace(y, d2);
            }
    }

    cout << (p[t][0] == MOD ? -1 : p[t][0] / 3) << endl;

    return 0;
}


signed main(){

    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int t = 0;
    while(solve(++t) != MOD);
}


Measured memory_bytes: 11264
def solve():
    INF = float('inf')

    def max2(x, y): return x if x >= y else y

    N, K = map(int, input().split())
    Hs = [0] + list(map(int, input().split()))

    if N == K:
        return 0

    dp = [INF] * (N+1)
    dp[0] = 0
    for j in range(1, N-K+1):
        dp2 = [INF] * (N+1)
        for i, H in enumerate(Hs[j:], j):
            for k in range(j-1, i):
                dp2[i] = min(dp2[i], dp[k] + max2(0, H-Hs[k]))
        dp = dp2

    return min(dp)

ans = solve()
print(ans)


Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int n = sc.nextInt();
        int m = 0;
        for(int i = 1; i <= n; i++){
            if(n%i == 0 && a <= i && i <=b){
                m++;
            }
            if(b < i)break;
        }
        System.out.print(m);
        System.out.println();
    }
}


Measured memory_bytes: 26244
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 1145141919
#define ll long long
//#define scanf scanf_s


int n, q, par[10005];

int root(int x)
{
	int tmp, tmp_,root;
	tmp = tmp_ = x;
	while (1)
	{
		if (par[tmp] == tmp) break;
		else
		{
			tmp = tmp[par];
		}
	}
	root = tmp;
	tmp = x;
	while (tmp != root)
	{
		tmp_ = tmp;
		tmp_ = par[tmp];
		par[tmp] = root;
		tmp = tmp_;
	}
	return root;
}

void unit(int x, int y)
{
	if (x < y) swap(x, y);
	par[root(y)] = root(x);
}

bool same(int x, int y)
{
	int rootx, rooty;
	int tmp = x;
	while (1)
	{
		if (par[tmp] == tmp) break;
		else tmp = par[tmp];
	}
	rootx = tmp;
	int tmp_;
	tmp = x;
	while (tmp != rootx)
	{
		tmp_ = tmp;
		tmp_ = par[tmp];
		par[tmp] = rootx;
		tmp = tmp_;
	}

	tmp = y;
	while (1)
	{
		if (par[tmp] == tmp) break;
		else tmp = par[tmp];
	}
	rooty = tmp;
	tmp = y;
	while (tmp != rooty)
	{
		tmp_ = tmp;
		tmp_ = par[tmp];
		par[tmp] = rooty;
		tmp = tmp_;
	}

	return rootx == rooty;
}

int main()
{
	cin >> n >> q;
	REP(i, n) par[i] = i;
	int a, b, c;
	REP(i, q)
	{
		cin >> a >> b >> c;
		if (a)
		{
			if (same(b, c)) cout << 1 << endl;
			else cout << 0 << endl;
		}
		else unit(b, c);
	}
	return 0;
}

Measured memory_bytes: 1200
#include<stdio.h>
int main(){
  int a,b;
  int n,flg=0;
  scanf("%d",&n);
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if(i*j==n)flg=1;
    }
  }
  if(flg){
    printf("Yes");
  }else{
    printf("No");
  }
  return(0);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int n = sc.nextInt();
		sc.close();

		int hc = 0;
		do {
			hc++;
			if(w*hc>=n){
				break;
			}
		} while (hc<=h);

		int wc = 0;
		do {
			wc++;
			if(h*wc>=n){
				break;
			}
		} while (wc<=h);

		System.out.println(hc<wc?hc:wc);
	}
}

Measured memory_bytes: 20820
def read():
    S = input().strip()
    return S,


def solve(S):
    for i in range(len(S) - 1):
        if S[i] == S[i+1]:
            return 'Bad'
    return 'Good'


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 2940
#!/usr/bin/env python3
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

(n, m), *LL = [[*map(int,o.split())] for o in open(0)]
UF = UnionFind(n + m)
for e, (k, *L) in enumerate(LL):
    for l in L:
        UF.union(e, l + n - 1)
print("YES" if len([i for i, x in enumerate(UF.parents) if x < 0 and i < n]) == 1 else "NO")

Measured memory_bytes: 25376
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

VVI g;
VI dist;
int ans;

void dfs(int v, int p, int n){
    for(int d: g[v]){
        if (d == p) continue;
        if (dist[d] != -1) continue;
        dist[d] = dist[v] + 1;
        if (dist[d] == n-1) ans++;
        dfs(d, v, n);
        dist[d] = -1;
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    g.resize(n);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    dist.resize(n, -1);
    dist[0] = 0;
    ans = 0;
    dfs(0, -1, n);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
package main

import "fmt"

func main() {
	ans := []int{}

	for {
		tmp := -1
		fmt.Scan(&tmp)

		if tmp == 0 {
			break
		}
		ans = append(ans, tmp)
	}

	for i, v := range ans {
		fmt.Printf("Case %d: %d\n", i+1, v)
	}
}



Measured memory_bytes: 2316
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }

int n, k;
vll va;
vector<bool> nec;

void init()
{
	cin >> n >> k;
	nec.resize(n, false);
	va.resize(n);
	REP(i, n) cin >> va[i];

	sort(ALL(va));
}

void declare()
{
	int ans = 0;
	REP(i, n)
		if (!nec[i]) ++ans;
	cout << ans << endl;
}

int main()
{
	init();

	REP(chk, n)
	{
		if (va[chk] >= k || nec[chk])
		{
			nec[chk] = true;
			continue;
		}

		ll s = va[chk];
		int left = chk + 1, right = chk + 2;
		if (left < n)
			s += va[left];

		while (left < n)
		{
			while (s < k && right < n)
			{
				s += va[right++];
			}
//			cout << "chkID, chkval = " << chk << ", " << va[chk] << " [ " << left << ", " << right << " )" << ", s = " << s << endl;

			if (s >= k)
			{
				if (s - va[chk] < k)
					nec[chk] = true;
				for (int i = left; i < right; i++)
					if (s - va[i] < k)
						nec[i] = true;
			}

			s -= va[left++];
		}
	}

	//REP(i, n)
	//	cout << va[i] << " : " << nec[i] << endl;
	//cout << endl;

	declare();
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <stack>
#include <vector>
#define ls (node << 1)
#define rs ((node << 1) | 1)
typedef unsigned long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
ll pic[200007];
ll sum[200007];
ll n;
int main()
{
    cin >> n;
    for (int i = 1; i <= n;i++)
    {
        cin >> pic[i];
        sum[i] = sum[i - 1] + pic[i];
        sum[i] %= MOD;
    }
    ll ans = 0;
    for (int i = n; i >= 1;i--)
    {
        ans = ((pic[i] * sum[i - 1]) % MOD + ans) % MOD;
    }
    cout << ans % MOD << endl;
}

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
  if (n == 0) return 1;
  mint x =  f(n / 2);
  x *= x;
  if ( n % 2 == 1 ) x *= 2;
  return x;
}

mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep (i, a) {
    x *= n - i;  // 分子
    y *= i + 1;  // 分母
  }
  return x / y;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  // mint ans = mint(2).pow(n);
  mint ans = f(n);  // せっかくだから一から書く！
  ans -= 1;
  ans -= choose(n, a);
  ans -= choose(n, b);
  cout << ans.x << endl;
  return 0;
}


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

char s[100020];
int K;
int len;

int main(void){

	scanf("%s",s);
	scanf("%d",&K);
	len=strlen(s);

	for (int i = 0; i < len; ++i)
	{
		if('z'+1-s[i]!=26&&K>='z'+1-s[i]){
			K=K-('z'+1-s[i]);
			s[i]='a';
		}
	}

	if(K>0){
		K=K%26;
		s[len-1]=s[len-1]+K;
	}

	printf("%s\n", s);

	return 0;

}


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

#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

struct BIT {
	vector<int> v;
	int n;
	BIT(int N) { n = N + 1; v.resize(n); }
	int sum(int idx) {
		int ret = 0;
		for (int i = idx + 1; i > 0; i -= i & -i) ret += v[i];
		return ret;
	}
	int sum(int from, int to) {
		return sum(to) - sum(from - 1);
	}
	void add(int idx, int num) {
		for (int i = idx + 1; i < n; i += i & -i) v[i] += num;
	}
};

signed main() {
	int n; cin >> n;
	vector<int> as(n);
	BIT bit(n + n);
	rep (i, n) {
		int x;  scanf("%d", &x);
		bit.add(i, x);
		bit.add(i + n, x);
	}
	int len = bit.sum(n - 1);
	int left = 0, right = 0;
	int ans = 0;
	while (left < n) {
		if (right < left) right = left;
		int s = bit.sum(left, right);
		int end = left + n;
		int rem = len - s;
		int b = right + 1, e = end;
		while (b + 1 < e) {
			int mid = (b + e) / 2;
			int x = bit.sum(right + 1, mid);
			if (x < s) b = mid;
			else e = mid;
		}
		if (bit.sum(right + 1, right + 1) > s) b = right;
		int r1 = bit.sum(right + 1, b + 1);
		int r2 = rem - r1;
		if (s <= r1 && s <= r2) {
			maxup(ans, s);
			right++;
		}
		else {
			left++;
		}
	}
	cout << ans << endl;
	//system("pause");
}

Measured memory_bytes: 5192
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

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

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

	vector<bool> possible(N + 1, false);
	vector<int> balls(N + 1, 1);
	possible[1] = true;
	while (M--)
	{
		int x, y;
		cin >> x >> y;

		if (possible[x])
			possible[y] = true;

		balls[x]--;
		balls[y]++;
		if (balls[x] == 0)
			possible[x] = false;
	}

	int cnt = 0;
	for (int i = 1; i <= N; ++i)
		cnt += possible[i];
	cout << cnt << endl;

	return 0;
}

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

string E, O;

int main () {
	cin >> O >> E;
	for (int i = 0; i < O.length()+E.length(); i++){
		if (i%2 == 0){
			cout << O[i/2];
		} else {
			cout << E[i/2];
		}
	}
}

Measured memory_bytes: 3564
#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <string>
#include <string.h>
#include <limits>
#include <utility>
#include <vector>
#include <algorithm>
#include <functional>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <chrono>

using namespace std;

namespace
{
	struct Dish
	{
		int64_t point;
		int64_t diffPoint;
		int id;

		bool operator<(const Dish& o) const
		{
			if (diffPoint == o.diffPoint)
			{
				return point > o.point;
			}
			return diffPoint > o.diffPoint;//年齢を比較
		};
	};
}

#if 1
int main()
{
	int n;
	cin >> n;
	
	vector<bool> isEated;
	isEated.resize(n, false);

	vector<Dish> aDish;
	vector<Dish> bDish;

	aDish.resize(n);
	bDish.resize(n);

	for (int i = 0; i < n; i++)
	{
		cin >> aDish[i].point;
		cin >> bDish[i].point;

		aDish[i].id = i;
		bDish[i].id = i;

		aDish[i].diffPoint = bDish[i].point + aDish[i].point;
		bDish[i].diffPoint = bDish[i].point + aDish[i].point;
	}

	sort(aDish.begin(), aDish.end());
	sort(bDish.begin(), bDish.end());

	bool isTTurn = true;
	int eatTIndex = 0;
	int eatAIndex = 0;

	int64_t tPoint = 0;
	int64_t aPoint = 0;

	for (int i = 0; i < n; i++)
	{
		if (isTTurn)
		{
			while (isEated[aDish[eatTIndex].id])
			{
				eatTIndex++;
				continue;
			}

			tPoint += aDish[eatTIndex].point;
			isEated[aDish[eatTIndex].id] = true;
			isTTurn = false;
		}
		else
		{
			while (isEated[bDish[eatAIndex].id])
			{
				eatAIndex++;
				continue;
			}

			aPoint += bDish[eatAIndex].point;
			isEated[bDish[eatAIndex].id] = true;
			isTTurn = true;
		}
	}

	cout << tPoint - aPoint;

	return 0;
}
#endif


Measured memory_bytes: 4992
/*

#      #      #####   ##   ##  #####      ##     #  #      #   #  #####
#      #      #   #  #  ###  # #          # ##   #  #      #   #  #   #
#      #      #   #  #   #   # #          #  ##  #  #      #   #  #   #
#      #      #   #   #     #  #####      #   #  #  #       ###   #####
#      #      #   #    #   #   #          #  ##  #  #        #    #   #
#      #      #   #     ###    #          # ##   #  #        #    #   #
#      #####  #####      #     #####      ##     #  #####    #    #   #

*/

#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define pb push_back
#define np next_permutation
#define bs binary_search
#define mp make_pair
#define all(x) x.begin(), x.end()
#define bp __builtin_popcountll
#define sqr(x) ((llong)sqrt (x))
#define b_ctz __builtin_ctzll
#define b_clz __builtin_clzll

#define y1 road_to_respa_top_6
#define prev road_to_respa_top_6
#define Abdrakhman abcdefghijklmnopqrstuvwxyzRakhman
#define left kotoriy_levee_chem_right
#define right kotoriy_pravee_chem_left

#define android ios_base::sync_with_stdio(0), cin.tie (0), cout.tie (0)
#define fn ""

typedef long long llong;
typedef long double ldouble;
typedef unsigned long long ullong;

typedef vector <llong> vl;
typedef vector <string> vs;
typedef vector <vector <llong>> matrix;

typedef pair <llong, llong> pll;

typedef map <llong, llong> mll;

typedef set <llong> sl;

const llong MXN = 1e6 + 1;
const llong MNN = 1e3 + 1;
const llong MOD = 1e9 + 7;
const llong INF = 1e18;
const llong MAGIC = 1000;
const ldouble EPS = 1e-9;
const ldouble PI = 3.1415926536;
const string TIME = "rovno_ushten_push_ketti";

inline llong log2 (llong x) {return 64 - b_clz (x) - 1;};
inline llong __lcm (llong a, llong b) {return a / __gcd (a, b) * b;};

llong n, a, b;

int main () {
    android;
    random_device rand;
    #ifdef I_LOVE_DILYA
        freopen ("input.txt", "r", stdin);
    #endif
    cin >> n >> a >> b;
    llong c = b - a;
    if (c % 2) cout << "Borys";
    else cout << "Alice";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <iterator>

using namespace std;

int main()
{
    list<int> l;
    list<int>::iterator it = l.begin();

    int t, x, q;
    cin >> t;
    while (t--)
    {
        cin >> q;
        if (q == 0)
        {
            cin >> x;
            it = l.insert(it, x);
        }
        if (q == 1)
        {
            cin >> x;
            if (x > 0)
            {
                while (x--)
                    it++;
            }
            else
            {
                while (x++)
                    it--;
            }
        }
        if (q == 2)
        {
            it = l.erase(it);
        }
    }

    for (it = l.begin(); it != l.end(); it++)
    {
        cout << *it << endl;
    }
}


Measured memory_bytes: 18656
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	public static void main(String[] args) {
		int a=sc.nextInt();
		int b=sc.nextInt();
		String g;
		boolean x=true;
		int ans=0;
		for(int i=a;a<=b;a++) {
			g=a+"";
			x=true;
			for(int t=0;t<g.length()/2;t++) {
				if(g.charAt(t)!=g.charAt(g.length()-t-1)) {
					x=false;
					break;
				}
			}
			if(!x)continue;
			ans++;
		}
		p(ans);		
		
		
		//p(S.toString());
		//setCharAt(int a, char s)
	}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


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

#define ll long long
#define mx 100005
int n,m;
int ar[mx];
char ch[mx];

int main()
{
    int n;
  cin>>n;
    ll re=0;
    for(int i=1;i<=n;i++)
    {
      for(int j=1;j<=n;j++)
        for(int k=1;k<=n;k++)
        {
          int gc=__gcd(i,j);
          re+=__gcd(gc,k);
        }
    }
  cout<<re<<endl;
    
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
vector<long long>v[200005];
long long dp[200005],vis[200005];
void dfs(long long node)
{
    vis[node]=1;
    for(int i=0;i<v[node].size();i++)
    {
        if(vis[v[node][i]]==0)
        dfs(v[node][i]);
        
        dp[node]=max(dp[v[node][i]]+1,dp[node]);
    }
}
int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    
      long long n,i,j,k,sum=0,count=0,ans=0,x=0,y=0,l,r,m;
      cin>>n>>m;
      long long a[m],b[m]={0},c[n];
      for(i=0;i<m;i++)
      {
          cin>>a[i]>>b[i];
          a[i]--;
          b[i]--;
          v[a[i]].push_back(b[i]);
      }
      for(i=0;i<n;i++)
      {
          if(vis[i]==0)
          dfs(i);
      }

      for(i=0;i<n;i++)
      {
          ans=max(ans,dp[i]);
      }
      cout<<ans;

	return 0;
}

Measured memory_bytes: 17164
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;

int main(){
	string S;
  cin >> S;
	int a,b,c;
	a=0;b=0;c=0;
	for(auto itr=begin(S);itr!=end(S);++itr){
		if(*itr=='a') a++;
		if(*itr=='b') b++;
		if(*itr=='c') c++;
	}
	if(abs(a-b)<2 and abs(b-c)<2 and abs(c-a)<2) printf("YES");
	else printf("NO");
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define lint long long
#define INF 10000000000
lint N, X;
lint c[51];
lint dp(lint n, lint x) {

	if (n == 0) {
		return 1;
	}
	else {
		if (x == 1) {
			return 0;
		}
		else if (x <= 1 + c[n - 1]) {
			return dp(n - 1, x - 1);
		}
		else if(x == 2 + c[n-1]){
			return 1 + dp(n - 1, c[n - 1]);
		}
		else if (x <= 2 + 2 * c[n - 1]) {
			return 1 + dp(n - 1, c[n - 1]) + dp(n - 1, x - 2 - c[n - 1]);
		}
		else {
			return 1 + 2 * dp(n - 1, c[n - 1]);
		}

	}
}
int main() {
	//入力
	cin >> N >> X;
	//CはレベルNバーガーの全枚数
	c[0] = 1;
	for (int i = 0; i < N; i++)
	{
		c[i + 1] = 3 + 2 * c[i];

	}

	//レベルNバーガーの、下からX枚の範囲におけるパティの枚数
	cout << dp(N, X) << endl;
	return 0;

}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	int n, m, p, a, b;
	int[] t;
	E[] G;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			n = sc.nextInt();
			m = sc.nextInt();
			p = sc.nextInt();
			a = sc.nextInt() - 1;
			b = sc.nextInt() - 1;

			if ((n|m) == 0) break;

			t = new int[n];
			G = new E[m];
			for (int i = 0; i < m; i++) G[i] = new E();

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

			for (int i = 0; i < p; i++) {
				int x = sc.nextInt() - 1, y = sc.nextInt() - 1, z = sc.nextInt();
				G[x].add(new V(y, z));
				G[y].add(new V(x, z));
			}

			System.out.println(dijkstra());
		}
	}

	String dijkstra() {
		double[][] d = new double[1 << n][m];
		for (double[] a : d) fill(a, INF);
		d[0][a] = 0;
		PriorityQueue<S> q = new PriorityQueue<S>();
		q.add(new S(0, a, 0));
//		debug(q);
		for (;!q.isEmpty();) {
			S cur = q.remove();
//			debug(cur);
			if (d[cur.s][cur.p] != cur.d) continue;
			if (cur.p == b) return "" + cur.d;

			for (V v : G[cur.p]) {
				for (int i = 0; i < n; i++) if (((cur.s>>i)&1) == 0) {
					if (d[cur.s|(1<<i)][v.t] > cur.d + 1.0 * v.c / t[i]) {
						d[cur.s|(1<<i)][v.t] = cur.d + 1.0 * v.c / t[i];
						q.add(new S(cur.s|(1<<i), v.t, d[cur.s|(1<<i)][v.t]));
					}
				}
			}
		}

		return "Impossible";
	}

	class E extends ArrayList<V>{}
	class V {
		int t, c;
		V(int t, int c) {
			this.t = t;
			this.c = c;
		}
	}

	class S implements Comparable<S>{
		int s, p;
		double d;
		S(int s, int p, double d) {
			this.s = s;
			this.p = p;
			this.d = d;
		}
		@Override
		public int compareTo(S o) {
			// TODO ティツ?ェテ・ツ仰陛ァツ板淌ヲツ按静」ツ?陛」ツつ古」ツ?淌」ツδ。テ」ツつステ」ツδε」ツδ嘉」ツδサテ」ツつケテ」ツつソテ」ツδ?
			return d - o.d > EPS ? 1 : -1;
		}

		public String toString() {
			return "[" + Integer.toString(s, 2) + ", " + p + ", " + d + "]";
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 38580
#include <bits/stdc++.h>
//#define int long long

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

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = (int)1e9 + 7;

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

    int a, b, c;
    cin >> a >> b >> c;
    cout << ((a*100 + b*10 + c) % 4 == 0 ? "YES" : "NO") << endl;
}

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

int main() {
  long long N,A;
  cin>>N>>A;
  vector<long long> x(N);
  rep(i,N) cin>>x[i];
  
  long long dp[51][51][2501];
  //dp[j][k][s]は、j=0のとき1枚も選べない。j>0のとき、x[0]~x[j-1]からk枚選んで合計sとなる組み合わせ.
  dp[0][0][0]=1;
  for(long long j=0;j<=N;j++){//j=1~N
    for(long long k=0;k<=j;k++){//k=1~j
      for(long long s=0;s<=N*A;s++){//s=1~N*A
        if(j>=1&&s<x[j-1]) dp[j][k][s]=dp[j-1][k][s];
        else if(j>=1&&k>=1&&s>=x[j-1]) dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-x[j-1]];
      }
    }
  }
  long long sum=0;
  for(long long k=1;k<=N;k++) sum += dp[N][k][k*A];
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 50816
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define db double
using namespace std;
int t,n,m,x;
const int maxn=1e5+10;

int main(){
	int n;
	int a[4];
	memset(a,0,sizeof(a));
	cin>>n;
	string s;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s[0]=='A') a[0]++;
		if(s[0]=='W') a[1]++;
		if(s[0]=='T') a[2]++;
		if(s[0]=='R') a[3]++;
	}	
	cout<<"AC x "<<a[0]<<endl;
	cout<<"WA x "<<a[1]<<endl;
	cout<<"TLE x "<<a[2]<<endl;
	cout<<"RE x "<<a[3]<<endl;
} 

Measured memory_bytes: 3632
/* Author darklight13 -_- 
   IIT Patna 
*/
#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds; 
using namespace std;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
//typedef tree<int, null_type, less<int>, rb_tree_tag, 
//             tree_order_statistics_node_update> 
//    data_set;
#define rep(i,l,r)   for(int i=(l);i<(r);i++)
#define deb(x)     cout << (#x) << " is " << (x) << endl
#define dbg(x)     cout << x << ' '
#define here cout << " Hey baitch!!\n";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
const int MOD = 1e9+7;
const int MOD1 = 998244353;
const int N = 2e5+5;
const int INF = 1000111000111000111LL;
const ld PI = 3.1415926535898;

int32_t main()
{
	SYNC
	int h,w; cin >> h >> w;
	int dp[h][w],a[h][w];
	rep(i,0,h) {
		rep(j,0,w) {
			char x; cin >> x;
			if(x=='.')	a[i][j] = 0;
			else	a[i][j] = 1;
		}
	}
	if(!a[0][0])	dp[0][0] = 0;
	else	dp[0][0] = 1;
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if(i==0 && j==0)	continue;
			int t1 = INF, t2 = INF;
			if(i > 0) {
				if(!a[i-1][j] && a[i][j])	t1 = dp[i-1][j] + 1;
				else t1 = dp[i-1][j];
			}
			if(j > 0) {
				if(!a[i][j-1] && a[i][j])	t2 = dp[i][j-1] + 1;
				else	t2 = dp[i][j-1];
			}
			dp[i][j] = min(t1,t2);
		}
	}
	cout << dp[h-1][w-1];
    return 0;
}

Measured memory_bytes: 384
N = int(input())
a = [int(i) for i in input().split()]

b = [0]*N
ans = []
for i in range(N, 0, -1):
    s = 0
    for j in range(i, N+1, i):
        s += b[j-1]
    if s % 2 != a[i-1]:
        b[i-1] += 1
        ans.append(i)

print(sum(b))
if len(ans) > 0:
    print(*ans)

Measured memory_bytes: 14088
package main

import (
	"fmt"
	"sort"
)

func main() {
	L := [3]int{}
	for i := 0; i < 3; i++ {
		fmt.Scan(&L[i])
	}

	sort.Ints(L[:])
	ans := L[0] + L[1]

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	int a=s[0]-'0';
	int b=s[1]-'0';
	if(a==9 || b==9){
		cout<<"Yes"<<endl;
	}
	
	else cout<<"No"<<endl;
	
}

Measured memory_bytes: 256