akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
char s[105][105];
int main(){
	int h,w;cin>>h>>w;
	for(int i=1;i<=h;i++) cin>>(s[i]+1);
	for(int i=1;i<=2*h;i++){
		for(int j=1;j<=w;j++){
			printf("%c",s[(i+1)/2][j]);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std;

const int N = 2e5 + 5, mo = 1e9 + 7, inf = 1e9;
int n, X, Y;
ll ans, fac[N], ivf[N], inv[N];
vector <int> co[N];
pair <int, int> mn, smn;

void prep () {
	fac[0] = 1, ivf[0] = 1;
	fac[1] = ivf[1] = inv[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fac[i] = fac[i - 1] * i % mo;
		inv[i] = mo - 1ll * mo / i * inv[mo % i] % mo;
		ivf[i] = ivf[i - 1] * inv[i] % mo;
	}
	mn = smn = make_pair(inf, 0);
}
int main (){
	cin >> n >> X >> Y, ans = 1, prep();
	for (int i = 1, x, y; i <= n; ++i) {
		scanf("%d%d", &x, &y), co[x].push_back(y);
		if (y < mn.fi)
			smn = mn, mn = make_pair(y, x);
		else if (y < smn.fi)
			smn = make_pair(y, x);
	}
	int tot = 0;
	for (int i = 1; i <= n; ++i) {
		if (!(int)co[i].size())
			continue;
		int M = inf, C = 0;
		for (auto x : co[i])
			M = min(M, x);
		if (M + mn.fi > Y)
			continue;
		if (i == mn.se)
			for (auto x : co[i])
				C += (x + M <= X || x + smn.fi <= Y);
		else
			for (auto x : co[i])
				C += (x + M <= X || x + mn.fi <= Y);
		tot += C;
		ans = ans * ivf[C] % mo;
	}
	ans = ans * fac[tot] % mo;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13952
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n){return REPS(n).map(i->getInt());}
	static int getInt(){return Integer.parseInt(s.next());}

	public static void main(String[]$){
		long k=s.nextLong();

		final int n=50;
		long[]r=new long[n];

		for(int i=0;i<n&&k>0;i++) {
			r[i]=n-i;
			--k;
		}

		for(int i=0;i<n;i++)
			r[i]+=k/n;
		k%=n;

		for(int i=0;i<n&&k>0;i++) {
			++r[i];
			--k;
		}

		System.out.println(n);
		System.out.println(Arrays.stream(r).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
	}
}


Measured memory_bytes: 27092
package main

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

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
        buf := make([]byte, 0, 1000000)
        for {
                l, p, e := rdr.ReadLine()
                if e != nil {
                        panic(e)
                }
                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)
}

func strSprit(str string) []string {
        cols := strings.Split(str, " ")
        return cols
}

func parseInt(str string) int {
        n, _ := strconv.Atoi(str)
        return n
}

func intSprit(str string) []int {
        strs := strSprit(str)
        cols := make([]int, len(strs))
        for i, v := range strs {
                cols[i] = parseInt(v)
        }
        return cols
}

func bitCount(n uint) int {

        x := uint64(n)

        const m = 1<<64 - 1
        const m0 = 0x5555555555555555
        const m1 = 0x3333333333333333
        const m2 = 0x0f0f0f0f0f0f0f0f

        x = x>>1&(m0&m) + x&(m0&m)
        x = x>>2&(m1&m) + x&(m1&m)
        x = (x>>4 + x) & (m2 & m)
        x += x >> 8
        x += x >> 16
        x += x >> 32

        return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
        return ((n >> uint(i)) & 1) == 1
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////
func gcd(a, b int) int {
        for {
                if b == 0 {
                        return a
                } else {
                        a, b = b, a%b
                }
        }
}

func main() {
        line := readBigLine()
        N := parseInt(line)

        l := readBigLine()
        a := intSprit(l)

        n := gcd(a[0], a[1])
        for i := 2; i < N; i++ {
                n = gcd(n, a[i])
        }
        fmt.Println(n)
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

struct Edge{
    int to,id;
    Edge(int to,int id):to(to),id(id){}
};

vector<Edge> g[55];

vector<int> es;

bool dfs(int v,int tv,int p=-1){
    if( v == tv){
        es = vector<int>();
        return true;
    }
    for(Edge e:g[v]){
        if(e.to == p)continue;
        if(dfs(e.to,tv,v)){
            es.push_back(e.id);
            return true;
        }
    }
    return false;
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    int n,m;
    cin >> n;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].emplace_back(b,i);
        g[b].emplace_back(a,i);
    }
    cin >> m;
    vector<ll> eset(m);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        dfs(a,b);
        for(int e:es){
            eset[i] |= 1LL<<e;
        }
    }

    ll ans = 0;
    rep(i,1<<m){
        ll mask = 0;
        rep(j,m){
            if((i>>j) &1)mask |= eset[j];
        }
        int white = __builtin_popcountll(mask);
        ll now = 1LL << (n-1-white);  //2^(n-1-white);
        if(__builtin_popcountll(i)%2 == 0) ans += now;
        else ans -= now;
    }
    cout << ans << endl;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
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);
        CKDMC solver = new CKDMC();
        solver.solve(1, in, out);
        out.close();
    }

    static class CKDMC {
        static final char D = 'D';
        static final char M = 'M';
        static final char C = 'C';

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            char[] s = in.next().toCharArray();

            int Q = in.nextInt();
            for (int q = 0; q < Q; q++) {
                int k = in.nextInt();
                long answer = 0;
                long dm = 0, d = 0, m = 0;
                for (int i = 0; i < n; i++) {
                    if (s[i] == D) {
                        d++;
                    }
                    if (i - k >= 0) {
                        if (s[i - k] == M) {
                            m--;
                        }
                        if (s[i - k] == D) {
                            d--;
                            dm -= m;
                        }
                    }
                    if (s[i] == M) {
                        m++;
                    }
                    if (s[i] == M) {
                        dm += d;
                    }
                    if (s[i] == C) {
                        answer += dm;
                    }
                }

                out.println(answer);
            }
        }

    }

    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 int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 33548
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;

