akhauriyash/Code-Regression huggingface dataset:
// C - Sum of product of pairs
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
	int N; cin>>N;
	vector<int> A(N); rep(i, N) cin>>A[i];
	vector<int64_t> S(N+1, 0);
	int MOD = (1e9) + 7;
	rep(i, N) S[i+1] = (S[i] + A[i]) % MOD;
	int64_t ans = 0;
	rep(i, N) ans = (ans + A[i] * (S.back() - S[i+1]) % MOD) % MOD;
	cout<< (ans + MOD) % MOD <<endl;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  printf("%d\n", max(A+B, max(A-B, A*B)));
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#define il inline
#define re register
#define fo(i,j,k) for(register int i=j;i<=k;i++)
#define do(i,j,k) for(register int i=j;i>=k;i--) 
#define inf 0x7fffffff
typedef long long ll;
using namespace std;
il ll read()
{
	ll 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<<1)+(x<<3)+(c^48),c=getchar();
	return f*x;	
}
int n; 
string s;
ll ans,a,b,c;
int main()
{
	cin>>n;
	cin>>s;
	s=" "+s;
	if(n<3)
	{
		cout<<"0";
		return 0;
	}
	fo(i,1,n)
	{
		if(s[i]=='R') a++;
		else if(s[i]=='G') b++;
		else c++;
	}
	ans=a*b*c;
	for(int i=1;i<=n-2;i++)
	{
		for(int j=i+2;j<=n;j+=2)
		{
			if(j>n) break;
			int k=(i+j)/2;
			if(s[i]!=s[j]&&s[j]!=s[k]&&s[k]!=s[i]) ans--;
		}
	}
	cout<<ans;
	return 0;
}


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

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

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

#define INF 1e9

int main(int, char**)
{
  int k;
  cin >> k;

  int m = 0, ans = -1;
  int a = 7;
  rep(i,k) {
    m = (m + a % k) % k;
    if (!m) { ans = i+1; break; }
    a = a * 10 % k;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
 
class Program
{
    const int Modulus = 1000000007;
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        long power = 1;
        for (int i = 0; i < n; i++)
        {
            power = power * (i + 1) % Modulus;
        }
        Console.WriteLine(power);
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int face[][] = new int[n][6];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < 6; j++) {
				face[i][j] = sc.nextInt();
			}
		}

		char com[] = new char[] {'E', 'N', 'E', 'N', 'E', 'N'};

		//2つめのサイコロをDiceクラスのインスタンスとして考える
		boolean frag = false;  //判定が終了したらtrueにする

		for(int i = 0; i < n-1; i++) {
			for(int j = i + 1; j < n; j++) {
				Dice4 d4 = new Dice4(face[j]);

				for(int k = 0; k < 6; k++) {  //rollのループ //なぜ7回の操作が必要なのか？
					for(int l = 0; l < 4; l++) {  //rotaのループ
						if(d4.getNum(0) == face[i][0] && d4.getNum(1) == face[i][1] && d4.getNum(2) == face[i][2]
								&& d4.getNum(3) == face[i][3] && d4.getNum(4) == face[i][4] && d4.getNum(5) == face[i][5]) {
							frag = true;
							break;
						}
						if(frag == true) break;
						d4.rota();
					}
					if(frag == true) break;
					d4.roll(com[k]);
				}
				if(frag == true) break;
			}
			if(frag == true) break;
		}
		if(frag) System.out.println("No");
		else System.out.println("Yes");
	}
}

class Dice4{
	private int a[] = new int[6];
	private int temp;

	Dice4(int face[]){
		for(int i = 0; i < 6; i++) {
			this.a[i] = face[i];
		}
	}

	public void roll(char c) {
		switch(c) {
		case 'E':
			temp = this.a[5];
			this.a[5] = this.a[2];
			this.a[2] = this.a[0];
			this.a[0] = this.a[3];
			this.a[3] = temp;
			break;
		case 'N':
			temp = a[5];
			this.a[5] = this.a[4];
			this.a[4] = this.a[0];
			this.a[0] = this.a[1];
			this.a[1] = temp;
			break;
		case 'S':
			temp = this.a[5];
			this.a[5] = this.a[1];
			this.a[1] = this.a[0];
			this.a[0] = this.a[4];
			this.a[4] = temp;
			break;
		case 'W':
			temp = this.a[5];
			this.a[5] = this.a[3];
			this.a[3] = this.a[0];
			this.a[0] = this.a[2];
			this.a[2] = temp;
			break;
		}
	}
	public void rota() {  //横方向の回転をさせるメソッド
		temp = this.a[1];
		this.a[1] = this.a[2];
		this.a[2] = this.a[4];
		this.a[4] = this.a[3];
		this.a[3] = temp;
	}

	public int getNum(int i) {
		return this.a[i];
	}
}


Measured memory_bytes: 29576
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[1000][10];

