akhauriyash/Code-Regression huggingface dataset:
def main():
    x1, y1, x2, y2 = map(int, input().split(" "))
    dx = x2 - x1
    dy = y2 - y1
    print(x2 - dy, y2 + dx, x1 - dy, y1 + dx)
    # abs(x2 - x1)とすると詰み．ベクトルとして符号付きで扱う．
    # 結局dx > 0, dy > 0のときの式がそのまま使える?


if __name__ == '__main__':
    main()

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

struct Card {
	int value;
	char suit;
};

void PrintCards(Card C[], int N) {
	for (int i = 0; i < N; i++) {
		cout << C[i].suit << C[i].value;
		if (i != N-1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}
}

int main() {
	int N; cin >> N;
	Card BubbleSorted[40], SelectionSorted[40];
	for (int i = 0; i < N; i++) {
		cin >> BubbleSorted[i].suit >> BubbleSorted[i].value;
		SelectionSorted[i] = BubbleSorted[i];
	}
	
	// Begin of BubbleSort
	for (int i = 0; i < N; i++) {
		for (int j = N-1; j > i; j--) {
			if (BubbleSorted[j].value < BubbleSorted[j-1].value) {
				Card temp = BubbleSorted[j];
				BubbleSorted[j] = BubbleSorted[j-1];
				BubbleSorted[j-1] = temp;
			}
		}
	}
	PrintCards(BubbleSorted, N);
	cout << "Stable" << endl;
	// End of BubbleSort
	
	// Begin of SelectionSort
	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i; j < N; j++) {
			if (SelectionSorted[j].value < SelectionSorted[minj].value) {
				minj = j;
			}
		}
		if (minj != i) {
			Card temp = SelectionSorted[i];
			SelectionSorted[i] = SelectionSorted[minj];
			SelectionSorted[minj] = temp;
		}
	}
	PrintCards(SelectionSorted, N);
	bool stable = true;
	for (int i = 0; i < N; i++) {
		if (BubbleSorted[i].suit != SelectionSorted[i].suit) {
			stable = false;
			break;
		}
	}
	cout << (stable ? "Stable" : "Not stable") << endl;
	// End of SelectionSort
}



Measured memory_bytes: 3096
#include <stdio.h>

int main(){
	int i, n;
	long a, max=-1000000, min=1000000, sum=0;

	scanf("%d", &n);

	for (i = 0; i < n; i++){
		scanf("%ld", &a);
		if (min > a)min = a;
		if (max < a)max = a;
		sum += a;
	}
	printf("%ld %ld %ld\n", min, max, sum);
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>;
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int n;
int ans, d[100002];

int main() {

	cin >> n;
	rep(i, n)cin >> d[i];

	sort(d, d + n);

	if (n % 2 == 0) {
		ans = d[n / 2] - d[n / 2 - 1];
	}
	else ans = 0;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int ans = 180 * (n-2);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3580
// ITP1_10_B
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

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

    double a,b,C;
    double pi=M_PI;
    cin>>a>>b>>C;
    double radC;
    if(360<=C){
        int num;
        num=C/360;
        C=C-num*360;
        radC=(C/180)*pi;
    }else radC=(C/180)*pi;

    //cout<<sin(pi*radC)<<endl;

    double s,l,h;
    s=a*b*0.5*sin(radC);
    h=2*s/a;

    double c;
    c=sqrt(a*a+b*b-2*a*b*cos(radC));
    l=c+a+b;
    cout<<s<<endl;
    cout<<l<<endl;
    cout<<h<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll A[100010];
int main()
{
	int K;
	cin >> K;
	for (int i = 0; i < K; i++) cin >> A[i];
	if (A[K - 1] != 2) {
		cout << -1 << endl;
		return 0;
	}
	ll ans = 2;
	// 最小
	for (int i = K - 1; i >= 0; i--) {
		ans = (ans + A[i] - 1) / A[i] * A[i];
	}
	ll num = ans;
	for (int i = 0; i < K; i++) {
		num = num - (num % A[i]);
	}
	if (num == 2)cout << ans << " ";
	else {
		cout << -1 << endl;
		return 0;
	}
	//cout << endl;

	ans = 2;
	//最大
	for (int i = K - 1; i >= 0; i--) {
		ans = ans / A[i] * A[i] + A[i] - 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import sys,copy
from itertools import accumulate

input=sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))

A=list(accumulate(A))
B=copy.copy(A)
test1=0
s=0
for i in range(0,N):
    A[i]+=s
    if i%2==0:
        if 0>=A[i]:
            test1+=1-A[i]
            s+=1-A[i]
    else:
        if A[i]>=0:
            test1+=A[i]+1
            s-=A[i]+1


test2=0
s=0
for i in range(0,N):
    B[i]+=s
    if i%2==0:
        if B[i]>=0:
            test2+=B[i]+1
            s-=B[i]+1
    else:
        if 0>=B[i]:
            test2+=1-B[i]
            s+=1-B[i]

print(min(test1,test2))

Measured memory_bytes: 65188
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstring>
using namespace std;
int main()
{
  int h,w,a[26][26];
  int ans[26][26]={0},sum;
  int ANS=100000011;
  cin >> h >> w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> a[i][j];
    }
  }
  for(int x=0;x<h;x++){
    for(int y=0;y<w;y++){
      for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
          sum=0;
          if(i<x&&j<y){
            sum=min(x-i, y-j);
          }else if(i<x&&j>y){
            sum=min(x-i, j-y);
          }else if(i>x&&j<y){
            sum=min(i-x,y-j);
          }else if(i>x&&j>y){
            sum=min(i-x,j-y);
          }
            ans[x][y]+=sum*a[i][j];
        }
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(ANS>ans[i][j]){
        ANS=ans[i][j];
      }
    }
  }

  cout << ANS << endl;
  return 0;
}



