akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

void dfs(vector<vector<int>>& g, unordered_set<int>& visited, int v)
{
    visited.insert(v);
    for(auto& next_v:g[v])
    {
        if(visited.count(next_v) > 0) continue;
        dfs(g, visited, next_v);
    }
}

int main()
{    
    int h,w;
    cin >> h >> w;
    int s[h][w];
    rep(i,h)
    {
        string t;
        cin >> t;
        rep(j,w)
        {
            if(t.substr(j,1)==".")
                s[i][j] = 0;
            else
                s[i][j] = 1;
        }
    }

    rep(i,h)
        rep(j,w)
        {
            if(s[i][j]==0) continue;

            bool has_nbr_black = false;
            if(i-1>=0)  has_nbr_black |= (s[i-1][j]==1);
            if(i+1< h)  has_nbr_black |= (s[i+1][j]==1);
            if(j-1>=0)  has_nbr_black |= (s[i][j-1]==1);
            if(j+1< w)  has_nbr_black |= (s[i][j+1]==1);
            if(!has_nbr_black)
            {
                cout << "No" << endl;
                return 0;
            }
        }
    cout << "Yes" << endl;
    return 0;
}

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

int main()
{
	   int a, b;
	   
	   cin >> a >> b;
	   
	   int empty = 1, ans = 0;
	   
	   while(empty < b){
				    ans++;
				    empty--;
				    empty += a;
				}
				
				cout << ans << "\n";
	   
    return 0;
}


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

using namespace std;

struct Task
{
  uint64_t A, B;
  Task(uint64_t A = 0, uint64_t B = 0) : A(A), B(B) {}
  
  bool operator<(const Task &rhs) const {
    return B == rhs.B ? A > rhs.A : B < rhs.B;
  }
};

istream& operator>>(istream &is, Task &task)
{
  is >> task.A >> task.B;
  return is;
}

int main()
{
  uint64_t N;
  cin >> N;
  
  vector<Task> tasks(N);
  for (uint64_t n = 0; n < N; ++n) {
    cin >> tasks[n];
  }
  
  sort(tasks.begin(), tasks.end());
  
  bool flag = true;
  uint64_t T = 0;
  for (const Task &task : tasks) {
    if (T > task.B) { flag = false; break; }
    
    T += task.A;
    
    if (T > task.B) { flag = false; break; }
  }
  cout << (flag ? "Yes" : "No") << endl;
  
  return 0;
}

Measured memory_bytes: 3328
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
import math
from collections import deque, defaultdict
import heapq
INF = float("inf")


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.E = defaultdict(list)
        pass

    def add_edge(self, from_, to_, weight=1):
        self.E[from_].append((to_, weight))
        self.E[to_].append((from_, weight))


INF = float("inf")


def solve(N: int, u: int, v: int, A: "List[int]", B: "List[int]"):
    g = Graph(N)
    for a, b in zip(A, B):
        g.add_edge(a-1, b-1)

    ddhouse = [0]*N

    def dfs(f_, pre, dep):
        ddhouse[f_] = dep

        for t_, w in g.E[f_]:
            if t_ == pre:
                continue
            dfs(t_, f_, dep+1)
        return

    dfs(v-1, -1, 0)

    ffhouse = [0]*N

    def dfs(f_, pre, dep):
        ffhouse[f_] = dep

        for t_, w in g.E[f_]:
            if t_ == pre:
                continue
            dfs(t_, f_, dep+1)
        return

    dfs(u-1, -1, 0)
    m = 0
    for d, f in zip(ddhouse, ffhouse):
        if f >= d:
            continue
        else:
            m = max(d, m)
    print(max(m-1, 0))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    u = int(next(tokens))  # type: int
    v = int(next(tokens))  # type: int
    A = [int()] * (N - 1)  # type: "List[int]"
    B = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, u, v, A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 142076
K, X = gets.split(' ').map(&:to_i)
row = X - (K - 1)
high = X + (K - 1)
r = []
if row < -1000000
	row = -1000000
elsif high > 1000000
	high = 1000000
end
for i in row..high
	r << i
end
for s in r
	print "#{s} "
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
    #define ll long long
    #define f   first
    #define s   second
    #define pb          push_back
    #define mod         1000000007
    #define hell        998244353
    #define inf         1000000000000000000LL
    using namespace std;
    ll n,k,m,l,mx,sum,q;
    //ll dp[15][1005]
    ll c[11];
    vector<ll> v;
    bool dfs(ll x,ll y,ll k1)
    {
        if(k1>m) return 1;
        bool f=0;
        for(int i=1;i<=10;i++)
        {
            if(c[i] && x>=0 && i!=y && x-i<0)
                f=dfs(x-i,i,k1+1);
            else if(c[i] && x<0 && i!=y && x+i>0)
                f=dfs(x+i,i,k1+1);
            if(f) {v.pb(i);return 1;}
        }
        return 0;   
    }
    void solve()
    {   ll a,b,x,y;
        cin>>n>>m;
        if(m>=n) cout<<"unsafe\n";
        else cout<<"safe\n";
        
    }    
    int main()
    {  
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
        //cout<<primes.size();
        
        ll t=1;
        //cin>>t;
        while(t--)
            solve();

    }


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

