akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

bool sum_binsearch(int target, int index, vector<int>& A) {
	if(target==A[index]) {
		return true;
	} else if( target < A[index] || index>=(int)A.size()) {
		return false;
	} else {
		return (sum_binsearch(target,index+1,A) || sum_binsearch(target-A[index],index+1,A));
	}
}

int main() {
	int i;
	int m,n,q;
	vector<int> A;
	scanf("%d",&n);
	A.resize(n);
	for(i=0;i<n;++i) {
		scanf("%d",&A[i]);
	}
	sort(A.begin(),A.end()); // ?????????
	scanf("%d",&q);
	for(i=0; i<q; ++i) {
		scanf("%d",&m);
		if(sum_binsearch(m,0,A)) {
			printf("yes\n");
		} else {
			printf("no\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2616
from collections import deque

n, m = map(int, input().split())
ans_list = [0]*(n+1)

class Node:
    def __init__(self, x):
        self.val = x
        self.adj = []

nodelist = [Node(0)]
for i in range(1, n+1):
  nodelist.append(Node(i))

for i in range(m):
    a, b = map(int, input().split())
    nodelist[a].adj.append(b)
    nodelist[b].adj.append(a)

q = deque()
q.append(nodelist[1])

while len(q) > 0:
    node = q.popleft()

    if node is not None:
        for i in node.adj:
            if ans_list[i] == 0:
                ans_list[i] = node.val
                q.append(nodelist[i])

print('Yes')
for j in range(2, n + 1):
    print(ans_list[j])  


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

#define MATHPI acos(-1)

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

using Mat = vector<vector<ll>>;
using Column = vector<ll>;
// using Graph = vector<vector<bool>>;

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N,M;cin>>N>>M;
    vector<vector<bool>> g(N+1, vector<bool>(N+1, false));
    
    for (size_t i = 0; i < M; i++)
    {
        int a,b;cin>>a>>b;
        g[a][b] = true;
        g[b][a] = true;
    }

    vector<int> B;
    for (int i = 0; i < N; i++) {
        B.push_back(i+1);
    }

    int cnt=0;
    do {
        bool connected =true;
        for (size_t i = 0; i < N-1; i++)
        {
            if(!g[B[i]][B[i+1]]) {
                connected = false;
                break;
            }
        }
        if(connected) {
            cnt++;
        }
    } while(next_permutation(B.begin() + 1, B.end()));

    cout << cnt<<"\n";
    

    return 0;

}

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

typedef complex<double> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()
const double EPS = 1e-9;
const double PI = acos(-1.0);
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

namespace std {
    bool operator<(const Point a, const Point b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

double dot(Point a, Point b) {
    return a.X*b.X + a.Y*b.Y;
}

double cross(Point a, Point b) {
    return a.X*b.Y - a.Y*b.X;
}

int ccw(Point a, Point b, Point c) {
    b -= a;  c -= a;
    if (cross(b,c) >  EPS) return +1;  // counter clockwise
    if (cross(b,c) < -EPS) return -1;  // clockwise
    if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
    if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
    return 0;                          // a--c--b on line or a==c or b==c
}

VP convexHull(VP ps) {  // 元の点集合がソートされていいならVP&に
  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  VP ch(2*n);
  for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
    while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;  // 余計な点も含むなら == -1 とする
  for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) // upper-hull
    while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  ch.resize(k-1);
  return ch;
}

int main(void){
    VP vp;
    int n;
    cin>>n;
    rep(i,n){
        double x,y;
        cin>>x>>y;
        vp.push_back(Point(x,y));
    }

    VP ch = convexHull(vp);
    int m = ch.size();
    vector<double> range;
    rep(i,m){
        range.push_back(arg(ch[(i+1)%m]-ch[i]) - arg(ch[i]-ch[(m+i-1)%m]));
    }

    rep(i,n){
        bool inConvex = true;
        rep(j,m){
            if(vp[i] == ch[j]){
                inConvex = false;
                printf("%.10f\n", acos(cos(range[j]))/(2.0*PI));
                break;
            }
        }
        if(inConvex) printf("0.0\n");
    }

    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] list = new int[n];

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

        Arrays.sort(list);

        int ans = Integer.MAX_VALUE;

        for (int i = list[0]; i <= list[n - 1]; i++) {
            int part = 0;
            for (int v: list
                 ) {
                part += (v - i) * (v - i);
            }
            ans = Math.min(ans, part);
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 998244353;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int t[26];
#define DIV 4
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, 0, n)cin >> a[i];
	sort(all(a));
	int x[DIV + 1], p;
	x[0] = a.front(), x[DIV] = a.back();
	ll s, m;
	while (x[DIV] - x[0] > 1) {
		m = 1ll << 60;
		rep(i, 1, DIV) {
			x[i] = x[0] + (x[DIV] - x[0]) * i / DIV;
			s = 0;
			rep(i2, 0, n) {
				s += (a[i2] - x[i]) * (a[i2] - x[i]);
			}
			if (m > s)m = s, p = i;
		}
		x[0] = x[p - 1], x[DIV] = x[p + 1];
	}
	printf("%d\n", m);
	return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
  function Main(input) {
  	// 1行目がinput[0], 2行目がinput[1], …に入る
  	input = input.split("\n");
  	var arry_kushi = input[1].split(" ");
    var sumNum = 0;

    //入力された串を配列に格納し、昇順で並べ換え。
    arry_kushi.sort(
      function(a,b){return a - b;}
    )

    //偶数で(%2で)割り切れる時に、値を入れる（昇順で並べ替えているので、偶数の時には必ず値が小さい）
    arry_kushi.forEach(function(a,i){
      if(i % 2　== 0) {
        sumNum += Number(a);
      }
    });
    console.log(sumNum);
  }
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
import os
import sys

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph._shortest_path import dijkstra

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, X, Y = list(map(int, sys.stdin.buffer.readline().split()))

V = [X - 1]
U = [Y - 1]
for i in range(N - 1):
    V.append(i)
    U.append(i + 1)

graph = csr_matrix(([1] * N, (V, U)), shape=(N, N))
dist = dijkstra(graph, directed=False).astype(int)
ans = np.bincount(dist.ravel(), minlength=N) // 2
print(*ans[1:], sep='\n')


Measured memory_bytes: 76504
#include<bits/stdc++.h> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl "\n"
#define p_b push_back
#define fastIO ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
template <class T> 
using _ost = tree<
		T, 
		null_type, 
		less<T>, 
		rb_tree_tag, 
        tree_order_statistics_node_update>;
// char alphabet[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
void swap(int* a,int* b){
    int temp = *a;
    *a=*b;
    *b=temp;
}
int32_t main(){
 	fastIO;
 	int n,m;cin>>n>>m;
 	int a[n],sum=0;
 	for(int i=0;i<n;i++){
 		cin>>a[i];
 		sum+=a[i];
 	}
 	int req=sum/(4*m);
 	if(sum%(4*m)!=0)req++;
 	sort(a,a+n);
 	int i;
 	for(i=n-1;i>=n-m;i--){	
 		if(a[i]>=req);
 		else break;
 	}
 	if(i!=n-m-1)cout<<"No"<<endl;
 	else cout<<"Yes"<<endl;
} 	

Measured memory_bytes: 256
'''بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ'''
#codeforces
gi = lambda : list(map(int,input().split()))
cnt = 0
for _ in range(gi()[0]):
  x, y = gi()
  if x == y:
    cnt += 1
  else:
    cnt = 0
  if cnt == 3:
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
string s;

int main(){
	cin>>n;
	int l=0,r=n/2+1,t=0;
	cout<<l<<endl;
	cin>>s;
	if(s[0]=='V') return 0;
	if(s[0]=='F') t++;
	while(r-l>1){
		int m=(l+r)/2;
		cout<<2*m<<endl;
		cin>>s;
		if(s[0]=='V') return 0;
		if(s[0]=='M'^t) l=m;
		else r=m;
	}
	cout<<2*l+1<<endl;
	cin>>s;
}

Measured memory_bytes: 852
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = Long.parseLong(sc.next());
		long V = Long.parseLong(sc.next());
		long B = Long.parseLong(sc.next());
		long W = Long.parseLong(sc.next());
		long T = Long.parseLong(sc.next());
		sc.close();
 
		if(V > W) {
			long diff = V - W;
			long distance = Math.abs(A - B);
			if(distance <= diff * T) {
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}
		}else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 35520
// █   https://www.youtube.com/watch?v=Dx6OQ7RvDXc

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef long long unsigned llu;
typedef pair<long long, long long> pll;
const long long inf = 2000000000000000000LL;	// 2e18
#define pi                  acos(-1.0)
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define shesh               "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define bp                  pop_back
#define pf                  push_front
#define fp                  pop_front
#define ub                  upper_bound
#define lb                  lower_bound
#define all(x)              x.begin(), x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"
#define mest(a,b)           memset(a,b,sizeof(a))

int main(){
    fast;
    ll t,n,m,i,j,k,l,temp,flag,len,shit,q,res,ans=0,p;
    cin>>n>>k;
    ans=0;
    if(k%2==0)
        temp=(n+(k/2))/k;
    else temp=0;
    ans+=(temp*temp*temp);
    temp=(n/k);
    ans+=(temp*temp*temp);
    cout<<ans;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            double w = Double.parseDouble(in.next());
            double h = Double.parseDouble(in.next());
            double x = Double.parseDouble(in.next());
            double y = Double.parseDouble(in.next());
            double ans = w * h / 2.0;
            // 出力
            out.printf("%.10f", ans);
            out.print(" ");

            if (2 * x == w && 2 * y == h && w % 2 == 0 && h % 2 == 0) out.print(1);
            else out.print(0);

        }

    }
}



Measured memory_bytes: 22100
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
 
/*** Template Begins ***/
 
typedef long long    ll;
typedef pair<ll,ll>  pll;
typedef pair<ll, pair<int, int> > plll;
typedef vector<long long>  vll;
typedef vector<pll>  vp;
typedef long double ld;
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
#define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
// #define h 998244353
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p){ ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p;y = y>>1;x = (x*x) % p;} return res; } 
 
