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

using namespace std;

using ll = long long;

int main(){
    set<char> s;
    ll n;
    cin >> n;
    for(ll i = 0; i < n; ++i){
        char tmp; cin >> tmp;
        s.insert(tmp);
    }
    if(s.size() == 3)cout << "Three";
    else cout << "Four";
    return 0;
}


Measured memory_bytes: 256
data class Data(val c: Int, val s: Int, val f: Int)

fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val datas: List<Data> = (0 until n - 1).map {
        val (c, s, f) = readLine()?.split(" ")?.map { it.toInt() }!!
        Data(c, s, f)
    }

    // n駅については最後に0を出力すればよいので考えない
    for (i in datas.indices) {
        var total = datas[i].s + datas[i].c // 出発時間 + 運行時間

        // n-1駅についてはn駅より先の駅について考える必要はない
        if (i == datas.size - 1) {
            println(total)
            break
        }

        // 1 ~ n-2駅については、n-1までループして時間計算する
        for (j in (i + 1) until datas.size) {
            // j駅に到着してもj駅から電車が出ていない場合
            if (datas[j].s >= total) {
                total = datas[j].s + datas[j].c
                continue
            }

            // j駅に到着してからの待ち時間を計算する
            val diff = total - datas[j].s
            val remainder = diff % datas[j].f
            val waitTime = if (remainder == 0) 0 else datas[j].f - remainder
            total += (waitTime + datas[j].c)
        }

        println(total)
    }
    println(0)
}

Measured memory_bytes: 38340
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
#include<set>
using namespace std;
using ll = __int64_t;
using lll = __int128_t;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;
const ll mod=1e9+7;



int main(void){
      int n;
      cin>>n;
      string s;
      cin>>s;
      int ok=0;
      int ng=n/2+1;
      string t;
      while(ng-ok>1){
            int pos=(ok+ng)/2;
            bool good=false;
            for(int i=pos;i+pos<=n;i++){
                  if(i==pos){
                  t={};
                        for(int j=i;j<i+pos;j++){
                              t.push_back(s[j]);
                        }
                  }
                  else{
                        t.erase(t.begin());
                        t.push_back(s[i+pos-1]);
                  }
                  if(s.find(t)+pos<=i){
                        good=true;
                  }
            }
            if(good) ok=pos;
            else ng=pos;
      }
      cout<<ok<<endl;
      return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
int main()
{
  int res=0;
  char str[50];
  scanf("%s",str);
  REP(i,4){
    if(str[i] == '-')
      res--;
    else
      res++;
  }
  printf("%d\n",res);
  return 0;
}


Measured memory_bytes: 128
import heapq

n=int(input())
arr=list(map(int,input().split()))
q1=[]
tmp=0
for val in arr[:n]:
  heapq.heappush(q1,val)
  tmp+=val
sum1=[tmp]
for val in arr[n:2*n]:
  tmp=heapq.heappop(q1)
  if val>tmp:
    heapq.heappush(q1,val)
    sum1.append(sum1[-1]+(val-tmp))
  else:
    heapq.heappush(q1,tmp)
    sum1.append(sum1[-1])
q2=[]
tmp=0
for val in arr[2*n:]:
  heapq.heappush(q2,-val)
  tmp+=val
sum2=[tmp]
for val in arr[2*n-1:n-1:-1]:
  tmp=-heapq.heappop(q2)
  if val<tmp:
    heapq.heappush(q2,-val)
    sum2.append(sum2[-1]+(val-tmp))
  else:
    heapq.heappush(q2,-tmp)
    sum2.append(sum2[-1])
sum2=sum2[::-1]
ans=-10**18
for i in range(n+1):
  tmp=sum1[i]-sum2[i]
  ans=max(ans,tmp)
print(ans)

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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;
/*NodePointer head=NULL;*/

NodePointer listSearch(int key){
  NodePointer x;
  x=nil->next;
  while(x != nil && x->key != key){
    x=x->next;
  }
  return x;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if(t->prev!=nil) t->prev->next=t->next;
  else nil->next=t->next;
  
  if(t->next!=nil) t->next->prev=t->prev;
  else nil->prev=t->prev;
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer u = nil->prev;
  
  if ( u == nil ) return;
  deleteNode(u);
}

void delete(int key){

  NodePointer x = listSearch(key);

  if(x==nil) return;

  if(x->prev!=nil) x->prev->next = x->next;
  else nil->next=x->next;

  if(x->next!=nil) x->next->prev = x->prev;
  else nil->prev=x->prev;
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  if(nil->next!=nil){
    nil->next->prev=x;
  }
  if(nil->prev==nil){
    nil->prev=x;
  }
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ) {
      scanf("%d",&key);
      insert(key); np++; size++;
    }else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	scanf("%d",&key);
	delete(key);
	nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 36120
module ABC133

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_D

  ! variables for this <module>
  integer(INT32), private :: num_mountain

  ! arrays for this <module>
  integer(INT64), dimension(:), allocatable, private :: solution

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_D

    ! support variables for this <subroutine>
    integer(INT32) :: itr

    ! STEP.01
    ! read out given data (1/2)
    read(unit=INPUT_UNIT, fmt=*) num_mountain

    ! STEP.02
    ! allocate the array to store the given data & the answer of this task
    allocate( solution(1:num_mountain) )

    ! STEP.03
    ! read out given data (2/2)
    read(unit=INPUT_UNIT, fmt=*) solution(:)

    ! STEP.04
    ! calculate the answer of this task
    solution(:) = solution(:) * 2_INT32

    do itr = 2, num_mountain - 1, 1
      solution(itr) = solution(itr) - solution(itr - 1)
    end do

    if ( mod(num_mountain, 2_INT32) .eq. 0_INT32 ) then
      solution(num_mountain) = solution(num_mountain) - solution(num_mountain - 1)
    else
      solution(num_mountain) = solution(num_mountain) + solution(num_mountain - 1)
    end if

    solution(num_mountain) = solution(num_mountain) / 2_INT64

    solution(num_mountain - 1) = solution(num_mountain) - solution(num_mountain - 1)

    do itr = 1, num_mountain - 2, 1
      if ( mod(itr, 2_INT32) .eq. 0_INT32 ) then
        solution(itr) = solution(itr) + solution(num_mountain - 1)
      else
        solution(itr) = solution(itr) - solution(num_mountain - 1)
      end if
    end do

    ! STEP.05
    ! output the answer of this task
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='no') solution(num_mountain - 1)

    do itr = 2, num_mountain - 1, 1
      write(unit=OUTPUT_UNIT, fmt='(1X,I0)', advance='no') solution(itr - 1)
    end do

    write(unit=OUTPUT_UNIT, fmt='(1X,I0)', advance='no') solution(num_mountain)

    ! STEP.06
    ! deallocate the array to store the given data & the answer of this task
    deallocate( solution )

    ! STEP.END
    return

  end subroutine task_D

