akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 * 0001：List of Top 3 Hills
 * 
 * @author Lyu
 * @version 2015/06/21
 */
public class Main {

    /**
     * 10個のデータを読み込み、高い順に3つ出力する。
     * 
     * @param args
     * @throws IOException 
     * @throws NumberFormatException 
     */
    public static void main(String[] args) throws NumberFormatException, IOException {

        // 標準入力読取り
        int[] heightOfHills = getHeightOfHills();
        
        // 高い順に3つを表示
        printTop3(heightOfHills);
    }

    
    /**
     * 標準入力を読み取り、山の高さを表すデータを要素数10の配列で返す。
     * 
     * @return 山の高さを表す配列
     * @throws NumberFormatException
     * @throws IOException
     */
    private static int[] getHeightOfHills() throws NumberFormatException, IOException {
        // 入力読取り
        InputStreamReader streamReader = new InputStreamReader(System.in);
        BufferedReader bufferedReader = new BufferedReader(streamReader);

        String line = null;
        int[] heightOfHills = new int[10];
        int count = 0;

        try {
            while ((line = bufferedReader.readLine()) != null) {
                heightOfHills[count] = Integer.parseInt(line);
                ++count;
            }
        } finally {
            bufferedReader.close();
            streamReader.close();
        }
        return heightOfHills;
    }

    /**
     * 受け取ったint型配列要素を、数値の大きい順に3つ出力する。
     * 
     * @param array int型の配列
     */
    private static void printTop3(int[] array) {
        // ソート
        Arrays.sort(array);
        
        // 高い順に3つを出力
        for (int i = 1; i <= 3; ++i) {
            System.out.println(array[array.length - i]);
        }
    }
}

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

int main(){
  string s;
  cin >> s;
  int flag = 0;
  int cp;
  bool g = true;
  if(s.at(0) == 'A'){
    for(int c = 2; c < s.size()-1; c++){
      if(s.at(c) == 'C'){
        flag++; cp = c;
      }
    }
  }
  for(int c = 1; c < s.size(); c++){
    if(c == cp) continue;
    else if((s.at(c) >= 'A') && (s.at(c)<= 'Z'))
      g = false;
  }
  if(g && flag == 1) cout << "AC" << endl;
  else cout << "WA" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

void mainsolve(){

	ll h,a;
	cin >> h >> a;

	ll cnt = 0;
	while(h > 0){
		cnt++;
		h -= a;
	}

	cout << cnt << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 256
from collections import deque
n = int(input())
edges = [[]] + [list(map(int, input().split())) for _ in range(n)]
inf = 10 ** 4
d = [inf for _ in range(n+1)]

que = deque()
d[1] = 0
que.append(1)
while que:
    cur = que.popleft()
    for to in edges[cur]:
        if d[to] == inf:
            d[to] = d[cur] + 1
            que.append(to)

for i in range(1, n+1):
    if d[i] == inf:
        d[i] = -1
    print(i, d[i])



Measured memory_bytes: 6036
// In God We Trust


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

# define INF 1 << 31 - 1
# define pb push_back
# define fi first
# define se second
signed main(){
  int n;
  cin >> n;
  int h[n];
  for (int i = 0 ; i < n; i ++)
    cin >> h[i];
  long long dp[n];
  dp[n - 1] = 0;
  for (int i = n - 2; i >= 0; i--){
    dp[i] = abs(h[i] - h[i + 1]) + dp[i + 1];
    if (i != n - 2)
      dp[i] = min(dp[i], abs(h[i] - h[i + 2]) + dp[i + 2]);
  }
  cout << dp[0] << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll N, K; cin >> N >> K;
    vvll s(N);
    rep(i, N) {
        ll t, d; cin >> t >> d; t--;
        s[t].push_back(d);
    }

    rep(i, N) {
        if (s[i].empty()) s[i].push_back(-inf);
        sort(all(s[i]), greater<ll>());
    }

    sort(all(s), [&](vll a, vll b){return a[0] > b[0];});

    priority_queue<ll> que;
    ll cur = 0;
    rep(i, K) {
        cur += s[i][0];
        for (ll j = 1; j < s[i].size(); j++) que.push(s[i][j]);
    }

    reprr(i, K, N) {
        rep(j, s[i].size()) que.push(s[i][j]);
    }

    ll res = cur + K * K;

    for (ll x = K - 1; x >= 1; x--) {
        ll v = s[x][0];
        ll w = que.top();
        if (v < w) {
            cur -= v;
            cur += w;
            que.pop();
            que.push(v);
            res = max(res, cur + x * x);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 8696
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  int h,w;cin>>h>>w;
  vector<vector<int>> data(h+2, vector<int>(w+2));
  vector<vector<char>> bom(h+2, vector<char>(w+2));
  for(int i=1;i<h+1;i++){
    string s;cin>>s;
    for(int j=1;j<w+1;j++){
      if(s.at(j-1)=='#'){
        bom.at(i).at(j)='#';
        //上
        data.at(i-1).at(j-1)++;
        data.at(i-1).at(j)++;
        data.at(i-1).at(j+1)++;
        //同じ列
        data.at(i).at(j-1)++;
        data.at(i).at(j+1)++;
        //下
        data.at(i+1).at(j-1)++;
        data.at(i+1).at(j)++;
        data.at(i+1).at(j+1)++;
      }
    }
  }
    for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      if(bom.at(i).at(j)=='#')
        cout<<bom.at(i).at(j);
      else{
      cout<<data.at(i).at(j);
      }
      if(j==w)
        cout<<endl;
    }
  }
}
      
    

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class Main{
    public static void main(String[] args) {
	try {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    List<String> lines = new ArrayList<String>();

	    for (String line = br.readLine(); line != null; line = br.readLine()) {
		lines.add(line);
	    }
	    br.close();

	    for (Integer i = 0; i < lines.size(); i++) {
		String[] splits = lines.get(i).split(" ");
		Integer H = Integer.parseInt(splits[0]);
		Integer W = Integer.parseInt(splits[1]);
		if (H==0&&W==0) {
		    System.exit(0);
		}

		for (int h = 0; h < H; h++) {
		    if (h==0||h==H-1) {
			char[] chars = new char[W];
			Arrays.fill(chars, '#');
			System.out.println(new String(chars));
		    } else {
			if (W>2) {
			    char[] chars = new char[W-2];
			    Arrays.fill(chars, '.');
			    System.out.println("#" + new String(chars) + "#");
			} else {
			    char[] chars = new char[W];
			    Arrays.fill(chars, '#');
			    System.out.println(new String(chars));
			}
		    }
		}
		System.out.println("");
	    }
	    System.exit(0);

	} catch (Exception e) {
	    System.out.println(e.getMessage());
	    System.out.println(Arrays.toString(e.getStackTrace()));
	    System.exit(0);
	}
    }
}

Measured memory_bytes: 26156
import java.util.Scanner;

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

        String s = sc.next();
        int min = 999;

        for (int i = 0; i < s.length() - 2; i++) {
            String part = s.substring(i,i + 3);
            int number = Integer.parseInt(part);
            int difference = Math.abs(number - 753);
            if (difference < min) {
                min = difference;
            }
        }
        System.out.println(min);
    }
}


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

