akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
   int buy, sell, prof;
   int rate;
   int n;
   int i = 2;
   
   scanf("%d", &n);
   scanf("%d", &buy);
   scanf("%d", &sell);
   prof = sell - buy;
   if (prof < 0)
      buy = sell;
   while (i < n){
      scanf("%d", &rate);
      if (rate - buy > prof)
         prof = rate - buy;
      if (rate < buy)
         buy = rate;
      ++i;
   }
   printf("%d\n", prof);
   return 0;
}

Measured memory_bytes: 1844
#include <algorithm>
#include <cstring>
#include <cstdio>
#define MOD 998244353
#define GEN 3
typedef long long ll; 
inline int sum(int x, int y)
{
	x += y; 
	if (x >= MOD)
		x -= MOD; 
	return x; 
}
inline int sub(int x, int y)
{
	x -= y; 
	if (x < 0)
		x += MOD; 
	return x; 
}
inline int quick_pow(int a, int n)
{
	int res = 1; 
	while (n)
	{
		if (n & 1)
			res = (ll)res * a % MOD; 
		a = (ll)a * a % MOD; 
		n >>= 1; 
	}
	return res; 
}
int alpha[2][40005], poly_rev[40005], poly_ntt_lst = -1; 
inline void poly_ntt_init(int n)
{
	if (poly_ntt_lst == n)
		return;
	poly_ntt_lst = n;
	alpha[0][0] = alpha[1][0] = 1; 
	alpha[0][1] = quick_pow(GEN, (MOD - 1) / n); 
	alpha[1][1] = quick_pow(alpha[0][1], MOD - 2); 
	for (int i = 2; i <= n; i++)
	{
		for (int x = 0; x < 2; x++)
			alpha[x][i] = (ll)alpha[x][1] * alpha[x][i - 1] % MOD; 
	}
	for (int i = 1, j = n >> 1; i + 1 < n; i++)
	{
		poly_rev[i] = j; 
		int k = n >> 1; 
		while (j >= k)
		{
			j -= k; 
			k >>= 1; 
		}
		j += k;
	}
}
inline void poly_ntt(int *arr, int n, bool f)
{
	poly_ntt_init(n); 
	for (int i = 1; i + 1 < n; i++)
	{
		if (i < poly_rev[i])
			std::swap(arr[i], arr[poly_rev[i]]); 
	}
	for (int i = 1; i < n; i <<= 1)
	{
		for (int j = 0, off = n / (i << 1); j + i < n; j += i << 1)
		{
			for (int k = j, cur = 0; k < j + i; k++, cur += off)
			{
				int x = (ll)arr[k + i] * alpha[f][cur] % MOD; 
				arr[k + i] = sub(arr[k], x); 
				arr[k] = sum(arr[k], x); 
			}
		}
	}
	if (f)
	{
		int x = quick_pow(n, MOD - 2); 
		for (int i = 0; i < n; i++)
			arr[i] = (ll)arr[i] * x % MOD; 
	}
}
inline void poly_mul(int *a, int *B, int n, int m)
{
	static int b[40005];
	int len = 1; 
	while (len < n + m - 1)
		len <<= 1; 
	memcpy(b, B, m << 2);
	memset(b + m, 0, len - m << 2);
	memset(a + n, 0, len - n << 2);
	poly_ntt(a, len, false); 
	poly_ntt(b, len, false); 
	for (int i = 0; i < len; i++)
		a[i] = (ll)a[i] * b[i] % MOD; 
	poly_ntt(a, len, true); 
}
ll fact[10005], inv[10005];
int dp[40005], f[40005];
char s[10005], t[10005];
int main()
{
	// freopen("AGC019-E.in", "r", stdin);
	fact[0] = inv[0] = 1;
	for (int i = 1; i <= 10000; i++)
	{
		fact[i] = fact[i - 1] * i % MOD;
		inv[i] = quick_pow(fact[i], MOD - 2);
	}
	scanf("%s%s", s, t);
	int n = 0, m = 0;
	for (int i = 0; s[i]; i++)
	{
		n += s[i] == '1' && t[i] == '0';
		m += s[i] == '1' && t[i] == '1';
	}
	for (int i = 0; i <= m; i++)
		f[i] = inv[i + 1];
	dp[0] = 1;
	for (int i = 0; i < 20; i++)
	{
		if (n & (1 << i))
			poly_mul(dp, f, m + 1, m + 1);
		poly_mul(f, f, m + 1, m + 1);
	}
	ll ans = 0;
	for (int i = 0; i <= m; i++)
		(ans += dp[i]) %= MOD;
	printf("%lld\n", ans * fact[n] % MOD * fact[m] % MOD * fact[n + m] % MOD);
	return 0;
}


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