// Debug //
 
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
// Constants //
 
 
/*** Template Ends ***/
ll n;
std::vector<ll> h(100005),cache(100005,-1);
ll cost(ll n)
{
  if(n==1)
    return 0;
  if(n==2)
    return abs(h[2]-h[1]);
  if(cache[n]!=-1)
    return cache[n];
  return  cache[n] = min(abs(h[n]-h[n-1])+cost(n-1),cost(n-2)+abs(h[n]-h[n-2]));

}
void solve()
{
  cin>>n;
  ll i=0;

  for(i=1;i<=n;i++)
    cin>>h[i];
  if(n==1)
    cout<<0;
  else
    cout<<cost(n);
}
 
int main(){ 
  ios;
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  ll t;
  // cin >> t;
  t=1;
  while(t--)
    solve();
 
  return 0;
}

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

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

int main() {
   int N; cin >> N;
   vector<int> d(N);
   rep(i,N) cin >> d[i];
   int ans = 0;
   for(int i = 0; i < N; i++){
       for(int j = i + 1; j < N; j++){
           ans += d[i] * d[j];
       }
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var res = 0L;
        var mark = new long[n];
        for (int i = 0; i < a.Length; i++)
        {
            if (0 <= i - a[i]) res += mark[i - a[i]];
            if (i + a[i] < n) mark[i + a[i]]++;
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 45164
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxd = 64;
const int mod = 1e9+7;
int a[maxd],b[maxd];
long long dp[maxd][2][2][2],n,m;
long long dfs(int p,int l,int r,int f)
{
	//位数，是否填过小于m的值，是否填过大于n的值，是否填过a<b,最高位是否都为1
	if(p < 0) return 1;
	long long &ans = dp[p][l][r][f];
	// 记忆化搜索
	if(ans) return ans;
	for(int i=0;i<2;i++)  // y
		for(int j=0;j<2;j++) // x
		{
			int nl = l,nr = r,nf = f;
			if(!nf && i && i!=j) continue;
			if((j&i)!=j) continue;
			if(!nl && j < a[p]) continue; // 如果值小于n了
			if(!nr && i > b[p]) continue; // 如果值大于m了
			if(j > a[p]) nl = 1;
			if(i < b[p]) nr = 1;
			if(j) nf = 1;

			ans += dfs(p-1,nl,nr,nf);
			ans %= mod;
		}
	return ans;
}
int main()
{
	// freopen("a.in","r",stdin);
	// freopen("k.out","w",stdout);
	scanf("%lld %lld",&n,&m);
	for(int i=0;i<=63;i++) a[i] = (n>>i)&1 , b[i] = (m>>i)&1;
	long long ans = dfs(63,0,0,0);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  
  public static void main(String args[]) {
    Scanner stdIn = new Scanner(System.in);
    int a = stdIn.nextInt();
    int b = stdIn.nextInt();
    int x = stdIn.nextInt();
    
    if (a <= x && x <= a+b) System.out.println("YES");
    else System.out.println("NO");
  }
}

Measured memory_bytes: 23252
<?php
fscanf(STDIN, "%s %s %s", $a, $b, $c);
if (substr($a, strlen($a)-1, 1) == substr($b, 0, 1) and substr($b, strlen($b)-1, 1) == substr($c, 0, 1)){
    print("YES\n");
} else {
    print("NO\n");
}
?>

Measured memory_bytes: 4728
#include<bits/stdc++.h>
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define F(i,n) for(int i=0;i<n;i++)
#define VE(i,v) for(int i = 0;i < (v).size();i++)
using namespace std;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned int ui;
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
typedef pair<ll,ll> pll;
typedef vector<pll> vpll; 
vl cnt(100002, -1LL); 
ll arr[100002];
int N,K;
ll calc(int x)
{
	if(cnt[x]==-1LL)
	{
		cnt[x] = LLONG_MAX;
		int i = 1;
		while((x+i <=N) && ( i <=K))
		{
			cnt[x] = min(abs(arr[x]-arr[x+i]) + calc(x+i), cnt[x]);
			i++;
		}
		
	}
	//cout<<x<<" "<<cnt[x]<<"\n";
	return cnt[x];
}
int main()
{
	//std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	int T=1;
	
	
	

	for(int tc = 0; tc < T; tc++)
	{
		cin >> N>>K;
		for(int i =1 ; i <= N; i++)
			cin >> arr[i];
		cnt[N] = 0;
		cout<<calc(1)<<"\n";
	}

 
 
 
	return 0;
}
 
 


Measured memory_bytes: 8064
#include <stdio.h>

int main(){
	int countTable[256] = {0};
	char ch;

	while((ch = getchar()) != EOF){
				countTable[ch]++;
	}
	for(int i = 97; i <=122;i++)printf("%c : %d\n",i,countTable[i]+countTable[i-32]);
}


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


int main(){
    string s;
    cin >>s;
    int ans=0;
    if(s[0]!=s[1]&&s[1]!=s[2]){
        if(s[2]!=s[3]){
            cout <<"Good";
            ans++;
        }
    }
    if(ans==0){
        cout << "Bad";
    }
    cout << endl;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main(string[] args)
        {
            var v = Scanner.scanint;
            var x = v[2];
            for(var i = 0; i < 10; i++)
            {
                x = v[0] * x - v[1];
                Console.WriteLine(x);
            }
        }
    }

    public class Scanner
    {
        public static string[] scan => Console.ReadLine().Split(' ');
        public static string[][] rescan(int n) => Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split(' ')).ToArray();
        public static int[] scanint => Array.ConvertAll(scan, int.Parse);
        public static long[] scanlong => Array.ConvertAll(scan, long.Parse);
    }

    public class Ex
    {
        public static int[] subarr(int[] arr, int begin, int n) { int[] a = new int[arr.Length]; Array.Copy(arr, begin, a, 0, n); return a; }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

bool cmp(string a,string b)
{
	int n=min(a.size(),b.size());
	rep(i,n)
	{
		if(a[i]!=b[i])
		{
			return a[i]<b[i];
		}
	}
	return a.size()<b.size();
}

int main()
{
	string s;
	cin >> s;
	if(s=="zyxwvutsrqponmlkjihgfedcba")
	{
		cout<<-1<<endl;
		return 0;
	}
	string alph = "abcdefghijklmnopqrstuvwxyz";
	if(s.size()==26)
	{
		char mi='z';
		for(int i=s.size()-1;i>=0;i--)
		{
			if(s[i-1]<s[i])
			{
				char minc='z';
				for(int j = i;j<s.size();j++)
				{
					//cout<<s[j]<<endl;
					if(s[j]>s[i-1])
					{
						minc=min(minc,s[j]);
					}
				}
				rep(j,i-1)cout<<s[j];
				cout<<minc<<endl;
				return 0;
			}	
		}
	}
	else
	{
		rep(i,s.size())
		{
			alph.erase(alph.begin()+alph.find(s[i]));
		}
		cout<<s<<alph[0]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

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

   vector<int> L(N);
   for(int i=0;i<N;++i) cin >> L[i];
   vector<int> D(N+1,0);

   for(int i=1;i<N+1;++i)
   {
      D[i] = D[i-1]+L[i-1];
      if(D[i]>X) {
         cout << i << endl;
         return 0;
      }
   }
   cout << N+1 << endl;
   return 0;
}


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

signed main(){
    string s;
    cin >> s;
    if(s == "RRR") cout << 3;
    if(s == "RRS" || s == "SRR") cout << 2;
    if (s == "RSR" || s == "RSS" || s == "SRS" || s == "SSR") cout << 1;
    if (s == "SSS") cout << 0;
    cout << endl;
    
}

Measured memory_bytes: 3596
#include<stdio.h>
int main(void){
        int n,i,x,f;
        scanf("%d",&n);
        int a[n];
        for(i=0;i<n;i++){
         scanf("%d",&a[i]);
        }
        for(i=n-1;i>0;i=i-1){
         printf("%d ",a[i]);
        }
        printf("%d\n",a[0]);

        
	return 0;
}


Measured memory_bytes: 2012
//#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#define MAX_INT 2100000000
using namespace std;
typedef long long int ll;
//#include "Header.h"
int main()
{
	int a, b, c, d, e, k, i, j;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a <= k) cout << "Yay!" << endl;
	else cout << ":(" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int k,m,n;
	cin>>k>>m>>n;
	int r=0;
	for(int i=m;i<=n;i++)
	{
		if(i%k==0)
		{
		r=1;
		break;
		}
	}
	if(r==1)
	cout<<"OK"<<endl;
	else
	cout<<"NG"<<endl;
}

Measured memory_bytes: 3132
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

signed main(){
	ll x, y;
	cin >> x >> y;
	if(abs(x-y) <= 1){
		cout << "Brown";
	}else{
		cout << "Alice";
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace whatever{
	int readu(){
		char ch=getchar();
		while(!isdigit(ch))
			ch=getchar();
		int value=ch-'0';
		ch=getchar();
		while(isdigit(ch)){
			value=value*10+ch-'0';
			ch=getchar();
		}
		return value;
	}
	void writeull(long long n){
		if(n<10)
			putchar(n+'0');
		else{
			writeull(n/10);
			putchar(n%10+'0');
		}
	}
	void run(){
		int n=readu();
		static int a[200001];
		for(int i=0; i<n; ++i)
			a[i]=readu();
		if(a[0]!=0){
			puts("-1");
			return;
		}
		for(int i=1; i<n; ++i)
			if(a[i]>a[i-1]+1){
				puts("-1");
				return;
			}
		long long result=0;
		for(int i=1; i<=n; ++i)
			if(a[i]!=a[i-1]+1)
				result+=a[i-1];
		writeull(result);
		putchar('\n');
	}
}
int main(){
	whatever::run();
}

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

using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    ll a[n];ll val=0;
    ll i;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        val^=a[i];
    }
    for(i=0;i<n;i++)
    {
        a[i]^=val;
        cout<<a[i]<<" ";
    }
    
    
   
   return 0;
}

Measured memory_bytes: 5068
N, W = map(int, input().split())
w = [0]*N
v = [0]*N
for i in range(N):
    w[i], v[i] = map(int, input().split())


dp = [[0]*(W+1) for _ in range(N+1)]
#dp[ i ][ sum_w ] : 
#i-1 番目までの品物から重さが sum_w 以下となるように選んだときの、
#価値の総和の最大値
for i in range(N):
    for j in range(W+1):
        if j - w[i] >= 0:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]] + v[i])
        
        dp[i+1][j] = max(dp[i][j], dp[i+1][j])