Measured memory_bytes: 3092
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

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

yes = "Yes"
no = "No"

def main():
    s = input()
    q = ii()
    qlist = []
    for i in range(q):
        tmp = list(input().split())
        qlist.append(tmp)

    flag = False
    headlist = ''
    hiplist = ''
    for i in qlist:
        if i[0] == '1':
            flag = not flag
            continue
        else:
            ftmp = i[1] == '1'
            ctmp = i[2]
            if flag:
                ftmp = not ftmp
            if ftmp:
                headlist += ctmp
            else:
                hiplist += ctmp
    ansstr = ''    
    headlist = headlist[::-1]
    ansstr+=headlist
    ansstr+=s
    #hiplist = hiplist[::-1]
    ansstr+=hiplist
    if flag:
        ansstr = ansstr[::-1]#reversed(ansstr)
    print(ansstr)
        
            




main()



Measured memory_bytes: 33204
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
using namespace std; 
 
const int N = 1000, OO = 1e18 + 100, M = 998244353, P = 6151, SQ = 120, lg = 22;
typedef pair <int, int> pii;

int32_t main() {
    use_fast;
    int a, b;
    cin >> a >> b;
    string s = "", t = "";
    for(int i = 0; i < a; i++) {
    	s += (char)(b + '0');
	}
    for(int i = 0; i < b; i++) {
    	t += (char)(a + '0');
	}
	cout << min(s, t) << endl;
	return 0; 
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/	

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

typedef long long ll;

long long int modPow(long long int a, long long int n){//繰り返し自乗法(a^n mod p)。計算量 O(logN)
    long long int p = pow(10, 9) + 7;//任意のp(素数) modのやつで使える 
    if(n == 0){
        return 1;
    }
    if(n == 1){
        return a % p;
    }
    if (n % 2 == 1){ 
        return (a * modPow(a, n - 1)) % p;
    }      
    long long t = modPow(a, n / 2);
    return (t * t) % p;
}

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    //bool flag = true;
    
    while(b <= a){
        b = 2 * b;
        k--;
    }
    //cout << b << endl;
    while(c <= b){
        c = 2 * c;
        k--;
    }
    //cout << c << endl;
    //cout << k << endl;
    if(k < 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  int mod500 = a % 500;
  if (b >= mod500) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl; 
  }
}

Measured memory_bytes: 3612
x, y = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
#ab = [list(map(int, input().split())) for i in range(n)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))

# xひき　y本
total = 0
for i in range(0, x+1):
    total = 2*i + 4*(x-i)
    
    if total == y:
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 9164
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		}
		int[] sorted = (int[])(arr.clone());
		Arrays.sort(sorted);
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
		    if (arr[i] == sorted[n - 1]) {
		        sb.append(sorted[n - 2]);
		    } else {
		        sb.append(sorted[n - 1]);
		    }
		    sb.append("\n");
		}
		System.out.print(sb);
   }
}


Measured memory_bytes: 91764
#include <iostream>
#include <iomanip>
#include <cmath>

double PI = acos(-1);

using namespace std;

int main(void){
	double a,b,x,tmp,res;
	cin >> a >> b >> x;
	double k = (x*2)/(a*b*b);
	if(a >= b*k){
		tmp = atan(k);
		res = PI/2.0 - tmp;
	}else{
		k = b/a - x/(a*a*a);
		res = atan(2.0*k);
	}
	cout << fixed << setprecision(10) << res * 180 / PI << endl;
}



Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>

using lint = long long;
constexpr lint INF = 1LL << 50;