end module ABC133

program main

  ! <module>s to import
  use, non_intrinsic :: ABC133

  ! require all variables to be explicitly declared
  implicit none

  call task_D

end program main

Measured memory_bytes: 2688
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int N, M, a[1000][4];
int dp[1000];
string S;
int main() {
	while (cin >> N >> M) {
		for (int i = 0; i < N; i++) {
			S = "";
			while (S == "") {
				getline(cin, S);
			}
			cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3];
		}
		int maxn = 0;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 1000; j++) {
				dp[j] = 0;
			}
			for (int j = 0; j < N; j++) {
				for (int k = 0; k <= M; k++) {
					dp[k + a[j][0]] = max(dp[k + a[j][0]], dp[k] + a[j][i + 1]);
				}
			}
			for (int j = 0; j <= M; j++)maxn = max(maxn, dp[j]);
		}
		cout << maxn << endl;
	}
	return 0;
}

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

int main() {
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx>> ty;
  int ver_total = abs(ty-sy);
  int hor_total = abs(tx-sx);
  pair<string,string> ver_direction;
  (ty-sy > 0) ? ver_direction =  make_pair('U','D') : ver_direction = make_pair('D','U');  
  pair<string,string> hor_direction;
  (tx-sx > 0) ? hor_direction = make_pair('R','L') : hor_direction = make_pair('L','R');  
  string temp = "";
  string path_1 = "";
  string path_2 = "";
  for(int i = 0 ; i < ver_total; ++ i) temp += ver_direction.first;
  for(int i = 0 ; i < hor_total; ++ i) temp += hor_direction.first;
  path_2 += hor_direction.second; 
  path_2 += ver_direction.first;
  path_2 += temp;
  path_1 += temp;
  path_2 += hor_direction.first; 
  path_2 += ver_direction.second;
  temp = "";
  for(int i = 0 ; i < ver_total; ++ i) temp += ver_direction.second;
  for(int i = 0 ; i < hor_total; ++ i) temp += hor_direction.second;
  path_2 += hor_direction.first; 
  path_2 += ver_direction.second;
  path_2 += temp;
  path_1 += temp;
  path_2 += hor_direction.second; 
  path_2 += ver_direction.first;
  string answer = path_1 + path_2;
  cout << answer << endl;
}

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

using namespace std;