print(dp[N][W])


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

typedef long long ll;
const int INF = 1e9 + 7;
const ll LINF = 1LL<<61;

int n,k,s;

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

	cin >> n >> k >> s;
	if(s == 1e9){
		vector<int> ans(n,1);
		for(int i = 0; i < k; i++) ans[i] = s;
		for(auto i : ans) cout << i <<" ";
		cout << endl;
		return 0;
	}
	vector<int> ans(n,1e9);
	for(int i = 0; i < k; i++) ans[i] = s;
	for(auto i : ans) cout << i <<" ";
	cout << endl;
	return 0;
}

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

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int k = sc.nextInt();
      int sum = Math.min(a, k);
      k -= Math.min(a, k);
      if(k > 0) {
        k -= Math.min(b, k);
        if(k > 0)
          sum -= Math.min(c, k);
      }
      System.out.println(sum);
  }
}

Measured memory_bytes: 27004
boal_cup = 'A'
while line = $stdin.gets
	cups = line.chomp.split( /,/ )
	if cups[ 0 ] == boal_cup
		boal_cup = cups[ 1 ]
	elsif cups[ 1 ] == boal_cup
		boal_cup = cups[ 0 ]
	end
	#puts boal_cup
end
puts boal_cup


Measured memory_bytes: 6084
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 min = Math.min(a, b);

		System.out.print(min + " ");

		if(a + b - n > 0) {
			System.out.println(a + b - n);
		}else {
			System.out.println(0);
		}

	}
}