main () {
  int n;
  scanf("%d", &n);

  vector<int> a(n);
  rep(i,n) scanf("%d", &a[i]);

  //最大値とそれを除いた中で最大値の1/2に最も近い値の組み合わせが答え
  auto ptr_max = max_element(a.begin(), a.end());
  int max_ = *ptr_max;
  a.erase(ptr_max);
  int near_half_max = *min_element(a.begin(), a.end(), [max_](const int& a, const int&b){
    return abs(a-max_/2) < abs(b-max_/2);
  });

  printf("%d %d\n", max_, near_half_max);

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,n,s) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define rall(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;
int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{
  cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;
}
void printpair(vector<pair<ll, ll>> vp)
{
  cout<<'['<<endl;
  rep(i,0,vp.size())
  {
    pair<ll, ll> p=vp[i];
    cout<<'{'<<p.first<<','<<p.second<<'}'<<endl;
  }
  cout<<'}'<<endl;
}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
const long long INF = 1e12;
//------------------------------------------------------------
struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

ll N,M;
void solve()
{
    cin >> N>>M;

    vector<ll> P(N);
    rep(i,0,N) cin >> P[i];

    UnionFind UF(N);

    rep(i,0,M)
    {
      int x,y;
      cin>>x>>y;
      --x;--y;

      UF.unite(x,y);
    }

    ll count = 0;
    rep(i,0,N)
    {
      if(UF.same(i,P[i]-1)) count++;
    }

    print(count);

    return;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
#ifdef IS_MY_ENV
#include <tourist>
#endif
using namespace std;

#define int long long

signed main() {

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int l = c / __gcd(c, d) * d;

    a--;
    int q = a - a/c - a/d + a/l;
    int w = b - b/c - b/d + b/l;

    cout << w - q << endl;

    return 0;
}

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

using namespace std;

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

int main(){
    ll n;
    cin >> n;
    int a[200005];
    bool b[200005];
    for(ll i = 0; i < n; i++)cin >> a[i];
    ll ans = 0;
    for(ll i = n-1; i>=0; i--){
        ll j = i;
        ll num = 0;
        while(j <= n-1){
            if(b[j])num++;
            j+=i+1;
        }
        if(num%2!=a[i])b[i]=true, ans++;
    }
    cout << ans << endl;
    for(ll i = 0; i < n; i++)if(b[i])cout << i+1 << endl;
    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxm=2e5+5;
const int mod=1e9+7;
vector<int>g[maxm];
int mul[maxm];
int sz[maxm];
int n;
int ppow(int a,int b,int mod){
	int ans=1%mod;a%=mod;
	while(b){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
void dfs1(int x,int fa){
    sz[x]=1;
    for(int v:g[x]){
        if(v==fa)continue;
        dfs1(v,x);
        sz[x]+=sz[v];
        mul[x]=mul[x]*mul[v]%mod;
    }
    mul[x]=mul[x]*sz[x]%mod;
}
void dfs2(int x,int fa){
    for(int v:g[x]){
        if(v==fa)continue;
        //mul[x]是正确的
        int pre=mul[x]*ppow(n,mod-2,mod)%mod*ppow(mul[v],mod-2,mod)%mod*(n-sz[v])%mod;
        mul[v]=mul[v]*ppow(sz[v],mod-2,mod)%mod*pre%mod*n%mod;
        dfs2(v,x);
    }
}
signed main(){
    cin>>n;
    for(int i=1;i<n;i++){
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i=1;i<=n;i++)mul[i]=1;
    dfs1(1,-1);
    dfs2(1,-1);
    int nn=1;
    for(int i=1;i<=n;i++){//计算阶乘
        nn=nn*i%mod;
    }
    for(int i=1;i<=n;i++){
        cout<<nn*ppow(mul[i],mod-2,mod)%mod<<endl;
    }
    return 0;
}

Measured memory_bytes: 17792
#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
    int input[5];
    int biggest_loss_time = 10;
    int biggest_loss_dish = 0;
    for (int ii=0; ii<5; ii++) {
        cin >> input[ii];
        int loss_tmp = (input[ii] % 10);
        if (loss_tmp < biggest_loss_time
         && loss_tmp > 0) {
          biggest_loss_dish = ii;
          biggest_loss_time = loss_tmp;
        }
    }
    
    int total_time = 0;
    for (int ii = 0; ii <5; ii++) {
        if (ii != biggest_loss_dish
        && (input[ii] % 10) > 0) {
          input[ii] = (input[ii]/10)*10 + 10;
        }
        total_time += input[ii];
    }
    
    printf("%d", total_time);
    return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
assert len(S) == N

AC = [S[i : i + 2] == 'AC' for i in range(len(S) - 1)]

nAC = [0]  # nAC[i] == the number of 'AC' whose head 'A' is in S[:i]
for i in range(len(AC)):
    nAC.append(nAC[-1] + (1 if AC[i] else 0))

def solve(l, r):
    return nAC[r - 1] - nAC[l - 1]

for i in range(Q):
    l, r = map(int, input().split())
    print(solve(l, r))


Measured memory_bytes: 8556
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) {
		FastReader scan = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		Task solver = new Task();
		int t = 1;
		while(t-->0) solver.solve(1, scan, out);
		out.close();
	}
	
	static class Task {
		static long mod = (long) (1e9+7);
		public void solve(int testNumber, FastReader scan, PrintWriter out) {
			int n = scan.nextInt();
			long k = scan.nextLong(), kk = k*(k-1)/2, t = 0;
			long[] a = new long[n];
			for(int i = 0; i < n; i++) a[i] = scan.nextLong();
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < n; j++) {
					if(a[j] > a[i]) {
						if(j <= i) t += k;
						t += kk;
						t %= mod;
					}
				}
			}
			out.println(t);
		}
	}
	
	static void shuffle(int[] a) {
		Random get = new Random();
		for(int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			int temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
	
	static void shuffle(long[] a) {
		Random get = new Random();
		for(int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			long temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
	

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public FastReader(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}


Measured memory_bytes: 22996
#include <iostream>
#include <string>
using namespace std;
int MOD = 1000000007;

int main() {
	int n;
	string s1, s2;
	cin >> n >> s1 >> s2;
	long long ans = 3;
	bool bv = false;
	for (int i = 0; i < n; i++) {
		if (s1[i] == s2[i]) {
			if (i) {
				if (bv) ans = (ans * 2) % MOD;
			}
			else ans = 3;
			bv = true;
		}
		else {
			if (i) {
				if (bv) ans = (ans * 2) % MOD;
				else ans = (ans * 3) % MOD;
			}
			else ans = 6;
			i++;
			bv = false;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from fractions import gcd
import bisect
 
stdin = sys.stdin
 
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()
s = [ns() for _ in range(n)]
m = ni()
t = [ns() for _ in range(m)]
ans = 0
for word in set(s):
        point = s.count(word) - t.count(word)
        ans = max(point, ans)

print(ans)

Measured memory_bytes: 5204
n = int(input())
t, a = map(int, input().split())
H = list(map(int, input().split()))

#print(H)
#H2 = list(map(lambda h: t - h*0.006, H))
#print(H2)
min_ = 100000000
min_i = -1
for i, h in enumerate(H):
    diff = abs(a-(t-h*0.006))
    if diff < min_:
        min_ = diff
        min_i = i + 1
print(min_i)

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

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

int MOD=1e9+7;
ll INF=1e18;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int main(){
    int n; cin>>n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];

    int ans=0, i=0;
    while(i<n){
        if(i==n-1){
            ans++;
            break;
        }

        if(a[i]==a[i+1]){
            i++;
            continue;
        }

        while(a[i]<=a[i+1] && i<n-1){
            i++;
            if(a[i]>a[i+1]){
                i++;
                ans++;
                goto END;
            }
        }

        while(a[i]>=a[i+1] && i<n-1){
            i++;
            if(a[i]<a[i+1]){
                i++;
                ans++;
                break;
            }
        }
        END:;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int x,i;
  char ch[1000];
  while(1){
    scanf("%s",ch);
    x=0;
    if(ch[0]=='0')break;
    for(i=0;ch[i]!='\0';i++){
      x+=ch[i]-'0';
    }   
    printf("%d\n",x);
  }
  return 0; 
}




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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  = 3.141592653589793238463;
const int N = 1e5+10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}


// Main Code

string ansConv ="";
void convert10tob(ll N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(abs(x));
     return;
}

int main()
{
	int n;
	cin>>n;
	convert10tob(n, -2);
	if(ansConv == "") ansConv += to_string(0);
	cout<<ansConv<<endl;
}


Measured memory_bytes: 256
import java.util.*;



public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    
    for(int i = 1; i <= n; i++){
      int ans = 0;
      for(int x = 1; x*x + x < i; x++){
        for(int y = 1; y <= x; y++){
          for(int z = 1; z <= y; z++){
            if(x*x + y*y + z*z + x*y + y*z + z*x == i){
              if(x == y && y == z){
                ans++;
              }else if(x==y || y == z){
                ans += 3;
              }else{
                ans += 6;
              }
            }
          }
        }
      }


      System.out.println(ans);
    }

   
    
    scanner.close();
    return;
  }
  
}


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

int dp[50];

int fibonacci(int n){
  if(n == 0 || n == 1){
    dp[n] = 1;
    return dp[n];
  }
  if(dp[n] != -1){
    return dp[n];
  }
  return dp[n] = fibonacci(n-1) + fibonacci(n-2);
}

int main(void){
  int n; cin >> n;
  rep(i,50) dp[i] = -1;
  cout << fibonacci(n) << endl;
  return 0;
}



Measured memory_bytes: 3104
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 H = sc.nextInt();
        int M = sc.nextInt();
        double angH = 30 * H;
        double angM =  5.5 * M;
        double red = Math.toRadians(Math.abs(angH-angM));
        double res = 0;
        res = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(red));
        System.out.println(res);
    }
}

Measured memory_bytes: 35968
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let s = input::<String>();
    let mut ans = 0;
    let mut cnt = 0;
    for c in s.chars() {
        if c == 'A' || c == 'C' || c == 'G' || c == 'T' {
            cnt += 1;
            ans = std::cmp::max(ans, cnt);
        } else {
            cnt = 0;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
a = [c for c in input()][::-1]
b = [c for c in input()][::-1]
c = [c for c in input()][::-1]

def func(p):
    if p == "a": cur = a
    if p == "b": cur = b
    if p == "c": cur = c

    if not cur:
        return p

    new = cur.pop()
    return func(new)

print(func("a").upper())


Measured memory_bytes: 3188
import sys
import os
import math
import bisect
import collections
import itertools
import heapq
import re

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    print('YES' if re.match('^(dream|dreamer|erase|eraser)+$', S) else 'NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 7036
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    try (Scanner scanner = new Scanner(System.in)) {
      int m, f, r;
      while (true) {
        m = scanner.nextInt();
        f = scanner.nextInt();
        r = scanner.nextInt();
        if (m == -1 && f == -1 && r == -1) {
          return;
        }
        System.out.println(new Score(m, f, r).score());
      }
    }
  }
}

class Score {
  private final int midtermExam;
  private final int finalExam;
  private final int reExam;


  Score(int midtermExam, int finalExam, int reExam) {
    this.midtermExam = midtermExam;
    this.finalExam = finalExam;
    this.reExam = reExam;
  }

  private int sumExamScore() {
    return midtermExam + finalExam;
  }

  String score() {
    if (midtermExam == -1 || finalExam == -1) {
      return "F";
    }
    if (sumExamScore() >= 80) {
      return "A";
    }
    if (sumExamScore() >= 65) {
      return "B";
    }
    if (sumExamScore() >= 50) {
      return "C";
    }
    if (sumExamScore() >= 30) {
      if (reExam >= 50) {
        return "C";
      } else {
        return "D";
      }
    }
    return "F";
  }
}

Measured memory_bytes: 26292
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  map<lint,lint> m;
  REP(i,N){
    int A;
    cin>>A;
    m[A]++;
  }
  lint ans=0;
  for(auto e:m){
    ans+=e.first*e.second;
  }
  int Q;
  cin>>Q;
  REP(i,Q){
    int B,C;
    cin>>B>>C;
    m[C]+=m[B];
    ans+=(C-B)*m[B];
    m[B]=0;
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 9420
import copy

n = int(input())
t = list(map(int,input().split()))
m = int(input())

l = []

for i in range(m):
    p,x = map(int,input().split())
    l = copy.copy(t)
    l[p-1] = x
#    print(t)
#    print(l)
    print(sum(l))


Measured memory_bytes: 3444
#include <iostream>

using namespace std;

long long N, A, B, ans = 0, m = 0, M = 0;

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

	if (A <= B && !(N == 1 && A != B)){
		m = A*(N - 1) + B;
		M = A + B*(N - 1);

		ans = M - m + 1;
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

#define IOS ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);

#define endl "\n";


#define mod 1000000007
#define loop(i,s,n)  for(ll i=s;i<n;i++)
#define test  ll t; cin>>t; while(t--)
#define p push_back
typedef long long ll;
string longDivision(string number,ll divisor) 
{ 
    // As result can be very large store it in string 
    string ans; 
  
    // Find prefix of number that is larger 
    // than divisor. 
    int idx = 0; 
    int temp = number[idx] - '0'; 
    while (temp < divisor) 
        temp = temp * 10 + (number[++idx] - '0'); 
  
    // Repeatedly divide divisor with temp. After 
    // every division, update temp to include one 
    // more digit. 
    while (number.size() > idx) { 
        // Store result in answer i.e. temp / divisor 
        ans += (temp / divisor) + '0'; 
  
        // Take next digit of number 
        temp = (temp % divisor) * 10 + number[++idx] - '0'; 
    } 
  
  
        
  
       return ans; 
} 
int main()
{IOS

ll n,k,i=0,j=0,f=0;
double count;
cin>>n;
ll divisor=n;
string s="7"
;
if(n==1||n==7)
{cout<<1;}
else{
for(i=2;i<=n;i++)
{s=s+'7';

j=atoi( s.c_str() );
if(j%n==0)
{cout<<i;
f=1;
break;}
else{j=j%n;
s=to_string(j);
}
}
	if(f==0)
	{cout<<-1;}
}
return 0;
}


Measured memory_bytes: 3708
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	bool flag = false;
	while (1) {
		
		int H, W;
		cin >> H;
		if (!H)break;
		cin >> W;
		if (!flag) {
			flag = true;
		}
		else {
			cout << endl;
		}
		vector<int>rs(H+1), cs(W+1);
		int unknown = 0;
		map<pair<int, int>, int>mp;
		vector<vector<int>>field(H + 1, vector<int>(W + 1));
		for (int i = 0; i < H + 1; ++i) {
			for (int j = 0; j < W + 1; ++j) {
				string st; cin >> st;
				int num;
				if (st == "?") {
					num = 1e8;
					mp[make_pair(i, j)] = unknown++;
					rs[i]++;
					cs[j]++;
				}
				else num = stoi(st);
				field[i][j] = num;
			}
		}
		queue<pair<int, int>>que;
		for (int y = 0; y <= H; ++y) {
			if (rs[y] == 1) {
				que.push(make_pair(1, y));
			}
		}
		for (int x = 0; x <= W; ++x) {
			if (cs[x] == 1) {
				que.push(make_pair(0, x));
			}
		}
		while (!que.empty()) {
			auto p(que.front());
			que.pop();
			if (p.first) {
				const int y = p.second;
				if (rs[y] == 1) {
					int sum = 0;
					int place = -1;
					for (int i = 0; i <= W; ++i) {
						if (field[y][i] != 1e8) {
							sum += i!=W?field[y][i]:-field[y][i];
						}
						else {
							place = i;
						}
					}
					if (place != W) {
						field[y][place] = -sum;
					}
					else {
						field[y][place] = sum;
					}
					rs[y]--;
					cs[place]--;
					if (cs[place] == 1) {
						que.push(make_pair(0, place));
					}
					
				}
			}
			else {
				const int x = p.second;
				if (cs[x] == 1) {
					int sum = 0;
					int place = -1;
					for (int i = 0; i <= H; ++i) {
						if (field[i][x] != 1e8) {
							sum += i != H ? field[i][x] : -field[i][x];
						}
						else {
							place = i;
						}
					}
					if (place != H) {
						field[place][x] = -sum;
					}
					else {
						field[place][x] = sum;
					}
					cs[x]--;
					rs[place]--;
					if (rs[place] == 1) {
						que.push(make_pair(1, place));
					}
					
				}
			}
		}
		bool ok = true;
		for (int i = 0; i <= H; ++i) {
			int sum = 0;
			for (int j = 0; j < W; ++j) {
				sum += field[i][j];
			}
			if (sum != field[i][W])ok = false;
		}
		for (int i = 0; i <= W; ++i) {
			int sum = 0;
			for (int j = 0; j < H; ++j)sum += field[j][i];
			if (sum != field[H][i])ok = false;
		}
		if (!ok)cout << "NO" << endl;
		else {
			for (auto m : mp) {
				cout << field[m.first.first][m.first.second] << endl;
			}
		}
	}
	return 0;
}

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

using namespace std;

void insertion_sort(int N, vector<int> &A){

  for(int k = 0; k < N; k++){
    cout << A.at(k);
    if(k == N-1){
      cout << endl;
    }
    else{
      cout << " ";
    }
  }

  for (int i = 1; i < N; i++){
    int v = A.at(i);
    int j = i - 1;
    while ((j >= 0) && (A.at(j) > v)){
      A.at(j+1) = A.at(j);
      j--;
    }
    A.at(j+1) = v;

    for(int k = 0; k < N; k++){
      cout << A.at(k);
      if(k == N-1){
        cout << endl;
      }
      else{
        cout << " ";
      }
    }
  }
}

int main(){
  int N; //要素数
  cin >> N;

  vector<int> A(N);//数列要素

  //数列に入力
  for(int &a: A){
    cin >> a;
  }

  insertion_sort(N, A);

}



Measured memory_bytes: 3108
#include <stdio.h>
int main(void)
{
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	int sum=a+b;
	int cha=a-b;
	int mul=a*b;
	printf("%d",mul>(sum>cha?sum:cha)?mul:(sum>cha?sum:cha));
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.ABC_115
{
    class A
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int d = ReadInt();
            if (d == 25)
            {
                Console.WriteLine("Christmas");
            }
            else if (d == 24)
            {
                Console.WriteLine("Christmas Eve");
            }
            else if (d == 23)
            {
                Console.WriteLine("Christmas Eve Eve");

            }
            else if (d == 22)
            {
                Console.WriteLine("Christmas Eve Eve Eve");

            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )
import Data.List

cReadLn :: IO Int
cReadLn = fst . fromJust . C.readInt <$> C.getLine

getParms :: IO [Int]
getParms = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [n,k] <- getParms
  as    <- getParms
  print $ f n k as

f :: Int -> Int -> [Int] -> Int
f n k as 
  | k >= l = 0
  | k <  l = g as'' (l-k) 0
  where
    as'  = group . sort $ as
    l    = length as'
    as'' = sortOn length as'

    g :: [[Int]] -> Int -> Int -> Int
    g _      0 x = x
    g (b:bs) k x = g bs (k-1) (x + length b)


Measured memory_bytes: 44412
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define FASTIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define inf 1e18
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mod 1000000007
#define pb push_back
#define all(s) s.begin(),s.end()
#define pie 3.14159265358979323846
#define fr(i,a,b)  for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=b-1;i>=a;i--)
#define gcd __gcd
#define con continue
#define pii pair<ll,ll>
const ll N=3e5+5;
ll x[N],y[N],cntx[N],cnty[N];
map<ll,bool>mm[N];
signed main(){
    FASTIO;
    ll tt=1;
    //cin>>tt;
    while(tt--){
         string s;cin>>s;
         ll ans=0,fans=0;
         for(auto x:s){
            if(x=='R')ans++;
            else ans=0;
            fans=max(fans,ans);
         }
         cout<<fans<<"\n";
    }
}


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

#define EPS (1e-7)
#define INF (1e16)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll dp[100005][305];
int main() {
    //cout.precision(10);
    ll n, m, k;
    cin >> n >> m >> k;
    ll a[100005];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        dp[i][1] = a[i];
    }
    for(int time = 2; time <= k; time++){
        dp[1][time] = -INF;
        list<int> l;
        for(ll index = 2; index <= n; index++){
            while(!l.empty()){
                if(dp[l.back()][time-1] <= dp[index - 1][time-1]){
                    l.pop_back();
                } else {
                    break;
                }
            }
            l.push_back(index - 1);
            dp[index][time] = dp[l.front()][time - 1] + time * a[index];
            if(l.front() == (index - m)){
                l.pop_front();
            }
        }
        /*cout << time << endl;
        for(int i = 1; i <= n; i++){
            cout << dp[i][time] << endl;
        }
        cout << endl;*/
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        ans = max(ans, dp[i][k]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 239488
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;

int main() {
    char ch;
    while(true) {
        scanf("%c", &ch);
        if('a' <= ch && ch <= 'z') {
            ch = ch-'a'+'A';
        }
        else if('A' <= ch && ch <= 'Z'){
            ch = ch-'A'+'a';
        }
        cout << ch;
        if(ch=='\n') {
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3096
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("Heisei")
    else:print("TBD")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())


#n = ip()                              #入力整数1つ
n,k= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
#n,a,b,c= (int(i) for i in input().split())  #入力整数横4つ
a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
a.sort(reverse=1)
print(sum(a[:k]))

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

int main(){
    int m,f,r;
    cin >> m >> f >> r;

    while (1){

        if (m==-1&&f==-1&&r==-1) {
            break;
        }
        else {
            
            if (m==-1||f==-1){
                cout << "F" << endl;
            }else if (m+f>=80) {
                cout << "A" <<endl;
            }else if (m+f >= 65 && m+f < 80) {
                cout << "B" << endl;
            }else if (m+f >= 50 && m+f < 65) {
                cout << "C" << endl;
            }else if (m+f >= 30 && m+f < 50) {
                if (r >= 50){
                    cout << "C" <<endl;
                }else {
                    cout << "D" <<endl;
                }
            }else if (m+f <30){
                cout << "F" <<endl;
            }
            cin >> m >> f >> r;

        }
    }
    return 0;
}


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

template <class V, class F>
int lower_bound(int i0, int i1, V v, F f) {
    while (i0 != i1) {
        int i = (i0 + i1) / 2;
        if (f(i) < v) {
            i0 = i + 1;
        } else {
            i1 = i;
        }
    }
    return i0;
}

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

    vector<int> a[2];
    for (int g = 0; g < 2; g++) {
        a[g].resize(n);
    }
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[0][i]);
    }
    sort(a[0].begin(), a[0].end());
    for (int i = 0; i < n; i++) {
        a[1][n - i - 1] = a[0][i];
    }

    // 最初のj個を使ったときに和をiにできるか
    vector<char[5000]> dp[2];
    for (int g = 0; g < 2; g++) {
        dp[g] = vector<char[5000]>(n);
        dp[g][0][0] = 1;
        for (int j = 0; j < n - 1; j++) {
            memcpy(dp[g][j + 1], dp[g][j], sizeof dp[g][0]);
            for (int i = k - a[g][j] - 1; i >= 0; i--) {
                if (dp[g][j][i]) dp[g][j + 1][i + a[g][j]] = 1;
            }
        }
    }

    int r = lower_bound(0, n, 1, [&](int j) {
        int t = k; // どこまでチェックしたか
        for (int i = 0; i < k; i++) {
            if (!dp[0][j][i]) continue;
            int h0 = max(k - i - a[0][j], 0);
            int h1 = min(k - i, t);
            t = min(t, h0);
            for (int h = h0; h < h1; h++) {
                if (dp[1][n - j - 1][h]) return 1;
            }
        }
        return 0;
    });
    cout << r << endl;

    return 0;
}


Measured memory_bytes: 49280
#include<bits/stdc++.h>
using namespace std;
int n, m, a, b, c, t;
typedef vector<vector<int> > matrix;

matrix multi(matrix a, matrix b){
  matrix res;
  res.resize(a.size());
  for (int i = 0; i < a.size(); i++) {
    res[i].resize(a[i].size(), 0);
    for (int j = 0; j < a[i].size(); j++) {
      for (int k = 0; k < a[i].size(); k++) {
        res[i][j] += a[i][k] * b[k][j];
        res[i][j] %= m;
      }
    }
  }
  return res;
}

void func(int t, matrix& mat){
  if(t < 0){
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if(i == j)mat[i][j] = 1;
        else mat[i][j] = 0;
      }
    }
    return; 
  }
  int cnt = 1, size = 0;
  while(t > 2*cnt)cnt *= 2, size++;
  vector<matrix> doubling(size + 1);
  for (int i = 0; i <= size; i++) {
    doubling[i].resize(n);
    for (int j = 0; j < n; j++) {
      doubling[i][j].resize(n, 0);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      doubling[0][i][j] = mat[i][j];
    }
  }
  for (int i = 1; i <= size; i++) {
    doubling[i] = multi(doubling[i - 1], doubling[i - 1]);
  }

  while(t != 0){
    while(t < cnt){
      cnt /= 2;
      size--;
    }
    mat = multi(mat, doubling[size]);
    t -= cnt;
  }

  // for (int i = 0; i < doubling.size(); i++) {
  //   std::cout << "doubling:" << i << std::endl;
  //   for (int j = 0; j < n; j++) {
  //     for (int k = 0; k < n; k++) {
  //       std::cout << doubling[i][j][k] << " ";
  //     }
  //     std::cout  << std::endl;
  //   }
  // }
}

int calc(int i, vector<int> &s, matrix& mat){
  int res = 0;
  for (int j = 0; j < n; j++) {
    res += s[j] * mat[j][i];
    res %= m;
  }
  return res;
}

int main(int argc, char *argv[]){
  while(cin >> n >> m >> a >> b >> c >> t, n){
    vector<int> s(n);
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    matrix mat(n, vector<int>(n, 0));
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if(i  == j){
          mat[max(0, j - 1)][i] = a;
          mat[min(n - 1, j + 1)][i] = c;
          mat[j][i] = b;
          continue;
        }
      }
    }
    func(t-1, mat);
    // for (int i = 0; i < n; i++) {
    //   for (int j = 0; j < n; j++) {
    //     std::cout << mat[i][j] << " ";
    //   }
    //   std::cout << std::endl;
    // }
    for (int i = 0; i < n - 1; i++) {
      std::cout << calc(i, s, mat)%m << " ";
    }
    std::cout << calc(n - 1, s, mat)%m << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1572
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <tuple>
#include <stdbool.h>
#include <bitset>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>
#include <bitset>

namespace mp = boost::multiprecision;
using namespace std;

int main(void) {
    string s;
    cin >> s;
    
    int a = 0;
    int b = 0;
    for(int i = 0 ; i < s.length() ; ++i) {
        if(s[i] == '0') {
            if(i & 0x1) { ++a; }
            else { ++b; }
        } else {
            if(i & 0x1) { ++b; }
            else { ++a; }
        }
    }
    auto ans = min(a, b);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

string S[100010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    map<string, int> mp;
    
    rep(i, N) {
        cin >> S[i];
        sort(S[i].begin(), S[i].end());
        mp[S[i]]++;
    }
    ll ans = 0;
    rep(i, N) {
        ans += (mp[S[i]] - 1);
        mp[S[i]]--;
    }
    cout << ans << endl;

    return 0;
}


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

public class Main {
    BufferedReader rd;

    Main() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        out("ABC"+rd.readLine());
    }

    private static void out(Object x) {
        System.out.println(x);
    }

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


Measured memory_bytes: 21076
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int N = 3e5+7 ;
const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;

int getLis(vi& a){
	int n = sz(a) ;
	vi dp(n+1,INF) ;
	for(int i = 0 ; i < n ; i++){
		auto it = upper_bound(all(dp),a[i])-dp.begin() ;
		dp[it] = a[i] ;
	}
	return lower_bound(all(dp),INF)-dp.begin() ;
}

void solve(){
	int n ;
	cin >> n ;
	vi a(n) ;
	for(auto& x : a) cin >> x ;
	reverse(all(a)) ;
	cout << getLis(a) ;
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 2048
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
tmp = -1000
ans = 0
for i in range(n):
    j = a[i] - 1
    if tmp + 1 == j:
        ans += b[j] + c[tmp]
    else:
        ans += b[j]
    tmp = j
print(ans)

Measured memory_bytes: 3064
l = list(map(lambda x:int(x), input().split(" ")))
a = l[0]
b = l[1]
c = l[2]
k = l[3]
if a >= k:
    print(k)
elif a < k:
    if b >= k-a:
        print(a)
    elif b < k-a:
        print(a-(k-a-b))


Measured memory_bytes: 61780
fun main(args: Array<String>){

    var N = readLine()!!.toInt()
    var S = readLine()!!
    var ans = 0

    for(i in 0..9){
        for(j in 0..9){
            for(k in 0..9){
                var iPos = S.indexOf(i.toString())
                if(iPos != -1){
                    var jPos = S.indexOf(j.toString(),iPos+1)
                    if(jPos != -1){
                        if(S.indexOf(k.toString(),jPos+1) != -1){
                            ans++
                        }
                    }

                }


            }
        }
    }

    print(ans)


}


Measured memory_bytes: 37836
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.function.Function;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());

      Function<String,double[]> lineSpliteThenArray =
        s -> Stream.of(s.split(" "))
          .mapToDouble(Double::parseDouble)
          .toArray();

      double[][] vecter =
        br.lines()
          .limit(2)
          .map( lineSpliteThenArray )
          .toArray(double[][]::new);

      double p1 =
        IntStream.range(0, n)
          .parallel()
          .mapToDouble(i -> Math.abs(vecter[0][i] - vecter[1][i]) )
          .sum();

      double p2 = Math.sqrt(
        IntStream.range(0, n)
          .parallel()
          .mapToDouble(i -> Math.pow( vecter[0][i] - vecter[1][i], 2))
          .sum() );

      double p3 = Math.pow(
        IntStream.range(0, n)
        .parallel()
        .mapToDouble(i -> Math.pow( Math.abs(vecter[0][i] - vecter[1][i]), 3d))
        .sum() , 1d/3d );

      double p00 =
        IntStream.range(0, n)
          .parallel()
          .mapToDouble(i -> Math.abs(vecter[0][i] - vecter[1][i]))
          .max()
          .getAsDouble();

      System.out.printf("%.8f\n%.8f\n%.8f\n%.8f\n", p1,p2,p3,p00);
    }
  }

}


Measured memory_bytes: 33268
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> p;
typedef long long ll;
const int inf = 1000000007;

int main() {
  string s;
  cin >> s;
  vector<int> a(s.size() + 1);
  rep(i, s.size()) {
    if (s[i] == '<') {
      a[i + 1] = a[i] + 1;
    }
  }
  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] == '>') {
      a[i] = max(a[i], a[i + 1] + 1);
    }
  }
  ll ans = 0;
  rep(i, s.size() + 1) ans += a[i];
  cout << ans << endl;
  return 0;
}

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

int main(){
    int n;
  while(cin >> n){
    int arr[n+1],arr2[n+1];
    for( int i = 0; i < n; i++ ){
      cin >> arr[i];
    }
    for( int i = 0; i < n; i++ ){
      cin >> arr2[i];
    }
    int sum = 0;
    for( int i = 0; i < n; i++ ){
      if( arr[i] > arr2[i] ){
        sum += (arr[i]-arr2[i]);
      }
    }
    cout << sum << endl;
  }
}


Measured memory_bytes: 256
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

struct Mod {
    static uint64_t PRIME;
    uint64_t value = 0;
    Mod() : value(0) {}
    Mod(ll v) {
        if (v >= 0) {
            value = v % PRIME;
        } else {
            value = PRIME - (-v) % PRIME;
        }
    }
    Mod operator+(const Mod& rhs) const {
        return Mod(*this) += rhs;
    }
    Mod& operator+=(const Mod& rhs) {
        value += rhs.value;
        if (value >= PRIME) {
            value -= PRIME;
        }
        return *this;
    }
    Mod operator-(const Mod& rhs) const {
        return Mod(*this) -= rhs;
    }
    Mod& operator-=(const Mod& rhs) {
        if (value < rhs.value) {
            value += PRIME;
        }
        value -= rhs.value;
        return *this;
    }
    Mod operator*(const Mod& rhs) const {
        return Mod(*this) *= rhs;
    }
    Mod& operator*=(const Mod& rhs) {
        value = (value * rhs.value) % PRIME;
        return *this;
    }
    Mod inv() const {
        return power(*this, PRIME - 2);
    }
    Mod operator/(const Mod& rhs) const {
        return Mod(*this) /= rhs;
    }
    Mod& operator/=(const Mod& rhs) {
        *this *= rhs.inv();
        return *this;
    }
    static Mod power(Mod rhs, ll exp) {
        Mod ans = 1;
        while (exp > 0) {
            if (exp % 2) {
                ans *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return ans;
    }
};
uint64_t Mod::PRIME = 1000000007;

Mod binom(ll n, ll r) {
    Mod ans = 1;
    rep(i,0,r) {
        ans *= (n-i);
        ans /= (r-i);
    }
    return ans;
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    Mod ans = 0;
    ans += Mod::power(2, n);
    ans -= binom(n, a);
    ans -= binom(n, b);
    ans -= 1;
    cout << ans.value << endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int N = 100010;

int n, m;
char s[N], t[N];
int sums[N], sumt[N];

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  cin >> (s + 1) >> (t + 1);
  n = strlen(s + 1);
  m = strlen(t + 1);
  for (int i = 1; i <= n; ++i)
    sums[i] = (sums[i - 1] + (s[i] - 'A' + 1)) % 3;
  for (int i = 1; i <= n; ++i)
    sumt[i] = (sumt[i - 1] + (t[i] - 'A' + 1)) % 3;
  int q;
  cin >> q;
  while (q--) {
    int sl, sr, tl, tr;
    cin >> sl >> sr >> tl >> tr;
    cout << ((sums[sr] - sums[sl - 1] - (sumt[tr] - sumt[tl - 1])) % 3 == 0 ? "YES\n" : "NO\n");
  }

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 1536
N , M = map(int , input().split(" "))

solve_problem = [0] * N 
wa = [0] * N
ans = 0

for i in range(0,M):
    ps = input().split(" ")
    if ps[1] == "AC":
        if solve_problem[ int(ps[0]) -1] == 0:
            solve_problem[int(ps[0]) -1] = 1
            ans += 1
    elif ps[1] == "WA":
        if solve_problem[ int(ps[0])-1] == 0:
            wa[int(ps[0]) -1 ] += 1

print(ans,sum(wa[i] for i in range(0,N) if solve_problem[i] == 1))



Measured memory_bytes: 4596