akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}init;

typedef long long LL;
#define fin "\n"
template<typename T>void chmin(T &a,T b){a=min(a,b);}
template<typename T>void chmax(T &a,T b){a=max(a,b);}
template<typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

int main(){
    int N;cin>>N;
    vector<int> pos(N+1);
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        pos[a]=i;
    }
    map<int,int> m;
    m[N-1]=0;
    LL res=0;
    for(int i=1;i<=N;i++){
        auto it=m.lower_bound(pos[i]);
        int l=it->second;
        int r=it->first;
        LL L=pos[i]-l+1;
        LL R=r-pos[i]+1;
        res+=L*R*i;
        if(pos[i]==r){
            m.erase(r);
            m[r-1]=l;
        }
        else if(pos[i]==l){
            m[r]=l+1;
        }
        else{
            m[r]=pos[i]+1;
            m[pos[i]-1]=l;
        }
    }
    cout<<res<<endl;
    return 0;
}


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

int main() {
	string o,e; int i;
	cin >> o >> e;
	for(i=0; i<e.size(); i++){
		cout << o[i] << e[i];
	}
	if(o.size()>e.size()){
		cout << o[i];
	}
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
 
using namespace std;
 
int main() {
  int n,m;
  while( cin >> n >> m, n|m ) {
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(ALL(a));
    int maxi = -1;
    rep(i,n) {
      int rem = m - a[i];
      int ptr = upper_bound(ALL(a),rem) - a.begin();
      --ptr;
      if( ptr == i ) --ptr;
      if( ( 0 <= ptr && ptr < n ) && a[i] + a[ptr] <= m ) maxi = max(maxi,a[i]+a[ptr]);
    }
    ( maxi == -1 ) ? puts("NONE") : printf("%d\n",maxi);
  }
  return 0;
}


Measured memory_bytes: 3248
//╔╗───────────╔╗────────────────────╔╗─
//║║──────────╔╝╚╗──────────────────╔╝╚╗
//║╚═╗╔══╗╔══╗╚╗╔╝╔══╗╔═╗╔╗╔╗╔══╗ ╔╗╚╗╔╝
//║╔╗║║╔╗║║╔╗║─║║─║║═╣║╔╝║╚╝║║╔╗║─╣║─║║─
//║╚╝║║╔╗║║║║║─║╚╗║║═╣║║─║║║║║╚╝║─║║─║╚╗
//╚══╝╚╝╚╝╚╝╚╝─╚═╝╚══╝╚╝─╚╩╩╝╚══╝─╚╝─╚═╝ 

#include <bits/stdc++.h>

#define pb push_back
#define ff first
#define ss second
#define sz size()
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define forn(i, n) for (int i = 0; i < (int) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

int main() {
    IO;
    int x;
    cin >> x;
    string res = "ARC";
    if(x < 1200){
        res[1] = 'B';
    }
    cout << res;
    return 0;
}

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

// 内部定数
#define D_MONEY_MAX		20										// 最大金額種類数

// 内部変数
static int si1Money[D_MONEY_MAX];								// 金額種類
static int siMCnt;												// 金額種類数
static int siACnt;												// 引き出し回数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// ソート関数 - int降順
int
fSortFnc(
	const void *pzpVal1			// <I> 値１
	, const void *pzpVal2		// <I> 値２
)
{
	int *lipVal1 = (int *)pzpVal1;
	int *lipVal2 = (int *)pzpVal2;

	// 降順
	if (*lipVal1 >  *lipVal2) {
		return(-1);
	}
	else if (*lipVal1 < *lipVal2) {
		return(1);
	}

	return 0;
}

// 引き出し回数セット
int
fSetACnt(
	int piMoney					// <I> 残額
	, int piACnt				// <I> 引き出し回数
	, int piMSNo				// <I> 金額種類配列番号 0～
)
{
	int i;

	// 引き出し回数チェック
	if (piACnt >= siACnt) {
		return 0;
	}

	// 残額チェック
	if (piMoney == 0) {			// 到達
		siACnt = piACnt;			// 引き出し回数更新
		return 0;
	}
	else if (piMoney < 0) {		// エラー
		return 0;
	}

	// 引き出し
	for (i = piMSNo; i <siMCnt; i++) {
		fSetACnt(piMoney - si1Money[i], piACnt + 1, i);
	}

	return 0;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	char lc1Buf[1024], lc1Out[1024];

	// データ初期化
	siMCnt = 0;													// 金額種類数
	siACnt = INT_MAX;											// 引き出し回数

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 合計金額取得
	int liMoney;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d", &liMoney);

	// 金額種類セット - １円
	si1Money[0] = 1;
	siMCnt = 1;

	// 金額種類セット - ６円のべき乗
	int liVal = 6;
	while (liMoney >= liVal) {
		si1Money[siMCnt] = liVal;
		siMCnt++;
		liVal *= 6;
	}

	// 金額種類セット - ９円のべき乗
	liVal = 9;
	while (liMoney >= liVal) {
		si1Money[siMCnt] = liVal;
		siMCnt++;
		liVal *= 9;
	}

	// ソート
	qsort(si1Money, siMCnt, sizeof(int), fSortFnc);

	// 引き出し回数セット
	fSetACnt(liMoney, 0, 0);

	// 結果セット
	sprintf(lc1Out, "%d\n", siACnt);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << (char)toupper(s1[0]);
    cout << (char)toupper(s2[0]);
    cout << (char)toupper(s3[0]);
    cout << endl;
 
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        StringBuilder a = new StringBuilder(scanner.nextLine());
        int b = Integer.parseInt(scanner.nextLine());
        for (int i = 0; i < b; i++) {
            String[] c = scanner.nextLine().split(" ");
            int d = Integer.parseInt(c[1]);
            int e = Integer.parseInt(c[2]) + 1;
            if (c[0].equals("print")) {
                System.out.println(a.substring(d, e));
            } else if (c[0].equals("reverse")) {
                StringBuilder builder = new StringBuilder(a.substring(d, e))
                        .reverse();
                a.replace(d, e, builder.toString());
            } else {
                a.replace(d, e, c[3]);
            }
 
        }
    }
}


Measured memory_bytes: 28456
#include <bits/stdc++.h>
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
#define FORD(i,a,b) for (int i=(a)-1; i>=(b); --i)

#define pb push_back
#define mp make_pair
#define st first
#define nd second

const int MOD = 1000000007;

int N;
char S[50];


map<tuple<int, int, string>, LL> memo;
LL go(int L, int R, string suf) {
  if (suf.size() > R-L) return 0;
  if (L == R) return suf.empty();

  auto entry = tuple<int, int, string>(L, R, suf);
  if (memo.find(entry) != memo.end()) return memo[entry];


  LL result = 0;
  if (!suf.empty()) {
    if (S[L] == suf.back()) {
      result += go(L+1, R, suf.substr(0, suf.size() - 1));
    }
    FOR(i,L+1,R) if (S[L] == S[i]) {
      result += go(L+1,i,string(S+i+1,S+R)+suf);
    }
  } else {
    FOR(i,L+1,R) if (S[L] == S[i]) {
      result += 2*go(L+1,i,string(S+i+1,S+R));
    }
  }

  return memo[entry] = result;
}


int main() {
  // ios_base::sync_with_stdio(0);

  scanf("%d", &N);
  N *= 2;
  scanf("%s", S);
  LL result = go(0,N,string());
  printf("%lld\n", result);

}


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

int main(){
  ll n;
  cin >> n;
  ll ans = 1e18;
  for(ll i=1;i*i<=n;i++){
    if(n%i!=0)continue;
    ll j = n/i;
    ans = min(ans,i+j-2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

class RAQ_RMQ:
    def __init__(self, n, F=min, e=float("inf")):
        self.n = n
        self.n0 = 2**(n-1).bit_length()
        self.e = e
        self.F = F
        self.lazy = [0]*(2*self.n0)
        self.data = [e]*(2*self.n0)

    def construct(self, a):
        for i, x in enumerate(a):
            self.data[i+self.n0] = x
        for i in range(self.n0-1, 0, -1):
            self.data[i] = self.F(self.data[2*i], self.data[2*i+1])

    def bottomup(self, i):
        i += self.n0
        k = i//(i & -i)
        c = k.bit_length()
        for j in range(c-1):
            k >>= 1
            self.data[k] = self.F(self.data[2*k], self.data[2*k+1]) + self.lazy[k]

    def topdown(self, i):
        i += self.n0
        k = i//(i & -i)
        c = k.bit_length()
        for j in range(c-1):
            idx = k >> (c - j - 1)
            ax = self.lazy[idx]
            if not ax:
                continue
            self.lazy[idx] = 0
            self.data[2*idx] += ax
            self.data[2*idx+1] += ax
            self.lazy[2*idx] += ax
            self.lazy[2*idx+1] += ax

    def query(self, l, r):
        self.topdown(l)
        self.topdown(r)
        L = l+self.n0
        R = r+self.n0

        s = self.e
        while L < R:
            if R & 1:
                R -= 1
                s = self.F(s, self.data[R])
            if L & 1:
                s = self.F(s, self.data[L])
                L += 1
            L >>= 1
            R >>= 1
        return s

    def add(self, l, r, x):
        L = l+self.n0
        R = r+self.n0

        while L < R :
            if R & 1:
                R -= 1
                self.data[R] += x
                self.lazy[R] += x
            if L & 1:
                self.data[L] += x
                self.lazy[L] += x
                L += 1
            L >>= 1
            R >>= 1

        self.bottomup(l)
        self.bottomup(r)

n,m = map(int, input().split())
memo = [[] for i in range(n+2)]
for i in range(m):
    l,r,a = map(int, input().split())
    memo[l].append((l,a))
    memo[r+1].append((l,-a))

seg = RAQ_RMQ(n+2, F=max, e=-float("inf"))
seg.construct([0]*(n+2))
for i in range(1, n+2):
    for j, a in memo[i]:
        seg.add(0, j, a)
    tmp = seg.query(0, i)
    seg.add(i, i+1, tmp)
ans = seg.query(0, n+1)
print(ans)

Measured memory_bytes: 126796
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
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;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string a,b;
    cin >> a >> b ;
    ll ans = 0;
    rep(i, a.size()){
        if(a[i] == b[i]) ans ++;
    }
    cout << ans << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*
 * author: Tran Minh Khoa
 * Ho Chi Minh University of Science
 */

#include <bits/stdc++.h>

using namespace std;

const int inf = (int) 1e9 + 7;
const long long INF = (long long) 1e18 + 7;

const int N = 123456;
const int M = 1010;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) (int) a.size()
#define all(a) a.begin(), a.end()
#define sqrt(x) (x) * (x)

#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define DEBUG(x) cerr << #x << " = " << x << '\n';
#define PR(x, a, b) { cerr << #x << " = "; REP(i, a, b) cerr << x[i] << ' '; cerr << '\n'; }
                 
int main() {
  #ifdef KM777
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
  #endif
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr); cout.tie(nullptr);
  char b;
  cin >> b;
  if (b == 'A') {
    cout << 'T' << '\n';
  }
  if (b == 'T') {
    cout << 'A' << '\n';
  }
  if (b == 'G') {
    cout << 'C' << '\n';
  }
  if (b == 'C') {
    cout << 'G' << '\n';
  }
        
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

	if(r<=y && y<=H-r && r<=x && x<=W-r)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}
	

Measured memory_bytes: 584
const mod = 10^9 + 7
function main()
    n,k = readline() |> split .|> (x -> parse(Int, x))
    marker = Vector(1:isqrt(n))
    append!(marker, map(x -> n ÷ x, marker)) |> unique! |> sort!
    for i = length(marker):-1:2 marker[i] -= marker[i-1] end 

    x = marker[:]
    for _ = 1:k-1
        x = reverse(cumsum(x)) .* marker .% mod
    end
    println(sum(x)%mod)
end
main()

Measured memory_bytes: 260736
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string in;
	getline(cin,in);
	bool f=false;
	string out="";
	for(int i = 0; i < in.size(); ++i)
	{
		if(in[i]==' '||in[i]==','||in[i]=='.')
		{
			if(2<out.size()&&out.size()<7)
			{
				if(f) cout<<" ";
				cout<<out;
				f=true;
			}
			out="";
		}	
		else out+=in[i];
	}
	cout<<endl;
  return 0;
}

Measured memory_bytes: 1176
while True:
    n, m = [int(_) for _ in raw_input().split()]
    if n == m == 0:
        break

    h = [int(raw_input()) for _ in xrange(n)]
    w = [int(raw_input()) for _ in xrange(m)]

    hs = {}

    for i in xrange(n):
        h0 = 0
        for j in xrange(i, n):
            h0 += h[j]
            hs[h0] = hs.get(h0, 0) + 1

    ans = 0

    for i in xrange(m):
        w0 = 0
        for j in xrange(i, m):
            w0 += w[j]
            ans += hs.get(w0, 0)

    print(ans)

Measured memory_bytes: 35736
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>

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

using namespace std;

int main() {
	int A, B;// , i, Max;
//	vector<int> x1(100),x2(100),ans(100);
	cin >> A >> B;
	if (A == 2 || B == 2) {
		cout << "No" << endl;
		return 0;
	}
	else {
		cout << "Yes" << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans;
ll dp[305][305][305];
vector<pair<int,int>> Q[305];


int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int l,r,x;
		cin>>l>>r>>x;
		Q[r].emplace_back(l,x);
	}
	dp[0][0][0]=1;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++)
			for(int k=0;k<=n;k++)
			{
				if(dp[i][j][k]==0)continue;
				int ma=max(i,max(j,k));
				bool ok=1;
				for(auto q : Q[ma])
				{
					int cnt=0;
					if(q.first<=i)cnt++;
					if(q.first<=j)cnt++;
					if(q.first<=k)cnt++;
					if(cnt!=q.second){ok=0;break;}
				}
				if(!ok)continue;
				dp[i][j][k]%=1000000007;
				if(ma==n)ans+=dp[i][j][k];
				dp[ma+1][j][k]+=dp[i][j][k];
				dp[i][ma+1][k]+=dp[i][j][k];
				dp[i][j][ma+1]+=dp[i][j][k];
			}
	ans%=1000000007;
	cout<<ans<<endl;
}