Measured memory_bytes: 22868
def change_apple_peach(sentence):
    sentence = sentence.replace('apple','aaa')
    sentence = sentence.replace('peach','apple')
    sentence = sentence.replace('aaa','peach')
    print(sentence)

def main():
    str = input()
    change_apple_peach(str)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5552
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

const long long INF=2000000000;

int main(){
  int v,e; cin >> v >> e;
  int adj[v][v];
  int s,t,d;
  for(int i=0;i<v;i++){
    for(int j=0;j<v;j++){
      if(i==j) adj[i][j]=0;
      else adj[i][j]=INF;
    }
  }
  for(int i=0;i<e;i++){
    scanf("%d %d %d",&s,&t,&d);
    adj[s][t]=d;
  }
  //warshallFloyd
  //A_k[i,j] represents the minimum cost from i to j via V_k{1,2,3,...,k}
  long long A[v][v];
  for(int i=0;i<v;i++){
    for(int j=0;j<v;j++){
      A[i][j]=adj[i][j];
    }
  }
  for(int k=0;k<v;k++){
    for(int i=0;i<v;i++){
      for(int j=0;j<v;j++){
        if(A[i][j]<A[i][k]+A[k][j]) A[i][j]=A[i][j];
        else{
          if(A[i][k]==INF || A[k][j]==INF) A[i][j]=INF;
          else A[i][j]=A[i][k]+A[k][j];
        }
      }
    }
  }
  bool flag=1;
  for(int i=0;i<v;i++){
    if(A[i][i]<0){
      cout << "NEGATIVE CYCLE" << endl;
      flag=0; break;
    }
  }
  if(flag){
    for(int i=0;i<v;i++){
      for(int j=0;j<v-1;j++){
        if(A[i][j]==INF) cout << "INF" << " ";
        else cout << A[i][j] << " ";
      }
      if(A[i][v-1]==INF) cout << "INF" << endl;
      else cout << A[i][v-1] << endl;
    }
  }
}