void solve() {
    int n;
    lint a, b;
    std::cin >> n >> a >> b;

    std::vector<int> xs(n);
    for (auto& x : xs) std::cin >> x;
    xs.insert(xs.begin(), -1);

    std::vector<lint> dp(1, 0);
    std::vector<lint> ndp = dp;

    for (int i = 1; i <= n; ++i) {
        ndp.assign(i + 1, INF);

        for (int j = 0; j < i; ++j) {
            if (xs[j] < xs[i]) {
                // fix
                ndp[i] = std::min(ndp[i], dp[j]);
                // pass
                ndp[j] = std::min(ndp[j], dp[j] + a);
            } else {
                // pass
                ndp[j] = std::min(ndp[j], dp[j] + b);
            }
        }
        std::swap(dp, ndp);
    }

    std::cout << *std::min_element(dp.begin(), dp.end()) << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ull unsigned ll
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (ll)1e9
#define OO (ll)1e18
#define EPS 1e-7
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=200005;
int n;
ll a[maxn];
ll check(ll b){
    ll ret=0;
    for(int i=1;i<=n;++i)
        ret+=abs(a[i]-b-i);
    re ret;
}
ll bs(){
    ll l=-oo,r=oo,mid;
    while(l<=r){
        ll mid=(l+r)/2ll;
        ll A=check(mid-1);
        ll B=check(mid);
        ll C=check(mid+1);
        if(A>=B&&B<=C)re B;
        if(A<=B&&B<=C)
            r=mid;
        if(A>=B&&B>=C)
            l=mid;
    }
}
int main()
{
    IO;
    cin >> n;
    for(int i=1;i<=n;++i)
        cin >> a[i];
    cout<<bs()<<endl;
    re 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3

import sys

def solve(bigN, bigX, xs):
    ys = [abs(x - bigX) for x in xs]
    g = ys[0]
    for y in ys[1:]:
        g = gcd(y, g)
    return g

def gcd(a, b):
    '''The greatest common divisor of a and b.'''
    while b > 0:
        (a, b) = (b, a % b)
    return a

def readQuestion():
    [line1, line2] = list(sys.stdin)
    [bigN, bigX] = [int(s) for s in line1.split(' ')]
    xs           = [int(s) for s in line2.split(' ')]
    return (bigN, bigX, xs)

def main():
    bigN, bigX, xs = readQuestion()
    answer = solve(bigN, bigX, xs)
    print(answer)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 15140
#include <bits/stdc++.h>
using namespace std;
int d[105];
bool v[105];
int main() {
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= k; i++) {
        cin >> d[i];
        for (int j = 1; j <= d[i]; j++) {
            int x;
            cin >> x;
            v[x] = true;
        }
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (!v[i]) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>

static void A_WhiteCells();

int main()
{
	A_WhiteCells();

	fflush(stdout);
	return 0;
}

static void A_WhiteCells()
{
	int H = 0, W = 0;
	int h = 0, w = 0;

	scanf(" %d %d", &H, &W);
	scanf(" %d %d", &h, &w);

	int restW = (H * W) - ((h * W) + (w * H) - (h * w));

	printf("%d\n", restW);
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			long[] a = new long[n];
			long ans = 1;
			long limit = (long)Math.pow(10, 18);
			for(int i = 0; i < n; i++) {
				a[i]  = in.nextLong();
				if(a[i] == 0) {
					ans = 0;
				}
			}
			if(ans == 0) {
				out.println(ans);
				return;
			}
			for(int i = 0; i < n; i++) {
				if(a[i] > (limit / ans)) {
					ans = -1;
					break;
				} else {
					ans *= a[i];
				}
			}
			out.println(ans);
		}
	}

	static boolean permutation_2(String s, String t) {
		if (s.length() != t.length()) {
			return false;
		}

		int[] letters = new int[256];

		char[] s_array = s.toCharArray();
		for (char c : s_array) {
			letters[c]++;
		}

		for (int i = 0; i < t.length(); i++) {
			int c = (int) t.charAt(i);
			if (--letters[c] < 0) {
				return false;
			}
		}
		return true;
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

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

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

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

	}
}


Measured memory_bytes: 49308
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
vector<int>g[123456];
vector<int>ans;
bool used[123456];
int main(){
    int n,m;
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int now = 1;
    ans.push_back(now);
    used[now] = true;
    while(1){
        bool flag = false;
        for(int x:g[now]){
            if(!used[x]){
                now = x;
                used[now] = true;
                ans.push_back(now);
                flag = true;
                break;
            }
        }
        if(!flag)break;
    }
    reverse(ans.begin(),ans.end());
    now = 1;
    while(1){
        bool flag = false;
        for(int x:g[now]){
            if(!used[x]){
                now = x;
                used[now] = true;
                ans.push_back(now);
                flag = true;
                break;
            }
        }
        if(!flag)break;
    }
    cout << ans.size() << endl;
    rep(i,ans.size()){
        cout << ans[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 7416
s = input()
count = 0
result = 0
for i in range(len(s)):
    if s[i] == "A" or s[i] == "T" or s[i] == "C" or s[i] == "G":
        count += 1
        if count >= result:
            result = count
    else:
        count = 0
print(result)

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;

int main(void)
{
	int n,x;
	int cost = 0;
	vector<int> m;

	cin >> n >> x;

	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		m.push_back(tmp);
	}

	int min = 0;
	int mincost = m[0];

	for (int i = 0; i < n; i++) {
		cost += m[i];
		if (mincost > m[i]) {
			min = i;
			mincost = m[i];
		}
	}

	int last = x - cost;
	int lastnum = last / mincost;

	cout << lastnum + n << endl;


	return 0;
}

Measured memory_bytes: 256
r,g,b,n = map(int,input().split())
b,g,r = sorted([r,g,b])

ptn = 0
for i in range(n+1):
    if i*r > n:
        break
    
    for j in range(n+1):
        if i*r + j*g > n:
            break
        
        if ((n - i*r - j*g)%b) == 0:
            ptn += 1
        
print(ptn)

Measured memory_bytes: 41820
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
  int n, x;
  cin >> n >> x;
  vector<long long int> ns(n, 0);
  for (int i = 0; i < n; i++) { cin >> ns[i]; }

  long long int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    long long int sum = ns[i] + ns[i + 1];
    long long int diff = sum - x;
    if (diff <= 0) { continue; }
    ans += diff;
    long long int m1 = min(diff, ns[i + 1]);
    ns[i + 1] -= m1;
    long long int m2 = diff - m1;
    if (m2 > 0) {
      ns[i] -= m2;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
  int n,k,l[50],i,j,max,z,ans=0;
  scanf("%d%d",&n,&k);
  for (i=0;i<n;i++) scanf("%d",&l[i]);
  for (i=0;i<k;i++){
    max=0;
    for (j=0;j<n;j++){
      if (max<l[j]){
        max=l[j];
        z=j;
      }
    }
    ans+=max;
    l[z]=0; 
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
fun main() {
    val sc=Scanner(System.`in`)
    val n=sc.nextInt();
    var cnt:Long=0L
    for(i in 1..1000000){
        for(j in 1..1000000){
            if(i*j<n){
                cnt++
            }else {
                break
            };
        }
    }
    println(cnt)
}

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

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String w = scanner.next();
		int sum = 0;

		while(true){
			String x = scanner.next();

			if(x.equals("END_OF_TEXT")){
				break;
			}

			if(x.toLowerCase().equals(w.toLowerCase())){
				sum++;
			}
		}

		System.out.println(sum);
	}
}

Measured memory_bytes: 26400
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

long int combination(long int n, long int r);

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(data, 10, sizeof(int), compare_int)

long int combination(long int n, long int r)
{
	if(r>n-r) r = n-r;
	if(r == 0) return 1;
	else if(r == 1) return n;
	return (combination(n-1, r) + combination(n-1, r-1));
	//大きくなるとき
	/*
	long int tmp1, tmp2, tmp3;
	tmp1 = combination(n-1, r);
	if(tmp1>=MOD) tmp1 = tmp1%MOD;
	tmp2 = combination(n-1, r-1);
	if(tmp2>=MOD) tmp2 = tmp2%MOD;
	tmp3 = tmp1+tmp2;
	if(tmp3>=MOD) tmp3 = tmp3%MOD;
	return (tmp3);
	*/
}


int main(){
	int n;
	scanf("%d", &n);
	int time[n+1], x[n+1], y[n+1];
	time[0]=0, x[0]=0, y[0]=0;
	for(int i=1; i<=n; i++){
		scanf("%d%d%d", &time[i], &x[i], &y[i]);
	}
	int sax, say, sat, ok=1;
	for(int i=1; i<=n; i++){
		sat = time[i]-time[i-1];
		sax = x[i]-x[i-1];
		say = y[i]-y[i-1];
		if((sax+say>sat) || ((sat-sax-say)%2 != 0)){
			ok = -1;
			break;
		}
	}
	if(ok==1) printf("Yes\n");
	else printf("No\n");
		
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005
const ll MOD = 1000000007;

int main() {
    ll n,k;
    cin >> n >> k;
    ll a[n];
    ll count[2100] = {};
    rep(i,n){
        cin >> a[i];
        count[a[i]]++;
    }

    ll sum[2100] = {};
    drep(i,2050){
        sum[i] = sum[i+1] + count[i+1];
    }

    ll ans = 0;

    rep(i,n){
        srep(j,i+1,n){
            if(a[i]>a[j]){
                ans += k;
                ans %= MOD;
            }
        }
    }

    ll kk = (k-1)*k/2;
    kk %= MOD;
    
    rep(i,n){
        ll aa = a[i];
        ll ss = sum[aa]*kk;
        ss %= MOD;
        ans += ss;
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

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

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

    ll N;
    cin >> N;
    vector<pair<ll, ll>> brackets(N);
    Rep (i, N) {
        string S;
        cin >> S;
        ll m = 0, now = 0;
        for (char c : S) {
            if (c == '(') {
                now++;
            } else {
                now--;
            }
            chmin(m, now);
        }
        brackets[i] = {m, now};
    }

    sort(brackets.begin(), brackets.end(), [](pair<ll, ll> a, pair<ll, ll> b) {
        if (a.first == b.first) {
            return a.second > b.second;
        }
        return a.first > b.first;
    });

    ll now = 0;
    Rep (i, N) {
        if (brackets[i].second >= 0) {
            if (now + brackets[i].first < 0) {
                cout << "No\n";
                return 0;
            }
            now += brackets[i].second;
            brackets[i] = {0, 0};
        }
    }

    sort(brackets.begin(), brackets.end(), [](pair<ll, ll> a, pair<ll, ll> b) {
        return a.second - a.first > b.second - b.first;
    });

    Rep (i, N) {
        if (now + brackets[i].first < 0) {
            cout << "No\n";
            return 0;
        }
        now += brackets[i].second;
    }

    if (now != 0) {
        cout << "No\n";
        return 0;
    } else {
        cout << "Yes\n";
    }
}

Measured memory_bytes: 18668
#include<stdio.h>
#include<string.h>

const int L = 14;
const int M = 1046527;

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]){
    long long key,i = 0;
    key = getKey(str);
    while(1)
    {
        int h = ( h1(key) + i*h2(key) ) % M;
        if(strcmp( H[h],str) == 0 ) return 1;
        else if(strlen(H[h]) == 0) return 0;
        i++; 
    }
    return 0;
}

void insert(char str[]){

    long long i = 0,key;
    key = getKey(str);
    while(1)
    {
        int h = ( h1(key) + i*h2(key) ) % M;
        if(strcmp(H[h],str) == 0 ) return ;
        else if(strlen(H[h]) == 0 )
        {
            strcpy(H[h],str);
            return ;
        }
        i++;
    }
    return ;
}

int main(){
    int i, n;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
        scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
        scanf(" %s %s", com, str);

    if ( com[0] == 'i' ){
        insert(str);
    } else {
        if (find(str)){
        printf("yes\n");
        } else {
        printf("no\n");
        }
    }
    }

    return 0;
}


Measured memory_bytes: 16972
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
 
int main(){
    int n, m, q;
    cin >> n >> m >> q;
    vector<vector<int> > trains(n, vector<int>(n,0));
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--;b--;
        trains[a][b]++;
    }

    for(int i = 0; i < n; i++){
        for(int j = 1; j < n; j++){
            trains[i][j] += trains[i][j-1];
        }
    }

    rep(count,q){
        int ans = 0;
        int r, l;
        cin >> r >> l;
        r--;l--;
        for(int i = r; i <= l; i++){
            if(r == 0) ans += trains[i][l];
            else ans += trains[i][l] - trains[i][r-1];
        }

        cout << ans << '\n';
    }

    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")
int par[200001];
int treesize[200001];
int group = 100000;

int find(int x) {           //親探し
	if (par[x] == x) {
		return x;
	}
	else {
		int z = find(par[x]);
		par[x] = z;
		return z;
	}
}

bool  unit(int x, int y) {

	int xpar = find(x);
	int ypar = find(y);

	if (xpar == ypar) { return false; }   //すでに結合済み
	group--;
	par[ypar] = xpar;
	treesize[xpar] += treesize[ypar];
	return true;
}

int main()
{
	int N, M;
	cin >> N >> M;
	group = N;
	fx(N) {
		par[x + 1] = x + 1;
		treesize[x + 1] = 1;
	}
	fx(M) {
		int a, b;
		cin >> a >> b;
		unit(a, b);
	}

	int ans = 0;
	fx(N) {
		int k = treesize[find(x + 1)];
		ans = max(ans, k);
	}
	ce(ans)
    return 0;
}



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

int main()
{
    string t_s, h_s;
    int n, t_p = 0, h_p = 0;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> t_s >> h_s;
        if (t_s < h_s) {
            h_p += 3;
        } else if (t_s == h_s) {
            t_p++;
            h_p++;
        } else {
            t_p += 3;
        }
    }
    cout << t_p << ' ' << h_p << endl;
}


Measured memory_bytes: 3172
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979

int main()
{
	ll a, b;
	cin >> a >> b;
	if (b >= 0 && a <= 0)                            cout << "Zero" << endl;
	else if (a > 0 && b > 0 || (b - a + 1) % 2 == 0) cout << "Positive" << endl;
	else			                                 cout << "Negative" << endl;
	return 0;
}

Measured memory_bytes: 3556
#include<cmath>
#include<cstdio>

int main(void){
	int n, i;
	double m[100], y, d;
	scanf("%d", &n);
	for(i=0; i<n; ++i){ scanf("%lf", m+i); }
	for(i=0; i<n; ++i){ scanf("%lf", &y); m[i]=fabs(m[i]-y); }
	for(i=0, d=0.0; i<n; d+=m[i], ++i); printf("%f\n", d);
	for(i=0, d=0.0; i<n; d+=m[i]*m[i], ++i); printf("%f\n", sqrt(d));
	for(i=0, d=0.0; i<n; d+=m[i]*m[i]*m[i], ++i); printf("%f\n", cbrt(d));
	for(i=0, d=0.0; i<n; d=(d<m[i])?m[i]:d, ++i); printf("%f\n", d);
	return(0);
}


Measured memory_bytes: 2868
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1]* n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members()) for r in self.roots())


