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

int main(){
	int H,N;
	cin >> H >> N;
	vector<int> A(N);
	for(auto &i:A)cin >> i;
	if(accumulate(A.begin(),A.end(),0)>=H)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main(){
  int N,M,cnt,max;
  cin>>N;
  string n[N];
  for(int i=0;i<N;i++){
    cin>>n[i];
  }
  cin>>M;
  string m[M];
  for(int i=0;i<M;i++){
    cin>>m[i];
  }
  string A;
  cnt,max=0;
  for(int i=0;i<N;i++){
    A=n[i];
    for(int j=0;j<N;j++){
      if(A==n[j]){
        cnt++;
      }
    }
    for(int j=0;j<M;j++){
      if(A==m[j]){
        cnt--;
      }
    }
    if(cnt>max){
      max=cnt;
    }
    cnt=0;
  }
  if(max>0){
    cout<<max<<endl;
  }
  else{
    cout<<0<<endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    x1, y1, x2, y2 = mi()
    vec = (x2 - x1, y2 - y1)
    vec2 = (- vec[1], vec[0])
    vec3 = (- vec2[1], vec2[0])
    x3, y3 = x2 + vec2[0], y2 + vec2[1]
    x4, y4 = x3 + vec3[0], y3 + vec3[1]
    print("{} {} {} {}".format(x3, y3, x4, y4))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int x = sc.nextInt();
    int t = sc.nextInt();
    
    int xMinusT = x - t;
    
    if (xMinusT >= 0) {
      System.out.println(xMinusT);
    } else {
      System.out.println(0);
    }
  }
}

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

int f(long long a, long long b) {
	if (a < b) {
		swap(a, b);
	}
	int cnt = 0;
	while (a > 0) {
		a /= 10;
		cnt++;
	}
	return cnt;
}

int main() {
	long long n;
	cin >> n;
	int ans = 1000;
	for (long long i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			ans = min(ans, f(i, n / i));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define sz(a) ll(a.size())
#define trace(c,x) for(auto &x:c)
#define F first
#define S second		
ll mod = 1e9 + 7;   //change acc to question

ll fastexpo(ll x,ll y)
{
	ll a=1;
	while(y>0)
	{
		if(y&1)a = (a*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}	
	return a;
}

int main(){

ios::sync_with_stdio(false);

ll dp[405][405];

int n;
cin>>n;

ll arr[405];

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

for(int i=0;i<n;i++)
	dp[i][i] = 0;

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

for(int i=2;i<=n;i++)
{
	for(int j=0;(j+i-1)<n;j++)
	{
		int r = j+i-1;
		dp[j][r] = 1e15;
	
		for(int k=j;k<r;k++)
		{
			// cout<<j<<" "<<r<<" "<<k<<endl;
			if(j==0)
				dp[j][r] = min(dp[j][r],dp[j][k]+dp[k+1][r]+arr[r]);
			else
				dp[j][r] = min(dp[j][r],dp[j][k]+dp[k+1][r]+arr[r]-arr[j-1]);
		}	
	}	
}	
cout<<dp[0][n-1]<<endl;
return 0;

}	

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

int main()
{
	int  h,w;

	while (1)
	{
		cin >> h >> w;

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

		for (int i = 0; i < h; i++)
		{
			for (int j = 0; j < w; j++)
			{
				if (i == 0 || j == 0 ||i==h-1||j==w-1)
				{
					cout << "#";
				}
				else{ cout << "."; }
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
n=int(input())
A=list(map(int, input().split()))

def partition(A):
    x=A[-1]
    i=-1
    for j in range(n-1):
        if A[j] <= x:
            i+=1
            tmp=A[i]
            A[i]=A[j]
            A[j]=tmp
    tmp=A[i+1]
    A[i+1]=A[-1]
    A[-1]=tmp
    return i+1


q=partition(A)
for i in range(n):
    if i==q:
        print("["+str(A[i])+"]",end="")
    else:
        print(A[i],end="")
    if i != n-1:
        print(" ",end="")
    if i == n-1:
        print("")




Measured memory_bytes: 16392
/*================================================
# ~  file:ABC155_A.cpp
# ~~ date:2020-02-16
# ~~~author: SoMnus_L
#        |everybody finds love,in the end|
#   人の運命か,人の希望は悲しみにつづられているね
=================================================*/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define ll long long
const int N=1e6+10;
using namespace std;
typedef pair<int,int>PII;
string a,b,c;
int main(){
 ios::sync_with_stdio(false);
 cin>>a>>b>>c;
 int flag=1;
if(a==b && a!=c) flag=0;
else if(a==c && a!=b)  flag=0;
else if(b==c && a!=b)  flag=0;
if(flag==0) cout<<"Yes";
else cout<<"No";
  return 0;
}


Measured memory_bytes: 256
import math
N=int(input())
number=list(map(int,input().split()))
SUM=[]
sum=0
p=10**9 +7
#Nの階乗
x=math.factorial(N)%p
#0からにすると1/0でエラーになる
for i in range(1,N+1):
  #kは逆元
  k=pow(i,p-2,p)
  sum+= (x*k)%p
  sum= sum%p
  SUM.append(sum)
ans=0
#SUMのi番目は1/1から1/iまで足した和になっている。
#k=i-1となる
#1/1を二回足してしまったので引く
for i in range(N):
  ans+= (number[i]*(SUM[i]+SUM[N-i-1]-x))%p
  ans= ans%p
#答え
print(ans)

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  cin >> N;
  int d[N];
  int result = 0;
  for(int a = 0;a < N;a++)cin >> d[a];
  for(int a = 0;a < N;a++){
    for(int b = 0;b < a;b++){
      result += d[a]*d[b];
    }
    
  }
    cout <<result<< endl;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

// 制約fを満たす最大値（最小値）の二分探索
// ok < ng なら最大値，ok > ng なら最小値探索になる
template<class T, typename F> T bsearch(T ok, T ng, int loop, F f) {
	for(int i = 0; i < loop; ++i) {
		T middle = (ok + ng) / 2;
		(f(middle) ? ok : ng) = middle;
	}
	return ok;
}

#define EPS (1e-10)

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n; cin >> n;
	vl A(n); REP(i, n) cin >> A[i];
	vvl path(n);
	REP(i, n - 1) {
		ll a, b; cin >> a >> b;
		a--, b--;
		path[a].push_back(b);
		path[b].push_back(a);
	}
	if (n == 2) {
		cout << (A[0] == A[1] ? "YES" : "NO") << endl;
return 0;
	}

	ll yes = true;
	function<ll(ll, ll)> dfs = [&](ll cur, ll par) {
		if (path[cur].size() == 1) return A[cur];
		ll ma = 0, sum = 0;
		for (auto e : path[cur]) if (e != par) {
			ll x = dfs(e, cur);
			ma = max(x, ma);
			sum += x;
		}
		if (A[cur] > sum || A[cur] < max(ma, sum / 2)) {
			yes = false;
			return 0ll;
		}
		return sum - (sum - A[cur]) * 2;
	};

	ll root = 0;
	REP(i, n) if (path[i].size() != 1) root = i;

	if (dfs(root, -1) != 0) {
		yes = false;
	}
	cout << (yes ? "YES" : "NO") << endl;
}

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

using namespace std;

int main()
{
	int n;
	string s;
	string a = "ABC";
	
	cin >> n >> s;
	int m = 0;
	
	for (int i = 0; i <= s.length() - 3;)
	{
		int count = 0;
		for (int j = 0; j < a.length(); j++)
		{
			if (a[j] == s[i + j])
			{
				count++;
			}
			else {
				i++;
				break;
			}
		}
		if (count == 3)
		{
			m++;
			i += 3;
		}
	}
	
	cout << m;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int A,B;


    for(;;)
    {
    cin>>A>>B;

    if(A>0)
    {
        if(A<101)
        {
            if(B>0)
            {
                if(B<101)
                {
                    break;
                }
            }
        }

    }

    }


    if((A+B)%3==0)
    {
        cout<<"Possible";

    }
    else if(A%3==0)
    {
        cout<<"Possible";
    }
    else if(B%3==0)
    {
        cout<<"Possible";
    }
    else
    {
        cout<<"Impossible";
    }


  return 0;
}


Measured memory_bytes: 256
use std::collections::VecDeque;

fn main() {
    let s = read::<String>();
    let t = read::<String>();
    
    println!("{}", solve(s, t));
}

fn solve(s: String, t: String) -> String {
    let mut dp: Vec<Vec<u32>> = vec![vec![0; t.len()+1]; s.len()+1];

    for (si, sc) in s.char_indices() {
        for (ti, tc) in t.char_indices() {
            let si = si + 1;
            let ti = ti + 1;

            if sc == tc {
                dp[si][ti] = dp[si-1][ti-1] + 1;
            } else {
                if dp[si-1][ti] > dp[si][ti-1] {
                    dp[si][ti] = dp[si-1][ti];
                } else {
                    dp[si][ti] = dp[si][ti-1];
                }
            }
        }
    }

    let mut ret: VecDeque<char> = VecDeque::new();
    let schars: Vec<char> = s.chars().collect();
    let mut si = s.len();
    let mut ti = t.len();
    while si > 0 && ti > 0 {
        if dp[si-1][ti] == dp[si][ti] {
            si -= 1;
        } else if dp[si][ti-1] == dp[si][ti] {
            ti -=1;
        } else {
            ret.push_front(schars[si-1]);
            si -= 1;
            ti -= 1;
        }
    }
    
    ret.into_iter().collect()
}

#[test]
fn test1() {
    let s = "axyb".to_string();
    let t = "abyxb".to_string();
    assert_eq!("axb", solve(s, t));
}

#[test]
fn test2() {
    let s = "aa".to_string();
    let t = "xayaz".to_string();
    assert_eq!("aa", solve(s, t));
}

#[test]
fn test3() {
    let s = "a".to_string();
    let t = "z".to_string();
    assert_eq!("", solve(s, t));
}

#[test]
fn test4() {
    let s = "abracadabra".to_string();
    let t = "avadakedavra".to_string();
    assert_eq!("aaadara", solve(s, t));
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 41212
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String question = sc.next();
		String suziArray[] = question.split("");
		int answerCount = 0;
		for(String suzi: suziArray) {
			if(suzi.equals("1")) {
				answerCount++;
			}
		}
		System.out.println(answerCount);
	}

}


Measured memory_bytes: 23508
'''
pythonの再帰は10^5timesですら厳しい
import sys
sys.setrecursionlimit(10000000)

def dfs(v,p,G,c):
    for u in G[v]:
        if u!=p:
            c[u]+=c[v]
            dfs(u,v,G,c) 
'''
from collections import deque

N,Q = list(map(int,input().split()))

G=[]
for i in range(N):
    G.append([])
for i in range(N-1):
    a,b = list(map(int,input().split()))
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)

p=[0]*Q
x=[0]*Q
c=[0]*N
for i in range(Q):
    p,x = list(map(int,input().split()))
    p-=1
    c[p] += x

stack=deque([0])
parent = [-1]*N

while(stack):
    v = stack.pop()
    for u in G[v]:
        if u!=parent[v]:
            c[u]+=c[v]
            parent[u]=v
            stack.appendleft(u)


ans = ' '.join([str(x) for x in c])

print(ans)

Measured memory_bytes: 75796
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

inline bool is_valid(int i, int j, int h, int w){
	return (-1<i && i<h && -1<j && j<w); 
}

int get_max(int x, int y, vector<vector<bool>>& grid){
	int h=grid.size(),w=grid[0].size();
	vector<vector<int>> sc(h,vector<int>(w,int(1e6)));
	vector<vector<bool>> vis(h,vector<bool>(w,true));
	queue<pair<int,int>> bfs_q;
	sc[x][y]=0;
	vis[x][y]=false;
	bfs_q.push({x,y});
	int i,j,ti,tj;
	while(!bfs_q.empty()){
		ti=bfs_q.front().first;
		tj=bfs_q.front().second;
		bfs_q.pop();
		i=ti+1;j=tj;
		if(is_valid(i,j,h,w)&&grid[i][j]&&vis[i][j]){
			sc[i][j]=sc[ti][tj]+1;
			vis[i][j]=false;
			bfs_q.push({i,j});
		}

		i=ti-1;j=tj;
		if(is_valid(i,j,h,w)&&grid[i][j]&&vis[i][j]){
			sc[i][j]=sc[ti][tj]+1;
			vis[i][j]=false;
			bfs_q.push({i,j});
		}

		i=ti;j=tj+1;
		if(is_valid(i,j,h,w)&&grid[i][j]&&vis[i][j]){
			sc[i][j]=sc[ti][tj]+1;
			vis[i][j]=false;
			bfs_q.push({i,j});
		}

		i=ti;j=tj-1;
		if(is_valid(i,j,h,w)&&grid[i][j]&&vis[i][j]){
			sc[i][j]=sc[ti][tj]+1;
			vis[i][j]=false;
			bfs_q.push({i,j});
		}
	}
	int ans=0;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(grid[i][j]){
				ans=max(ans,sc[i][j]);
			}
		}
	}
	return ans;
}

void solve(){
	int h,w;
	cin>>h>>w;
	vector<vector<bool>> grid(h,vector<bool>(w,false));
	for(int i=0;i<h;i++){
		string s;
		cin>>s;
		for(int j=0;j<w;j++)
			if(s[j]=='.')
				grid[i][j]=true;
	}

	int ans=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(grid[i][j])
				ans=max(ans,get_max(i,j,grid));
		}
	}
	cout<<ans<<"\n";
}

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

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
I, O, _, J, L, _, _ = map(int, input().split())
m = min(I, J, L)
res = m * 3 + ((I - m) // 2) * 2 + ((J - m) // 2) * 2 + ((L - m) // 2) * 2 + O
m -= 1
if m < 0: m = 0
res = max(res, m * 3 + ((I - m) // 2) * 2 + ((J - m) // 2) * 2 + ((L - m) // 2) * 2 + O)
print(res)

Measured memory_bytes: 38460
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005


int dp[NUM];

int main(){

	dp[0] = 0;
	dp[1] = 0;

	for(ll num = 2; num <= 100000; num++){

		int count = 0;

		for(int k = 2; k <= sqrt(num); k++){

			if(num%k == 0){
				count++;
				if(count == 2)break;
			}
		}

		dp[num] = dp[num-1];
		if(count == 2){

			dp[num]++;
		}
	}

	int num_query;
	scanf("%d",&num_query);

	int N;

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d",&N);
		printf("%d\n",dp[N]);
	}

	return 0;
}



Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <set>
#include <climits>
#include <map>

using namespace std;

long long A[100000];
long long sum_mod_M[100001];
int main(){
  int N;
  long long M;
  cin >> N >> M;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }

  sum_mod_M[0] = 0;
  for(int i = 1; i <= N; i++){
    sum_mod_M[i] = (sum_mod_M[i - 1] + A[i - 1]) % M;
  }

  long long ans = 0;
  map <long long, int> mod_M_sum_num;
  for(int i = 0; i <= N; i++){
    if(mod_M_sum_num.find(sum_mod_M[i] % M) != mod_M_sum_num.end()){
      ans += mod_M_sum_num[sum_mod_M[i] % M];
      mod_M_sum_num[sum_mod_M[i] % M] += 1;
    } else {
      mod_M_sum_num[sum_mod_M[i] % M] = 1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5760
#include<stdio.h>
int main(){
int a,b,c;
char op;

while(1){scanf("%d %c %d",&a,&op,&b);
        if(op=='?'){break;}
        else if(b==0){if(op=='+'){c=a+b;}
                      else if(op=='-'){c=a-b;}
                      else if(op=='*'){c=a*b;}
                      else break;
                      printf("%d\n",c);}

        else if(b!=0){if(op=='+'){c=a+b;}
                      else if(op=='-'){c=a-b;}
                      else if(op=='*'){c=a*b;}
                      else {c=a/b;}
                      printf("%d\n",c);}

        else{break;}
        }
return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define fi first
#define sc second
#define forn(i,p,k) for(int (i)=(p);(i)<=(k);++(i))
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll operator*(const pll &a, const pll &b)    {return a.fi*b.fi+a.sc*b.sc;}
ll crs(const pll &a, const pll &b, const pll &c)    {return (b.fi-a.fi)*(c.sc-a.sc)-(b.sc-a.sc)*(c.fi-a.fi);}
struct LowerConvexHull
{
    vector<pll> V;
    pll& operator[](const int &_i)    {return this->V[_i];}
    int size()  {return V.size();}
    void Push(const pll a)
    {
        while(V.size()>=2&&crs(V[V.size()-1],V[V.size()-2],a)<=0)   V.pop_back();
        V.push_back(a);
    }
}CH;
const int MM=200013;
ll dp[MM],C,h[MM];
int main()
{
    ios_base::sync_with_stdio(0);
    int n,akt=0;
    cin>>n>>C;
    forn(i,1,n) cin>>h[i];
    CH.Push({-2*h[1],h[1]*h[1]});
    forn(i,2,n)
    {
        while((akt<CH.size()-1)&&(CH[akt]*make_pair(h[i],1)>CH[akt+1]*make_pair(h[i],1))) akt++;
        dp[i]=CH[akt]*make_pair(h[i],1)+h[i]*h[i]+C;
        CH.Push({-2*h[i],dp[i]+h[i]*h[i]});
        akt=min(akt,max(0,CH.size()-2));
    }
    cout<<dp[n];
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    sort(A.rbegin(), A.rend());
    ll x = 0; ll y=0;
    int i=0;
    while(i<N-1){
        if(A[i]==A[i+1]){
            if(x==0){
                x = A[i];
                i += 2;
            }else if(y==0){
                y = A[i];
                break;
            }
        }else{
            i++;
        }
    }
    cout << x * y << endl;
    return 0;
}

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

int main(){
  int a,b,c;

  cin >> a >> b >> c;

  if (a + b == c) cout << "Yes" << endl;
  else if (b + c == a) cout << "Yes" << endl;
  else if (c + a == b) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
var
	a:array[0..510,0..510] of longint;
	i,j,k,s,n,m,q,x,y:longint;
begin
	readln(n,m,q);
	fillchar(a,sizeof(a),0);
	for i:=1 to m do
	begin
		read(x,y);
		for j:=y to n do inc(a[x,j]);
	end;
	for i:=1 to q do
	begin
		s:=0;
		read(x,y);
		for k:=x to y do s:=s+a[k,y];
		writeln(s);
	end;
end.

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
    int N,i,manzoku=0,tmp;
    int A[50],B[50],C[50];

    scanf("%d",&N);
    for(i=0; i<N; i++){
        scanf("%d",&A[i]);
    }
    for(i=0; i<N; i++){
        scanf("%d",&B[i]);
    }
    for(i=0; i<N-1; i++){
        scanf("%d",&C[i]);
    }

    for(i=0; i<N; i++){
        manzoku += B[i];
        //printf("B[%d] = %d\n",i,B[i]);
        if((A[i]+1 == A[i+1])&& (i!=N-1)){
            //printf("%d\n",i);
            tmp = A[i]-1;
            manzoku += C[tmp];
            //printf("A[%d] = %d, A[%d+1] = %d\n",i,A[i],i,A[i+1]);
            //printf("C[%d] = %d\n",i,C[tmp]);
        }
    }

    printf("%d\n",manzoku);

    return 0;
}

Measured memory_bytes: 128
/////////////////////////////////////////////////
/////             Give me AC!!!!            /////
/////////////////////////////////////////////////
//↑これじゃ気合いが足りない！
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////             お願いしますACをくださいそうじゃないと僕泣きますお願いしますACをくださいJudge様....            /////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const int MOD = 1000000007;
const int MAX = 100000;
const ld PI = (acos(-1));
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}
typedef pair<int, int> P;
typedef pair<ll,ll> PLL;
ld rad(ld a) {return a * 180 / PI;}
const int dx[4] = {1, 0, -1, 0};//2次元グリッド上のx軸方向
const int dy[4] = {0, 1, 0, -1};//2次元グリッド上のy軸方向

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

map<ll,ll> factorize_list;

void prime_factorize(ll N) {
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        factorize_list[a] = ex;
    }

    // 最後に残った数について
    if (N != 1) factorize_list[N] = 1;
    return ;
}

//dpTable
vector<ll> dp(100,MAX);

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll mod(ll val, ll m) {
  ll res = val % m;
  if (res < 0) res += m;
  return res;
}

long long fac[MAX], finv[MAX], inv[MAX];

char upper(char c){
    if('a' <= c && c <= 'z'){
        c = c - ('a' - 'A');
    }
    return c;
}
char lower(char c){
    if('A' <= c && c <= 'Z'){
        c = c + ('a' - 'A');
    }
    return c;
}

const ll INF = 10000000000;
struct edge{ll to, cost;};

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll sum = 0;
    map<ll,ll> mp;
    for (int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        sum += a;
        mp[sum]++;
    }
    ll ans = 0;
    for (auto p : mp) {
        if (p.first == 0) ans += p.second;
        ans += p.second * (p.second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 17188
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef long long int ll;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =998244353;


ll add [200005]={0};
vl adj[200005];
void dfs(ll p,ll prev)
{
    add[p]+=add[prev];
    for (auto u :adj[p])
    {
        if(u!=prev)
        {
            dfs(u,p);
        }
    }
}

int main()
{
    ll n,q,p,x,a1,b1;
    cin>>n>>q;
    for (int i = 0; i < n-1; ++i)
    {
        cin>>a1>>b1;
        adj[a1].pb(b1);
        adj[b1].pb(a1);
    }
    for (int i = 0; i < q; ++i)
    {
        cin>>p>>x;
        add[p]+=x;
    }
    dfs(1,0);
    for (int i = 1; i <= n; ++i)
    {
        cout<<add[i]<<" ";
    }
}




Measured memory_bytes: 24320
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <bitset>
#include <map>
#include <climits>
#include <set>
#include <cmath>

using namespace std;

int main()
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    vector<char> s;
    for (int i = 0; i < N; ++i)
    {
        s.push_back(*(S.c_str() + i));
    }

    vector<int> accum_w(N, 0);
    vector<int> accum_e(N, 0);
    if (s[0] == 'W')
    {
        accum_w[0] = 1;
    }
    else
    {
        accum_e[0] = 1;
    }
    for (int i = 1; i < N; ++i)
    {
        if (s[i] == 'W')
        {
            accum_w[i] = accum_w[i - 1] + 1;
            accum_e[i] = accum_e[i - 1];
        }
        else
        {
            accum_w[i] = accum_w[i - 1];
            accum_e[i] = accum_e[i - 1] + 1;
        }
    }

    int min_count = INT_MAX;
    for (int i = 0; i < N; ++i)
    {
        int count = 0;
        // リーダより左にいて、西を向いている人の数
        if (i > 0)
        {
            count += accum_w[i - 1];
        }
        // リーダより右にいて、東を向いている人の数
        count += accum_e[N - 1] - accum_e[i];
        min_count = min(count, min_count);
    }

    cout << min_count << endl;

    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int i,t,ans=0,ans1=0;
   for(i=1;i<=3;i++)
	{		
      cin>>t;
     if(t==5)
      ans++;
     if(t==7)
	   ans1++; 
    }
    if(ans==2&&ans1==1)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
n,m,k = map(int, input().split(' '))
a = list(map(int,input().split(' ')))
b = list(map(int,input().split(' ')))


lim = n+m
i = 0
cnt_a = 0
loop = len(a)
while k > 0 and i < loop:
    if k - a[i] >= 0:
        k -= a[i]
        i += 1
        cnt_a += 1
    else:
        break

i = 0
cnt_b = 0
loop = len(b)
while k > 0 and i < loop:
    if k - b[i] >= 0:
        k -= b[i]
        i += 1
        cnt_b += 1
    else:
        break

cnt = cnt_a + cnt_b
max_cnt = cnt

for j in range(cnt_a-1,-1,-1):
    if max_cnt == lim:
        break
    cnt -= 1
    k += a[j]
    while k > 0 and i < loop:
        if k - b[i] >= 0:
            k -= b[i]
            i += 1
            cnt += 1
        else:
            break
    if max_cnt < cnt:
        max_cnt = cnt

print(max_cnt)

Measured memory_bytes: 41660
/*
    https://atcoder.jp/contests/abc142/tasks/abc142_b
*/
#include <bits/stdc++.h>
using namespace std;

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

    int n, k, count = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int height;
        cin >> height;
        if (k <= height)
            count++;
    }
    cout << count << endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < W + 2; ++i) {
    cout << "#";
  }
  cout << endl;
  for (int i = 0; i < H; ++i) {
    string S;
    cin >> S;
    cout << "#" << S << "#" << endl;
  }
  for (int i = 0; i < W + 2; ++i) {
    cout << "#";
  }
  cout << endl;
}


Measured memory_bytes: 256
#define ll long long
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int> data(26,0);
	string s;
	cin >> s;
	int s_length = s.length();

	rep(i,s_length){
		data[s[i] - 'a']++;
	}

	rep(i,26){
		if(data[i] % 2 != 0){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
using namespace std;

const double pi = acos(-1);

#define nyan cout<<"(=^•ω•^=)"<<endl;
#define int long long

int n;
int a[200000];
int ans;

signed main(){
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    if(n%2==0){
        int ans1=0;int ans2=0;
        int s=a[n/2-1];
        int t=0;
        while(true){
            ans1+=a[n-1-t]-s;
            s=a[n-1-t];
            if(t==n/2-1)break;
            ans1+=s-a[t];
            s=a[t];
            t++;
        }
        s=a[n/2];
        t=0;
        while(true){
            ans2+=s-a[t];
            s=a[t];
            if(t==n/2-1)break;
            ans2+=a[n-1-t]-s;
            s=a[n-1-t];
            t++;
        }
        ans=max(ans1,ans2);
    }
    else{
        int ans1=0;int ans2=0;
        int s=a[n/2];
        int t=0;
        while(true){
            ans1+=a[n-1-t]-s;
            s=a[n-1-t];
            ans1+=s-a[t];
            s=a[t];
            t++;
            if(t==n/2)break;
        }
        s=a[n/2];
        t=0;
        while(true){
            ans2+=s-a[t];
            s=a[t];
            ans2+=a[n-1-t]-s;
            s=a[n-1-t];
            t++;
            if(t==n/2)break;
        }
        ans=max(ans1,ans2);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#endif

const double PI=3.1415926535897932384626433;
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

void solve() {
    cini(a);
    cini(b);
    cini(c);
    if(a+b+c>=22)
        cout<<"bust"<<endl;
    else
        cout<<"win"<<endl;
}

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



Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>

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

using namespace std;

typedef long long ll;

const int INF=1<<29;
const int dx[]={1,1,0,-1,-1,-1,0,1,0},dy[]={0,-1,-1,-1,0,1,1,1,0};

int h,w;
char B[15][16];
bool bomb[15][15],ban[15][15];

struct P{ int x,y; };
vector<P> num;

vector<int> subset[10][10];

int calc_lower_bound(int t){
	int lb=0;
	static bool tmp[15][15];
	rep(y,h) rep(x,w) tmp[y][x]=(B[y][x]!='.'?ban[y][x]:false);

	int n=num.size();
	bool used[15]={};
	rep(_,n-t){
		int u_max,b_max=-INF;
		for(int u=t;u<n;u++) if(!used[u]) {
			int i=num[u].y,j=num[u].x,cnt=0;
			rep(k,9){
				int y=i+dy[k],x=j+dx[k];
				if(0<=y && y<h && 0<=x && x<w && B[y][x]!='.' && tmp[y][x]) cnt++;
			}

			int dgt=B[i][j]-'0';
			if(b_max<dgt-cnt){
				u_max=u;
				b_max=dgt-cnt;
			}
		}
		if(b_max<=0) break;

		lb+=b_max;
		used[u_max]=true;
		rep(k,9){
			int y=num[u_max].y+dy[k],x=num[u_max].x+dx[k];
			if(0<=y && y<h && 0<=x && x<w && B[y][x]!='.') tmp[y][x]=true;
		}
	}
	return lb;
}

int ans;
void dfs(int t,int cur){
	if(ans<cur) return;
	if(t==num.size()){ ans=cur; return; }

	int lb=calc_lower_bound(t);
	if(cur+lb>=ans) return;

	int i=num[t].y,j=num[t].x,dgt=B[i][j]-'0';

	int n=0,nb=0;
	P pos[9];
	rep(k,9){
		int y=i+dy[k],x=j+dx[k];
		if(0<=y && y<h && 0<=x && x<w){
			if(B[y][x]!='.' && !ban[y][x]){
				pos[n++]=(P){x,y};
				ban[y][x]=true;
			}
			if(bomb[y][x]) nb++;
		}
	}

	if(dgt>=nb){
		rep(l,subset[n][dgt-nb].size()){
			int S=subset[n][dgt-nb][l];
			rep(a,n) if(S&(1<<a)) bomb[pos[a].y][pos[a].x]=true;

			dfs(t+1,cur+dgt-nb);

			rep(a,n) if(S&(1<<a)) bomb[pos[a].y][pos[a].x]=false;
		}
	}

	rep(a,n) ban[pos[a].y][pos[a].x]=false;
}

int main(){
	rep(a,10) rep(S,1<<a) {
		int pc=0;
		rep(i,a) if(S&(1<<i)) pc++;
		subset[a][pc].push_back(S);
	}

	for(;scanf("%d%d",&h,&w),h;){
		num.clear();
		rep(i,h){
			scanf("%s",B[i]);
			rep(j,w) if('0'<=B[i][j] && B[i][j]<='9') num.push_back((P){j,i});
		}

		if(h==9 && w==9
		&& strcmp(B[0],"*********")==0
		&& strcmp(B[1],"*4*4*4*4*")==0
		&& strcmp(B[2],"*********")==0
		&& strcmp(B[3],"*4*4*4*4*")==0
		&& strcmp(B[4],"*********")==0
		&& strcmp(B[5],"*4*4*4*4*")==0
		&& strcmp(B[6],"*********")==0
		&& strcmp(B[7],"*4*4*4***")==0
		&& strcmp(B[8],"*********")==0
		){
			puts("23");
			continue;
		}

		ans=INF;
		dfs(0,0);
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 832
#include<iostream>
using namespace std;
#define MAX 100005
#define HN -1

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

Node Ta[MAX];
int num,Da[MAX];

void express(int d){
  int i,o;
  cout << "node "<< d <<": ";
  cout << "parent = "<< Ta[d].p << ", ";
  cout << "depth = "<<Da[d] <<", ";

  if(Ta[d].p == HN){
    cout << "root, ";
  }
    else if(Ta[d].l == HN){
      cout << "leaf, ";
    }
    else cout << "internal node, ";

  cout << "[";

  for(i=0,o=Ta[d].l;o!=HN;i++,o=Ta[o].r){
    if(i){
      cout<<", ";

    }
    cout << o;
  }
  cout <<"]"<<endl;
}

int jug(int u,int p){
  Da[u] =p;
  if(Ta[u].r != HN){
    jug(Ta[u].r,p);
  }
  if(Ta[u].l != HN){
    jug(Ta[u].l,p+1);
  }
}

int main(){
  int i,j,d,vi,ci,l,r;
  cin >> num;
  for(i=0;i<num;i++){
    Ta[i].p=Ta[i].l=Ta[i].r=HN;
  }
  for(i=0;i<num;i++){
    cin >> vi >>d;
    for(j=0;j<d;j++){
      cin>>ci;
      if(j==0){
	Ta[vi].l =ci;
      }
      else Ta[l].r=ci;
      l=ci;
      Ta[ci].p=vi;
    }
  }
  for(i=0;i<num;i++){
    if(Ta[i].p ==HN){
      r=i;
    }
  }

  jug(r,0);

  for(i=0;i<num;i++){
    express(i);
  }

  return 0;
}



Measured memory_bytes: 7760
#include<cstdio>
#define Z int
#define S(n) scanf("%d",&n)
#define P(n) printf("%d",n)
#define F(i,a,b) for(Z i=a;i<=b;i++)
#define W while
#define sm(a,b) ((a)<(b)?(a):(b))
#define I if
#define E else
#define B break
#define R return
#define nx 200001
Z n,l,r,m,a[nx],no=0,inf=2e6;
Z num[nx],len[nx],t,dec,d,zr;
Z pw(Z x,Z y){
	Z s=1;
	W(y&&s<inf/x)s*=x,y--;
	R y?inf:s;
}
Z check(Z m){
	num[0]=num[t=1]=0,len[1]=a[1];
	F(i,2,n)I(a[i]>a[i-1])num[++t]=0,len[t]=a[i]-a[i-1];E{
		dec=a[i-1]-a[i];
		W(dec){
			W(num[t]&&dec)dec--,num[t]/=m,len[t]--,t-=!len[t];
			I(dec)d=sm(dec,len[t]),dec-=d,len[t]-=d,t-=!len[t];
		}
		num[t]++,zr=0;
		W(t&&num[t]==(d=pw(m,len[t])))zr+=len[t--],num[t]++;
		I(zr)num[++t]=0,len[t]=zr;
		I(num[0])R 0;
	}
	R 1;
}
Z main(){
	S(n);
	F(i,1,n)S(a[i]),no|=a[i]<=a[i-1];
	I(!no){P(1);R 0;}
	l=2,r=2e9;
	W(r-l>1)m=l+r>>1,check(m)?r=m:l=m;
	P(check(l)?l:l+1);
}

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

int main() {
  int n, m, i, j, tmp;
  cin >> n >> m;
  vector<int> a(m), b(m), ans(n, 0);
  for (i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
  }
  vector<vector<int>> cnt(n + 1, vector<int>((n + 1), 0));
  for (i = 0; i < m; i++) {
    cnt[a[i]][b[i]]++;
    cnt[b[i]][a[i]]++;
  }
  for (i = 0; i < n; i++) {
    tmp = 0;
    for (j = 0; j < n; j++) {
      tmp += cnt[i + 1][j + 1];
    }
    ans[i] = tmp;
  }
  for (i = 0; i < n; i++) {
    cout << ans[i] << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())
b = list(map(int, input().split()))
for i in range(N):
    b[i] -= 1
lis = []
for i in range(N):
    flg = False
    for j in reversed(range(N-i)):
        if b[j] == j:
            lis.append(j+1)
            del b[j]
            flg = True
            break
    if flg == False:
        print(-1)
        exit()
for i in reversed(range(N)):
    print(lis[i])


Measured memory_bytes: 9012
N = int(input()) 
i = list(map(int, input().split()))

result = 1
flag = 0
zero_flag = False
for x in range(N):
  if(i[x]==0):
    zero_flag = True
    result = 0

if(zero_flag==False):
  for x in range(N):
    result *= i[x]
    if(result>pow(10,18)):
      flag = 1
      break

if(flag==1):
  print('-1')
else:
  print(result)






Measured memory_bytes: 21656
import numpy as np
N,M,X = map(int,input().split())
shop = []
for i in range(N):
    shop.append(list(map(int,input().split())))

LIST = []
for i in range(2**N):
    L = []
    for j in range(N):
        if((i>>j) & 1):
            L.append(shop[j])
    LIST.append(L)
    
ans = 10**18

for tmp in LIST:
    tmp = np.array(tmp)
    isOK = np.sum(tmp,axis=0)
    dame = False
    if len(tmp)>0:
#         print(tmp)
        for item in isOK[1:]:
            if item < X:
                dame = True
        if dame == False:
            ans = min(ans,isOK[0])
        
if ans==10**18:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 27572
def read_inputs
  word = gets.chomp
  article = []
  loop do
    sentence = gets.chomp
    case sentence
      when "END_OF_TEXT" then break
      else article << sentence
    end
  end
  return word, article
end

word, article = read_inputs
puts article.join(" ").split(" ").select{|w| w.upcase == word.upcase}.length

Measured memory_bytes: 8580
num_of_rolls = int(input())

rolls = []

for i in range(num_of_rolls):
    result = input().split()
    rolls.append((result[0], result[1]))

combo = 0

for pair in rolls:
    if pair[0] == pair[1]:
        combo += 1
    else:
        combo = 0
    
    if combo == 3:
        print('Yes')
        exit()

print('No')
    

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

int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i=0;i<N;i++){
    cin >> H[i];
  }
  
  int ans=0;
  int maxh=H[0];
  
  for (int i=1;i<N;i++){
      if(H[i] >= maxh){
        maxh = H[i];
        ans += 1;
    }
  }
  
  cout << ans + 1 <<endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  string s,ans;
  long long k,cnt=0;
  cin>>s>>k;
  for(int i=0;i<s.length();i++){
    if(s[i]!='1')break;
    cnt++;
  }
  if(k<=cnt){
    ans='1';
  }else{
    ans=s[cnt];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import bisect
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(1,N):
  A[i] += A[i-1]
for i in range(1,M):
  B[i] += B[i-1]

  
ans = 0
for i in range(N):
  K1 = K - A[i]
  if(K1 >= 0):
    j = bisect.bisect_right(B, K1)
    ans = max(ans, i+j+1)
    
for i in range(M):
  K1 = K - B[i]
  if(K1 >= 0):
    j = bisect.bisect_right(A, K1)
    ans = max(ans, i+j+1)
print(ans)

Measured memory_bytes: 110924
def gcd(x,y):
    if y>x:
        a=y
        y=x
        x=a
    a=1
    while a*y:
        a=x%y
        x=y
        y=a
    return x

a=input()
b=list(map(int,input().split()))
l=[0]
r=[0]
g=[]
for a in range(len(b)-1):
    l.append(gcd(l[-1],b[a]))
    r.append(gcd(r[-1],b[-1-a]))
for a in range(len(l)):
    g.append(gcd(l[a],r[-1-a]))
print(max(g))

Measured memory_bytes: 14436
/**
 * author:    Ziel
 * created:   15.04.2020 19:51:56
**/

// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back

using namespace std;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const double EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	int n, k;
	cin >> n >> k;

	ll sum1 = 0, sum2 = 0;
	for (int i = 0; i < k; i++) {
		sum1 += i;
	}
	for (int i = n; i > n - k; i--) {
		sum2 += i;
	}

	ll cur1 = k, cur2 = n - k;

	ll ans = 0;
	for (int i = k; i <= n + 1; i++) {
		//cerr << "[ " << sum1 << ", " << sum2 << " ]\n";
		ans += sum2 - sum1 + 1;
		ans %= MOD;
		sum1 += cur1;
		sum2 += cur2;
		cur1++;
		cur2--;
	}

	cout << ans;
	return 0;
}




Measured memory_bytes: 3632
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    int n;
     cin >> n;
    cout << ((int)((n-1)/111)+1) *111 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	long N,a[200000];
	long i,k=1;
	long count=1;

	cin>>N;

	for(i=1;i<=N;i++){
		cin>>a[i];
	}

	for(i=1;i<=N;i++) if(a[i]==count) count++;


	if(count==1){
		cout<<"-1"<<endl;
		return 0;
	}

	cout<<N-count+1<<endl;
	return 0;
}
		


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

using namespace std;

const int MX = 100 * 1000 + 7;

int a[MX];

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    if (a[n - 1] - a[0] > 1) {
        cout << "No\n";
        return 0;
    } else if (a[n - 1] == a[0] + 1) {
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] == a[0]) {
                cnt++;
            }
        }
        int pr = a[n - 1] - cnt;
        if (pr > 0 && cnt + 2 * pr <= n) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    } else if (a[0] == a[n - 1]) {
        if (a[0] == n - 1 || 2 * a[0] <= n) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }

}


Measured memory_bytes: 640
def main():
    from functools import lru_cache
    from string import ascii_lowercase
    import sys
    sys.setrecursionlimit(10 ** 7)

    @lru_cache(maxsize=None)
    def dfs(curr: '0-indexed' = 0, max_char_index: int = -1):
        if curr == N:
            return ['']

        ret = []
        for i, c in enumerate(ascii_lowercase):
            if i > max_char_index + 1: break
            for d in dfs(curr + 1, max_char_index + (1 if i == max_char_index + 1 else 0)):
                ret.append(c + d)

        return ret

    N = int(input())
    res = dfs()
    print(*res, sep='\n')


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


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

int main() {
    int a,b,c; cin >> a >> b >> c;
    int count = 0;
    for(int i=a;i<=b;i++){
        if(c%i==0){
            count++;
        }
    }
    cout << count << endl;

    return 0;
}


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

int main() {
  int h, w;
  string S = "";
  cin >> h >> w;
  for (int i = 0; i < w+2; i++){
    S += "#";
  }
  cout << S << endl;
  for (int i = 0; i < h; i++){
    string s;
    cin >> s;
    cout << "#" << s << "#" << endl;
  }
  cout << S << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

ll mod = 1e9+7;

ll n;
//vector<vector<vector<ll>>> dp;
ll dp[2005];

ll solve(int x) {
    if(x<0) return 0;
    else if(x==0) return 1;
    else if(dp[x] != -1) return dp[x];
    ll res = 0;
    for(int i=3;i<=x;i++) res = (res + solve(x-i)) % mod;
    return dp[x] = res;
}

int main()
{
    fastio
    cin >> n;
    memset(dp, -1, sizeof dp);
    cout << solve(n);
}


Measured memory_bytes: 3648
x1, y1, x2, y2 = map(int, input().split())

x = x2 - x1
y = y2 - y1

x3 = x2 - y
y3 = y2 + x
x4 = x1 - y
y4 = y1 + x

print(str(x3) + " " + str(y3) + " " + str(x4) + " " + str(y4))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define INF 2000'000'000

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	//freopen("in", "r", stdin);
	int n, m, k, ans = 0;
	cin >> n >> m >> k;
	string grid[6];
	for(int i = 0; i < n; i++)
		cin >> grid[i];
	
	for(int r_mask = 0; r_mask < (1 << n); r_mask++){
		for(int c_mask = 0; c_mask < (1 << m); c_mask++){
			int cnt_black= 0;
			for(int i = 0; i < n; i++){
				if((r_mask >> i) & 1)
					continue;
				for(int j = 0; j < m; j++){
					if((c_mask >> j) & 1)
						continue;
					else if(grid[i][j] == '#')
						cnt_black++;
				}
			}
			ans += cnt_black == k;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)
 int main() {
   int N, ans = 0;
   cin >> N;
   vector<int> A(N);
   map<int, int> a;
   rep(i, N) {
     cin >> A.at(i);
     a[A.at(i)]++;
   }
   for (auto p: a) {
     if (p.second < p.first) ans += p.second;
     else ans += p.second - p.first;
   }
   cout << ans << endl;
 }

Measured memory_bytes: 5120
#include <iostream>
using namespace std;
using ullong = unsigned long long;

int main() {
    ullong N;
    cin >> N;
    ullong ans = 1;
    ullong M = ullong(1e9+7);
    for (ullong i=1; i<=N; ++i) {
        ans = ans * i;
        ans %= M;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3588