akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;

    for(int i=1;i<=N;i++){
        int price = i*1.08;
        if(price == N){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}

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

int main(){
  string X;
  cin >> X;
  reverse(X.begin(),X.end());
  int N=X.size();
  vector<int> A(N,0);
  if(X[0]=='S'){
    A[0]=1;
  }else{
    A[0]=-1;
  }
  for(int i=1;i<N;i++){
    if(X[i]=='S'){
      A[i] = A[i-1]+1;
    }else{
      A[i] = A[i-1]-1;
    }
  }
  sort(A.begin(),A.end());
  cout << 2*A[N-1] << endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

struct MWA{
	using W=long long;
	using E=pair<W,int>;

	struct EHeap{
  		struct Node{
			E e; 
			W put;
			Node *l,*r;
			Node(E e):e(e),put(0),l(nullptr),r(nullptr){}
			Node* push(){
				e.first+=put;
				if(l)l->put+=put;
				if(r)r->put+=put;
				put=0;
				return this;
			}
		};
		Node* merge(Node *a,Node *b){
			if(!a)return b;
			if(!b)return a;
			a->push();b->push();
			if(a->e>b->e)swap(a,b);
			a->r=merge(a->r,b);
			swap(a->l,a->r);
			return a;
		}

		Node* root;
		EHeap():root(nullptr){}
		void pop(){
			root->push();
			root=merge(root->l,root->r);
		}
		void push(E e){
			Node *p=new Node(e);
			root=merge(root,p);
		}
		void add(W a){
			if(root)root->put+=a;
		}
		E top(){
			return root->push()->e;
		}
		void meld(EHeap &eh){
			root=merge(root,eh.root);
		}
	};

	int n;
	vector<vector<E>>G;
	MWA(int n):n(n),G(n){}

	void addEdge(int a,int b,W c){
		G[a].emplace_back(c,b);
	}

	W calc(int r){
		vector<int>par(n);iota(par.begin(),par.end(),0);
		function<int(int)>find=[&](int x){return x==par[x]?x:par[x]=find(par[x]);};
		
		vector<int>st(n);
		vector<EHeap>eh(n);
		
		rep(v,n)for(auto &e:G[v])eh[e.second].push(E(e.first,v));
		
		st[r]=2;
		W ans=0;
		rep(i,n){
			if(st[i])continue;
			int v=i;
			vector<E>es;
			
			while(st[v]!=2){
				st[v]=1;
				int u;W c;
				tie(c,u)=eh[v].top();eh[v].pop();
				u=find(u);
				if(u==v)continue;
				ans+=c;
				if(st[u]!=1){
					es.eb(c,v);
					v=u;
					continue;
				}

				eh[v].add(-c);
				while(v!=u){
					int w;
					tie(c,w)=es.back();es.pop_back();
					eh[w].add(-c);
					eh[w].meld(eh[v]);	
					par[v]=u;
					v=w;
				}
			}
			for(auto &e:es)st[e.second]=2;
		}
		return ans;
	}
};

signed main(){
	int V,E,r;
	scanf("%lld%lld%lld",&V,&E,&r);

	MWA mwa(V);
	rep(i,E){
		int a,b,c;
		scanf("%lld%lld%lld",&a,&b,&c);
		mwa.addEdge(a,b,c);
	}
	printf("%lld\n",mwa.calc(r));
	return 0;
}


Measured memory_bytes: 3308
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0

for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if i * 500 + j * 100 + 50 * k == x:
                count += 1

print(count)


Measured memory_bytes: 3060
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
const ll nmax = 1e9 + 7;
const ll MOD = 998244353;
const double PI = 2 * asin(1);

int main(){
  int N; cin >> N;
  string S; cin >> S;
  int ans = 0;
  for (int i = 0; i < N - 2; i++){
    if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    string s;
    cin >> s;

    bool flag = true;
    int A = 0;
    int Z = 0;
    for(int i = 0; i < s.size(); i++) {
        if (s.at(i) == 'A' && flag == true) {
            A = i;
            flag = false;
        }
        else if (s.at(i) == 'Z') {
            Z = i;
        }
    }
    cout << Z - A + 1 << endl;
}

Measured memory_bytes: 640
N = int(input().strip())

A = {}
for a in [int(x) for x in input().strip().split(" ")]:
    A.setdefault(a, 0)
    A[a] += 1
total = sum([k * v for k, v in A.items()]) 

Q = int(input().strip())

for q in range(Q):
    B, C = [int(x) for x in input().strip().split(" ")]
    if B in A:
        A.setdefault(C, 0)
        dif = (C - B) * A[B]
        A[C] += A[B]
        del A[B]
        total += dif
    print(total)


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

int main() {
  int x, y, a;
  
  while(1) {
    cin >> x >> y;
    
    if (x == 0 && y == 0) {
      break;
    } else {
      if (x > y) {
        a = x;
        x = y;
        y = a;
        }
        cout << x << " " << y << endl;
    }
  }
  
  return 0;
  
}


Measured memory_bytes: 3092
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N,M = inputMap()
	A = inputList()

	if len(A) == 1:
		print(A[0] // (2**M))
		sys.exit()

	A.sort()
	A = A[::-1]
	ans = 0
	A_new = []
	mimi = -1

	for i in range(1000000000000):
		for i,val in enumerate(A):
			if i == len(A)-1:
				A_new.append(val)
				break

			if mimi < val and M > 0:
				flg = False
				for j in range(1,M+1):
					if M - j != 0:
						tmp = val // (2**j)
						if tmp < A[i+1] or tmp < mimi:
							M -= j
							A_new.append(tmp)
							flg = True
							if mimi == -1:
								mimi = tmp
							break

				if flg == False:
					tmp = val // (2**M)
					M = 0
					A_new.append(tmp)

			else:
				A_new.append(val)

		#print(A_new)
		#A = copy.deepcopy(A_new)
		A = A_new
		A.sort()
		A = A[::-1]
		A_new = []
		mimi = -1

		if M == 0:
			break

	#print(A)

	ans = 0
	for i in A:
		ans += i

	print(ans)


if __name__ == "__main__":
	main()


Measured memory_bytes: 70888
#include <stdio.h>

int main(void)
{
    int N;
    scanf("%d", &N);
    int res=0;
    int ans=1;
    for(int i=1;i<=N;i++){
        int c=0;
        int j=i;
        while(j%2==0){
            c++;
            j/=2;
        }
        if(res<c){
            res=c;
            ans=i;
        }
    }
    printf("%d\n",ans);
    
    return 0;
}


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

int main() {
	int A,B,k=-1;
	cin >> A>>B;
	rep(i, 1010) {
		if (int(i * 0.08) == A && int(i * 0.1) == B) {
			k = i;
			break;
		}
	}
	cout <<k<< endl;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe

solve :: String -> Int
solve s | n `mod` 2 == 0 = (n `div` 2) + k
        | otherwise     = (n `div` 2) + 1 + k

  where

  n = length s

  (sa, sb) = splitAt (n `div` 2) s

  (pred0, seq1, seq2) 
    | n `mod` 2 == 0 = (const True, reverse sa, sb)
    | otherwise = ((== (head sb)), reverse sa, (tail sb))

  k = length $ takeWhile id $ zipWith f seq1 seq2 where
    f x y = pred0 x && x == y

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_s]:remLines1 = remLines0
      s = B.unpack bs_s
  in solve s

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents


Measured memory_bytes: 6396
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll=long long;


vector<ll> cumsum(vector<ll> v)
{
  int v_len = v.size();
  vector<ll> s(v.size() + 1, 0);
  for (int i = 0; i  < v_len; ++i) s[i + 1] = s[i] + v[i];

  return s;
}


int main(int argc, char const* argv[])
{
  ll n, m;

  cin >> n >> m;

  vector<ll> a(n);

  REP(i, n) {
    cin >> a.at(i);
  }

  sort(ALL(a));
  vector<ll> cum_sum = cumsum(a);

  vector<int> num_greater_or_equal_x(2e5 + 1, 0);
  {
    int idx = 0;
    for (int i = 0; i < a.size(); ++i) {
      while (idx <= a[i]) {
        num_greater_or_equal_x[idx] = a.size() - i;
        idx++;
      }
    }
  }

  ll l = 0, r = 2e5+1, mid;

  while(r - l > 1) {
    mid = (r + l) / 2;
    ll count = 0;
    REP(i, n) {
      // cout << "i: " << i << ", count: " << count << ", score: " << max((int)(mid - a[i]), 0) << endl;
      count += num_greater_or_equal_x[max((int)(mid - a[i]), 0)];
    }
    if (count > m) {
      l = mid;
    } else {
      r = mid;
    }
    // cout << "l: " << l << ", r: " << r << ", mid: " << mid << endl;
  }

  ll num, sum_num = 0, ans = 0;
  REP(i, n) {
    num = num_greater_or_equal_x[max((int)(r - a[i]), 0)];
    sum_num += num;
    ans += a[i] * num + *(cum_sum.end() - 1) - cum_sum[cum_sum.size() - 1 - num];
  }
  ans += l * (m - sum_num);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2576
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 
 
 
public class Main {
 
	public static void main(String[] args) {
 
		Solve s= new Solve();
		s.solve();
 
	}
}
 
 
class Solve{
 
 
	 public void solve() {
		 Scanner sc = new Scanner(System.in) ;
		 int N = sc.nextInt();
		 int K = sc.nextInt();
		 int[] a = new int[N];
		 int res =0;
		 
 
		 
		 for(int i=0;i<N;i++) {
			 a[i]=sc.nextInt();
		 }
		 
		 for(int l=0;l<=K;l++) {
			 for(int r=0;r<=K-l;r++) {
				 
				 if(l+r>N) {
					 continue;
				 }
				 ArrayList<Integer> now = new ArrayList<>();
				 int d=K-l-r;
				 int score=0;
				 for(int i=0;i<l;i++) {
					 score+=a[i];
					 now.add(a[i]);
				 }
				 for(int i =N-r;i<N;i++) {
					 score+=a[i];
					 now.add(a[i]);
				 }
				Collections.sort(now);
				 
				 for(int i=0;i<d;i++) {
					 if(i>=now.size())break;
					 if(now.get(i)>0)break;
					 score-=now.get(i);
				 }
				 
					 res=Math.max(res, score);
					 
				 
			 }
			 
		 }
		 System.out.println(res);
 
		
	 }
}

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

int main() {
  ll n,m;
  cin >> n >> m;
  vector<ll> b(n,1);
  vector<bool> r(n,false);
  r[0] = true;
  rep(i,m){
    ll x,y;
    cin >> x >> y;
    x--;
    y--;
    b[x]--;
    b[y]++;
    if(r[x]){
      r[y] = true;
    }
    if(b[x] == 0){
      r[x] = false;
    }
  }
  
  ll cnt=0;
  
  rep(i,n){
    if(b[i]>0 && r[i]){
      cnt++;
    }
  }
  
  cout << cnt << endl;
  
  return(0);
}

Measured memory_bytes: 3992
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

// LazyAddSegmentTree
template<typename T>
class LazyAddSegTree{
public:
    int n;
    T defaultValue;
    vector<T> dat;
    vector<T> lazy;

    LazyAddSegTree(vector<T>& v, T value){
        n = 1;
        int vSize = (int)v.size();
        while(n < vSize){
            n *= 2;
        }
        dat.assign(2 * n - 1, value);
        lazy.assign(2 * n - 1, 0);
        defaultValue = value;

        for(int i = 0; i < vSize; i++){
            dat[i + n - 1] = v[i];
        }
        for(int i = n - 2; i >= 0; i--){
            dat[i] = ope(dat[2 * i + 1], dat[2 * i + 2]);
        }
    }

    T add(int a, int b, T value, int k = 0, int l = 0, int r = -1){
        if(r < 0){
            r = n;
        }
        propagate(k);

        if(r <= a || b <= l){
            return dat[k];
        }

        if(a <= l && r <= b){
            lazy[k] += lazyPlus(value, l, r);
            propagate(k);
            return dat[k];
        }
        else{
            T vl = add(a, b, value, 2 * k + 1, l, (l + r) / 2);
            T vr = add(a, b, value, 2 * k + 2, (l + r) / 2, r);
            dat[k] = ope(vl, vr);
            return dat[k];
        }
    }

    T query(int a, int b, int k = 0, int l = 0, int r = -1){
        if(r < 0){
            r = n;
        }

        if(r <= a || b <= l){
            return defaultValue;
        }
        propagate(k);

        if(a <= l && r <= b){
            return dat[k];
        }
        else{
            T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
            T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
            return ope(vl, vr);
        }
    }

private:

    void propagate(int k){
        if(lazy[k] != 0){
            dat[k] += lazy[k];
            if(k <= n - 2){
                T value = lazyPropPlus(lazy[k]);
                lazy[2 * k + 1] += value;
                lazy[2 * k + 2] += value;
            }

            lazy[k] = defaultValue;
        }
    }

    T ope(T a, T b){
        return a + b;
    }

    T lazyPlus(T value, int l, int r){
        return (r - l) * value;
    }

    T lazyPropPlus(T value){
        return value / 2;
    }
};

int main(){

    int n, q;
    cin >> n >> q;

    vector<long long> v(n, 0);
    LazyAddSegTree<long long> lazySegTree(v, 0);

    for(int loop = 0; loop < q; loop++){
        int com;
        cin >> com;
        if(com == 0){
            int s, t, x;
            cin >> s >> t >> x;
            lazySegTree.add(s - 1, t, x);
        }
        else{
            int s, t;
            cin >> s >> t;
            cout << lazySegTree.query(s - 1, t) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 7852
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

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

		char[][] g = new char[h][w];
		for (int i = 0; i < h; i++) {
			g[i] = sc.nextLine().toCharArray();
		}

		long[][] dp = new long[h][w];
		dp[0][0] = 1;

		int[][] d = {{0, 1}, {1, 0}};
		Queue<int[]> q = new LinkedList<>();
		q.offer(new int[]{0, 0});
		boolean[][] visited = new boolean[h][w];

		while (!q.isEmpty()) {
			int[] hw = q.poll();
			if (visited[hw[0]][hw[1]]) continue;
			visited[hw[0]][hw[1]] = true;

			for (int i = 0; i < d.length; i++) {
				int hi = hw[0] + d[i][0];
				int wi = hw[1] + d[i][1];
				if (hi >= 0 && wi >= 0 && hi < h && wi < w && g[hi][wi] == '.' && !visited[hi][wi]) {
					dp[hi][wi] = (dp[hi][wi] + dp[hw[0]][hw[1]]) % 1000000007;
					q.offer(new int[]{hi, wi});
				}
			}
		}

		//for (int i = 0; i < h; i++) {
		//	for (int j = 0; j < w; j++) {
		//		System.out.print(dp[i][j]);
		//		System.out.print(" ");
		//	}
		//	System.out.println();
		//}

		System.out.println(dp[h - 1][w - 1]);
	}
}


Measured memory_bytes: 72544
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.nextLine().split(" ");
        int A = getInt(s[0]);
        int B = getInt(s[1]);
        int C = getInt(s[2]);
        int max = Math.max(A,B);
            max = Math.max(max,C);

        int remA = (max - A) % 2;
        int remB = (max - B) % 2;
        int remC = (max - C) % 2;

        int result = 0;
        result += (max - A - remA) != 0 ? (max - A - remA) / 2 : 0;
        result += (max - B - remB) != 0 ? (max - B - remB) / 2 : 0;
        result += (max - C - remC) != 0 ? (max - C - remC) / 2 : 0;

        if(remA != 0 || remB != 0 || remC != 0 ) result++;
        if((remA + remB + remC) % 2 != 0 ) result++;
        System.out.println(result);
        sc.close();
    }
    static int getInt(String val) {
        return Integer.parseInt(val);
    }
    static long getLong(String val) {
        return Long.parseLong(val);
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vec vector<ll>
vec dp;
vec a;
ll recur(ll i,ll n)
{
  ll x=INT_MAX,y=INT_MAX;
  if(i==n-1)
  return 0;
  if(dp[i]!=-1)
    return dp[i];
  if(i+1<n)
  x=recur(i+1,n)+abs(a[i]-a[i+1]);
  if(i+2<n)
  y=recur(i+2,n)+abs(a[i]-a[i+2]);
  return dp[i]=min(x,y);
}
int main()
{
  int n;
  cin>>n;
  dp.resize(n+1,-1);
  a.resize(n);
  for(int i=0;i<n;i++)
  cin>>a[i];
  cout<<recur(0,n);
}

Measured memory_bytes: 9568
#include<iostream>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  	int a;
  	int b;
  	cin>>a>>b;
  	if(a<=b){
  		cout<<a<<endl; 
	}
	else cout<<a-1<<endl;
  	return 0;
}

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

vector<int> d, f;
vector<vector<int>> edge;
int t = 0;

void dfs(int s) {
    d[s] = ++t;
    for (int u : edge[s]) {
        if (d[u] == -1)
            dfs(u);
    }
    f[s] = ++t;
}

int main() {
    int n;
    cin >> n;
    d.resize(n, -1);
    f.resize(n);
    edge.resize(n);
    for (int i = 0; i < n; ++i) {
        int id, k;
        cin >> id >> k;
        if (id != i + 1) exit(1);
        if (!k) continue;

        edge[i].resize(k);
        for (int j = 0; j < k; ++j) {
            cin >> edge[i][j];
            --edge[i][j];
        }
    }
    for (int i = 0; i < n; ++i) {
        if (d[i] == -1)
            dfs(i);

        cout << (i + 1) << " " << d[i] << " " << f[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
using namespace std;
int keta(int m){
  int sum=0;
  while(m>0){
    sum+=m%10;
    m/=10;
  }
  return sum;
}

int main(){
long int n;
int a,b;
int awa=0;
int bwa=0;
int wa;
int out=100000;
cin>>n;
for(a=1;a<n;a++){
  b=n-a;
  awa=keta(a);
  bwa=keta(b);
  wa=awa+bwa;
  out=min(wa,out);
}
cout<<out<<endl;
}


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

int main(){
	int H,W;
	cin>>H>>W;
	vector<vector<char>>board(H+2,vector<char>(W+2,'.'));
	rep(i,H){
		rep(j,W){
			cin>>board.at(i+1).at(j+1);
			//cout<<board.at(i+1).at(j+1);
		}
		//cout<<endl;
	}
	rep(i,H){
		rep(j,W){
			if(board.at(i+1).at(j+1)=='.'){
				int mine=0;
				if(board.at(i+1+1).at(j+1)=='#'){
					mine++;
				}
				if(board.at(i+1+1).at(j+1+1)=='#'){
					mine++;
				}
				if(board.at(i+1).at(j+1+1)=='#'){
					mine++;
				}
				if(board.at(i+1-1).at(j+1+1)=='#'){
					mine++;
				}
				if(board.at(i+1-1).at(j+1)=='#'){
					mine++;
				}
				if(board.at(i+1-1).at(j+1-1)=='#'){
					mine++;
				}
				if(board.at(i+1).at(j+1-1)=='#'){
					mine++;
				}
				if(board.at(i+1+1).at(j+1-1)=='#'){
					mine++;
				}
				cout<<mine;
			}else if(board.at(i+1).at(j+1)=='#'){
				cout<<'#';
			}else{}
		}
		cout<<endl;
	}
return 0;}

/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"

using namespace std;

int main(){
    string s;
    int len, res=1, c=0;
    cin >> s;
    if(s[0]!='A') res=0;
    else{
        len=s.size();
        for(int i=1; i<len; i++){
            if(i>1 && i<len-1){
                if(s[i]=='C') c++;
                else if(s[i]<'a'){
                    res=0;
                    break;
                }
            }
            else if(s[i]<'a'){
                res=0;
                break;
            }
        }
        if(c!=1) res=0;
    }
    cout << (res&1? "AC":"WA") << endl;
    return 0;
}


Measured memory_bytes: 256
S = input()

s = []
for i in S:
  s.append(i)
#print(s)
cnt = 0
for i in range(len(S)):
  if i%2==1:
    if (s[i] == 'L')or(s[i] == 'U')or(s[i] == 'D'):
      cnt += 0
    else:
      cnt += 1
      break
  else:
    if (s[i] == 'R')or(s[i] == 'U')or(s[i] == 'D'):
      cnt += 0
    else:
      cnt += 1
      break
if cnt == 0:
  print('Yes')
else:
  print('No')
      
    

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
const int N=1e5+10;
int A[N],B[N],t1,t2,ans,n;
char s[N],t[N];
int main(){
    scanf("%*d%s%s",s+1,t+1);n=strlen(s+1);int *a=A+n,*b=B+n;
    rep(i,1,2*n) a[i]=b[i]=n;
    rep(i,1,n-1) if(s[i]!=s[i+1]) a[++t1]=i;
    rep(i,1,n-1) if(t[i]!=t[i+1]) b[++t2]=i;ans=1e9;
    rep(i,-t1-1,t2+1) if((i&1)!=(s[1]==t[1])){
        int now=0;
        rep(j,min(1,1-i),max(t1,t2-i))
            now+=abs(a[j]-b[i+j]);
        ans=min(ans,now);
    }
    printf("%d\n",ans);
    return 0;
}

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

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

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


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

int main(){
  ll n,k;cin>>n>>k;
  ll ans=0;
  while(pow(k,ans)<=n){
    ans=ans+1;
  }
  cout<<ans<<endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_b() {
	ll n, m;
	ll x, y;
	ll a, b, c;
	//ll k;
	string s;
	ll l_ans = 0;
	float f_ans = 0;
	string s_ans;

	cin >> x >> y;

	if ((y - 2 * x) % 2 != 0) {
		s_ans = "No";
	}
	else if ((y - 2 * x) < 0) {
		s_ans = "No";
	}
	else {
		b = (y - 2 * x) / 2;
		if (x - b < 0) {
			s_ans = "No";
		}
		else {
			s_ans = "Yes";
		}
	}

	cout << s_ans << "\n";
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_b();

	return 0;
}


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

int main() {
    int n;
    cin >> n;
    for(int i=0; i<n; ++i) {
        string s1, s2;
        cin >> s1;
        s2 = s1;
        sort(s1.begin(), s1.end());
        sort(s2.rbegin(), s2.rend());
        cout << stoi(s2) - stoi(s1) << endl;
    }
}


Measured memory_bytes: 2992
N = int(input())
abc = [list(map(int, input().split())) for _ in range(N)]

dp = [[0]*3 for _ in range(N)]
dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]
for n in range(1, N):
    dp[n][0] = max(dp[n-1][1]+abc[n][0], dp[n-1][2]+abc[n][0])
    dp[n][1] = max(dp[n-1][0]+abc[n][1], dp[n-1][2]+abc[n][1])
    dp[n][2] = max(dp[n-1][0]+abc[n][2], dp[n-1][1]+abc[n][2])
print(max(dp[-1]))

Measured memory_bytes: 75224
import sys
input = sys.stdin.readline
#n = int(input())
#l = list(map(int, input().split()))
'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

n=int(input())
print(len(set([input() for i in range(n)])))

Measured memory_bytes: 35580
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan =  new Scanner(System.in);
        
        int count = 0;
        
        int n = scan.nextInt();

        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = scan.nextInt();
        }
        
        int m = scan.nextInt();
        
        int[] b = new int[m];
        for(int i = 0; i < m; i++){
            b[i] = scan.nextInt();
            int indexR = n - 1;
            int indexL = 0;
            while(true){
                int indexM = (indexR + indexL) /2;
                if(b[i] == a[indexM]){
                    count++;
                    break;
                } else if(indexL > indexR){
                    break;
                } else if(b[i] > a[indexM]){
                    indexL = indexM + 1;
                } else {
                    indexR = indexM - 1;
                }
            }
        }
        
        System.out.println(count);
        
        scan.close();
    }
}



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


int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  vector<int> b(N);
  for(int i = 0; i < N; i++){
    b.at(a.at(i)-1) = i + 1;
  }
  for(int i = 0; i < N; i++){
    cout << b.at(i) << endl;
  }
}

Measured memory_bytes: 1536
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))


s = ''.join(str(i) for i in LI())
print('YES' if s.count('1') == s.count('7') == s.count('9') == s.count('4') == 1 else 'NO')


Measured memory_bytes: 66668
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define ll long long
#define M 1000000007
#define N 200010
using namespace std;

int n,h[N];
ll mx,ans,a[N],t[N];

ll get(int p)
{
    ll ret=0;
    while(p>0)
    {
        ret=max(ret,t[p]);
        p-=p&(-p);
    }
    return ret;
}

void put(int p,ll v)
{
    while(p<N)
    {
        t[p]=max(t[p],v);
        p+=p&(-p);
    }
}

int main()
{
    cin>>n; 
    FOR(i,0,n) cin>>h[i];
    FOR(i,0,n) cin>>a[i];
    FOR(i,0,n)
    {
        mx=get(h[i]);
        put(h[i],mx+a[i]);
        ans=max(ans,mx+a[i]);
    }
    cout<<ans<<'\n';

    return 0;
}

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

int main()
{
	std::multiset<int> a;
	int n;
	scanf("%d",&n);
	for(int i = 0; i < n;++i) {
		int k;
		scanf("%d",&k);
		a.insert(k);
	}
	int m;
	scanf("%d",&m);
	for(int i = 0;i < m;++i) {
		int k;
		scanf("%d",&k);
		if(a.find(k) == a.end()) {
			printf("NO\n");
			return 0;
		}
		a.erase(a.find(k));
	}
	printf("YES\n");
}

Measured memory_bytes: 9728
#include <bits/stdc++.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+1); i++)
#define OUT(s) cout << s << "\n";
using namespace std;

int cnt=0;
long X,a=100;
// https://atcoder.jp/contests/abc165
void Main()
{
    while(a < X) {
        cnt++;
        a += a * 0.01;
    }
    OUT(cnt);

}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    cin >> X;
    Main();
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

ll counter(ll num){
    return (num*(num-1))/2;
}
int main(){
    int n;
    cin>>n;
    /*
    ll a[200005]={};
    ll b[200005]={};
    */
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    rep(i,n)a[i]--;
    vector<int> b(n);
    rep(i,n)b[a[i]]++;
   
    ll sum=0;
    rep(i,n){
        sum+=counter(b[i]);
    }
    rep(i,n){
        ll ans=sum;
        ans-=counter(b[a[i]]);
        ans+=counter(b[a[i]]-1);
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 4096
#include <algorithm>
#include <cstdio>
#include <vector>
#define pb push_back
std::vector<int> adj[3005];
int arr[3005];
bool dfs(int u, int fa = -1)
{
	for (int v : adj[u])
	{
		if (v == fa)
			continue;
		if (arr[v] < arr[u] && !dfs(v, u))
			return true;
	}
	return false;
}
int main()
{
	// freopen("AGC010-F.in", "r", stdin);
	int n;
	scanf("%d", &n);
	std::for_each(arr, arr + n, [&] (int &x) { scanf("%d", &x); });
	for (int i = 1; i < n; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		adj[--u].pb(--v);
		adj[v].pb(u);
	}
	for (int i = 0; i < n; i++)
	{
		if (dfs(i))
			printf("%d ", i + 1);
	}
	return 0;
}


Measured memory_bytes: 384
require 'pp'
n, m, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
masu = Array.new(n+1, 0)
a.each do |aa|
  masu[aa] = 1
end
p [masu[0..x].inject(:+),masu[x..-1].inject(:+)].min

# 1 0 3


Measured memory_bytes: 2172
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from functools import reduce
mod = 10**9+7

n, a, b = map(int, input().split())


def nCk(n, k):
    numer = reduce(lambda x, y: (x * y) % mod, range(n, n - k, -1))
    denom = reduce(lambda x, y: (x * y) % mod, range(1, k + 1))
    return numer * pow(denom, mod - 2, mod) % mod


ans = pow(2, n, mod) - nCk(n, a) - nCk(n, b) - 1
ans %= mod
print(ans)


Measured memory_bytes: 3572
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] ss = s.split("");
        Arrays.sort(ss);
        if (String.join("", ss).equals("abc")) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21972
// C++11
#include "bits/stdc++.h"
#include <sys/time.h>
#include <emmintrin.h>
#include <string>
#include <sstream>
#include <fstream>
#include <random>
#include <bitset>

using namespace std;

inline long long GetTSC() {
  long long lo, hi;
  asm volatile ("rdtsc": "=a"(lo), "=d"(hi));
  return lo + (hi << 32);
}
inline double GetSeconds() {
  return GetTSC() / 2.8e9;
}

int a[2000] = {};
double TO = 1.9;

void solve(){
  double starttime = GetSeconds();
  int n;
  int s = 0;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a[i];
    s += a[i];
  }
  bitset<2000*2000/2+1> b;
  b[0] = 1;
  for(int i=0; i<n; i++){
    b |= b << a[i];
  }
  for(int i=s/2; i>=0; i--){
    if(b[i]){
      cout << s-i << endl;
      return;
    }
  }

  return;
}

int main() {
  solve();
  return 0;
}



Measured memory_bytes: 1024
// ABC157D.cpp :
// UnionFind
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
struct UnionFind {
    vector<int> d;
    UnionFind(int n = 0) : d(n, -1) {// 最初は全て -1:「根」とする
    }
    // グループ番号を返す
    int find(int x) {
        if (d[x] < 0) {
            return x;  // 根なら値を返す
        }
        return d[x] = find(d[x]);
    }
    // 連結する
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)  return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    // 同じグループか？
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    // サイズ
    int size(int x) {
        return -d[find(x)];
    }
};
// UnionFind uf(n);n個の頂点で初期化
// uf.unite(a,b) a頂点とb頂点を結ぶ
// uf.size(e) eグループのサイズ
// uf.same(c,d) a頂点とc頂点が同じグループか、調べる

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<int>buddy(n); // 友だち
    int a, b;
    UnionFind uf(n);
    rep(i, m) {
        cin >> a >> b;
        a--;
        b--;
        uf.unite(a, b); // aとbを友だちにする
        buddy.at(a)++; // aの直接の友だちの数
        buddy.at(b)++; // bの直接の友だちの数
    }
    int c, d;
    vector<vector<int>>block(n);
    rep(i, k) {
        cin >> c >> d;
        c--;
        d--;
        block.at(c).push_back(d); // cがブロックしている人のリスト
        block.at(d).push_back(c); // dがブロックしている人のリスト
    }
    vector<int>bl_count(n);
    rep(i, n) {
        for (int x : block.at(i)) {
            if (uf.same(i, x)) bl_count.at(i)++; // a.at(i)が、自分と同じグループ内でブロックしている人数
        }
    }

    vector<int>ans(n);
    rep(i, n) {
        ans.at(i) = uf.size(i)-buddy.at(i)-1-bl_count.at(i);
        if (i == 0) {
            cout << ans.at(i);
        }
        else {
            cout << " " << ans.at(i);
        }
    }
    cout << endl;
}


