akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
	int t[100] = {0}, r, c, s, S = 0, i, j, k;

	scanf("%d %d", &r, &c);
	for (i = 0; i < r; i++) {
		s = 0;
		for (j = 0; j < c; j++) {
			scanf("%d", &k);
			t[j] += k;
			s += k;
			S += k;
			printf(j == 0 ? "%d" : " %d", k);
			if (j + 1 == c) printf(" %d\n", s);
		}
	}
	
	for (i = 0; i < c; i++) {
		printf(i == 0 ? "%d" : " %d", t[i]);
	}
	printf(" %d\n", S);

	return 0;
}



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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

int n, W;
vector<int> w, v;
int dp[110][100100];

signed main()
{
    cin >> n >> W;
    w = v = vector<int>(n);
    rep(i, n)
    {
        cin >> w[i] >> v[i];
    }

    // dp[i][sum] i番目まで調べて重さsum1まで選んだ時の最大値
    rep(i, n)
    {
        for (int sum_w = 0; sum_w <= W; sum_w++)
        {

            if (sum_w - w[i] >= 0)
            {
                chmax(dp[i + 1][sum_w], dp[i][sum_w - w[i]] + v[i]);
            }
            chmax(dp[i + 1][sum_w], dp[i][sum_w]);
        }
    }

    print(dp[n][W]);
}


Measured memory_bytes: 79360
N = gets.to_i
ls, rs, ll, rr, ss = [], [], 0, 10**9 + 1, 0
readlines.map{|l| l.split.map(&:to_i)}.each do |l, r|
  r += 1
  s = r - l
  ls << l; rs << r
  ll = l if l > ll
  rr = r if r < rr
  ss = s if s > ss
end
nz = ->(a, b){a >= b ? a - b : 0}
ans = nz[rr, ll] + ss
ts = (0 ... N).map{|i| [nz[rs[i], ll], nz[rr, ls[i]]]}.sort_by{|a, b| a || -b}
_, bb = ts.shift
ts.each do |a, b|
  ans = a + bb if a + bb > ans
  bb = b if b < bb
end
puts ans

Measured memory_bytes: 24464
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
using namespace std;

typedef pair<string, int> P;

bool compare(P a,P b){
	return a.second == b.second ? a.first < b.first : a.second > b.second;
}

int main(){
	string str,tmp;
	int n;
	char initial;
	map<string,int> m;
	vector<P> much;
	while(cin >> n,n){
		m.clear();
		much.clear();
		getline(cin,str);
		for(int i = 0;i < n;++i){
			stringstream ss;
			getline(cin,str);
			ss << str;
			while(ss >> tmp){
				++m[tmp];
			}
		}
		cin >> initial;
		map<string,int>::iterator mit;
		for(mit = m.begin();mit != m.end();++mit){
			if((*mit).first[0] == initial){
				much.push_back(make_pair((*mit).first,(*mit).second));
			}
		}
		if(much.size() != 0){
			sort(much.begin(),much.end(),compare);
			for(int i = 0;i < much.size() && i < 5;++i){
				if(i) cout << " ";
				cout << much[i].first;
			}
			cout << endl;
		}
		else cout << "NA" << endl;
	}
	return 0;
}

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

const int MAX_N=1e5;

int N,A[MAX_N];

int main(){
	cin>>N;
	int mx=0,mn=N;
	REP(i,N){
		cin>>A[i];
		mx=max(mx,A[i]);
		mn=min(mn,A[i]);
	}
	bool flg;
	if (mx-mn>1){
		flg=false;
	}else if (mx==mn){
		if (A[0]==N-1 || A[0]<=N/2){
			flg=true;
		}else{
			flg=false;
		}
	}else{
		int n1=0,n2=0;
		REP(i,N){
			if (A[i]==mx){
				n1++;
			}else{
				n2++;
			}
		}
		if (mx-n2>0 && mx-n2<=n1/2){
			flg=true;
		}else{
			flg=false;
		}
	}
	cout<<(flg ? "Yes"  : "No")<<endl;
	return 0;
}


Measured memory_bytes: 640
import sys
import math

def main():
    def iterate_position():
        yield list(map(int, sys.stdin.readline().rstrip().split()))

    N = int(sys.stdin.readline().rstrip())
    now_position = [0, 0, 0]
    for x in range(N):
        try:
            next_position = next(iterate_position())
            dt = next_position[0] - now_position[0]
            dx = next_position[1] - now_position[1]
            dy = next_position[2] - now_position[2]
            if dt < abs(dx) + abs(dy):
                print("No")
                sys.exit()
            check = dt - (dx + dy)
            if check % 2 == 1:
                print("No")
                sys.exit()
            now_position = next_position
        except StopIteration:
            print("No")
    else:
        print("Yes")

if __name__ == '__main__':
    main()