int main() {
	ll n, k;
	cin >> n >> k;
	ll n1 = n / 11;
	ll n2 = n % 11;
	int index = 1;
	rep(i, 0, 1000) {
		rep(j, 0, 7) {
			d[i][j] = index;
			index++;
		}
	}
	if (n < 3) {
		cout << "0" << endl;
		return 0;
	}
	if (n < 100) {
		ll b = 0;
		rep(i, 0, n - 2) {
			rep(j, 0, 5) {
				ll a = 0;
				rep(y, 0, 3) {
					rep(x, 0, 3) {
						a += d[i + y][j + x];
					}
				}
				if (a % 11 == k)b++;
			}
		}
		cout << b << endl;
		return 0;
	}
	ll b = 0;
	rep(i, 0, 11) {
		rep(j, 0, 5) {
			ll a = 0;
			rep(y, 0, 3) {
				rep(x, 0, 3) {
					a += d[i + y][j + x];
				}
			}
			if (a % 11 == k)b++;
		}
	}
	ll c = 0;
	rep(i, 0, 11 + n2 - 2) {
		rep(j, 0, 5) {
			ll a = 0;
			rep(y, 0, 3) {
				rep(x, 0, 3) {
					a += d[i + y][j + x];
				}
			}
			if (a % 11 == k)c++;
		}
	}
	cout << b*(n1 - 1) + c << endl;
	return 0;
}

Measured memory_bytes: 256
import fractions
n = int(input())
li = list(map(int, input().split()))

g = li[0]
for i in range(1, n):
    g = g * li[i] // fractions.gcd(g, li[i])

ans = 0
for i in range(n):
    ans += g // li[i]

print(ans % (10**9+7))

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

#define M 1000000
#define L 14

char H[M][L];

int getChar(char ch)
{
  if(ch == 'A')
    {
      return 1;
    }
  else if(ch == 'C')
    {
      return 2;
    }
  else if(ch == 'G')
    {
      return 3;
    }
  else if(ch == 'T')
    {
      return 4;
    }
}

long long getKey(char str[])
{
  long long sum = 0,p = 1,i;
  for(i = 0;i < strlen(str);i++)
    {
      sum += p*(getChar(str[i]));
      p *= 5;
    }
  return sum;
}

int h1(int key)
{
  int ans;
  ans = key % M;
  return ans;
}

int h2(int key)
{
  int ans;
  ans = 1 + key % (M - 1);
  return ans;
}

int find(char str[])
{
  long long key,i,a;
  key = getKey(str);
  for(i = 0;i < M;i++)
    {
      a  = (h1(key) + i *h2(key)) % M;
      if(strcmp(H[a],str) == 0)
	{
	  return 1;
	}
      else if(strlen(H[a]) == 0)
	{
	  return 0;
	}
    }
}

int insert(char str[])
{
  long long key,i,a;
  key = getKey(str);
  for(i = 0;i < M;i++)
    {
      a = (h1(key) + i * h2(key)) % M;
      if(strcmp(H[a],str) == 0)
	{
	  break;
	}
      else if(strlen(H[a]) == 0)
	{
	  strcpy(H[a],str);
	  break;
	}
    }
  return 0;
}

int main()
{
  int i,n;
  char str[L],com[9];
  for(i = 0;i < M;i++)
    {
      H[i][0] = '\0';
    }
  scanf("%d",&n);

  for(i = 0;i < n;i++)
    {
      scanf("%s %s",com,str);

      if(com[0] == 'i')
	{
	  insert(str);
	}
      else
	{
	  if(find(str))
	    {
	      printf("yes\n");
	    }
	  else
	    {
	      printf("no\n");
	    }
	}
    }
  return 0;
}



Measured memory_bytes: 15460
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int main(){
	int n;
	cin >> n;

	vector<int> x(n);
	cin >> x;

	vector<int> s(all(x));
	sort(all(s));

	int low = s[n / 2 - 1], high = s[n / 2];
	for(auto i : x){
		if(i < high) cout << high << endl;
		else cout << low << endl;
	}
}


Measured memory_bytes: 3712
BIGMOD = 998244353
 
def modPow(x,n):
    ans = 1
    while n >= 1:
        if bin( n & 1)==bin(1):
            ans = (ans*x) % BIGMOD
        x = x * x % BIGMOD
        n = n>>1
    return ans % BIGMOD
 
def modFact(N):
    fact = []
    fact.append(1) #0! = 1
    for i in range(1,N+1):
        a = fact[i-1]*i % BIGMOD
        fact.append(a)
    return fact
 
def modInvFact(fact):
    invFact = []
    for i in range(1,N+2):
        a = modPow(fact[i-1],BIGMOD-2)
        invFact.append(a)
    return invFact
 
def modPlus(a,b):
    return (a + b) % BIGMOD
 
def modMinus(a,b):
    if a-b >= 0:
        return (a - b) % BIGMOD
    else:
        return (a - b + BIGMOD)
    
def modMulti(a,b):
    return a * b % BIGMOD
 
# fact(n),invFact(r),invFact(n-r)
def nCr(fact,invFact,n,r):
    return (fact[n] * invFact[r] * invFact[n-r] ) %BIGMOD
 
def nPr(fact,invFact,n,r):
    return(fact[n] * invFact[r])%BIGMOD
 
def fact(num):
    ans = 1
    for i in range(1,num+1):
        ans = ans*i%BIGMOD
    return ans
 