Measured memory_bytes: 9460
N=gets.to_i
es = {}
(N-1).times do
  a,b = gets.split.map(&:to_i)
  es[a] ||= []
  es[a] << b
  es[b] ||= []
  es[b] << a
end
cs = gets.split.map(&:to_i).sort

arr = Array.new(N+1,0)

arr[1] = cs.pop
q = es[1]
ret = 0
until q.empty?
  node = q.shift
  next if arr[node] != 0
  arr[node] = cs.pop
  ret += arr[node]
  q += es[node]
end

p ret
puts arr[1..-1].join(' ')


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

int main()
{
    long long int H, W, Ch, Cw, Dh, Dw, i, j, k, l;
    cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
    vector<vector<long long int>> board(H, vector<long long int>(W)); /* -2が壁、10000000が未開の道 */
    char c;
    for (i = 0; i < H; i++)
    {
        for (j = 0; j < W; j++)
        {
            cin >> c;
            if (c == '#')
            {
                board[i][j] = -2;
            }
            else
            {
                board[i][j] = 10000000;
            }
        }
    }
    set<pair<long long int, long long int>> group[2];
    group[0].insert(make_pair(Ch - 1, Cw - 1));
    long long int now = 0;
    long long int next = 1;
    long long int dist = 0;
    while (!group[now].empty())
    {
        set<pair<long long int, long long int>>::iterator it = group[now].begin();
        while (!group[now].empty())
        {
            i = (*it).first;
            j = (*it).second;
            board[i][j] = dist;
            if (i - 1 > -1 && board[i - 1][j] != -2 && board[i - 1][j] > dist)
            {
                board[i - 1][j] = dist;
                group[now].insert(make_pair(i - 1, j));
                group[next].erase(make_pair(i - 1, j));
            }
            if (j - 1 > -1 && board[i][j - 1] != -2 && board[i][j - 1] > dist)
            {
                board[i][j - 1] = dist;
                group[now].insert(make_pair(i, j - 1));
                group[next].erase(make_pair(i, j - 1));
            }
            if (i + 1 < H && board[i + 1][j] != -2 && board[i + 1][j] > dist)
            {
                board[i + 1][j] = dist;
                group[now].insert(make_pair(i + 1, j));
                group[next].erase(make_pair(i + 1, j));
            }
            if (j + 1 < W && board[i][j + 1] != -2 && board[i][j + 1] > dist)
            {
                board[i][j + 1] = dist;
                group[now].insert(make_pair(i, j + 1));
                group[next].erase(make_pair(i, j + 1));
            }
            for (k = i - 2; k < i + 3; k++)
            {
                for (l = j - 2; l < j + 3; l++)
                {
                    if (-1 < k && k < H && -1 < l && l < W && board[k][l] != -2 && board[k][l] > dist + 1)
                    {
                        group[next].insert(make_pair(k, l));
                        board[k][l] = dist + 1;
                    }
                }
            }
            group[now].erase(it);
            it = group[now].begin();
        }
        if (now == 0)
        {
            now = 1;
            next = 0;
        }
        else
        {
            now = 0;
            next = 1;
        }
        dist += 1;
    }
    if (board[Dh - 1][Dw - 1] == 10000000)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << board[Dh - 1][Dw - 1] << endl;
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<char> s(n);
  for(int i = 0; i < n; i++)
    cin >> s.at(i);
  cout << unique(s.begin(), s.end()) - s.begin() << endl;
}

