akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mem(v,x) memset(v,x,sizeof(v))
#define N 200005

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n;
	cin>>n;
	int dp[3][n];
	int a[3][n];
	for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>a[j][i];
        }
	}
	for(int i=0;i<3;i++){
        dp[i][0] = a[i][0];
	}
	for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            dp[j][i] = 0;
            for(int k=0;k<3;k++){
                if(k==j) continue;
                dp[j][i] = max(dp[j][i], a[j][i] + dp[k][i-1]);
            }
        }
	}
	cout<<max({dp[0][n-1], dp[1][n-1], dp[2][n-1]});
	return 0;
}


Measured memory_bytes: 2560
n = int(input())
a = []
for i in range(4):
    a.append(n%10)
    n //= 10
a.reverse()
#print(a)#
OP = [['+', '-'] for i in range(3)]
PM = ['+', '-']
OP = []
for op1 in PM:
    for op2 in PM:
        for op3 in PM:
            OP.append([op1,op2,op3])
#print(OP)#
for op in OP:
    #print(op)#
    result = a[0]
    for i in range(len(op)):
        if op[i]=='+': result += a[i+1]
        else: result -= a[i+1]
    if result==7: break
        
print(a[0],end='')
for n in range(3):
    print('%s%d' % (op[n], a[n+1]), end='')