int main() {
	int n;
	int length[3];
	int temp;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> length[0] >> length[1] >> length[2];
		if(length[0] <= length[1]){
			temp = length[0];
			length[0] = length[1];
			length[1] = temp;
		}
		if(length[0] <= length[2]){
			temp = length[0];
			length[0] = length[2];
			length[2] = temp;
		}
		if(length[0]*length[0] == length[1]*length[1] + length[2]*length[2]){
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int x, n;
	cin >> x >> n;
	vector<int> p(n);
	map<int,int> m;
	for(int i = 0; i < n; i++) {
		cin >> p[i];
		m[abs(x-p[i])]++;
	}
	if(m[0] == 0) {
		cout << x << endl;
		return 0;
	}
	for(int i = 1; i <= 100; i++) {
		if(m[i] < 2) {
			if(count(all(p), x-i) == 0)
				cout << x-i << endl;
			else cout << x+i << endl;
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 3576
import numpy as np
h, w = map(int,input().split())
way = []
for i in range(h):
    s = input()
    for j in range(w):
        if s[j] == "#":
            way.append([i,j])

for i in range(len(way)-1):
    if (way[i+1][0]-way[i][0])+(way[i+1][1]-way[i][1]) == 1 and (way[i+1][0]-way[i][0])*(way[i+1][1]-way[i][1]) == 0:
        continue
    else:
        print("Impossible")
        exit()

print("Possible")


Measured memory_bytes: 12424
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    
    dp=[0]*(100000+5)
    for n in range(1,100001):
        dp[n]=100000
        power=1
        while power<=n:
            dp[n]=min(dp[n],dp[n-power]+1)
            power*=6
        power=1
        while power<=n:
            dp[n]=min(dp[n],dp[n-power]+1)
            power*=9

    print(dp[N])
if __name__=="__main__":
    main()

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

int main()
{
    int n;
    std::cin >> n;
    std::vector<std::vector<std::pair<int,int>>> hen(n);
    std::vector<int> col(n,-1);
    for(int i = 0; i < n-1; i++){
        int u,v,w;
        std::cin >> u >> v >> w;
        u--; v--;
        hen[u].push_back({v,w});
        hen[v].push_back({u,w});
    }
    //便宜的に頂点0を親とする
    col[0] = 0;
    std::queue<int> que;
    que.push(0);
    while(que.size()){
        auto cur = que.front();
        que.pop();
        for(auto i : hen[cur]){
            if(col[i.first] != -1)continue; //彩色済み
            que.push(i.first);
            if(i.second & 1)col[i.first] = !col[cur];
            else col[i.first] = col[cur];
        }
    }
    for(int i = 0; i < n; i++)std::cout << col[i] << std::endl;
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int a=0,b=0;
  for (int i=0;i<3;i++)
  {
    if (s[i]=='A')
      a=1;
    else
      b=1;
  }
  if (a and b)
    cout<<"Yes\n";
  else
    cout<<"No\n";
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;

int x[105];
int y[105];
int main(){
	int n, m;
	cin >> n >> m;
	int X, Y;
	cin >> X >> Y;
	int cnt1 = 0;
	int cnt2 = 0;
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		cin >> x[i];	
	}
	for(int i = 1; i <= m; i++){
		cin >> y[i];
	}
	for(int i = X + 1; i <= Y; i++){
		cnt1 = 0;
		cnt2 = 0;
		for(int j = 1; j <= n; j++){
			if(x[j] < i) cnt1++;
		}
		for(int k = 1; k <= m; k++){
			if(y[k] >= i) cnt2++;	
		}
		if(cnt1 == n && cnt2 == m){
			printf("No War\n");
			return 0;
		}
		cnt++;
	}
	if(cnt == (Y - X)) printf("War\n");
	return 0;
}

Measured memory_bytes: 256
from collections import deque
import heapq
N=int(input())
numbers=[[] for _ in range(N)]
for _ in range(N-1):
    a,b,c=map(int,input().split())
    a-=1
    b-=1
    numbers[a].append((b,c))
    numbers[b].append((a,c))
Q,K=map(int,input().split())
K-=1
keika=[]
for _ in range(Q):
    x,y=map(int,input().split())
    keika.append([x-1,y-1])
inf=pow(10,10)
visited=[inf for _ in range(N)]
visited[K]=0
stack=[K]
heapq.heapify(stack)
while len(stack)>0:
    n=heapq.heappop(stack)
    for s,t in numbers[n]:
        if visited[s]==inf:
            heapq.heappush(stack,s)
            visited[s]=visited[n]+t
for z in keika:
    print(visited[z[0]]+visited[z[1]])


Measured memory_bytes: 61812
#include<iostream>
#include<vector>
#include<climits>
using namespace std;

using ll=long long;
//space complexity O(N), where N is the number of trees
//time complexity O(N*K)
long long minCost(const int num, const int k, const vector<int>& heights) {
    vector<ll> dp(num, LLONG_MAX);
    dp[0] = 0;
    for (int i = 1; i < num; ++ i) {
        for (int j = 1; i-j>=0 && j <= k; ++j) {
            dp[i] = min (dp[i], dp[i-j]+abs(heights[i-j] - heights[i]));
        }
    }
    return dp[num-1];
}

int main(){
    int num, k;
    cin>>num>>k;
    vector<int> heights (num);
    for (auto& e : heights) {
        cin>>e;
    }
    cout<<minCost(num, k, heights);
    return 0;
}


Measured memory_bytes: 1408
N = int(input())
dic = {}
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
max_val = max(dic.values())
rst = [ key for key, val in dic.items() if val == max_val ]
[ print(i) for i in sorted(rst) ]

Measured memory_bytes: 36424
#include <stdio.h>
#include <math.h>

int main(void) {
	int n,i;
	double X,Y;
	double A1,A2,B1,B2,C1,C2;
	double X1,X2,X3,Y1,Y2,Y3;
	double r;
	
	scanf("%d\n", &n);
	
	for(i=0;i<n;i++) {
		scanf("%lf %lf %lf %lf %lf %lf\n", &X1, &Y1, &X2, &Y2, &X3, &Y3);
		
		A1 = 2*(X2-X1);
		B1 = 2*(Y2-Y1);
		C1 = X1*X1-X2*X2+Y1*Y1-Y2*Y2;
		A2 = 2*(X3-X1);
		B2 = 2*(Y3-Y1);
		C2 = X1*X1-X3*X3+Y1*Y1-Y3*Y3;
		
		X = (B1*C2-B2*C1)/(A1*B2-A2*B1);
		Y = (C1*A2-C2*A1)/(A1*B2-A2*B1);
		r = sqrt((X-X1)*(X-X1)+(Y-Y1)*(Y-Y1));
		
		printf("%.3lf %.3lf %.3lf\n", X, Y, r);
	}
	return 0;
}

Measured memory_bytes: 668
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
count = -1
ans = 0

n.times do |i|
  ans += b[a[i]-1]
  if count + 1 == a[i]
    ans += c[a[i-1]-1]
  end
  count = a[i]
end

puts ans

Measured memory_bytes: 1788
n = int(input())
a_list = list(map(int, input().split()))
a_dict = {a: 0 for a in range(1, n + 1)}
for a in a_list:
    a_dict[a] += 1
base_ans = 0
for m in a_dict.values():
    base_ans += m * (m - 1) // 2
for a in a_list:
    m = a_dict[a]
    ans = base_ans - m + 1
    print(ans)


Measured memory_bytes: 38524
#!/usr/bin/env python
# coding: utf-8

import sys

def get_answer(param):
    param = list(param)
    param.sort()
    small = int("".join(param), 10)
    big = int("".join(param[::-1]), 10)
    return big - small
    
def main():
    params = [line.replace("\n", "") for line in sys.stdin.readlines()]
    params.pop(0)

    for param in params:
        print get_answer(param)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7256
#include<cstdio>
#include<map>
#define LL long long
using namespace std;
const int mod=1e9+7;
map<long long,long long>f;
LL dp(LL n)
{
    if(f[n]) return f[n];
    return f[n]=(dp(n/2)+dp((n-1)/2)+dp((n-2)/2))%mod;
}
int main()
{
    LL n;
    f[0]=1;
    f[1]=2;
    scanf("%lld",&n);
    printf("%lld",dp(n));
}


Measured memory_bytes: 256
a,b,c,x,y = map(int,input().split())

ans = 10**9
for i in range(max(x,y)+1):
    cnt = 2*c*i
    if x > i:
        cnt += a*(x-i)
    if y >i:
        cnt += b*(y-i)
    ans = min(ans,cnt)

print(ans)

Measured memory_bytes: 39280
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a, b, c, x;
    scanf("%d %d %d", &a, &b, &c);
    if(a > b){
        x = a;
        a = b;
        b = x;
    }
    if(b > c){
        x = b;
        b = c;
        c = x;
    }
    if(a > b){
        x = a;
        a = b;
        b = x;
    }
    printf("%d %d %d\n", a, b, c);
    return 0;
}



Measured memory_bytes: 2040
import java.util.*;
import java.util.Scanner;

class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        String[] strs = new String[N];
        // char[][] seq = new char[N][];
        // ArrayList<String> arr = new ArrayList<String>
        sc.nextLine();
        for (int i = 0; i < N; i++) {
            strs[i] = sc.nextLine();
            char[] seq = strs[i].toCharArray();

            Arrays.sort(seq);
            strs[i] = new String(seq);
            // System.out.println(seq[i]);
        }
        Arrays.sort(strs);
        // combinationInit();
        long ans = 0;
        int lif = 0;
        // int[][] pkr = new int[N][27];
        for (int i = 1; i < N; i++) {
            if (strs[i].equals(strs[i - 1])) {
                // System.out.println(strs[i]);
                lif++;
            } else if (lif > 0) {
                ans += combination(lif + 1, 2);
                lif = 0;
            }
        }
        if (lif > 0) {
            ans += combination(lif + 1, 2);
            lif = 0;
        }

        System.out.println(ans);

    }

    static private long combination(long num1, long num2) {
        if (num2 == 0) {
            return 1;
        }
        return (num1 - num2 + 1) * combination(num1, num2 - 1) / num2;
    }
}

Measured memory_bytes: 99428
#include <stdio.h>


int main() {
  int x, y, z, gcd;

  scanf("%d%d", &x, &y);

  if (x < y) {
    z = y;
    y = x;
    x = z;
  }

  while(1) {
    z = x % y;
    if (z == 0) {
      printf("%d\n", y);
      break;
    }
    x = y;
    y = z;

  }

  return 0;
}



Measured memory_bytes: 2144
fun main(arr: Array<String>) {
    val n = readLine()!!.toInt()
    val t = readLine()!!.split(" ").map { it.toInt() }
    val m = readLine()!!.toInt()
    val drink = (1..m).map { readLine()!!.split(" ").map { it.toInt() } }
    val totalTime = t.sum()
    val ans = drink.map { totalTime - t[it[0]-1] + it[1] }
    ans.forEach { println(it) }
}

Measured memory_bytes: 38004
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define double long double
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
#define P pair<int,int>
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool integer(double n){
	if(n==long(n))return true;
	else return false;	
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}
int sankaku(int a){
	return a*(a+1)/2;
} 
bool search(int x){
	int n;
	int a[n];
	int l=0,r=n;
	while(r-l>=1){
		int i=(l+r)/2;
		if(a[i]==x)return true;
		else if(a[i]<x)l=i+1;
		else r=i;
	}
	return false;
}
int a[114514];
signed main(){
	ic(n) ic(m)
	int sum=0;
	rep(0,i,n){
		cin>>a[i];
		sum+=a[i];
	}	
	sort(a,a+n);
	reverse(a,a+n);
	rep(0,i,m){
		if(a[i]*4*m<sum){
			c("No")
			return 0;
		}
	}
	c("Yes")	
}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
string a[4]={"dream","dreamer","erase","eraser"};
int main(){
    string S;
    cin>>S;
    int n=SZ(S);
    bool suc=1;
    while(suc){
        suc=0;
        REP(i,4){
            if(S.substr(max(0,n-SZ(a[i])),n-max(0,n-SZ(a[i])))==a[i]){
                n-=SZ(a[i]);
                suc=1;
            }
        }
    }
    puts(n?"NO":"YES");
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fit(x) for(auto it=x.begin();it!=x.end();++it)
#define se second
#define mp make_pair
#define ALP "abcdefghijklmnopqrstuvwxyz"
#define nline cout<<"\n"
#define rep(i,x) for(i=0;i<x;++i)
#define repr(i,a,b) for(i=a;i<=b;++i)
#define mi2 500000004
#define mi3 333333336
#define MOD 1000000007
#define N 1000005
#define pll pair<ll,ll>
#define Vll vector<ll>
#define W(t) while(t--)
#define modsum(a,b,M) (a%M + b%M)%M
#define modsub(a,b,M) (a%M - b%M + M)%M
#define modmul(a,b,M) (a%M * b%M)%M
#define moddiv(a,b,M) (a%M * modinv(b,M)%M)%M
using namespace std;
ll powermod(ll x,ll n,ll M)
{
	ll result=1;
	while(n>0)
	{
	  if(n % 2 ==1)
	    result=(result * x)%M;
	  x=(x*x)%M;
	  n=n/2;
	}
	return result;
}
vector<ll> readll() {
	cin>>ws;
	vector<ll> v;
	string input;
	getline(cin, input);
	cout<<input;
	istringstream is(input);
	ll num;
	while(is>>num) v.pb(num);
	return v;
}
ll modinv(ll n,ll p) {
	return powermod(n,p-2,p);
}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll fact[1000005],invf[1000005];
void facmod(ll n,ll M) {
	ll i;
	fact[0]=fact[1]=1;
	for(i=2;i<=n;++i) {
		fact[i]=((fact[i-1])%M * (i%M))%M;
	}
	invf[n]=modinv(fact[n],M);
	for (i=n-1;i>=0;--i){
		invf[i]=invf[i+1]*(i+1);
		invf[i]%=M;
	}
}
/*****
ll T=0;
ll p[200005], d[200005];
ll tin[200005], tout[200005];
vector<ll> g[200005];

void dfs(ll v, ll par = 1, ll dep = 0) {
	p[v] = par;
	d[v] = dep;
	tin[v] = T++;
	for (auto to : g[v]) {
		if (to == par) continue;
		dfs(to, v, dep + 1);
	}
	tout[v] = T++;
}
****/
void solve() {
	ll n,i,a,b;
	cin>>a>>b;
	rep(i,1001) {
		if(floor(i*0.08)==a && floor(i*0.1)==b) {
			cout<<i;
			return;
		}
	}
	cout<<"-1";
}
int main() {
  	fastio;
	ll t=1;
	//cin>>t;
	W(t) {
		solve();
	}
	
  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL               long long
#define PB               push_back
using namespace std;
int main(){
  int l,R,c=0; cin >>l>>R;
  int d; cin>>d;
  for (int i=l;i<=R;i++){
    if (!(i%d)) c++;
  }
  cout<< c<<endl;
}

Measured memory_bytes: 3620
/*Shivam Bhalla */
  /* f2016941@pilani.bits-pilani.ac.in */



  #include <iostream>
  #include <cstdio>
  #include <cstring>
  #include <cstdlib>
  #include <cctype>
  #include <algorithm>
  #include <map>
  #include <vector>
  #include <list>
  #include <set>
  #include <queue>
  #include <deque>
  #include <stack>
  #include <iostream>
  #include <string>
  #include <cmath>
  #include <cassert>
  #include <bits/stdc++.h>
  #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
  using namespace std;
  long long maxv = 1e9;


  int main()
  {
    fast_cin();
    int A,B;
    cin>>A>>B;
    int K;
    cin>>K;
    vector<int>divisors;
    for(int i=1;i<=100;i++){
      if(A%i==0 && B%i==0){
        divisors.push_back(i);
      }
    }
    cout<<divisors[divisors.size()-K];
    return 0;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define int long long int
int32_t main() {
    int n ;
    cin >> n ;
    int a[n];
    for(int i = 0 ; i <n ; i++){
        cin >> a[i]  ;
    }
    int dp[n][n];
    for(int len = 0 ; len <n ; len++){
        for(int start = 0 ; start < n -len ; start++){
            int end = start + len; 
            int t1 = (start+2 <= end)?dp[start+2][end]:0 ;
            int t2 = (start+1<= end-1)?dp[start+1][end-1]:0 ;
            int t3 = (start<=end-2)?dp[start][end-2]:0;
            dp[start][end] = max(a[start]+min(t1,t2),a[end]+min(t2,t3)) ;
        }
    }
    int total = 0;
    for(int i = 0 ; i <n ; i++){
        total = total + a[i];
    }
    cout << (2*dp[0][n-1] - total) << endl ;
    return 0;
}

Measured memory_bytes: 70400
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 200005
using namespace std;

int n, a[N], t[N];
int main()
{
	int i;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		t[i] = a[i];
	}
	sort(t, t + n);
	for (i = 0; i < n; i++) {
		if (a[i] < t[n / 2]) printf("%d ", t[n / 2]);
		else printf("%d ", t[n / 2 - 1]);
	}
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
map<int, pair<int, int> > info;int used[4][4];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int arr[3][3];
	for(int i = 1;i <= 3;i++)for(int j = 1;j <= 3;j++)cin >> arr[i][j],info[arr[i][j]] = make_pair(i, j);
	int n;cin >> n;
	for(int i = 1;i <= n;i++){
		int a;
		cin >> a;
		used[info[a].first][info[a].second] = 1;
	}
	for(int i = 1;i <= 3;i++){
		int s1 = 0;
		for(int j = 1;j <= 3;j++){
			s1 += used[i][j];
		}
		int s2 = 0;
		for(int j = 1;j <= 3;j++){
			s2 += used[j][i];
		}
		if(s1 == 3 || s2 == 3)cout << "Yes",exit(0);
	}
	if(used[1][1] + used[2][2] + used[3][3] == 3)cout << "Yes",exit(0);
	if(used[3][1] + used[2][2] + used[1][3] == 3)cout << "Yes",exit(0);
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
using namespace std;

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

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

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

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

string s;
int k;

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

  cin >> s >> k;
  REP(i, k) {
    if(s[i] != '1') {
      cout << s[i] << endl;
      return 0;
    }
  }
  cout << '1' << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
	int N;
	int a,b,c;
	int i;
	
	scanf("%d",&N);
	
	for(i = 0;i < N;i++){
		scanf("%d %d %d",&a,&b,&c);
		if(pow(a,2)+pow(b,2) == pow(c,2)||pow(b,2)+pow(c,2) == pow(a,2)||pow(c,2)+pow(a,2) == pow(b,2)){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  string s;
  cin >> s;
  for(int i = 0; i < s.length(); ++i)
  {
    cout << s[i];
    ++i;
  }
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, n) { cin >> l[i]; }
  sort(l.begin(), l.end());
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int temp = l[i] + l[j];
      int num = lower_bound(l.begin(), l.end(), temp) - l.begin();
      ans += num - j - 1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll a[N];
    ll ans = 0;
    REP(i, 0, N) {
        cin >> a[i];
        if (i % 2 == 0 && a[i] % 2 == 1) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

int dp[10][10];

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

    int h, w;
    cin >> h >> w;

    rep(i, 10) rep(j, 10) {
        cin >> dp[i][j];
    }

    rep(k, 10) rep(i, 10) rep(j, 10)
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
    
    int ans = 0;
    rep(i, h*w) {
        int a;
        cin >> a;
        if (0 <= a) {
            ans += dp[a][1];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
m, a, r, c, h = [0] * 5

N = int(input())

for _ in range(N):
    s = input()[0]

    if s == 'M':
        m += 1
    elif s == 'A':
        a += 1
    elif s == 'R':
        r += 1
    elif s == 'C':
        c += 1
    elif s == 'H':
        h += 1
print(m * a * r + 
      m * a * c +
      m * a * h + 
      m * r * c + 
      m * r * h + 
      m * c * h + 
      a * r * c + 
      a * r * h +
      a * c * h +
      r * c * h)


Measured memory_bytes: 3060
import os
import sys
from collections import deque

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

# 解説AC
N, K = list(map(int, sys.stdin.readline().split()))
if 2 * K > N + 1:
    print(-1)
    exit()

ab = []
ai = 0
bi = N - 1
for _ in range(N):
    a = K + ai
    b = K + N + bi
    ab.append((a + b, a, b))
    ai = (ai + 2) % N
    bi = (bi - 1) % N
    if ai == 0:
        # もう選んだ
        ai += 1

ab.sort()
for c, (_, a, b) in zip(range(K + 2*N, K + 3*N), ab):
    print(a, b, c)


Measured memory_bytes: 23020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define len(array) (sizeof(array) / sizeof(array[0]))

int main() {
  string s,t;cin>>s>>t;
  sort(s.begin(), s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(), t.end());
  if (s<t) cout<<"Yes";
  else cout <<"No";
}


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

int main() {
	int n;
	cin >> n;
	int current = 1;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a == current) {
			current++;
		}
	}
	if (current == 1) {
		cout << "-1\n";
		return 0;
	}
	cout << n - (current - 1) << '\n';
	return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int k, s;
  scanf("%d %d", &k, &s);

  long int ans = 0;

  for(int x = 0; x <= (s < k ? s : k); x++){
    if(s - x > k && s - x <= 2 * k){
      ans += (long)(2 * k) + (long)x - (long)s + 1;
    }
    else if(s - x <= k){
      ans += (long)s - (long)x + 1;
    }
  }

  printf("%ld\n", ans);

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
const int N=3010;
const int yql=1e9+7;
using namespace std;
int a[N],dp[N][N],n,m,s[N];
char p[N];
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
int main(){
	n=read();m=read();
	scanf("%s",p+1);
	for(int i=1;i<=n;i++){a[i]=i;s[i]=s[i-1];if(p[i]=='1')s[i]++;}
	//for(int i=1;i<=n;i++)printf("%d%c",s[i],i==n?'\n':' ');
	for(int i=1;i<=m;i++){
		int l=read(),r=read();
		for(int j=l;j<=r;j++)a[j]=max(a[j],r);
	}
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(j>s[a[i]])continue;
			if(i-j>a[i]-s[a[i]])continue;
			dp[i][j]=dp[i-1][j];
			if(j)dp[i][j]=(dp[i][j]+dp[i-1][j-1])%yql;
		}
	}
	printf("%d\n",dp[n][s[n]]);
}

Measured memory_bytes: 33920
D = int(input())
C = [int(T) for T in input().split()]
S = [[] for TD in range(0,D)]
for TD in range(0,D):
    S[TD] = [int(T) for T in input().split()]
Type = 26
Last = [0]*Type
SatD = [0]*D
SatA = [0]*(D+1)
for TD in range(0,D):
    Test = int(input())-1
    Last[Test] = TD+1
    SatD[TD] = S[TD][Test]
    for TC in range(0,Type):
        SatD[TD] -= C[TC]*(TD+1-Last[TC])
    SatA[TD+1] = SatA[TD]+SatD[TD]
print('\n'.join(str(T) for T in SatA[1:]))

Measured memory_bytes: 9452
//´íÁË 
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;

ll time=0;
struct node
{
	ll dis;
	ll end;
	ll cha;
}num[200005];

bool cmp(node a,node b)
{
	if(a.cha!=b.cha)
	return a.cha<b.cha;
	else
	return a.end<b.end;
}

bool cmp2(node a,node b)
{
	if(a.end!=b.end)
	return a.end<b.end;
	else
	return a.dis>b.dis;
}

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%lld %lld",&num[i].dis,&num[i].end);
		num[i].cha=num[i].end-num[i].dis;
	}
	
	//sort(num,num+n,cmp);
	sort(num,num+n,cmp2);
/*	printf("-------------------\n");
	for(int i=0;i<n;i++)
	{
		printf("%lld %lld %lld\n",num[i].dis,num[i].end,num[i].cha);
	}
	*/
	for(int i=0;i<n;i++)
	{
		time+=num[i].dis;
		if(time>num[i].end)
		{
			printf("No");
			//printf("end of %lld %lld %lld\n",num[i].dis,num[i].end,num[i].cha);
			return 0;
		}
		
		
		
	}
	printf("Yes");
	
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 1000100100
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vii;
typedef vector<ll> vll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, T;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> T;
    vii c(n), t(n);
    rep(i, 0, n) cin >> c[i] >> t[i];
    int ans = INF;
    rep(i, 0, n) {
      if (t[i] <= T) {
        ans = min(ans, c[i]);
      }
    }
    if (ans == INF) cout << "TLE" << endl;
    else cout << ans << endl;
    return 0;
}




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

using namespace std;

int main(){
  int N,K;
  int p[1000];
  int sum = 0;
  cin >> N >> K;
  for(int i = 0;i < N;i++){
    cin >> p[i];
  }
  sort(p,p+N);
  for(int i = 0;i < K;i++){
    sum += p[i];
  }
  cout << sum << endl;
  return 0;
}

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

int main() {
    int cnt=0, count=0, a,b;
    string s;
    cin >> s;
    vector<int> ans(s.size(),0);

    for(int i=0; i<s.size(); i++) {
        if(s.at(i)=='R' && s.at(i+1)=='L') {
            ans[i]++;
            ans[i+1]++;
            for(int j=i+2; j<s.size(); j++) {
                if(s.at(j)=='L') {
                    if((j-i)%2==0) ans[i]++;
                    else ans[i+1]++;
                }
                else break;
            }
            for(int j=i-1; j>=0; j--) {
                if(s.at(j)=='R') {
                    if((i-j)%2==0) ans[i]++;
                    else ans[i+1]++;
                }
                else break;
            }
        }
    }
    for(int i=0; i<s.size(); i++) {
        cout << ans[i] << " ";
    }
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int n,i=1,a[5],count1=0,count2=0;
    scanf("%d",&n);
    while(n!=0)
    {
        a[i++]=(n%10);
        n=n/10;
    }
    for(i=1; i<=2; i++)
    {
        if(a[i]==a[i+1])
            count1++;
    }
    for(i=2; i<=3; i++)
    {
        if(a[i]==a[i+1])
            count2++;
    }

    if(count1==2||count2==2)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
    vector<vector<int> > c(3,vector<int>(3));
    REP(i,3) REP(j,3) cin>>c[i][j];

    bool f=0;
    REP2(a1,-1000,1000){
        int a2,a3,b1,b2,b3;
        b1=c[0][0]-a1;b2=c[0][1]-a1;b3=c[0][2]-a1;
        a2=c[1][0]-b1;
        if(a2!=c[1][1]-b2 || a2!=c[1][2]-b3) continue;
        a3=c[2][0]-b1;
        if(a3!=c[2][1]-b2 || a3!=c[2][2]-b3) continue;
        f=1;
        break;
    }
    cout<<(f? "Yes":"No")<<endl;

	return 0; 
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define N 1000001

int arrr1[N+5],arrr2[N+5];
int main()
{
    int n,m,a,b;

    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        cin>>a>>b;
        if(a==1)
            arrr1[b]=1;//第一次的终点
        if(b==n)
            arrr2[a]=1;//第二次的起点
    }

    int p=0;
    for(int i=1; i<=m; i++)
    {
        if(arrr1[i]&&arrr2[i])
        {
            cout<<"POSSIBLE"<<endl;
            p=1;
        }
    }

    if(p==0)
        cout<<"IMPOSSIBLE"<<endl;

    return 0;
}



Measured memory_bytes: 5120
#include <iostream>
#include<bits/stdc++.h>
#include<queue>

using namespace std;

int vis[100005];
//int a[20005]={0};
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        vis[a]++;
        vis[b]++;
    }
    int flag=0;
    for(int i=1;i<=n;i++)
    {
        if(vis[i]&1)
            flag=1;
    }
    if(flag)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	string s; cin>>s;
	int n=s.size();
	bool ok=true;
	rep(i,0,n-1){
		if(s[i]==s[i+1]) ok=false;
	}
	cout<<(ok ? "Good":"Bad");
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
#define inI(x) scanf("%d",&x)
#define inI2(x,y) scanf("%d %d",&x,&y)
#define inI3(x,y,z) scanf("%d %d %d",&x,&y,&z)
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
char c[100005];
int sc,pp,n;
int main()
{
    scanf("%s",c+1);
    n=strlen(c+1);
    for(int i=1;i<=n;i++)
    {
        if(pp==0)
        {
            if(c[i]=='p')sc--;
            pp++;
        }
        else
        {
            if(c[i]=='g')sc++;
            pp--;
        }
        //printf("%d %d %d\n",i,sc,pp);
    }
    printf("%d",sc);
}


Measured memory_bytes: 384
gets.chomp
preorderd = gets.chomp.split.map(&:to_i)
inorderd  = gets.chomp.split.map(&:to_i)



def make_tree(inorderd, preorderd)
  return [] if inorderd.nil? or inorderd.empty? 
  return [] if preorderd.nil? or preorderd.empty? 

  focus = preorderd.shift
  split = inorderd.index(focus)

  l = inorderd.shift(split)
  inorderd.shift

  [make_tree(l, preorderd), make_tree(inorderd, preorderd)].flatten << focus
end

puts make_tree(inorderd, preorderd).join(' ')

Measured memory_bytes: 8640
H, W = map(int,input().split())
S = [list(input()) for i in range(H)]
arr = [[0]*W for i in range(H)]
for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      if i-1 >= 0 and S[i-1][j] == ".":
        arr[i-1][j] += 1
      if i+1 < H and S[i+1][j] == ".":
        arr[i+1][j] += 1
      if j-1 >= 0 and S[i][j-1] == ".":
        arr[i][j-1] += 1
      if j+1 < W and S[i][j+1] == ".":
        arr[i][j+1] += 1
      if i-1 >= 0 and j-1 >= 0 and S[i-1][j-1] == ".":
        arr[i-1][j-1] += 1
      if i-1 >= 0 and j+1 < W and S[i-1][j+1] == ".":
        arr[i-1][j+1] += 1
      if i+1 < H and j-1 >= 0 and S[i+1][j-1] == ".":
        arr[i+1][j-1] += 1
      if i+1 < H and j+1 < W and S[i+1][j+1] == ".":
        arr[i+1][j+1] += 1
      arr[i][j] = "#"
for i in range(H):
  print(*arr[i], sep="")

Measured memory_bytes: 3572
import java.io.*;
import java.util.*;
 
public class Main {
 
 
    public static void main(String[] args) throws Exception {
 
        FastReader fs = new FastReader();
      out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = fs.nextInt();
        int w = fs.nextInt();
        
        if(w>=n){
            out.println("unsafe");
        }else{
            out.println("safe");
        }
 
        out.close();
 
    }
 
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
 
    //-----------MyScanner class for faster input----------
    public static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
 
    }
    //--------------------------------------------------------
}

Measured memory_bytes: 32916
S=list(input())
Count=[]
for i in range(len(S)):
    if S[i] in ['A','C','T','G']:
        Count.append(1)
    else:
        Count.append(0)
c=0
m=[]
for i in range(len(S)):
    if Count[i]==1:
        c+=1
        m.append(c)
        continue
    else:
        c*=0
        m.append(c)
        continue


print(max(m))

Measured memory_bytes: 3064
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan =new Scanner(System.in);
    		
    		int n=Integer.parseInt(scan.next());
    		int a=Integer.parseInt(scan.next());
    		
    		int _a=n-(n/500)*500;
    		
    		if (a>=_a) {
    			System.out.print("Yes");
    		}else {
    			System.out.print("No");
    		}
 
     
    }
    }
// end 

Measured memory_bytes: 23252
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let a=sin()
  out(a.replace(/,/g, ' '))
}
main()

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
 
  vector<int> t(N + 1), x(N + 1), y(N + 1);
  for (int i = 0; i < N; i++) {
    cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
  }
 
  bool can_move = true;
  for (int i = 0; i < N; i++) {
    int dt = t[i + 1] - t[i];
    int dxy = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);  // 前回との移動値
    // 移動量を超えるか、偶数と奇数が一致しない場合は不可
    if (dxy > dt || dt % 2 != dxy % 2) can_move = false;
  }
 
  cout << (can_move ? "Yes" : "No") << endl;
}

Measured memory_bytes: 4576
#include<bits/stdc++.h>
#define for(i,a,b) for(int i=a;)
using namespace std;
#define LL long long int
#define MAX 1000001
bool prime[1000001];
LL count[1000001];

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
   LL a,b,c,d;
   cin >> a>> b>> c>>d;
   cout << max(b*d,max(a*c,max(a*d,(b*c))));
   // c
}

Measured memory_bytes: 3652