int main(){
    string s,t;
    cin>>s>>t;
    int ans=0;
    for (int i = 0; i < 3; ++i) {
        if(s[i]==t[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#define N 100000

using namespace std;

int W[N];
int n,k;
int ans;

int check( int P ) {
    int i = 0;
    int v = 0;
    int sum = 0;
    int cnt = 0;
    while ( cnt < k ) {
        sum = 0;
        while ( sum + W[i] <= P ) {
            sum += W[i++];
            v++;
            if ( v >= n ) {
                return 1;
            }
        }
        cnt++;
    }

    return 0;
}

int binarySearch(int L, int R) {
    int P;
    int mid;
    mid = (L + R) / 2;
    P = mid;

    if (mid > L) {
        if (check(P)) {
            binarySearch(L, mid);
        } else {
            binarySearch(mid, R);
        }
    }
    else {
        if ( check(P) == 1 ) ans = P;
        else ans = P + 1;
    }
}



int main() {

    int R,L;
    int Wsum = 0;

    scanf("%d %d", &n, &k);

    for ( int i = 0; i < n; ++i ) {
        cin >> W[i];
        Wsum += W[i];
    }


    L = 0;
    R = Wsum;

    binarySearch(L,R);


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3572
// 木の直径
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>

using namespace std;

#define MAX 100000
#define INFTY ( 1 << 30 )

class Edge
{
    public:
        int t, w;
        Edge(){}
        // t : 辺の end 側,  w : 辺の重み
        Edge(int t, int w): t(t), w(w){}
};

vector<Edge> G[MAX];
int n;
// 任意のスタート点から、各頂点までの距離を保持する配列
int d[MAX];

bool vis[MAX];
int cnt;

void bfs(int s)
{
    for(int i = 0; i < n; i++)
    {
        d[i] = INFTY;
    }

    queue<int> Q;
    // スタート点の情報を設定する
    Q.push(s);
    d[s] = 0;

    int u;

    while( !Q.empty() )
    {
        u = Q.front();
        Q.pop();

        for(int i = 0; i < G[u].size(); i++)
        {
            Edge e = G[u][i];

            // 未訪問の頂点について距離を求める
            if( d[e.t] == INFTY )
            {
                d[e.t] = d[u] + e.w;
                Q.push(e.t);
            }
        }
    }
}

void solve()
{
    // 適当な始点 s から最も遠い節点 tgt を求める
    bfs(0);

    int maxv = 0;
    int tgt = 0;

    for(int i = 0; i < n; i++)
    {
        if( d[i] == INFTY )
        {
            continue;
        }

        if( maxv < d[i] )
        {
            maxv = d[i];
            tgt = i;
        }
    }

    // tgt から最も遠い節点の距離 maxv を求める
    bfs(tgt);
    maxv = 0;

    for(int i = 0; i < n; i++)
    {
        if( d[i] == INFTY )
        {
            continue;
        }

        maxv = max(maxv, d[i]);
    }

    cout << maxv << endl;
}

int main(void)
{
    int s, t, w;

    cin >> n;

    for(int i = 0; i < n - 1; i++)
    {
        cin >> s >> t >> w;

        G[s].push_back(Edge(t, w));
        G[t].push_back(Edge(s, w));
    }

    solve();

    return 0;
}



Measured memory_bytes: 9824
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
string str;
int xs[] = {0, 1, 0, -1}, ys[] = {1, 0, -1, 0};
bool m[20][20];
void dfs(int x, int y){
    for(int i = 0;i < 4;i++){
	int tx = x + xs[i], ty = y + ys[i];
	if(tx < 0 || tx >= 12 || ty < 0 || ty >= 12)continue;
	if(m[tx][ty]){
	    m[tx][ty] = false;
	    dfs(tx, ty);
	}

    }
}

int main(){
    while(true){
	int res = 0;
	for(int i = 0;i < 12;i++){
	    if(cin >> str){
		for(int j = 0;j < str.size();j++){
		    m[i][j] = str[j] == '1';
		}
	    }
	    else return 0;
	}
	for(int i = 0;i < 12;i++){
	    for(int j = 0;j < 12;j++){
		if(m[i][j]){
		    res++;
		    dfs(i, j);
		}		
	    }
	}
	cout << res << endl;
    }
}

Measured memory_bytes: 1180
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools

def unko(x, y, z):
    return x**2+y**2+z**2+x*y+x*z+y*z

sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

N = int(input())
ans = [0]*(N+1)
f=0
#a, b, c = map(int, input().split())
rootN = int(math.sqrt(N))

for i in range(1,rootN):
    for j in range(1, rootN):
        for k in range(1, rootN):
            f=unko(i,j,k)
            if(f>N):
                pass
            else:
                ans[f]+=1
                #if(i==j and j==k):
                    #ans[f]-=2

for i in range(1, N+1):
    print(ans[i])


Measured memory_bytes: 76452
#include <iostream>
#include <iomanip>

double getValue(double val);

int main(void)
{
    double a,b,c,d,e,f;
    double x,y;
    std::cout << std::fixed << std::setprecision(3);
    while(std::cin >> a >> b >> c >> d >> e >> f){
        x = getValue((c * e - b * f) / (a * e - b * d));
        y = getValue((f * a - c * d) / (a * e - b * d));
        std::cout << x << " " << y << std::endl;
    }
    return 0;
}

double getValue(double val)
{
    double result;
    val *= 1000;
    if(val >= 0.0){
        result = (int)(val + 0.5);
    }
    else{
        result = (int)(val - 0.5);
    }
    return result / 1000;
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _overload4(_1,_2,_3,_4,name,...) name
#define _overload3(_1,_2,_3,name,...) name
#define _overload2(_1,_2,name,...) name
#define _re(n) _rep(i,n)
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(ll i=a;i<b;++i)
#define _repc(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) _overload4(__VA_ARGS__,_repc,_repi,_rep,_re)(__VA_ARGS__)
#define _rre(n) _rrep(i,n)
#define _rrep(i,n) _rrepi(i,0,n)
#define _rrepi(i,a,b) for(ll i=b-1;i>=a;i--)
#define _rrepc(i,a,b,c) for(ll i=a+(b-a-1)/c*c;i>=a;i-=c)
#define rrep(...) _overload4(__VA_ARGS__,_rrepc,_rrepi,_rrep,_rre)(__VA_ARGS__)
#define sum(...) accumulate(range(__VA_ARGS__),0)
#define _range(i) (i).begin(),(i).end()
#define _rangek(i,k) (i).begin(),(i).begin()+k
#define range(...) _overload2(__VA_ARGS__,_rangek,_range)(__VA_ARGS__)
#define LINF (ll)1000000000000000000
#define MOD (ll)1000000007
#define INF (int)1000000007
#define Yes(i) out(i?"Yes":"No")
#define YES(i) out(i?"YES":"NO")
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,size) vector<type> name(size);
#define VEC(type,name,size) vector<type> name(size);in(name)
struct aaa{aaa(){cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}aaaaaaa;
template<typename T>
inline constexpr T gcd (T a,T b) {if(a==b)return a;else return gcd(b,(a-1)%b+1);}
inline void in() {}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec);
template<typename T,size_t size>
istream& operator >> (istream& is, array<T,size>& vec);
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p);
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec);
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p);
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p){is >> p.first;is >> p.second;return is;}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){os << vec[0];rep(i,1,vec.size()){os << ' ' << vec[i];}return os;}
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){cin>>head;in(move(tail)...);}
template <class T>
inline void out(T t){cout<<t<<'\n';}
inline void out(){cout<<'\n';}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){cout<<head<<' ';out(move(tail)...);}