Measured memory_bytes: 3340
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll n;
	cin>>n;
	ll h[n];
	for(ll i=0;i<n;i++){
		cin>>h[i];
	}
	ll dp[n];
	dp[0]=0;
	dp[1]= abs(h[1]-h[0]);
	for(ll i=2;i<n;i++){
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]) , dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n-1];
	
	
	return 0;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
const static int tx[] = {0,1,0,-1};
const static int ty[] = {-1,0,1,0};

const static double EPS = 1e-8;

int main(){
  int num_of_players;
  map<string,int> dict;
  dict["Rock"] = 0;
  dict["Fire"] = 1;
  dict["Scissors"] = 2;
  dict["Snake"] = 3;
  dict["Human"] = 4;
  dict["Tree"] = 5;
  dict["Wolf"] = 6;
  dict["Sponge"] = 7;
  dict["Paper"] = 8;
  dict["Air"] = 9;
  dict["Water"] = 10;
  dict["Dragon"] = 11;
  dict["Devil"] = 12;
  dict["Lightning"] = 13;
  dict["Gun"] = 14;

  map<int,bool> canWin;
  for(int hand_i = 0; hand_i < 15; hand_i++){
    for(int hand_j = 0; hand_j < 15; hand_j++){
      canWin[hand_i * 15 + hand_j] = false;
      for(int offset = 1; offset <= 7; offset++){
        if(hand_j == (hand_i + offset) % 15){
          canWin[hand_i * 15 + hand_j] = true;
        }
      }
    }
  }

  while(~scanf("%d",&num_of_players)){
    if(num_of_players == 0){
      break;
    }
    vector<string> players;
    for(int player_i = 0; player_i < num_of_players; player_i++){
      string hand;
      cin >> hand;
      players.push_back(hand);
    }

    map<string,bool> lose;
    map<string,bool> win;

    set<string> hands;
    for(int player_i = 0; player_i < num_of_players; player_i++){
      hands.insert(players[player_i]);
    }
    for(set<string>::iterator ally_it = hands.begin(); ally_it != hands.end(); ally_it++){
      for(set<string>::iterator foe_it = hands.begin(); foe_it != hands.end(); foe_it++){
        if(canWin[dict[*ally_it] * 15 + dict[*foe_it]]){
          win[*ally_it] = true;
          lose[*foe_it] = true;
        }
      }
    }

    string res = "Draw";
    for(set<string>::iterator ally_it = hands.begin(); ally_it != hands.end(); ally_it++){
      if(win[*ally_it] && !lose[*ally_it]){
        res = *ally_it;
      }
    }
    printf("%s\n",res.c_str());
  }
}

