akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main {
	private static final double EPS = 1e-8;
	Scanner sc;
	int N;
	int[] x, y;
	double[] d = new double[3];
	
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		x = new int[N];
		y = new int[N];
		for (int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		
		double minr = Double.MAX_VALUE / 10;
		for (int i = 0; i < N; i++) {
			for (int j = i; j < N; j++) {
				for (int k = j; k < N; k++) {
					setEnclosingDiskOf(x[i], y[i], x[j], y[j], x[k], y[k]);
					if (isEnclosing()) minr = Math.min(minr, d[2]);
				}
			}
		}
		
		System.out.println(Math.sqrt(minr));
	}
	
	private void setEnclosingDiskOf(double x1, double y1,
					double x2, double y2,
					double x3, double y3) {
		double a2 = dist2(x1, y1, x2, y2);
		double b2 = dist2(x2, y2, x3, y3);
		double c2 = dist2(x3, y3, x1, y1);
		
		if (a2+b2 <= c2) {
			d[0] = (x3+x1)/2;
			d[1] = (y3+y1)/2;
			d[2] = c2/4;
		} else if (b2+c2 <= a2) {
			d[0] = (x1+x2)/2;
			d[1] = (y1+y2)/2;
			d[2] = a2/4;
		} else if (c2+a2 <= b2) {
			d[0] = (x2+x3)/2;
			d[1] = (y2+y3)/2;
			d[2] = b2/4;
		} else {
			boolean s = setSub(x1, y1, x2, y2, x3, y3) ||
				setSub(x2, y2, x3, y3, x1, y1) ||
				setSub(x3, y3, x1, y1, x2, y2);
		}
	}
	
	private boolean setSub(double x1, double y1,
					double x2, double y2,
					double x3, double y3) {
		if ( Math.abs((x3-x1)*(y1-y2)-(x2-x1)*(y1-y3)) < EPS ) return false;
		double x12 = x1 * x1;
		double y12 = y1 * y1;
		double x22 = x2 * x2;
		double y22 = y2 * y2;
		double x32 = x3 * x3;
		double y32 = y3 * y3;
		d[1] = ((x3-x1) * (x12+y12-x22-y22) - (x2-x1) * (x12+y12-x32-y32)) / (2*(x3-x1)*(y1-y2) - 2*(x2-x1)*(y1-y3));
		if (Math.abs(x1-x2) < EPS)
			d[0] = (2*(y1-y3)*d[1]-x12-y12+x32+y32) / (2*(x3-x1));
		else
			d[0] = (2*(y1-y2)*d[1]-x12-y12+x22+y22) / (2*(x2-x1));
		d[2] = dist2(d[0], d[1], x1, y1);
		return true;
	}
	
	private double dist2(double x1, double y1, double x2, double y2) {
		return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
	}
	
	private boolean isEnclosing() {
		for (int i = 0; i < N; i++) {
			if (dist2(x[i], y[i], d[0], d[1]) - EPS > d[2]) return false;
		}
		return true;
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int MOD = 1000000007;
signed main()
{
	int n,k;
	cin >> n >> k;
	vector<int> d(k);
	vector<vector<int> > a(100, vector<int>(100));

	for(int i=0;i<k;i++){
		cin >> d.at(i);
		for(int j=0;j<d.at(i);j++){
			cin >> a.at(i).at(j);
		}
	}

	vector<int> sunuke(n);

	for(int i=0;i<k;i++){
		for(int j=0;j<d.at(i);j++){
			sunuke.at(a.at(i).at(j)-1)++;
		}
	}

	int cnt = 0;
	rep(i,n){
		if(sunuke.at(i)==0){
			cnt++;
		}
	}

	cout << cnt << endl;
	
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  string S; cin >> S;
  REP(i, S.size()-1){
    if(S[i]==S[i+1]){
      cout << i+1 << ' ' << i+2 << endl;
      return 0;
    }
    if(i<S.size()-2 and S[i]==S[i+2]){
      cout << i+1 << ' ' << i+3 << endl;
      return 0;
    }
  }
  cout << "-1 -1" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <limits>


using namespace std;

bool kaibun(string s){
    size_t len = s.length();
    for(int i = 0; i < len/2; i++){
        if(s[i] != s[len-i-1]) return false;
    }
    return true;
}

void Kitei(int N,int K, vector<int> & v){
    int sho = N/K;
    int amari= N%K;
    v.push_back(amari);
    if(sho==0){
        return;
    }
    Kitei(sho,K,v);
}


int main(){
    int PI,N =0;
    int sum = 0;
    long energy= 0;
    vector<int> vec;
    cin >> N ;
    for(int i =0;i<N;i++){
        int p;
        cin >> p;
        sum+=p;
        vec.push_back(p);
    }

    PI = round((sum/double(N)));

    for(auto itr = vec.begin(); itr != vec.end(); ++itr){
        energy += pow((*itr-PI),2.0);
    }

    cout<<energy<<endl;

    return 0;
}

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

#define int long long
#define mod 1000000007
#define p pair<int,int>
#define MAX 1000010

using namespace std;

int a[MAX],b[MAX];
bool vis[MAX];

vector <int> v;
vector <p> vp;
set <int> s;
set <p> sp;
map <int,int> m;
unordered_map <int,int> um;
queue <int> bq;

int32_t main()
{
    um.reserve(1<<15);
    um.max_load_factor(0.25);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    if(n == 1)
    {
        cout << "Hello World\n";
    }
    else
    {
        int x,y;
        cin >> x >> y;
        cout << x+y << endl;
    }

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <numeric>
using namespace std;
int main() {
    int K, ans = 0;
    cin >> K;
    for (int a = 1; a <= K; a++) {
        for (int b = 1; b <= K; b++){
            for (int c = 1; c <= K; c++) {
                ans += gcd(a, gcd(b, c));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
from math import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

K = ii()
ans = 0

memo = dp3(-1, K+1, K+1, K+1)

for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            #l = sorted([i, j, k])
            #l = [i, j, k]
            #a, b, c = l[0], l[1], l[2]
            a, b, c = i, j, k
            if memo[a][b][c] != -1:
                ans += memo[a][b][c]
            else:
                memo[a][b][c] = gcd_list([a, b, c])
                memo[i][k][j] = memo[k][i][j] = memo[k][j][i] = memo[j][i][k] = memo[j][k][i] = memo[i][j][k]
                #memo[i][k][j] = memo[i][j][k]
                #memo[k][i][j] = memo[i][j][k]
                #memo[k][j][i] = memo[i][j][k]
                #memo[j][j][i] = memo[i][j][k]
                #memo[j][i][k] = memo[i][j][k]
                ans += memo[a][b][c]
            #ans += gcd_list([i, j, k])


print(ans)

Measured memory_bytes: 137576
#include <stdio.h>
int main(){
        int n,i;
        int yen = 100000;
        scanf("%d",&n);
        for(i=0;i<n;i++){
                yen = yen * 1.05;
                if(yen % 1000 != 0){
                        yen = (yen / 1000 + 1) * 1000;
                }
        }
        printf("%d\n", yen);
return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll inf = 1e18+5;
ll n, a[405], dp[405][405];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	for (ll i= 0; i < n; i++)cin >> a[i];
	for (ll L = n; L >= 0; L--){
		for (ll R = L; R < n; R++){
			if (R == L){
				dp[L][R] = 0;continue;
			}else if (R == L+1){
				dp[L][R] = a[L]+a[R];continue;
			}
			dp[L][R] = inf;
			//~ dp[L][R] = min(a[L]+2*dp[L+1][R], a[R]+(R == 0 ? inf:2*dp[L][R-1]));
			//~ for (ll i = L+1; i < R; i++){
				//~ //consider L and R separately, likely out of loop
				//~ dp[L][R] = min(a[L]+dp[L+1][R], a[R]+(R == 0 ? inf:dp[L][R-1]));
				//~ dp[L][R] = min(dp[L][R], (a[i]+dp[L][i-1]*2)*2+dp[i+1][R]*2);
				//~ dp[L][R] = min(dp[L][R], dp[L][i-1]*2+(dp[i+1][R]*2+ a[i])*2);
			//~ }
			ll sum = 0;
			for (ll i = L; i <= R; i++)sum += a[i];
			for (ll i = L; i < R; i++){
				dp[L][R] = min(dp[L][R], dp[L][i]+dp[i+1][R]+ sum);
				//IMPT: dp[i][j]*2 != sum of i to j, sum is the one you have to double
			}
		}
	}
	cout << dp[0][n-1];	
	//~ for (ll i =0; i< n; i++){
		//~ for (ll j = 0; j < n; j++){
			//~ cout << dp[i][j] << ' ';
		//~ }
		//~ cout << '\n';
	//~ }
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
using Graph = vector<vector<int>>;

int main() {
     int n; cin >> n;
     string tmp;
     map<string, int> ma;
     FOR(i,0,n) {
         cin >> tmp;
         ma[tmp]++;
     }
     int m; cin >> m;
     FOR(i,0,m) {
         cin >> tmp;
         ma[tmp]--;
     }
 
     int ans = 0;
     for(auto itr : ma) {
         ans = max(itr.second, ans);
     }
 
     cout << ans << endl;
 
     return 0;
     
 }

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    public static void main (String args[]) {
        Scanner sc = new Scanner(System.in);
    	int n = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int max = 0;
        int min = -1;

        if (n >= a + b) {
        	min = 0;
        } else {
        	min = a + b - n;
        }

        if (a > b) {
        	max = b;
        } else {
        	max = a;
        }

        System.out.println(max + " " + min);
    }
}


Measured memory_bytes: 23124
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int K,X,i;
    cin>>K>>X;
    X=X-(K-1);
    cout<<X<<" ";
    for(i=1;i<=(2*(K-1));i++)
    {
        X++;
        cout<<X<<" ";
    }
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T>void chkmin(T &x,const T &y){
    if(y<x){
        x=y;
    }
}
template<class T>void chkmax(T &x,const T &y){
    if(y>x){
        x=y;
    }
}
template<class T>void sort(vector<T> &a){
    sort(a.begin(),a.end());
}
template<class T>void reverse(vector<T> &a){
    reverse(a.begin(),a.end());
}
void reverse(string &a){
    reverse(a.begin(),a.end());
}
template<class T,class Cmp>void sort(vector<T> &a,Cmp cmp){
    sort(a.begin(),a.end(),cmp);
}
template<class T>void unique(vector<T> &a){
    a.resize(unique(a.begin(),a.end())-a.begin());
}
int readInt(){
    int x=0;
    bool sign=false;
    char c=getchar();
    while(!isdigit(c)){
        sign=c=='-';
        c=getchar();
    }
    while(isdigit(c)){
        x=x*10+c-'0';
        c=getchar();
    }
    return sign?-x:x;
}
ll readLong(){
    ll x=0;
    bool sign=false;
    char c=getchar();
    while(!isdigit(c)){
        sign=c=='-';
        c=getchar();
    }
    while(isdigit(c)){
        x=x*10+c-'0';
        c=getchar();
    }
    return sign?-x:x;
}
string readString(){
    string s;
    char c=getchar();
    while(isspace(c)){
        c=getchar();
    }
    while(!isspace(c)){
        s+=c;
        c=getchar();
    }
    return s;
}
void solve_single_test(int test_id=1){
    int n=readInt();
    std::vector<int> v(n,0);
    for (int i = 0; i <n; ++i)
    {cin>>v[i];
        /* code */
    }
    vector<int>dp(1000001,0);
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(v[1]-v[0]);

    for (int i = 3; i <=n; ++i)
    {dp[i]=min(dp[i-1]+abs(v[i-1]-v[i-2]),dp[i-2]+abs(v[i-1]-v[i-3]));
        /* code */
    }
    cout<<dp[n]<<"\n";
}
void solve_multiple_tests(){
    int n_tests=readInt();
    for(int i=1;i<=n_tests;++i){
        solve_single_test(i);
    }
}
int main(){
    solve_single_test();
    return 0;
}


Measured memory_bytes: 4480
#include <cmath>
#include<iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h> 
using namespace std;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


int main(){    
  long long X;
  cin >> X;
  
  if(IsPrime(X)){
    cout << X << endl;
  }
  else{
    while(1){
      X++;
      if(IsPrime(X)){
	cout << X << endl;
	return 0;
      }	
    } 
  }
}


Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N = i()
A = l()
for i in A:
    ans += 1/i

ans = 1/ans
print(ans)


Measured memory_bytes: 10080
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    set<string> s;
    int n;
    cin >> n;
    string l;
    while (n--)
    {
        string c;
        cin >> c;
        if (l.empty() || c.front() == l.back())
        {
            if (s.find(c) != s.end())
                return cout << "No", 0;
        }
        else
            return cout << "No", 0;
        s.insert(c);
        l = c;
    }
    cout << "Yes";
}


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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

int N;
int x[110000], y[110000];
pair<pint, int> xyi[110000], yxi[110000];
vint G[110000];
bool visited[110000];

set<int> xset, yset;
void dfs(int idx) {
    if (visited[idx]) { return; }
    visited[idx] = true;
    xset.insert(x[idx]), yset.insert(y[idx]);
    for (int i = 0; i < G[idx].size(); i++) { dfs(G[idx][i]); }
};

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
        xyi[i] = make_pair(pint(x[i], y[i]), i);
        yxi[i] = make_pair(pint(y[i], x[i]), i);
    }
    sort(xyi, xyi + N), sort(yxi, yxi + N);
    for (int i = 0; i < N - 1; i++) {
        if (xyi[i].first.first == xyi[i + 1].first.first) {
            G[xyi[i].second].push_back(xyi[i + 1].second);
            G[xyi[i + 1].second].push_back(xyi[i].second);
        }
        if (yxi[i].first.first == yxi[i + 1].first.first) {
            G[yxi[i].second].push_back(yxi[i + 1].second);
            G[yxi[i + 1].second].push_back(yxi[i].second);
        }
    }
    int ans = -N;
    for (int i = 0; i < N; i++) {
        xset.clear(), yset.clear();
        dfs(i);
        ans += xset.size() * yset.size();
    }
    cout << ans << endl;
}


Measured memory_bytes: 20480
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=100010;
const ll mod=1e9+7;

vector<int> r(mx,0);
vector<P> e[mx];
vector<bool> used(mx,false);

vector<int> used_edge;

int dfs(int x){
  used[x] = true;
  int res = r[x];
  for(auto it:e[x]){
    if(used[it.F]) continue;
    int f = dfs(it.F);
    if(f){ used_edge.emplace_back(it.S); }
    res ^= f;
  }
  return res;
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<P> bomb;
  rep(i,n){
    int a,b;
    cin >> a >> b;
    bomb.emplace_back(a,b);
  }
  sort(bomb.begin(),bomb.end());
  
  r[0] = bomb[0].S;
  rep(i,n-1){
    r[i+1] = bomb[i].S^bomb[i+1].S;
  }
  r[n] = bomb[n-1].S;

  
  rep(i,m){
    int x,y; cin >> x >> y;
    x = lower_bound(bomb.begin(),bomb.end(),P(x,-inf)) - bomb.begin();
    y = lower_bound(bomb.begin(),bomb.end(),P(y,inf)) - bomb.begin();
    e[x].emplace_back(y,i);
    e[y].emplace_back(x,i);
  }

  rep(i,n){
    if(used[i])continue;
    if(dfs(i)){
      cout << -1 << ln; return 0;
    }
  }

  cout << used_edge.size() << ln;
  sort(used_edge.begin(),used_edge.end());
  for(auto ans:used_edge){
    cout << ans+1 << " ";
  }
  cout << ln;
  return 0;
}

Measured memory_bytes: 16376
#include<iostream>
#include<cstdio>
using namespace std;
bool three(int x){
  if(x%3==0)return true;

  while(x>0){

    if(x%10==3)return true;
    x/=10;
  }
  return false;
}
int main(){

  int n;

  cin>>n;

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

    if(three(i))cout<<" "<<i;

  }
cout<<endl;
    

  return 0;
}

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




int main(){

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


	return 0;
}

Measured memory_bytes: 3544
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

vector<int> G[1 << 17];
bool used[1 << 17];
void solve() {
	int n, m; cin >> n >> m;
	rep(i, m) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	if (m < n + 2) {
		cout << "No" << endl;
	}
	else {
		bool exi6 = false;
		int exi4 = 0;
		vector<int> u;
		rep(i, n) {
			if (G[i].size() % 2) {
				cout << "No" << endl; return;
			}
			if (G[i].size() >= 6)exi6 = true;
			else if (G[i].size() == 4) {
				exi4++;
				u.push_back(i);
			}
		}
		if (exi6 || exi4 > 2) {
			cout << "Yes" << endl; return;
		}
		int le = u[0], ri = u[1];
		used[le] = used[ri]=true;
		queue<int> q;
		rep(j, 4) {
			q.push(G[le][j]);
		}
		int num = 0;
		while (!q.empty()) {
			int x = q.front(); q.pop();
			rep(j, G[x].size()) {
				int to = G[x][j];
				if (to == ri)num++;
				if (used[to])continue;
				used[to] = true; q.push(to);
			}
		}
		if (num == 4) {
			cout << "No" << endl; return;
		}
		cout << "Yes" << endl;
	}
}
int main() {
	solve();
	//stop
	return 0;
}


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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define cr const reg&
using namespace std;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int read() {
	reg x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(LL x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(LL x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(LL x) {put(x), putchar(' ');}
I void pr2(LL x) {put(x), puts("");}

char ss[100];

int main() {
	scanf("%s", ss + 1);
	reg len = strlen(ss + 1);
	fo(i, 1, len - 8) putchar(ss[i]);
	return 0;
}



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

char S[30001], T[3001];
int dp[3001][3001];
int preI[3001][3001];
int preJ[3001][3001];
char ans[3001];

int main() {
    scanf("%s %s", S, T);
    int n = strlen(S);
    int m = strlen(T);
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            dp[i][j] = -1e9;
        }
    }
    dp[0][0] = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            if (i < n && j < m && S[i] == T[j]) {
                if (dp[i + 1][j + 1] < dp[i][j] + 1) {
                    dp[i + 1][j + 1] = dp[i][j] + 1;
                    preI[i + 1][j + 1] = i;
                    preJ[i + 1][j + 1] = j;
                }
            }
            if (i < n && dp[i + 1][j] < dp[i][j]) {
                dp[i + 1][j] = dp[i][j];
                preI[i + 1][j] = i;
                preJ[i + 1][j] = j;
            }
            if (j < m && dp[i][j + 1] < dp[i][j]) {
                dp[i][j + 1] = dp[i][j];
                preI[i][j + 1] = i;
                preJ[i][j + 1] = j;
            }
        }
    }
    int k = dp[n][m];
    int i = n;
    int j = m;
    while (k > 0) {
        if (preI[i][j] == i - 1 && preJ[i][j] == j - 1) {
            ans[--k] = S[i - 1];
        }
        int i_ = i;
        int j_ = j;
        i = preI[i_][j_];
        j = preJ[i_][j_];
    }
    printf("%s\n", ans);
    return 0;
}


Measured memory_bytes: 105728
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    string o, e;
    cin >> o >> e;

    rep(i, e.size()) cout << o[i] << e[i];
    if (o.size() > e.size()) cout << o[o.size() - 1];
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 3556
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;


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

	static int n, m;
	static int[][] node;


	public static void main(String[] args) {
		while(read()){
			solve();
		}

	}

	static boolean read(){
		n = sc.nextInt();
		m = sc.nextInt();
		if(n == 0 && m == 0)  return false;

		node = new int[n][n];  //£sñ

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

		for(int i=0; i<m; i++){
			int node1 = sc.nextInt();
			int node2 = sc.nextInt();
			int cost = sc.nextInt();

			node[node1][node2] = cost;
			node[node2][node1] = cost;
		}

		return true;
	}


	static void solve(){
		//v@ÅÀ
		int sum =0;
		HashSet<Integer> X = new HashSet<Integer>();  //èÏÝ
		HashSet<Integer> Y = new HashSet<Integer>();  //¢è

		for(int i=1; i<n; i++){
			Y.add(i);
		}
		X.add(0);

		//¢èÌWªóÉÈéÜÅ
		while(!Y.isEmpty()){
			//System.out.println("X:" + X);
			//System.out.println("Y:" + Y);

			//Å¬RXgÌ×Úm[hð²×é
			int min = Integer.MAX_VALUE;
			int min_num = -1, min_num2 = -1;

			for(Iterator<Integer> i1 = X.iterator(); i1.hasNext();){
				int n1 = i1.next();
				for (Iterator<Integer> i2 = Y.iterator(); i2.hasNext();){
					int n2 = i2.next();
					//System.out.println(n1 + " " + n2);
					if(node[n1][n2] == -1)  continue;

					if(min > node[n1][n2]){
						min = node[n1][n2];
						min_num = n1;
						min_num2 = n2;
					}
				}
			}

			sum += node[min_num][min_num2];
			Y.remove(min_num2);
			X.add(min_num2);

		}

		System.out.println(sum);  //oÍ
	}

}

Measured memory_bytes: 12000
/*
AizuOnline A0043
Puzzle
*/
#include <stdio.h>

char  tehai[13];

int maisuu[9]={1,0,3,3,3,0,0,0,3};


void showhand(char f)
{
  int i,c;

  printf("%c",f);
  for(i=0;i<9;i++)
    printf("%d",maisuu[i]);
  printf("\n");

  scanf("%c",&c);
}

int isagari2()
{
  int i,ret;
/*showhand('C');*/
  
  for(i=0;i<9;i++)
    if(maisuu[i] == 0)
      continue;
    else if(i<7 && maisuu[i] < 3)
      {  if(maisuu[i] && maisuu[i+1] && maisuu[i+2])
         {  maisuu[i]--;
            maisuu[i+1]--;
            maisuu[i+2]--;
            ret=isagari2();
            maisuu[i]++;
            maisuu[i+1]++;
            maisuu[i+2]++;
            return(ret);
         }
         else
           return(0);
      }    
    else if(maisuu[i] > 2)
         {
           maisuu[i] -= 3;
           ret=isagari2();
           maisuu[i] += 3;
           return(ret);
         }
  for(i=0;i<9;i++)
    if(maisuu[i])
      return(0);
  return(-1);
}
int isagari()
{ int i,ret;
  
  for(i=0;i<9;i++)
    {
      if(maisuu[i] > 1)
      {   maisuu[i] -= 2;
      /*printf("h %d del\n",i);*/
      /*  showhand('B'); */
          ret=isagari2();
          maisuu[i] += 2;
      /*printf("h %d res\n",i);*/
          if(ret)
            return(-1);
      }
    }
    return(0);
}

main()
{
  int  i;
  int ret;
  int c;
  int flag;

  while(EOF != scanf("%s",tehai))
    {
      for(i=0;i<9;i++)
        maisuu[i]=0;
 
      for(i=0;i<13;i++)
        { c=tehai[i];
          maisuu[(c-'1')]++;
        }

      flag = 0;
      for(i=1;i<=9;i++)
        {
          if(maisuu[i-1] > 3)
            continue;
          maisuu[i-1] ++;
/*    showhand('A');  */
          ret=isagari();
          maisuu[i-1] --;
          if(ret)
            { if(flag)
              printf(" ");
              printf("%d",i);
              flag = -1;
            }
        }
      if(flag==0)
        printf("0");
      printf("\n");
    }
return(0);
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,M,Q=MI()
    a=[0]*Q
    b=[0]*Q
    c=[0]*Q
    d=[0]*Q
    
    for i in range(Q):
        a[i],b[i],c[i],d[i]=MI()
    
    #dfsの数列生成
    st=[]
    st2=[]
    for i in range(1,M+1):
        st.append([i])
    
    for dig in range(N):
        while len(st)!=0:
            L=st.pop()
            v=L[-1]
            for i in range(v,M+1):
                st2.append(L+[i])
                
        while len(st2)!=0:
            L=st2.pop()
            st.append(L)
            
    ans=0
    for i in range(len(st)):
        L=st[i]
        temp=0
        for j in range(Q):
            if L[b[j]-1]-L[a[j]-1]==c[j]:
                temp+=d[j]
        ans=max(ans,temp)
    print(ans)
    
    
    
main()


Measured memory_bytes: 157740
#include <iostream>
#include <string>
#include <map>
#include <math.h>
using namespace std;

#define ll long long

int main(){
    int N;
    cin >> N;
    float x[N],ans = 0;
    string u[N];
    for(int i = 0;i < N;i++){
        cin >> x[i] >> u[i];
        if(u[i] == "JPY")ans += x[i];
        else if(u[i] == "BTC")ans += 380000 * x[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    let mut count = 0;
    let mut ans = 0;
    for ch in s {
        if ch == 'R' {
            count += 1;
        } else {
            count = 0;
        }
        ans = max(ans, count);
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
int MOD=1000000007;
int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w)
{
	cout<<w.size()<<endl;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<endl;
}

void M998()
{
	swap(MOD,MOD2);
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

ll max(ll a,int b)
{
	if (a>b) return a;
	return b;
}

ll max(int a,ll b)
{
	if (a>b) return a;
	return b;
}

ll gcd(ll a,ll b)
{
	if (b==0) return a;
	return gcd(b,a%b);
}

ll lcm(ll a,ll b)
{
	return a/gcd(a,b)*b;
}

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

const int N=300010;
int n,h[N],ans[N];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829)+13893829);
	cin>>n;
	for (int i=0;i<n;++i) cin>>h[i];
	int lo=0,hi=h[0];
	while (lo<hi)
	{
		int mid=(lo+hi)/2;
		ans[0]=mid;
		for (int i=1;i<n;++i) ans[i]=h[i-1]-ans[i-1];
		if (ans[n-1]+ans[0]>h[n-1]) hi=mid-1;
		else if (ans[n-1]+ans[0]<h[n-1]) lo=mid+1;
		else break;
	}
	int mid=(lo+hi)/2;
	ans[0]=mid;
		for (int i=1;i<n;++i) ans[i]=h[i-1]-ans[i-1];
	for (int i=0;i<n;++i) cout<<ans[i]*2<<' '; 
}




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

signed main() {
    int n, k, ans = 0;
    cin >> n >> k;
    int s[n + 1] = {0};
    int a[n + 1];
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        s[i] = s[i - 1] + a[i];
    }

    for (int i = 0; i <= min(n, k); ++i) {
        int x = 0, y = 0;
        for (int j = 0; j <= i; ++j) {
            int l = i - j;
            x = j;
            y = l;

            int maxa = 0;
            vector<int> v;
            v.clear();
            for (int t = 1; t <= x; ++t) {
                v.push_back(a[t]);
                maxa += a[t];
            }

            for (int t = 0; t < y; ++t) {
                v.push_back(a[n - t]);
                maxa += a[n-t];
            }

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

            int cnt = 0;
            if (i < k)
                for (auto t:v) {
                    cnt++;
                    if (t < 0) {
                        maxa -= t;
                    }
                    if (cnt + i == k)
                        break;
                }

            if (ans < maxa) {
                ans = maxa;
            }

        }

    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 998244353;
const int N = 2010;
ll fact[N], invf[N];

ll powll(ll x, ll y){
    x %= mod;
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll mul(ll x, ll y){
    return (x%mod)*(y%mod)%mod;
}

ll divll(ll x, ll y){
    x %= mod;
    return (x * powll(y,mod-2)) % mod;
}

ll nPr(ll n, ll r){
    if (n < r || r < 0) return 0;
    return mul(fact[n], invf[n-r]);
}

ll nCr(ll n, ll r){
    if (n < r || r < 0) return 0;
    if (n < N) return mul(mul(fact[n], invf[r]), invf[n-r]);
    ll ret = 1;
    n %= mod;
    REP(i,r) ret = (ret * (n - i + mod)) % mod;
    return mul(ret, invf[r]);
}

int main() {
    ll m, n, k;
    cin >> m >> n >> k;
    fact[0] = invf[0] = 1;
    FOR(i,1,N-1){
        fact[i] = (fact[i-1] * i) % mod;
        invf[i] = divll(invf[i-1], i);
    }
    VL dp(k + 1);
    dp[1] = 1;
    FOR(x,2,k){
        dp[x] = powll(x, n);
        FOR(y,1,x-1){
            dp[x] = (dp[x] - ((nCr(x, y) * dp[y]) % mod) + mod) % mod;
        }
    }
    ll ans = powll(m, n);
    FOR(x,1,k-1){
        ans = (ans - ((nCr(m, x) * dp[x]) % mod) + mod) % mod;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3164
import java.util.Scanner;;
public class Main {
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext())
		{
			int N = sc.nextInt();
			int A = sc.nextInt();
			int B = sc.nextInt();
			String S = sc.next();
			findyes(S,N,A,B);
		}
	}
	public static void findyes(String S,int N,int A,int B)
	{
		int suma = 0;
		int sumb = 0;
		for(int i=0;i<S.length();i++)
		{
			if(S.charAt(i) == 'a')
			{
				suma++;	
				if((suma+sumb) <= (A+B))
				{
					System.out.println("Yes");	
				}
				else
				{
					System.out.println("No");	
				}
			}
			else if(S.charAt(i) == 'b')
			{
				sumb++;
				if((suma+sumb) <= (A+B) && sumb <=B)
				{
					System.out.println("Yes");
				}
				else
				{
					sumb--;
					System.out.println("No");	
				}
			}
			else
			{
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 24036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 100005
const ll MOD = 1000000007;

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

	ll a,b,c,k;
	cin>>a>>b>>c>>k;

	int cnt = 0;		
	while(b <= a){
		b <<= 1;
		++cnt;
	}

	while(c <= b){
		c <<=1;
		++cnt;
	}

	if(cnt <= k)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  ll n,m;
  cin >> n >> m;
  ll ans = 0;
  ll p;
  p = min(n,ll(m/2));
  ans += p;
  n = n - p;
  m = m - 2*p;
  if(m < 4){
    cout << ans << endl;
    return 0;
  }
  ans += ll(m/4);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int a[10];

int encode(int x[10], int n) {
  int res = 0;
  REP(i,n-1) {
    res = 10 * res + x[i];
  }
  return res;
}

void decode(int x[10], int n, int code) {
  int bit = 0;
  for (int i=n-2; i>=0; --i) {
    x[i] = code%10;
    bit |= 1<<x[i];
    code /= 10;
  }
  REP(i,n) if (!(bit>>i&1)) x[n-1] = i;
}

int now[10];

int main() {
  int n;
  cin >> n;
  REP(i,n) {
    cin >> a[i];
    --a[i];
  }
  queue<int> Q;
  int start = encode(a,n);
  Q.push(start);
  map<int, int> mp;
  mp[start] = 0;
  while(!Q.empty()) {
    int p = Q.front(); Q.pop();
    decode(now, n, p);
    int d = mp[p];
    REP(i,n) {
      REP(j,i) {
        reverse(now+j, now+i+1);
        int next = encode(now,n);
        if (mp.count(next) == 0) {
          mp[next] = d+1;
          if (d<4) {
            Q.push(next);
          }
        }
        reverse(now+j, now+i+1);        
      }
    }
  }
  REP(i,n) now[i]=i;
  start = encode(now,n);
  Q.push(start);
  map<int,int> mp2;
  mp2[start] = 0;
  int ans = INF;
  
  while(!Q.empty()) {
    int p = Q.front(); Q.pop();
    decode(now, n, p);
    int d = mp2[p];

    if (mp.count(p)) {
      ans = min(ans, mp[p] + mp2[p]);
    }
    if (d == 4) continue;
    REP(i,n) {
      REP(j,i) {
        reverse(now+j, now+i+1);
        int next = encode(now,n);
        if (mp2.count(next) == 0) {
          mp2[next] = d+1;
          Q.push(next);
        }
        reverse(now+j, now+i+1);        
      }
    }
  }
  if (ans == INF) {
    cout << 9 << endl;
  } else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 73684
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=200 +117;
const int MM=1 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
int a[2*NN][2*NN]={};
bool vis[2*NN][2*NN]={};
int stat[4]={};
int pp[3][2*NN][2]={};
int cnt[3];
int pre[4][2]={{1,1},{1,-1},{-1,1},{-1,-1}};
bool inside(int x,int y){
	return x>=0&&x<2*n&&y>=0&&y<2*n;
}
void col(int x,int y,int c,int now){
	vis[x][y]=1;
	if(now)a[x][y]^=c;
	for(int i=1;i<=cnt[c];++i){
		for(int j=0;j<4;++j){
			int nx=x+pre[j][0]*pp[c][i][0];
			int ny=y+pre[j][1]*pp[c][i][1];
			if(inside(nx,ny)&&!vis[nx][ny]){
				col(nx,ny,c,now^1);
			}
		}
	}
}
int main(){
	//open();
	n=read();
	int d1=read(),d2=read();
	for(int i=0;i<=2*n;++i){
		int tp=d1-i*i;
		int k=tp>0?sqrt(tp)+0.1:0;
		if(i*i<=d1&&k*k==tp){
			pp[1][++cnt[1]][0]=i;
			pp[1][cnt[1]][1]=k;
		}
		tp=d2-i*i;
		k=tp>0?sqrt(tp)+0.1:0;
		if(i*i<=d2&&k*k==tp){
			pp[2][++cnt[2]][0]=i;
			pp[2][cnt[2]][1]=k;
		}
	}
	for(int i=0;i<2*n;++i){
		for(int j=0;j<2*n;++j){
			if(!vis[i][j])col(i,j,1,1);
		}
	}
	for(int i=0;i<2*n;++i){
		for(int j=0;j<2*n;++j){
			vis[i][j]=0;
		}
	}
	for(int i=0;i<2*n;++i){
		for(int j=0;j<2*n;++j){
			if(!vis[i][j])col(i,j,2,1);
		}
	}
	for(int i=0;i<2*n;++i){
		for(int j=0;j<2*n;++j){
			++stat[a[i][j]];
		}
	}
	int mx=0;
	for(int i=0;i<4;++i)if(stat[i]>stat[mx])mx=i;
		int opcnt=0;
	for(int i=0;i<2*n;++i){
		for(int j=0;j<2*n;++j){
			if(opcnt<n*n&&a[i][j]==mx){
				printf("%d %d\n",i,j);
				++opcnt;
			}
		}
	}
	close();
	return 0;
}

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

using namespace std;

const int Nmax = 2e5 + 10;
const int Mod = 1e9 + 7;
const int oo = 2e9;

int n, m, x, cmin;
int st[20], vf[20], a[20][20];

void Back(int top)
{
    if(top == n + 1)
    {
        int cost = 0;
        memset(vf, 0, sizeof vf);
        for(int i = 1; i <= n; i++)
            if(st[i])
            {
                cost += a[i][0];
                for(int j = 1; j <= m; j++)
                    vf[j] += a[i][j];
            }

        int ok = 1;
        for(int i = 1; i <= m; i++)
            if(vf[i] < x) ok = 0;

        if(ok == 1) cmin = min(cmin, cost);

        return ;
    }

    for(int i = 0; i < 2; i++)
    {
        st[top] = i;
        Back(top + 1);
    }
}

int main()
{
/**
    #ifndef ONLINE_JUDGE
        ifstream cin("test.in");
        ofstream cout("test.out");
    #endif // ONLINE_JUDGE
*/

    cin >> n >> m >> x;

    for(int i = 1; i <= n; i++)
    {
        cin >> a[i][0];

        for(int j = 1; j <= m; j++)
            cin >> a[i][j];
    }

    cmin = oo;

    Back(1);

    cout << (cmin == oo ? -1 : cmin);
    return 0;
}


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

bool cmp(const pair<pair<string,int>,int> &a, const pair<pair<string,int>,int> &b){
    if(a.first.first != b.first.first){
        return a.first.first<b.first.first;
    }
    return a.first.second > b.first.second;
}

int main(){
    int n;
    cin>>n;
    vector<pair<pair<string,int>,int>> t(n);
    for(int i = 0;i<n;++i){
        cin>>t[i].first.first>>t[i].first.second;
        t[i].second = i+1;
    }
    sort(t.begin(),t.end(),cmp);
    for(int i = 0;i<n;++i){
        cout<<t[i].second<<endl;
    }
    return 0;
}

Measured memory_bytes: 3536
#include <stdio.h>

int main()
{
	int n, a[100000], i, flag, sum;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	
	i = 0;
	sum = 0;
	flag = 0;
	while (1){
		if (a[i] % 2 == 0){
			flag++;
			a[i] /= 2;
		}
		else {
			break;
		}
		
		i++;
		
		if (flag == n){
			sum++;
			i = 0;
			flag = 0;
		}
	}
	
	printf("%d\n", sum);
	
	return 0;
}


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

int main() {
  int N,sum = 0;
  cin >> N;
  for(int i = N;i;i /= 10){
    sum += i % 10;
  }
  if(N % sum == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 384
n, k = map(int,input().split())

a = list(map(int,input().split()))

tel_list = []

next_city = 0

city_have_been_to = set([0])

way = [0]

while k > 0:
    k -= 1
    temp = len(city_have_been_to)

    next_city = a[next_city] - 1
    city_have_been_to.add(next_city)
    way.append(next_city)

    if temp == len(city_have_been_to):
        break

if k == 0:
    print(way[-1] + 1)
else:
    temp_index = way.index(next_city)
    print(way[temp_index:-1][k % len(way[temp_index:-1])] + 1)

Measured memory_bytes: 123324
#include<stdio.h>

int main(){
 int n,a,b,c,i,aa,bb,cc;

 scanf("%d",&n);
 for(i=0;i<n;i++){
  scanf("%d %d %d",&a,&b,&c);
  aa=a*a;
  bb=b*b;
  cc=c*c;
  if((aa+bb)==cc||
     (cc+bb)==aa||
     (cc+aa)==bb){
   printf("YES\n");
  }else{
   printf("NO\n");
  }
 }
 return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i, n) for(int i=0;i<n;++i)
#define REPR(i, n) for(int i = n-1;i>=0;--i)
#define REPI(itr, v) for(auto itr=v.begin();itr!=v.end();+itr)
#define SORT(v, n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define llong long long
#define INF 999999999
#define pb(a) push_back(a)

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

using namespace std;

int main(){

  int n;
  int a[100001] = {};
  vector<int> v;
  
  scanf("%d", &n);
  REP(i,n){
    int t;
    scanf("%d", &t);
    v.pb(t);
  }

  REP(i,n){
    if(v[i] != 0){
      a[v[i] - 1]++;
    }
    a[v[i]]++;
    if(v[i] != n){
      a[v[i] + 1]++;
    }
  }

  int res = 0;
  REP(i, 100001){
    res = max(res, a[i]);
  }

  printf("%d\n", res);

  return 0;
}



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

int main(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int time1, time2, awake;
    time1 = h1 * 60 + m1;
    time2 = h2 * 60 + m2;
    awake = time2 - time1;
    cout << awake - k;
    return 0;
}


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

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//配列の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗する

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) の絶対値

main(){
  string s;
  cin >> s;
  if (s.size()<2){
    cout << '0' << endl;
    return 0;
  }
  int o=0,z=0;
  for (int i=0;i<s.size();i++){
    if (s.at(i)=='0') z++;
    else o++;
  }
  cout << 2*min(z,o) << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;


int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	
	for (int i = 0; i < n; i++) {
		
		cin >> a[i];

	}

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

	vector<int> cnt(3);
	int max = 0;
	int num = a[0];
	for (int i = 0; i < n; i++) {
		if (a[i] == num) {
			cnt[0]++;
		}
		else if (a[i] == num + 1) {
			cnt[2] = cnt[1];
			cnt[1] = cnt[0];
			cnt[0] = 1;
			num++;
		}
		else if (a[i] == num + 2) {
			cnt[2] = cnt[0];
			cnt[1] = 0;
			cnt[0] = 1;
			num += 2;
		}
		else {
			cnt[2] = cnt[1] = 0;
			cnt[0] = 1;
			num = a[i];
		}

		int sum = 0;
		for (int c : cnt) {
			sum += c;
		}
		if (sum > max) {
			max = sum;
		}
	}

	cout << max << endl;
}

Measured memory_bytes: 640