int N, M;
int x, y;
int num[101010];
bool red[101010];

signed main()
{
    cin >> N >> M;

    for (int i=1; i<=N; i++) {
        num[i] = 1;
        red[i] = false;
    }
    red[1] = true;

    REP(i,M) {
        cin >> x >> y;
        if (red[x]) red[y] = true;
        num[x] -= 1;
        num[y] += 1;
        if (num[x] == 0) red[x] = false;
    }

    int ans = 0;
    for (int i=1; i<=N; i++) if (red[i]) ans++;

    cout << ans << endl;
}


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

#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define pll pair<long,long>
#define S second
#define F first

signed main(){
	int n;
	cin>>n;
	pll a[n+1];
	int dp[n+1][n+1];
	f(i,n+1) f(j,n+1) dp[i][j]=0;

	for(int i=1;i<n+1;i++){
		cin>>a[i].F; //so  that it can be compared for descending
		a[i].S=i;
	}

	sort(a+1,a+n+1,greater<pll>());

	for(int i=1;i<n+1;i++){
		//currently at ith index of our sorted weights
		//i-1 weights have already been placed
		for(int j=0;j<i;j++){
			int L = j;
			int R = i-1-j;
			dp[L+1][R] = max(
				dp[L+1][R],
				dp[L][R] + abs(L+1 - a[i].S)*a[i].F
			);
			dp[L][R+1] = max(
				dp[L][R+1],
				dp[L][R] + abs(n-R - a[i].S)*a[i].F
			);
		}
	}

	int ans=0;
	for(int i=0;i<n+1;i++){
		//num ele to left
		ans = max(ans,dp[i][n-i]);
	}
	cout<<ans<<endl;
	return 0;
}


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


def solve(b: str):
    S = '#ACGT'
    return S[-S.find(b)]


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n, k = map(int, input().split())
amax = 100000
cnt = [0 for _ in range(amax+1)]


for i in range(n):
    a, b = map(int, input().split())
    cnt[a] += b

for i in range(1, amax+1):
    if k <= cnt[i]:
        print(i)
        break
    k -= cnt[i]

Measured memory_bytes: 5900
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define endl '\n'
#define PI pair<int,int>
#define ff first
#define ss second
#define int long long 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)

bool isPalim(string s){
	string ss=s;
	reverse(s.begin(),s.end());
	return ss==s;
}