n, m = map(int, input().split())
F = [list(map(int, input().split())) for i in range(m)]

uf = UnionFind(n)

for f in F:
    uf.union(f[0] - 1, f[1] - 1)

out = 0

for r in uf.roots():
    out = max(out, uf.size(r))

print(out)

Measured memory_bytes: 50132
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		sa = br.readLine().split(" ");
		int[] c = new int[n];
		for (int i = 0; i < n; i++) {
			c[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int mod = 1000000007;
		if (n == 1) {
			System.out.println(c[0] * 2 % mod);
			return;
		}

		Arrays.parallelSort(c);
		long b = power(2, n);
		long a = power(2, n - 2);
		long ans = 0;
		for (int i = 2; i <= n + 1; i++) {
			long val = a * i % mod;
			val *= c[n + 1 - i];
			val %= mod;
			ans += val;
			ans %= mod;
		}
		ans *= b;
		ans %= mod;
		System.out.println(ans);
	}

	static long power(long x, long n) {
		if (n == 0) {
			return 1;
		}
		int mod = 1000000007;
		long val = power(x, n / 2);
		val = val * val % mod;
		if (n % 2 == 1) {
			val = val * x % mod;
		}
		return val;
	}
}


Measured memory_bytes: 55180
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main() {
    
  
   int l, n=0, a[10];
  
   while(cin>>l){
     
        a[n] = l;
       
        n++;
    }
  
     int p = 0;
  
 
    
     for (int f = 0;f < 3;f++){
     
         if (a[0]==a[f]){
           
             p = p + 1;
            
            
              
           
          }
 
      }
  
 
  
  if (p == 3){
    
    cout << 1 << endl;
    
  }else{
    
    
    int v = 0;
    
    for (int x = 0;x < 3;x++){
      
      int s = 0;
      
       for (int d = 0;d < 3;d++){
     
            if (a[x]==a[d]){
           
                s = s + 1;
              
              
                if (s == 2){
                 
                
                  v = 2;
                  
                   break;
                }
 
            }
 
        }
      
    }
    
     
    
    if(v == 2){
     
             
                   cout << 2 << endl;
               
    }else{
       cout << 3 << endl;
    }
    
  }
  
  
  
  
  return 0;
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n,k;cin >> n >> k;
    vector<int> a(n);
    rep(i,n)
    {
        cin >> a[i];
    }
    int left, right, mid;
    left = 0;
    right = *max_element(all(a));
    mid = (left+right)/2;
    while(right-left>1)
    {
        //cout << mid << endl;
        int counter =0;
        rep(i,n)
        {
            counter += ceil((double)a[i]/(double)mid)-1;
        }
        if(counter>k)
        {
            left = mid;
        }else{
            right = mid;
        }
        mid = (right+left)/2;
    }
    cout << right << endl;

}

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