print('=7')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,h;cin>>n>>h;
    priority_queue<pair<int,int>> q;
    int a,b;
    rep(i,n){
        cin>>a>>b;
        q.push(mp(a,0));
        q.push(mp(b,1));
    }
    int res=0;
    while(h>0){
        auto p=q.top();q.pop();
        if(p.second==1){
            h-=p.first;
            res++;
        }
        else{
            int tmp=p.first;
            res+=(h+tmp-1)/tmp;
            break;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 2420
n, k = map(int, input().split())
rsp = list(map(int, input().split()))
t = input()

win = {"r": 2, "s": 0, "p": 1}
lost = [False] * n

ans = 0
for i in range(n):
    score = rsp[win[t[i]]]
    ans += score
    if i >= k and t[i - k] == t[i] and not lost[i - k]:
        lost[i] = True
        ans -= score

print(ans)


Measured memory_bytes: 4084
from collections import deque
def bfs(al, h, w):
    q = deque([])
    visited = [ [-1]*w for _ in range(h) ]
    for i in range(h):
        for j in range(w):
            if al[i][j] == '#': 
                q.append((i,j))
                visited[i][j] = 0

    while q:
        i, j = q.popleft()
        for ver, hor in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            ni, nj = i+ver, j+hor
            if ni >= h or nj >= w or ni < 0 or nj < 0:
                continue
            if al[ni][nj] == '.' and visited[ni][nj] == -1:
                visited[ni][nj] = visited[i][j] + 1
                q.append((ni,nj))
    return visited


def main():
    h,w = map(int, input().split())
    al = []
    for _ in range(h):
        row = list(input())
        al.append(row)

    visited = bfs(al,h,w)
    ans = 0
    for v in visited:
        ans = max(max(v),ans)

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 154676
#include <bits/stdc++.h>
using namespace std;
 
int n, a, l=1e9, r;
 
int main() {
  cin >> n;
  while(n--) {
    cin >> a;
    l = min(l,a), r = max(r,a);
  }
  cout << r-l << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;


int main(void){
 int N,K,h;
 long long int min1=1000000000000;
 vector<long long int> H;
 cin>>N>>K;

 for(int i=0; i<N; i++){
  cin>>h;
  H.push_back(h);
 }
 sort(H.begin(),H.end());
 
 for(int i=0; i<=(N-K);i++){
  min1=min(min1,H[i+K-1]-H[i]);
 }

 std::cout<<min1<<std::endl;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;


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

    cout << (n * (n - 1)) / 2 << endl;
}


Measured memory_bytes: 256
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, k: usize, a: [usize; n]);
    let mut d = std::collections::HashMap::new();
    for i in 0..n {
        d.entry(a[i]).or_insert(vec![]).push(i);
    }
    let mut b = vec![0];
    while b[b.len() - 1] % n != 0 || b[b.len() - 1] == 0 {
        let mut i = b[b.len() - 1];
        let ai = a[i % n];
        let j = d[&ai].binary_search(&(i % n + 1)).unwrap_or_else(|x| x);
        if j == d[&ai].len() {
            i += n + d[&ai][0] + 1 - (i % n);
        } else {
            i += d[&ai][j] + 1 - (i % n);
        }
        b.push(i);
    }

    let len = b[b.len() - 1];
    let r = (n * k) % len;
    let r = match b.binary_search(&r) {
        Ok(_) => 0,
        Err(i) => r - b[i - 1],
    };
    let mut s = std::collections::HashSet::<usize>::new();
    let mut stack = vec![];
    'outer: for i in (n - r)..n {
        if let Some(&ai) = s.get(&a[i]) {
            while let Some(aj) = stack.pop() {
                s.remove(aj);
                if *aj == ai {
                    continue 'outer;
                }
            }
        }
        stack.push(&a[i]);
        s.insert(a[i]);
    }
    println!(
        "{}",
        stack
            .into_iter()
            .map(|i| i.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    use std::fs;
    #[test]
    fn test_file() {
        let s = fs::read_to_string("src/bin/in").expect("foo");
        solve(&s);
    }
    //     fn test_input() {
    //         let s = "
    //         11 97
    // 3 1 4 1 5 9 2 6 5 3 5
    //         ";
    //         solve(s);
    //     }
}


Measured memory_bytes: 43148
# -*- coding: utf-8 -*-
a,b,c,k = map(int,input().split())

if k%2==0:
    if a-b>10**18:
        print("Unfair")
    else:
        print(a-b)
else:
    if b-a>10**18:
        print("Unfair")
    else:
        print(b-a)


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

char mp[555][555];

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

	int h, w;cin >> h >> w;
	REP(i, h)REP(j, w)cin >> mp[i][j];

	REP(i, h){
		REP(j, w){
			bool flag = false;
			if(j == 0)flag = true;
			if(mp[i][j] == '#')flag = true;
			if(j != w - 1 && i % 2 == 0)flag = true;
			if(flag){
				cout << '#';
			}
			else {
				cout << '.';
			}
		}
		cout << endl;
	}

	cout << endl;

	REP(i, h){
		REP(j, w){
			bool flag = false;
			if(j == w - 1)flag = true;
			if(mp[i][j] == '#')flag = true;
			if(j != 0 && i % 2 == 1)flag = true;
			if(flag){
				cout << '#';
			}
			else {
				cout << '.';
			}
		}
		cout << endl;
	}


	return 0;
}


Measured memory_bytes: 1024
N,M = map(int,input().split())
C = [[0 for _ in range(2)]for _ in range(N)]


for n in range(N):
    C[n][0], C[n][1] = map(int,input().split())

C.sort()
cost = 0
for n in range(N):
    if C[n][1] <= M:
        cost += C[n][1]*C[n][0]
    else:
        cost += C[n][0]*M
        break
    M -= C[n][1]
    if M <= 0:
        break
print(cost)

Measured memory_bytes: 21548
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,y;
    cin>>n>>y;
    for(int i=0;i<=n;i++)
     	for(int j=0;j<=n;j++)
     	{
		 	for(int k=0;k<=n,i+j+k<=n;k++)
       		{
        	    if(i+j+k==n&& i*1000+j*5000+k*10000==y)
          	     {
             	    cout<<k<<" "<<j<<" "<<i<<endl;
                    return 0;   
            	}
       		}
        } 
    cout<<"-1 -1 -1\n"; 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>

using namespace std;
using PII = pair<int, int>;

const int inf = 1e8;
const int dx[4] = {1, 0, -1,  0};
const int dy[4] = {0, 1,  0, -1};

int main() {
	int h, w, k;
	cin >> h >> w >> k;

	vector<string> board(h);
	for (int i = 0; i < h; i++) {
		cin >> board[i];
	}

	int sx = -1, sy = -1;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (board[i][j] == 'S') {
				sx = j;
				sy = i;
				break;
			}
		}
		if (sx != -1) {
			break;
		}
	}

	if (sx == 0 || sx == w - 1 || sy == 0 || sy == h) {
		cout << 0 << endl;
		return 0;
	}

	vector<vector<int>> walk(h, vector<int>(w, inf));
	walk[sy][sx] = 0;

	queue<PII> que;
	que.push(make_pair(sx, sy));

	while (!que.empty()) {
		auto p = que.front();
		que.pop();

		int x = p.first;
		int y = p.second;

		if (walk[y][x] >= k) {
			continue;
		}

		for (int i = 0; i < 4; i++) {
			int nx = x + dx[i];
			int ny = y + dy[i];

			if (0 <= nx && nx < w && 0 <= ny && ny < h &&
				board[ny][nx] == '.' && walk[ny][nx] == inf)
			{
				walk[ny][nx] = walk[y][x] + 1;
				que.push(make_pair(nx, ny));
			}
		}
	}

	int min_len = inf;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (walk[i][j] == inf) {
				continue;
			}

			min_len = min({min_len, i, h - 1 - i, j, w - 1 - j});
		}
	}

	int ans = 1 + (min_len + k - 1) / k;

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


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0;i < N;i++)
#define F first
#define S second
typedef pair<int,int> Pi;

