akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main() {
    string base = "CODEFESTIVAL2016";
    string s;
    cin >> s;
    int n = int(base.size());
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (base[i] != s[i]) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

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

  ll n, m;
  cin >> n >> m;
  vector<pll> works(n);
  for (int i = 0; i < n; i++) cin >> works[i].first >> works[i].second;
  sort(works.begin(), works.end());
  //reverse(works.begin(), works.end());

  priority_queue<ll, vector<ll>> que;
  ll ans = 0;
  int index = 0;
  for (int i = m-1; i >= 0; i--) {
    while ((index < n) && (works[index].first <= m-i)) {
      que.push(works[index].second);
      index++;
    }

    if (!que.empty()) {
      ans += que.top();
      que.pop();
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 5756
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def gcd(a,b):
    if a%b == 0:
        return b
    else:
        return gcd(b, a%b)
    
n = ni()
a = list(li())
    
gcd_left = [0, a[0]]
gcd_right = [0, a[-1]]

for ai in a[1:]:
    gcd_left.append(gcd(gcd_left[-1], ai))
    
for ai in a[-2::-1]:
    gcd_right.append(gcd(gcd_right[-1], ai))
    
ans = 1

for le, ri in zip(gcd_left[:-1], gcd_right[::-1][1:]):
    if le == 0 or ri == 0:
        ans = max(ans, le, ri)
        
    else:
        ans = max(ans, gcd(le, ri))
        
print(ans)
    


Measured memory_bytes: 14488
#include <iostream>
#include <string>

int main(void){
  //int a,b;
  //std::cin >> a;
  //std::cin >> b;
  int n;
  std::cin >> n;
  int ans = n / 2;
  if(n % 2 == 1){
    ans++;
  }
  std::cout << ans << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
from math import cos, sqrt, radians


A, B, H, M = map(int, input().split())
Md = M * 6
Hd = (H * 30) + ((M/60) * 30)
Cd = (Hd - Md)
As = A ** 2
Bs = B ** 2
D = 2 * A * B
X = sqrt(As + Bs - (D * cos(radians(Cd))))
print(X)






Measured memory_bytes: 9508
n = int(input())
S = [input() for _ in range(n)]
alphabet_str = "abcdefghijklmnopqrstuvwxyz"
alphabets = list(alphabet_str)

s_maps = []
for s in S:
    strs = list(s)
    m = {}
    for alphabet in alphabets:
        m[alphabet] = 0
    for _str in strs:
        m[_str] += 1
    s_maps.append(m)

ans = ""
for alphabet in alphabets:
    min_num = 51
    for s_map in s_maps:
        min_num = min(s_map[alphabet], min_num)
    for i in range(min_num):
        ans = ans + alphabet
print(ans)


Measured memory_bytes: 3064
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
void solve() {
	int n, r;
	cin >> n >> r;
	cout << r + max(0LL, 100 * (10 - n)) << endl;
}
#undef int
int main() {
	init();
	solve();
}

Measured memory_bytes: 764
a,b = map(int,input().split())
s = input()
ans = "Yes"
try:
    for i in range(a+b+1):
        #print(i,s[i])
        if i < a and s[i].isdigit():
            continue
        elif i == a and s[i] == "-":
            continue
        elif a < i < a+b+1 and s[i].isdigit():
            continue
        else:
            ans = "No"
            break
except:
    ans = "No"

print(ans)

Measured memory_bytes: 3060
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] a = new int[5];
        int cnt = 0;
        int sabun = 0;
        int max  =0;

        for(int i = 0;i<5;i++){
            a[i] = sc.nextInt();
            cnt+=a[i];
            sabun = (int)(Math.ceil((double)a[i]/10))*10-a[i];
            //System.out.println(sabun);
            cnt+=sabun;
            if(max<sabun){
                max=sabun;
            }

        }

        cnt -=max;

        System.out.println(cnt);
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define int long long
using namespace std;
 
 

int dp[2][10000 + 7];
 
int32_t main() {
 		memset(dp, 0x3f, sizeof dp);
 		dp[0][0] = 0;
        int h, n; cin >> h >> n;
        for(int i = 1; i <= n; i++) {
        	int a, b; cin >> a >> b;
        	for(int j = 0; j <= h; j++) {
        		dp[i & 1][j] = dp[(i - 1) & 1][j];
        		if(a <= j) dp[i & 1][j] = min(dp[i & 1][j], min(dp[i & 1][j - a] + b, dp[(i - 1) & 1][j - a] + b));
        		else dp[i & 1][j] = min(dp[i & 1][j], b);
        	}
        }

        cout << dp[n & 1][h] << endl;

}

Measured memory_bytes: 384
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner sc =new Scanner(System.in);
        int a =sc.nextInt();
        int b =sc.nextInt();
        int x=a+b;
        int y=a*b;
        int z=a-b;
        if(x>y&&x>z){
        	System.out.println(x);
        }else if(y>x&&y>z){
            System.out.println(y);
        }else{
        	        	System.out.println(z);
        }
        }}

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

int main(){
  int h,n,a,sum=0;
  cin>> h >> n;
  for(int i=0; i<n; i++){ cin>> a; sum+=a;}
  if(h>sum) cout<< "No" <<endl;
  else cout<< "Yes" <<endl;
}

Measured memory_bytes: 3620
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
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; } 
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 