Measured memory_bytes: 42348
#include<bits/stdc++.h>
using namespace std;
int L,N;
int main(){
  cin >> L >> N;
  int l=0,r=0;
  for(int i=0;i<N;i++){
    int x,w; cin >> x >> w;
    if( x < 0 ) {
      l += (-x)*w;
    } else if( x > 0 ){
      r += x*w;
    }
  }
  if( l < r ){
    cout << 1 << endl;
    cout << "-1 " << r-l << endl;
  } else if( l > r ){
    cout << 1 << endl;
    cout << "1 " << l-r << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 1168
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
struct ll
{
	int x,y;
	long long v;
}b[600000];
long long n,q,a[300000],t=0,f[300000];
int cmp(ll a,ll b)
{
	return a.v<b.v;
}
int find(int x)
{
	if (x==f[x])
	return x;
	return f[x]=find(f[x]);
}
void un(int x,int y)
{
	int fx=find(x),fy=find(y);
	f[fx]=fy;
}
void add(int x,int y,int v)
{
	b[++t].x=x;
	b[t].y=y;
	b[t].v=v;
}
int main()
{
    scanf("%d%d",&n,&q);
	int x,y;
	long long v;
	for (int i=0;i<=n;++i)
	a[i]=1e17;
	for (int i=1;i<=q;++i)
	{
		scanf("%d%d%lld",&x,&y,&v);
	    add(x,y,v);
	    a[x]=min(a[x],v+1);
		a[y]=min(a[y],v+2); 
	}	
	for (int i=1;i<=2;++i)
	for (int j=1;j<=n;++j)
	a[(j%n)]=min(a[(j%n)],a[j-1]+2);
	for (int i=0;i<n;++i)
	add(i,(i+1)%n,a[i]);
	sort(b+1,b+t+1,cmp);
	for (int i=0;i<n;++i)
	f[i]=i;
	long long ans=0;
	for (int i=1;i<=t;++i)
	if (find(b[i].x)!=find(b[i].y))
	{
		un(b[i].x,b[i].y);
		ans+=b[i].v;
		if (t==n-1)
		break;
	}
	printf("%lld\n",ans);
} 

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

using namespace std;

#define pb push_back

const int N = 2e5 + 5;
const long long inf = 1e18 + 123;
int n, h[N];
long long c, dp[N];

struct ConvexHull {
    vector<long long> A, B;
    int iA = 0;
    bool bad (int l1, int l2, int l3) { return (B[l3] - B[l1]) * (A[l1] - A[l2]) < (B[l2] - B[l1]) * (A[l1] - A[l3]); }
    void add (long long a, long long b) {
        A.pb(a); B.pb(b);
        while (A.size() >= 3 && bad(A.size() - 3, A.size() - 2, A.size() - 1) ) A.erase(A.end() - 2), B.erase(B.end() - 2);
    }
    long long val (int x, int id) { return A[id] * x + B[id]; }
    long long solve (int x) {
        iA = min(iA, (int)A.size() - 1);
        while (iA + 1 < A.size() ) {
            if (val(x, iA) <= val(x, iA + 1) ) break ;
            ++iA;
        }
        return val(x, iA);
    }
} convexHull;

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

    for (int i = 1; i <= n; ++i) scanf("%d", h + i);

    for (int i = 2; i <= n; ++i) {
        convexHull.add(-2 * h[i - 1], 1LL * h[i - 1] * h[i - 1] + dp[i - 1]);
        dp[i] = 1LL * h[i] * h[i] + c + convexHull.solve(h[i]);
    }

    cout << dp[n];

    return 0;
}


Measured memory_bytes: 6760
S = list(input())
flag = True
flag_t = False

if S[0] == "A":

    S_part = S[2:-1]
    # print(S_part)

    count = 0
    for i, str in enumerate(S_part):
        if str == "C":
            ind = i
            # print(i)
            count += 1

    if count == 1:
        # print(S)
        S.pop(0)
        S.pop(ind + 1)
        # print(S)

        for str in S:
            if not str.islower():
                flag = False

        if flag:
            print("AC")
            flag_t = True

if flag_t == False:
    print("WA")

Measured memory_bytes: 3064
#include <stdio.h>
#define min(a,b)((a)<=(b)?(a):(b))

int main() {
	int N, P[200000], a = 0, L = 0;
	scanf("%d", &N);
	while (a < N) {
		scanf("%d", &P[a]);
		a++;
	}
	int Min = P[0];
	for (int i = 0; i < N; i++) {
		L++;
		Min = min(Min,P[i]);
		if (P[i] > Min) {
			L--;
		}
	}
	printf("%d", L);
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
typedef long long ll;
using namespace std;

void samei() {
	int A, B,C;
	cin >> A >> B >> C;
	vector<int> v;
	v.push_back(A);
	v.push_back(B);
	v.push_back(C);
	sort(v.begin(), v.end());
	int oc = 0;
	for (size_t i = 0; i < 3; i++)
	{
		oc += (v[i] % 2 == 0);
	}
	int res = 0;
	if (oc == 1) {
		for (size_t i = 0; i < 3; i++)
		{
			if (v[i] % 2 != 0) {
				v[i]++;
			}
		}
		res++;
	}
	else if(oc == 2){
		for (size_t i = 0; i < 3; i++)
		{
			if (v[i] % 2 == 0) {
				v[i]++;
			}
		}
		res++;
	}
	res += ((v[2] - v[1]) + (v[2] - v[0])) / 2;

	cout << res << endl;
}
int main() {
	samei();
	return 0;
}

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

#define ALL(v) v.begin(), v.end()
typedef long long ll;



using namespace std;
int main() {
	string s, r;
	cin >> s >> r;
	int ans = 0;

	if (s[0] == r[0]) ans++;
	if (s[1] == r[1]) ans++;
	if (s[2] == r[2]) ans++;


	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,m;
  cin >> n >> m;
  
  long l;
  if (n >= 2 && m >= 2) {
    l = (n - 2) * (m - 2);
  } else {
    if (n == m) {
      l = 1;
    } else if (n == 1){
      l = m - 2;
    } else {
      l = n - 2;
    }
  }
  cout << l << endl;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define LL long long
#define pii pair<int,int>
#define SZ(x)  (int)x.size()
#define all(x) x.begin(),x.end()

using namespace std;

LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
LL lcm(LL a, LL b) {return a / gcd(a, b) * b;}
LL powmod(LL a, LL b, LL MOD) {LL ans = 1; while (b) {if (b % 2)ans = ans * a % MOD; a = a * a % MOD; b /= 2;} return ans;}
const int N = 5e5 + 3;
const LL mod = 1e9 + 7;
int n,k,q;
int a[N],b[N];
int main() {
	ios::sync_with_stdio(false);
    cin>>n>>k>>q;
    for(int i=1;i<=n;i++)a[i]=k;
    for(int i=1;i<=q;i++){
        int x;
        cin>>x;
        b[x]++;
    }
    for(int i=1;i<=n;i++){
        if(a[i]+b[i]-q>0)cout<<"Yes\n";
        else cout<<"No\n";
    }
	return 0;
}

Measured memory_bytes: 1408
n, a, b, c, d = map(int, input().split())
s = input()

if a > b and c > d or a < b and c < d:
  if s[a - 1:c].count('##') + s[b - 1:d].count('##') == 0:
    print('Yes')
  else:
    print('No')
else:
  i, j = (b, d) if a < b else (a, c)
  if any(s[k - 1] == s[k] == s[k + 1] == '.' for k in range(i - 1, j)):
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 9408
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<int>a(n);
rep(i,n)cin>>a[i];
string ans="APPROVED";
rep(i,n){
    if(a[i]%2==0){
        if(a[i]%3!=0 && a[i]%5!=0){
            ans="DENIED";
        }
    }
}
cout<<ans<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

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

	int n;
	cin >> n;
	vector<pair<int,int>> a(n);
	rep(i, n)
	{
		cin >> a[i].first;
		a[i].second = i + 1;
	}
	sort(a.begin(), a.end());
	rep(i, n-1)
	{
		cout << a[i].second << " ";
	}
	cout << a[n - 1].second << endl;

	return 0;
}

Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.RoundingMode;


public class Main {
    private static int MOD = 1000000007;


    public static void main(String[] args) throws IOException {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        String s = br.readLine();
        int i = Integer.parseInt(s);

        BigDecimal l = new BigDecimal(i);
        BigDecimal divide = l.divide(new BigDecimal(3), 10, RoundingMode.HALF_DOWN);

        BigDecimal pow = divide.pow(3);

        System.out.println(pow.toString());
    }

}


Measured memory_bytes: 21844
/* Coached by rainboy */
#include <stdio.h>

#define H 50
#define W 50

int main() {
	static char cc[H][W + 1];
	int h, w, i, j;

	scanf("%d%d", &h, &w);
	for (i = 0; i < h; i++)
		scanf("%s", cc[i]);
	for (i = 0; i < h; i++)
		for (j = 0; j < w; j++)
			if (cc[i][j] == '#'
					&& (i + 1 == h || cc[i + 1][j] != '#')
					&& (j + 1 == w || cc[i][j + 1] != '#')
					&& (i == 0 || cc[i - 1][j] != '#')
					&& (j == 0 || cc[i][j - 1] != '#')) {
				printf("No\n");
				return 0;
			}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
lis = [0]*(N+1)
for i in range(N,0,-1):
  k = i*2
  cnt = 0
  while k<=N:
    cnt ^= lis[k]
    k += i
  lis[i] = cnt^A[i-1]
print(lis.count(1))
ans = []
for i in range(1,N+1):
  if lis[i]==1:
    ans.append(i)
if len(ans):
  print(*ans)

Measured memory_bytes: 97704
#include <iostream>

using namespace std;

int main()
{
    int sh,sm,ss,eh,em,es;
    int stays;
    for(int i=0; i<3; ++i) {
        cin >> sh >> sm >> ss >> eh >> em >> es;
        stays=es-ss+60*((em-sm)+60*(eh-sh));
        cout << stays/3600 << " " << (stays/60)%60 << " " << stays%60 << endl;
    }
    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
#define pint pair<int,int>
#define pdouble pair<double,double>
using namespace std;
typedef long long ll;

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

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

int main(){
	int t,n,h[100];
	cin>>t;
	int max,min;
	while(t--){
		cin>>n;
		for(int i=0;i<n;i++) cin>>h[i];
		max=-100;
		min=-100;
		for(int i=1;i<n;i++){
			if(h[i]-h[i-1]>0){//nobori
				if(max<h[i]-h[i-1]) max=h[i]-h[i-1];
			}else if(h[i]-h[i-1]<0){
				if(min<h[i-1]-h[i]) min=h[i-1]-h[i];
			}
		}
		if(max!= -100)cout << max;
		else cout<< "0";
		cout << " ";
		if(min!= -100) cout << min;
		else cout << "0";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<math.h>

struct Point {double x, y;};

void koch(int n, Point a, Point b){
  if (n == 0) return;
  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n-1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n-1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n-1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n-1, t, b);
}

int main(){
  Point a, b;
  int n;

  scanf("%d", &n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}



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

int main(){
    ll int n,k;
    cin>>n>>k;
    ll int arr[n];
    ll int dp[k+1];
    memset(dp,0,sizeof(dp));
    for(int i = 0;i<n;i++){
        cin>>arr[i];
        dp[arr[i]] = 1;
    }

    for(ll int i = 1;i<=k;i++){
        if(dp[i]==1)
            continue;

        for(ll int j = 0;j<n;j++){

            if(i-arr[j]>=0 && dp[i-arr[j]]==0){
                dp[i] = 1;
                break;
            }
        }
    }
    if(dp[k]==1)
        cout<<"First"<<endl;
    else
        cout<<"Second"<<endl;
}








Measured memory_bytes: 1024
#include <stdio.h>

int main(void){

    int N = 0;
    
    scanf("%d", &N);

    int A[N];
    int count[200000] = {0};

    for (int i = 0; i < N - 1; i++){
        scanf("%d", &A[i]);    
        count[A[i] - 1] += 1;
    }

    for (int j = 0; j < N; j++){
        printf("%d\n", count[j]);
    }

    return 0;
}

Measured memory_bytes: 3244
#include <bits/stdc++.h>
#include <iostream>
#include <string>

using namespace std;


int main(){
    int n,m;
    cin >> n >> m;
    int h[n + 1];
    int ma[n + 1];
    for(int i = 1; i <= n;i++){
        cin >> h[i];
        ma[i]=0;
    }
    for(int i = 0;i < m;i++){
        int a;
        int b;
        cin >> a >> b;
        ma[a] = max(ma[a],h[b]);
        ma[b] = max(ma[b],h[a]);
    }
    int ans = 0;
    for(int i = 1;i <= n;i++){
        if(h[i] > ma[i])
            ans++;
    }
    cout << ans << endl;
}




Measured memory_bytes: 4384
import collections
def calc_double(n):
    return n%2
a=input()
b=collections.Counter(a)
values=zip(*b.most_common())
c=list(values)
e=c[1]
d=list(map(int,e))
if sum(map(calc_double,d))==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
 
typedef long long   ll;
typedef long double ld;
const int N  = 2e5+10;
const ll mod = 1e9+7;
const ll inf = 1e18;
 
#define fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb              push_back
#define mp              make_pair
#define ub              upper_bound                 // first element >  val(itr)
#define lb              lower_bound                 // first element >= val(itr) 
#define all(x)          (x).begin(),(x).end()
#define reset(a,x)      memset(a,x,sizeof(a))       // x can be 0 or -1
#define leadzero(a)     __builtin_clz(a)            // count leading zeroes
#define trailzero(a)    __builtin_ctz(a)            // count trailing zeroes
#define bitcount(a)     __builtin_popcount(a)       // count set bits
#define test            int t; cin>>t; while(t--)
#define forn(i,a,e)     for(ll i = a; i < e; i++)
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define sp              <<" "<<
 
 
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;    }
ll powm(ll base,ll exp){ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
ll add(ll a,ll b)  { return (a%mod+b%mod)%mod;        }
ll sub(ll a, ll b) { return (a%mod+mod-b%mod)%mod;    }
ll mult(ll a,ll b) { return ((a%mod)*(b%mod))%mod;    }

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

    ll v[n],c[n];
    forn(i,0,n)
    cin>>v[i];
    forn(i,0,n)
    cin>>c[i];
    ll ans=0;
    forn(i,0,n)
    {
    	if(v[i]-c[i]>=0)
    		ans+=(v[i]-c[i]);
    }

    cout<<ans;

    return 0;
} 

Measured memory_bytes: 256
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
using namespace std;

int n, m;
int cnt[100000];
vector<int> t[100000];

int memo[100000];

int dfs(int pos) {
  if (memo[pos] != -1) {
    return memo[pos];
  }

  int res = 0;
  for (int i = 0; i < t[pos].size(); i++) {
    res = max(res, dfs(t[pos][i]) + 1);
  }
  return memo[pos] = res;
}

int main() {
  while (cin >> n >> m) {
    for (int i = 0; i < n; i++) {
      t[i].clear();
    }

    fill(cnt, cnt + n, 0);

    for (int i = 0; i < m; i++) {
      int x, y;
      cin >> x >> y;

      x--;
      y--;
      t[x].push_back(y);
      cnt[y]++;
    }

    fill(memo, memo + n, -1);

    int ans = 0;
    for (int i = 0; i < n; i++) {
      if (cnt[i] != 0) continue;
      ans = max(ans, dfs(i));
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 11136
A=list(input())
B=list(input())
C=list(input())
A.reverse()
B.reverse()
C.reverse()

turn='a'

while True:
    if turn == 'a':
        if len(A)==0:
            break
        turn=A.pop()
    elif turn == 'b':
        if len(B)==0:
            break
        turn=B.pop()
    elif turn == 'c':
        if len(C)==0:
            break
        turn=C.pop()
    else:
        print('error')
        break

print(turn.upper())

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

#define endl '\n'
#define ll long long
#define LSB __builtin_ctzll
#define sc(a) scanf("%d",&a)
#define MSB 63-__builtin_clzll
#define scl(a) scanf("%lld",&a)
#define BITS __builtin_popcountll
#define mem(a , v)  memset(a , v , sizeof(a))
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9+7;
const int MAX = 1e5+55;
const int INF = 1e9+77;
const ll INFINF = 1e18+1e17;
const double PI = acos(-1.0);
vector<int> months = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y&1)
         s*=x;
         return s;
}

string s1;
string s2;
string ans;
int n1;
int n2;


int dp[3001][3001];

int solve(int i,int j){
    if(i==n1){
        return 0;
    }
    if(j==n2){
        return 0;
    }

    int &res=dp[i][j];
    if(res!=-1){
        return res;
    }

    res=0;
    if(s1[i]==s2[j]){
        res+=solve(i+1,j+1)+1;
    }
    else{
        res=max(    solve(i+1,j)  ,   solve(i,j+1)   );
    }

    return res;

}


void build(int i,int j){
    if(i==n1){
        return;
    }
    if(j==n2){
        return;
    }


    if(s1[i]==s2[j]){
        ans+=s1[i];
        build(i+1,j+1);
    }
    else{
        if(solve(i+1,j)>=solve(i,j+1)){
            build(i+1,j);
        }
        else{
            build(i,j+1);
        }
    }

    return;

}



int main(){

ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//freopen("input.txt" , "r" , stdin);
//freopen("output.txt" , "w" , stdout);



     cin>>s1>>s2;
     n1=s1.size();
     n2=s2.size();

     mem(dp,-1);
     solve(0,0);
     ans="";
     build(0,0);
     cout<<ans;








     return 0;

}


Measured memory_bytes: 35712
import numpy as np


def main():
    MOD = 10**9 + 7
    N, M = list(map(int, input().split(' ')))
    broken = np.zeros(N + 1)
    for _ in range(M):
        a = int(input())
        broken[a] = 1
    dp = np.zeros(N + 1)
    dp[0] = 1
    for i in range(1, N + 1):
        dp[i:(i + 2)] += dp[i - 1] * (1 - broken[i:(i + 2)])
        dp[i:(i + 2)] %= MOD
    print(int(dp[N]))


if __name__ == '__main__':
    main()

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

typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


//===

const ll mod = ll(1e9 + 7);



int main() {
	int N, L;
	cin >> N >> L;
	
	int i_min;
	int abs_min = 1e9;
	for (int i = 1; i <= N; ++i) {
		if (abs(L + i - 1) < abs_min) {
			i_min = i;
			abs_min = abs(L + i - 1);
		}
	}

	cout << N * (L - 1) + N * (N + 1) / 2 - (L + i_min - 1) << endl;
}


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

const int MAX_N = 1005;
int dp[MAX_N][MAX_N];

int minimum(int a, int b, int c){
    return min(min(a,b),c);
}

int levenshteinDistance(string a, string b){
    rep(i,a.size() + 1) dp[i][0] = i;
    rep(i,b.size() + 1) dp[0][i] = i;

    range(i,1,a.size() + 1){
        range(j,1,b.size() + 1){
            int cost = a[i - 1] == b[j - 1] ? 0 : 1;
            dp[i][j] = minimum(dp[i - 1][j] + 1, dp[i][j - 1] + 1, dp[i - 1][j - 1] + cost);
        }
    }
    return dp[a.size()][b.size()];
}

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

    cout << levenshteinDistance(a,b) << endl;
}

Measured memory_bytes: 7160
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())

if N == 1:
    print(0)
    exit()

primes = factorization(N)

ans = 0
for _, cnt in primes:
    n = 0
    while n * (n + 1) // 2 <= cnt:
        n += 1
    ans += n - 1

print(ans)

Measured memory_bytes: 63336
const main = input => {
  const [n, ...a] = input.trim().split(/ |\n/).map(e => parseInt(e))
  const r = new Array(n).fill(0)
  const l = a.length
  for (let i = 0; i < l; i++) r[a[i] - 1]++
  return r.join("\n")
}

console.log(main(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 61912
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n; R(n);
    string s;
    R(s);
    map<char,int>AA;
    REP(i,n){
        AA[s[i]]++;
    }
    LL v=1;
    for(auto x: AA){
        v=v*(x.S+1)%MOD;
    }
    v--;
    if(v<0)v+=MOD;
    W(v);
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main()
{
    int N;
    cin >> N;
    vll A(N);
    cin >> A;
    ll hmax = A[0];
    ll ans = 0;
    for(int i=1; i<N; i++){
        if(hmax > A[i]){
            ans += hmax - A[i];
        }else{
            hmax = A[i];
        }
    }
    cout << ans << endl;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    long long a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<long long> v;
    for (int i = 0; i < n; i++) {
        long long sum = 0;
        for (int j = i; j < n; j++) {
            sum += a[j];
            v.emplace_back(sum);
        }
    }
    long long ans = 0;
    for (int i = 40; i >= 0; i--) {
        ans ^= (1LL << i);
        int cnt = 0;
        for (int j = 0; j < v.size(); j++) {
            if ((v[j] & ans) == ans) cnt++;
        }
        if (cnt < k) ans ^= (1LL << i);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 6512
from collections import deque
 
q = deque([]) 

def ct(a,b):
    ans = 0
    while abs(a)<abs(b):
        ans += 2
        a *= 4
    return ans

N = int(input())
A = [int(a) for a in input().split()]

# A = [3, 1, 4, 1]
# N = len(A)


X = [0] * (N)
Y = [0] * (N)

a = -1
for i in range(N):
    b = a
    if i > 0:
        X[i] = X[i-1]
    else:
        X[i] = 0
    a = A[i]
    t = 0
    if a > 0:
        X[i] += 1
        a *= -2
    
    if i > 0:
        t = 0
        r = b/a
        while r >= 4:
            q.append(i)
            r /= 4
            
        while abs(a)>abs(b):
            if len(q) == 0:
                X[i] += 2 * i
            else:
                X[i] += 2 * (i - q.pop())
            b *= 4
    
q = deque([]) 
a = -1
for i in range(N):
    b = a
    if i > 0:
        Y[i] = Y[i-1]
    else:
        Y[i] = 0
    a = A[N-1-i]
    t = 0
    if a < 0:
        Y[i] += 1
        a *= -2
    
    if i > 0:
        t = 0
        r = b/a
        while r >= 4:
            q.append(i)
            r /= 4
            
        while abs(a)>abs(b):
            if len(q) == 0:
                Y[i] += 2 * i
            else:
                Y[i] += 2 * (i - q.pop())
            b *= 4

mi = min(X[-1], Y[-1])
for i in range(N-1):
    if X[i]+Y[-2-i] < mi:
        mi = X[i]+Y[-2-i]
print(mi)

Measured memory_bytes: 28432
#include <bits/stdc++.h>
using namespace std;
int main(){
    
    int a,b;
    cin>>a>>b;
    if(a==1&&b&&b==2){
        cout<<3;
    }else if(a==3&&b&&b==2){
        cout<<1;
    }else if(a==1&&b&&b==3){
        cout<<2;
    }else if(a==3&&b&&b==1){
        cout<<2;
    }else if(a==2&&b&&b==1){
        cout<<3;
    }else if(a==2&&b&&b==3){
        cout<<1;
    }
    return 0;
}

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

fun solve(N: Long, M: Long, a: LongArray) {
    val b = a.distinct()
    if (b.map { powerOf(it, 2) }.distinct().size >= 2) { println(0) } else {
        val g = b.map { it / 2L }.reduce { a, b -> a / gcd(a, b) * b }
        // 1 <= g * (2*m - 1) <= M
        // m = 1, 2, 3, ... , (M / g + 1) / 2
        println((M / g + 1) / 2)
    }
    return
}

tailrec fun gcd(x: Int, y: Int): Int = if (y == 0) x else gcd(y, x % y)
tailrec fun gcd(x: Long, y: Long): Long = if (y == 0L) x else gcd(y, x % y)

fun powerOf(x: Long, base: Long): Int {
    var count = 0
    var ret = x
    while (ret % base == 0L) {
        ret /= base
        count++
    }
    return count
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    val M = sc.next().toLong()
    val a = LongArray(N.toInt())
    for (i in 0 until N.toInt()) {
        a[i] = sc.next().toLong()
    }
    solve(N, M, a)
}


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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  ll n;ll k;cin>>n>>k;
  vector<ll> A(n);
  map<ll, ll> mp;
  for(ll i=0;i<n;i++){
    cin>>A[i];A[i]--;
  }
  // if(A[0]==0){puts("1");return 0;}
  mp[0]=0;
  ll pos=0;
  ll cnt=1;
  for(ll i=0;i<n;i++){
    if(k==cnt){
      cout<<A[pos]+1<<endl;return 0;
    }
    if(mp[A[pos]]){
      ll dif = cnt - mp[A[pos]];
      // cout<<dif<<endl;
      ll rest = k - cnt + 1;
      // cout<<rest<<endl;
      k = rest % dif;
      // cout<<k<<endl;
      // cout<<pos<<endl;
      for(ll j=0;j<k;j++){
        pos = A[pos];
      }
      cout<<pos+1<<endl;
      return 0;
    }
    mp[A[pos]] = cnt;
    pos = A[pos];
    cnt++;
  }
  return 0;
}


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

int main() {
  int N, sum;
  double A[1000], avg, sumdiv, std;

  while (1) {
    cin >> N;
    if (N == 0) break;
    sum = avg = sumdiv = std = 0;
    for (int i = 0; i < N; i++){
      cin >> A[i];
      sum += A[i];
    }

    avg = (double)sum / N;
    for (int i = 0; i < N; i++){
      sumdiv += pow(A[i] - avg, 2);
    }
    std = sqrt(sumdiv/N);
    cout << fixed << setprecision(8) << std << endl;
  }
  return 0;
}


Measured memory_bytes: 3296
function Main(input){
  const [a, b] = input.split(' ').map(Number);
  let d, r, f;
  d = Math.floor(a / b);
  r = Math.floor(a % b);
  f = (a / b).toFixed(8);
  console.log(d + ' ' + r + ' ' + f);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define endl "\n"
#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007
//グリッドグラフの範囲チェック
bool range_validation(int y,int x,int h,int w){
    return y>=0 && y<h && x>=0 && x < w;
}
//ビットカウント
int popcount(long bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  int n;
  cin >> n;
  vector<int> h(n);
  REP(i,n)cin >> h[i];

  vector<ll> dp(n,INF);

  dp[0] = 0;
  REP(i,n){
    if(i+1 < n){
      chmin(dp[i+1] , dp[i] + abs(h[i]-h[i+1]));
    }
    if(i+2 < n){
      chmin(dp[i+2] , dp[i] + abs(h[i]-h[i+2]));
    }
  }


  cout << dp[n-1] << endl;
  return 0;
}


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

int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector <int> x(N+1);
    vector <int> y(M+1);
    for (int i=0; i<N; i++) cin >> x.at(i);
    x.at(N) = X;
    for (int i=0; i<M; i++) cin >> y.at(i);
    y.at(M) = Y;
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    int x_max, y_min;
    x_max =  x.at(x.size()-1);
    y_min =  y.at(0);
    if (x_max<y_min) cout << "No War";
    else cout << "War";
}

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

int main()
{
    int n;
    cin >> n;
    if (n)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << 1 << endl;
    }
}


Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>

using namespace std;

int main() {

	char s;
	cin >> s;

	if (isupper(s))
	{
		cout << "A" << endl;
	}
	else
	{
		cout << "a" << endl;
	}

	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int main(){
    int x,y,z,k; cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    for (int i = 0; i < x; i++) cin >> a[i];
    for (int i = 0; i < y; i++) cin >> b[i];
    for (int i = 0; i < z; i++) cin >> c[i];

    sort(c.begin(), c.end()); reverse(c.begin(), c.end());
    vector<ll> multi(0), multi3(0);
    for (int i = 0; i < x; i++){
        for (int j = 0; j < y; j++){
            multi.push_back(a[i]+b[j]);
            //cout << a[i]+b[j] << endl;
        }
    }
    //cout << "-------" << endl;
    sort(multi.begin(), multi.end()); reverse(multi.begin(), multi.end());

    for (int i = 0; i < min(k,(x*y)); i++){
        for (int j = 0; j < z; j++){
            //cout << "multi=" << multi[i] << endl;
            multi3.push_back(multi[i]+c[j]);
        }
    }
    sort(multi3.begin(), multi3.end()); reverse(multi3.begin(), multi3.end());
    for (int i = 0; i < k; i++){
        cout << multi3[i] << endl;
    }
}

Measured memory_bytes: 43112
/**
    AUTHOR:JUNSH
    TIME:19/5/25
**/
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rev(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef long long ll;
inline int read(){
    int f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
const int inf=0x3f3f3f3f;
int n,m,k;
const int maxn=105;
struct node{
     string name;
     int val;
     int id;
}res[maxn];
bool cmp(node a,node b){
    return a.name==b.name?a.val>b.val:a.name<b.name;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>>res[i].name>>res[i].val;
        res[i].id=i;

    }
    sort(res+1,res+n+1,cmp);
    for(int i=1;i<=n;++i)
        cout<<res[i].id<<endl;

}


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

int A, B, C;
int lists[3];

int main(){
    cin >> A >> B >> C;
    lists[0] = A; lists[1]  = B; lists[2] = C;
    sort(lists, lists + 3);
    int max_value = lists[2];
    int middle_value = lists[1];
    int min_value = lists[0];
    int D = middle_value - min_value;
    int E = max_value - min_value;
    if (D % 2 == 0){
        cout << E - D + D / 2 << endl;
    }else{
        cout << E - D + D / 2 + 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
    #include <algorithm>
    #include <functional>
    #include <vector>
    #include <set>
    #include <map>
    #include <stack>
    #include <queue>
    #include <string>
     
    #define rep(i, n) for (int i = 0; i < n; i++)
    using namespace std;
    typedef long long ll;
     
    template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
    template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}
     
    int main(){
      ll n; cin >> n;
      vector<ll> s(n+1,0);
      rep(i, n){
        if ((i + 1) % 3 == 0 || (i + 1) % 5 == 0) s[i+1] = s[i];
        else {
          s[i+1] = s[i] + (i + 1);
        }
      }
      cout << s[n] << endl;
    }

Measured memory_bytes: 11140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;cin>>A>>B;
  bool get=false;
  int y=1;
  for(;y<=10000;y++){
    if(int(y*0.08)==A&&int(y*0.1)==B){
      get=true;
      break;
    }
  }
  cout<<(get?y:-1)<<endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in range(n)]
a.sort()
if n % 2 == 0:
    half_n = n // 2
    pre = a[:half_n]
    post = a[half_n:]
    print((sum(post) * 2 - post[0]) - (sum(pre) * 2 - pre[-1]))
else:
    half_n = n // 2
    pre1 = a[:half_n]
    post1 = a[half_n:]
    pre2 = a[:half_n+1]
    post2 = a[half_n+1:]
    diff1 = (sum(post1) * 2 - post1[0] - post1[1]) - sum(pre1) * 2
    diff2 = sum(post2) * 2 - (sum(pre2) * 2 - pre2[-1] - pre2[-2])
    print(max(diff1, diff2))

Measured memory_bytes: 8540
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<bitset>
#include <numeric>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define LONG_INF 9223372036854775807
#define INF 1000000000LL
#define EPS 1e-10
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define dump(a) rep(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define all(v) v.begin(),v.end()
#define pb push_back

#define INT 1.01

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

    ll X, v = 100; //intにすると大幅に遅くなる（2ms -> 2005ms）

    cin >> X;

    rep(ret, INF){ //whileにしても実行時間に大きな差はない
        if(X<=v){
            cout << ret << endl;
            break;
        }
        v *= INT;
    }

    /*
    int ret=0;
    while(true){
        ret++;
        v *= INF;
        if(X<=v) break;
    }
    cout << ret << endl;
    */

    return 0;
}


/* 以下悪いコード

#define INT 1.01

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

    ll X;
    cin >> X;

    int ret = 0, v = 100;
    while(true){
        ret ++;
        v *= INT;
        if(X<=v) break;
    }

    cout << ret << endl;

    return 0;
}
*/

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

using namespace std;

void solve(string &s)
{
    int m;
    cin >> m;
    vector<int> H(m);

    for(int i = 0; i < m; i++){
        cin >> H.at(i);
    }

    for(int i = 0; i < m; i++){
        int h = H.at(i);
        s = s.substr(h, s.size()-h) + s.substr(0,h);
    }
    cout << s << endl;
}

int main()
{
    for(;;){
        string s;
        cin >> s;
        if(s == "-") return 0;
        solve(s);
    }
    return 0;
}


Measured memory_bytes: 3176
#include<iostream>
#include<queue>
#include<algorithm>
#include<numeric>
using namespace std;
const long long INF=1LL<<40;

int main(){
    long long N,K;cin>>N>>K;
    vector<vector<long long> >s(N);
    for(int i=0;i<N;i++){
        long long t,d;cin>>t>>d;--t;
        s[t].push_back(d);

    }
    //cout<<" 1"<<endl;

    for(auto &v:s){
        sort(v.begin(),v.end(),greater<long long>());
        if(v.empty())v.push_back(-INF);
    }

    sort(s.begin(),s.end(),[](vector<long long>a,vector<long long>b){
        return a[0]>b[0];
    });
    //cout<<" 2"<<endl;

    long long cur=0;
    priority_queue<long long>que;
    for(int i=0;i<K;i++){
        cur+=s[i][0];
        for(int j=1;j<s[i].size();j++)que.push(s[i][j]);

    }
    //cout<<" 3"<<endl;
    for(int i=K;i<N;i++)for(int j=0;j<s[i].size();j++)que.push(s[i][j]);
    //cout<<"4"<<endl;
    long long res=cur+K*K;
    for(long long x=K-1;x>=1;--x){
        long long v=s[x][0];
        long long w=que.top();
        if(v<w){
            que.pop();cur+=w;
            que.push(v);cur-=v;
        }
        res=max(res,cur+x*x);
    }
    cout<<res<<endl;

}

Measured memory_bytes: 8696
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>




const int N=1e5+10;
int n,res;
char s[N];




void solve()
{
	cin>>(s+1);
	n=strlen(s+1);
	res=1;
	for(int i=2;i<=n;i++)
	{
		if(s[i]!=s[i-1])res++;
	}
	res--;
	cout<<res<<"\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

bool has[200];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int N, K; gi(N), gi(K);
	set<int> v;
	while(K--) {
		int g; gi(g);
		while(g--) {
			int p; gi(p);
			v.insert(p);
		}
	}
	print(N-v.size());
}


Measured memory_bytes: 3656