Measured memory_bytes: 221440
import itertools

n, m, q = map(int, input().split())
abcd = []
ans = 0

for i in range(q):
    abcd .append(list(map(int, input().split())))

for comb in list(itertools.combinations_with_replacement(range(1, m + 1),n)):
    sum = 0
    for i in range(q):
        if comb[abcd[i][1] - 1] - comb[abcd[i][0] - 1] == abcd[i][2]:
            sum += abcd[i][3]
    if ans < sum:
        ans = sum

print(ans)


Measured memory_bytes: 21624
S = input()
L = list(S)

if L.count('a') >= 2:
	print('no')
	quit()
if L.count('b') >= 2:
	print('no')
	quit()
if L.count('c') >= 2:
	print('no')
	quit()
if L.count('d') >= 2:
	print('no')
	quit()
if L.count('e') >= 2:
	print('no')
	quit()
if L.count('f') >= 2:
	print('no')
	quit()
if L.count('g') >= 2:
	print('no')
	quit()
if L.count('h') >= 2:
	print('no')
	quit()
if L.count('i') >= 2:
	print('no')
	quit()
if L.count('j') >= 2:
	print('no')
	quit()
if L.count('k') >= 2:
	print('no')
	quit()
if L.count('l') >= 2:
	print('no')
	quit()