int main()
{
  int N, M;
  while(cin >> N,N) {
    Pi pps[205];
    Pi star[1005];
    Rep(i,N) {
      cin >> pps[i].F >> pps[i].S;
    }
    cin >> M;
    Rep(i,M) {
      cin >> star[i].F >> star[i].S;
    }
    sort(pps, pps + N);
    sort(star, star + M);
    Rep(p,M) {
      int x = star[p].F - pps[0].F;
      int y = star[p].S - pps[0].S;
      int cnt = 1;
      for(int i = p + 1; i < M && cnt < N; i++) {
	if(star[i].F == pps[cnt].F + x && star[i].S == pps[cnt].S + y)cnt++;
      }
      if(cnt == N) {
	cout << x << " " << y << endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);

	int a;
	cin >> a;

	for (int i=1;i<=9;i++)
	{
		for (int j=1;j<=9;j++)
		{
			if (i*j==a)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;
	getchar();
	return 0;
}

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

int main(){
	int a,b,k;
	cin>>a>>b>>k;
	
	if(b-a+1<=k*2){
		for(int i=a;i<=b;i++) cout<<i<<endl;
	}else{
		for(int i=a;i<a+k;i++) cout<<i<<endl;
		for(int i=b-k+1;i<=b;i++) cout<<i<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  [scanElem,scanElem,scanElem].sort()[0..2].sum.writeln;
}


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

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            var arr = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            Console.WriteLine(GCD(arr[0], arr[1]));
        }

        private static long GCD(long a, long b)
        {
            if (a < b)
                return GCD(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
    }
}


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

namespace AOJHelloWorld1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] str = Console.ReadLine().Split(' ');
                int x = int.Parse(str[0]);
                int y = int.Parse(str[1]);

                if (x == 0 && y == 0) break;
                else if (x > y)
                {
                    Console.WriteLine(y+" "+x);
                }
                else if (y > x)
                {
                    Console.WriteLine(x+" "+y);
                }
                else if (x==y)
                {
                    Console.WriteLine(x+" "+y);
                }
            }
        }
    }
}



Measured memory_bytes: 13616
#include <stdio.h>
#define MAX 101
#define INF 10000005
#define NIL -1

   
int main()
{
  int i, j;
  int n, count=0, v, c, c1, v1, i2, min;
  int G[MAX][MAX], col[MAX], d[MAX], pi[MAX];
  
  for(i=0; i<MAX; i++){
    for(j=0; j<MAX; j++){
      G[i][j] = NIL;
	}   
  }
  
  scanf("%d", &n);
  for(i=0; i<n; i++){   
    scanf("%d%d", &v, &c);   
    for(j=0; j<c; j++){
      scanf("%d%d", &v1, &c1);
      G[v][v1] = c1;
    }
  }
    
  for(i=0; i<n; i++){   
    col[i] = 0;
    pi[i] = NIL;
    d[i] = INF; 
  }
   
  d[0] = 0;
    
  while(1){
    min = INF;
    for(i=0; i<n; i++){   
      if(col[i] != 2 && d[i] < min){
        min = d[i];
        i2 = i;
      }
    }
   
    if(min == INF) break;
   
    col[i2] = 2;
   
    for(i=0; i<n; i++){
      if(G[i2][i] != NIL && col[i] != 2 && (G[i2][i]+d[i2]) < d[i]){
		pi[i] = i2;
		d[i] = G[i2][i] + d[i2];
		col[i] = 1;
      }
    }
  }
  
  for(i=0; i<n; i++){
	printf("%d %d\n", i, d[i]);
  }   

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

int main()
{
    char ch;
    cin >> ch;

    if (ch == 'T')
        cout << 'A';
    else if (ch == 'A')
        cout << 'T';
    else if (ch == 'C')
        cout << 'G';
    else cout << 'C';
}

Measured memory_bytes: 3620
import sys
input = sys.stdin.readline

class Factorization:	
	def __init__(self):
		# privateなインスタンス変数を作成
		self.__factors = dict()
		self.__n = 0
	
	
	def get_factors(self, n):
		# [summary] 素因数分解した結果を、辞書([素因数, 指数]...)で返す
		self.__factors.clear()
		self.__n = n
		
		if n < 2:
			# 2より小さい数の場合、素因数分解できない
			return { n:1 }
		else:
			self.__factorization()
			
			return self.__factors
	
	
	def get_divisors(self, n):
		# [summary] 約数をリストに列挙
		self.__factors.clear()
		self.__n = n
		
		if n < 2:
			return [1]
		else:
			self.__factorization()
			divisors = [1]
			
			for k, v in self.__factors.items():
				import copy
				copy_ = copy.deepcopy(divisors)
								
				for i in range(1, v + 1):
					for c in copy_:
						divisors.append(c * (k ** i))
			
			return divisors

				
	def count_divisors(self, n):
		# [summary] 約数の個数を返す
		self.__factors.clear()
		self.__n = n
		
		if n < 2:
			return 1
		else:
			self.__factorization()
			count = 1
			
			for v in self.__factors.values():
				count *= v + 1
			
			return count
	

	def	__factorization(self):
		# [summary]素因数分解した結果を、インスタンス変数に格納
		
		# 2,3,5で、割れなくなるまで割り続ける
		# (末尾に2,3,5のつく数は素数でないことが明白なので
		# 後続の処理で素数のリストに入れないように、先に処理する)
		self.__divide_with(2)
		self.__divide_with(3)
		self.__divide_with(5)
			
		# 平方根以下の素数で総当たりで試し割りする
		# (実際は、素数らしき数)
		import math
		sqrt_ = math.floor(math.sqrt(self.__n))
			
		primes = [7, 11, 13, 17, 19, 23, 29, 31]
		i = 0
		is_break = False
			
		while self.__n > 1:
			for p in primes:
				if p + i <= sqrt_:
					self.__divide_with(p + i)
				else:
					# 試し割りする数が平方根を超えたら、ループを抜ける
					is_break = True
						
					# 1が素因数に追加されることを防止
					if self.__n > 1:
						self.__factors.setdefault(self.__n, 1)
				
			if is_break:
				break
			else:
				i += 30
	
	
	def __divide_with(self, d):
		count = 0
		
		while self.__n % d == 0:
			self.__n //= d
			count += 1
		
		if count > 0:
			self.__factors.setdefault(d, count)


# C - Digits in Multiplication
n = int(input())

lib = Factorization()
divisors = lib.get_divisors(n)
divisors.sort()

ans = len(str(n))

for a in divisors:
	if a > n / 2:
		break
	else:
		b = n // a
		f = max(len(str(a)), len(str(b)))
		ans = min(ans, f)

print(ans)

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define MAX 510000
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n; cin >> n;
    cout << pow(n,3) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#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() {
	int K;
	cin >> K;
	vector<int> a = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	cout << a[K - 1] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
	int n;
	
	char s[100001];
	
	char c;
	
	long t;
	t=1;
	
	
	long i;
	
	int ret;
	
	ret = scanf("%d",&n);
	ret = scanf("%s",s);
	
	c=s[0];
	
	
	for(i=1; i<n; i++){
	
		if(c!=s[i]){
			t++;
			c=s[i];
		}
		
	}
	
	printf("%ld\n",t);
	
	return 0;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,n) for(long long i=0;i<n;i++)
