akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main(){
  string str;
  cin >> str;
  str.push_back(' ');

  int ans = 0;
  int dps = 0;
  for(auto i : str){
    switch(i){
      case 'S':
        dps++;
        break;
      case 'T':
        if(dps == 0){
          ans += 1;
        }else{
          dps--;
        }
    }
  }

  cout << ans + dps << endl;;
}


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

#define int long long
#define endl '\n'

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    int ans = 1;
    set<int> s;
    int x = 7;
    s.insert(x);
    int n; cin>>n;
    while(1) {
        if (x%n == 0) return cout<<ans, 0;
        x = (x*10+7)%n;
        if (s.count(x)) return cout<<-1, 0;
        s.insert(x);
        ans++;
    }
}

Measured memory_bytes: 50476
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    vector<P> A(N);
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        A[i] = P(x, y);
    }

    vector<int> B(N);
    for (int i = 0; i < N; i++) B[i] = i;

    double ret = 0;

    do {
        double sum = 0;
        for (int i = 0; i < N - 1; i++) {
            P before = A[B[i]];
            P after = A[B[i+1]];
            sum += sqrt((before.first - after.first) * (before.first - after.first) + (before.second - after.second) * (before.second - after.second));
        }

        ret += sum;
    } while (next_permutation(B.begin(), B.end()));

    double d = 1;
    for (int i = 1; i <= N; i++) d *= i;

    ret /= d;
    cout << setprecision(10) << fixed << ret << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>   
#include<math.h>
#include<string> 
#include<set>  
using namespace std;    
int main()   
{   
string a[3];
for(int i=0;i<3;i++)
cin>>a[i];
cout<<a[0][0]<<a[1][1]<<a[2][2]; 
system("pause");
return 0;  
}
  

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

using namespace std;

using ll = long long;

ll Solve() {
    ll n, k;
    cin >> n >> k;

    int len = log2(k) + 1;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] != 0) len = max(len, (int)log2(a[i]) + 1);
    }

    vector<ll> sum(len + 1);
    vector<vector<ll>> f(len + 1, vector<ll>(2));
    for (ll i = 0; i < len; ++i) {
        ll value = 1ll << i;
        for (ll j = 0; j < n; ++j)
            f[i][!(a[j] >> i & 1)] += value;
        sum[i] = max(f[i][0], f[i][1]);
    }

    for (int i = 1; i < len; ++i) sum[i] += sum[i - 1];

    ll res = 0, add = 0;
    for (ll i = len - 1; 0 <= i; --i) {
        if (k >> i & 1) { // k の i ビット目が 1
            // 0 を選んで i + 1 ビット目以降貪欲的に選ぶ
            ll score = add + f[i][0];
            if (0 < i) score += sum[i - 1];
            res = max(res, score);

            add += f[i][1];
        }
        else { // k の i ビット目が 0
            add += f[i][0];
        }
    }

    return max(res, add);
}

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

    cout << Solve() << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

vector<int> generatePrime(int n) {
    vector<int> prime;
    vector<bool> v(n + 1, true);
    v[0] = false;
    v[1] = false;

    for (int i = 2; i < (int)v.size(); i++) {
        if (v[i] == false)
            continue;

        prime.push_back(i);
        for (int j = i + i; j < (int)v.size(); j += i)
            v[j] = false;
    }

    return prime;
}

int main(void)
{
    int X;
    cin >> X;

    vector<int> prime = generatePrime(X * 2);
    int ans = *lower_bound(prime.begin(), prime.end(), X);
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int i,n;cin>>n;
  vector<int> l(n);
  for(i=0; i<n; ++i) cin>>l[i];
  
  int a,b,c,cnt=0;
  for(a=0; a<n; ++a)
    for(b=a+1; b<n; ++b)
      for(c=b+1; c<n; ++c)
        if(l[a]!=l[b]&&l[a]!=l[c]&&l[b]!=l[c]&&l[a]+l[b]>l[c] && l[a]+l[c]>l[b] && l[b]+l[c]>l[a]) ++cnt;
  cout<<cnt<<endl;
  return 0;
}

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

using namespace std;