Measured memory_bytes: 384
// nb_9960
  #include <bits/stdc++.h> 
  using namespace std; 
  #define fi(i,a,n) for (ll i=a; i < n; i++) 
  #define ll long long
  #define pb push_back 
  #define mp make_pair 
  #define F first 
  #define S second 
  #define all(x) x.begin(), x.end() 
  #define clr(x) memset(x, 0, sizeof(x)) 
  #define sortall(x) sort(all(x)) 
  typedef pair<ll, ll> pl; 
  typedef vector<ll> vl; 
  typedef vector<pl> vpii; 
  #define sz(a) int((a).size())
  #define tr(c,i) for(typeof(c).begin() 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 MOD 1000000007
  #define PI 3.1415926536

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

    ll t = 1; 
    // cin >> t;

    while (t--) { 
      ll n;
      cin>>n;
      vector<pair<int,int>>v;
      fi(i,0,n){
        int a,b;
        pair<int,int>p;
        cin>>a>>b;
        p=make_pair(a,b);
        v.push_back(p);
      }
      bool z=false;
      fi(i,0,n-2){
        if(v[i].first==v[i].second && v[i+1].first==v[i+1].second && v[i+2].first==v[i+2].second){
          z=true;
          break;
        }
      }
      if(z==true){
        cout<<"Yes"<<endl;
      }else{
        cout<<"No"<<endl;
      }
    }
    return 0; 
  } 


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