import collections
 
N = int(input())
D = list(map(int,input().split()))
 
S = list(set(D))
S.sort()
if S[0]==0:
    S.pop(0)
ans = 1
before = 0
before_i = 0
c = collections.Counter(D)
if c[0] > 1:
  ans=0
for i in S:
    if i == 1:
        before = c[i]
        before_i = i
        continue
    ans = ans*modPow(before,c[i])%BIGMOD
    before = c[i]
    if i - before_i!=1:
        ans = 0
    before_i = i
if D[0] >0:
    print(0)
else:
    print(ans)

Measured memory_bytes: 62824
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_StationandBus_158
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();

            string s1 = s.Substring(0, 1);
            string s2 = s.Substring(1, 1);
            string s3 = s.Substring(2, 1);

            string result;

            if (s1 == s2 && s2 == s3)
            {
                result = "No";
            }
            else
            {
                result = "Yes";
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 25812
#include <stdio.h>
#include <string.h>
int main(){
  int	n, cnt=0;
  char	s[51]={0};
  char	*ptr;
  scanf("%d", &n);
  scanf("%s", s);
  
  ptr = strstr( s, "ABC" );
  while( ptr ){
    cnt++;
    *ptr = 0x2d;
    ptr = strstr( ptr, "ABC" );
  }
  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 1700
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val a = sc.nextInt()
  val b = sc.nextInt()
  val c = sc.nextInt()

  val list = mutableListOf<Int>()
  for (i in 1..b) {
    val tmp = i * a % b
    list.add(tmp)
  }

  for (i in list) {
    if (i == c) {
      println("YES")
      return
    }
  }

  println("NO")
}


Measured memory_bytes: 36396
#include<bits/stdc++.h>
using namespace std;
long long n;
int a[500001],cnt=0;
int main(){
	cin>>n;
	int i,ans=0;
	for(i=2;i<=sqrt(n);++i){
		if(n%i==0){
			while(n%i==0){
				++a[cnt];
				n/=i;
			}
			++cnt;
		}
	}
	if(n!=1)++ans;
	for(i=0;i<cnt;++i){
		//cout<<a[i]<<endl;
		ans+=(-1+sqrt(1+8*a[i]))/2;
	}
	cout<<ans;
} 

Measured memory_bytes: 3656
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  string s;
  cin >> s;
  int ans = s.length();
  for (int i = 0; i < 26; i++) {
    if (s.find(('a' + i)) == string::npos) continue;
    string t(s.length(), '?');
    for (int j = 0; j < (int)s.length(); j++)
      if (s[j] == ('a' + i)) t[j] = s[j];
    int cnt = 0;
    while (t.find('?') != string::npos) {
      string t_(t.length() - 1, '?');
      for (int j = 0; j < (int)t_.length(); j++) {
        if (t[j] == ('a' + i) || t[j + 1] == ('a' + i)) {
          t_[j] = 'a' + i;
        }
      }
      t.swap(t_);
      cnt++;
    }
    // debug(t);
    // debug(cnt);
    ans = min(ans, cnt);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int h = sc.nextInt();
    int w = sc.nextInt();
    int[][] hw = new int[n][2];
    
    for(int i=0; i<n; i++){
      for(int j=0; j<2; j++){
        hw[i][j] = sc.nextInt();
      }
    }
    
    int cnt = 0;
    
    for(int i=0; i<n; i++){
      if(hw[i][0] >= h && hw[i][1] >= w){
        cnt++;
      }
    }
    
    System.out.println(cnt);
  }
}


Measured memory_bytes: 25904
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print("{0} {1} {2}".format(i, j, (n - i - j)))
            exit(0)
print("-1 -1 -1")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define je 1000000007
using namespace std;

int n;
long long su[100005];
long long sum[100005];
long long lsum[100005];
long long rsum[100005];

long long fact[100005];
long long inv[100005];

long long invv(long long x){
    int lft = je - 2;
    long long ret = 1;
    long long gop = x;
    while(lft){
        if(lft & 1){
            ret = (ret * gop) % je;
        }
        gop = (gop * gop) % je;
        lft >>= 1;
    }
    return ret;
}