int main() {
    vector<int> a(3,100);
    for (int i = 0; i < 3; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    cout << a[0] + a[1];

    return 0;
}

Measured memory_bytes: 256
H, W, N = map(int, input().split())
d = 10**9+1
L = []
S = set()
for _ in range(N):
    a, b = map(int, input().split())
    S.add((a, b))
Map =[[0]*5 for _ in range(5)]
ans = [0]*10
for i in S:
    a, b = i
    for i in range(-2, 3):
        for j in range(-2, 3):
            a1, b1 = a+i, b+j

            if (1<=a1<=H) and (1<=b1<=W):
                if (a1, b1) in S:
                    Map[i+2][j+2] = 1
                else:
                    Map[i+2][j+2] = 0
            else:
                Map[i+2][j+2] = -100
    for i in range(-1, 2):
        for j in range(-1, 2):
            res = 0
            for k in range(3):
                for l in range(3):
                    res+=Map[i+1+k][j+1+l]
            if res>=0:
                ans[res]+=1
for i in range(1, 10)[::-1]:
    ans[i] //=i
ans[0] = (W-2)*(H-2)-sum(ans)
for i in ans:
    print(i)

Measured memory_bytes: 58908
import java.util.*;
 
public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        String S = sc.next();
        String T = sc.next();
        sc.close();
        Map<Character, Character>map1 = new HashMap<>();
        for(int i = 0; i < S.length(); i++){
            if(!(map1.containsKey(S.charAt(i)))){
                map1.put(S.charAt(i), T.charAt(i));
            } else {
                if(map1.get(S.charAt(i)) != T.charAt(i)){
                    System.out.println("No");
                    return;
                }
            }
        }

        Map<Character, Character>map2 = new HashMap<>();
        for(int i = 0; i < S.length(); i++){
            if(!(map2.containsKey(T.charAt(i)))){
                map2.put(T.charAt(i), S.charAt(i));
            } else {
                if(map2.get(T.charAt(i)) != S.charAt(i)){
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 28124
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define fi first
#define se second


int main() {
    int n;
    cin>>n;
    vector<int>a(n);
    vector<int>b(n);
    vector<int>c(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    sort(a.begin(),a.end());
    // sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll ans=0;

    for(int i=0;i<n;i++){
        auto x = lower_bound(a.begin(),a.end(),b[i]);
        auto y = lower_bound(c.begin(),c.end(),b[i]+1);
        ans+=(x-a.begin())*(c.end()-y);
    }
    cout<<ans<<endl;


    return 0;
}


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

int main() {
    
    int N, T;
    cin >> N >> T;
    int t[N];
    for(int i = 0; i < N; i++){
        cin >> t[i];
    }

    int total = 0;
    for(int i = 1; i <= N; i++){
        if(i == N){
            total += T;
        } else {
            int dt = t[i] - t[i-1];
            if(dt < T){
                total += dt;
            } else {
                total += T;
            }
        }
   }
    cout << total << endl;

    return 0;
}
    

Measured memory_bytes: 4336
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 1;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll MOD =  1000000007;
const ll INF =  1LL << 60;
ll n, m, x = 0, y,z,w,h, sum= 0, ans = 0;
string s, t;
int main() {
	cin >> n; vector<int> a(n), b(n), c(n);
	rep(i, n) cin >> a[i];
	rep(i, n) {
		cin >> b[i];
		c[i] = i +1 ;
	}
	do {
		rep(i, n) {
			if (c[i] != a[i]) break;
			if (i == n - 1) sum = x;
		}
		rep(i, n) {
			if (c[i] != b[i]) break;
			if (i == n - 1) ans = x;
		}
		x++;
	} while (next_permutation(ALL(c)));
	cout << abs(sum - ans) << endl;
}

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

static const int N = 1000;

int lcs(string X, string Y){
    int c[N+1][N+1];
    int m = X.size();
    int n = Y.size();
    int maxl =0;

    X = ' ' + X; // X[0]に空白を挿入
    Y = ' ' + Y; // Y[0]に空白を挿入
    for(int i=0; i<=m; i++) c[i][0] = 0;
    for(int j=1; j<=n; j++) c[0][j] = 0;

    for(int i=1; i<=m; i++){// 全通りの組み合わせを試している？
        for(int j=1; j<=n; j++){
            if(X[i] == Y[j]){
                c[i][j] = c[i-1][j-1] + 1;
            }
            else{
                c[i][j] = max(c[i-1][j], c[i][j-1]);
            }
            maxl = max(maxl, c[i][j]);
        }
    }
    return maxl;
}

int main(int argc, char const *argv[])
{
    string s1, s2;
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> s1 >> s2;
        cout << lcs(s1, s2) << endl;
    }
    return 0;
}



Measured memory_bytes: 6932
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <utility>
#include <vector>
#include <atcoder/all>

template <class InputIterator>
std::ostream& range_output(std::ostream& os_arg, InputIterator first_arg, InputIterator last_arg){ if(first_arg != last_arg){ do{ os_arg << *(first_arg++); if(first_arg == last_arg) break; os_arg << ' '; } while(true); }  return os_arg; }
template <class Tp> std::ostream& operator << (std::ostream& os_arg, const std::vector<Tp>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class Tp, std::size_t Size> std::ostream& operator << (std::ostream& os_arg, const std::array<Tp, Size>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class S, class T> std::ostream& operator << (std::ostream& os_arg, const std::pair<S, T>& pair_arg){ return os_arg << '(' << pair_arg.first << ", " << pair_arg.second << ')'; }

#ifndef ONLINE_JUDGE
    template <typename Head> void dump_out(Head head_arg){ std::cerr << head_arg << '\n'; }
    template <typename Head, typename... Tail>
    void dump_out(Head head_arg, Tail... tail_args){ std::cerr << head_arg << ", "; dump_out(tail_args...); }
    #define dump(...) do { std::cerr << "[in line " << __LINE__ << "] " << #__VA_ARGS__ << " : "; dump_out(__VA_ARGS__); } while(false)
#else
    #define dump(...) (void(0))
#endif




int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);
    int n, m; std::cin >> n >> m;
    atcoder::scc_graph graph(n);
    for(int i = 0; i < m; ++i){
        int u, v; std::cin >> u >> v;
        graph.add_edge(u, v);
    }
    const auto res = graph.scc();
    std::cout << res.size() << '\n';
    for(const auto& vec : res){
        std::cout << vec.size();
        for(const int v : vec) std::cout << ' ' << v;
        std::cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 40112
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int t1 = h1 * 60 + m1;
    int t2 = h2 * 60 + m2;

    cout << t2 - t1 - k << endl;

    return 0;
}


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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(auto &i:a)cin >> i;
	set<int> H,W;
	H.insert(n);
	W.insert(n);
	vector<int> b(n);
	for(int i = 0;i<n;i++)
		b[a[i]-1]=i;
	ll ans = 0;
	for(int i = 0;i<n;i++)
	{
		ll now = 0;
		now = *H.lower_bound(b[i])-b[i];
		now *= *W.lower_bound(n-b[i]-1)-(n-b[i]-1);
		H.insert(b[i]);
		W.insert(n-b[i]-1);
		ans += now*(1+i);

	}
	cout<<ans<<endl;

}


Measured memory_bytes: 23552
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char S[2000020];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	fread(S, 1, 2000020, stdin);

	char* c = S, ct;
	int N = 0;
	
	while ((ct = *c++) >= '0') N = N * 10 + ct - '0';

	int L = 0, R = 2000001;
	while (L + 1 < R) {
		int M = (L + R) / 2;
		if (*(c + M) >= ' ') L = M;
		else R = M;
	}

	if (*c == '0') {
		printf("0\n");
		return 0;
	}

	int zero = 0;
	int n = R / 8 + 1;
	for (char* d = c; d < c + R - 8; d += 7) {
		ll tmp = *(ll*)(d);
		tmp += 0x1010101010101010;
		tmp ^= 0xcfcfcfcfcfcfcfcf;

		ll tmp2 = tmp + 0x0001000100010001;
		if ((tmp2 << 1 ^ tmp2) & 0x2000200020002000) {
			printf("0\n");
			return 0;
		}
		tmp2 = tmp + 0x0000010001000100;
		if ((tmp2 << 1 ^ tmp2) & 0x0020002000200000) {
			printf("0\n");
			return 0;
		}
	}

	for (char* d = c + min(0, R - 10); d < c + R; d++) {
		if (*d == ' ' && *(d + 1) == '0') {
			printf("0\n");
			return 0;
		}
	}

	if (R >= N * 2 + 18) {
		printf("-1\n");
		return 0;
	}

	ll kotae = 1;
	auto owa = c + R;
	while (c < owa) {
		ll tmp = *(ll*)(c);
		if (tmp != 0x2031203120312031) {
			ll k = 0;
			while ((ct = *c++) >= '0') k = k * 10 + ct - '0';
			if (ll(1e18) / kotae < k) {
				printf("-1\n");
				return 0;
			}
			else kotae *= k;
		}
		else c += 8;
	}

	printf("%lld\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 3312
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		char table[] = new char[128];
		table['A'] = 'T';
		table['T'] = 'A';
		table['G'] = 'C';
		table['C'] = 'G';

		System.out.println(table[sc.next().charAt(0)]);
	}

}


Measured memory_bytes: 20564
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    print('x' * len(s))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
    int a,b;
    string s;
    cin >> a >> b;
    cout << (a-1) * (b-1) << endl; 
    
    
    return 0;
}

Measured memory_bytes: 256
h,w=gets.split.map(&:to_i)
s=[]
c=0
h.times do
  s << gets.chomp
  c+=s[-1].count(".")
end
k=1
q=[[0,0]]
s[0][0]="#"
while s[-1][-1]=="."
  if q==[]
    puts "-1"
    exit
  end
  z=[]
  q.each do |i,j|
    if i>0&&s[i-1][j]=="."
      z << [i-1,j]
      s[i-1][j]="#"
    end
    if j>0&&s[i][j-1]=="."
      z << [i,j-1]
      s[i][j-1]="#"
    end
    if i<h-1&&s[i+1][j]=="."
      z << [i+1,j]
      s[i+1][j]="#"
    end
    if j<w-1&&s[i][j+1]=="."
      z << [i,j+1]
      s[i][j+1]="#"
    end
  end
  q=z.dup
  k+=1
end
puts c-k


Measured memory_bytes: 1788
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        List<int> input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        int n = input[0];
        int a = input[1];
        int b = input[2];
        
        int output = Enumerable.Range(1, n)
            .Where(x => a <= DigitsSum(x) && DigitsSum(x) <= b)
            .Sum();

        Console.WriteLine(output);
    }

    static int DigitsSum(int num) =>
        num.ToString().ToCharArray().Select(c => int.Parse(c.ToString())).Sum();
}

