akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
  int a;
  int seven, five;

  seven = five = 0;

  for ( int i = 0; i < 3; ++i ) {
    cin >> a;
    if ( a == 7 ) ++seven;
    if ( a == 5 ) ++five;
  }

  if ( seven == 1 && five == 2 ) cout << "YES\n";
  else cout <<  "NO\n";
}


Measured memory_bytes: 256
def check(s, p):
    if s == p:
        return 1
    else:
        return 0

s = input()
p = input()

n = 0
answer = 0
while n < len(s) and answer == 0:
    answer = check(s[:len(p)], p)
    s0 = s[0:1]
    s1 = s[1:]
    s = s1 + s0
    n += 1

if answer:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 7552
using System;

namespace AizuOnLine
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true)
            {
                string input = Console.ReadLine();

                if (input == "0")
                {
                    break;
                }

                int sum = 0;
                for (int i = 0; i < input.Length; i++)
                {
                    sum += int.Parse(input[i].ToString());
                }

                Console.WriteLine(sum);
            }
        }
    }
}

Measured memory_bytes: 9236
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long lolong;

inline int input() { int x; scanf("%d", &x); return x; }
inline lolong linput() { lolong x; scanf("%lld", &x); return x; }

const int maxn = 200005, maxv = 1000005, mod = 998244353, inv2 = 499122177;
int a[maxn];
lolong s[maxv];
int mu[maxv];
bool nop[maxv];
int prime[maxv], pp;
int tot[maxv];

int main() {
	int n = input();

	int max = 0;
	for(int i = 1; i <= n; i ++) {
		a[i] = input();
		tot[a[i]] ++;
		max = std::max(a[i], max);
	}

	for(int d = 1; d <= max; d ++)
		for(int t = d; t <= max; t += d)
			s[d] += 1ll * (t / d) * tot[t] % mod;

	for(int i = 1; i <= max; i ++) {
		s[i] %= mod;
		s[i] *= s[i];
		s[i] %= mod;
	}

	mu[1] = 1;
	for(int i = 2; i <= max; i ++) {
		if(!nop[i]) {
			prime[++ pp] = i;
			mu[i] = -1;
		}

		for(int j = 1; j <= pp; j ++) {
			int p = prime[j];
			if(1ll * i * p > max)
				break;
			nop[i * p] = 1;
			if(i % p)
				mu[i * p] = mu[i] * mu[p];
		}
	}

	lolong ans = 0;
	for(int d = 1; d <= max; d ++)
		for(int t = d; t <= max; t += d) {
			ans += 1ll * (mod + mu[t / d]) * t % mod * (t / d) % mod * s[t] % mod;
			ans %= mod;
		}

	for(int i = 1; i <= n; i ++)
		ans -= a[i];

	ans %= mod;
	ans += mod;
	ans %= mod;

	(ans *= inv2) %= mod;

	printf("%lld\n", (ans % mod + mod) % mod);
}


Measured memory_bytes: 21504
import math

#n, a, b= map(int, input().split())
#a, b  = map(int, input().split())
#h = list(map(int, input().split()))
#s = list(str(input()))
n = int(input())
a = list(map(int, input().split()))

alice = 0
bob   = 0

for i in range(n):
  a.sort(reverse=True)
  alice = alice + a[0]*((i+1)%2)
  bob   = bob   + a[0]*(i%2)
  a[0] = 0
    
print(alice - bob)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>	
#include <numeric>
#include <sstream>

#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;