int main(){
    scanf("%d", &n);
    fact[0] = 1;
    for(int i=1;i<=n;i++){
        fact[i] = (fact[i-1] * i) % je;
        inv[i] = invv(fact[i]);
    }
    for(int i=1;i<=n;i++){
        scanf("%lld", &su[i]);
    }
    for(int i=1;i<=n;i++){
        sum[i] = (sum[i-1] + su[i]) % je;
        lsum[i] = (lsum[i-1] + i * su[i]) % je;
    }
    for(int i=n;i>=1;i--){
        rsum[i] = (rsum[i+1] + (n+1-i) * su[i]) % je;
    }
    long long ans = (fact[n] * ((sum[n] - sum[0] + je) % je)) % je;
    for(int ii=1;ii<n;ii++){
        long long cal1 = (sum[n] - sum[n-ii] + je + sum[ii]) % je;
        long long gop1 = ((fact[n] * inv[ii+1]) % je * fact[ii]) % je;
        long long gap = min(ii, n-1-ii);
        long long cal2 = (sum[n-gap] - sum[gap] + je) % je;
        cal2 = (cal2 * (gap+1)) % je;
        long long cal3 = (lsum[gap] + rsum[n+1-gap]) % je;
        cal2 = (cal2 + cal3) % je;
        cal2 = (cal2 + je - sum[n]) % je;
        long long gop2 = ((fact[n] * inv[ii+2]) % je * fact[ii] * 2) % je;
        long long cal = (cal1 * gop1 + cal2 * gop2) % je;
        ans = (ans + cal) % je;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 4992
while True:
    n, m = map(int, input().split())
    if not n:
        break
    stops = [int(input()) for _ in range(n)] + [0] * 5
    dices = [int(input()) for _ in range(m)]
    i, p = 1, 0
    g = n - 1
    for d in dices:
        p += d + stops[p + d]
        if p >= g:
            break
        i += 1
    print(i)

Measured memory_bytes: 7676
import copy
from collections import Counter

N = int(input())
K = list(map(int,input().split()))
"""
N = 4
K = [1, 2 ,3 ,4]
"""
a = list(set(K))
#print(a)
a_count = {}



a_count = Counter(K)
#print(c)

#print(a_count)

ans_dict = 0
for l in a_count.values() :
        
    ans_dict += l * (l-1)  // 2

#print(ans_dict)

"""
for i in a_count :

    a_count_2 = copy.deepcopy(a_count)
    
    a_count_2[i] -= 1

    #print(a_count_2)
    
    ans_dict[i] = 0
    for l in a_count_2.values() :
        
        ans_dict[i] += l * (l-1)  // 2

#print(ans_dict)
"""

for i in K:
    print(ans_dict - (a_count[i]-1))
    pass

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int K;
    cin >> K;
    vector<ll> a(K);
    rep(i, K) cin >> a[i];

    ll l = 0;
    ll r = 1LL << 60;
    while (r - l > 1) {
        ll c = (l + r) / 2;
        ll tmp = c;
        rep(i, K) tmp = (tmp / a[i]) * a[i];
        if (tmp >= 2) r = c;
        else l = c;
    }
    ll L = r;

    l = 0;
    r = 1LL << 60;
    while (r - l > 1) {
        ll c = (l + r) / 2;
        ll tmp = c;
        rep(i, K) tmp = (tmp / a[i]) * a[i];
        if (tmp > 2) r = c;
        else l = c;
    }
    ll R = l;

    if (L > R) cout << -1 << endl;
    else cout << L << " " << R << endl;
}

Measured memory_bytes: 1024
n,x = map(int, input().split())
a = list(map(int, input().split()))
b = a[::-1]

def solve(a):
    total = 0
    if a[0] > x:
        total += a[0]-x
        a[0] = x

    for i in range(1, n):
        if a[i-1] + a[i] > x:
            d = (a[i-1] + a[i]) - x
            total += d
            a[i] = max(0, a[i] - d)
    return total

print(min(solve(a), solve(b)))


Measured memory_bytes: 14548
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
	int N;
	cin >> N;
	int D;
	cin >> D;
	vector<int>X(N);
	vector<int>Y(N);
	int a = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> X[i];
		cin >> Y[i];
		if (pow(pow(X[i],2)+pow(Y[i],2),0.5) <= D)
		{
			a++;
		}
	}
	cout << a << endl;
}

Measured memory_bytes: 4896
#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); }
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * ceil_(a, b)); }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

signed main() {
  int n;
  cin >> n;
  while (n != 0) {
    vector<int> p(n);
    deque<int> j(n - 1);
    rep(i, n) cin >> p[i];
    rep(i, n - 1) cin >> j[i];
    vector<int> num(n);
    sort(ALL(j), greater<int>());
    cumulative_sum(j);
    j.emplace_front(0);
    int p_sum = accumulate(ALL(p), 0LL);
    int ans   = 0;
    rep(i, n) {
      ans = max(ans, (i + 1) * (p_sum + j[n - (i + 1)]));
    }
    cout << ans << endl;
    cin >> n;
  }
}