using namespace std;

typedef struct node_{
    int id;
    node_* parent;
    node_* left;
    node_* right;
    node_* bro;
}* node;

void printPreorder(node root){
    printf(" %d", root -> id);
    if(root -> left != NULL){
        printPreorder(root -> left);
    }
    if(root -> right != NULL){
        printPreorder(root -> right);
    }
}

void printInorder(node root){
    if(root -> left != NULL){
        printInorder(root -> left);
    }
    printf(" %d", root -> id);
    if(root -> right != NULL){
        printInorder(root -> right);
    }
}

void printPostorder(node root){
    if(root -> left != NULL){
        printPostorder(root -> left);
    }
    if(root -> right != NULL){
        printPostorder(root -> right);
    }
    printf(" %d", root -> id);
}

int main(){
    int n;
    scanf("%d", &n);
    vector<node> tree(n);
    vector<int> find_root(n);
    for(int i = 0; i < n; i++){
        node nd = new node_;
        nd -> parent = NULL;
        nd -> left = NULL;
        nd -> right = NULL;
        nd -> bro = NULL;
        tree[i] = nd;
        find_root[i] = 1;
    }
    for(int i = 0; i < n; i++){
        int id, l, r;
        scanf("%d %d %d", &id, &l, &r);
        node nd = tree[id];
        nd -> id = id;
        if(l != -1){
            nd -> left = tree[l];
            tree[l] -> parent = nd;
            find_root[l] = 0;
        }
        if(r != -1){
            nd -> right = tree[r];
            tree[r] -> parent = nd;
            find_root[r] = 0;
        }
    }

    int root_id = 0;
    while(find_root[root_id] == 0){
        root_id++;
    }

    node root = tree[root_id];
    printf("Preorder\n");
    printPreorder(root);
    printf("\nInorder\n");
    printInorder(root);
    printf("\nPostorder\n");
    printPostorder(root);
    printf("\n");

    return 0;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e5;
const int size=1e5;
const long inf=1e18;
int main(){
	int X,Y,Z,K;cin>>X>>Y>>Z>>K;
	long A[X],B[Y],C[Z];long D[X*Y];
	rep(i,0,X) cin>>A[i];
	rep(i,0,Y) cin>>B[i];
	rep(i,0,Z) cin>>C[i];
	rep(i,0,X)rep(j,0,Y) D[i*Y+j]=A[i]+B[j];
	sort(C,C+Z); sort(D,D+X*Y);
	long a=0,b=1e18+1;
	int cnt; long sum;
	while(b-a>1){
		long v=(a+b)/2;
		cnt=0; sum=0;
		int j=X*Y-1;
		rep(i,0,Z){
			while(j>=0&&C[i]+D[j]>=v){
				sum+=C[i]+D[j];
				j--;
			}cnt+=X*Y-1-j;
		}
		if(cnt>=K) a=v;
		else b=v;
	}
	deque<long> cake;
    int j=X*Y-1;
    rep(i,0,Z){
        while(j>=0&&C[i]+D[j]>=a) j--;
        rep(k,j+1,X*Y) cake.push_back(C[i]+D[k]);
    }sort(cake.begin(),cake.end(),greater<long>());
    rep(i,0,K) cout<<cake[i]<<endl;
}

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

int main() {
  string S,T;
  cin>>S>>T;
  
  int cnt=0;
  
  for(int i=0;i<S.size();i++){
    if(S[i]!=T[i])cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int *arr = new int[n];
	for(int i =0;i<n;i++){
		cin>>arr[i];
	}
	sort(arr,arr+n);
	int sum=0;
	for(int i =0;i<k;i++)
       sum+=arr[i];
   cout<<sum<<endl;
}

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

int main() {
    ll n;
    std::cin >> n;
    vector<ll> p(n);
    for (int i = 0; i < n; i++) {
        std::cin >> p[i];
    }
    sort(p.begin(),p.end());
    ll res = 0;
    for (int i = 0; i < n; i++) {
        res += p[i];
    }
    std::cout << res-p[n-1]/2 << std::endl;
}


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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

"""
山札がなくなると終了かつ必ず1枚は引かなくてはいけない
⇒最後の1枚は必ずどちらかの手になる(山札が1枚の場合、必ず自分の手になる)
先攻はそれを自分の手にするか、相手の手にするかを選べる
自分の手にする場合、1ターン目で全部の手札を取る
相手の手にする場合、1ターン目で最後から2番目まで全部取る
この2通りのみを考える
"""
n,z,w = LI()
a = LI()
if n == 1:
    ans = abs(a[0] - w)
else:
    ans = max(abs(a[-2]-a[-1]),abs(a[-1]-w))
print(ans)

Measured memory_bytes: 38640
N = int(input())
t = 0
for i in range(N):
    s = 0
    if (i+1)%2 == 0:
        continue
    else:
        for l in range(i+1):
            if (i + 1) % (l + 1) == 0:
                s += 1
        if s == 8:
            t += 1
print(t)



Measured memory_bytes: 3316
def get_key_from_value(d, val):
    keys = [k for k, v in d.items() if v == val]
    if keys:
        return keys[0]
    return None


dic = {0:"A",1:"B",2:"C",3:"D",4:"E",5:"F",6:"G",7:"H",8:"I",9:"J",10:"K",11:"L",12:"M",13:"N",14:"O",15:"P",16:"Q",17:"R",18:"S",19:"T",20:"U",21:"V",22:"W",23:"X",24:"Y",25:"Z"}
n = int(input())
s = input()
for i in s:
    print(dic[(get_key_from_value(dic, i) + n) % 26], end = "")
    

Measured memory_bytes: 4468
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vll A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  ll res = 0;
  ll sum = 0;
  ll ans = 0;
  int right = 0;
  for(int left = 0; left < N; left++){
    while(right < N && !(res & A[right])){
      res += A.at(right);
      right++;
    }
    ans += right - left;
    if(right == left) right++;
    res &= ~A.at(left);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <cassert>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;

double dp[3010][3010];

int main(void) {
  int n;
  scanf("%d", &n);
  dp[0][0] = 1;
  REP(i, n) {
    double p;
    scanf("%lf", &p);
    REP(j, i+1) {
      dp[i+1][j+1] += dp[i][j] * p;
      dp[i+1][j] += dp[i][j] * (1-p);
    }
  }
  double res = 0;
  REP(i, n+1) {
    if(i > n-i) {
      res += dp[n][i];
    }
  }
  printf("%.10f\n", res);
  return 0;
}


Measured memory_bytes: 69120
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,min:Integer;
  l:array of Integer;
  s,s123,s1,s2,s3:string;
  al:string = 'abcdefghijklmnopqrstuvwxyz';
  tf,tfl,tfr:Boolean;
begin
  try
    { TODO -oUser -cConsole メイン : ここにコードを記述してください }
    Read(a);
    Readln(b);
    count:=0;
    max  :=0;
    min  :=100;

    Writeln(a-b+1);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 128
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()

rt = [[] for i in range(n)]
srb = [None] * n
dk = [10**10]*n


for i in range(m):
    a,b = mi()
    rt[a-1].append(b-1)
    rt[b-1].append(a-1)

from collections import deque
l = deque()

srb[0] = 0
for i in rt[0]:
    l.append(i)
    srb[i] = 1

while len(l) != 0:
    c = l.popleft()
    for i in rt[c]:
        if srb[i] == None:
            l.append(i)
            srb[i] = c+1

print('Yes')
for i in range(1,n):
    print(srb[i])




Measured memory_bytes: 94564
using System;
class Program
{
  static void Main(string[] args)
  {
    int n = int.Parse(Console.ReadLine());
    int minv = int.MaxValue;
    int maxv = int.MinValue;

    for(int i = 0; i < n; i++)
    {
      var current = int.Parse(Console.ReadLine());
      if (i != 0)
      {
        var x =  current - minv;
        maxv = maxv < x ? x : maxv;
      }

      minv = minv > current ? current : minv;
    }

    Console.WriteLine(maxv); 
  }
}


Measured memory_bytes: 20048
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>
#include<iomanip>

#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define MOD 1000000007

using namespace std;
using ll=long long int;

int main(){
    int A,B;
    cin>>A>>B;
    cout << A*B-(A+B-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

int n;
int *B,*A;
void countingsort(int N[],int max){
	int S[max+1];
	for(int i = 0;i < max+1;i++){
		S[i] = 0;
	}
	for(int j = 0;j < n;j++){
		S[N[j]]++;
	}
	int p = 0;
	for(int k = 0;k < max+1;k++){
		for(int l = 1;l <= S[k];l++){
			B[p] = k;
			p++;
		}
	}
}

int main(){
	cin >> n;
	int max = -1;
	A = new int[n];
	B = new int[n];
	for(int i = 0;i < n;i++){
		cin >> A[i];
		if(A[i] >= max){
			max = A[i];
		} 
	}
	countingsort(A,max);
	for(int i = 0;i < n;i++){
		if(i != n-1){
			cout << B[i] << " ";
		}else{
			cout << B[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 16844
n=int(input())
C=[]

for i in range(n):
    a,b=map(int,input().split())
    C.append([a+b,a,b])
    

count_a=0
count_b=0

C.sort(reverse=True)

for j in range(n):
    if(j%2==0):
        count_a+=C[j][1]
    else:
        count_b+=C[j][2]

print(count_a-count_b)

Measured memory_bytes: 23260
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
typedef pair<int, int> P;
set<int> G[10000];
int c[10000];
int val[10000];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].insert(b);
		G[b].insert(a);
	}
	deque<int> leaf;
	for (int i = 0; i < N; i++) {
		if (G[i].size() == 1) leaf.push_back(i);
	}
	for (int i = 0; i < N; i++) cin >> c[i];
	sort(c, c + N);
	ll ans = 0;
	memset(val, -1, sizeof(val));
	for (int i = 0; i + 1 < N; i++) {
		int v = leaf.front(); leaf.pop_front();
		val[v] = c[i];
		ans += c[i];
		for (int to : G[v]) {
			G[to].erase(v);
			if (G[to].size() == 1) leaf.push_back(to);
		}
	}
	for (int i = 0; i < N; i++) if (val[i] == -1) val[i] = c[N - 1];
	cout << ans << endl;
	for (int i = 0; i < N; i++) cout << val[i] << " ";
	cout << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a==k)
    {
       cout<<a<<endl;
       return 0;
    }
    else if(a>k)
    {
        cout<<k<<endl;
        return 0;
    }
    else if(a<k)
    {
        ll maxSum=a;
        ll baki=k-a;
        if(baki<=b)
        {
            cout<<maxSum<<endl;
            return 0;
        }
        else if(baki>b)
        {
            ll minusKoro=baki-b;
            cout<<maxSum-minusKoro<<endl;
        }
    }


    return 0;
}


Measured memory_bytes: 3632
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}
func scanText() string {
	sc.Scan()
	return sc.Text()
}

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

	N := scanInt()

	var (
		ACi  int
		WAi  int
		TLEi int
		REi  int
	)
	for i := 0; i < N; i++ {
		str := scanText()
		switch str {
		case "AC":
			ACi++
		case "WA":
			WAi++
		case "TLE":
			TLEi++
		case "RE":
			REi++
		}
	}
	fmt.Printf("AC x %v\n", ACi)
	fmt.Printf("WA x %v\n", WAi)
	fmt.Printf("TLE x %v\n", TLEi)
	fmt.Printf("RE x %v\n", REi)
}


Measured memory_bytes: 1784
object Main extends App {
  val scan = new java.util.Scanner(System.in)
  val n  = scan.next().toInt
  val ns = (1 to n).map(_ => scan.next().toInt)

  var even_sum = 0L
  var even_cnt = 0L
  for (i <- 0 until n) {
    even_sum += ns(i)
    if (i%2 == 0) {
      if (even_sum == 0) {
        even_sum += 1L
        even_cnt += 1L
      } else if (even_sum < 0L) {
        even_cnt += (1L-even_sum)
        even_sum = 1L
      }
    } else {
      if (even_sum == 0L) {
        even_sum -= 1L
        even_cnt += 1L
      } else if (even_sum > 0L) {
        even_cnt += (1L+even_sum)
        even_sum = -1L
      }
    }
  }

  var odd_sum = 0L
  var odd_cnt = 0L
  for (i <- 0 until n) {
    odd_sum += ns(i)
    if (i%2 != 0) {
      if (odd_sum == 0L) {
        odd_sum += 1L
        odd_cnt += 1L
      } else if (odd_sum < 0) {
        odd_cnt += (1L-odd_sum)
        odd_sum = 1L
      }
    } else {
      if (odd_sum == 0L) {
        odd_sum -= 1L
        odd_cnt += 1L
      } else if (odd_sum > 0) {
        odd_cnt += (1L+odd_sum)
        odd_sum = -1L
      }
    }
  }
  println(math.min(odd_cnt, even_cnt))
}

Measured memory_bytes: 51540
#include<bits/stdc++.h>
using namespace std;
#define int long long
template <class Q>
void clearQueue(Q & q) {
    q = Q();
}
const int mod=1e9+7;
void solve(){
	int h,w;cin>>h>>w;
	char arr[h][w];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>arr[i][j];
		}
	}
	int dp[h][w];
	dp[0][0]=1;
	for(int i=1;i<h;i++){
		if(arr[i][0]=='#') dp[i][0]=0;
		else
		dp[i][0]=dp[i-1][0];
	}
	for(int j=1;j<w;j++){
		if(arr[0][j]=='#') dp[0][j]=0;
		else
		dp[0][j]=dp[0][j-1];
	}
	for(int i=1;i<h;i++){
		for(int j=1;j<w;j++){
			if(arr[i][j]=='#') dp[i][j]=0;
			else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
		}
	}
//	for(int i=0;i<h;i++){
//		for(int j=0;j<w;j++){
//			cout<<dp[i][j]<<" ";
//		}
//		cout<<'\n';
//	}
	cout<<dp[h-1][w-1];
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 12324
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(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);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	string s; cin >> s;
	if (s == "RRR")cout << 3 << endl;
	else if (s == "RRS" || s == "SRR")cout << 2 << endl;
	else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R')cout << 1 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll n;
    cin>>n;
    vector <ll> h(n);
    for (ll i = 0; i < n; i++){
        cin>>h[i];
    }
    ll ans = 0;
    for (ll i = 0; i<n; i++){
        bool flag =true;
        for (ll j = 0; j<i; j++){
            if(h[j] > h[i])flag = false;
        }
        if(flag)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define se set<ll>
#define vec vector<ll>
#define prin(x) cout<<setprecision(12)<<fixed<<x<<endl;





#define inf 10000000000000000
bool mark[100005];
vec adj[100005];
ll counter;
vec cnt;
vector<string> forsubs;
ll b;
ll a;
ll u;

void addedge(ll u, ll v)

   {
      adj[u].push_back(v);
      adj[v].push_back(u);
   }

void dfs(ll node)
   {
      //cout<<node<<endl;
      mark[node]=1;
      

      for(auto i:adj[node])
      {  
         if(!mark[i])
            {
               dfs(i);
               u++;
            }

      }        

         
   }



int main()
{    
 

   #ifdef APNA_IO
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
   #endif
          ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 

ll n;
cin>>n;
double p[n+1];
double h[n+1][n+1];
ll a=n/2;
double ans=0;

for(ll i=0;i<=n;i++)
{
   h[i][0]=0;
}

h[0][0]=1;
for(ll i=1;i<=n;i++)
{
   cin>>p[i];
}

for(ll i=1;i<=n;i++)
{
   h[0][i]=h[0][i-1]*(1-p[i]);
//cout<<h[0][i]<<endl;
}




for(ll j=1;j<=n;j++)
{
   for(ll i=1;i<=n;i++)
   {  
      if(i<=j)
         { 
             h[i][j]=(h[i-1][j-1]*p[j])+(h[i][j-1]*(1-p[j]));
            // cout<<h[i][j]<<"fck"<<i<<j<<endl;
         }

         else
            h[i][j]=0;

   }
}

for(ll i=a+1;i<=n;i++)
{
   ans+=h[i][n];
//cout<<h[i][n]<<endl;
}

prin(ans);


}     





Measured memory_bytes: 72960
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <string>

using namespace std;

int main()
{

  int n;
  string s;
  int k;
  cin >> n;
  cin >> s;
  cin >> k;

  char c = s[k - 1];

  for(int i = 0;
      i < n;
      ++i)
    {
      if(s[i] != c)
        {
          s[i] = '*';
        }
    }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
monster = [int(i) for i in input().split()]
brave_power = [int(i) for i in input().split()]
toubatsu_count = 0

for i in range(N):
    if brave_power[i]>monster[i]:
        toubatsu_count+=monster[i]
        nokori_brave = brave_power[i] - monster[i]
        
        if nokori_brave > monster[i+1]:
            toubatsu_count+=monster[i+1]
            monster[i+1]=0
        else:
            toubatsu_count+=nokori_brave
            monster[i+1]-=nokori_brave
    else:
        toubatsu_count+=brave_power[i]

print(toubatsu_count)

Measured memory_bytes: 18468
import numpy as np
from numba import njit, i8

n, k = map(int, input().split())
arr = np.array(list(map(int, input().split())))


@njit(i8[:](i8, i8, i8[:]))
def solve(n, k, arr):
    for i in range(min(k, 50)):
        tmp_arr = np.zeros(n + 2, np.int64)
        for i, power in enumerate(arr):
            tmp_arr[max(0, i - power + 1)] += 1
            tmp_arr[min(n + 1, i + power + 2)] -= 1
        arr = np.cumsum(tmp_arr)[1:-1]
    return arr


print(*solve(n, k, arr))

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

int main() {
	int N, M, max = 0;
	string s;
	map<string, int> mp;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> s;
		mp[s]++;
	}
	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> s;
		mp[s]--;
	}
	map<string, int>::iterator it;
	for (it = mp.begin(); it != mp.end(); it++) {
		if (max < it->second) {
			max = it->second;
		}
	}
	cout << max << endl;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.15f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto T = RD;
	auto A = RDA;
	auto B = new long[](N+1);
	foreach_reverse (i; 0..N)
	{
		B[i] = max(B[i+1], A[i]);
	}

	long[long] cnt;
	foreach (i; 0..N)
	{
		auto d = B[i+1] - A[i];
		++cnt[d];
	}

	auto keys = cnt.keys;
	keys.sort!"a > b"();

	writeln(cnt[keys[0]]);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 11316
#include<cstdio>
#include<cstring>
#include<algorithm>
int n,tmp,max=0,min=0x7fffffff;
int main()
{
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d",&tmp);
        min=std::min(min,tmp);
        max=std::max(max,tmp);
    }
    printf("%d\n",max-min);
}


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

#define all(c) c.begin(), c.end()
using ll = long long;
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  cout << count(all(s), '1');
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    cout << max(n-m,0) << endl;
}

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

struct node{
	int data;
	node *next;
};

int main(){
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif

	string stro;
	int count;
	cin >> count;
	cin >> stro;

	if(count >= stro.length()){
		cout << stro << endl;
		return 0;
	}

	for(int i=0;i<count;i++){
		cout << stro[i];
	}
	cout << "..." << endl;

	return 0;

}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int min(long long int a,long long int b)
{
    if(a<b)
        return a;
    return b;
}
int main(){
  cin.tie(NULL);
  cout.tie(NULL);
  long long int a,b,c,k;
  long long int val=0;
  cin>>a>>b>>c>>k;
            val+=min(k,a);
            k-=a;
            if(k>0)
                k-=b;
            if(k>0)
                val-=min(k,c);
            cout<<val;}


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

int main()
{
	while( 1 ) {
		int W, H;
		cin >> H >> W;
		if( W == 0 && H == 0 ) {
			break;
		}
		for( int i = 0; i < H; i++ ) {
			for( int j = 0; j < W; j++ ) {
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}
}



Measured memory_bytes: 3084
n = int(input())
a_list = [int(i) for i in input().split()]

ans = 0
tmp = 0
before = 0
a_list.append(100000)

for a in a_list:

    if a == before:
        tmp += 1
    elif tmp > 0:

        ans += (tmp+1) // 2
        tmp = 0
    before = a
print(ans)

Measured memory_bytes: 3060
#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;
//const int INF = 1e8;
using namespace std;

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

	map<char,long long> m;
	for(auto c : s){
		m[c]++;
	}
	auto f = [](long long a){ return a * (a - 1) / 2; };

	long long ans = f(s.size());
	for(auto p : m){
		ans -= f(p.second);
	}
	cout << ans + 1 << endl;
}


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

int main()
{
         int N;
         cin>>N;
         int count=0;
         int a1=N/100;
         int b=N%100;
         int a2=b/10;
         int a3=b%10;

         if(a1==7||a2==7||a3==7)
                  cout<<"Yes"<<endl;
         else
                  cout<<"No"<<endl;
         return 0;

}


Measured memory_bytes: 3632
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Sum of Three Integers
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int N = 3;
const int MAX_K = 2500;
const int MAX_S = MAX_K * N;

/* typedef */

typedef vector<int> vi;

/* global variables */

/* subroutines */

/* main */

int main() {
  int k, s;
  cin >> k >> s;

  int kn = k * N;
  vi dp(kn + 1);
  dp[0] = 1;

  for (int i = 0; i < N; i++) {
    vi dp0(dp);
    int ki = k * i;
    for (int j = 0; j <= ki; j++)
      for (int l = 1; l <= k; l++)
	dp0[j + l] += dp[j];
    swap(dp, dp0);
  }

  printf("%d\n", dp[s]);
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

// 0 : max sum
// 1 : three count
// 2 : id 1
// 3 : id 2
int dp[1<<22][4];

int main(){
  // init
  REP(i,1<<22){
    dp[i][0] = 0;
    dp[i][1] = false;
    dp[i][2] = dp[i][3] = -1;
  }
  int n;
  scanf("%d",&n);
  REP(i,n){
    int id = 0;
    int k;
    scanf("%d",&k);
    REP(j,k){
      int a;
      scanf("%d",&a);
      id |= (1<<(a-1));
    }
    dp[id][0] |= id;
    if(!dp[id][1]){
      if(dp[id][2]==-1){
        dp[id][2] = i;
      }else if(dp[id][2]!=i){
        if(dp[id][3]==-1){
          dp[id][3] = i;
        }else if(dp[id][3]!=i){
          dp[id][1] = true;
        }
      }
    }
  }
  FORR(i,1,1<<22){
    REP(j,22)if(i&(1<<j)){
      int to = i ^ (1<<j);
      dp[to][0] |= dp[i][0];
      if(dp[i][1]){
        dp[to][1] = true;
      }else if(!dp[to][1]){
        if(dp[i][2]!=-1){
          int add = dp[i][2];
          if(dp[to][2]==-1){
            dp[to][2] = add;
          }else if(dp[to][2]!=add){
            if(dp[to][3]==-1){
              dp[to][3] = add;
            }else if(dp[to][3]!=add){
              dp[to][1] = true;
            }
          }
        }
        if(dp[i][3]!=-1){
          int add = dp[i][3];
          if(dp[to][2]==-1){
            dp[to][2] = add;
          }else if(dp[to][2]!=add){
            if(dp[to][3]==-1){
              dp[to][3] = add;
            }else if(dp[to][3]!=add){
              dp[to][1] = true;
            }
          }
        }
      }
    }
  }
  int ans = 0;
  REP(i,1<<22)if(dp[i][1]){
    CHMAX(ans, __builtin_popcount(i) * __builtin_popcount(dp[i][0]));
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 68716
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑



int digits(int n) {
	int ans = 0;
	while (n) {
		++ans;
		n /= 10;
	}
	return ans;
}

int main() {


	int n, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		if (digits(i) % 2 == 1) { ++ans; }
	}

	cout << ans << endl;





}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

#define pb push_back
#define ri(x) scanf("%d",&x)
#define rii(x,y) ri(x),ri(y)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define ms2(obj,val,sz) memset(obj,val,sizeof(obj[0])*sz)
#define FOR(i,f,t) for(int i=f;i<(int)t;i++)
#define FORR(i,f,t) for(int i=f;i>(int)t;i--)

typedef long long ll;
typedef vector<int> vi;

const int MAXN=0;

ll ans;
int N,A[4];

int main() {
	FOR(i,0,4) ri(A[i]);
	FOR(i,1,4) A[i] = min(A[i], 2*A[i-1]);
	ri(N);
	ans = 1ll * (N / 2) * A[3] + ((N % 2) * A[2]);
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()

const ll mod=1000000007;

int countBits(int in){
  int res=0;
  for(int i=0;i<10;i++){
    int msk=1<<i;
    if((in&msk)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int a,b,c,d;cin>>a>>b>>c>>d;
  int ans=max(a*b,c*d);
  cout<<ans<<endl;
  return 0;
}


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

const int MAXN = 1e5 + 10;

int N, maxV = 0;
int oddCnt[MAXN], evenCnt[MAXN];

int main()
{
	cin >> N;
	for (int i = 1; i <= N; i++)
	{
		int x;
		cin >> x;
		maxV = max(maxV, x);
		if (i % 2 == 0)
			evenCnt[x]++;
		else
			oddCnt[x]++;
	}
	int oddMax1 = 0, oddMax2 = 0;
	int evenMax1 = 0, evenMax2 = 0;
	int oddMaxId, evenMaxId;

	for (int i = 1; i <= maxV; i++)
	{
		if (oddCnt[i] > oddMax1)
			oddMax2 = oddMax1, oddMax1 = oddCnt[i], oddMaxId = i;
		else if (oddCnt[i] > oddMax2)
			oddMax2 = oddCnt[i];
		if (evenCnt[i] > evenMax1)
			evenMax2 = evenMax1, evenMax1 = evenCnt[i], evenMaxId = i;
		else if (evenCnt[i] > evenMax2)
			evenMax2 = evenCnt[i];
	}

	if(oddMaxId != evenMaxId)
		cout << N - oddMax1 - evenMax1 << endl;
	else
		cout << min(N - oddMax1 - evenMax2, N - oddMax2 - evenMax1) << endl ;

	return 0;
}



Measured memory_bytes: 1024
program distance
    integer :: n, i
    integer :: ans = 0
    integer(8) :: d
    integer(8), allocatable :: x(:)
    integer(8), allocatable :: y(:)

    read *, n, d
    allocate(x(n))
    allocate(y(n))
    do i = 1, n
        read *, x(i), y(i)
        if(d**2 >= ((x(i)**2)+(y(i)**2)))then
            ans = ans+1
        end if
    end do
    print *, ans
end program

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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;

int main(void){
  double A,B,H,M;
  cin >> A >> B >> H >> M;
  
  double deg,degH,degM;
  degH = 2.0 * M_PI * (H/12.0 + M/720.0);
  degH  = fabs(degH);
  degM = 2.0 * M_PI * M /60.0;
  deg = fabs(degH-degM);
  if(deg>M_PI){
    //cout << "rev" << 360*deg/2/M_PI << " " << 360*(deg-M_PI)/2/M_PI << "\n";
    deg = 2.0 * M_PI - deg;
  }
  
  double ans;
  //cout << 360.0 * deg / 2 / M_PI << "\n";
  ans = A*A + B*B; 
  ans += -2 * A * B * cosl(deg);
  ans = sqrtl(ans);
  cout << setprecision(11) << ans;
  return 0;
}

Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sq(x) ((x)*(x))
#define fo(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<n;i++)
#define Fo(i,n) for(int i=1;i<=n;i++)
#define all(x) x.begin(),x.end()
#define fi first
#define se second
const double pi = 3.14159265358979323846;
#define uni(c) (c).resize(unique(all(c))-(c).begin())
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
//pair <int, int> w[4] = {mp(-1, 0), mp(0, -1), mp(1, 0), mp(0, 1)};   // for matrix movement:
void cp()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
void solve()
{
	ull n; cin >> n;
	ull a[n];
	//vi have;
	fo(i, n) {
		cin >> a[i];
		//have.pb(to_string(a[i]).size());
	}
	ull ans = 1;
	sort(a, a + n);
	if (a[0] == 0)
	{
		cout << 0;
		return;
	}
	ull tot = 0;
	ll flag = 0;
	for (int i = 0; i < n; i++)
	{
		//cout << have[i] << "\n";
		ans *= a[i];
		if (tot > to_string(ans).size())
			flag = 1;
		tot = max(tot, (ull) to_string(ans).size());

	}
	if (flag == 1 or tot > 19 or ans > 1000000000000000000)
		cout << -1;
	else
		cout << ans;
	// long double a, b; cin >> a >> b;
	// ll ans = a * b;
	// cout << ans;










}
int main()
{
	fast;
	//cp();
	ll t = 1;

	//cin >> t;
	while (t--)
		solve();


	return 0;
}

Measured memory_bytes: 4564
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::unordered_set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int n; cin >> n;
  cout << (n*n*n) << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector< vector<int> >
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int N, t;
Graph G(110);
vector<int> D(110, 0), F(110, 0);

void dfs(int v){
    t++;
    D[v] = t;
    for(int i = 0; i < G[v].size(); i++){
        int v2 = G[v][i];
        if(D[v2] == 0) dfs(v2);
    }
    t++;
    F[v] = t;
}

int main(){
    scanf("%d", &N);
    rep(i, N){
        int u, k;
        scanf("%d%d", &u, &k);
        rep(j, k){
            int v;
            scanf("%d", &v);
            G[u].push_back(v);
        }
    }

    t = 0;

    for(int i = 1; i <= N; i++){
       if(D[i] == 0) dfs(i);
    }

    for(int i = 1; i <= N; i++){
        printf("%d %d %d\n", i, D[i], F[i]);
    }    
}


Measured memory_bytes: 3272
import math
def binsearch(l, r, fn):
    while r - l > 1:
        m = (l + r) // 2
        if fn(m):
            l = m
        else:
            r = m
    return l

def main():
    N, A, B = map(int, input().split())
    l = []
    C = A - B
    for _ in range(N):
        h = int(input())
        l.append(h)
    def func(i):
        if max(l) <= B*i:
            return False
        r = 0
        for j in l:
            r += max(math.ceil((j - B*i) / C), 0)
        if r <= i:
            return False
        return True
    return 1 + binsearch(0, 1000000000, func)

print(main())


Measured memory_bytes: 12924
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  int ans = N + N*N + N*N*N;
  cout << ans << endl;
}


Measured memory_bytes: 3636