int main(){
    INT(a,b,c);
    out(a/gcd(a,b)*b/gcd(a,b)*c);
}
















Measured memory_bytes: 3164
pub struct Poper<'a> {
	iter: std::str::SplitWhitespace<'a>,
}

impl<'a> Poper<'a> {
	pub fn new(iter: std::str::SplitWhitespace) -> Poper {
		Poper { iter: iter }
	}
	pub fn read<T: std::str::FromStr>(&mut self) -> T
	where
		<T as std::str::FromStr>::Err: std::fmt::Debug,
	{
		self.iter.next().unwrap().parse().unwrap()
	}
}

fn main() {
	let input = {
		use std::io::Read;
		let mut s = String::new();
		std::io::stdin().read_to_string(&mut s).unwrap();
		s
	};
	let mut iter = Poper::new(input.split_whitespace());

	let n: usize = iter.read();
	let a_list: Vec<u32> = (0..n).into_iter().map(|_| iter.read()).collect();

	let mut top: Option<(usize, u32)> = None;
	let mut sec: Option<(usize, u32)> = None;

	for a in a_list.into_iter().enumerate() {
		let a = match top {
			None => {
				top = Some(a);
				continue;
			}
			Some(t) => {
				if t.1 < a.1 {
					top = Some(a);
					t
				} else {
					a
				}
			}
		};
		match sec {
			None => {
				sec = Some(a);
				continue;
			}
			Some(t) => {
				if t.1 < a.1 {
					sec = Some(a);
				}
			}
		};
	}

	for i in 0..n {
		if let Some((j, a)) = top {
			if i == j {
				if let Some((_, b)) = sec {
					println!("{}", b);
				}
			} else {
				println!("{}", a);
			}
		}
	}

}


Measured memory_bytes: 7676
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

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

    int hc = 0, wc = 0;

    if(h > w) {
        for(int i = 1; i <= w; i++) {
            hc = i;
            if(h*i >= n) {
                cout << i << endl;
                return 0;
            }
        }
        w = w - hc;
        for(int i = 1; i <= h; i++) {
            wc = i;
            if(hc*h+w*i >= n) {
                break;
            }
        }
    }
    else if(h <= w) {
        for(int i = 1; i <= h; i++) {
            wc = i;
            if(w*i >= n) {
                cout << i << endl;
                return 0;
            }
        }
        h = h - wc;
        for(int i = 1; i <= w; i++) {
            hc = i;
            if(wc*w+h*i >= n) {
                break;
            }
        }
    }

    cout << wc + hc << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9; //1(1倍)e(指数)9(10^9)
int main() {
	vector<int> time(5);
	cin >> time[0] >> time[1] >> time[2] >> time[3] >> time[4];

	vector<int> index = { 0, 1, 2, 3, 4 }; //順番の並び替え用の配列

	int bestTime = inf;

    do { //最初に一度実行
		int ans = 0;
		for (int i = 0; i < 5; ++i) {
			while (ans % 10 != 0) ans += 1; //10で割り切れるまで+1。10の倍数でしか次の注文ができないから
			ans += time[index[i]];
		}
		bestTime = min(bestTime, ans);
	} while (next_permutation(index.begin(), index.end())); //indexの組合わえを全探索してくれる

    cout << bestTime << endl;
	return 0;
}

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

#define ll long long

int main(){
    int N,S;
    cin >> N >> S;
    vector<ll>A(N);
    const ll MOD= 998244353;
    for(int i=0;i<N;i++)cin>>A[i];

    ll dp[3030][3030][3];
    dp[0][0][0]=1;
    for(int i=0;i<N;i++){
        for(int s=0;s<=S;s++){
            dp[i+1][s][0]+=dp[i][s][0];
            dp[i+1][s][1]+=dp[i][s][0]+dp[i][s][1];
            dp[i+1][s][2]+=dp[i][s][0]+dp[i][s][1]+dp[i][s][2];
            for(int k=0;k<3;k++)dp[i+1][s][k]%=MOD;
            if(s+A[i]<=S){
                dp[i+1][s+A[i]][1]+=dp[i][s][0]+dp[i][s][1];
                dp[i+1][s+A[i]][2]+=dp[i][s][0]+dp[i][s][1];
                for(int k=1;k<3;k++)dp[i+1][s+A[i]][k]%=MOD;
            }
        }
    }
    cout<< dp[N][S][2]<<endl;
    return 0;
}