Measured memory_bytes: 4328
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    static const int MAXN=1e5+10;
    int isprime[MAXN];
    int similar[MAXN];
    void calIsPrime(){
        for(int u=0;u<MAXN;u++)isprime[u]=true;
        isprime[0]
        =isprime[1]=false;
        for(int u=2;u<MAXN;u++){
            if(isprime[u]==false)continue;
            if(isprime[(u+1)/2])similar[u]=true;
            for(int v=u+u;v<MAXN;v+=u)
                isprime[v]=false;
        }
    }
    void solve(){
        calIsPrime();
        for(int u=1;u<MAXN;u++){
            similar[u]+=similar[u-1];
        }
        int q;
        cin>>q;
        while(q--){
            int l,r;
            cin>>l>>r;
            cout<<similar[r]-similar[l-1]<<'\n';
        }
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    char a[n][n], b[m][m];
    rep(i, 0, n) {
        rep(j, 0, n) {
            cin >> a[i][j];
        }
    }
    rep(i, 0, m) {
        rep(j, 0, m) {
            cin >> b[i][j];
        }
    }

    for (int i = 0; i <= n - m; i++) {
        for (int j = 0; j <= n - m; j++) {
            bool flag = true;;
            for (int k = 0; k < m; k++) {
                for (int l = 0; l < m; l++) {
                    if (a[i + k][j + l] != b[k][l]) {
                        flag = false;
                    }
                }
            }
            if (flag) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}


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

using namespace std;

int main(){

    
    long long a,b,min,max,num=0;

    cin>>a;
    cin>>b;

    if(a<b){
        min = a;
        max = b;
    }else{
        min = b;
        max = a;
    }

    for (int i = min+1; i <= max; i++)
    {   
        if(abs(a-i) == abs(b-i)){
            num = i;
        }
    }

    if(num != 0){
        cout<<num<<endl;
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }
    
}


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

int main() {
	int W, H, x, y, r;
	cin >> W;
	cin >> H;
	cin >> x;
	cin >> y;
	cin >> r;

	if (x <= (W - r) && x >= r && y <= (H - r) && y >= r)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3072
import sys
x, n = list(map(int, input().split()))
p = list(map(int, input().split()))

if (n == 0):
    print(x)
    sys.exit()

i = 0
while True:
    if (not (x-i) in p):
        print(x-i)
        break
    if (not (x+i) in p):
        print(x+i)
        break
    i += 1


Measured memory_bytes: 9128
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  string s;

  sc.scan(s);

  int res = 0;

  foreach (i; 0 .. 3) {
    if (s[i] == '1')
      res++;
  }

  writeln(res);
}


Measured memory_bytes: 256
S = input()
count = 0
max_c = 0

for i in range(len(S)):
    if S[i] == 'A' or S[i] == 'T' or S[i] == 'C' or S[i] == 'G':
        count +=1
    else:
        if count > max_c:
            max_c = count
        count = 0
if count > max_c:
    max_c = count
print(max_c)

Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <iostream>
using namespace std;

int n;
set<string> st;
vector<vector<string> > group;
map<string,int> gindex;
vector<bool> flag;


void func(int index){
	flag[index] = true;
	map<string,int>::iterator it;

	for(int i = 0; i < group[index].size(); ++i){
		it = gindex.find(group[index][i]);

		if( it == gindex.end() ){
			st.insert(group[index][i]);
		}
		else if( !flag[it->second] ){
			func(it->second);
		}
	}
}


int main(){
	char str[64] = "";
	int n;

	string ln;
	while(1){
		getline(cin, ln);
		int d0 = -9, d1 = -9;
		char cc = 0;
		sscanf(ln.c_str(), " %n%d%c", &d0, &n, &cc);
		if(d0 != 0 || cc != 0){
			throw 0;
		}
		if(n == 0){ break; }
		
		if(n > 100){ throw 0; }
		
		group.assign(n, vector<string>());
		flag.assign(n, false);
		st.clear();
		gindex.clear();

		for(int i = 0; i < n; ++i){
			getline(cin, ln);
			const char *ptr = ln.c_str();

			d0 = d1 = -9;
			sscanf(ptr, " %n%[^:]:%n", &d0, str, &d1);
			if(d0 != 0 || d1 == -9){ throw 0; }
			gindex[str] = i;
			ptr += d1;

			char ch = ',';
			while(ch != '.'){
				d0 = d1 = -9;
				ch = 0;
				sscanf(ptr, " %n%[^,.]%c%n", &d0, str, &ch, &d1);
				if(d0 != 0 || d1 == -9 || (ch != '.' && ch != ',')){
					throw 0;
				}
				group[i].push_back(str);
				ptr += d1;
			}
			if(*ptr){
				throw 0;
			}
			
			if(group[i].empty() || group[i].size() > 10){
				throw 0;
			}
		}

		func(0);
		cout << st.size() << endl;
	}
	
	if(!cin.good()){
		throw 0;
	}
	cin.peek();
	if(cin.good()){
		throw 0;
	}
	
	for(volatile int i = 0; i < 100000000; ++i);
}

Measured memory_bytes: 1392
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  long long n,a[100000],b[100000],ans=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i] >> b[i];
  }
  for(int i=n-1; i>=0; i--) {
    a[i]+=ans;
    if(a[i]%b[i]!=0) {
      ans+=((a[i]/b[i])+1)*b[i]-a[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define F(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define VE(i,v) for(int i = 0;i < (v).size();i++)

using namespace std;
#define trace(...) cerr<<__FUNCTION__<<":"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned int ui;
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
typedef pair<ll,ll> pll;
typedef vector<pll> vpll; 
 

constexpr int b = 80*80+3;
constexpr int m = b*2;


int main()

{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	int T;
	T=1;
	for(int tc=1; tc<=T;tc++)
	{
		int H,W;
		cin >> H >> W;
		vvi A(H, vi(W));
		vvi B(H, vi(W));
		for(int i =0; i < H; i++)
			for(int j=0; j < W; j++)
				cin >> A[i][j];
		for(int i =0; i < H; i++)
			for(int j=0; j < W; j++)
				cin >> B[i][j];
		bitset<m> dp[81];
		int i =0;
		dp[0][b+abs(A[0][0] - B[0][0])]=1;
		dp[0][b-abs(A[0][0] - B[0][0])]=1;
		while(i < H)
		{
			int j =0;
			while(j < W)
			{
				if(true)
				{
						//trace(i,j,k);
						int temp;
						
						

						if(j!=W-1)
						{
							temp = abs(A[i][j+1] - B[i][j+1]);
							dp[j+1] = dp[j+1] | (dp[j] << temp) | (dp[j] >> temp);
						}

						if(i!=H-1)
						{
							temp = abs(A[i+1][j] - B[i+1][j]);
							//trace(i,j,k, temp);
							dp[j] = (dp[j]<<temp) | (dp[j] >> temp);
							//trace(j, dp[j]);
						}
						

						
				}
				
				j++;
			}
			

			i++;
		}
		int ans = dp[W-1]._Find_next(b - 1) - b;
			
		cout<<ans<<"\n";






	}
 
 
 
	return 0;
}
 
 


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)
#define EPS (1e-4)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int dp[4][256];
int board[5][5];

int ten[4] = { 0,60,70,80 };

#define H(h,x) ((h>>(x+x)) & 3)

int solve(int now, int h){
  if(dp[now][h] != -1) return dp[now][h];
  int ret = 0;

  int tmp[5] = {0};
  if(board[now][0] != 0) tmp[0] = 1 + ((board[now][0] - 1) + H(h,0)) % 4;
  if(board[now][1] != 0) tmp[1] = 1 + ((board[now][1] - 1) + H(h,0) + H(h,1)) % 4;
  if(board[now][2] != 0) tmp[2] = 1 + ((board[now][2] - 1) + H(h,1) + H(h,2)) % 4;
  if(board[now][3] != 0) tmp[3] = 1 + ((board[now][3] - 1) + H(h,2) + H(h,3)) % 4;
  if(board[now][4] != 0) tmp[4] = 1 + ((board[now][4] - 1) + H(h,3)) % 4;

  REP(x,256){
    int rtmp = 0;
    if(tmp[0] != 0) rtmp += ten[((tmp[0] - 1) + H(x,0)) % 4];
    if(tmp[1] != 0) rtmp += ten[((tmp[1] - 1) + H(x,0) + H(x,1)) % 4];
    if(tmp[2] != 0) rtmp += ten[((tmp[2] - 1) + H(x,1) + H(x,2)) % 4];
    if(tmp[3] != 0) rtmp += ten[((tmp[3] - 1) + H(x,2) + H(x,3)) % 4];
    if(tmp[4] != 0) rtmp += ten[((tmp[4] - 1) + H(x,3)) % 4];

    if(now == 3){
      if(board[4][0] != 0)
        rtmp += ten[((board[4][0] - 1) + H(x,0)) % 4];
      if(board[4][1] != 0)
        rtmp += ten[((board[4][1] - 1) + H(x,0) + H(x,1)) % 4];
      if(board[4][2] != 0)
        rtmp += ten[((board[4][2] - 1) + H(x,1) + H(x,2)) % 4];
      if(board[4][3] != 0)
        rtmp += ten[((board[4][3] - 1) + H(x,2) + H(x,3)) % 4];
      if(board[4][4] != 0)
        rtmp += ten[((board[4][4] - 1) + H(x,3)) % 4];
      ret = max(ret, rtmp);
    }else{
      ret = max(ret, rtmp + solve(now+1,x));
    }
  }
  return dp[now][h] = ret;
}

int main(){
  int n = getInt();
  while(n --> 0){
    memset(dp, -1, sizeof(dp));
    REP(i,5) REP(j,5) board[i][j] = getInt();
    print(solve(0,0));
  }
  return 0;
}

Measured memory_bytes: 844
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll X, ll Y) {
  cout << X + Y/2 << endl;
}

int main() {
  ll X;
  cin >> X;
  ll Y;
  cin >> Y;
  solve(X, Y);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int n,k;
  cin >> n >> k;
  map<int,int> ma;
  for(int i = 0;i < n;i++){
    int num = 0;
    cin >> num;
    ma[num]++;
  }
  vector<int> count;
  for(auto& i:ma){
    count.push_back(i.second);
  }
  sort(count.begin(),count.end());
  int res = 0;
  if(count.size() <= k){
    cout << 0 << endl;
    return 0;
  }
  for(int i = 0;i < count.size() - k;i++)res += count[i];
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 10748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
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; }
int Inf = (1<<30);
ll inf = (1LL<<60);
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 main() {
	int n;
	cin >> n;
	int i;
	bool flag[9] = {};
	int count = 0;
	int wild = 0;
	for (i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a >= 3200) {
			wild++;
			continue;
		}
		if (!flag[a / 400]) {
			count++;
			flag[a / 400]++;
		}
	}
	int f = count ? count : 1;
	int s = count + wild;
	cout << f << " " << s;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define for0(i,n) for(int i=0;i<n;i++)
#define rep(i,s,n) for(int i=s;i<n;i++)
#define sp <<" "<<					// giving space
#define MOD 1000000007				// for mod
#define ll_max 1000000000000000000
#define ll long long
#define ld long double
#define BOOST ios_base::sync_with_stdio ( false ); cin.tie ( nullptr ); cout.tie ( nullptr );
using namespace std;
// Vector
#define vi vector<int>					//integer vector
#define vll vector<ll>
#define pb push_back				//vector element insertion
#define pf push_front
#define er(v,i) v.erase(v.begin()+i)			// erase ith element in a vector
#define erng(v,x) v.erase(v.begin(),v.begin()+x)       	// delete a range in array

//Stack
/*  stack<int> s;						//declaring stack
s.push(1)						// enter  element in stack
s.top()							//returns top element in stack
s.pop()							//removes top element in  stack
*/
// pair
#define pii pair<int,int>					//pair integers
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)			// entering pair element in vector(size not defined)

//Hashmap
/* map<string,string> a;				//declaration
a[“abc”]=”xyz”;					// element entry in map;
gquiz1.insert(pair<int, int>(1, 40));
map<string,string>::iterator itr;			//iterating map
for (itr = a.begin(); itr!=a.end(); itr++){
    cout <<(*itr).first  << itr->second <<endl;
  }
  itr = companies.find("abc");		//finding element in map
  cout << itz->second;

//*/
int dp[3005][3005];
int main()
{
    stack<char> a;
    string s,t;
    cin>>s>>t;
    int n=t.size(),m=s.size();
for0(i,m+1)
{
    for0(j,n+1)
     {
       if (i == 0 || j == 0)
         dp[i][j] = 0;
       else if (s[i-1] == t[j-1])
         dp[i][j] = dp[i-1][j-1] + 1;
       else
         dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
     }
}
//cout<<dp[m][n]<<endl;
    while(n>0&&m>0)
    {
        //cout<<dp[n][m] sp dp[n][m-1]<<endl;
        if(s[m-1]==t[n-1])
        {
            m--;
            n--;
            a.push(s[m]);
        }
        else if(dp[m-1][n]>dp[m][n-1])m--;
        else
        {
            n--;
        }

    }
    n=t.size();m=s.size();
    n=dp[n][m];

    while(!a.empty())
    {
        char c=a.top();
        cout<<c;
        a.pop();
    }
    if(n==0)cout<<"";
    /*
    for0(i,n)
    {
        for0(j,m)cout<<dp[i+1][j+1]<<" ";
        cout<<endl;
    }*/
}


Measured memory_bytes: 35456
import sys


def main():
    l, r = [int(s) for s in sys.stdin.readline().strip().split()]
    mods = []
    seen = set()
    for n in range(l, r+1):
        mod = n % 2019
        if mod in seen:
            break
        mods.append(mod)
        seen.add(mod)

    ans = 2019
    for i in range(len(mods)-1):
        for j in range(i+1, len(mods)):
            cand = (mods[i] * mods[j]) % 2019
            ans = min(ans, cand)
    print(ans)


if __name__ == '__main__':
    main()



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

#define ulli unsigned long long int
#define ll long long
#define ld long double

using namespace std; 
void solve(); 
int main() 
{ 
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
  
    int t = 1; 
    // cin >> t; 
    while (t--) { 
        solve(); 
    } 
  
    cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
    return 0; 
} 

void solve() 
{ 
	ulli h, w;
    cin >> h >> w;

    if (h == 1 || w == 1) {
        cout << 1 << "\n";
        return;
    }

    ulli area = h*w;

    ulli ans = (area & 1) ? (area / 2) + 1 : (area / 2);

    cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int[] d = new int[n];
        
        for(int i = 0; i < n; i++) d[i] = sc.nextInt();
        
        int res = 0;
        
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n; j++){
                res+=d[i]*d[j];
            }
        }
        
        System.out.println(res);
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll n;
    cin >> n;
    ll f[9]; mem(f, 0);
    rep(i, n)
    {
        ll z; cin >> z;
        for(ll j = 400, k = 0; j <= 3200; j+=400)
        {
            if(z < j) {f[k] = 1; break;}
            else k++;
        }
        if(z >= 3200) f[8]++;
    }
    ll ans = 0;
    rep(i, 9) ans += f[i];
    cout << max(ans - f[8], 1ll) << " " << ans;
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<max(a,max(b,c))-min(a,min(b,c))<<endl;
  return 0;
}


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