#define SFOR(i,a,b) for(long long i=a;i<b;i++)
#define elif(a) else if(a)
#define INF INT_MAX
#define F first
#define S second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a;
  string s;
  cin>>a>>s;
  if(a>=3200) cout<<s<<endl;
  else cout<<"red"<<endl;
  return 0;
}



Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    if s > '2019/04/30':
        return 'TBD'

    return 'Heisei'



print(main())




Measured memory_bytes: 5584
object Main extends App {
    var get = readLine.split(" ")
    var n = get(0).toInt
    var m = get(1).toInt
    var c = get(2).toInt
  
    var get2 = readLine.split(" ")
	val b = new Array[Int](m)
    var a = new Array[Int](m)
    var ans=0
  	for(loop <- 0 to m - 1) {
	  b(loop)=get2(loop).toInt
    }
  	for(loop <- 0 to n - 1){
      var get3 = readLine.split(" ")
      var sum=0
      for(loop2 <- 0 to m - 1){
        sum+=b(loop2)*get3(loop2).toInt
      }
      if(sum+c>0)
      	ans+=1
    }      
  println(ans)
}

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

namespace 競プロ_Csharp {
    class Program {
        static void Main(string[] args) {

            while (true) {

                int[] a = NextInts();
                if (a[0] == 0 && a[1] == 0) return;

                Array.Sort(a);
                Println(string.Join(" ", a));

            }

        }

        public static void Println (Object o) {
            Console.WriteLine(o);
        }

        public static string NextString() {
            return Console.ReadLine();
        }

        public static int NextInt () {
            return int.Parse(Console.ReadLine());
        }

        public static int[] NextInts () {
            string[] a = Console.ReadLine().Split();
            int[] b = new int[a.Length];
            for (int i = 0; i < a.Length; i++) {
                b[i] = int.Parse(a[i]);
            }
            return b;
        }

    }
}