Measured memory_bytes: 1304
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=0,z=0;
		char A = 'A';
		char Z = 'Z';
		String s = sc.next();
		char sa[] = s.toCharArray();
		for(int i=0;i<sa.length;i++) {
			if(sa[i]==A) {
				a=i;
				break;
			}
		}
		for(int i=sa.length-1;i>0;i--) {
			if(sa[i]==Z) {
				z=i;
				break;
			}
		}
		System.out.print(z-a+1);
		sc.close();
	}
}


Measured memory_bytes: 25988
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int X;
    cin >> X;
    
    for (long long A = -3000; A <= 3000; ++A) {
        long long left = -3000;
        long long right = 3000;
        while (right - left > 1) {
            long long mid = (left + right) / 2;
            if (A * A * A * A * A - mid * mid * mid * mid * mid < X) right = mid;
            else left = mid;
        }
        if (A * A * A * A * A - left * left * left * left * left == X) {
            cout << A << " " << left << endl;
            return 0;
        }
        if (A * A * A * A * A - right * right * right * right * right == X) {
            cout << A << " " << right << endl;
            return 0;
        }
    }
    return 0;
}


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

using namespace std;

#define MAX 100
#define INF (1<<29)

int main()
{
    int N, M, s, g1, g2;
    while (cin >> N >> M >> s >> g1 >> g2, N) {
        s--; g1--; g2--;
        int d[MAX][MAX];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                d[i][j] = INF;
            }
            d[i][i] = 0;
        }
        for (int i = 0; i < M; i++) {
            int a, b, c;
            cin >> a >> b >> c;
            a--; b--;
            d[a][b] = c;
        }

        for (int k = 0; k < N; k++) {
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }
        int res = INF;
        for (int i = 0; i < N; i++) {
            res = min(res, d[s][i] + d[i][g1] + d[i][g2]);
        }
        cout << res << endl;
    }
    return 0;
}

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