using namespace std;
//-------------------------------------------
int main(void){
    ll N,K;cin>>N>>K;
    vector<int> h(N);
    REP(i, N) cin >> h[i];
    ll cnt=0;
    REP(i,N){
        if(h[i]<K)continue;
        cnt++;
    }
    cout<<cnt<<"\n";
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

bool reach[2505];
bool rreach[2505];
vector<int> to[2505];
vector<int> rto[2505];

void dfs(int now){
  reach[now]=true;
  for(int next:to[now]){
    if(reach[next])continue;
    else dfs(next);
  }
}

void rdfs(int now){
  rreach[now]=1;
  for(int next:rto[now]){
    if(rreach[next])continue;
    else  rdfs(next);
  }
}

struct edge {
    int to;
    int cost;
};

int V;
vector<edge> G[2505];
vector<int> dist(2505, INF);

bool bellman_ford(int n, int s) { // nは頂点数、sは開始頂点
  dist[s] = 0; // 開始点の距離は0
  for (int i = 0; i < n; i++) {
    for (int v = 0; v < n; v++) {
      for (int k = 0; k < G[v].size(); k++) {
        edge e = G[v][k];
        if(reach[e.to]==0||rreach[e.to]==0)continue;
        if (dist[v] != INF && dist[e.to] > dist[v] + e.cost) {
          dist[e.to] = dist[v] + e.cost;
          if (i == n - 1) return true; // n回目にも更新があるなら負の閉路が存在
        }
      }
    }
  }
  return false;
}

int main(){
  int n,m,p;
  cin >> n >> m >> p;
  rep(i,m){
    int a,b,c;
    cin >> a >> b >> c;
    a--,b--;
    c-=p;
    c=-c;
    edge e = {b,c};
    G[a].push_back(e);
    to[a].push_back(b);
    rto[b].push_back(a);
  }
  dfs(0);
  rdfs(n-1);
  if(bellman_ford(n,0))cout << -1 << endl;
  else{
    int ans = dist[n-1];
    ans = -ans;
    cout << max(ans,0) << endl;
  }
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	int n;
	ll a[100];
	cin>>n;
	rep(i,n)cin>>a[i];
	ll s=1000/a[0];
	ll m=1000%a[0];
	rep(i,n-1)
	{
	//	cout<<m<<" "<<s<<endl;
		if(a[i+1]>a[i])
		{
			m+=a[i+1]*s;
			s=0;
			s=m/a[i+1];
			m%=a[i+1];
		}
		else 
		{
			m+=a[i]*s;
			s=0;
			s=m/a[i+1];
			m%=a[i+1];
		}
	//	cout<<m<<" "<<s<<endl;
	}
//	cout<<m<<" "<<s<<endl;
	cout<<m+s*a[n-1]<<endl;
	return 0;
}



Measured memory_bytes: 3604
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int n      = Integer.parseInt(scanner.nextLine()) - 400;
		int ans    = 8;
		boolean flg = true;
		while(flg) {

			if(n >= 200) {

				n -= 200;
				ans--;
			}else {
				flg = false;
			}
		}

		System.out.println(ans);


		/*
		 * 400以上599以下：8級
		 * 600以上799以下：7級
		 * 800以上999以下：6級
		 * 1000以上1199以下：5級
		 * 1200以上1399以下：4級
		 * 1400以上1599以下：3級1600以上1799以下：2級1800以上1999以下：1級
		 */


	}

}