if L.count('m') >= 2:
	print('no')
	quit()
if L.count('n') >= 2:
	print('no')
	quit()
if L.count('o') >= 2:
	print('no')
	quit()
if L.count('p') >= 2:
	print('no')
	quit()
if L.count('q') >= 2:
	print('no')
	quit()
if L.count('r') >= 2:
	print('no')
	quit()
if L.count('s') >= 2:
	print('no')
	quit()
if L.count('t') >= 2:
	print('no')
	quit()
if L.count('u') >= 2:
	print('no')
	quit()
if L.count('v') >= 2:
	print('no')
	quit()
if L.count('w') >= 2:
	print('no')
	quit()
if L.count('x') >= 2:
	print('no')
	quit()
if L.count('y') >= 2:
	print('no')
	quit()
if L.count('z') >= 2:
	print('no')
	quit()
print('yes')

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    n = I()

    return n * 2 // fractions.gcd(n,2)



print(main())


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

struct edge {
    int from, to;
    edge(int f, int t) : from(f), to(t) {}
};

using edges = vector<edge>;
using graph = vector<edges>;

class lowlink { // multiple edges ok
public:
    lowlink(graph const& g)
        : ord(g.size()), low(g.size())
    {
        const int n = g.size();
        std::vector<bool> visited(n);
        int cnt = 0;
        for(int i = 0; i < n; ++i) {
            if(!visited[i]) {
                dfs(g, i, -1, cnt, visited);
            }
        }
    }