int main(){
  int N;cin >> N;
  vector<pair<ll,ll>> P;
  vector<pair<ll,ll>> M;
  for(int i=0;i<N;i++){
    string S;cin >> S;
    int h=0,min_h=0;
    for(int j=0;j<S.size();j++){
      if(S[j]=='('){
        h ++;
      }else{
        h --;
      }
      min_h = min(min_h,h);
    }
    pair<ll,ll> x;
    if(h>=0){
      x.first = min_h;
      x.second = h;
      P.push_back(x);
    }else{
      x.first = min_h - h;
      x.second = -h;
      M.push_back(x);
    }
  }
  sort(P.begin(),P.end());
  reverse(P.begin(),P.end());
  sort(M.begin(),M.end());
  reverse(M.begin(),M.end());
  //for(int i=0;i<P.size();i++){
  //  cout << "P[" << i << "] = (" << P[i].first << "," << P[i].second << ")" << endl;
  //}
  //for(int i=0;i<M.size();i++){
  //  cout << "M[" << i << "] = (" << M[i].first << "," << M[i].second << ")" << endl;
  //}
  ll P_h = 0;
  for(int i=0;i<P.size();i++){
    if(P_h + P[i].first<0){
      cout << "No" << endl;
      return 0;
    }
    P_h = P_h + P[i].second;
  }
  ll M_h = 0;
  for(int i=0;i<M.size();i++){
    if(M_h + M[i].first<0){
      cout << "No" << endl;
      return 0;
    }
    M_h = M_h + M[i].second;
  }
  if(M_h == P_h){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 18940
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int R = sc.nextInt();
		int G = sc.nextInt();
		int B = sc.nextInt();
		int N = sc.nextInt();

		int ans = 0;
		for (int r = 0; r <= N / R; r++) {
			for (int g = 0; g <= N / G; g++) {
				int x = r * R + g * G;
				if (x <= N && (N - x) % B == 0) {
					ans++;
				}
			}
		}

		out.println(ans);

		sc.close();

	}

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

}


