akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(void){
    long long int a,b;
    cin >> a >> b;
    int c[b];
    int n = 0;
    for(int i=0; i<b; i++){
        cin >> c[i];
    }
    for(int i=0; i<b; i++){
        n = n+c[i];
    }
    if(a>=n){
        cout << a-n << endl;
    }
    else{
        cout << "-1" << endl;
    }
}

Measured memory_bytes: 3216
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        double r=Double.parseDouble(reader.readLine());
        Double area=r*r*Math.PI;
        Double circumference=r*2*Math.PI;
        System.out.println(String.format("%.6f %.6f", area, circumference));
    }
}

Measured memory_bytes: 24536
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n%2 == 0){
            System.out.println(n/2);
        }else{
            System.out.println((n/2)+1);
        }
    }
}

Measured memory_bytes: 21972
#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>;

int main() {
  int n, a;
  cin >> n >> a;
  
  cout << (n%500 > a ? "No" : "Yes") << endl;
  return 0;
}

Measured memory_bytes: 256
# C - Marks


def marks(n, k, a):
    results = []
    for i in range(n - k):
        if a[i] < a[i + k]:
            results.append("Yes")
        else:
            results.append("No")
    return results


if __name__ == "__main__":
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    results = marks(n, k, a)
    for i in results:
        print(i)


Measured memory_bytes: 31588
#include <stdio.h>
typedef long long ll;
int main() {
	ll a, b, c, k;
	scanf("%lld%lld%lld%lld", &a, &b, &c, &k);
	printf("%lld\n", k % 2 == 0 ? a - b : b - a);
	return 0;
}

Measured memory_bytes: 128
var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(function (value) {
  return value.split(' ');
});

var tmp = input.shift();
var n = parseInt(tmp[0]);
var quantum = parseInt(tmp[1]);

var time = 0;
var currentProcess = null;
var left = 0;

while (input.length > 0) {
  var current = input.shift();
  left += quantum;
  currentQ = parseInt(current[1]);
  if (currentQ > left) {
    current = [current[0], currentQ - left];
    time += left;
    input.push(current);
  } else {
    time += currentQ;
    console.log([current[0], time].join(' '));
  }
  left = 0;
}

Measured memory_bytes: 41524
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename TYPE>
void print_vec(const vector<TYPE>& v, int num=0){
  if(num == 0) num = (int)v.size();
	for(int i=0; i<num; i++){
		cout << v[i]; if(i!=num-1) cout << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

template <typename T>
void SWAP(T &a, T &b){
  a = a^b;// a^b 
  b = a^b;// (a^b)^b
  a = a^b;// (a^b)^(a^b^b)
}

template <typename T>
void insertionSort(vector<T> &a, T N){
  //http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A&lang=ja
  print_vec(a);
  for(int i=0; i<N-1; i++){
    int j = i;
    while(j>=0 && a[j] > a[j+1]){
      SWAP(a[j], a[j+1]);
      j--;
    }
    print_vec(a);
  }
}
template <typename T>
void bubbleSort(vector<T> &a, int n){
  //http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_A&lang=ja
  ll num = 0;
  for(int i=0; i<n; i++){
    for(int j=n-1; j>i; j--){
      if(a[j-1] > a[j]){
        SWAP(a[j-1], a[j]);
        num++;
      }
    }
  }
  print_vec(a);
  cout << num << endl;
  return;
}

template <typename T>
void selectionSort(vector<T> &a, int n){
  ll num = 0;
  for(int i=0; i<n; i++){
    int min_id = i;
    for(int j=i+1; j<n; j++){
      if(a[min_id] > a[j]) min_id = j;
    }
    if(min_id != i){
      num++;
      SWAP(a[i], a[min_id]);
    }
  }
  print_vec(a);
  cout << num << endl;
  return;
}
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  //insertionSort(a, n);
  //bubbleSort(a, n);
  selectionSort(a, n);
  return 0;
}




Measured memory_bytes: 3104
n, m = map(int, input().split())
req = [list(map(int, input().split())) for i in range(m)]
for i in range(10000):
	st = str(i)
	if len(st) != n:
		continue
	ok = True
	for s, c in req:
		if int(st[s-1]) != int(c):
			ok = False
	if ok:
		print(st)
		exit(0)

print(-1)


Measured memory_bytes: 3060
import java.util.*;
public class Main {
    public static void main(String[] args) {
      	Scanner sc = new Scanner(System.in);
		int n1 = Integer.parseInt(sc.next());
      	int p[] = new int[n1];
      	int err = 0;
      	int cnt = 0;
      	for(int i=0;i<p.length;i++){
          p[i] = Integer.parseInt(sc.next());
          if( p[i]%2==0 ){
            if( p[i]%3==0||p[i]%5==0 ){
              cnt++;
            }else{
              err = -1;
            }
          }
        }
 
      
      	if( err == 0 ){
       	 System.out.println("APPROVED");
        }else{
          System.out.println("DENIED");
        }
    }
}

Measured memory_bytes: 24916
#include <iostream>
using namespace std;
#define mod 1000000007
static const int MAX_N = 100000;

int main(void){
    // 入力
    int n,m;
    int a[MAX_N+1];
    cin >> n >> m;

    // stairs[i]=1 => i段目は壊れている
    int stairs[n+1]={0};
    for(int i=1; i<=m; i++){
        cin >> a[i];
        stairs[a[i]] = 1;
    }

    // dp[i]:=i段目までの行き方の総数
    long long dp[n+1];
    dp[0]=1;
    if(stairs[1]==0) dp[1]=1;
    else dp[1]=0;

    for(int i=0; i<n-1; i++){
        if(stairs[i+2]==0){
            dp[i+2] = dp[i+1] + dp[i];
            dp[i+2] %= mod;
        }
        else{
            dp[i+2] = 0;
        }
    }

    // 出力
    cout << dp[n];


}

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

const int MOD = 1000000007;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i, N) cin >> P[i];

    int mi = 5000500;
    int c = 0;

    rep(i, N) {
        mi = min(mi, P[i]);
        if (mi >= P[i]) {
            c++;
        }
    }

    cout << c << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll N;
    cin >> N;
    ll A[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    ll m = 1ll << 50;
    ll count = 0;
    for(int i = 0; i < N; i++){
        if(A[i] < m){
            m = A[i];
            count++;
        }
    }
    cout << count << endl;


}