    std::vector<int> get_articulation_points() const { return articulation_points; }
    std::vector<edge> get_bridges() const            { return bridges; }

    bool is_bridge(int u, int v) const {
        if(ord[u] > ord[v]) std::swap(u, v);
        return ord[u] < low[v];
    }

private:
    void dfs(graph const& g, int v, int prev, int& cnt, std::vector<bool>& visited) {
        visited[v] = true;
        low[v] = ord[v] = cnt++;
        bool is_articulation = false;
        int cnt2 = 0, pcnt = 0;

        for(auto& e : g[v]) {
            if((e.to != prev || (e.to == prev && pcnt == 1)) && visited[e.to]) {
                low[v] = min(low[v], ord[e.to]);
            } else if(!visited[e.to]) {
                cnt2++;
                dfs(g, e.to, v, cnt, visited);
                low[v] = min(low[v], low[e.to]);
                if(prev != -1 && ord[v] <= low[e.to]) {
                    is_articulation = true;
                }
                if(is_bridge(v, e.to)) {
                    bridges.push_back(edge{min(v, e.to), max(v, e.to)});
                }
            }
            pcnt += e.to == prev;
        }
        is_articulation |= (prev == -1 && cnt2 > 1);
        if(is_articulation) articulation_points.push_back(v);
    }

private:
    std::vector<int> articulation_points;
    std::vector<edge> bridges;
    std::vector<int> ord, low;
};