Measured memory_bytes: 20008
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, p = -1, q = -1;

  std::cin >> N;

  std::vector<int> P(N), Q(N), a(N);

  for (auto& i : P)
    std::cin >> i;

  for (auto& i : Q)
    std::cin >> i;

  std::iota(ALL(a), 1);

  int i = 0;

  do {
    i ++;
    
    if (a == P)
      p = i;

    if (a == Q)
      q = i;
  } while (std::next_permutation(ALL(a)));

  std::cout << std::abs(p - q) << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var r = parseInt(input[0].split(" ")[0]);
  var D = parseInt(input[0].split(" ")[1]);
  var x = parseInt(input[0].split(" ")[2]);
  var anss = new Array(10);
  anss[0]=x*r-D;
  for(var i=1;i<10;i++){
    anss[i]=anss[i-1]*r-D;
  }
  var ans=anss.join("\n");

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(int argc, const char * argv[]) {
    
    int x[5],y[5];
    
    cin >> x[1] >> y[1] >> x[2] >> y[2];
    
    if(x[2]>x[1]){
        if(y[2]>y[1]){
            x[3]=x[2]-(y[2]-y[1]);
            y[3]=y[2]+(x[2]-x[1]);
            x[4]=x[3]-(x[2]-x[1]);
            y[4]=y[3]-(y[2]-y[1]);
        }
        else{
            x[3]=x[2]+(y[1]-y[2]);
            y[3]=y[2]+(x[2]-x[1]);
            x[4]=x[3]-(x[2]-x[1]);
            y[4]=y[3]+(y[1]-y[2]);
        }
    }
    else{
        if(y[2]>y[1]){
            x[3]=x[2]-(y[2]-y[1]);
            y[3]=y[2]-(x[1]-x[2]);
            x[4]=x[3]+(x[1]-x[2]);
            y[4]=y[3]-(y[2]-y[1]);
        }
        else{
            x[3]=x[2]+(y[1]-y[2]);
            y[3]=y[2]-(x[1]-x[2]);
            x[4]=x[3]+(x[1]-x[2]);
            y[4]=y[3]+(y[1]-y[2]);
        }
    }
    
    cout << x[3] << " " << y[3] << " " << x[4] << " " << y[4] << endl;
    
    return 0;
}


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

int main() {

  int N;
  cin >> N;
  if (N==100000000){
    cout << "Yes" << endl;
  }
  else{
  int one = N%10; //1桁目
  int two = (N-one)/10%10; //2桁目
  int three = (N-one-two*10)/100%10; //3桁目
  int four = (N-one-two*10-three*100)/1000%10;
  int five = (N-one-two*10-three*100-four*1000)/10000%10;
  int six  = (N-one-two*10-three*100-four*1000-five*10000)/100000%10;
  int seven = (N-one-two*10-three*100-four*1000-five*10000-six*100000)/1000000%10;
  int eight = (N-one-two*10-three*100-four*1000-five*10000-six*100000-seven*1000000)/10000000%10;
  int S = one+two+three+four+five+six+seven+eight;
   if(N%S == 0){
   cout << "Yes" << endl;
   }
   else{
     cout << "No" << endl;
   }
  }
}
  
  
  
  
  


    
 








Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  char c[h][w];
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin >> c[i][j];
    }
  }
  for(int i=1; i<=2*h; i++){
    for(int j=0; j<w; j++){
      cout << c[(i+1)/2-1][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
dp = [float('inf')] * 100010

dp[0] = 0

for i in range(n + 1):

  dp[i] = min(dp[i], dp[i-1] + 1)

  power = 6
  while(power <= i):
    dp[i] = min(dp[i], dp[i - power] + 1)
    power *= 6

  power = 9
  while (power <= i):
    dp[i] = min(dp[i], dp[i - power] + 1)
    power *= 9


print(dp[n])

Measured memory_bytes: 45660
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
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;}
int const INF = 1001001001;

void err() {
    cout << -1 << endl;
    exit(0);
}

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

int n;
cin >> n;
vi b(n);
rep(i,n) cin >> b[i];

vi ans;
while(!b.empty()) {
    int cur = -1;
    rep(i,SZ(b)) {
        if(b[i] == i+1) cur = i;
    }
    if(cur == -1) err();
    ans.push_back(b[cur]);
    b.erase(b.begin() + cur);
}
drep(i,n) cout << ans[i] << endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

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

int main() {
  int k,ans;
  cin >> k;
  if (k % 2 == 0) {
    cout << (k/2)*(k/2);
  } else {
    cout << (k/2)*(k/2 +1);
  }
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        if(n==1)
        {
            Console.WriteLine("Hello World");
        }
        else
        {
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            Console.WriteLine(a + b);
        }
    }   
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e17;
#define int long long

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	VE a(m), b(m), c(m);
	rep(i, m) {
		cin >> a[i] >> b[i] >> c[i];
		c[i] *= -1;
	}
	VE dist(n); rep(i, n)dist[i] = INF;
	dist[0] = 0;
	rep(tmp, n - 1) {
		rep(i, m) {
			if (dist[a[i] - 1] == INF)continue;
			if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
				dist[b[i] - 1] = dist[a[i] - 1] + c[i];
			}
		}
	}
	int ans = dist[n - 1];
	VE negative(n); rep(i, n)negative[i] = false;
	rep(tmp, n) {
		rep(i, m) {
			if (dist[a[i] - 1] == INF)continue;
			if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
				dist[b[i] - 1] = dist[a[i] - 1] + c[i];
				negative[b[i] - 1] = true;
			}
			if (negative[a[i] - 1] == true) {
				negative[b[i] - 1] = true;
			}
		}
	}
	if (negative[n - 1])cout << "inf" << endl;
	else cout << ans * (-1) << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>