Measured memory_bytes: 35596
import java.io.*;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String[] str = br.readLine().split(" ");
			long a = Long.parseLong(str[0]);
			long b = Long.parseLong(str[1]);
			
			long[] ab = new long[2];
			ab[0] = Math.min(a, b);
			ab[1] = Math.max(a, b);
			System.out.println(GCD(ab));
			
		}catch(IOException e){
			System.out.println("IOException");
		}
	}
	
	static long GCD(long[] ab){
		long k;
		while(true){
			k = ab[1]%ab[0];
			if (k==0){
				return ab[0];
			}
			ab[1] = ab[0];
			ab[0] = k;
		}
	}

}

Measured memory_bytes: 24404
n,A = map(int,input().split())
a = list(map(int,input().split()))
a = [x-A for x in a]
B = A*n
dp = [[0]*B*2 for i in range(n+1)]
dp[0][B] = 1
for i in range(n):
    for j in range(B*2):
        dp[i+1][j] += dp[i][j]
        k = j+a[i]
        if k >=0 and k<B*2:
            dp[i+1][k] += dp[i][j]
print(dp[n][B]-1)

Measured memory_bytes: 41200
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;




void solve() {
	int a, b; cin >> a >> b;
	cout << 6 - a - b << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(4);
	//init();
	solve();
	stop
		return 0;
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

void solve()
{
  ll n; cin >> n;
  // ll x, y, z; cin >> x >> y >> z;
  string s; cin >> s;
  // vector<ll> a(n); REP(i, n) cin >> a[i];
  // ll ans = 0;
  // bool ok = false;
  if(s.size() <= n) {
    cout << s << endl;
  } else {
    REP(i, n) cout << s[i];
    cout << "...\n";
  }
  // cout << ans << endl;
  // cout << (ok?"Yes":"No") << endl;}
}


int main(void)
{
  // ll t; cin >> t; REP(i, t)
  solve();
}


Measured memory_bytes: 3632
import java.util.Scanner;

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

		int h = S / 3600;
		S = S - 3600 * h;
		int m = S / 60;
		S = S - 60 * m;
		int s = S;

		String a = h + ":" + m + ":" + s;
		System.out.println(a);
	}
}

Measured memory_bytes: 26240
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b) = scan!(usize, usize);
    println!("{}", (a + b) % 24)
}