using namespace std;

int gcd(int a, int b) {

    if(a < b) return gcd(b, a);
    int r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
  return b;

}

int gcd3(int a, int b, int c) {
    int g = 1;

    g = gcd(a, b);
    g = gcd(g, c);

    return g;
}

int main() {
    int K;
    int res = 0;
    cin >> K;

    for(int a = 1; a <= K; a++) {
        for(int b = 1; b <= K; b++){
            for(int c = 1; c <= K; c++){
                res += gcd3(a, b, c);
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <string>
#include <vector>

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

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

    int N = S.length();
    rep(i, N) {
        if (i % 2 == 0) {
            /* code */
            if (S[i] != 'R' && S[i] != 'U' && S[i] != 'D') {
                /* code */
                cout << "No"; return 0;
            }
        }
        else if (i % 2 == 1) {
            if (S[i] != 'L' && S[i] != 'U' && S[i] != 'D') {
                /* code */
                cout << "No"; return 0;
            }
        }
    }
    printf("Yes");
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N, K;
  std::cin >> N >> K;
  std::vector<i64> h;
  tools::read(h, N);
  std::sort(h.begin(), h.end());
  i64 answer = std::numeric_limits<i64>::max();
  for (i64 i = 0; i <= N - K; ++i) {
    answer = std::min(answer, h[i + K - 1] - h[i]);
  }
  std::cout << answer << std::endl;
  return 0;
}

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

template<typename T> class Dijkstra {
public:
  struct edge {
    int to; T cost;
  };
  int V;
  vector<vector<edge>> G;
  vector<T> dist;
  using pti = pair<T,int>;
  Dijkstra(int n) : V(n), G(V), dist(V, numeric_limits<T>::max()) {}
  void add(int u, int v, T cost) {
    G.at(u).push_back((edge) {v, cost});
    G.at(v).push_back((edge) {u, cost});
  }
  void solve(int s) {
    priority_queue<pti, vector<pti>, greater<pti>> Q;
    dist.at(s) = 0;
    Q.push(pti(0, s));
    while (!Q.empty()) {
      pti p = Q.top();
      Q.pop();
      int v = p.second;
      if (dist.at(v) < p.first) continue;
      for (auto &w : G.at(v)) {
        if (dist.at(w.to) > dist.at(v) + w.cost) {
          dist.at(w.to) = dist.at(v) + w.cost;
          Q.push(pti(dist.at(w.to), w.to));
        }
      }
    }
  }
};

int main() {
  int N;
  cin >> N;
  Dijkstra<long> D(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    D.add(--a, --b, c);
  }
  int Q, K;
  cin >> Q >> K;
  D.solve(--K);
  while (Q--) {
    int x, y;
    cin >> x >> y;
    cout << D.dist.at(--x) + D.dist.at(--y) << "\n";
  }
}

Measured memory_bytes: 11120
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int a,b;
    cin>>a>>b;
    if (a==1 && b==1)
        cout<<"Draw\n";
    else if (a==b)
        cout<<"Draw\n";
    else if (a==1 && b!=1)
        cout<<"Alice\n";
    else if (a!=1 && b==1)
        cout<<"Bob\n";
    else if (a>b)
        cout<<"Alice\n";
    else if (a<b)
        cout<<"Bob\n";
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val an = readLine()!!.split(" ").map(String::toInt)
    val sortedAn = an.sortedDescending()
    val alice = sortedAn.filterIndexed { index, i -> index % 2 == 0 }
    val bob = sortedAn.filterIndexed { index, i -> index % 2 == 1 }
    println(alice.sum() - bob.sum())
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

const int N = 123;
const long long inf = 1e17;

int f[N][5][2];
int p[N][10];

void solve() {
	int n; scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 5; ++j) {
			scanf("%d%d", f[i][j], f[i][j]+1);
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 11; ++j) {
			scanf("%d", p[i]+j);
		}
	}
	int i[5];
	long long ans = -inf;
	for (i[0] = 0; i[0] < 4; ++i[0]) {
		for (i[1] = 0; i[1] < 4; ++i[1]) {
			for (i[2] = 0; i[2] < 4; ++i[2]) {
				for (i[3] = 0; i[3] < 4; ++i[3]) {
					for (i[4] = 0; i[4] < 4; ++i[4]) {
						if (!(i[0] || i[1] || i[2] || i[3] || i[4])) continue;
						int c[N] = {};
						long long cur = 0;
						for (int j = 0; j < n; ++j) {
							for (int k = 0; k < 5; ++k) {
								c[j] += f[j][k][0] && (i[k]&1);
								c[j] += f[j][k][1] && (i[k]&2);
							}
							cur += p[j][c[j]];
						}
						ans = max(cur, ans);
					}
				}
			}
		}
	}
	printf("%lld", ans);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
import itertools

n,m,q=map(int,input().split())
List=[]
for i in range(m):
    List.append(i+1)
ans=[0,0]
a=[0]*q
b=[0]*q
c=[0]*q
d=[0]*q
for i in range(q):
    a[i],b[i],c[i],d[i]=map(int,input().split())
    
for v in itertools.combinations_with_replacement(List,n):
    ans[0]=0
    #print(v)
    for i in range(q):
        if (v[b[i]-1]-v[a[i]-1]==c[i]):
            ans[0]+=d[i]
           # print("Got",a[i],b[i],c[i],d[i])
    #print(ans[0])
    ans[1]=max(ans[1],ans[0])
    
print(ans[1])

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

int main() {
	// your code goes here
	long long a;
	long long b;
	long long r;
	long long gcd;
	long long lcm;
	while(cin>>a>>b){
		
		long long c=a;
		long long d=b;
		while(true){
		r=c%d;
		if(r==0){gcd=d; break;}
		c=d; d=r;
		
		}

	lcm= a*b / gcd;
	
	
	cout << gcd << " " << lcm << endl;	
	}
	return 0;
	
	
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    int n;cin>>n;
    cout << 3*n*n << endl;
}



Measured memory_bytes: 256