Measured memory_bytes: 15440
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
int b=scan.nextInt();
int c=scan.nextInt();
int d=0;
do{
	if(c%a==0){
		d++;
	}
	a++;
	if(a>b)break;
}while(true);
System.out.println(d);
scan.close();
	}
}

Measured memory_bytes: 26328
package main

import (
	"fmt"
	"strings"
)

func main() {

	var a string

	fmt.Scan(&a)

	i := 0

	for {
		var b string
		fmt.Scan(&b)

		if b == "END_OF_TEXT" {
			break
		}

		if strings.ToLower(b) == a {
			i++
		}

	}

	fmt.Println(i)
}



Measured memory_bytes: 1112
module Main where
 
import Control.Applicative
import Text.Printf
import Numeric
 
main :: IO ()
main = loop
 
loop :: IO()
loop = do
  {[as, os, bs] <- getStrings
  ; case os of
      "?" -> return ()
      "+" -> print(readInt' as + readInt' bs) >> loop
      "-" -> print(readInt' as - readInt' bs) >> loop
      "*" -> print(readInt' as * readInt' bs) >> loop
      "/" -> print(readInt' as `div` readInt' bs) >> loop
  }
--
   
getInts :: IO[Int]
getInts = map read . words <$> getLine
 
putInts :: [Int] -> IO()
putInts = putStrLn . unwords. map show
 