int main() {
    int n, m; cin >> n >> m;
    graph g(n);
    vector<int> deg(n);
    for(int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        a--, b--;
        g[a].emplace_back(a, b);
        g[b].emplace_back(b, a);
        deg[a] += 1;
        deg[b] += 1;
    }
    lowlink helper(g);
    vector<bool> is_art(n);
    for(auto&& v : helper.get_articulation_points()) {
        is_art[v] = true;
    }

    for(int i = 0; i < n; ++i) {
        if(deg[i] & 1) {
            cout << "No" << endl;
            return 0;
        }
    }

    vector<int> cnt(3);
    for(int i = 0; i < n; ++i) {
        if(deg[i] == 4 && is_art[i]) {
            cnt[0] += 1;
        } else if(deg[i] >= 6) {
            cnt[1] += 1;
        } else if(deg[i] == 4 && !is_art[i]) {
            cnt[2] += 1;
        }
    }
    if(cnt[0] >= 2 || cnt[1] >= 1 || cnt[2] >= 3 || (cnt[0] >= 1 && cnt[2] >= 1)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 11520
/* Alohomora */
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define pb         push_back
#define mp         make_pair
#define mod        1000000007
#define all(x)     x.begin(),x.end()    
#define F          first 
#define S          second
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
void comp() {
 ll i,j,k,n,m;
 cin>>i>>j>>k;
 swap(i,j);
 swap(i,k);
 cout<<i<<" "<<j<<" "<<k<<endl;
}
  
int main() {
  speedup;
  ll i=0,t;
  //cin>>t;
  t=1;
  while(t--) {
    comp();
  }
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int cnt = 0;

//画面表示用
void printconsole(int *A,int n){
    for (int k = 0; k < n; k++) {
        printf("%d",A[k]);
        if(k != n-1)putchar(' ');
    }
    putchar('\n');
}


//挿入ソート
void insertionSort(int *A,int n,int g){
    int v,j;
    for (int i = g; i < n; i++) {
        v = A[i];
        j = i - g;
        while(j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j+g] = v;
    }
}

//シェルソート
void shellsort(int *A,int n){
    
    int m = 5;
    int cm = 0;
    int G[5] = {1000,100,10,4,1};
    for (int i = 0; i < m; i++) {
        insertionSort(A, n,G[i]);
        if(G[i] <= n){
            cm++;
        }
    }
    
    printf("%d\n",cm);
    for (int i = m - cm; i < m ; i++) {
        printf("%d",G[i]);
        if(i != m - 1 )printf(" ");
    }
    printf("\n");
    printf("%d\n",cnt);
    for (int i = 0; i < n; i++) {
        printf("%d\n",A[i]);
    }
}


int main(int argc, const char * argv[]) {
    
    int n;
    int A[1000000];
    scanf("%d",&n);
    
    for (int i = 0; i < n; i++) {
        scanf("%d",&A[i]);
    }
    
    shellsort(A, n);
    
    /*
    printf("%d\n",n);
    for (int i = 0; i < n; i++) {
        printf("%d\n",A[i]);
    }
     */

    return 0;
}



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

int main()
{
        string S;
        int count=0,i;

        cin>>S;

        for(i=0;i<4;i++)
        {
                if(S[i]=='+')
                {
                        count++;
                }
                else
                {
                        count--;
                }
        }

        cout<<count<<endl;



        return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

const int MOD = 998244353;

int add(int x, int y) {
    x += y;
    if (x >= MOD)
        return x - MOD;
    return x;
}

int sub(int x, int y) {
    x -= y;
    if (x < 0)
        return x + MOD;
    return x;
}

int mul(int x, int y) {
    return (1LL * x * y) % MOD;
}

int bin_pow(int a, int p) {
    if (!p)
        return 1;
    if (p % 2)
        return (1LL * bin_pow(a, p - 1) * a) % MOD;
    int t = bin_pow(a, p / 2);
    return (1LL * t * t) % MOD;
}

int inv(int x) {
    return bin_pow(x, MOD - 2);
}


int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, s;
    cin >> n >> s;
    vector <int> a(n);
    cin >> a;
    vector <int> dp(s + 1);
    dp[0] = 1;
    forn (i, 0, n) {
        vector <int> new_dp(s + 1);
        forn (j, 0, s + 1)
            new_dp[j] = mul(dp[j], 2);
        forn (j, 0, s + 1 - a[i])
            new_dp[j + a[i]] = add(new_dp[j + a[i]], dp[j]);
        dp = new_dp;
    }
    cout << dp[s];
    return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main(){__
	lli a;
	cin >> a;
	Double b;
	cin >> b;
	lli ans = floor(Double(a) * b);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3748
X,Y,Z,K=map(int,input().split())
A= list(map(int,input().split()))
B= list(map(int,input().split()))
C= list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
ans=[]
for i in range(min(X,K)):
 D=int(K/(i+1))+1
 for j in range(min(D,Y,K)):
  E=int(D/(j+1))+1
  for k in range(min(E,Z,K)):
   ans.append(A[i]+B[j]+C[k])
ans.sort(reverse=True)
for i in range(K):
 print(ans[i])


Measured memory_bytes: 48752
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const ll MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);
const int MAX=200010;


int main() {
    ios_base::sync_with_stdio(false);

    ll n,d,a;
    cin >> n >> d >> a;
    vector<pair<ll,ll>> p(n);
    rep(i,n) cin >> p[i].first >> p[i].second;
    sort(p.begin(),p.end());
    queue<pair<ll,ll>> q;
    ll cnt=0,ans=0;
    rep(i,n) {
        while (!q.empty()) {
            pair<ll,ll> pp=q.front();
            if (p[i].first<=pp.first) break;
            else {
                cnt-=pp.second;
                q.pop();
            }
        }
        ll tans=(p[i].second+a-1)/a-cnt;
        if (tans>0) {
            ans+=tans;
            cnt+=tans;
            q.push({p[i].first+2*d,tans});
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7832
N = input()
p = [int(t)-1 for t in raw_input().split()]

ad = [1]*N
bd = [1]*N

for i in range(len(p)):
    ad[p[i]] += i
    bd[p[i]] += i

a = [0]*N
for i in range(N):
    a[i] = (0 if i==0 else a[i-1]) + ad[i]
b = [0]*N
for i in range(N)[::-1]:
    b[i] = (0 if i==N-1 else b[i+1]) + bd[i]

for t in a:
    print t,
print
for t in b:
    print t,
print


Measured memory_bytes: 6804
#include <iostream>
#include<algorithm>
#include <malloc.h>
#include<stack>
#include<map>
#include<stdio.h>
#include<set>
#define INF 0x3f3f3f3f
using namespace std;
int main()
{  set<char>s;
  int i;
    string ss;
    cin>>(ss);
    int len=ss.length();
    for(i=0;i<len;i++)
    {
        if(ss[i]==ss[i+1])
        {
            printf("%d %d",i+1,i+2);
            return 0;
        }
        if(ss[i]==ss[i+2])
        {
            printf("%d %d",i+1,i+3);
            return 0;
        }
      
    }
    printf("-1 -1\n");


    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    string s,t;
    cin >> s >> t;
    vi vs(26,0),vt(26,0);
    rep(i,s.size()){
        vs[s[i]-'a']++;
        vt[t[i]-'a']++;
    }
    sort(vs.begin(),vs.end());
    sort(vt.begin(),vt.end());
    cout << (vs==vt? "Yes" : "No") << endl;
}

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

int compare_llint_rise(const void *a, const void *b) {
	long long int A, B;
	A = *(long long int *)a;
	B = *(long long int *)b;
	if(A < B) {
		return -1;
	} else if (A > B){
		return 1;
	} else {
		return 0;
	}
}

int main(void) {
	int N;
	long long int *A;
	int i;
	int count;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	N = atoi(ch);
	A = (long long int *)calloc(N, sizeof(long long int));
	for(i = 0; i < N; i += 1) {
		fgets(buf, sizeof(buf), stdin);
		ch = strtok(buf, " ");
		A[i] = atoll(ch);
	}

	qsort(A, N, sizeof(long long int), compare_llint_rise);

	count = 1;
	for(i = 1; i < N; i += 1) {
		if(A[i] == A[i - 1]) {
			count -= 1;
			A[i] = -1;
		} else {
			count += 1;
		}
	}

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

	free(A);
	return 0;
}


Measured memory_bytes: 3380
import sys
N = int(input())

for h in range(1,3501):
    for n in range(1,3501):
        tmp = 4*h*n-N*(h+n)
        if tmp == 0:continue
        if (N*h*n)%(tmp) == 0:
            w = N*h*n // (tmp)
            if w <= 0:continue
            if h*n*w % N == 0:
                print(h,n,w)
                sys.exit()
        
print(-1)

Measured memory_bytes: 42900
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  if(a1 + a2 + a3 >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
}


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

// RGB Boxes
int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int count = 0;
  for (int i = 0; i <= N / R; i++) {
    for (int j = 0; j <= N / G; j++) {
      int Bcan = N - (i * R + j * G);
      if (Bcan >= 0 && Bcan % B == 0) {
        count++;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import sys
from collections import Counter
n = int(input())
A = list(map(int, input().split()))

# 全部同じ数字の時
if len(set(list(A))) == 1:
    print(n // 2)
    sys.exit(0)
O = A[0::2]
E = A[1::2]
mco = Counter(O).most_common()
mce = Counter(E).most_common()

l = len(O) # == len(E)
io = 0
io_max = len(mco) - 1
ie = 0
ie_max = len(mce) - 1
while(mco[io][0] == mce[ie][0]):
    if io_max <= io + 1:
        ie += 1
        continue
    if ie_max <= ie + 1:
        io += 1
        continue
    v1 = mco[io][1] + mce[ie+1][1]
    v2 = mco[io+1][1] + mce[ie][1]
    if v1 >= v2:
        ie += 1
    else:
        io += 1

print(l*2-mco[io][1]-mce[ie][1])


Measured memory_bytes: 21068
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

void dfs(const vector<vector<int>>& graph, vector<int>& color, int node, int c) {
    color[node] = c;
    for (auto next_node : graph[node]) {
        if (color[next_node] < 0) {
            dfs(graph, color, next_node, c);
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<ll> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    int X, Y;
    vector<vector<int>> graph(N);
    rep(_, 0, M) {
        cin >> X >> Y;
        graph[X].push_back(Y);
        graph[Y].push_back(X);
    }
    if (M == N - 1) {
        cout << 0 << endl;
        return 0;
    }
    if (N < 2 * (N - M - 1)) {
        cout << "Impossible" << endl;
        return 0;
    }
    vector<int> color(N, -1);
    int now_color = 0;
    rep(i, 0, N) {
        if (color[i] < 0) {
            dfs(graph, color, i, now_color++);
        }
    }
    vector<priority_queue<ll, vector<ll>, greater<ll>>> labels(now_color);
    rep(i, 0, N) {
        labels[color[i]].push(A[i]);
    }
    ll ans = 0;
    ll rest = 2 * (N - M - 1) - now_color;
    rep(i, 0, now_color) {
        ans += labels[i].top();
        labels[i].pop();
    }
    priority_queue<ll, vector<ll>, greater<ll>> que;
    rep(i, 0, now_color) {
        while (!labels[i].empty()) {
            que.push(labels[i].top());
            labels[i].pop();
        }
    }
    rep(i, 0, rest) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin >> n >> k;
  vector<int> a(n);
  int sum=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum+=a[i];
  }
  vector<int> v;
  for(int i=1;i*i<=sum;i++){
    if(sum%i==0){
      v.push_back(i);
      if(i*i!=sum){
        v.push_back(sum/i);
      }
    }
  }
  sort(v.begin(),v.end(),greater<int>());
  for(int i=0;i<v.size();i++){
    vector<int> r(n),sl(n),sr(n);
    for(int j=0;j<n;j++){
      r[j]=a[j]%v[i];
    }
    sort(r.begin(),r.end());
    for(int j=0;j<n;j++){
      if(!j){
        sl[j]=r[j];
      }
      else{
        sl[j]=sl[j-1]+r[j];
      }
    }
    for(int j=n-1;j>=0;j--){
      if(j==n-1){
        sr[j]=(v[i]-r[j])%v[i];
      }
      else{
        sr[j]=sr[j+1]+(v[i]-r[j])%v[i];
      }
    }
    int cnt=1e9+5;
    for(int j=0;j<n-1;j++){
      if(sl[j]==sr[j+1]){
        cnt=min(cnt,sl[j]);
      }
    }
    if(cnt<=k){
      cout << v[i] << endl;
      return 0;
    }
  }
}

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

int main() {
  int x;
  cin >> x;
  int s1 = x/500;
  int s2 = x%500;
  s2 = s2 /5;
  int sum = s1 * 1000 + s2 * 5;
  cout << sum;
 return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

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

	cout << (a-1)*(b-1) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b)
{
  if(b==0) return a;
  else	return gcd(b,a%b);
}
ll gcds(ll a,ll b,ll c)
{
  ll g = gcd(a,b);
  return gcd(g,c);
}
int main()
{
  ll k,sum=0;
  cin >> k;
  for(int i=1;i<=k;i++)
  {
    for(int j=1;j<=k;j++)
    {
    for(int l=1;l<=k;l++)
    {
      sum+=gcds(i,j,l);
    }
    }
  }
  cout << sum;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <climits>
#include <map>
using namespace std;
 
static const long long INFTY = (1LL<<32);
 
 
int main() {
    int n;
    cin >> n;
    
    int ans = 1;
    int value = 0;
    
    while ( n > 0 ) {
        value++;
        n /= 2;
    }
    
    while ( --value > 0 ) {
        ans *= 2;
    }
    
    cout << ans << endl;
}

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

int n, m;
priority_queue<ll> que;

int main(){
  cin >> n >> m;
  rep(i, n){
    ll tmp;
    cin >> tmp;
    que.push(tmp);
  }
  
  rep(i, m){
    ll tmp;
    tmp = que.top(), que.pop();
    tmp /= 2LL;
    que.push(tmp);
  }
  
  ll res = 0;
  while(que.size()){
    res += que.top();
    que.pop();
  }
  
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int p1 = 0, p2 = 0;
		p1 = n * a;
		p2 = b;
		if(p1 < p2) {
			System.out.println(p1);
		}else{
			System.out.println(p2);
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
using namespace std;
//using ll=long long;

int main(){
    string S;
    cin >> S;
    int ans = 0;
    for(int i = 0; i < 4; ++i){
        if(S[i] == '+') ans += 1;
        else ans -= 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 100010
#define inf 0x3f3f3f3f
int v[maxn];
int pre[maxn];
vector<int> g[maxn];
int ty[maxn];
bool used[maxn];
int a,b;
void dfs(int u){
    a++;b+=ty[u];
    used[u]=true;
    for(int i=0;i<g[u].size();i++){
        int to=g[u][i];
        if(used[to]) continue;
        dfs(to);
    }
}
int main(){
    int n,T;
    scanf("%d%d",&n,&T);
    scanf("%d",&v[0]);
    int minx=v[0],dis=0,pos=0;
    for(int i=1;i<n;i++){
        scanf("%d",&v[i]);
        if(v[i]<=minx){
            pre[i]=i;
            minx=v[i];
            pos=i;
        }
        else{
            pre[i]=pos;
            dis=max(dis,v[i]-v[pos]);
        }
    }
    memset(used,1,sizeof(used));
    for(int i=1;i<n;i++){
        if(v[i]-v[pre[i]]==dis){
            g[pre[i]].push_back(i);
            g[i].push_back(pre[i]);
            used[i]=used[pre[i]]=false;
            ty[pre[i]]=1;
        }
    }
    int res=0;
    for(int i=0;i<n;i++){
        if(!used[i]){
            a=b=0;
            dfs(i);
            res+=min(b,a-b);
        }
    }
    printf("%d\n",res);
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
// end of Template

str s;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s;
    if( (s[0]==s[1] && s[1]==s[2]) || (s[1]==s[2] && s[2]==s[3]) ){cout<<"Yes\n";}
    else{cout<<"No\n";}


}


Measured memory_bytes: 256
//  Suraj Saste

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pi pair<ll,ll>
#define in insert
#define fe first
#define se second
#define ms(x,i) memset(x,i,sizeof(x))
#define prec(x) cout<<std::setprecision(x)
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll fpow(ll n, ll k, ll p=mod) {ll r=1; n=n%p; while(k>0){ if(k&1){ r=(r*n)%p; } k=k>>1; n=(n*n)%p; } return r;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 || n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0||n%(i+2)==0)return false;}return true;}

int main()
{
	fast;
	ll n,m;cin>>n>>m;
	ll a[n][m],dp[n][m];
	for(ll i=0;i<n;i++)
	{
		string s;cin>>s;
		for(ll j=0;j<m;j++)
		{
			if(s[j]=='.')a[i][j]=0;
			else a[i][j]=1;
			dp[i][j]=0;
		}
	}
	for(ll i=0;i<n;i++)
	{
		if(!a[i][0])dp[i][0]=1;
		else break;
	}
	for(ll i=0;i<m;i++)
	{
		if(!a[0][i])dp[0][i]=1;
		else break;
	}
	for(ll i=1;i<n;i++)
	{
		for(ll j=1;j<m;j++)
		{
			if(a[i][j]==0)
			{
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
			}
		}
	}
	// for(ll i=0;i<n;i++)
	// {
	// 	for(ll j=0;j<m;j++)cout<<dp[i][j]<<" ";
	// 	cout<<"\n";
	// }
	cout<<dp[n-1][m-1];
	return 0;
}


Measured memory_bytes: 15872
import sys
from collections import deque

def solve():
    input = sys.stdin.readline
    N = int(input())
    Edge = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b, c = map(int, input().split())
        Edge[a-1].append((b-1, c))
        Edge[b-1].append((a-1, c))
    Q, K = map(int, input().split())
    q = deque()
    Dist = [-1] * N
    q.append((K-1, K-1, 0))
    while q:
        nowN, preN, nD = q.popleft()
        if Dist[nowN] == -1:
            Dist[nowN] = nD
            for e, add in Edge[nowN]:
                if e != preN: q.append((e, nowN, nD + add))
    Ans = [None] * Q
    for i in range(Q):
        x, y = map(int, input().split())
        Ans[i] = str(Dist[x-1] + Dist[y-1])
    print("\n".join(Ans))

    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 53884
# encoding: utf-8
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]

route = [[] for i in range(N)]

for ai, bi in ab:
    route[ai - 1].append(bi - 1)
    route[bi - 1].append(ai - 1)

def walk(pos, pos_prev, footprint):
    # print("#", pos, footprint)
    footprint = (2 ** pos) | footprint
    ret = footprint
    for pos_next in route[pos]:
        # print("##", pos_next, (2 ** pos_next) & footprint)
        if (2 ** pos_next) & footprint > 0: continue
        ret = ret | walk(pos_next, pos, footprint)
        if ret == (2 ** N - 1): return 2 ** N - 1 # speed test
    return ret

ans = 0
for ai, bi in ab:
    # temporary remove
    route[ai - 1].remove(bi - 1)
    route[bi - 1].remove(ai - 1)
    # connection check
    if walk(0, -1, 0) < (2 ** N - 1): ans += 1
    # recovery
    route[ai - 1].append(bi - 1)
    route[bi - 1].append(ai - 1)

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll N,W; cin >> N >> W;
 
    ll w[105],v[105];
 
    vector<ll> lis[4];
 
    cin >> w[0] >> v[0];
    lis[0].push_back(v[0]);
 
    for (int i =1;i < N;i++){
        cin >> w[i] >> v[i];
        lis[w[i]-w[0]].push_back(v[i]);
    }
 
    vector<ll> sum[4];
 
    for (int i = 0;i < 4;i++){
        sort(lis[i].begin(),lis[i].end());
        reverse(lis[i].begin(),lis[i].end());
        sum[i].push_back(0);
        for (int j = 0;j < lis[i].size();j++){
            sum[i].push_back(sum[i][j]+lis[i][j]);
        }
    }
 
    ll ans = -1;
 
    for (int i = 0;i <= lis[0].size();i++){
        for (int j = 0;j <= lis[1].size();j++){
            for (int k = 0;k <= lis[2].size();k++){
                for (int l = 0;l <= lis[3].size();l++){
                    if(w[0]*i+(w[0]+1)*j+(w[0]+2)*k+(w[0]+3)*l > W) continue;  
                    ans = max(sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l], ans);
                }
            }
        }
    }
 
    cout << ans << endl;
 
    return 0;
 
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			int[] arrived = new int[3];
			int[] accepted = new int[3];
			
			for(int i = 0; i < n; i++){
				String[] time_str = sc.next().split(":");
				
				int hour = Integer.parseInt(time_str[0]);
				int min = Integer.parseInt(time_str[1]);
				int min2 = sc.nextInt();
				
				int type = -1;
				if(hour >= 11 && hour < 15){
					type = 0;
				}else if(hour >= 18 && hour < 21){
					type = 1;
				}else if((hour >= 21 && hour <= 24) || (hour >= 0 && hour < 2)){
					type = 2;
				}
				
				if(type == -1){
					continue;
				}
				
				arrived[type]++;
				
				if(min > min2){
					min2 += 60;
				}
				
				if(min2 - min <= 8){
					accepted[type]++;
				}
			}
			
			String[] str = {"lunch", "dinner", "midnight"};
			
			for(int i = 0; i < 3; i++){
				System.out.println(str[i] + " " + (arrived[i] == 0 ? "no guest" : ((accepted[i] * 100) / arrived[i]) + ""));
			}
		
		}
	}

}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin>>n;
    for(ll i=n;i>=0;i--){
        int k=sqrt(i);
        if(k*k==i){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


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

int main() {
	long a,b;
	cin >> a >> b;
	if (a*b <= 0) cout << "Zero" << endl;
	else if (a > 0) cout << "Positive" << endl;
	else {
		if ((b - a + 1) % 2 == 0) cout << "Positive" << endl;
		else cout << "Negative" << endl;
	}
}


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

using ll = long long;
using P = pair<int, int>;

int main() {
    string s, t;

    cin >> s >> t;

    string ans = "No";
    if (s == t.substr(0,s.size())) {
        ans = "Yes";
    }
    cout << ans << endl;
}


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

int main() {
  int cnt = 0;
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++)
    if (s[i] == 'o') cnt++;
  cout << 700 + (100 * cnt) << endl;
}

Measured memory_bytes: 3540
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int[] lines = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        
        Console.WriteLine("{0} {1} {2}", lines[0] / lines[1], lines[0] % lines[1], string.Format("{0:f5}\r\n", (double)lines[0] / lines[1]));
    }
}

Measured memory_bytes: 9556