Measured memory_bytes: 21844
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        int A[] = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        // i 以前のAiの最小値
        int min[] = new int[N];
        min[0] = A[0];
        for (int i = 1; i < N; i++) {
            if (A[i] < min[i-1]) {
                min[i] = A[i];
            } else {
                min[i] = min[i-1];
            }
        }
        // i 以降のAiの最大値
        int max[] = new int[N];
        max[N-1] = A[N-1];
        for (int i = N - 2; i >= 0; i--) {
            if (A[i] > max[i+1]) {
                max[i] = A[i];
            } else {
                max[i] = max[i+1];
            }
        }
        // 最大の価格差
        int maxgap = 0;
        for (int i = 0; i < N; i++) {
            if (maxgap < max[i] - min[i]) {
                maxgap = max[i] - min[i];
            }
        }
        // maxgapを作る場所の数を算出
        // 連続したものはカウントしない
        int prevmax = 0; // ひとつ前のmax
        int prevmin = 0; // ひとつ前のmin
        int count = 0;
        for (int i = 0; i < N; i++) {
            if (max[i]-min[i]==maxgap && (prevmax!=max[i] || prevmin!=min[i])) {
                count++;
            }
            prevmax = max[i];
            prevmin = min[i];
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 33792
// Created by abhay
#include <bits/stdc++.h>
#define ll long long
#define mq 1000000007
using namespace std;
const int INF = 1e9 + 5;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	ll k;
	cin>>k;
	ll h[n];
	for (ll i = 0; i < n; i++)
		cin >> h[i];
	vector<ll> dp(n, INF);
	dp[0] = 0;
	for (ll i = 0; i < n; i++)
	{
		for (ll j = i + 1; j <= i + k; j++)
		{
			dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello
{
    public static void Main()
    {
        //入力を保持する
        var input = Console.ReadLine().Split().Select(e => int.Parse(e)).ToArray();
        var ans = 0;
        for (var n = 1; n <= input.Length; n++)
        {
            if (input[n - 1] == 0)
            {
                ans = n;
                break;
            }
        }
        Console.WriteLine(ans);

    }
}


Measured memory_bytes: 27712
#include <cstdio>
#include <queue>
#include <algorithm>
#include <ctype.h>
#define DEBUG
const int bufSize = 1e6;
using namespace std;
inline char nc()
{
    #ifdef DEBUG
    return getchar();
    #endif
    static char buf[bufSize],*p1 = buf,*p2 = buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,bufSize,stdin),p1==p2)?EOF:*p1++;
}
template<typename T>
inline T read(T &r)
{
    static char c;
    r=0;
    for(c = nc();!isdigit(c);) c = nc();
    for(;isdigit(c);c=nc()) r = r * 10 + c - 48;
    return r;
}
const int maxn = 2e5 + 100;
int T,n,anum,bnum;
struct node
{
    int L,R,K;
    bool operator<(const node &b)
    {
        return K < b.K;
    }
}A[maxn],B[maxn];
priority_queue<int,vector<int>,greater<int> > q1,q2;
int main()
{
    read(T);
    while(T--)
    {
        anum = bnum = 0;
        long long ans = 0;
        read(n);
        for(int i = 1;i<=n;++i) 
        {
            int k,l,r;
            read(k),read(l),read(r);
            if (l > r) A[++anum].L = l, A[anum].R = r, A[anum].K = k;
            else B[++bnum].L = l, B[bnum].R = r, B[bnum].K = n - k;
            ans += std::min(l,r);
        }
        sort(A + 1,A + 1 + anum),sort(B + 1,B + 1 + bnum);
        for(int i = 1;i<=anum;++i)
        {
            if(A[i].K == 0) continue;
            if(q1.size() < A[i].K) q1.push(A[i].L - A[i].R);
            else if(q1.size() == A[i].K && q1.top() < A[i].L - A[i].R) 
                q1.pop(),q1.push(A[i].L - A[i].R);
        }
        for (int i = 1; i <= bnum; ++i)
        {
            if(B[i].K == 0) continue;
            if(q2.size() < B[i].K) q2.push(B[i].R - B[i].L);
            else if(q2.size() == B[i].K && q2.top() < B[i].R - B[i].L) 
                q2.pop(),q2.push(B[i].R - B[i].L);
        }
        while(!q1.empty()) ans += q1.top(),q1.pop();
        while(!q2.empty()) ans += q2.top(),q2.pop();
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 5980
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;


vector<mint> mpow, ones;
struct S{
    mint value;
    int size;
};
using F = int;
const F ID = 1e6;
S op(S a, S b){ return {a.value*mint(10).pow(b.size)+b.value, a.size+b.size}; }
S e(){ return {mint(0), 0}; }
S mapping(F f, S x){
    if(f != ID) x.value = f*ones[x.size];
    return x;
}
F composition(F f, F g){ return (f == ID ? g : f); }
F id(){ return ID; }

void Main()
{
    int n, q;
    cin >> n >> q;
    std::vector<S> v(n, {mint(1), 1});
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);

    mpow.resize(n);
    mpow[0] = 1;
    for (int i = 0; i < n-1; i++)
    {
        mpow[i+1] = mpow[i]*10;
    }
    ones.resize(n+1);
    for (int i = 0; i < n+1; i++)
    {
        ones[i+1] = ones[i]*10+1;
    }
    
    for (int i = 0; i < q; i++)
    {
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        seg.apply(l, r, d);
        cout << seg.all_prod().value.val() << endl;
    }
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 11356
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  for(ll i = 1; i<=n; i++) {
    ll a = i;
    if(a%3!=0 && a%5!=0) ans += a;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
x = int(input())
A = list(map(int, input().split()))

kabu=0
money=1000
x=x-1
lastday=0
for i in range(len(A)):
    if A[x-i]>A[x-i-1]:
        lastday=x-i
        break
    
for i in range(lastday):
    if A[i]<A[i+1]:
        buy=money//A[i]
        money-=A[i]*buy
        kabu+=buy
    elif A[i]>A[i+1]:
        money+=A[i]*kabu
        kabu=0

money+=A[lastday]*kabu
print(money)
        

Measured memory_bytes: 9208
import numpy as np
N,K,Q = map(int,input().split())
P = np.array(N*[K])

for q in range(Q):
  a = int(input())
  P[a-1]+=1
  P-=1

for n in range(N):
  if P[n]<=0:
    print("No")
  else:
    print("Yes")

Measured memory_bytes: 28084
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli n;
mat t;
vll a;
vll b;
string ans;

void dfs(lli& i,lli r,lli l){
    for(lli j = r;j <= l;j++){
        if(b[j] == a[i]){
            i++;
            dfs(i,r,j-1);
            dfs(i,j+1,l);
            ans += to_string(b[j]) + " ";
        }
    }
}

int main(){
    cin >> n;
    t = mat(n+1,vll(2));
    a = vll(n);b = vll(n);
    for(lli i = 0;i < n;i++) cin >> a[i];
    for(lli i = 0;i < n;i++) cin >> b[i];
    for(lli i = 0;i < n;i++){
        if(b[i] == a[0]){
            lli x = 0;
            dfs(x,0,n-1);
        }
    }
    ans.pop_back();
    cout << ans << endl;
    return 0;
}

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

#define HUNDRED 100
#define THOUSAND 10000
#define TENTHOUSAND 10000
#define HUNDREDTHOUSAND 100000

int main() {
	string s;
	string t;

	cin >> s;

	for (int i = 0; s[i] != '\0'; i++) {
		if (i % 2 == 0) {
			t.push_back(s[i]);
		}

	}
	cout << t;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

ll C[51][51]; // C[n][k] -> nCk

void comb_table(int N){
    for(int i=0; i<=N; i++){
        for(int j=0; j<=i; j++){
            if(j==0 || j==i) C[i][j] = 1LL;
            else C[i][j] = (C[i-1][j-1]+C[i-1][j]);
        }
    }
}

int main(){
    int N, A, B; cin >> N >> A >> B;
    vector<ll> v(N);
    for(int i=0; i<N; i++) cin >> v[i];

    sort(v.begin(), v.end(), greater<ll>());

    int db = v[A-1];
    double mean = 0.0;
    for(int i=0; i<A; i++) mean += v[i];
    mean /= A;

    comb_table(50);


    ll ans = 0;
    if(v[0] == v[A-1]){
        int cnt = 0;
        for(int i=0; i<N; i++) if(v[i] == v[0]) cnt++;
        for(int i=A; i<=min(cnt, B); i++) ans += C[cnt][i];
    }
    else{
        int l = 0;
        int k = 0;
        for(int i=0; i<=A-1; i++) if(v[i] == v[A-1]) l++;
        for(int i=0; i<N; i++) if(v[i] == v[A-1]) k++;

        //printf("l = %d\n", l);
        //printf("k = %d\n", k);

        ans += C[k][l];
    }

    printf("%.8lf\n", mean);
    cout << ans << endl;
    
}

Measured memory_bytes: 256