Measured memory_bytes: 4352
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        
        while(true){
            var nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int vertical = nums[0];
            int side = nums[1];
            
            if(vertical==0 && side==0){
                break;
            }
            
            for(int i = 0; i < vertical; i++){
                for(int l = 0; l < side; l++){
                    Console.Write("#");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}



Measured memory_bytes: 18396
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define int ll
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORS(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll mod = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> H >> W;
    if (H % 3 == 0 || W % 3 == 0) {
        cout << 0 << endl;
        return 0;
    }
    ans = min(W, H);
    FOR(h, 1, H) {
        int tmp = 0;
        if (W & 1) {
            int w = W / 2;
            int a1 = (H - h) * w;
            int a2 = (H - h) * (w + 1);
            int a3 = h * W;
            tmp = max(a1, max(a2, a3)) - min(a1, min(a2, a3));
        } else {
            int w = W / 2;
            int a1 = (H - h) * w;
            int a2 = h * W;
            tmp = max(a1, a2) - min(a1, a2);
        }
        ans = min(ans, tmp);
    }
    FOR(w, 1, W) {
        int tmp = 0;
        if (H & 1) {
            int h = H / 2;
            int a1 = (W - w) * h;
            int a2 = (W - w) * (h + 1);
            int a3 = w * H;
            tmp = max(a1, max(a2, a3)) - min(a1, min(a2, a3));
        } else {
            int h = H / 2;
            int a1 = (W - w) * h;
            int a2 = w * H;
            tmp = max(a1, a2) - min(a1, a2);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX], n;
    
    cin >> n;
    for(int i=0; i<n; i++) cin >> R[i];
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for(int i=1; i<n; i++){
        maxv = max(maxv, R[i]-minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
}


Measured memory_bytes: 3880
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(n / 2);
	x %= mod;
	x *= x;
	x %= mod;
	if (n % 2 == 1)x *= 10;
	x %= mod;
	return x;
}

int main(){
	int n;
	cin >> n;
	hei(int) a(n * 2);
	rep(i, 0, 2*n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < 2 * n; i += 2)ans += a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
ss = []

for _ in range(n):
    ss.append(input())

d = {}
m = 0

for s in ss:
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
    m = max(d[s], m)

ans = sorted([k for k, v in d.items() if v == m])

print('\n'.join(ans))




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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

template<typename T> T ce(T x, T y) { return (x + y - 1) / y; }

LL k, a, b;

int main() {
	cin >> k >> a >> b;
	
	LL ans = 0;
	if(k <= a) { ans = 1; }
	else if(a - b <= 0) { ans = -1; }
	else { ans = ce(k - a, a - b) * 2 + 1; }
	
	cout << ans << endl;
	
	return 0;
}


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

using namespace std;

int add (int a , int b , int mod) {
    a += b;
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}

int mul (int a , int b , int mod) {
    return a * 1ll * b % mod;
}

int main() {
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#ifdef LOCAL
    freopen("input.in" , "r" , stdin);
#endif
    int n , p;
    string s;
    cin >> n >> p >> s;

    long long ans = 0;
    if (p == 2) {
        for (int i = 0 ; i < n ;i++) {
            int d = s[i] - '0';
            if (d % 2 == 0)
                ans += i + 1;
        }
    } else if (p == 5) {
        for (int i = 0 ; i < n ;i++) {
            int d = s[i] - '0';
            if (d == 5 || d == 0)
                ans += i + 1;
        }
    } else {
        reverse(s.begin() , s.end());

        vector<int> f(p);
        f[0]++;

        int power = 1 , h = 0;
        for (int i = 0 ;i < n ;i++) {
            int d = s[i] - '0';
            h = add(h , mul(power , d , p) , p);
            ans += f[h];
            f[h]++;
            power = mul(power , 10 , p);
        }
    }

    cout << ans;
}


Measured memory_bytes: 3644
n = int(input())
s = [input() for i in range(n)]
d ={}
for key in s:
    if key in d:
        d[key] += 1
    else:
        d[key] = 1
Max = max(d.values())
max_k_list = [kv[0] for kv in d.items() if kv[1] == Max]
max_k_list.sort()
for i in max_k_list:
    print(i)

Measured memory_bytes: 99664
N = int(input())
X = list(map(int, input().split()))

mid1, mid2 = sorted(X)[N//2-1:N//2+1]
smid1 = str(mid1)
smid2 = str(mid2)
print('\n'.join(smid1 if xi>mid1 else smid2 for xi in X))


Measured memory_bytes: 26772
// C - Dubious Document 2

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	if (S.size() < T.size()) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}

	bool restorable = false;
	for (int i=S.size() - T.size(); i>=0; i--) {
		bool valid = true;
		for (int j=0; j<T.size(); j++) {
			if (S[i+j] != T[j] && S[i+j] != '?') {
				//cout << "invalid " << i << " " << j << endl; // **** debug ****
				valid = false;
				break;
			}
		}

		if (valid) {
			for (int j=0; j<T.size(); j++) {
				S[i+j] = T[j];
			}

			for (int j=0; j<S.size(); j++) {
				if (S[j] == '?') S[j] = 'a';
			}

			restorable = true;
			break;
		}
	}

	if (restorable) {
		cout << S << endl;
	} else {
		cout << "UNRESTORABLE" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {


//	final int MOD = 1000000007;

	public static long ans = 0;

	public static void main(String[] args) {

//		int ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

//		long a = sc.nextLong();

		int n = sc.nextInt();


		//-------------------------------------------------------------------------------------

		int tmp = n / 1000;
		ans = (tmp + 1) * 1000 - n;
		if(n % 1000 == 0)
			ans = 0;


		//-------------------------------------------------------------------------------------

//		if(f) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}

		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 35656
using System;
class a161
 {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = Convert.ToInt32(str[0]);
            int b = Convert.ToInt32(str[1]);
            int c = Convert.ToInt32(str[2]);
            int tmpA = a;
            int tmpB = b;
            int tmpC = c;
            a = b;
            b = tmpA;
            c = a;
            a = tmpC;
            Console.WriteLine("{0} {1} {2}", a, b, c);
        }
        
 }

Measured memory_bytes: 13268
package main

import (
	"fmt"
)

func main() {
	var a, b, c, k uint
	fmt.Scan(&a, &b, &c, &k)

	if a > b && a > c {
		fmt.Println(a<<k + b + c)
	} else if b > a && b > c {
		fmt.Println(b<<k + a + c)
	} else {
		fmt.Println(c<<k + a + b)
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long check[20][20];
int main(){
  int N;
  cin>>N;
  long long count=0;
  for(int i=0;i<N;i++){
    string S;
    cin>>S;
    long long A=0;
    long long integar=54;
    for(int j=0;j<(int)S.size();j++){
      if(S.at(j)=='.'){
        integar=j;
        break;
      }
    }
    if(integar==54){
      integar=(int)S.size()+8;
    }
    else{
      integar+=8;
    }
    for(int j=0;j<(int)S.size();j++){
      if(S.at(j)!='.'){
        A+=(S.at(j)-'0')*pow(10,integar);
        integar--;
      }
    }
    long long V=0;
    long long II=0;
    while(A%2==0 && II<18){
      A/=2;
      II++;
    }
    while(A%5==0 && V<18){
      A/=5;
      V++;
    }
    check[II][V]++;
    if(II>=9 && V>=9){
      count++;
    }
  }
  long long ans=0;
  for(int i=0;i<19;i++){
    for(int j=0;j<19;j++){
      
      for(int k=0;k<19;k++){
        for(int l=0;l<19;l++){
          if(i+k>=18 && j+l>=18){
            ans+=check[i][j]*check[k][l];
          }
        }
      }
      
    }
  }
  cout<<(ans-count)/2<<endl;
}

Measured memory_bytes: 4084
# coding: utf-8
# Your code here!
dic_memo={0:1,1:2}
M=10**9+7
def memo(N):
    if N in dic_memo:
        return dic_memo[N]
    dic_memo[N]=(memo((N-1)//2)+memo(N//2)+memo(N//2-1))%M
    return dic_memo[N]

n=int(input())
print(memo(n))


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
long long a[300100],ans;
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=3*n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+3*n);
	for(int i=3*n-1,j=1;i>=1&&j<=n;i-=2,j++)
		ans+=a[i];
	cout<<ans<<endl;
}

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

int main(){
  int N;
  cin>>N;
  vector<int> P,Q;
  P=Q=vector<int>(N);
  for(int i=0;i<N;i++)cin>>P[i];
  for(int i=0;i<N;i++)cin>>Q[i];
  vector<int> tmp(N);
  for(int i=0;i<N;i++)tmp[i]=i+1;
  int cnt=1;
  int a,b;
  do{
    if(tmp==P)a=cnt;
    if(tmp==Q)b=cnt;
    cnt++;
  }while(next_permutation(tmp.begin(),tmp.end()));
  cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll h,n,a[114514];
	cin>>h>>n;
	ll sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	cout<<(sum>=h?"Yes":"No");
	return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;
    string s;
    cin>>s;ll int w,val=0,i;
    for(i=0;i<s.size();i++)
    {
        w=(int)s[i]-48;
        val+=w;
    }
    if(val%9==0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

    double num = 0;
    FOR(i, 1, N){
        if (i%2 == 1) num++;
    }
    double ans = num/N;

    cout <<  fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 3764
#include <iostream>

using namespace std;

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

    int n;
    cin >> n;

    int num = 1;
    while(true)
    {
        if(num*2 <= n) num = num*2;
        else break;
    }

    cout << num << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 4900000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, k;
    cin >> n >> k;
    vll x(n), y(n);
    rep(i, n){
        cin >> x[i] >> y[i];
    }
    vp sx;
    rep(i, n){
        sx.emplace_back(x[i], y[i]);
    }
    sort(ALL(sx));
    ll ans = INF;
    rep(i, n-1)repr(j, i+1, n){
        ll cnt = j-i+1;
        if(cnt < k) continue;
        vll sy;
        repr(a, i, j+1){
            sy.emplace_back(sx[a].second);
        }
        sort(ALL(sy));
        rep(l, cnt-k+1){
            chmin(ans, (sy[l+k-1]-sy[l])*(sx[j].first-sx[i].first));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    n = int(input())
    v = list(map(int, input().split()))
    c = list(map(int, input().split()))

    result = 0
    for i in range(n):
        sa = v[i] - c[i]
        if(sa > 0):
            result += sa
    
    print(int(result))


Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
    #define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
    #define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
const int MAXN = 1e5 + 10;
LL find_k(LL n) {
    n = n * 2;
    LL k = 1;
    while (k * (k-1) < n) {
        k++;
    }
    if (k * (k-1) == n) return k;
    return -1;
}
vector<int> ret[MAXN];




int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.precision(10); cout << fixed;
#ifdef LOCAL
    freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
    LL n; cin >> n;
    LL k = find_k(n);
    if (k == -1) {
        cout << "No" << endl;
        return 0;
    }
    vector<pii> ps;
    for (int i = 0; i < k; i++) {
        for (int j = i+1; j < k; j++) {
            ps.emplace_back(i, j);
        }
    }
    for (int i = 0; i < ps.size(); i++) {
        ret[ps[i].first].push_back(i+1);
        ret[ps[i].second].push_back(i+1);
    }
    cout << "Yes" << endl << k << endl;
    for (int i = 0; i < k; i++) {
        auto item = ret[i];
        cout << item.size();
        for (int num : item) {
            cout << " " << num;
        }
        cout << endl;
    }






/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
    return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


Measured memory_bytes: 5492
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll, ll> pii;
const int maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
int a, b;

int main() {
	cin >> a >> b;
	cout << ceil(1.0*a / b) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main
{
    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

    public void go() throws IOException
    {
        StringTokenizer tok = new StringTokenizer(in.readLine());
        int n = Integer.parseInt(tok.nextToken());
        tok = new StringTokenizer(in.readLine());
        PriorityQueue<Double> pq = new PriorityQueue<>();
        for (int i = 0; i < n; i++)
        {
            pq.add((double)Integer.parseInt(tok.nextToken()));
        }
        while (pq.size() > 1)
        {
            double a = pq.remove();
            double b = pq.remove();
            pq.add((a+b) / 2);
        }
        out.println(pq.remove());

        out.flush();
        in.close();
    }

    public static void main(String[] args) throws IOException
    {
        new Main().go();
    }
}


Measured memory_bytes: 20564
#include <iostream>
#include <stdlib.h> 
#include <stdio.h>
#include <math.h>
using namespace std;

int main() {
	int a;
	double p1 = 0, p2 = 0, p3 = 0, pi = 0;
	cin >> a;
	int x[a], y[a];
	for (int i = 0; i < a; i++) {
	    cin >> x[i];
	}
	for (int i = 0; i < a; i++) {
	    cin >> y[i];
	}
	for (int i = 0; i < a; i++) {
	    p1 += abs(x[i] - y[i]);
	    p2 += abs(x[i] - y[i]) * abs(x[i] - y[i]);
	    p3 += abs(x[i] - y[i]) * abs(x[i] - y[i]) * abs(x[i] - y[i]);
	    if (abs(x[i] - y[i]) > pi) {
	        pi = abs(x[i] - y[i]);
	    }
	}
	p2 = sqrt(p2);
	p3 = pow(p3, 1.0 / 3.0);
	printf("%.6f\n%.6f\n%.6f\n%.6f\n", p1, p2, p3, pi);
}


Measured memory_bytes: 3336
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int maxn = 2020;
const int mod = 1e9 + 7;
ll a[maxn];
ll dp[maxn][maxn];
bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b){
    return a.first > b.first;
}
void solve(){
    int n; cin >> n;
    vector<pair<ll, ll>> v;
    for(ll i = 1; i <= n; i++){
        cin >> a[i];
        v.push_back(make_pair(a[i], i));
    }
    sort(v.begin(), v.end(), cmp);
    //memset(dp, 0, sizeof dp);
    /*
        枚举最大的放在最左边还是最右边，
        放在离他最远的地方不是最大的答案
    */
    dp[1][n] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= i; j++){
            int l = j + 1, r = n - i + j;
            if(l - 1 >= 1) dp[l][r] = max(dp[l][r], dp[l - 1][r] + v[i - 1].first * abs(v[i - 1].second - l + 1));
            if(r + 1 <= n) dp[l][r] = max(dp[l][r], dp[l][r + 1] + v[i - 1].first * abs(v[i - 1].second - r - 1));
        }
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        ans = max(ans, dp[i][i] + v[n - 1].first * abs(i - v[n - 1].second));
    }
    cout << ans << endl;
}
int main(){
    IOS; int t = 1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 26448
#include<bits/stdc++.h>
using namespace std;
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
int main(){
	int n;
	int a[100];
	vector<int> d(9);
	cin >> n;
	int c = 0;
	for (int i=0; i<n; i++) {
		int x; cin >> x;
		if (x < 400) {
			d[0] = 1;
		} else {
			if (x < 800) {
				d[1] = 1;
			} else {
				if (x < 1200) {
					d[2] = 1;
				} else {
					if (x < 1600) {
						d[3] = 1;
					} else {
						if (x < 2000) {
							d[4] = 1;
						} else {
							if (x < 2400) {
								d[5] = 1;
							} else {
								if (x < 2800) {
									d[6] = 1;
								} else {
									if ( x < 3200) {
										d[7] = 1;
									} else {
										c++;
									}
								}
							}
						}
					}
				}
			}
		}
	}
	int ans = accumulate(d.begin(), d.end(), 0);
	if (ans == 0) {
		cout << 1 << " " << c;
	} else 
		cout << ans << " " << ans+c; 
	return 0;
}

Measured memory_bytes: 3644
#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, 'a' = 97

int main()
{
    int a, b;
    cin >> a >> b;

    cout << a * b << " " << (a + b) * 2 << endl;
}



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

using namespace std ;

#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)
#define ll long long int 

#define fr first
#define se second

#define all(v) v.begin(),v.end() 
#define rall(v) v.rbegin(),v.rend()
#define sz(v) v.size() 

#define pb push_back
#define mp make_pair 

#define PI 3.141592653589793238



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 valid(int x, int y){return x > 0 && x < n && y > 0 && y < m;}


int mm = INT_MAX;
string s;

int main(){
  cin >> s;
  int l = (int)sz(s);
  for(int i = 0 ; i < l-2 ; i++){
    string x;
    for(int j = i ; j  < i+3 ; j++)
      x += s[j];
    int d = stoi(x);
    mm = min(mm, abs(753-d));
  }
  cout << mm;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=tuple(map(int,input().split()))
b=tuple(map(int,input().split()))
import itertools as it
x=0
y=0
for i,j in enumerate(it.permutations(list(range(1,n+1)))):
    if a==j:
        x=i
    if b==j:
        y=i
print(abs(x-y))

        


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

int main()
{
    int N;
    cin>>N;
    vector<int> L;
    int num,max=0;
    for(int i=0; i<N; i++){
        cin>>num;
        if(max<num){max=num;}
        L.push_back(num);
    }
    int sum=0,f=0;
    for(int i=0; i<N;i++){
        if(L[i]!=max){
            sum+=L[i];
        }
        else if(L[i]==max && f==0){
            f=1;
        }
        else if(L[i]==max && f!=0){
            sum+=L[i];
        }
    }
    if(max<sum){cout<<"Yes"<<endl;}
    else { cout<<"No"<<endl;}
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N;cin>>N;
  vector<long>P(N);for(long i=0;i<N;i++)cin>>P[i];
  vector<long>X(N,0);for(long i=0;i<N;i++)X[P[i]-1]+=i;
  
  vector<long>A(N,1),B(N,1);
  for(long i=0;i<N;i++){A[i]=i+1;B[i]=N-i;}
  
  long x=0;
  for(long i=0;i<N;i++){
    x+=X[i];
    A[i]+=x;
  }
  
  long y=0;
  for(long i=N-1;i>=0;i--){
    y+=X[i];
    B[i]+=y;
  }
  
  for(long i=0;i<N;i++)cout<<A[i]<<" ";cout<<endl;
  for(long i=0;i<N;i++)cout<<B[i]<<" ";
}

Measured memory_bytes: 1280
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll k;
    cin >> k;
    if(k % 2 == 0){
        cout << (k / 2) * (k / 2) << endl;
    }else{
        cout << (k / 2) * (k / 2 + 1) << endl;
    }
    return 0;
}


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

int main(){
	int k,n;
	int x,y;
	int ans;
	cin >> k >> n;
	vector<int> a(n);
	cin >> x;
	a[0] = x;
	for(int i = 1;i<n;i++){
		cin >> y;
		a[i] = y-x;
		x = y;
	}
	a[0] += k-x;
	int max = *max_element(a.begin(),a.end());
	ans = k - max;
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pii pair<int,int>
#define F first
#define S second
#define MP make_pair
#define vi vector<int>
#define pb push_back
using namespace std;
const int N=1e5+5;
int n,x[N];
vi v;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x[i];
	}
	for(int i=0;i<n;i++)
	{
		int l=lower_bound(v.begin(),v.end(),x[i])-v.begin();
		if(l==0)
			v.insert(v.begin(),x[i]);
		else
			v[l-1]=x[i];
	}
	cout<<v.size()<<endl;
	return 0;
}

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

using namespace std;

int main(){
	int M,T,P,R;
	while(cin >> M >> T >> P >> R,M||T||P||R){
	
		//??£?????°,????????????????¨?,???????????????
		vector<pair<pair<int,int>,int>> v(T,make_pair(make_pair(0,0),0));
		for(int i=0;i<T;i++){
			v[i].second = i+1;
		}
		vector<vector<int>> unsolved(T,vector<int>(P,0));
		for(int i=0;i<R;i++){
			int m,t,p,j;
			cin >> m >> t >> p >> j;
			if(j){
				unsolved[t-1][p-1]++;
				continue;
			}
			v[t-1].first.first++;
			v[t-1].first.second-=m;
			v[t-1].first.second-=unsolved[t-1][p-1]*20;
		}
		sort(v.begin(),v.end(),greater<pair<pair<int,int>,int>>());
		cout << v[0].second;
		for(int unsigned i = 0;i<v.size()-1;i++){
			if(v[i].first.first == v[i+1].first.first && v[i].first.second == v[i+1].first.second){
				cout << "=";
			} else {
				cout << ",";
			}
			cout << v[i+1].second;
		}
		cout << endl;
	}	
	return 0;
}

Measured memory_bytes: 3108
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
Formatter frm=new Formatter();
double r=scan.nextDouble();
double S=Math.PI*r*r*1.0;
double d=2*Math.PI*r*1.0;
System.out.println(String.format("%5f",S)+" "+String.format("%5f",d));
}}

Measured memory_bytes: 28292
#include <stdio.h>
#include <math.h>
 
typedef struct{
  double x;
  double y;
}Data;
 
void kock(int, Data, Data);
 
int main() {
  int i,n ;
  Data d1 = {0.0, 0.0};
  Data d2 = {100.0, 0.0};
 
  scanf("%d", &n);
 
  printf("%f %f\n", d1.x, d1.y);
  kock(n, d1, d2);
  printf("%f %f\n", d2.x, d2.y);
 
  return 0;
} 
 
void kock(int n, Data d1, Data d2){
  Data s, t, u;
 
  if(n == 0) return;
  
  s.x = (2*d1.x + 1*d2.x) / 3.0;
  s.y = (2*d1.y + 1*d2.y) / 3.0;
 
  t.x = (1*d1.x + 2*d2.x) / 3.0;
  t.y = (1*d1.y + 2*d2.y) / 3.0;
 
  u.x = (t.x-s.x) * 0.5 - (t.y-s.y) * (sqrt(3)/2) + s.x;
  u.y = (t.x-s.x) * (sqrt(3)/2) + (t.y-s.y) * 0.5 + s.y;
 
 
  kock(n-1, d1, s);
  printf("%f %f\n", s.x, s.y);
  kock(n-1, s, u);
  printf("%f %f\n", u.x, u.y);
  kock(n-1, u, t);
  printf("%f %f\n", t.x, t.y);
  kock(n-1, t, d2);
 
  return ;
 
}

Measured memory_bytes: 636
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};


const int MAX = 510000;
const int mod = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//a^n (mod m)
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//mod mでの a の逆元を求める
ll modinv(ll a) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod; 
    if (u < 0) u += mod;
    return u;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int c;
    cin>>c;
    if(c)cout << 0 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 3636