int main() {
    int N;
    cin >> N;
    vector<int> A(N);

    rep(i, N) cin >> A.at(i);

    map<int, int> M;
    rep(i, N){
        M[A.at(i)]++;
        if(M[A.at(i)] != 1){
            cout << "NO"<< endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int main(){
  char a;

  int ans = 0;
  REP (i, 6) {
    scanf("%c",&a);
    if (a == '1') ans++;
  }
  printf("%d\n",ans);
}


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

int main()
{
  string a,b,c;
  int n,m;
  cin>>a>>b>>n>>m>>c;
  if(c==a)
  return cout<<n-1<<' '<<m<<endl,0;
  else
  return cout<<n<<' '<<m-1<<endl,0;
}


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

int main() {

  int X,Y;
  cin >> X >> Y;

  if((X+Y) % 3 != 0 || 2*Y < X || Y > 2*X) {
    cout << 0 << endl;
    return 0;
  }

  int x = (X-2*Y) / (-3);
  int y = (X-x) / 2;

  vector<long long> fac(2000100,1),finv(2000100,1),inv(2000100,1);
  for(int i = 2;i < 2000100;i++) {
    fac.at(i) = fac.at(i-1) * i % MOD;
    inv.at(i) = MOD - inv.at(MOD % i) * (MOD/i) % MOD;
    finv.at(i) = finv.at(i-1) * inv.at(i) % MOD;
  }

  cout << fac.at(x+y) * (finv.at(x) * finv.at(y) % MOD) % MOD << endl;
}




Measured memory_bytes: 47232
import re
x = input()

answer = "NO"

if len(re.findall(".*keyence$", x)) > 0 :
    answer = "YES"

elif len(re.findall("^k.*eyence$", x)) > 0 :
    answer = "YES"

elif len(re.findall("^ke.*yence$", x)) > 0 :
    answer = "YES"

elif len(re.findall("^key.*ence$", x)) > 0 :
    answer = "YES"

elif len(re.findall("^keye.*nce$", x)) > 0 :
    answer = "YES"

elif len(re.findall("^keyen.*ce$", x)) > 0 :
    answer = "YES"

elif len(re.findall("^keyenc.*e$", x)) > 0 :
    answer = "YES"

elif len(re.findall("^keyence.*", x)) > 0 :
    answer = "YES"

print(answer)

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

int N, T;
int M[1005], L[1005], K[1005];
int used[1005], add[1005];

bool check(int x){
  
  memset(used,0,sizeof(used));
  memset(add,0,sizeof(add));
  
  for(int i=0;i<=T;i++){
    
    x+=add[i];
    
    for(int j=0;j<N;j++){
      
      if(x==0) break;
      
      if(used[j]) continue;
      
      int mod=L[j]+K[j];
      
      if((i%mod<=L[j])&&i+M[j]<=T){
	x--;
	add[i+M[j]]++;
	used[j]=1;
      }      
      
    }

  }
  
  int res=0;
  for(int i=0;i<N;i++) res+=used[i];
  
  return res==N;
}

void solve(){
  
  /*int l=0, r=1005;
  
  while(l<r){
    
    int m=(l+r)/2;
    
    if(!check(m)) l=m+1;
    else r=m;
    
    }*/
  
  //for(int i=0;i<=N;i++) cout<<check(i)<<' ';
  //  cout<<endl;
  //  cout<<l<<endl;

  for(int i=0;i<=1000;i++)
    if(check(i)){
      cout<<i<<endl;
      return;
    }
  
}

int main(){
  
  while(1){
    
    cin>>N>>T;
    if(!N&&!T) break;
    
    for(int i=0;i<N;i++) scanf("%d %d %d", &M[i], &L[i], &K[i]);
    
    solve();
    
  }
  
  return 0;
}

Measured memory_bytes: 3128
#include <iostream>

using namespace std;

int main( void )
{
	int n, m, p;
	int fd[100];
	while(cin >> n >> m >> p, n | m | p) {
		int sum = 0;
		for(int i=0; i < n; ++i) { cin >> fd[i]; sum += fd[i]; }
		if(!fd[m-1])
			cout << 0 << endl;
		else {
			cout << (((sum * 100) * (100 - p)) / 100) / fd[m-1] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine();
 
         Triangle tr = new Triangle(N);
         
        for(int i = 0; i < N; i++){
            tr.L[i] = sc.nextInt();   
        }
        
        System.out.println(tr.triangleTotal());
        
    }
}

class Triangle {
    
    int[] L;
    int N;
    
    public Triangle(int N){
        this.N = N;
        L = new int[N];
    }
    
    public int triangleTotal(){
        Arrays.sort(L);
        int triangleTotal = 0;
        
        for(int i = 0; i < N -2; i++){
            for(int j = i + 1; j < N - 1; j++){
                for(int k = j + 1; k < N; k++){
                    if(judgeTriangle(i, j, k)){
                        triangleTotal++;
                    }else{
                        break;
                    }  
                }

            }
        }
        return triangleTotal;
    }
    
    private boolean judgeTriangle(int a, int b, int c){
        return (L[c] < L[a] + L[b]) && (L[a] < L[b] + L[c]) && (L[b] < L[a] + L[c]);
    }
    
    
    
}


Measured memory_bytes: 27604
#include<bits/stdc++.h>
using namespace std;
const int ssize=55;
const int dr[]={-1,-1,-1,0,0,1,1,1};
const int dc[]={-1,0,1,-1,1,-1,0,1};
int h,w;
char m[ssize][ssize];
int count(int x,int y){
	int sum=0,r,c;
	for(int i=0;i<8;i++){
		r=x+dr[i];
		c=y+dc[i];
		if(r>=0&&r<h&&c>=0&&c<w&&m[r][c]=='#') sum++;
	}
	return sum;
}
int main(){
	cin>>h>>w;
	for(int i=0;i<h;i++){
		cin>>m[i];
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(m[i][j]=='.') m[i][j]='0'+count(i,j);
		}
	}
	for(int i=0;i<h;i++) cout<<m[i]<<endl;
	return 0;
} 

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

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,mx=0;
    string s;
    cin >> n;
    cin >> s;
    vector<vector<int> > v(n+1,vector<int> (n+1,0));
    for (int i=0;i<n;i++)
        for (int j=i+1;j<n;j++)
        {
            if(s[i]==s[j] && v[i][j]<j-i)
            {
                v[i+1][j+1]=v[i][j]+1;
                mx=max(mx,v[i+1][j+1]);
            }
            else
                v[i+1][j+1]=0;
        }
    cout << mx;
}


Measured memory_bytes: 98176
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 15;

int cs[1 << MAX_N];
int con[MAX_N][1 << MAX_N];
int dp[1 << MAX_N][MAX_N];
int d[MAX_N][MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    int sm = 0;
    rep(i,m){
        int a,b,c;
        cin >> a >> b >> c;
        sm += c;
        d[a-1][b-1] = d[b-1][a-1] = c;
    }
    rep(i,(1 << n)){
        rep(j,n){
            if(!(i >> j & 1)){
                int res = cs[i];
                rep(k,n){
                    if(i >> k & 1){
                        res += d[j][k];
                    }
                }
                cmx(cs[i^(1 << j)], res);
            }
        }
    }
    rep(i,n){
        rep(j,(1 << n)){
            if(j >> i & 1) continue;
            con[i][j] = cs[j];
            rep(k,n){
                if(j >> k & 1){
                    con[i][j] += d[i][k];
                }
            }
        }
    }
    for(int k=(((1 << n)-1)^1);;k=(k-1)&(((1 << n)-1)^1)){
        int st = (1 ^ k);
        rep(l,n){
            if(!(st >> l & 1) && d[0][l] != 0){
                cmx(dp[st^(1 << l)][l], con[0][k]+d[0][l]);
            }
        }
        if(k == 0) break;
    }
    srep(i,3,1 << n){
        rep(j,n){
            if(dp[i][j] == 0) continue;
            for(int k=(((1 << n)-1)^i);;k=(k-1)&(((1 << n)-1)^i)){
                int st = (i ^ k);
                rep(l,n){
                    if(!(st >> l & 1) && d[j][l] != 0){
                        cmx(dp[st^(1 << l)][l], dp[i][j]+con[j][k]+d[j][l]);
                    }
                }
                if(k == 0) break;
            }
        }
    }
    int ans = 0;
    rep(i,(1 << n)){
        if(dp[i][n-1] == 0) continue;
        cmx(ans, dp[i][n-1]+con[n-1][((1 << n) - 1)^i]);
    }
    cout << sm - ans << "\n";
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#include <vector>
#include <string.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
//#define INF 2e9
#define ALL(v) v.begin(), v.end()
 
using namespace std;
typedef long long ll;

int main(){
  int n;
  bool result=false;
  cin >> n;
  vector <vector <int>> D(n,vector<int>(2));
  rep(i,n){
    cin >> D[i][0] >> D[i][1];
  }
  rep(i,n-2){
    if(D[i][0]==D[i][1]&&D[i+1][0]==D[i+1][1]&&D[i+2][0]==D[i+2][1]){
      result = true;
    }
  }
  if(result) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3592
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()
}

fn main() {
    let n: usize = read();
    let a = read_vec::<i64>();
    let mut dp = vec![0; n];
    dp[1] = (a[1] - a[0]).abs();
    for i in 2..n {
        dp[i] = std::cmp::min(dp[i - 1] + (a[i] - a[i - 1]).abs(),
                              dp[i - 2] + (a[i] - a[i - 2]).abs())
    }
    println!("{:?}", dp[n - 1]);
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
    x += y;
    if( x >= m )
        x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
    x -= y;
    if( x < 0 )
        x += m;
}

int main() 
{
    fastio();

    int s,w;
    cin>>s>>w;

    if( w >= s )
        cout<<"unsafe";
    else
        cout<<"safe";    

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

const int maxn=1000+10;
int n;
int Ans;
char s[maxn][maxn];
ull base=97,p[maxn],H1[maxn][maxn],H2[maxn][maxn];

inline void file() {
	freopen("AGC023B.in","r",stdin);
	freopen("AGC023B.out","w",stdout);
}

inline ull Hash1(int k,int l,int r) {
	return H1[k][r]-H1[k][l-1]*p[r-l+1];
}

inline ull Hash2(int k,int l,int r) {
	return H2[k][r]-H2[k][l-1]*p[r-l+1];
}

int main() {
//	file();
	scanf("%d",&n);
	For (i,1,n) scanf("%s",s[i]+1);
	For (i,1,n) For (j,1,n) s[i][j+n]=s[i][j];
	For (j,1,(n<<1)) For (i,1,n) s[i+n][j]=s[i][j];
	p[0]=1;
	For (i,1,(n<<1)) p[i]=p[i-1]*base;
	For (i,1,(n<<1)) {
		H1[i][0]=1;
		For (j,1,(n<<1)) H1[i][j]=H1[i][j-1]*base+(s[i][j]-'a'+1);
	}
	For (j,1,(n<<1)) {
		H2[j][0]=1;
		For (i,1,(n<<1)) H2[j][i]=H2[j][i-1]*base+(s[i][j]-'a'+1);
	}
	For (i,1,n) For (j,1,n) {
		int flag=1;
		For (k,0,n-1) {
			if (Hash1(i+k,j+k,j+n-1)!=Hash2(j+k,i+k,i+n-1)) {
				flag=0; break;
			}
		}
		if (flag) ++Ans;
	}
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 16768