int main(){

    ll n;cin >> n;
    ll in;
    ll a=1;
    ld b=1;
    rep(i, n){
        cin >> in;
        a *= in;
        b *= in;
    }
    if(a>1e18 || b>1e18) cout << "-1" << endl;
    else cout << a << endl;

    return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
#define int int64_t
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define mod 1000*1000*1000+7
#define mem(dp,a) memset(dp,a,sizeof dp)
int32_t main()
{
    int h,a;cin>>h>>a;
    int ans=0;
    for(int i=0;i<a;i++)
    {
        int x;cin>>x;
        ans+=x;
    }
    if(ans>=h)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include <fstream>
#include<unordered_set>
#include<stack>
#include <unordered_map>
#include<time.h>
#include <chrono>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
typedef long int l;
#define f(i,a,b) for(l i=(l)a;i<(l)b;i+=1)
#define rf(i,a,b) for(l i=(l)a;i>=(l)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define all(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0)
using namespace std;
#define MAX 1000001 
l spf[MAX];
void precompute()
{
	spf[1] = 1;
	for (l i = 2; i < MAX; i++)
		spf[i] = i;

	for (l i = 4; i < MAX; i += 2)
		spf[i] = 2;

	for (l i = 3; i * i < MAX; i++)
	{
		if (spf[i] == i)
		{
			for (l j = i * i; j < MAX; j += i)
				if (spf[j] == j)
					spf[j] = i;
		}
	}
}

int main()
{
	FAST;
	ll n;
	cin >> n;
	ll sum = 0;
	f(i, 1, n + 1)
	{
		if (i % 3 != 0 && i % 5 != 0)
		{
			sum += i;
		}
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int tmp;
  bool first = false;
  for(int i=0;i<N;++i) {
    cin>>tmp;
    if(tmp%2==1) first = true;
  }
  if(first) cout<<"first"<<endl;
  else cout<<"second"<<endl;
}



Measured memory_bytes: 3636
#include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

class UnionFind {
    public:
    int n;
    vector<int> par, rank, size;  //親, 深さ, その木の要素数

    UnionFind(int n): n(n) {
        for(int i=0;i<n;++i){
            par.push_back(i);
            rank.push_back(0);
            size.push_back(1);
        }
    }

    //根を求める
    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            int p = find(par[x]);
            size[x] = size[p];
            return par[x] = p;
        }
    }

    //xとyの属する集合の併合
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        
        size[x] += size[y];
        size[y] = size[x];
        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }

        x = find(x);
        y = find(y);
    }

    //同じ集合に属するか否か
    bool is_same(int x, int y){
        return find(x) == find(y);
    }
};