getDoubles :: IO[Double]
getDoubles = map read. words <$> getLine
 
putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble
 
showDouble :: Double -> String
showDouble x = showFFloat Nothing x ""
 
getStrings :: IO [String]
getStrings = words <$> getLine
 
readInt' :: String -> Int
readInt' = read


Measured memory_bytes: 4204
n,m,x = map(int,input().split())
ca = [[0]]*n
for i in range(n):
  ca[i] = list(map(int,input().split()))
minc = 10**10
for b in range(2**n):
  r = [0]*m
  c = 0
  for i in range(n):
    if b & (1<<i)>0:
      c += ca[i][0]
      for j in range(m):
        r[j] += ca[i][j+1]
  flag = True
  for j in range(m):
    if r[j] < x:
      flag = False
  if flag:
    minc=min(c,minc)
if minc < 10**9:
  print(minc)
else:
  print(-1)
  
      


Measured memory_bytes: 68380
k = int(input())
A,B = map(int,input().split())
x = B // k
y = A // k

if x - y >0:
    print('OK')
elif x - y == 0 :
    if A % k == 0 or B % k == 0:
        print('OK')
    else:
        print('NG')
else:
    print('NG')

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

int main() {
	int x;
	cin >> x;
	if (x < 600)
		cout << 8 << endl;
	else if (x < 800)
		cout << 7 << endl;
	else if (x < 1000)
		cout << 6 << endl;
	else if (x < 1200)
		cout << 5 << endl;
	else if (x < 1400)
		cout << 4 << endl;
	else if (x < 1600)
		cout << 3 << endl;
	else if (x < 1800)
		cout << 2 << endl;
	else
		cout << 1 << endl;
}


Measured memory_bytes: 3616
#include<iostream>
#define max 1000010
using namespace std;

bool isp[max];
int ans[max]={};