Measured memory_bytes: 1920
#include <iostream>
using namespace std;
int main(){
  int n,w,h,x,y,s,t,i,j,wcs,hcs,hce,wce,max,cnt,data[101][101];
  while(1){
    max=0;
    cin >> n;
    if(n==0) break;
    cin >> w >> h;
    for(i=0;i<=h;i++){
      for(j=0;j<=w;j++){
    data[i][j]=0;
      }
    }
    for(i=0;i<n;i++){
      cin >> x >> y;
      data[y][x]=1;
    }
    cin >> s >> t;
    hcs=1;
    wcs=1;
    hce=t;
    wce=s;
    while(1){
      while(1){
    cnt=0;
    for(i=hcs;i<=hce;i++){
      for(j=wcs;j<=wce;j++){
        if(data[i][j]==1){
          cnt++;
        }
      }
    }
    if(cnt>max) max=cnt;
    wcs++;
    wce++;
    if(wce==w+1) break;
      }
      hcs++;
      hce++;
      wcs=1;
      wce=s;
      if(hce==h+1) break;
    }
    cout << max << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> ans(n, k - q);
    rep(i, q) {
        int a;
        cin >> a;
        a--;
        ans[a]++;
    }
    rep(i, n) {
        if(ans[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3792
local n, x = io.read("*n", "*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
local inf = 1000000000
local cost = {}
for i = 1, n * n do
  cost[i] = 0
end
local mmi = math.min
for i = 1, n do
  for j = 0, n - 1 do
    local it = i + j
    if n < it then it = it - n end
    cost[j * n + it] = i
  end
end
for i = 1, n do
  for j = 0, n - 2 do
    local idx = j * n + i
    local pre_i = cost[idx]
    local pre_len = i - pre_i
    if pre_len < 0 then pre_len = pre_len + n end
    local pre_cost = a[pre_i]
    local next_idx = idx + n
    local next_cost = a[cost[next_idx]]
    if pre_cost < next_cost then
      cost[next_idx] = pre_i
    end
  end
end
local ret = 2000 * 1000000000
for j = 0, n - 1 do
  local sum = j * x
  for i = 1, n do
    sum = sum + a[cost[i + j * n]]
  end
  ret = mmi(ret, sum)
end
print(ret)


Measured memory_bytes: 34812
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
 
const int maxn = 2e5 + 20;

int a[maxn];

ll l[maxn] , r[maxn] , t[maxn];

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

	int n;
	cin >> n;

	for(int i = 1; i <= n; i++)
		cin >> a[i] , t[i] = t[i - 1] + (a[i] % 2 == 0);

	ll sum = 0;
	for(int i = 1; i <= n; i++)
	{
		sum += a[i];
		l[i] = sum;

		if(!a[i])
			l[i] = min(l[i] , l[i - 1] + 2);
		else if(a[i] % 2)
			l[i] = min(l[i] , l[i - 1] + 1);
		else
			l[i] = min(l[i] , l[i - 1]);
	}

	sum = 0;
	for(int i = n - 1; i >= 0; i--)
	{
		sum += a[i + 1];
		r[i] = sum;

		if(!a[i + 1])
			r[i] = min(r[i] , r[i + 1] + 2);
		else if(a[i + 1] % 2)
			r[i] = min(r[i] , r[i + 1] + 1);
		else
			r[i] = min(r[i] , r[i + 1]);
	}

	ll mx = 0 , res = 1e18;
	for(int i = 1; i <= n; i++)
	{
		mx = max(mx , t[i] - l[i]);
		res = min(res , r[i] + t[i] - mx);
	}

	cout << res << endl;
}


















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

int main()
{
    ios::sync_with_stdio(false);
    int a, b, c, k,maior,resto;

    cin >> a >> b >> c >> k;

    if(a>b && a>c){
        maior = a;
    }else if(b>c){
        maior = b;
    }else{
        maior = c;
    }

    if (maior == a){
        resto = b+c;
    }else if(maior == b){
        resto = a+c;
    }else{
        resto = a+b;
    }

    for(int i=0;i<k;i++){
        maior*=2;
    }

    cout<<maior+resto<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cstdio>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int x[n], y[n];

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

    double man = 0, yuku = 0, san = 0, max = 0;
    for (int i = 0; i < n; i++) {
        man += abs(x[i]-y[i]);
        yuku += pow(x[i]-y[i], 2);
        san += pow(abs(x[i]-y[i]), 3);
        if (max < abs(x[i]-y[i])) {
            max = abs(x[i]-y[i]);
        }
    }
    yuku = sqrt(yuku);
    san = cbrt(san);

    printf("%.6lf\n%.6lf\n%.6lf\n%.6lf\n", man, yuku, san, max);
}




Measured memory_bytes: 3424
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <assert.h>

using namespace std;

#define MAXDATA			2000000
#define APPTXT_BUFSZ	128

#define countof(arr)		(sizeof(arr) / sizeof(arr[0]))

static int g_anDataBuf[MAXDATA];
static bool g_abInvalid[MAXDATA];

int main(void) {
	char str[APPTXT_BUFSZ];
	int bgn, end;
    int n;
    int x;

	fgets(str, APPTXT_BUFSZ, stdin);
	n = atoi(&(str[0]));

	bgn = end = countof(g_anDataBuf);
	while( n-- > 0 && fgets(str, APPTXT_BUFSZ, stdin) != NULL ) {
		if (str[0] == 'i') {		// ("insert"?¢????)
			x = atoi(&(str[sizeof("insert") - 1]));
			g_anDataBuf[--bgn] = x;
			g_abInvalid[bgn] = false;
        } else {
			int c = str[sizeof("delete") - 1];
			if (isalpha(c)) {
				if (c == 'F') {		// ("deleteFirst"?¢????)
					while (bgn < end && g_abInvalid[bgn++]) { }
					assert(bgn <= end);
				} else {			// ("deleteLast"?¢????)
					while (bgn < end && g_abInvalid[--end]);
					assert(bgn <= end);
				}
			} else {				// ("delete"?¢????)
				x = atoi(&(str[sizeof("delete") - 1]));
				for (int i = bgn; i < end; i++) {
					if (g_abInvalid[i]) {
						continue;
					}
					if (g_anDataBuf[i] == x) {
						g_abInvalid[i] = true;
						break;
					}
				}
			}
		}
    }

	//display list
	bool bFirst = true;
	for (int i = bgn; i < end; i++) {
		if (g_abInvalid[i]) {
			continue;
		}
		const int x = g_anDataBuf[i];
		if (bFirst) {
			printf("%d", x);
			bFirst = false;
		} else {
			printf(" %d", x);
		}
	}
	fputc('\n', stdout);

	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, m, ans = 0, cnt = 0;
  cin >> n >> m;
  
  if(n >= m) {
    cout << 0 << "\n";
    return 0;
  }
  
  vector<ll> x(m);
  rep(i, 0, m) cin >> x[i];
  sort(x.begin(), x.end());
  
  vector<ll> sum(m-1);
  rep(i, 0, m-1) {
    sum[i] = x[i+1]-x[i];
    cnt += sum[i];
  }
  sort(sum.rbegin(), sum.rend());
  
  rep(i, 0, n-1)  ans += sum[i];
  
  cout << cnt - ans << "\n";
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, M, P;
	cin >> N >> M >> P;
	vector<pair<int, int>> E[2501];
	rep(i, M) {
		int a, b, c;
		cin >> a >> b >> c;
		E[a].pb(mp(b, c - P));
	}

	ll D[2501];
	rep1(i, N) D[i] = -2e9;
	D[1] = 0;

	rep(k, N * 2) {
		rep1(i, N) {
			if (D[i] != -2e9) {
				for (auto p : E[i]) {
					if (D[p.first] == -2e9) D[p.first] = D[i] + p.second;
					else D[p.first] = max(D[p.first], D[i] + p.second);
				}
			}
		}
	}

	ll D1[2501];
	rep1(i, N) D1[i] = D[i];
	rep(k, N * 2) {
		rep1(i, N) {
			if (D[i] != -2e9) {
				for (auto p : E[i]) {
					if (D[p.first] == -2e9) D[p.first] = D[i] + p.second;
					else D[p.first] = max(D[p.first], D[i] + p.second);
				}
			}
		}
	}

	//if (kari < D[N]) co(-1);
	//else co(max(0, D[N]));

	rep1(i, N) {
		if (D1[i] < D[i]) D[i] = 2e9;
	}
	rep(k, N * 2) {
		rep1(i, N) {
			if (D[i] != -2e9) {
				for (auto p : E[i]) {
					if (D[p.first] == -2e9) D[p.first] = D[i] + p.second;
					else D[p.first] = max(D[p.first], D[i] + p.second);
				}
			}
		}
	}

	if (D[N] > 1e9) co(-1);
	else co(max(0ll, D[N]));


	Would you please return 0;
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		while(true){
			int n = stdIn.nextInt();
			if(n==0){
				return;
			}
			int[] w = new int[n];
			for(int i=0;i<n;i++){
				w[i] = stdIn.nextInt();
			}
			Arrays.sort(w);
			long s = 0;
			long t = 0;
			for(int i=0;i<n;i++){
				s += t;
				t += w[i];
			}
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
using namespace std;

int main() {
	int H1, M1, H2, M2, K;
	int hour, min, total;
	cin >> H1 >> M1 >> H2 >> M2 >> K;
	hour = H2 - H1;
	min = M2 - M1;
	if (min < 0) {
		hour = hour - 1;
		min = 60 + min;
	}
	total = hour * 60 + min - K;
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 3588
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define FRE freopen("in.txt", "r", stdin);
#define endl "\n"
#define PI acos(-1.0)
typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10, M = 1010;

LL cacl(LL a, LL b) {
	return a*a*a*a + a*a*a*b + a*a*b*b + a*b*b*b + b*b*b*b;
}

void solve() {
	LL x;
	cin >> x;
	for(LL i = 1; i * i <= x; i++) {
		if(x % i == 0) {
			for(LL j = -1000; j <= 1000; j++) {
				if(cacl(j + i, j) == x / i) {
					cout << j + i << " " << j << endl;
					return;
				}
				else if(cacl(j + x / i, j) == i) {
					cout << j + x / i << " " << j << endl;
					return;
				}
			}
		}
	}
}

int main() {
	IOS;
	int t;
	solve();
	return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include<math.h>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
int G(ll n)
{
	ll pos=sqrt(n);
	for (;pos>=1;pos--)
	{
		if (n%pos==0)
			return pos;
	}


}
int main()
{
	ll a;
	cin>>a;
	ll g1=G(a);
	ll g2=a/g1;
	ll sum=g1+g2-2;
	cout<<sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   ll;
string s;
ll arr[10000009];
ll brr[10000009];
int main(){
    cin >> s;
    int ans=0,count=0;
    for(int i=1;i<=s.length();i++){
        ll d=s[i-1] - '0';
        if(d<=4){
            arr[i] += d;
        }
        else{
            arr[i-1]+=1;
            brr[i]+=10-d;
        }
    }
    int n=1;
    for(int i=0;i<=s.length();i++){
        if(arr[i]>=brr[i]){
            arr[i] = arr[i] - brr[i];
            brr[i] = 0;
        }
        else{
            brr[i] = brr[i] - arr[i];
            arr[i] = 0;
        }
    }
    while(n!=0){
        n=0;
        for(int i=0;i<=s.length();i++){
            if(arr[i] > 4 && brr[i-1] > 0){
                brr[i-1]--;
                brr[i]=10-arr[i];
                arr[i]=0;
                n++;
            }
            else if(brr[i] > 4 && arr[i-1] >0){
                arr[i-1]--;
                arr[i] = 10- brr[i];
                brr[i] =0;
                n++;
            }
        }
    }

    for(int i=0;i<=s.length();i++){
            if(arr[i]>=brr[i]){
                arr[i] = arr[i] - brr[i];
                brr[i] = 0;
            }
            else{
                brr[i] = brr[i] - arr[i];
                arr[i] = 0;
        }
    }
    for(int i=0;i<=s.length();i++){
        ans += max(arr[i],brr[i]);
    }
    cout << ans;
}

Measured memory_bytes: 17668
#include<iostream>
#include<math.h>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include <time.h>
#include<string.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 2005;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=2.718281828459045235360287471352662;
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back

int main()
{
    ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int a,b,k;
    cin>>a>>b>>k;
    for(int i=a;i<=min(a+k-1,b);i++)
        cout<<i<<endl;
    for(int i=max(a+k,b-k+1);i<=b;i++)
        cout<<i<<endl;
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
	string s[4] = { "dream", "dreamer", "erase", "eraser" };
	for (int i = 0; i < 4; ++i){
		reverse(s[i].begin(), s[i].end());
	}
	string t;
	cin >> t;
	reverse(t.begin(), t.end());
	int offset = 0;
	bool compare_flg = false;
	while (offset < t.size()){
		compare_flg = false;
		for (int j = 0; j < 4; ++j){
			if (t.substr(offset, s[j].size()) == s[j]){
				offset += s[j].size();
				compare_flg = true;
				break;
			}
		}
		if (compare_flg == false)break;
	}
	if (offset == t.size())cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 512
#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<ll, int>;

// 辺の構造体
struct E {
  int to, cost;
  E(int to = 0, int cost = 0) : to(to), cost(cost) {} 
};

string rev(string s) {
  reverse(s.begin(), s.end());
  return s;
}

int main() {
  int m;
  cin >> m;
  vector<string> s(m);
  vector<int> c(m);
  rep(i, m) cin >> s[i] >> c[i];
  rep(i, m) {
    s.push_back(rev(s[i]));
    c.push_back(c[i]);
  }
  int n = 1;
  vector<vector<int>> id(m*2);
  rep(i, m*2) {
    int l = s[i].size();
    id[i].resize(l);
    rep(j, l) {
      id[i][j] = n++;  // 各要素にidを割り振る
    }
  }
  
  // ダイクストラのグラフを作る
  vector<vector<E>> g(n);
  rep(i, m*2) {
    int l = s[i].size();
    rep(j, l) {
      int v = id[i][j];
      rep(ni, m*2) {
        if (i/m == ni/m) continue;
        int nl = s[ni].size();
        int w = min(nl, l-j);  // 共通部分
        // 共通部分が一致してればok, してなければcontinue
        if (s[i].substr(j, w) != s[ni].substr(0, w)) continue;
        // 遷移先の決定
        int u = 0;
        if (nl > w) {  // 後ろが余る
          u = id[ni][w];
        } else if (l > j+w) {  // 先頭が余る
          u = id[i][j+w];
        } else u = 0;  // 余りなし
        g[v].emplace_back(u, c[ni]);
      }
    }
  }
  
  // ダイクストラをしていく
  const ll INF = 1e18;
  vector<ll> dist(n, INF);
  // 値が小さい順に取り出すpriority_queue
  // 各要素は現在の距離と頂点番号のpair
  priority_queue<P, vector<P>, greater<P>> q;
  auto push = [&](int v, ll x) {  // vに対してxで更新する関数
    if (dist[v] <= x) return;
    dist[v] = x;
    q.emplace(x, v);  // pair.firstに現在の距離, secondに頂点番号
  };
  
  rep(i, m) push(id[i][0], c[i]);  // 初期状態. 各文字列の0文字目以降(まるまる)残っている
  while (!q.empty()) {
  	ll x = q.top().first;
  	int v = q.top().second; q.pop();
  	if (dist[v] != x) continue;  // 現在の最適箇所がxと一致してない場合continue. 計算量が定数倍変わる.
  	for (E e : g[v]) push(e.to, x+e.cost);  // vから出ている辺を全て探す
  }
  
  ll ans = dist[0];
  // 各状態を見ていく
  rep(i, m*2) {
  	int l = s[i].size();
    rep(j, l) {
      string t = s[i].substr(j);  // 余っている部分の文字列
      if (t == rev(t)) {  // 回文になっていればok
        ans = min(ans, dist[id[i][j]]);
      }
    }
  }
  
  if (ans == INF) cout << -1 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 3704
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var I = G;
		WriteLine(I.Sum() > 2 * I.Max() ? "Yes" : "No");
	}
}


Measured memory_bytes: 13396
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#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;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

ll N,a[3010];
ll dp[3010][3010];

int main(){
  cin >>N;
  REP(i,N){
    cin >>a[i];
  }
  REP(i,N+1){
    REP(j,N+1)dp[i][j]=0;
  }
  for(int len=1;len<=N;len++){
    for(int l=0;l<=N-len;l++){
      int r=l+len;
      if((N-len)%2==0){
        dp[l][r]=max(dp[l+1][r]+a[l],dp[l][r-1]+a[r-1]);
      }else{
        dp[l][r]=min(dp[l+1][r]-a[l],dp[l][r-1]-a[r-1]);
      }

    }
  }
  cout <<dp[0][N]<<endl;
}


Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

int main(){
  long long N,M;
  cin >> N >> M;

  long long ans=0;
  if(N>=M/2){
    ans=M/2;
  }
  else if(N<M/2){
    ans=N;
    M-=2*N;
    ans+=M/4;
  }
  cout << ans << endl;

  return 0;
}


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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

clock_t time_p = clock();

void rtime() {
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float) 1000 * (time_p) / CLOCKS_PER_SEC << "\n";
}

#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int INF=1e15;
const int MOD=1e9+7;
const int N=2e5+10;

int dp[2005][2005],n;
vector<pair<int,int>> arr;

int sol(int idx,int l,int r) {
    debug(l,r);
    if(l>r) return 0;
    int& ans=dp[l][r];
    if(ans!=-1) return ans;
    ans=max(sol(idx+1,l,r-1)+arr[idx].first*abs(arr[idx].second-r),sol(idx+1,l+1,r)+arr[idx].first*abs(arr[idx].second-l));
    return  ans;
}

signed main() {
//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif
    IOS;
    int t = 1;
//    cin >> t;
    while (t--) {
        cin>>n;
        arr=vector<pair<int,int>>(n+1);
        for(int i=1;i<=n;i++) {
            cin>>arr[i].first;
            arr[i].second=i;
        }
        sort(arr.begin()+1,arr.end(),greater<pair<int,int>>());
        memset(dp,-1,sizeof(dp));
        cout<<sol(1,1,n)<<"\n";
    }
    return 0;
}

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

using namespace std;

int main(void){
    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    double sum=0.0;
    for(int i=0;i<N;i++){
        sum+=1/(double)A[i];
    }
    cout<<1/sum<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String[] firstRowInput = br.readLine().split(" ");
            String[] secondRowInt = br.readLine().split(" ");

            int whiteRowCount = Integer.parseInt(firstRowInput[0]);
            int whiteColumnCount = Integer.parseInt(firstRowInput[1]);
            int blackRowCount = Integer.parseInt(secondRowInt[0]);
            int blackColumnCount = Integer.parseInt(secondRowInt[1]);
            int whiteCellsCountIs = (whiteRowCount - blackRowCount) * (whiteColumnCount - blackColumnCount);

            System.out.println(whiteCellsCountIs);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 22740
#include <iostream>

using namespace std;

int howMany(int n, int m)
{
    return n / m;
}

int main()
{
    int x, hap = 0, t;
    cin >> x;
    int i = 0;
    while(x >= 5)
    {
        if (x >= 500)
        {
            hap += 1000 * howMany(x, 500);
            x = x - howMany(x, 500) * 500;
        }
        else
        {
            hap += 5 * howMany(x, 5);
            x = x - howMany(x, 5) * 5;
        }

    }
    cout << hap << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,m,sum=0;
	scanf("%d%d",&n,&m);
	for(int i=0,x;i<m;i++) {
		scanf("%d",&x);
		sum+=x;
	}
	printf("%s\n",sum>=n?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
static const int N = 1000;

int lcs(string x, string y){
  int c[N + 1][N + 1], maxl = 0, i, j;
  int m = x.size();
  int n = y.size();

  x = ' ' + x;
  y = ' ' + y;
 
  for(i = 1; i <= m; i++) c[i][0] = 0;
  for(i = 0; i <= n; i++) c[0][i] = 0;

  for(i = 1; i <= m; i++){
    for(j = 1; j <= n; j++){
      if(x[i] == y[j]){
	c[i][j] = c[i - 1][j - 1] + 1;
      } else{
	c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      }
      maxl = max(maxl, c[i][j]);
    }
  }
  return maxl;
}

int main(){
  string x, y;
  int q, i;

  cin >> q;
  
  for(i = 0; i < q; i++){
    cin >> x >> y;
    cout << lcs(x, y) << endl;
  }
  return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
//2 pointer approach interesting problem

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    int a[n+1];
    for(int i=1;i<=n;i++)
    	cin>>a[i];
    int dp[n+1];
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
    	int mina=1e18;
    	for(int j=i-1;j>=(i-k);j--)
    	{
    		if(j>=1)
    		{
    			int x=dp[j]+abs(a[i]-a[j]);
    			mina=min(mina,x);

    		}
    	}
    	dp[i]=mina;
    }
   cout<<dp[n];
     
    
    return 0;
}

Measured memory_bytes: 1792
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> M >> K;
	vector<queue<int>>v(1001);
	vector<int>num(K);
	for (int i = 0; i < K; i++) {
		cin >> num[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> L >> R;
		L--;
		v[R].push(L);
	}
	int ans = 0;
	for (int i = 1000; i > 0; i--) {
		while (!v[i].empty()) {
			int box = v[i].front();
			v[i].pop();
			if (num[box]) {
				num[box]--;
				M--;
				ans += i;
				if (!M) {
					cout << ans << endl;
					return 0;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3832
import java.util.ArrayDeque;
import java.util.BitSet;
import java.util.Deque;
import java.util.Scanner;
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
    public static void main(String[] args){
        Deque<Integer> deque = new ArrayDeque<Integer>();
        StringBuilder sb = new StringBuilder();
        FS fs = new FS();
        int n = fs.nextInt();
        BitSet bitSet = new BitSet(2000);
        for(int i=0;i<n;i++){
            Integer m = fs.nextInt();
            bitSet.set(m);
            Object[] mm = deque.toArray();
            for (int j=0;j<mm.length;j++){
                int i1 = ((Integer) mm[j]) + m;
                bitSet.set(i1);
                deque.add(i1);
            }
            deque.add(m);
        }
        int q = fs.nextInt();
        for (int i=0;i<q;i++){
           sb.append( bitSet.get(fs.nextInt())?"yes\n":"no\n");
        }
        System.out.print(sb.toString());
    }



static class FS {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        return hasNextByte() ? buffer[ptr++] : -1;
    }

    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    private void skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    public boolean hasNext() {
        skipUnprintable();
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
        return (int) nextLong();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}
}


Measured memory_bytes: 54792
#include <iostream>
#include <string.h>
#include <algorithm>
#include <stack>
using namespace std;

typedef long long ll;

const int MAX_N = 300006;

struct P
{
	ll a;
	bool f;
	bool operator< (const P& ot)const
	{
		return a > ot.a;
	}
};
P p[MAX_N];


int main()
{
	int N;
	ll x;
	scanf("%d", &N);

	int r = 0;
	for (int i = 0; i < N; ++i)
	{
		scanf("%lld", &x);
		if (x < 0)
		{
			p[i].a = -x;
			p[i].f = true;
			++r;
		}
		else
		{
			p[i].a = x;
			p[i].f = false;
		}
	}
	sort(p, p + N);

	if (r == 0)
	{
		p[N - 1].a = -p[N - 1].a;
		p[N - 1].f = true;
	}
	else if (r == N)
	{
		p[N - 1].a = -p[N - 1].a;
		p[N - 1].f = false;
	}

	ll s = 0;
	for (int i = 0; i < N; ++i)
	{
		s += p[i].a;
	}
	printf("%lld\n", s);

	stack<ll> zh, fu;

	for (int i = 0; i < N; ++i)
	{
		if (p[i].f)
		{
			fu.push(-p[i].a);
		}
		else
		{
			zh.push(p[i].a);
		}
	}

	for (int i = 1; i < N; ++i)
	{
		if (fu.size() >= zh.size())
		{
			printf("%lld %lld\n", zh.top(), fu.top());
			zh.top() = zh.top() - fu.top();
			fu.pop();
		}
		else
		{
			printf("%lld %lld\n", fu.top(), zh.top());
			fu.top() = fu.top() - zh.top();
			zh.pop();
		}
	}

	return 0;
}


Measured memory_bytes: 4096
// Problem : D - Replacing
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
 *   ﷽
 * In the name of Allah, the Most Gracious, the Most Merciful
 */

#include <algorithm>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> arr(100005, 0);
    unsigned long ans = 0;
    for (int t=0;t<n;t++)
    {
    	int tmp;
    	cin>>tmp;
    	ans += tmp;
    	arr[tmp]++;
    }
        
    int q;
    cin >> q;
    while (q--)
    {
        int b, c;
        cin >> b >> c;
        int diff = c - b;
        arr[c]+= arr[b];
        ans += arr[b] * diff;
        arr[b] = 0;
        
        cout << ans << "\n";
    }
    return 0;
}

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

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

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

void solve() {
    int a, b, c, x, y; scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);
    int ans = 0;
    int k = min(x, y);
    if (2*c < a+b) {
        ans += k*2*c;
    } else {
        ans += k*a+k*b;
    }
    x -= k; y -= k;
    if (x > y) {
        if (2*c < a) {
            ans += x*2*c;
        } else {
            ans += x*a;
        }
    } else {
        if (2*c < b) {
            ans += y*2*c;
        } else {
            ans += y*b;
        }
    }
    printf("%d", ans);
}

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

Measured memory_bytes: 256
//C
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
	return b?gcd(b,a%b):a;
}
int main(){
	ll k,ans = 0;
	cin >> k;
	for(int i = 1;i <= k;i++)
		for(int j = 1;j <= k;j++)
			for(int x = 1;x <= k;x++)ans += gcd(i,gcd(j,x));
	cout << ans;
	return 0;
}


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

void insertionSort(int *A, int N){
  for(int i=1;i<N;i++){
    int v=A[i];
    int j=i-1;

    while(j>=0&&A[j]>v){
      A[j+1]=A[j];
      j--;
    }

    A[j+1]=v;

    for(int i=0;i<N;i++){
      cout<<(i?" ":"");
      cout<<A[i];
    }
    cout<<endl;
  }
}

int main(){

  int n;
  int a[110];

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    cout<<(i?" ":"");
    cout<<a[i];
  }
  cout<<endl;

  insertionSort(a, n);

  return 0;
}

Measured memory_bytes: 3096
#include <stdio.h>

int main(void){

  int n,m;
  scanf("%d %d", &n, &m);
  int a[m], b[m];
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a[i], &b[i]);
  }
  int count[n+1];
  for (int i = 0; i < n+1; i++) {
    count[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    count[a[i]]++;
    count[b[i]]++;
  }
  for (int i = 1; i < n+1; i++) {
    printf("%d\n", count[i]);
  }

  return 0;
}

Measured memory_bytes: 128
// Command quickstart generates an audio file with the content "Hello, World!".
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func scanInt() int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return a
}

func scanFloat() float64 {
	sc.Scan()
	a, _ := strconv.ParseFloat(sc.Text(), 64)
	return a
}

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func max(a int, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	_ = scanInt()
	m := scanInt()
	p := make([]int, m)
	s := make([]string, m)
	for i:=0; i<m; i++ {
		p[i] = scanInt()
		s[i] = scanText()
	}

	var (
		ac int
		pena int
	)
	record := map[int]int{}
	ok := map[int]int{}
	for i:=0; i<m; i++ {
		if s[i] == "AC" {
			if ok[p[i]] == 0 {
				ok[p[i]] = 1
				pena += record[p[i]]
				ac += 1
			}
		}else{
			record[p[i]] += 1
		}
	}

	fmt.Println(ac, pena)
}


Measured memory_bytes: 10788
n = int(input())
c, s, f = [], [], []
for _ in range(n-1):
    _c, _s, _f = map(int, input().split())
    c.append(_c)
    s.append(_s)
    f.append(_f)

for i in range(n-1):
    t = c[i]+s[i]
    for j in range(i+1, n-1):
        if s[j] <= t:
            if t%f[j] == 0:
                t += c[j]
            else:
                t += c[j]+(f[j]-t%f[j])
        elif s[j] > t:
            t = s[j]+c[j]

    print(t)

print(0)


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int a[3];
	rep(i, 3) cin >> a[i];

	sort(a, a+3);

	cout << a[0] * a[1] / 2 << endl;
}


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

#define INF_P 1100000000
#define INF_M -1100000000
#define MAX(a,b) a<b?b:a
#define MIN(a,b) a>b?b:a

struct item{
    int weight;
    int value;
};

int max(int a, int b);

int n, w;
int dp[101][10001];
struct item goods[101];

int main(void)
{
    int i, j, tmp;

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

    for (i = 1; i <= n; i++) {
        scanf("%d %d",&goods[i].value, &goods[i].weight);
    }

    for (i = 1; i <= n; i++) {
        for (j = 1; j <= w; j++) {
            if (goods[i].weight <= j) {
                dp[i][j] = max(dp[i-1][j],
                        max(dp[i][j-goods[i].weight]+goods[i].value,
                            dp[i-1][j-goods[i].weight]+goods[i].value));
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    tmp = -1;
    for (i = 0; i <= w; i++) {
        if (tmp < dp[n][i]);
        tmp = dp[n][i];
    }
    printf("%d\n",tmp);
    return 0;
}

int max(int a, int b) 
{
    if (a < b) {
        return b;
    } else {
        return a;
    }
}

Measured memory_bytes: 4504
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N;
	cin >> N;
	if (N == 1 || N == 2 || N == 3 || N == 5 || N == 6 || N == 9 || N == 10 || N == 13||N==17) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
const long long MOD = 1e9+7, INF = 1e18;

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;}

string s;
int now = 0,cnt = 0;
string solve(){
	string t="";
	cnt = 0;
	while(now<s.size()&&s[now]!=']'){
		if(s[now]=='+')cnt++;
		else if(s[now]=='-')cnt--;
		else if(s[now]=='['){
			now++;
			string tmp = solve();
			reverse(all(tmp));
			t+=tmp;
			cnt = 0;
		}else{
			if(s[now]=='?')t+='A';
			else t+=(char)'A'+(s[now]-'A'+cnt%26+26)%26;
			cnt = 0;
		}
		now++;
	}
	return t;
}

signed main(){
	vector<string>ans;
	while(cin>>s,s!="."){
		ans.push_back(solve());
		now = 0;
	}
	for(auto e:ans)cout<<e<<endl;
}


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

int main(){
  int N;
  cin>>N;
  vector<int>d(N);
for(int i=0;i<N;i++){
  cin>>d[i];
}
  sort(d.begin(),d.end());
cout<<d[N/2]-d[N/2-1]<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
    int a,b,c;
    cin >> a >> b >> c;
    cout << ((a+b+c)==17 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
"""
C
"""
N=int(input())
S=[input() for i in range(N)]
S.sort()

kkk=1
data=[]
for i in range(1,N):
    if S[i]==S[i-1]:
        kkk+=1
    else:
        data.append([kkk,S[i-1]])
        kkk=1
data.append([kkk,S[-1]])
data.sort()
num=data[-1][0]

for u in data:
    if u[0]==num:
        print(u[1])




Measured memory_bytes: 100780
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
     
using namespace std;
     
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

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

  cin >> a >> b >> c >> d;

  string ans;
  if(a + b > c + d){
    ans = "Left";
  } else if (a + b < c + d) {
    ans = "Right";
  } else {
    ans = "Balanced";
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

char table[256];

void clearTable(void)
{
	int i;
	for( i = 0; i < 256; i++ )
	{
		table[i] = 0;
	}
}

int main(void)
{
	int i;
	int n;
	int m;
	
	while( 1 )
	{
		char str[16];
		fgets( str, 16, stdin );
		sscanf( str, "%d", &n );
		if( n == 0 )
		{
			break;
		}
		clearTable();
		for( i = 0; i < n; i++ )
		{
			char c1;
			char c2;
			char str[32];
			fgets( str, 32, stdin );
			c1 = str[0];
			c2 = str[2];
			table[ c1 ] = c2;
		}
		
		fgets( str, 16, stdin );
		sscanf( str, "%d", &m );
		
		for( i = 0; i < m; i++ )
		{
			char c;
			char str[32];
			fgets( str, 32, stdin );
			c = str[0];
			if( table[ c ] != 0 )
			{
				printf( "%c", table[ c ] );
			}
			else
			{
				printf( "%c", c );
			}
		}
		puts("");
	}
	
	return (0);
}

Measured memory_bytes: 600
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(a: int, b: int, c: int):
    s = (a + b + c) / 2

    if s in [a, b, c]:
        print('Yes')
    else:
        print('No')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    solve(a, b, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060