using namespace std;
int n;
int main()
{
  cin >> n;
  float a[n];
  string b[n];
  float ans = 0.0f;
  for (int i=0; i<n; i++) {
    cin >> a[i] >> b[i];
    if(b[i] == "JPY")
       ans += a[i];
    else
      ans += a[i] * 380000.0f;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[3*114514];
int b[3*114514];
int c[3*114514];
signed main(){
  int n;
  cin>>n;
  for(int i=0;i<n*3;i++) cin>>a[i];
  priority_queue<int,vector<int>,greater<int> > q1;
  priority_queue<int> q2;
  memset(b,0,sizeof(b));
  memset(c,0,sizeof(c));
  int tmp1=0,tmp2=0;
  for(int i=0;i<n;i++){
    q1.push(a[i]);
    tmp1+=a[i];
    b[i]=tmp1;
    q2.push(a[3*n-1-i]);
    tmp2+=a[3*n-1-i];
    c[3*n-1-i]=tmp2;
  }
  for(int i=n;i<n*3;i++){
    q1.push(a[i]);
    tmp1+=a[i];
    int k=q1.top();q1.pop();
    tmp1-=k;
    b[i]=tmp1;
    q2.push(a[3*n-1-i]);
    tmp2+=a[3*n-1-i];
    k=q2.top();q2.pop();
    tmp2-=k;
    c[3*n-1-i]=tmp2;
  }
  int ans=-(1LL<<55LL);
  for(int i=n-1;i<2*n;i++){
    ans=max(ans,b[i]-c[i+1]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 9716
open Printf open Scanf
open Array

let () = scanf " %d" @@ fun n ->
  let edges = make n [] in
  let arr = init (n-1) (fun _ -> scanf " %d %d %d" @@ fun u v w ->
    (* u,v,w *)
    edges.(u-1) <- (v-1,w) :: edges.(u-1);
    edges.(v-1) <- (u-1,w) :: edges.(v-1);
  ) in
  let color = make n 2 in
  let rec dfs i c =
    if color.(i) <> 2 then ()
    else (
      color.(i) <- c;
      List.iter (fun (j,w) ->
        if w mod 2 = 0 then dfs j c
        else dfs j (1-c)
      ) edges.(i);
    )
  in dfs 0 0;
  iter (printf "%d\n") color


Measured memory_bytes: 19840
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <random>
#include <chrono>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < int(n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using ll = long long;
using namespace std;
bool solve(vector<int> & a) {
    auto start = chrono::system_clock::now();
    int n = a.size();
    const ll nc2 = n*(n+1ll)/2;
    const ll sum_a = whole(accumulate, a, 0ll);
    if (sum_a % nc2 != 0) return false;
    repeat (q, sum_a / nc2) {
        int i = whole(min_element, a) - a.begin();
        if (a[i] <= 0) break;
        repeat      (k,i)   a[k] -= (n+k)-i+1;
        repeat_from (k,i,n) a[k] -=    k -i+1;
        if (q % 10 == 0) {
            auto end = chrono::system_clock::now();
            double t = chrono::duration<double>(end - start).count();
            if (t > 1.9) {
                random_device device;
                uniform_int_distribution<int> dist(0, 1);
                return dist(device);
            }
        }
    }
    return whole(count, a, 0) == n;
}
int main() {
    int n; cin >> n;
    vector<int> a(n); repeat (i,n) cin >> a[i];
    cout << (solve(a) ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 1272
#include<stdio.h>
int main()
{
    int del[100000];
    int i,k,n,sum=0;
    scanf("%d",&n);
    scanf("%d",&k);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&del[i]);
    }
    for(i=1;i<=n;i++)
    {
        if(del[i]>=k)
            sum++;
    }
    printf("%d",sum);
}


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



int a, b;

int main() {

	cin >> a >> b;
	cout << max(a + b,max(a - b, a * b)) << endl;

	return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define range_for(i, b, e) for(int i=(b), i##_len=(e); i<=i##_len; ++i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define pb push_back
# define len(x) ((int)(x).size())
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
# define LINT_MAX (LONG_LONG_MAX)
# define cauto const auto
using namespace std;
using lint = long long;
template <class Type> inline constexpr bool InRange(const Type& x, const Type& i, const Type& a) { return (i <= x) && (x <= a); }
template<class Integer>bool chmax(Integer &a, const Integer &b) { if (a<b) { a=b; return 1; } return 0; }
template<class Integer>bool chmin(Integer &a, const Integer &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Integer>bool IsOdd(Integer &n) { return n & 1; }
template<class Integer>bool IsEven(Integer &n) { return !(n & 1); }
int ctoi(const char c) { return ('0' <= c && c <= '9') ? (c - '0') : -1; }
string YesNo(bool b) { return b ? "Yes" : "No"; }
string YESNO(bool b) { return b ? "YES" : "NO"; }
string yesno(bool b) { return b ? "yes" : "no"; }
int dy[4] = {0, 1, 0, -1};
int dx[4] = {1, 0, -1, 0};

// 整数の桁数を返す ( log(N) )
template <class Integer> Integer GetDigit(Integer n) {
    if (n == 0) return 1;
    Integer d = 0;
    while (n) {
        n /= 10;
        d++;
    }
    return d;
}

// 素数かどうかを返す ( O(sqrt(N)) )
template <class Integer>
constexpr bool IsPrime(const Integer n) noexcept {
    if (n < 4) return n == 2 || n == 3;
    if (n % 2 == 0 || n % 3 == 0 || (n % 6 != 1 && n % 6 != 5)) return false;
    for (Integer i = 5; i * i <= n; i += 6) if (n % i == 0 || n % (i + 2) == 0) return false;
    return true;
}

const double PI=3.141592653589;
int main()
{
    int R; cin >> R;
    double r = R;
    cout << 2.0*PI*r << endl;

    return 0;
}


Measured memory_bytes: 3724
# import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()
    zero = s.count("0")
    one = s.count("1")
    print(2 * min(zero, one))

if __name__ == '__main__':
    main()

Measured memory_bytes: 39152
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
    
    
public class Main {
	static int INF = 2 << 27;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if(n == 0) break;
			Data[] data = new Data[n];
			for (int i = 0; i < n; i++) {
				data[i] = new Data(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt());
			}
			Arrays.sort(data);
			HashMap<String, Integer> map = new HashMap<String, Integer>();
			int count = 0;
			for (int i = 0; i < n; i++) {
				if (count < 10) {
					if (map.containsKey(String.valueOf(data[i].u))) {
						if(map.get(String.valueOf(data[i].u)) < 3) {
							map.put(String.valueOf(data[i].u), map.get(String.valueOf(data[i].u)) + 1);
							System.out.println(data[i].i);
							count++;
						}
					} else {
						map.put(String.valueOf(data[i].u), 1);
						System.out.println(data[i].i);
						count++;
					}
				} else if (count < 20) {
					if (map.containsKey(String.valueOf(data[i].u))) {
						if (map.get(String.valueOf(data[i].u)) < 2) {
							map.put(String.valueOf(data[i].u), map.get(String.valueOf(data[i].u)) + 1);
							System.out.println(data[i].i);
							count++;
						}
					} else {
						map.put(String.valueOf(data[i].u), 1);
						System.out.println(data[i].i);
						count++;
					}
				} else if (count < 26) {
					if (map.containsKey(String.valueOf(data[i].u))) {
						if (map.get(String.valueOf(data[i].u)) < 1) {
							map.put(String.valueOf(data[i].u), map.get(String.valueOf(data[i].u)) + 1);
							System.out.println(data[i].i);
							count++;
						}
					} else {
						map.put(String.valueOf(data[i].u), 1);
						System.out.println(data[i].i);
						count++;
					}
				} else {
					break;
				}

			} 
		}
		
		
	}
	static class Data implements Comparable<Data>{
		int i;
		int u;
		int a;
		int p;
		Data(int i, int u, int a, int p) {
			this.i = i;
			this.u = u;
			this.a = a;
			this.p = p;
		}
		@Override
		public int compareTo(Data o) {
			if(o.a == this.a) {
				if(o.p == this.p) {
					return this.i - o.i;
				}
				return this.p - o.p;
			}
			return o.a - this.a;
		}
	}
	
	
	
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;

int main() {
    int n,m,l;cin >>n>>m>>l;
    vector<vector<ll>>d(n,vector<ll>(n,INF));
    for (int i = 0; i < n; ++i) {
        d[i][i]=0;
    }
    for (int i = 0; i < m; ++i) {
        int a,b,c;cin >>a>>b>>c;
        if(c>l)continue;
        a--;b--;
        d[a][b]=c;
        d[b][a]=c;
    }
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    vector<vector<ll>>d2(n,vector<ll>(n,INF));
    for (int i = 0; i <n; ++i) {
        for (int j = 0; j < n; ++j) {
            if(d[i][j]<=l){
                d2[i][j]=1;
                d2[j][i]=1;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        d2[i][i]=0;
    }
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                d2[i][j]=min(d2[i][j],d2[i][k]+d2[k][j]);
            }
        }
    }
    int q;cin >>q;
    for (int i = 0; i < q; ++i) {
        int s,t;cin >>s>>t;
        s--;t--;
        if(d2[s][t]==INF)cout <<-1<<endl;
        else cout <<d2[s][t]-1<<endl;
    }
}


Measured memory_bytes: 5064
from itertools import accumulate
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

ans = N

seq = 1
for i in range(N-1):
    if a_acc[i]*2 >= A[i+1]:
        seq += 1
    else:
        ans -= seq
        seq = 1
print(ans)


Measured memory_bytes: 14472
package main

import "fmt"

func main() {
	var l, r int
	fmt.Scan(&l, &r)

	var min int
	ans := 9999

	for i := l; i < r; i++ {
		for j := i + 1; j <= r; j++ {
			min = i * j % 2019
			if min < ans {
				ans = min
				if ans == 0 {
					break
				}
			}
		}
		if ans == 0 {
			break
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max
#include <string>	//string
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt
#include <sstream>	//stringstream,getline
#include <cmath>	//ceil

using namespace std;

int main() {

	int X;
	cin >> X;

	if (X >= 30) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;

}

Measured memory_bytes: 3632
use std::io::Read;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();
    let c: usize = iterator.next().unwrap().parse().unwrap();

    let ans = min(a + b, min(b + c, c + a));
    return ans.to_string();
}


Measured memory_bytes: 2136
n = gets.chomp.to_i
s = gets.chomp
r = 0
g = 0
b = 0
list = {}
list["R"] = []
list["G"] = []
list["B"] = []
n.times do |i|
  r += 1 if s[i] == "R"
  g += 1 if s[i] == "G"
  b += 1 if s[i] == "B"
end
ans = r * g * b
cnt = 0

n.times do |i|
  mar = 1
  while i-mar>=0 && i+mar<n do
    cnt += 1if s[i] != s[i-mar] && s[i] != s[i+mar] && s[i-mar] != s[i+mar]
    mar += 1
  end
end
puts ans - cnt

Measured memory_bytes: 14380
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <ll,ll>
#define N 300005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;


int main() 
{ 
	ll ans = 0, cnt;
    string s;
    int pre[N];
    cin >> s;
    cnt = 0;
    for (int i = 0; i < (int) s.size(); ++i)
    {
    	if(s[i] == 'W')
    	{
    		ans += cnt;
    	}
    	else
    	{
    		cnt++;
    	}
    }
    cout << ans;
} 

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
#include <ctype.h> // isdigit
#include <cassert>
using namespace std;

#define LE(n,m) ((n) < (m) + EPS * (abs(n) + abs(m)))
#define GE(n,m) ((n) + EPS * (abs(n) + abs(m)) > (m))
#define LT(n,m) ((n) + EPS * (abs(n) + abs(m)) < (m))
#define GT(n,m) ((n) > (m) + EPS * (abs(n) + abs(m)))
#define EQ(n,m) (abs((n)-(m)) < EPS * (abs(n) + abs(m)))

typedef long long int ll;
const int INF = (1<<30) - 1;
const double EPS = 1e-9;
const int MOD = 1000000007;

int N, M, Q;

set<int> merge(set<int> a, set<int> b){
    set<int> ret;
    for(auto p: a) if(b.find(p) != b.end()){
        ret.insert(p);
    }
    return ret;
}

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(16);
    //cout.setf(ios::fixed);
    
    while(cin >> N >> M >> Q, N|M|Q){
        string s, b;
        ll t = 0;
        vector<set<int>> conds(N);
        for(int j=0; j<N; j++){
            for(int k=0; k<M; k++)
                conds[j].insert(k);
        }
        
        for(int i=0; i<Q; i++){
            cin >> s >> b;
            
            set<int> cond;
            set<int> excond;
            
            for(int j=0; j<M; j++){
                if(b[j] == '1'){
                    cond.insert(j);
                }else{
                    excond.insert(j);
                }
            }
            
            for(int j=0; j<N; j++){
                if(s[j] == '1')
                    t ^= (1L<<j);
                if((t>>j) & 1L){
                    conds[j] = merge(conds[j], cond);
                }else{
                    conds[j] = merge(conds[j], excond);
                }
            }
        }
        
        vector<vector<int>> ans(M);
        
        for(int i=0; i<N; i++){
            for(auto p: conds[i])
                ans[p].push_back(i);
        }
        for(int i=0; i<M; i++){
            if(ans[i].size() != 1){
                cout << '?';
            }else{
                if(ans[i][0] < 10){
                    cout << ans[i][0];
                }else{
                    cout << (char('A'+(ans[i][0]-10)));
                }
            }
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 5004