ll solve(int n, int m) {
    vector<tuple<ll,int,int>> edges(m);
    int s,t; ll c;
    for(int i=0;i<m;++i){
        cin >> s >> t >> c;
        edges[i] = tuple<ll, int, int>{c, s, t};
    }
    sort(edges.begin(), edges.end());

    UnionFind uf(n+1);
    vector<int> edge_cnt(m);
    for(int i=0;i<m;++i){
        tie(c, s, t) = edges[i];
        if(uf.is_same(s,t)) {
            edge_cnt[i] = edge_cnt[i-1];
        } else {
            uf.unite(s, t);
            edge_cnt[i] = (i==0?0:edge_cnt[i-1]) + 1;
            if(edge_cnt[i] == ((n+1)/2)) {
                return c;
            }
        }
    }

    return 0LL;
}

int main() {
    int n, m;
    while(cin >> n >> m, n) {
        cout << solve(n, m) << endl;
    }
}


Measured memory_bytes: 3304
#include <cstdio>
#include <unordered_map>
#include <algorithm>
#include <map>
#include <vector>
#include <cstring>
#include <queue>
#include <cmath>
using namespace std;
const int N = 1001;
long long a[N], f[N * N];
int n, k, cnt;
long long help[61];
long long ans;
bool check()
{
    int K = k ;
    for (int i = 1; i <= cnt; i ++)
        K -= ((ans & f[i]) == ans);
    return K <= 0;
}
int main()
{
    scanf("%d %d", &n, &k);
    help[0] = 1;
    for (int i = 1; i < 61; i ++) help[i] = help[i - 1] * 2;
    for (int i = 1 ; i <= n ; i ++)
        scanf("%lld", &a[i]), a[i] += a[i - 1];
    for (int i = 1; i <= n ; i ++)
        for (int j = i ;  j <= n ; j ++)
            f[++cnt] = a[j] - a[i - 1];
    ans = 0;
    for (int i = 60 ; i >= 0; i  --)
    {
        ans += help[i];
        if (check())
            continue;
        ans -= help[i];
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
ll ok[12345678], cost[12345678];
signed main() {
    ll n, m, l, r, d, z = 0, ans = 0;
	cin >> n >> m; map <ll, map<ll, ll>> ma;
	vector<vector<ll>> G(123456);
    queue<ll> que;
    if (m == 0) { cout << "Yes" << endl; return 0; }
    for (int h = 0; h <= n + 10; h++) { ok[h] = 1; }
	for (int h = 0; h < m; h++) {
		cin >> l >> r >> d; ma[l][r] = d;
        G[l].push_back(r); ok[r] = 0;
	}
    for (int i = 0; i <= n; i++) {
        if (ok[i] != 0) {
            if (!G[i].empty()) { cost[i] = 1; que.push(i); }
        }
    }
    if (que.empty()) { cout << "No" << endl; return 0; }
    while (que.size()) {
        for (int i = 0; i < G[que.front()].size(); i++) {
            if (cost[G[que.front()][i]] == 0) {
                que.push(G[que.front()][i]);
                cost[G[que.front()][i]] = cost[que.front()] + ma[que.front()][G[que.front()][i]];
            }
            else {
                if (cost[G[que.front()][i]] != cost[que.front()] + ma[que.front()][G[que.front()][i]]) {
                    cout << "No" << endl; return 0;
                }
            }
        }
        que.pop();
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 30884
s = input()

if int(s[5]) == 0:
    month = int(s[6])
else:
    month = int(s[5:7])

if int(s[8]) == 0:
    day = int(s[9])
else:
    day = int(s[8:10])

if month < 4:
    flag = True

elif month == 4 and day < 31:
        flag = True
else:
    flag = False

if flag:
    print("Heisei")
else:
    print("TBD")

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

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

using namespace std;

int main() {
  int h,w,n;
  cin >> h >> w >>n;
  int sr, sc;
  cin >> sr >> sc;
  string s,t;
  cin >> s;
  cin >> t;

  int mr = 0, ml = 0, mu = 0, md = 0;

  int tmp = 0;
  REP(i,n) {
    if(s[i] == 'R') {
      tmp++;
    }
    mr = max(tmp, mr);

    if(t[i] == 'L' && sc + tmp > 1) {
      tmp--;
    }
  }


  tmp = 0;
  REP(i, n)
  {
    if (s[i] == 'L')
    {
      tmp++;
    }
    ml = max(tmp, ml);

    if (t[i] == 'R' && sc - tmp < w)
    {
      tmp--;
    }
  }


  tmp = 0;
  REP(i, n)
  {
    if (s[i] == 'U')
    {
      tmp++;
    }
    mu = max(tmp, mu);

    if (t[i] == 'D' && sr - tmp < h)
    {
      tmp--;
    }
  }


  tmp = 0;
  REP(i, n)
  {
    if (s[i] == 'D')
    {
      tmp++;
    }
    md = max(tmp, md);

    if (t[i] == 'U' && sr + tmp > 1)
    {
      tmp--;
    }
  }


  if(sc + mr > w || sc - ml < 1 || sr + md > h || sr - mu < 1) {
    cout <<"NO" << endl;
  } else {
    cout << "YES" << endl;
  }
}


Measured memory_bytes: 904
import java.util.Scanner;

public class Main
{

    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        int b = scan.nextInt();

        int A = a;
        int B = b;
        while (A % B != 0) {
            int Z = A;
            A = B;
            B = Z % A;

        }
        System.out.println((a + b + 1) - B);

    }

}



Measured memory_bytes: 26396
n = int(input())
A = list(map(int, input().split())) + [0, 0]

D = [] # Aiをスキップしたときのデルタ値
now = 0

total = 0
for new1, new2 in zip(A[:-1], A[1:]):
    dist = abs(new1 - now)
    total += dist

    no_skip = abs(new2 - new1) + dist
    skip = abs(new2 - now)
    delta = skip - no_skip
    D.append(delta)
    now = new1

for i in range(n):
    ans = total + D[i]
    print(ans)

Measured memory_bytes: 14048