Measured memory_bytes: 215168
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb puah_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

int main(){
    int n; cin >> n;
    vector<vector<int> > lis(n, vector<int>(3));
    REP(i, 0, n){cin >> lis[i][0] >> lis[i][1] >> lis[i][2];}
    int x = 0, y = 0;
    int t = 0;
    REP(i, 0, n){
        int dx = abs(lis[i][1] - x), dy = abs(lis[i][2] - y);
        int dt = lis[i][0] - t;
        if(dx + dy <= dt && (dt - (dx + dy)) % 2 == 0){
            x = lis[i][1];
            y = lis[i][2];
            t = lis[i][0];
            continue;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;

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

Measured memory_bytes: 256
#include<stdio.h>

void trace(int A[], int N){
    int  i;
    for(i=0; i<N; i++){
        if(i>0)printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertionSort(int A[], int N){
    int j,i,v;
    for(int i=1; i<N; i++){
        v = A[i];
        j=i-1;
        while(j>=0 && A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        trace(A,N);
        
    }
}

int main(){
    int N,i,j;
    int A[100];
    
    scanf("%d",&N);
    for(i=0; i<N; i++) scanf("%d", &A[i]);
    
    trace(A,N);
    insertionSort(A,N);
    
    return 0;
}


Measured memory_bytes: 2700
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main()
{
  int N;cin >> N;
  vector<ll> v(N);
  ll XOR = 0;
  rep(i,N){
    cin >> v[i];
    XOR ^= v[i];
  }

  rep(i,N) v[i] &= ~XOR;

  int rank = 0;
  per(j,60){
    int k = -1;
    repp(i,rank,N){
      if(v[i]&(1ll<<j)){
        k = i;
        break;
      }
    }
    if(k==-1)continue;

    if(k>rank) v[rank] ^= v[k];
    repp(i,rank+1,N){
      v[i] = min(v[i],v[i]^v[rank]);
    }
    ++rank;
    }

  ll x = 0;
  rep(i,N) x = max(x,x^v[i]);
  cout << (x*2) + XOR << endl;
	return 0;
}



Measured memory_bytes: 1152
//#define NDEBUG

#include <bits/stdc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define F first
#define S second
#define B back()
#define FR front()
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}
#define pii pair<int, int>
#define pll pair<ll, ll>
#define modadd(a, b) (((a % MOD) + (b % MOD)) % MOD)
#define modtimes(a, b) (((a % MOD) * (b % MOD)) % MOD)
#define iceil(a) ((int)ceil(a))
#define ifloor(a) ((int)floor(a))

//#define TEST

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

int main(){
    StarBurstStream

    int n, k;
    cin >> n >> k;

    vector<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];

    vector<ll> dp(n, MAX);
    dp[0] = 0;
    for(int i = 1; i < n; i++){
        for(int j = 1; i - j >= 0 && j <= k; j++){
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }
    cout << dp[n - 1] << "\n";

    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	char c;
	map<char,int>m;
	m['C']=0;
	m['D']=1;
	m['H']=2;
	m['S']=3;
	m['T']=10;
	m['J']=11;
	m['Q']=12;
	m['K']=13;
	m['A']=14;

	while(cin>>c,c!='#'){
		vvp in(13,vp(4));
		int ns=0,ew=0;
		rep(i,4)rep(j,13){
			char a,b;
			cin>>a>>b;
			if(isdigit(a))in[j][i]=pii(m[b]+(b==c?20:0),a-'0');
			else in[j][i]=pii(m[b]+(b==c?20:0),m[a]);
		}
		int co=0;
		int p=0;
		rep(i,13){
			vip t(4);
			rep(j,4)t[j]=pip(in[i][j].first,pii(in[i][j].second,j));
			rep(j,4)if(in[i][p].first==in[i][j].first)t[j].first+=10;
			sort(all(t));
			if(t[3].second.second%2==0)ns++;
			else ew++;
			p=t[3].second.second;
//			cout<<p<<endl;
		}
		if(ew>ns)cout<<"EW "<<ew-6<<endl;
		else cout<<"NS "<<ns-6<<endl;
	}
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  int n;
  cin>>n;
  ll a[n];
  lo(i,0,n)
  cin>>a[i];
  sort(a,a+n);
  cout<<a[n-1]-a[0]<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3568
#include <cstring>
#include <cstdio>
using namespace std;
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
const int N = 110;
const int inf = 0x3f3f3f3f;
int n, m, sx, sy, ans, h[N][N], s[N][N], f[N][N][N]; char str[N];

template <class T> inline void in(T &x) {
	x = 0; int f = 1; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x *= f;
}

int main() {
	int u, d, l, r, cost;
	in(n), in(m), memset(f, -1, sizeof f);
	for (int i = 1; i <= n; ++i) {
		scanf("%s", str + 1);
		for (int j = 1; j <= m; ++j) {
			h[i][j] = h[i][j-1];
			s[i][j] = s[i-1][j];
			if (str[j] == 'E') sx = i, sy = j;
			if (str[j] == 'o') ++h[i][j], ++s[i][j];
		}
	}
	
	f[0][0][0] = 0;
	for (int t = 0; t <= m - sy; ++t)
	  for (int i = 0; i <= sx - 1; ++i)
		for(int j = 0; j <= n - sx; ++j)
		  for (int k = 0; k <= sy - 1; ++k)
			if (~f[i][j][k]) {
				u = max(j + 1, sx - i), d = min(n - i, sx + j);
				l = max(t + 1, sy - k), r = min(m - k, sy + t);
				if (j + 1 <= sx - i - 1) {
					cost = h[sx - i - 1][r] - h[sx - i - 1][l - 1];
					f[i+1][j][k] = max(f[i+1][j][k], f[i][j][k] + cost);
				}
				if (sx + j + 1 <= n - i) {
					cost = h[sx + j + 1][r] - h[sx + j + 1][l - 1];
					f[i][j+1][k] = max(f[i][j+1][k], f[i][j][k] + cost);
				}
				if (t + 1 <= sy - k - 1) {
					cost = s[d][sy - k - 1] - s[u - 1][sy - k - 1];
					f[i][j][k+1] = max(f[i][j][k+1], f[i][j][k] + cost);
				}
				if (sy + t + 1 <= m - k) {
					cost = s[d][sy + t + 1] - s[u - 1][sy + t + 1];
					f[i][j][k] = max(f[i][j][k], f[i][j][k] + cost);
				}
				ans = max(f[i][j][k], ans);
			}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 5504
n = int(input())
a = sorted(map(int,input().split()))

ans = 0

baisu = [0]*(a[n-1]+1)
an = a[n-1]

for i in range(n):
    a0 = a[i]
    a1 = a0
    while a1 <= an:
        baisu[a1] += 1
        a1 += a0


for i in range(n):
    if baisu[a[i]] == 1:
        ans += 1
print(ans)

Measured memory_bytes: 32140
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
  
N = int(input())
li = [ int(it) for it in input().split() ]

w = li[0]
for i in range(N-1):
  w = gcd(w,li[i+1])
print (w)

Measured memory_bytes: 62704
#include<iostream>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

int main()
{
    int a,b,h,m,n;
    double ans,theta,theta1;
    cin>>a>>b>>h>>m;
    n=60*h+m;
    theta1=(n*6)%360;
    theta=abs(theta1-n*0.5);
    theta1=min(theta,360-theta);
    theta1=theta1/180*M_PI;
    ans=sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(theta1));
    cout<< std::fixed << std::setprecision(15)<<ans<<endl;
}

Measured memory_bytes: 4292
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

bool asc(const complex<int>& a, const complex<int>& b) {
  if(a.real() != b.real()) return a.real() < b.real();
  else return a.imag() < b.imag();
}

int cross_product(complex<int> a, complex<int> b) {
  return (conj(a)*b).imag();
}

int main() {
  int n, x, y, size;
  cin >> n;
  vector<complex<int> > vertex(n), ans_under, ans_above;
  for(int i = 0; i < n; i++) {
    cin >> x >> y;
    vertex[i] = complex<int>(x, y);
  }
  sort(vertex.begin(), vertex.end(), asc);
  int i = 0;
  while(i < n) {
    size = ans_under.size();
    if(size < 2) {
      ans_under.push_back(vertex[i]);
      i++;
    }
    else {
      int t = cross_product(vertex[i]-ans_under[size-1], ans_under[size-2]-ans_under[size-1]);
      if(t >= 0) {
	ans_under.push_back(vertex[i]);
	i++;
      }
      else {
	ans_under.pop_back();
      }
    }
  }
  i = n-1;
  while(i >= 0) {
    size = ans_above.size();
    if(size < 2) {
      ans_above.push_back(vertex[i]);
      i--;
    }
    else {
      int t = cross_product(vertex[i]-ans_above[size-1], ans_above[size-2]-ans_above[size-1]);
      if(t >= 0) {
	ans_above.push_back(vertex[i]);
	i--;
      }
      else
	ans_above.pop_back();
    }
  }
  int minIndex = 0;
  for(int j = 1; j < ans_under.size(); j++) {
    if(ans_under[minIndex].imag() > ans_under[j].imag()) {
      minIndex = j;
    }
  }
  if(ans_under[ans_under.size()-1] == ans_above[0] && ans_under[0] == ans_above[ans_above.size()-1]) {
    cout << ans_under.size()+ans_above.size()-2 << endl;
    for(int j = minIndex; j < ans_under.size(); j++) {
      cout << ans_under[j].real() << " " << ans_under[j].imag() << endl;
    }
    for(int j = 1; j < ans_above.size()-1; j++) {
      cout << ans_above[j].real() << " " << ans_above[j].imag() << endl;
    }
    for(int j = 0; j < minIndex; j++) {
      cout << ans_under[j].real() << " " << ans_under[j].imag() << endl;
    }
  }
  else
    cout << "error" << endl;

  return 0;
}

  

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

using namespace std;

int main(void)
{
  int n; cin>>n;
  int count=0;
  vector<vector<int>> d(n, vector<int>(2));
  for(int i=0;i<n;i++){
    for(int j=0;j<2;j++){
      cin>>d[i][j];
    }
    if(d[i][0]==d[i][1]){count++;}
    else{count=0;}
    
    if(count>=3){cout<<"Yes"<<endl; return 0;}
  }
  
  cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 3652
//import java.lang.Math;
import java.util.*;
import java.util.Map.Entry;
//import java.util.ListIterator;
//import java.util.Iterator;
//import java.util.LinkedList;
 
public class Main{
	

	public static void main(String[] arg) {
               Scanner sc =new Scanner(System.in);
               TreeSet<Integer> ts= new TreeSet<Integer>();
               TreeSet<Integer> set1= new TreeSet<Integer>();
               int cnt=sc.nextInt();

               for(int i=0;i<cnt;i++){
            	  
                  set1.add(sc.nextInt());
                 }
               TreeSet<Integer> set2= new TreeSet<Integer>();
               int cnt2=sc.nextInt();

               for(int i=0;i<cnt2;i++){
                  set2.add(sc.nextInt());
                 }
                  
              ts.clear();
              ts.addAll(set1);
              ts.addAll(set2);
             
               for(Iterator<Integer> it=ts.iterator();it.hasNext();){
               int xx=it.next();
               System.out.println(xx);
               }
	}
	}


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

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

int main(){
  string S;
  long K;
  cin>>S>>K;
  if(S.size()<K){
    rep(i,S.size()){
      if(S.at(i)!='1'){
        cout<<S.at(i)<<endl;
        break;
      }
    }
  }
  else{
    bool finished=false;
    rep(i,K){
      if(S.at(i)!='1'){
        cout<<S.at(i)<<endl;
        finished=true;
        break;
      }
    }
    if(finished==false) cout<<1<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <string>

using namespace std;

bool edge[5][5];

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b;

	memset(edge, false, sizeof(edge));
	for (int i = 0; i < 3; i++)
	{
		cin >> a >> b;
		edge[a][b] = true;
		edge[b][a] = true;
	}

	vector <int> perm = { 1,2,3,4 };

	do
	{
		bool ok = true;
		for (int i = 1; i < perm.size(); i++)
		{
			if (edge[perm[i - 1]][perm[i]]==false)
			{
				ok = false;
				break;
			}
		}
		if (ok)
		{
			cout << "YES" << '\n';
			return 0;
		}
	} while (next_permutation(perm.begin(), perm.end()));
	
	cout << "NO" << '\n';
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
  ll n,d;
  cin>>n>>d;
  ll ans,p;
  p = 2*d + 1;
  ans = n/p;
 // cout<<ans<<"\n";
  if(n%p==0)
    cout<<ans;
  else
    cout<<ans+1;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
t_now = 0
pos = [0,0]
l = [list(map(int, input().split())) for _ in range(n)]

for t, x, y in l:
    t_d = t - t_now
    range_move = list(range(-t_d, t_d+1, 2))

    pos_d = (x-pos[0]) + (y-pos[1])

    if pos_d in range_move:
        t_now = t
        pos = [x, y]
    else:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 27148
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <deque>
#include <map>
#include <set>

#define ll long long
#define inf 0x3f3f3f3f
#define il inline

namespace io {

    #define in(a) a=read()
    #define out(a) write(a)
    #define outn(a) out(a),putchar('\n')

    #define I_int ll
    inline I_int read() {
        I_int x = 0 , f = 1 ; char c = getchar() ;
        while( c < '0' || c > '9' ) { if( c == '-' ) f = -1 ; c = getchar() ; }
        while( c >= '0' && c <= '9' ) { x = x * 10 + c - '0' ; c = getchar() ; }
        return x * f ;
    }
    char F[ 200 ] ;
    inline void write( I_int x ) {
        if( x == 0 ) { putchar( '0' ) ; return ; }
        I_int tmp = x > 0 ? x : -x ;
        if( x < 0 ) putchar( '-' ) ;
        int cnt = 0 ;
        while( tmp > 0 ) {
            F[ cnt ++ ] = tmp % 10 + '0' ;
            tmp /= 10 ;
        }
        while( cnt > 0 ) putchar( F[ -- cnt ] ) ;
    }
    #undef I_int

}
using namespace io ;

using namespace std ;

#define N 100010

bool vis[6];
int head[N], cnt;
struct edge {
	int to, nxt;
}e[N];

void ins(int u, int v) {
	e[++cnt] = (edge) {v, head[u]};
	head[u] = cnt;
}

int tot = 0, flag = 0;
void dfs(int u) {
	if(vis[u]) return;
	vis[u] = 1; ++tot;
	bool f = 0;
	for(int i = head[u]; i; i = e[i].nxt) {
		if(vis[e[i].to]) continue;
 		dfs(e[i].to);
 		f = 1;
	}
	if(!f && tot < 4) flag = 1;
}

int main() {
	for(int i = 1; i <= 3; ++i) {
		int u = read(), v = read();
		ins(u, v); ins(v, u);
	}
	for(int i = 1; i <= 4; ++i) {
		memset(vis, 0, sizeof(vis));
		dfs(i); tot = 0;
		if(!flag) {
			puts("YES");
			return 0;
		}
	}
	puts("NO");
}

Measured memory_bytes: 256
num_red = int(input())
red = [0] * num_red

for i in range(num_red):
    red[i] = input()

num_blue = int(input())
blue = [0] * num_blue

for i in range(num_blue):
    blue[i] = input()

max = 0
count = 0

for i in range(num_red):
    if red.count(red[i]) > 0:
        count += red.count(red[i])

    for x in range(num_blue):
        if red[i] == blue[x]:
            count -= 1
    if count > max :
        max = count

    count = 0

print(max)

Measured memory_bytes: 3064
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    if s[2]==s[3] and s[4]==s[5]:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll N, K;
    cin >> N >> K;
    
    ll ans = 1;
    for(int i=0;i<N;i++)
        ans = min(ans*2, ans + K);

    cout << ans << endl;

}


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

int main() {
    int n, ans;
    string str;
    cin >> str;
    if(str.length() % 2) str = str.substr(0, str.length() - 1);
    else str = str.substr(0, str.length() - 2);
    n = ans = str.length() / 2;
    rep(i, n) {
        bool flag = true;
        rep(i, ans) if(str.at(i) != str.at(i + ans)) flag = false;
        if(flag) break;
        ans--;
    }
    cout << 2 * ans << endl;
}

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

int main() {
	string s;
	cin >> s;
	int begin, end;
	for (int i = 0; ; i++)
		if (s[i] == 'A') {
			begin = i;
			break;
		}
	for (int i = s.size() - 1; ; i--)
		if (s[i] == 'Z') {
			end = i;
			break;
		}
	cout << end - begin + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

std::string S, T;
std::set<std::string> st;

bool equal( ll idx, const std::string &T ) {
  repi( i, idx, idx+T.size() ) {
    if( i >= S.size() )
      return false;

    if( S[i] != '?' && S[i] != T[i-idx] )
      return false;
  }

  return true;
}

int main()
{
  std::cin >> S >> T;

  rep( i, S.size() ) {
    if( equal( i, T ) ) {
      auto t = S.substr(0,i);
      rep( j, t.size() ) if( t[j] == '?' )
        t[j] = 'a';

      auto t2 = i+T.size() < S.size() ? S.substr( i+T.size() ) : "";
      rep( j, t2.size() ) if( t2[j] == '?' )
        t2[j] = 'a';

      st.emplace( t+T+t2 );
    }
  }

  std::cout << (st.empty() ? "UNRESTORABLE" : *st.begin()) << std::endl;

  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      char s[3];
      int num = 0;
      cin >> s;
      // cout = s;
      for( int i; i<3 ; i++){
        if(s[i] == '1'){
          num ++;
        }
      }
      cout << num << endl;
    }

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int

using namespace std;


int main(){
    int N; cin>>N;
    vector <int> x;x.resize(N);
    vector <int> y;y.resize(N);
    vector <int> h;h.resize(N);
    int fh,fx,fy;
    for(int i=0;i<N;i++){
        cin>>x[i]>>y[i]>>h[i];
        if(h[i] != 0) {fx=x[i];fy=y[i];fh=h[i];}
    }

    for(int px=0;px<=100;px++){
        for(int py=0;py<=100;py++){
            bool flag = true;
            int ph = abs(px-fx) + abs(py-fy) + fh;
            for(int i=0;i<N;i++){
                int qx = x[i],qy=y[i],qh = h[i];
                if(qh == max(0,ph - abs(px-qx) - abs(py-qy))) continue;
                else {flag = false;break;}
            }
            if(flag) {cout<<px<<" "<<py<<" "<<ph<<endl;return 0;}
        }
    }

}

Measured memory_bytes: 256
from itertools import permutations
N, M = map( int, input().split())
edges = [[] for _ in range(N)]
for i in range(M):
    a, b = map( int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
ans = 0
for X in permutations(range(N),N):
    if X[0] != 0:
        continue
    Flag = True
    for i in range(1,N):
        if X[i] in edges[X[i-1]]:
            pass
        else:
            Flag = False
            break
    if Flag:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main() {

	char S[12] = { '\0' };
	char ans[12] = { '\0' };
	int count = 0;

	scanf("%s", &S);

	for (int i = 0; i < 10; i++) {
		if (S[i] == '\0') { break; }
		switch (S[i]) {
		case '0':
			ans[count] = '0';
			count++;
			break;

		case '1':
			ans[count] = '1';
			count++;
			break;

		case 'B':
			if (count == 0){
				ans[count] = '\0';
			}
			else {
				ans[count - 1] = '\0';
				count--;
			}
			break;
		}
	}

	printf("%s", ans);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int K,N;
  cin >> K >> N;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  sort(rng(A));
  int ans = (K-A[N-1])+A[0];
  rep(i,N-1) {
    chmax(ans,A[i+1]-A[i]);
  }
  cout << K-ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c;
    cin>>a>>b;
    if(a>9||b>9)
    cout<<-1<<endl;
    else if(a<=9&&b<=9)
    {
    c=a*b;
    cout<<c<<endl;
    }
    
}

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

#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

int gcd(int x,int y){
    if (x < y) swap(x,y);
    while(y>0){
        int r = x % y;
        x = y;
        y = r;
    }
    return x;
}




int main()
{
    int x,y;
    scanf("%d%d",&x,&y);
    printf("%d\n",gcd(x,y));
    return 0;
}


Measured memory_bytes: 3240