void sieve(){
	for(int i=0;i<max;i++)isp[i]=true;
	for(int i=2;i<max;i++){
		if(isp[i]){
			ans[i]++;
			for(int j=2*i;j<max;j+=i)isp[j]=false;
		}
	}
	for(int i=1;i<max;i++)ans[i]+=ans[i-1];
	return;
}

int main()
{
	int n;

	sieve();
	while(cin>>n)cout<<ans[n]<<endl;

	return 0;
}

Measured memory_bytes: 6044
#include<stdio.h>
int main(void)
{
	int a[10000];
	int i,n;
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf("%d",&a[i]);
	}
	for(i = n-1;i >= 0;i--){
		printf("%d",a[i]);
		if(i != 0){
			printf(" ");
		}
	}
		printf("\n");
	return 0;
}

Measured memory_bytes: 608
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
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;
}

//////////////////////////

bool jun(ll a,ll b,ll c){
    if((c-b)*(b-a)>=0)return true;
    return false;
}



int main(){fastio
    dd PI=acos((dd)-1.0);
    dd minus=20-PI*5;
    dd plus=10*PI-20;
    ll x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
    dd sum=abs(x2-x1)+abs(y1-y2);
    sum*=100;
    
    bool hanx=false,hany=false;
    if(x1>x2){hanx=true;x1*=-1;x2*=-1;}
    if(y1>y2){hany=true;y1*=-1;y2*=-1;}
    ll n;cin>>n;
    vector<ll>x,y;
    vector<l_l>p;
    rep(i,0,n-1){
        ll X,Y;cin>>X>>Y;
        if(hanx)X*=-1;
        if(hany)Y*=-1;
        if(jun(x1,X,x2)&&jun(y1,Y,y2)){
            p.pb({X,Y});
        }
    }
    SORT(p);
    /*
    for(auto x:p)cout<<x.fi<<" "<<x.se<<endl;
    cout<<x1<<" "<<y1<<endl;
    cout<<x2<<" "<<y2<<endl;
     */
    const ll N=200005;
    vector<ll>LIS(N);
    rep(i,0,N-1)LIS[i]=inf;
    for(auto x:p){
        ll y=x.se;
        ll pos=POSL(LIS,y);
        LIS[pos]=y;
    }
    //rep(i,0,N-1)cout<<LIS[i]<<" ";cout<<endl;
    ll gen=POSL(LIS,inf);
   // cout<<gen<<endl;
    ll sho=min(abs(x2-x1),abs(y2-y1));
    
    if(sho+1==gen){
        
        cout<<setprecision(20)<<sum-(gen-1)*minus+plus<<endl;
    }else{
        
        cout<<setprecision(20)<<sum-gen*minus<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 6256
n=int(input())
a=list(map(int,input().split()))
from itertools import accumulate
ac=list(accumulate(a))
ac.insert(0,0)

d={}
for i in ac:
    d[i]=d.get(i,0)+1

ans=0
for i in d.values():
    if i>=2:
        ans+=i*(i-1)//2
print(ans)

Measured memory_bytes: 41356
implicit none
INTEGER :: n,i,j,count,a,b,keta_sum,s_int
CHARACTER(5) :: s
READ(5,*) n,a,b

count = 0

do i=1,n
    keta_sum = 0
    WRITE(s,"(i0)") i

    do j=1,len(s)
        if (s(j:j)/="") then
            READ(s(j:j),*) s_int
            keta_sum = keta_sum+s_int
        endif
    enddo

    if (keta_sum>=a .and. b>=keta_sum) then
        count = count+i
    endif

enddo

WRITE(6,*) count

end


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderTest
{
    class ABC163B
    {
        public static int readLineAsInt()
        {
            var line = Console.ReadLine();
            return int.Parse(line);
        }

        public static List<int> readLineAsListOfInt()
        {
            var line = Console.ReadLine();
            return line.Split(' ').Select(x => int.Parse(x)).ToList();
        }

        public static List<List<int>> readLinesAsTableOfInt(int N)
        {
            var ret = new List<List<int>>();
            for (int i = 0; i < N; ++i)
                ret.Add(readLineAsListOfInt());

            return ret;
        }

        public static List<int> readLinesAsListOfIntFromColumn(int N)
        {
            var ret = new List<int>();
            for (int i = 0; i < N; ++i)
                ret.Add(readLineAsListOfInt()[0]);

            return ret;
        }

        static void Main(string[] args)
        {
            var N_M = readLineAsListOfInt();
            var As = readLineAsListOfInt();
            var res = core(N_M[0], N_M[1], As);

            Console.Write(res.ToString());
        }

        static int core(int N, int M, List<int> As)
        {
            var AsSum = As.Sum();

            if (AsSum > N)
                return -1;
            if (AsSum == N)
                return 0;

            return N - AsSum;
        }

    }
}


Measured memory_bytes: 20384
#include<iostream>
using namespace std;
int main()
{
    long n, m;   cin >> n >> m;
    long X[n], Y[m];
    long xans, yans;
    long mod1 = 1000000007;
    long long ans;

    for(int i=0; i<n; i++){
        int x;  cin >> x;
        X[i] = x;
    }
    for(int j=0; j<m; j++){
        int y;  cin >> y;
        Y[j] = y;
    }
    long x1 = X[0];
    long x2 = X[1];
    long dx = x2 - x1;
    long y1 = Y[0];
    long y2 = Y[1];
    long dy = y2 - y1;
    long xsum = dx;
  	long ysum = dy;
    if(n > 2){
        for(int i=2; i<n; i++){
            dx += (X[i] - X[i-1])*i;
            xsum += dx;
            xsum = xsum%mod1;
        }
    }
    if(m > 2){
        for(int i=2; i<m; i++){
            dy += (Y[i] - Y[i-1])*i;
            ysum += dy;
            ysum = ysum%mod1;
        }
    }
    ans = xsum*ysum;
    cout << ans%mod1;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline LL read()
{
    LL x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

const LL MOD=1e9+7;
LL qmod(LL a, LL b)
{
    if (b == 0) return 1;
    LL r = a % MOD;
    LL k = 1;
    while (b > 1){
        if ((b & 1)!=0)
            k = (k * r) % MOD;
        r = (r * r) % MOD;
        b >>= 1;
    }
    return (r * k) % MOD;
}

const int maxn=1e5+7;
int inv[maxn];

int main()
{
    int n=read();
    LL f=1;
    for(int i=1;i<=n;i++)f=(f*i)%MOD;
    for(int i=1;i<=n;i++)inv[i]=qmod(i,MOD-2);
    for(int i=1;i<=n;i++)inv[i]=(inv[i-1]+inv[i])%MOD;
    LL ans=0;
    for(int i=1;i<=n;i++){
        LL x=read();
        LL as=(x*((inv[i]+inv[n-i+1]-inv[1])%MOD))%MOD;
        ans=(ans+as)%MOD;
    }
    printf("%lld\n",(ans*f)%MOD);
    return 0;
}


Measured memory_bytes: 640
# 入力 : 縦並びの数字N個
N, L = map(int, input().split())
list_A = [0 for i in range(0,N)]
for i in range(0,N) :
    list_A[i] = input()

list_A.sort()
ans = "".join(list_A)
print(ans)


Measured memory_bytes: 3060
using System;
namespace Atcoder
{
    class AtCoderContest
    {
        static void Main()
        {
            string input = Console.In.ReadToEnd();
            string[] S = input.Split(',');
            int count = 0;
            string answer = "";
            while (count <= (S.Length) -1)
            {
                answer = answer + S[count] + " ";
                count++;
            }
            answer = answer.Remove(19);
            Console.Write(answer);
        }
    }
}



Measured memory_bytes: 11092
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

"""
nC3
|b - c| < a < |b + c|

nC2
b_i, c_iを除くiの中で|b-c|< a <b+cを満たすaの数をタス
"""

N = int(input())
L = LI()
L.sort()

ans = 0
for i in range(N - 1, -1, -1):
    for j in range(i - 1, -1, -1):
        ans += j - bisect.bisect_right(L[:j], L[i] - L[j])
print(ans)

Measured memory_bytes: 77528
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
const long double Pi=acos(-1);
int main(){
  ll A,B,C;
  cin>>A>>B>>C;
  if(A+B+C>=22){cout<<"bust"<<endl;}
  else{cout<<"win"<<endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;
const double PI = acos(-1);

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

  vector<bool> chk(n, true);
  for(int i = 0; i < m; i++){
    int a,b; cin >> a >> b;
    a--; b--;
    if(h[a] <= h[b]) chk[a] = false;
    if(h[b] <= h[a]) chk[b] = false;
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(chk[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3660
package main

import (
	"fmt"
)

func main() {


	var N int

	fmt.Scan(&N)

	a := SliceInt(N)

	for i:=0;i<N;i++{
		
		fmt.Scan(&a[i])
	}

	cnt:=0

	result := make(map[string]int)

	for i:=0;i<N;i++{

		if 1 <= a[i] && a[i]<400{

			val,ok := result["G"]

			if ok ==true{

				result["G"] = val +1
			}else{
				result["G"] = 1
			}			

		}else if a[i]<800{

			val,ok := result["T"]

			if ok ==true{

				result["T"] = val +1
			}else{
				result["T"] = 1
			}

		}else if a[i]< 1200{

			val,ok := result["GR"]

			if ok ==true{

				result["GR"] = val +1
			}else{
				result["GR"] = 1
			}

		}else if a[i] < 1600{

			val,ok := result["M"]

			if ok ==true{

				result["M"] = val +1
			}else{
				result["M"] = 1
			}
		
		}else if a[i] < 2000{

			val,ok := result["B"]

			if ok ==true{

				result["B"] = val +1
			}else{
				result["B"] = 1
			}

		}else if a[i] < 2400{

			val,ok := result["Y"]

			if ok ==true{

				result["Y"] = val +1
			}else{
				result["Y"] = 1
			}

		}else if a[i] < 2800{

			val,ok := result["O"]

			if ok ==true{

				result["O"] = val +1
			}else{
				result["O"] = 1
			}

		}else if a[i] < 3200{

			val,ok := result["R"]

			if ok ==true{

				result["R"] = val +1
			}else{
				result["R"] = 1
			}
		
		}else if a[i] >=3200{

			cnt++

		}

	}

	var min,max,temp int

	if len(result) >0{

		min = len(result)
	
	}else{

		min = 1

	}

	if len(result) < N{

		temp = len(result) + cnt
	}

	if temp <=N{

		max=  temp

	}else{
		max =N
	}


	fmt.Println(min," ",max)

}

//SliceInt 引数サイズのSliceを返す
func SliceInt(a int) []int {

	IntSample := make([]int, a)

	return IntSample

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
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; }
const ll MOD = 1e9+7;

vector<tuple<int, int, int> > ANS;

int main(){
    ll L;
    cin >> L;

    int n = 1;
    int t = 0;
    while(L >= n){
        n *= 2;
        t++;
    }
    n /= 2;

    //cout << n << endl;
    //cout << t << endl;

    n = 1;
    REP(i,t-1){
        ANS.emplace_back(i, i+1, 0);
        ANS.emplace_back(i, i+1, n);
        n *= 2;
    }

    for(int b = t-2; b >= 0; b--){
        bool bit = (L >> b) & 1;
        if(bit){
            ANS.emplace_back(b, t-1, n);
            n += (1LL << b);
        }
    }

    printf("%d %d\n", t, ANS.size());
    for(auto&& ans : ANS){
        int a = get<0>(ans);
        int b = get<1>(ans);
        int c = get<2>(ans);
        printf("%d %d %d\n", a+1, b+1, c);
    }
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    cout << a + (b-a)*2 << endl;

    return 0;
}

Measured memory_bytes: 3624
/*
貪欲
後ろから見る
DP
順位表をチェック
二分探索


*/
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
#include<set>
using namespace std;
#define INF 1100000000000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair< pair<int,int>,pair<int,int> > p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());

ll h[40];

int main(){
    int N;
    cin>>N;
    map<ll,int> M;
    priority_queue<ll> que;
    for(int i=0;i<N;i++){
        ll a;
        cin>>a;
        que.push(a);
        M[a]++;
    }
    h[0]=1;
    for(int i=1;i<=35;i++){
        h[i]=h[i-1]*2;
    }
    int ans=0;
    for(int i=0;i<N;i++){
        ll t=que.top(); que.pop();
        if(M[t]==0) continue;
        M[t]--;
        for(int i=0;i<=35;i++){
            if(M.find(h[i]-t)!=M.end() && M[h[i]-t]>0){
                M[h[i]-t]--;
                ans++;
                break;
            }
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 14320
import math

def is_prime(n):
    if n == 1:
        return False
    for k in range(2, int(math.sqrt(n))+ 1):
        if n % k == 0:
            return False
    return True

n = int(raw_input())
while True:
    if is_prime(n):
        print n
        break
    n += 1

Measured memory_bytes: 2568
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var s string
    fmt.Scan(&s)
    a := make([]int, 20)
    sz := 0
    for i:=0;i<len(s);i++{
        switch{
            case s[i]=='0':
                a[sz]=0
                sz++
            case s[i]=='1':
                a[sz]=1
                sz++
            case s[i]=='B':
                if sz!=0{
                    sz--
                }
        }
    }
    for i:=0;i<sz;i++{
        fmt.Printf("%d",a[i])
    }
    fmt.Printf("\n")
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func makeTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func sortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}

func reverseString(s string) string{
    t := []rune(s)
    for i,j := 0, len(s)-1 ; i < j ; i, j = i+1, j-1 {
        t[i], t[j] = t[j], t[i]
    }
    return string(t)
}

func inside(h,w,H,W int) bool{
    if h>=0 && h<H && w>=0 && w<W{
        return true
    }
    return false
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e15;

int main() {
  ll n,k;
  cin >> n >> k;
  vector<pll> a(n);
  for(ll i=0;i<n;i++) {
    ll p,q;
    cin >> p >> q;
    a[i]={p,q};
  }
  sort(a.begin(),a.end());
  ll cnt=0;
  for(ll i=0;i<n;i++) {
    cnt+=a[i].second;
    if(cnt>=k) {
      cout << a[i].first << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  string s, t;
  int count = 0;
  vector<int> l(26,-1), r(26, -1);
  cin >> s >> t;
  for (int i = 0; i < s.size(); i++) {
    int a = s[i]-'a', b = t[i]-'a';

    if (l[a] != -1 || r[b] != -1) {
      if (l[a] != b || r[b] != a) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      l[a] = b;
      r[b] = a;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 776
#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

n,k=map(int,input().split())
a=(n//k)**3
if k%2==1:
    print(a)
else:
    b=((n+(k//2))//k)**3
    print(a+b)

Measured memory_bytes: 38256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    int n; cin >> n;
    VI a(n); REP(i,n) cin >> a[i]; SORT(a); REVERSE(a);
    int b=0,c=0; REP(i,n) if(i & 1) b+=a[i]; else c+=a[i];
    out(c-b);

    return 0;
}

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

const int N = 100005;

int n, dsu[N];
long long f[N];
vector<int> adj[N];

struct edge {
    int u, v, c;
} e[N];

int trace(int u) {
    return dsu[u] < 0 ? u : dsu[u] = trace(dsu[u]);
}

void connect(int u, int v, int c) {
    u = trace(u); v = trace(v);
    if (dsu[u] > dsu[v]) {
        swap(u, v);
    }
    adj[u].push_back(v);
    f[u] += -1LL * dsu[v] * c;
    f[v] -= f[u]; f[v] += -1LL * dsu[u] * c;
    dsu[u] += dsu[v];
    dsu[v] = u;
}

void DFS(int u) {
    for (int &v : adj[u]) {
        f[v] += f[u];
        DFS(v);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    fill(dsu + 1, dsu + n + 1, -1);
    for (int i = 1; i < n; i++) {
        cin >> e[i].u >> e[i].v >> e[i].c;
    }   
    sort(e + 1, e + n, [](const edge &u, const edge &v) {
        return u.c > v.c;
    });
    for (int i = 1; i < n; i++) {
        connect(e[i].u, e[i].v, e[i].c);
    }
    DFS(trace(1));
    for (int i = 1; i <= n; i++) {
        cout << f[i] << '\n';
    }
}


Measured memory_bytes: 7424
def solve(string):
    n = len(string)
    ans = [0] * n

    def op(string, ans, forward=True):
        count = 0
        check = "R" if forward else "L"
        sign, base = 2 * forward - 1, (n - 1) * (1 - forward)
        for i, a in enumerate(string[::sign]):
            if a == check:
                count += 1
                continue
            if count > 0:
                ans[base + sign * i] += count // 2
                ans[base + sign * (i - 1)] += (count + 1) // 2
                count = 0
        return ans

    ans = op(string, ans, True)
    return " ".join([str(a) for a in op(string, ans, False)])


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 10492
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a;
  string s;
  cin >> a >> s;
  ll b = 0;
  rep(i, s.size()) {
    if (s[i] == '.')
      continue;
    b *= 10;
    b += s[i]-'0';
  }
  cout << a*b/100 << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
 
int main (){
  int x;
  cin>>x;
  cout<<1-x;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,c=0;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    //sort(a,a+n);
    //for(i=0;i<n;i++)
    //cout<<a[i]<<" ";
    int maxx=0;
    for(i=0;i<n;i++)
    {
        if(a[i]>=maxx)
        {
            c++;
            maxx=a[i];
        }
    }
    cout<<c;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b := intScanner(), intScanner()
	if a%2 == 0 || b%2 == 0 {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}


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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
	int n, m;
	ll k;
	cin >> n >> m >> k;
	vector<ll> a(n);
	vector<ll> b(m);
	rep(i,n){
		cin >> a.at(i);
	}
	ll t = 0;
	rep(i, m){
		cin >> b.at(i);
	 	t += b.at(i);
	}
	int j = m;
	int ans = 0;
	rep(i,n+1){
		while(j > 0 && t > k){
			j--;
			t -= b.at(j);
		}
		if(t > k) break;
		ans = max(ans, i+j);
		if(i == n) break;
		t += a.at(i);
	}
	cout << ans << endl;

}


Measured memory_bytes: 6356