int main()
{
	string str = "";
	
	while (getline (cin, str ) && str != "0" ){
		stringstream ss (str );
		vector <int> hand;
		int n;
		int ace = 0;
		while (ss >> n ){
			if (n == 1 )
				ace++;
			if (n > 10 )
				n = 10;
			hand.push_back (n );
		} // end while
		int sum = accumulate (ALL (hand ), 0 );
		int res = 0;
		if (ace == 0 && sum > 21 ){
			res = 0;
		}else if (ace == 0 && sum <= 21 ){
			res = sum;
		}else if (ace && sum > 21 ){
			res = 0;
		}else if (ace && sum == 21 ){
			res = sum;
		}else{
			res = sum;
			for (int i = 1; i <= ace; i++ ){
					int curr = sum + 10*i;
				if (curr <= 21 ){
					res = max (res, curr );
				} // end 
		 	} // end for
		} // end if
		cout << res << endl;	
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int main() {
	var(int, x);
	print(x == 3 || x == 5 || x == 7 ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "sstream"
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=1e5+1;
int main() {
    quick
int a,b,ans=0,temp=1; cin>>a>>b;
while(temp<b){
    temp--;
    temp+=a;
    ans++;
}
cout<<ans;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <stack>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <sstream>
#include <iomanip>
using namespace std;


#define int int64_t
#define vi vector<int>
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define all(x) (x).begin(), (x).end()
#define vii vector< vector<int> >
#define rip(dp, n, m) vector< vector<int> > dp(n, vector<int>(m,0))
#define ff first
#define ss second
#define pii pair<int64_t, int64_t>
#define miv map<int, vector<int> >
#define mp make_pair
#define pb push_back
#define prr(x) cout << (#x) <<'	' << (x) << endl
#define pr(x) cout  << (x) << endl
#define f(i,n) for(i=0;i<n;i++)
#define pqb priority_queue<int>
#define pqs priority_queue<int,vi,greater<int> >
#define setbits(x)  __builtin_popcountll(x)
#define zrobits(x)  __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x) int x; cin>>x; while(x--)
#define FIO  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int dr8[] = {1,1,0,-1,-1,-1, 0, 1};
int dc8[] = {0,1,1, 1, 0,-1,-1,-1};
int dr4[] = {1,0,0,-1};
int dc4[] = {0,1,-1,0};

int32_t main()
{
    FIO;
    int i, n, j, m, k, l, t;
    // w(X)
    {
       cin >> n ;
        vi v(n);
        f(i,n) cin >> v[i];
        k=0;
        for(i=0;i<n;i++) k+= v[i];
        t=0;
        f(i,n-1)
        {
            k-=v[i];
            t = (t%mod)+((v[i]%mod)*(k%mod))%mod;
        }

        cout << t%mod << endl;

    }
}

Measured memory_bytes: 4768
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF (1e10)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}

int N, M;

int visited[100000];
int distance1[100000];
int distanceN[100000];

vector<vector<int>> links;
void dfs1(int d, int idx)
{
	distance1[idx] = d;
	visited[idx] = 1;
	REP(i,0,links[idx].size()){
		if(visited[links[idx][i]]==0){
			dfs1( d + 1, links[idx][i]);
		}
	}
}

void dfsN(int d,int idx){
	distanceN[idx] = d;
	visited[idx] = 1;
	REP(i,0,links[idx].size()){
		if(visited[links[idx][i]]==0){
			dfsN( d + 1, links[idx][i]);
		}
	}
}

int main()
{
	cin >> N;

	

	links.resize(N);

	REP(i,0,N-1){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		
		links[a].push_back(b);
		links[b].push_back(a);

	}
	REP(i,0,N){
		visited[i] = 0;
	}
	dfs1( 0, 0);

	

	REP(i,0,N){
		visited[i] = 0;
	}
	dfsN(0, N-1);

	
	int blk = 0;
	int wht = 0;
	REP(i, 0, N)
	{
		
		if (distance1[i] <= distanceN[i])
		{
			blk++;
		}else{
			wht++;
		}
	}


	if(blk>wht){
		cout << "Fennec" << endl;
	}else{
		cout << "Snuke" << endl;
	}

	return 0;
}

Measured memory_bytes: 9984
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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

void YN(bool ans){
    if(ans)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return;
}

int main(){
    ll N;
    cin>>N;
    string S;
    do{
        N--;
        S += char('a' + N%26);
        N/=26;
    }while(N != 0);
    reverse(all(S));
    cout<<S;
    return 0;
}

Measured memory_bytes: 3628
n = int(input())
s = [input() for _ in range(n)]
t = []
for i in range(n):
    t.append(s[i] + s[i])
t = t + t
ans = 0
for i in range(n):
    ok = True
    for j in range(n):
        for k in range(n):
            if t[i+j][k] != t[i+k][j]: 
                ok = False
                break
        if not ok: break
    if ok: ans += 1
print(ans * n)

Measured memory_bytes: 42076
import numpy as np

def main():
    N,K = map(int, input().split())
    A = np.array(input().split(), np.int64)
    F = np.array(input().split(), np.int64)

    if sum(A) <= K:
        print(0)
        exit()

    A.sort()
    F.sort()
    A = A[::-1]
    
    cost = A * F
    down = -1
    up = np.max(cost)
    while up > down + 1:
        mid = (down + up) // 2
        if np.sum(np.where(cost > mid, np.ceil((cost - mid) / F), 0)) <= K:
            up = mid
        else:
            down = mid
    
    print(up)
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 37196
package main

// https://hiroyuki.sano.ninja/notes/4d8091cd-87fb-44f5-9f4c-830b76357684

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var infty = 1000000000

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

type DirectedGraphNodeID int

func newDirectedGraph(nNodes int) *DirectedGraph {
	graph := DirectedGraph{}

	graph.nodes = make([]*DirectedGraphNode, nNodes)
	for iNode := 0; iNode < nNodes; iNode++ {
		graph.nodes[iNode] = &DirectedGraphNode{
			key:       DirectedGraphNodeID(iNode),
			adjacents: map[DirectedGraphNodeID]*DirectedGraphNode{},
			costs:     map[DirectedGraphNodeID]int{},
			d:         infty,
		}
	}

	return &graph
}

type DirectedGraph struct {
	nodes []*DirectedGraphNode
	time  int
}

func (graph *DirectedGraph) sedAdjacent(leftID, rightID DirectedGraphNodeID, weight int) {
	graph.nodes[leftID].adjacents[rightID] = graph.nodes[rightID]
	graph.nodes[leftID].costs[rightID] = weight
}

type DirectedGraphNode struct {
	key       DirectedGraphNodeID
	adjacents map[DirectedGraphNodeID]*DirectedGraphNode
	costs     map[DirectedGraphNodeID]int

	parent   *DirectedGraphNode
	d, f     int
	visitied bool
	distance int
}

func dfsVisit(graph *DirectedGraph, startNode *DirectedGraphNode) {
	graph.time++
	startNode.d = graph.time
	startNode.visitied = true

	for adjacentID, adjacent := range startNode.adjacents {
		if !adjacent.visitied {
			adjacent.parent = startNode
			adjacent.distance = startNode.distance + startNode.costs[adjacentID]
			dfsVisit(graph, adjacent)
		}
	}
	graph.time++
	startNode.f = graph.time
}

func fillDistances(graph *DirectedGraph, startNode *DirectedGraphNode) {
	for _, node := range graph.nodes {
		node.visitied = false
		node.parent = nil
		node.distance = infty
	}
	graph.time = 0
	startNode.distance = 0
	dfsVisit(graph, startNode)
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func getFarthestNode(graph *DirectedGraph) *DirectedGraphNode {
	maxDistance := 0
	var nodeMaxDistance *DirectedGraphNode
	for _, node := range graph.nodes {
		if node.distance >= maxDistance {
			maxDistance = node.distance
			nodeMaxDistance = node
		}
	}
	return nodeMaxDistance
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	scanner.Split(bufio.ScanWords)

	nNodes := nextInt()
	graph := newDirectedGraph(nNodes)
	for iNode := 0; iNode < nNodes-1; iNode++ {
		parent := DirectedGraphNodeID(nextInt())
		child := DirectedGraphNodeID(nextInt())
		weight := nextInt()
		graph.sedAdjacent(parent, child, weight)
		graph.sedAdjacent(child, parent, weight)
	}

	distances := make([]int, nNodes)

	fillDistances(graph, graph.nodes[0])
	nodeMaxDistance1 := getFarthestNode(graph)

	fillDistances(graph, nodeMaxDistance1)
	for i, node := range graph.nodes {
		distances[i] = node.distance
	}
	nodeMaxDistance2 := getFarthestNode(graph)

	fillDistances(graph, nodeMaxDistance2)
	for i, node := range graph.nodes {
		distances[i] = max(distances[i], node.distance)
	}

	for i := 0; i < nNodes; i++ {
		fmt.Println(distances[i])
	}
}



Measured memory_bytes: 10640
N, M = map(int, input().split())
H = list(map(int, input().split()))
Hneig = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    Hneig[A - 1].append(H[B - 1])
    Hneig[B - 1].append(H[A - 1])
print(sum([1 for n in range(N) if len(Hneig[n]) == 0 or H[n] > max(Hneig[n])]))


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

int main(){
  int n,l,ans=0,min=1000,mini;cin>>n>>l;
  REP(i,n){
    ans+=l+i;
    if(abs(l+i)<min){
      min=abs(l+i);
      mini=i;
    }
  }
  cout<<ans-mini-l;
}

Measured memory_bytes: 256
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

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

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

a,b,c = RI()

if c>=a and c<=b:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
def main():
  n,m=map(int,input().split())
  x=list(map(int,input().split()))
  #xmod=[y%m for y in x]
  from collections import Counter
  cx=Counter(x)
  cxmod={}
  for k in cx:
    if k%m in cxmod:
      cxmod[k%m]+=cx[k]
    else:
      cxmod[k%m]=cx[k]
  keys=cxmod.keys()
  ans1,ans2=0,0 # ams1:m倍になるペア、ans2:同数のペア。ans1からもとめる
  for k in keys:
    if k==0:
      ans1+=cxmod[k]//2
      cxmod[k]-=2*(cxmod[k]//2)
    else:
      if k==m-k:
        ans1+=cxmod[k]//2
        cxmod[k]-=2*(cxmod[k]//2)
      elif m-k in keys:
        tmp=min(cxmod[k],cxmod[m-k])
        ans1+=tmp
        cxmod[k]-=tmp
        cxmod[m-k]-=tmp
  for k in cx:
    v=cx[k]
    if v>=2 and cxmod[k%m]>=2:
      tmp=min(v//2,cxmod[k%m]//2)
      ans2+=tmp
      cxmod[k%m]-=tmp*2

  print(ans1+ans2)
if __name__=='__main__':
  main()



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


int main()
{
	int a, b, c, d,x,y;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	if (a < b)
	{
		x = a;
	}
	else
	{
		x = b;
	}
	if (c < d)
	{
		y = c;
	}
	else
	{
		y = d;
	}
	cout << x + y;
    return 0;
}



Measured memory_bytes: 256
class Main
{
  public static void main(String[] args) {
    java.io.BufferedReader reader = null;
    try {
      reader = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
      String[] inputs = reader.readLine().split(" ");
      int a = Integer.parseInt(inputs[0]);
      int b = Integer.parseInt(inputs[1]);
      int s = a * b;
      int r = a + a + b + b;
      System.out.printf("%d %d\n", s, r);
    } catch (java.io.IOException e) {
      e.printStackTrace();
    } finally {
      if (reader != null) {
        try {
          reader.close();
        } catch (java.io.IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
}

Measured memory_bytes: 16908
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;


typedef long long ll;
//typedef pair<string, int> pii;
//typedef pair<ll, ll> pll;
typedef vector<int> vi;
//typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef pair <int,int> pii;
typedef pair <int,pii> pi;
#define fi first
#define se second
#define pb push_back
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sv(v) sort(v.begin(),v.end())
#define floop(a,n) for(int i=a; i<n; i++)
#define max3(a,b,c) max(a, max(b,c))
#define max4(a,b,c,d) max(a, max(b,max(c,d)))
#define min3(a,b,c) min(a, min(b,c))
#define min4(a,b,c,d) min(a, min(b,min(c,d)))
vector <int> v;
string int_to_string(int a){return to_string(a);}
int string_to_int(string s){stringstream x(s);int a=0; x>>a; return a;}
//long long int gcd(long long int a, long long int b){if(a%b==0)return b;return gcd(b, a%b);}
//long long int lcm(long long int a, long long int b){return (a*b)/gcd(a, b);}

//long long int factorial(int a){if(a==0)return 1;elsereturn a*factorial(a-1);}



int main()
{
    int a,b,c;
    
    cin >> a >> b >> c;
    
    if(a+b>=c)cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main() {
    string S; cin >> S;
    int cnt = 0;
    for (int i = 0; i < S.length(); ++i) {
        if (S[i] != 'A' && S[i] != 'C' && S[i] != 'G' && S[i] != 'T') continue;
        int k = 0;
        for (int j = i; i < S.length(); ++j) {
            if (S[j] != 'A' && S[j] != 'C' && S[j] != 'G' && S[j] != 'T') {
                k = j; break;
            }
        }
        cnt = max(cnt, k - i);
    }
    printf("%d\n", cnt);
}


Measured memory_bytes: 3688
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
using namespace std;


int main(){
   int N,A[100],mini;
   int sw =0;
   cin >> N;
   for(int i=0;i<N;i++)cin >> A[i];
   for(int i=0;i<N; i++){
      mini=i;
      for(int j=i;j<N;j++){
          if(A[mini]>A[j]) mini=j; 
      } 
      swap(A[i],A[mini]);
      if(mini != i)sw++;
   }
    for(int i=0;i<N;i++){
        if(i>0)cout << " ";
        cout << A[i] ;
    }
    cout << endl;
    cout << sw << endl;
    

   return 0;

}



Measured memory_bytes: 3104
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))

import itertools

t=list(i+1 for i in range(n))
tt=list(itertools.permutations(t))

a=0
b=0
for c,it in enumerate(tt):
  if p==list(it):
    a = c
  if q==list(it):
    b = c

print(abs(a-b))

Measured memory_bytes: 13964
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_n = 200000+10;
Int A[max_n];
Int dp[max_n][2][3];

int main(void) {
    int N;
    cin>>N;

    for(int i = 0;i <= N;i++) {
        for(int j = 0;j < 2;j++) {
            for(int k = 0;k < 3;k++) {
                dp[i][j][k] = -1LL<<60;
            }
        }
    }

    dp[0][1][0] = 0;
    for(int i = 0;i < N;i++) {
        cin>>A[i];
        for(int j = 0;j < 2;j++) {
            for(int k = 0;k < 3;k++) {
                if(j+k < 3) {
                    dp[i+1][1][k+j] = max(dp[i+1][1][k+j],dp[i][j][k]);
                }
                if(j == 1) {
                    dp[i+1][0][k] = max(dp[i+1][0][k],dp[i][j][k]+A[i]);
                }
            }
        }
    }

    if(N % 2 == 0) {
        cout<<max(dp[N][1][0],dp[N][0][1])<<endl;
    } else {
        cout<<max(dp[N][0][2],dp[N][1][1])<<endl;
    }

    return 0;
}


Measured memory_bytes: 14096
#include<iostream>

using namespace std;

int main(void) {

	int i = 0, n, h, w, m = -1;
	int H[300], W[300];

	do {

		m = m + 1;
		cin >> H[m] >> W[m];

	} while (H[m] != 0 && W[m] != 0);

	do {

		h = H[i];
		w = W[i];

		if (h == 0 && w == 0) {
			break;
		}

		else {

			for (n = 0; n < h; n++) {

				for (int i = 0; i < w; i++) {

					if (n == 0 || n == h - 1 || i == 0 || i == w - 1)
						cout << "#";

					else
						cout << ".";

				}
				cout << endl;
			}

			cout << endl;

			i++;

		}
	} while (i);

	return 0;

}

Measured memory_bytes: 3048
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;


vector<int>  dx = {1,-1,0,0};
vector<int>  dy = {0,0,1,-1};


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

	int S = 0;
	int tmp = stoi(N);
	for (int i = 0; i < N.size(); i++) {
		S += N[i] - '0';	
	}
	if (tmp % S == 0) {
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())  # N個の町, 1移動するたびにA, テレポートのB
X = list(map(int, input().split()))
ans = 0
now_x = X[0]
for i in range(1, N):
    ans += min((X[i] - now_x) * A, B)
    now_x = X[i]
print(ans)


Measured memory_bytes: 14224
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, std::vector<long long> P){
  vector<ll> sum(N, 0);
  sum[0] = P[0];
  for(ll i=1; i<N; i++) {
    if(P[i]<sum[i-1])
      sum[i] = P[i];
    else
      sum[i] = sum[i-1];
  }
  ll ans = 0;
  for(ll i=0; i<N; i++) {
    if(sum[i]>=P[i])
      ans++;
  }
  
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> P(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&P[i]);
  }
  solve(N, std::move(P));
  return 0;
}



Measured memory_bytes: 3456
S=[x for x in input()]
T=S[::-1]
start=0
end=0
for i in range(len(S)):
  if S[i]=='A':
    start=i
    break
for i in range(len(T)):
  if T[i]=='Z':
    end=i
    break
    
print(len(S)-end-start)

Measured memory_bytes: 12100
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        N: usize,
    }

    let mut ans: i64 = 0;
    for i in (1..=N).filter(|i| i % 2 == 1) {
        let mut mp: HashMap<usize, usize> = HashMap::new();

        // 制約的にsqrt()じゃなくてもいける
        let mut rest = i;
        for p in 2..N {
            if i % p == 0 {
                let mut cnt: usize = *mp.get(&p).unwrap_or(&0);
                while rest % p == 0 {
                    rest /= p;
                    cnt += 1;
                }

                mp.insert(p, cnt);
            }
        }

        if rest != 1 {
            mp.insert(rest, 1);
        }

        // 約数の個数を数える
        let mut loc_ans = 1;
        for (_k, v) in mp.iter() {
            loc_ans *= v + 1;
        }

        if loc_ans == 8 {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2164
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map
#include<cmath>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 10000007

typedef  long long ll;

using namespace std;

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

ll deg(int i){
  ll ret = 1;
  while(i != 0){
    if(i/10 == 0){
      break;
    }
    i/=10;
  }
  return i;
}

void solve(){
 ll k;
 cin >> k;
 ll ans = 0;
 for(int a = 1;a < k+1;a++){
   for(int b = 1;b < k+1;b++){
     for(int c = 1;c < k+1;c++){
       ans += gcd(a,gcd(b,c));
     }
   }
 }
 cout << ans << endl;
}


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


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

int main() {
    int n; cin >> n;
    char bag[n];
    set<char> color;

    for (int i = 0; i < n; i++) {
        cin >> bag[i];
        color.insert(bag[i]);
    }

    cout << (color.size() == 3 ? "Three" : "Four") << endl;

    return 0;
}

Measured memory_bytes: 256
# frozen_string_literal: true

n = gets.to_i
a = gets.split.map(&:to_i).sort

b = a.pop

c = a.map { |e| ((b - e) - e).abs }.sort[0]

e1 = (b - c) / 2
e2 = (b + c) / 2

if a.include?(e1)
  puts "#{b} #{e1}"
else
  puts "#{b} #{e2}"
end


Measured memory_bytes: 11632
#include <stdio.h>

#define NIL -1

struct Node{
  int p;
  int l;
  int r;
};

struct Node t[100005];
int n;

void pre(int u){
  if(u==NIL)return;
  printf(" %d",u);
  pre(t[u].l);
  pre(t[u].r);
}

void in(int u){
  if(u==NIL)return;
  in(t[u].l);
  printf(" %d",u);
  in(t[u].r);
}

void po(int u){
  if(u==NIL)return;
  po(t[u].l);
  po(t[u].r);
  printf(" %d",u);
}

int main(){

  int i,n,v,r;
  scanf("%d",&n);

  for(i=0;i<n;i++)t[i].p=t[i].l=t[i].r = NIL;
    
  for(i=0;i<n;i++){
    scanf("%d",&v);
    scanf("%d",&t[v].l);
    scanf("%d",&t[v].r);
    t[t[v].l].p = t[t[v].r].p = v;

  }
  for(i=0;i<n;i++)if(t[i].p==NIL)break;

  printf("Preorder\n");
  pre(i);
  printf("\nInorder\n");
  in(i);
  printf("\nPostorder\n");
  po(i);
  printf("\n");
 
  return 0;
}



Measured memory_bytes: 2132
import math
Q=int(input())
for roop in range(Q):
    X,Y=map(int,input().split())
    A=min([X,Y])
    B=max([X,Y])
    if A==B:
        print(2*A-2)
    elif A+1==B:
        print(2*A-2)
    else:
        C=int(math.sqrt(A*B))
        while(True):
            if C**2>=A*B:
                C-=1
            elif (C+1)**2<A*B:
                C+=1
            else:
                break
        if C*(C+1)>=A*B:
            print(2*C-2)
        else:
            print(2*C-1)


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

using namespace std;


int main()
{


  int N, M;
  cin >> N;
  cin >> M;

  vector<vector<int> > jobs(M);
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    if ((M - a) >= 0) {
      jobs[M - a].push_back(b);
    }
  }

  priority_queue<int> p_que;
  long long v = 0;
  for (int i = M - 1; i >= 0; --i) {
    for (auto job : jobs[i]) {
      p_que.push(job);
    }
    if (p_que.empty()) {
      continue;
    }
    v += p_que.top();
    p_que.pop();
  }
  cout << v;
  return 0;
}



Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define ll long long
#define fast cin.tie(0);cout.tie(0);
#define order ios::sync_with_stdio(0);
using namespace std;
int t;
ll n,k,ans;
int main()
{
    cin>>n>>k;
    ll d=n/k;
    n-=d*k;
    ans=n;
    n-=k;
    n*=-1;
    n=min(n,ans);
    cout<<n;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int MAX(int a,int b){return a<b?b:a;}
//int P[1010],L[1010],R[1010],H[1010],C=1;
int P[3][1010],H[1010],C=1;
//int hyouka(int i,int x){return N[i]<=x?N[i]<x?-1:0:1;}
char N[1010][110];
int hyouka(int i,char *s){return strcmp(s,N[i]);}
int h(int a){return H[P[2][a]]-H[P[1][a]];}
void rot(int a,int t){//L==1,R==2
  int b=P[3-t][a],r=P[0][a];
  P[1][r]==a?(P[1][r]=b):(P[2][r]=b);
  if(P[2][b])P[0][P[2][b]]=a;
  P[3-t][a]=P[t][b];
  P[t][b]=P[0][b];
  P[0][b]=P[0][a];
  P[0][a]=b;
  H[a]=MAX(H[P[1][a]],H[P[2][a]])+1;
  H[b]=MAX(H[P[1][b]],H[P[1][b]])+1;
}
void make(int p,int t,char *s){
  P[t][p]=C;
  P[0][C]=p;
  strcpy(N[C],s);
  H[C]=1;
  if(p)H[p]=MAX(2,H[p]);
  C++;
}
int mfind(char *x){
  int i,j,r,n;
  if(C==1){
    make(0,1,x);
    return 1;
  }
  for(i=P[1][0];r=hyouka(i,x);i=n){//printf("%d %s\n",r,x);
    if(r<0){
      if(P[1][i]==0){
	make(i,1,x);
     }
      n=P[1][i];
    }
    else{
      if(P[2][i]==0){
	make(i,2,x);
      }
      n=P[2][i];
    }
  }//printf("%d\n",i);
  //for(j=0;j<C;j++){
  // printf(":%d %d %d %d %s\n",P[0][j],P[1][j],P[2][j],H[j],N[j]);
  //}
  j=P[0][i];
  while(1){
    H[j]=MAX(H[P[1][j]],H[P[2][j]])+1;
    if(h(j)<-1){
      if(h(P[1][j])>0)rot(P[1][j],1);
      rot(j,2);
      break;
    }
    if(h(j)>1){
      if(h(P[2][j])<0)rot(P[2][j],2);
      rot(j,1);
      break;
    }
    if(h(j)==0)break;
    j=P[0][j];
    if(j==0)break;
  }//printf("%d\n",i);
  return i;
}      
void prim(int n){
  int i;
  if(P[1][n])prim(P[1][n]);
  for(i=0;i<H[n];i++)printf("  ");
  printf("%s\n",N[n]);
  if(P[2][n])prim(P[2][n]);
}
/*int main(){
  int n,i;
  //for(i=0;i<100;i++)H[i]=-1;
  char s[10];
  while(~scanf("%s",s)){
    printf("%d\n",mfind(s));
    for(i=0;i<C;i++){
      printf("%d %d %d %d %s\n",P[0][i],P[1][i],P[2][i],H[i],N[i]);
    }
    prim(P[1][0]);printf("end\n");
  }
  return 0;
}/*/
int main(){
  int i,l,max=0,mj=1,r,a[1010]={};
  char *c,*mi,s[1020];
  fgets(s,1010,stdin);
  mi=strtok(s," \n");
  a[mj=mfind(mi)]++;
  max=strlen(mi);
  // printf("%s\n",mi);
  while(c=strtok(NULL," \n")){
    //printf("%s\n",c);
    a[r=mfind(c)]++;
    //printf("%d\n",r);
    l=strlen(c);//printf("%s %d\n",mi,l);
    if(max<l){
      max=l;
      strcpy(mi,c);
    }//printf("a\n");
    if(a[r]>a[mj])mj=r;//printf("a\n");
  }
  //printf("%s %d\n",mi,mj);
  printf("%s %s\n",N[mj],mi);
  return 0;
  }//*/

Measured memory_bytes: 564
// luogu-judger-enable-o2
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int b;
    cin>>s;
    int k=0;
    for (int i=0; i<s.length(); ++i)
        if (s[i]=='C'&& k==0)
        {
            ++k;
            b=i;
            break;
        }
    for (int i=b; i<s.length(); ++i)
        if (s[i]=='F'&& k==1)
        {
            ++k;
            break;
        }
        if (k==2) 
        printf("Yes\n");
        else
        printf("No\n");     
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String a = sc.next();
    String b = sc.next();
    String c = sc.next();
    
    String x = a.substring(0, 1);
    String y = b.substring(0, 1);
    String z = c.substring(0, 1);
    
    System.out.println(x + y + z);
  }
}

Measured memory_bytes: 23764
n=int(input())
info=list(map(int,input().split()))
info.insert(0,0)
box=[0]*(n+1)
ball=0
num=[] #ボールを入れた番号を記憶
for i in range(n,0,-1):
    j=i
    total=0
    while j<=n:
        total+=box[j]
        j+=i
    if total%2!=info[i]: #箱にボール入れる
        box[i]=1
        ball+=1
        num.append(i)

print(ball)
if ball!=0:
    l=len(num)
    for i in range(l):
        print(num[i],end=" ")

Measured memory_bytes: 12884
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

int h1,m1,h2,m2,k;

int main(){
	h1=read(),m1=read(),h2=read(),m2=read(),k=read();
	printf("%d\n",h2*60+m2-h1*60-m1-k);
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fast_io ios::sync_with_stdio(false);cin.tie(NULL);
#define input freopen("Test.txt","r",stdin)
#define output freopen("Output.txt","w",stdout);
#define what_is(x) cout<<#x<<" is "<<x<<endl;
#define pb push_back
#define eb emplace_back
#define inf 1000000000
const double pi = 3.141592653589793238460;
#define mod 1000000007

int main()
{
    fast_io;
    ///input;
    ///output;
    int N; cin>>N;
    int arr[N];
    for(int i=0;i<N;i++)
        cin>>arr[i];
    int ans = 1;
    for(int i=0;i<N;i++)
    {
        if(arr[i]==ans)
        {
            ans++;
        }
    }
    
    if(ans==1)
        cout<<"-1"<<endl;
    else
    {
        ans = N-ans+1;
        cout<<ans<<endl;
    }
    return 0;
}

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

int main()
{
	long long N, K;
	cin >> N >> K;
	unsigned long long num[100001] = { 0 };
	for (long long i = 0; i < N; i++) {
		long long a, b;
		cin >> a >> b;
		num[a] += b;
	}
	unsigned long long sum = 0;
	for (long long i = 1; i < 100001; i++) {
		sum += num[i];
		if (K <= sum) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1024
#include <iostream>

#include <map>
#include <string>

#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cinttypes>


using namespace std;

int main()
{
	uint64_t w, h;
	cin >> h >> w;

	if (w == 1 || h == 1)
	{
		cout << 1 << endl;
	}
	else
	{
		uint64_t a = (w + 1) / 2;
		uint64_t b = w / 2;

		uint64_t ans = (h + 1) / 2 * a + h / 2 * b;
		cout << ans << endl;
	}

	

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<sstream>
#include<set>

using namespace std;

#define forn(i,n) for(int i=0;i<(int)(n); i++)
#define forsn(i,s,n) for(int i=(s);i<(int)(n); i++)
#define esta(x,v) (find((v).begin(),(v).end(),(x)) !=  (v).end())
#define index(x,v) (find((v).begin(),(v).end(),(x)) - (v).begin())
#define debug(x) cout << #x << " = "  << x << endl
#define pb push_back
#define mp make_pair

typedef long long tint;
typedef pair<int,int> pint;
typedef pair<tint,tint> ptint;
typedef unsigned long long utint;
typedef long double ldouble;

typedef vector<int> vint;

int toNumber (string s)
{
	int Number;
	if ( ! (istringstream(s) >> Number) ) Number = 0; // el string vacio lo manda al cero
	return Number;
}

string toString (int number)
{
    ostringstream ostr;
    ostr << number;
    return  ostr.str();
}

tint ele(tint a, tint b){
	if(b==0)return 1;
	if(b%2==0){
		return ele(a*a, b/2);
	}else{
		return a*ele(a*a, b/2);
	}
}

tint mcd(tint a, tint b){
	if(a==0)return b;
	return mcd(b%a, a);
}

double d_abs(long a, long b){
	if(a>b){
		return a-b;
	}
	return b-a;
}

void solve(){
	tint a, b, c, n;
	string s;
	vector<tint> v;
	map<int, int> m;
	cin>>n>>a;
	vector< vector<int> > gr(n+1);
	forn(i, a){
		cin>>b>>c;
		gr[b].pb(c);
		gr[c].pb(b);
		m[b]++;
		m[c]++;
	}
	tint cant=0;
	forn(i, n){
		if (m[i+1]%2){
			forn(j, gr[i+1].size()){
				if(m[gr[i+1][j]]%2){
					cout<<"NO"<<endl;
					return;
				}
			}
		}
	}
	cout<<"YES"<<endl;
}




int main (){
	int T;
	T=1;
	while(T--){
		solve();
	}
}


Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double eps=1e-8;
int main(void)
{
	LL a,b,c; scanf("%lld%lld%lld",&a,&b,&c);
	if(4ll*a*b<(c-a-b)*(c-a-b)&&(c-a-b)>0) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using Graph = vector<vector<pair<int, int>>>;

constexpr int MOD = 1000000007;

template <typename T> T stable_add(T x, T y) {
    T m = numeric_limits<T>::min();
    if (x == m || y == m) { return m; }
    T M = numeric_limits<T>::max();
    if (x == M || y == M) { return M; }
    return x + y;
}

vi dijkstra(const Graph& G, int s) {
    int v = G.size();

    // Initialize cost.
    vi cost(v);
    fill(all(cost), INT_MAX);
    cost[s] = 0;

    // Priority queue: (-cost, v).
    priority_queue<pair<int, int>> pq;
    pq.emplace(0, s);

    // Seen or not.
    vb seen(v, false);

    while (!pq.empty()) {
        pair<int, int> curr = pq.top();
        pq.pop();

        int curr_v = curr.second;
        int curr_cost = -curr.first;

        if (seen[curr_v]) { continue; }
        seen[curr_v] = true;

        for (pair<int, int> next : G[curr_v]) {
            int next_v = next.first;
            int edge = next.second;

            if (!seen[next_v] && cost[next_v] > stable_add(curr_cost, edge)) {
                cost[next_v] = stable_add(curr_cost, edge);
                pq.emplace(-cost[next_v], next_v);
            }
        }
    }
    return cost;
}

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

    int n;
    cin >> n;

    Graph G(n);
    rep(_, 0, n - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        G[u - 1].emplace_back(v - 1, w % 2);
        G[v - 1].emplace_back(u - 1, w % 2);
    }

    vi cost = dijkstra(G, 0);
    rep(i, 0, n) { cout << cost[i] % 2 << endl; }

    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    char s[h][w];
    rep(i, 0, h) {
        rep(j, 0, w) {
            cin >> s[i][j];
        }
    }

    int ans = INF;
    rep(i, 0, 1 << (h - 1)) {
        int group[h] = {};
        int gnum = 0;
        rep(j, 0, h) {
            group[j] = gnum;
            if (i & (1 << j)) {
                gnum++;
            }
        }
        gnum++;
        int lines = gnum - 1;
        int cnt[gnum][w] = {};
        rep(j, 0, h) {
            rep(l, 0, w) {
                cnt[group[j]][l] += s[j][l] - '0';
            }
        }
        int now[gnum] = {};
        rep(j, 0, w) {
            rep(l, 0, gnum) {
                now[l] += cnt[l][j];
            }
            bool ok = true;
            rep(l, 0, gnum) {
                if (now[l] > k) {
                    lines++;
                    ok = false;
                    break;
                }
            }
            if (!ok) {
                rep(l, 0, gnum) {
                    now[l] = cnt[l][j];
                    if (now[l] > k) {
                        lines = INF;
                    }
                }
            }

        }
        ans = min(ans, lines);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n,w=map(int,input().split())
wv=[list(map(int,input().split())) for i in range(n)]
wv.sort(key=lambda x:-x[1])#reverse
wv.sort(key=lambda x:x[0])
#print(wv)
w0=wv[0][0]
x=[[0],[0],[0],[0]]
for i in range(n):
    z=wv[i][0]-w0
    k=wv[i][1]+x[z][-1]
    l=len(x[z])
    if l*wv[i][0]<=w:
        x[z].append(k)
ma=0
l3=len(x[3])
l2=len(x[2])
l1=len(x[1])
for i in range(l3):
    d=w-i*(w0+3)
    for j in range(l2):
        d=w-i*(w0+3)-j*(w0+2)
        if d>=0:
            for k in range(l1):
                d=w-i*(w0+3)-j*(w0+2)-k*(w0+1)
                if d>=0:
                    ma_sub=x[3][i]+x[2][j]+x[1][k]+x[0][min(d//w0,len(x[0])-1)]
                    ma=max(ma,ma_sub)
                else:
                    break
        else:
            break

print(ma)


Measured memory_bytes: 3192
#include<stdio.h>

int main()
{
    int S,h,p,m,s;
    scanf("%d",&S);

    h=S/3600;
    p=S%3600;
    m=p/60;
    s=p%60;

    printf("%d:%d:%d\n",h,m,s);



    return 0;
}



Measured memory_bytes: 2056
N = int(input())
A = [int(i) for i in input().split()]


count = len([i for i in A if i < 0])
B = []
for i in range(N):
    B.append(abs(A[i]))

ans = sum(B)
if count % 2 == 0:
    print(ans)
else:
    print(ans - min(B) * 2)

Measured memory_bytes: 14412
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll N, x, y;
  double d, t = 0;
  cin >> N;
  vector<pair<double, double>> town(N);
  for (ll i = 0; i < N; i++) {
    cin >> x >> y;
    town[i] = make_pair(x, y);
  }

  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      d = sqrt(pow(get<0>(town[i]) - get<0>(town[j]), 2) +
               pow(get<1>(town[i]) - get<1>(town[j]), 2));
      t += d * 2;
    }
  }
  cout << fixed << setprecision(10) << t / N << endl;
}


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

using namespace std;
using ll = long long;
int main() {
    string str;
    cin>>str;
    vector<char> v{'A','C','G','T'};
    int n = str.size();
    int ret = 0;
    for(int i=0;i<n;++i){
        for(int j=n-1;j>=i;j--){
            string tmp =str.substr(i,j-i+1);
            int count = 0;
            for(auto a : v){
                for(auto t : tmp){
                    if(a == t)count++;
                }
            }
            if(count == (int)tmp.size())ret =  max(ret,count);
        }
    }
    cout << ret <<endl;
    return 0;
}



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

int main(){    
  int A,B;
  cin >> A >> B;
  
  if(A > B) cout << 2*A - 1 << endl;
  else if (A < B) cout << 2*B - 1 << endl;
  else cout << 2*A << endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
t=sum(a)
mi=abs(t-2*a[0])
k=a[0]

for i in range(1,n-1):
    k=k+a[i]
    if abs(t-2*k) < mi:
        mi=abs(t-2*k)
print(mi)

Measured memory_bytes: 23800
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int INF = 2e9;
const int MAX = 2e5;
const int divisor = 998244353;
int n;
pair<int, int> a[MAX + 1];
int dp[MAX + 1];

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first >> a[i].second;
    }

    sort(a, a + n);

    dp[n] = 1;
    vector<pair<int, int>> L(1, {1e9, n});
    for (int k = n - 1; k >= 0; --k) {
        while (L.back().first < a[k].first + a[k].second) L.pop_back();
        dp[k] = (dp[k + 1] + dp[L.back().second]) % divisor;
        L.emplace_back(a[k].first, k);
    }

    cout << dp[0];
    return 0;
}


Measured memory_bytes: 3572
n=int(input())
itv=[]
for i in range(n):
  x,l=map(int,input().split())
  itv+=[(x+l,x-l)]
itv=sorted(itv)
l=-10**18
cnt=0
for t,s in itv:
  if l<=s:
    l=t
    cnt+=1
print(cnt)

Measured memory_bytes: 83792
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n, m, k;

	cin >> n >> m >> k;

	REP(i, n + 1) {
		REP(j, m + 1) {
			ll a = abs(i * m + j * n - 2 * i * j);

			if (a == k) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;
}


Measured memory_bytes: 256