bool okk(string s){
	bool ans=isPalim(s);
	int n=s.size();
	int r=(n-1)/2;
	string ss=s.substr(0,r);
	//cout<<ss<<endl;
	ans   =  ans & isPalim(ss);
	r=(n+3)/2;
	ss=s.substr(r-1,n-r+1);
	//cout<<ss<<endl;
	ans =  ans & isPalim(ss);
	return ans;
}

int32_t main() {

	boost;
    string s;
    cin>>s;
    if(okk(s))
    	cout<<"Yes"<<endl;
    else
    	cout<<"No"<<endl; 

    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
using ll = long long;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,n) for(int i = (a); i < (n); ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

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

int n, m;
bool edge[9][9];
int perm[9];

int main() {
  cin >> n >> m;
  int a, b; REP(i,m) {
    cin >> a >> b;
    edge[a][b] = edge[b][a] = true;
  }
  FOR(i,1,n+1) perm[i] = i;
  int ans = 0;
  do {
    bool f = true;
    FOR(i,1,n) if (!edge[perm[i]][perm[i+1]]) { f = false; break; }
    if (f) ans++;
  } while (next_permutation(perm+2, perm+n+1)) ;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
NK = input().split(' ')
N, K = int(NK[0]), int(NK[1])
trees = []
for i in range(N):
  trees.append(int(input()))
trees.sort()
min = float("inf")
for i in range(N-K+1):
  h = trees[i+K-1]-trees[i]
  if h < min:
    min = h
print(min)

Measured memory_bytes: 7384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		String ls = System.lineSeparator();
		int q = in.nextInt();
		for(int i=0;i<q;i++) {
			long a = in.nextLong();
			long b = in.nextLong();
			long m = a*b;
			long k = (int)Math.sqrt(m);
			if(k*k>=m) k--;
			
			long sum = 0;
			if(k*(k+1)>=m) sum += 2*k-1;
			else sum += 2*k;
			
			if(Math.min(a, b)<=k) sum--;
			
			sb.append(sum);
			sb.append(ls);
		}
		System.out.println(sb.toString());
		in.close();
	} 
}

Measured memory_bytes: 21972
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <string.h>
#include <map>
#include <iomanip>
#include <time.h>
using namespace std;
typedef long long ll;

int n, m;
bool vis[100010] = {};
vector<int> G[100010], tp;

void dfs(int v) {
    if (!vis[v]) {
        vis[v] = 1;
        for (int i = 0; i < G[v].size(); i++) {
            dfs(G[v][i]);
        }
        tp.push_back(v);
    }
}

int main() {
    cin >> n >> m;

    for (int i = 0; i < n + m - 1; i++) {
        int a, b;
        cin >> a >> b;
        G[--a].push_back(--b);
    }

    bool t[n + 5] = {};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < G[i].size(); j++) {
            t[G[i][j]] = 1;
        }
    }

    int root = -1;
    for (int i = 0; i < n; i++) {
        if (!t[i]) {
            root = i;
            break;
        }
    }

    dfs(root);
    reverse(tp.begin(), tp.end());

    int p[n + 5] = {};
    p[root] = -1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < G[tp[i]].size(); j++) {
            p[G[tp[i]][j]] = tp[i];
        }
    }   

    for (int i = 0; i < n; i++) cout << p[i] + 1 << endl;

}


Measured memory_bytes: 10100
# https://atcoder.jp/contests/abc051/tasks/abc051_c
sx, sy, tx, ty = map(int, input().split())

ans = []
ans.append('R' * (tx - sx) + 'U' * (ty - sy))
ans.append('L' * (tx - sx) + 'D' * (ty - sy))
ans.append('D' + 'R' * (tx - sx + 1) + 'U' * (ty - sy + 1) + 'L')
ans.append('U' + 'L' * (tx - sx + 1) + 'D' * (ty - sy + 1) + 'R')
print(''.join(ans))

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

int main(){
	int x,a,b;
	cin >> x >> a >> b;
	int disa= x > a ? x-a : a-x;
	int disb= x > b ? x-b : b-x;
	char ans;
	if(disa > disb) ans = 'B';
	else ans = 'A';
	cout << ans << endl;
	return 0;
}


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

int main() {
    int a;
    cin>>a;
    string s = to_string(a);
    int x=0;
    for(int i=0;i<s.size();++i) {
        x+=s[i]-'0';
    }
    if(a%x==0) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;

using namespace std;

int main() 
{
    int m;
    cin >> m;

    cout << 24+(24-m) << endl;
    return 0;
}
    



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct initon
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define pob pop_back
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main(){
string s;
cin >> s;
int a;
if(s=="SUN"){
a=7;
}else if(s=="MON"){
a=6;
}else if(s=="TUE"){
a=5;
}else if(s=="WED"){
a=4;
}else if(s=="THU"){
a=3;
}else if(s=="FRI"){
a=2;
}else if(s=="SAT"){
a=1;
}
cout <<a;
}

Measured memory_bytes: 256
// ※※※ 解答不能 ※※※
// 正解者のソースを学習する(一部改変).
// tourist氏
// https://atcoder.jp/contests/agc035/submissions/6377050
#include <bits/stdc++.h>
using namespace std;

int main(){

    int N, M;
    scanf("%d %d", &N, &M);
    vector<vector<int>> g(N);
    for(int i = 0; i < M; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        --x; --y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    
    if(M % 2 != 0){
        printf("%d\n", -1);
        return 0;
    }
    
    vector<pair<int, int>> res;
    vector<int> deg(N, 0);
    vector<int> depth(N, -1);
    // v: 現在探索している頂点, pr: 前回探索した頂点.
    function<void(int, int)> dfs = [&](int v, int pr){
        for(int u : g[v]){
            if(depth[u] == -1){
                depth[u] = depth[v] + 1;
                dfs(u, v);
                // printf("--- 1. debug start ---\n");
                // printf("depth[%d]=%d depth[%d]=%d deg[%d]=%d pr=%d\n", u, depth[u], v, depth[v], v, deg[v], pr);
                // printf("--- 1. debug end -----\n");
            }else{
                if(depth[u] > depth[v]){
                    res.emplace_back(v, u);
                    ++deg[v];
                    // printf("--- 2. debug start ---\n");
                    // printf("depth[%d]=%d depth[%d]=%d deg[%d]=%d pr=%d\n", u, depth[u], v, depth[v], v, deg[v], pr);
                    // printf("--- 2. debug end -----\n");
                }
            }
        }
        if(deg[v] % 2 == 1){
            assert(pr != -1);
            res.emplace_back(v, pr);
            ++deg[v];
            // printf("--- 3. debug start ---\n");
            // printf("depth[%d]=%d deg[%d]=%d pr=%d\n", v, depth[v], v, deg[v], pr);
            // printf("--- 3. debug end -----\n");
        }else{
            if(pr != -1){
                res.emplace_back(pr, v);
                ++deg[pr];
                // printf("--- 4. debug start ---\n");
                // printf("depth[%d]=%d deg[%d]=%d pr=%d\n", v, depth[v], v, deg[v], pr);
                // printf("--- 4. debug end -----\n");
            }
        }
    };

    depth[0] = 0;
    dfs(0, -1);
    for(auto& p : res) printf("%d %d\n", p.first + 1, p.second + 1);
    return 0;

}

Measured memory_bytes: 14836
#include <stdio.h>
#include <stdbool.h>
#include <limits.h>
int main()
{
  int n;
  scanf("%d",&n);
  unsigned long a[n];
  int i = 0;
  unsigned long ans = 1;
  bool minus = false;
  bool zero = false;
  unsigned long max = 0;
  while (i < n)
  {
    scanf("%lu",&a[i]);
    if (a[i] == 0 || ans == 0)
    {
      printf("0");
      return (0);
    }
    if (a[i] <= 1000000000000000000/ans)
    {
      //printf("%lu",ans);
      ans *= a[i];
    }
	else
    {
      minus = true;
    }
    i++;
  }
  if (minus)
  {
    printf("-1");
  }
  else
  	printf("%lu",ans);
}

Measured memory_bytes: 2504
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
	//Implement solution here.
		String input = next();
		char[] ca = input.toCharArray();
		int result = 0;
		int tmp = 0;
		for(char c:ca) {
			if(c == 'A'||c == 'C'||c == 'G'||c == 'T') {
				tmp++;
			} else {
				result = Math.max(result, tmp);
				tmp = 0;
			}
		}
		if(tmp > 0) {
			result = Math.max(result, tmp);
		}
		System.out.println(result);
	}

    //Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args){
        String debugDataPath = System.getenv("DD_PATH");        
        if(debugDataPath != null){
            try{
                scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        }
        solve();
	}

    //Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
    //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
    //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
    //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
    //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
    //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 24916
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int N=2e5+50;
int n,m,a[N],ans;
vector<int>v[N];
priority_queue<int>q;
int main(){
    scanf("%d%d",&m,&n);
    for(int i=1,x,y;i<=m;i++)
        scanf("%d%d",&x,&y),v[y].pb(x);
    for(int i=n+1,j=n;i;i--)
        for(int k=0;k<v[i].size();k++){
            q.push(v[i][k]);
            if(j>=i)j--,ans++;
            else a[q.top()]++,q.pop();
        }
    for(int i=1,j=0;i<=n;i++){
        int dat=min(a[i],i-j);
        j+=dat;ans+=dat;
    }
    cout<<m-min(ans,n);
    return 0;
}

Measured memory_bytes: 10108
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



int n, m, a, res, x, y;
pair<int,int> b[100100];
priority_queue<int> p, q;

signed main() {
    cin >> n >> m;
    rep(i,n) {
        cin >> a;
        q.push(a);
    }
    rep(i,m) cin >> b[i].second >> b[i].first;
    sort(b,b+m), reverse(b,b+m);
    int id = 0;
    rep(i,m) {
        x = b[i].first, y = b[i].second;
        rep(i,y) {
            p.push(x);
            id++;
            if (id==n) break;
        }
        if (id==n) break;
    }
    rep(i,n) p.push(-1), q.push(-1);
    rep(i,n) {
        x = p.top(), y = q.top();
        if (x>y) res += x, p.pop();
        else res += y, q.pop();
    }
    cout << res << endl;
}


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

int main() {

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
    int n, k;
    cin>>n>>k;
    int cnt = 0;
    int curr;
    for (int i=0; i<n; i++){
        cin>>curr;
        if (curr>=k) cnt++;
    }   
    cout<<cnt;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination

int main(){
    int n;
    cin >> n;
    int a[n],b[n];
    rep(i,n){
        cin >> a[i];
        b[i]=a[i];
    }
    sort(a,a+n);
    int c=a[n-1];
    rep(i,n){
        if(b[i]==c){
            cout<<a[n-2]<<endl;
        }else{
            cout<<c<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3200
while True:
    n,m=list(map(int,input().split()))
    if n==0&m==0:
        break

    count=0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k==m:
                    count+=1
    print(count)



Measured memory_bytes: 5592
N = int(input())
h = list(map(int, input().split()))
pre = h[0] - 1
for i in range(1, N):
    if pre > h[i]:
        print('No')
        exit()
    else:
        if pre == h[i]:
            pre = h[i]
        else:
            pre = h[i] - 1

print('Yes')



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

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<int>> c(h,vector<int>(w));
    vector<vector<int>> a(h,vector<int>(w));

    char ch;

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> ch;
            if(ch == '#') c[i][j] = 1;
            else c[i][j] = 0;
        }
    }

    vector<int> vech(h,0);
    vector<int> vecw(w,0);

    int numh = 1;
    for(int i=0; i<h; i++){
        numh *= 2;
    }

    int numw = 1;
    for(int i=0; i<w; i++){
        numw *= 2;
    }

    int ans = 0;
    for(int i=0; i<numh; i++){
        for(int j=0; j<numw; j++){
            
            int n = i;
            int m = j;
            for(int x=0; x<h; x++){
                vech[x] = n % 2;
                n /= 2;
            }
            for(int x=0; x<w; x++){
                vecw[x] = m % 2;
                m /= 2;
            }
            int count = 0;
            for(int x=0; x<h; x++){
                for(int y=0; y<w; y++){
                    if(vech[x] == 0 && vecw[y] == 0 && c[x][y] == 1){
                        count++;
                    }
                }
            }
            if(count == k) ans++;
        }
    }
    cout << ans << endl;

}

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

int main(){
    int S, h, m, s; 
    cin >> S;
    h = S/3600;
    m = (S - (h*3600))/60;
    s = (S%3600)%60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3096
N = int(input())
h = [int(i) for i in input().split()]
minToatalCostList = [0 for i in range(N)]

for i in range(N) :
	if i > 1 :
		minToatalCostList[i] = min( abs(h[i] - h[i-1]) + minToatalCostList[i-1], abs(h[i] - h[i-2]) + minToatalCostList[i-2] )
	elif i == 1:
		minToatalCostList[i] = abs(h[i] - h[i-1])
	else :
		minToatalCostList[i] = 0

print(minToatalCostList[N-1])

Measured memory_bytes: 13980
#include <climits>
#include <iostream>

using namespace std;

int main (void) {
    int N;
    cin >> N;
    long long A;
    long long ans_tmp, ans = LLONG_MAX;
    for ( int i=0; i<N; i++ ) {
        cin >> A;

        ans_tmp = 0;
        while ( A % 2 == 0 ) {
            ans_tmp++;
            A /= 2;
        }

        if ( ans_tmp < ans )
            ans = ans_tmp;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
// abc055_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll N, M;
    cin >> N >> M;

    ll ans;
    if (M - 2 * N <= 0){
        ans = M / 2;
    } else {
        ans = N;
        ans += (M - 2 * N) / 4;
    }
    print(ans);


    return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))
l.sort()

count = 0
for i in range(n):
    for j in range(i + 1, n):
        if l[i] == l[j]:
            continue
        for k in range(j + 1, n):
            if l[i] == l[k] or l[j] == l[k]:
                continue
            if l[i] + l[j] > l[k]:
                count += 1
print(count)


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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

long long int to_int(string S){
    int n = S.size();
    long long int ans = 0;
    vector<int> B(n);
    for(int i =0;i < n;i++){
      bool frag = 1;
        for(int j = 0;j < 10;j++){
            char a = '0' + j;
            if(S[i] == a){
                B[i] = j;
                frag = 0;
                break;
            }
        }
        if(frag) return -1;
    }
    for(int i = 0;i < n;i++){
        ans += B[i]*pow(10,(n-i-1));
    }
    return ans;
}

bool Primefactor(ll n){
  ll a = n;
  for(ll i = 2;i * i <= n;i++){
    if(n % i == 0){
      return false;
    }
  }
  return true;
}

int CA[12]{31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
  ll X;cin >> X;
  while(1){
    if(Primefactor(X)){
      cout << X << endl;
      break;
    }
    X++;
  }
}

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

int main() {
    int a[3], x=0, y=0;
    for (int i=0; i<3; i++)
        cin >> a[i];
    for (int i=0; i<3; i++) {
        if (a[i] == 5)
            x++;
        if (a[i] == 7)
            y++;
    }
    if (x == 2 && y == 1)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}


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

int n, A[200000], B[1000001], ans = 0;
int main()
{

    cin >> n;
    rep(i, n) cin >> A[i];
    sort(A, A + n);
    rep(i, n)
    {
        for (int j = A[i]; j <= A[n - 1]; j += A[i])
        {
            B[j]++;
        }
    }
    rep(i, n)
    {
        if (B[A[i]] == 1)
        {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 8260
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int main() {

  int N,W,v[101],w[101];

  cin>>N>>W;
  REP(i,0,N) cin>>v[i+1]>>w[i+1];

  int dp[101][10001];

  REP(i,0,N+1)REP(j,0,W+1) dp[0][j] = 0;

  REP(i,1,N+1){
    REP(j,0,W+1){
      dp[i][j] = dp[i-1][j];
      if(j-w[i] >= 0) dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
    }
  }
/*
  REP(i,0,N+1){
    REP(j,0,W+1){
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }
*/
  cout<<dp[N][W]<<endl;

  return 0;
}

Measured memory_bytes: 6968
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	int n , k; cin >> n >> k;
	map<int,int>vis;
	int cnt = 0 ; 
	rep(i,0,k){
		int a;
		cin >> a ;  
		rep(j,0,a) {
			int b;
			cin >> b;
			vis[b] = 1 ;
		}
	}
	for(int i = 1 ; i <= n ; ++i) if(!vis[i]) cnt++;
	cout << cnt << endl;
}
signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int x, n; cin >> x >> n;
    vector<int> p(n); rep(i, 0, n) cin >> p[i];

    int ans = INT_MAX;
    rep(i, 0, 110) {
        bool flag = true;
        rep(k, 0, n) {
            if (i == p[k]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            if (abs(ans - x) > abs(i - x)) {
                ans = i;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <stdio.h>
int main()
{
	int N, K;
	int num = 1;
	scanf("%d", &N);
	scanf("%d", &K);
	for (int i = 0;i < N;i++)
	{
		if (num < K)
			num = num * 2;
		else
			num = num + K;
	}
	printf("%d", num);
	return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

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

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import Data.List (foldl', group)

main :: IO ()
main = do
  getLine
  hs <- map read . words <$> getLine
  print $ solve hs

solve :: [Int] -> Int
solve = foldl' max 0 . map length . filter head . group . go
  where
    go [x] = []
    go (x:y:zs) = (x >= y) : go (y:zs)


Measured memory_bytes: 43260
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int n;
    cin >> n;
    priority_queue<pair<ll,int> > x,y;
    vector<ll> s(n),t(n);
    rep(i,n){
        ll a,b;
        cin >> a >> b;
        s[i] = a;
        t[i] = b;
        x.push(MP(a+b,i));   
    }
    ll ans = 0;
    int cnt = 0;
    while(!x.empty()){
        auto p = x.top();
        x.pop();
        if(cnt%2==0){
            ans += s[p.second];
        }else{
            ans -= t[p.second];
        }
        cnt++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3956
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

class arc092_c {
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<int> a(N), b(N), c(N), d(N);
        vector<pair<int, int>> cd(N);
        for (int i = 0; i < N; ++i) {
            in >> a[i] >> b[i];
        }
        for (int i = 0; i < N; ++i) {
            in >> c[i] >> d[i];
            cd[i] = {c[i], d[i]};
        }
        sort(begin(cd), end(cd));
        int res = 0;
        for (int i = 0; i < N; ++i) {
            int ind = -1;
            for (int j = 0; j < N; ++j) {
                if (a[j] < cd[i].first && b[j] < cd[i].second) {
                    if (ind == -1 || b[j] > b[ind]) {
                        ind = j;
                    }
                }
            }
            if (ind != -1) {
                ++res;
                a[ind] = b[ind] = 3 * N;
            }
        }
        
        out << res << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	arc092_c solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <math.h>
#include <string>
using namespace std;
const int M=998244353;


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

	string s;
	cin>>s;
	printf("%s\n",(s[2]==s[3]&&s[4]==s[5])?"Yes":"No");

 	return 0;
}

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

int main(){
    ll n;
    ll ans = 0;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        for (int j=i;j<=n;j += i+1)a[j]+=1;
    }
    rep(i,n)ans += (i+1)*a[i];
    cout << ans << endl;
}

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

int main(void){
	char str[200001];
	int i,l;
	int nums,numt;
  int ans;
	scanf("%s",str);
  l=strlen(str);
  nums=0;
  numt=0;
  for(i=0;i<l;i++){
    if(str[i] == 'S'){
      nums++;
    }
    if(str[i] == 'T'){
      if(nums){
        nums--;
      }else{
        numt++;
      }
    }
  }
  ans=numt+nums;
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 384
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
n = 1
for i in range(1, N+1):
    n *= i
    n %= MOD

m = 1
for i in range(1, M+1):
    m *= i
    m %= MOD
if abs(N - M) > 1:
    print(0)
elif abs(N - M) == 1:
    print((n * m) % MOD)
else:
    print((n * m) * 2 % MOD)


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

const int maxn = 305;
double dp[maxn][maxn][maxn];
int n;

double find(int a, int b, int c) {
  if (a < 0 || b < 0 || c < 0) return 0;
  if (a == 0 && b == 0 && c == 0) return 0;
  if (dp[a][b][c] == 0) {
    dp[a][b][c] = n + a*find(a - 1, b, c) + b*find(a + 1, b - 1, c) + c*find(a, b + 1, c - 1);
    dp[a][b][c] /= a + b + c;
  }
  return dp[a][b][c];
}

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

  cin >> n;
  int cnt[5] = {};
  cout << setprecision(10) << fixed;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    cnt[a]++;
  }

  cout << find(cnt[1], cnt[2], cnt[3]) << '\n';

  return 0;
}


Measured memory_bytes: 219392
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        //int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var ans = "No";
        var tmp = s.Replace("hi", "?");

        var count = tmp.Where(x => x != '?').Count();
        if (count == 0) ans = "Yes";

        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
const int N=5010,K=5;
int n;
char str[N];
int m;
string a[N*K];
int acnt;
void readData(){
	scanf("%s",str+1);
	n=strlen(str+1);
	scanf("%d",&m);
}
void solve(){
	string cur;
	for(int i=1;i<=n;i++){
		cur="";
		for(int j=0;j<m&&i+j<=n;j++){
			cur.append(1,str[i+j]);
			a[++acnt]=cur;
		}
	}
	sort(a+1,a+1+acnt);
	acnt=unique(a+1,a+1+acnt)-a-1;
	cout<<a[m]<<endl;
}
int main(){
	readData();
	solve();
	return 0;
}


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

int main() {
	string s;
	int a, b;
	while (cin >> s >> a >> b) {
		cout << s << ' ' << a + b << ' ' << a * 200 + b * 300 << endl;
	}
}

Measured memory_bytes: 3060
#include<stdio.h>

/* 選択ソート（0オリジン） */
int selectionSort(int A[], int N) {
  int i, j, t, sw = 0, mini;
  for ( i = 0; i < N - 1; i++ ) {
    mini = i;
    for ( j = i; j < N; j++ )
      if ( A[j] < A[mini] ) mini = j;
    t = A[i]; A[i] = A[mini]; A[mini] = t;
    if ( i != mini ) sw++;
  }
  return sw;
}

int main() {
  int A[100], N, i, sw;

  scanf("%d", &N);
  for ( i = 0; i < N; i++ ) scanf("%d", &A[i]);

  sw = selectionSort(A, N);

  for ( i = 0; i < N; i++ ) {
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", sw);

  return 0;
}


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

long long int psum[200001];
long long int A[200001];
int n;

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

	long long int res = 1e18;
	cin >> n;

	for(int i=1;i<=n;i++)
	{
		cin >> A[i];
		psum[i] = A[i] + psum[i-1];
	}

	for(int i=1;i<n;i++)
	{
		res = min(res,abs(psum[n] - 2*psum[i]));
	}

	cout << res << '\n';
	
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[105],ans=10000;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		int res1=0,res2=0;
		for(int j=0;j<i;j++)
		{
			res1+=a[j];
		}
		for(int j=i;j<n;j++)
		{
			res2+=a[j];
		}
		if(abs(res1-res2)<=ans)
		  ans=abs(res1-res2);
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
   string a,b;
   cin >>a>>b;
   int count = 0;
    if(a.at(0) == b.at(0)){
        count++;
    }if(a.at(1) == b.at(1)){
        count++;
    }if(a.at(2) == b.at(2)){
        count++;
    }cout << count <<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;

bool cmp(pint a, pint b) {
  return a.second < b.second;
}

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

  int n,m; cin >> n >> m;
  vector<pint> a;
  a.resize(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i].first >> a[i].second;
  }

  sort(a.begin(), a.end(), cmp);

  int ans = 0;
  int endtime = 0;
  for (int i = 0; i < m; i++) {
    if (a[i].first >= endtime) {
      endtime = a[i].second;
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#coding: utf-8

n = int(raw_input())

s = []

w = raw_input()
s.append(w)

for i in range(n-1):
    w = raw_input()
    if w[0] != s[-1][-1]:
        print "No"
        exit()
    for j in s:
        if w == j:
            print "No"
            exit()
    s.append(w)
print "Yes"





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

const int mod = (int) 1e9 + 7;
 
int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> vis(n);
  for (int i = 0; i < m; ++i) {
    int x;
    cin >> x;
    vis[x] = true;
  }
  vector<long long> dp(n + 3);
  dp[n] = 1;
  for (int i = n - 1; i >= 0; --i) {
    if (vis[i]) {
      continue;
    }
    dp[i] = (dp[i + 1] + dp[i + 2]) % mod;
  }
  cout << dp[0] << '\n';
}

Measured memory_bytes: 4464
#include<iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R'){
    cout << 3 << endl;
  }else if((s[0] == 'R' && s[1] == 'R' && s[2] == 'S') || (s[0] == 'S' && s[1] == 'R' && s[2] == 'R')){
    cout << 2 << endl;
  }else if (s[0] == 'S' && s[1] == 'S' && s[2] == 'S'){
    cout << 0 << endl;
  }else{
    cout << 1 <<endl;
  }
}

Measured memory_bytes: 3624