akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		
		FastScanner fs = new FastScanner();
		
		int n = fs.nextInt();
		HashMap<String, Integer> nameStartNum = new HashMap<>();
		nameStartNum.put("M", 0);
		nameStartNum.put("A", 0);
		nameStartNum.put("R", 0);
		nameStartNum.put("C", 0);
		nameStartNum.put("H", 0);
		
		String[] startCharArr = {"M", "A", "R", "C", "H"};
		
		for(int i = 0; i < n; i++) {
			String name = fs.next();
			
			char startChar = name.charAt(0);
			
			if(startChar == 'M') {
				incrementMap("M", nameStartNum);
			}else if(startChar == 'A') {
				incrementMap("A", nameStartNum);
			}else if(startChar == 'R') {
				incrementMap("R", nameStartNum);
			}else if(startChar == 'C') {
				incrementMap("C", nameStartNum);
			}else if(startChar == 'H') {
				incrementMap("H", nameStartNum);
			}
		}
		
		long ans = 0;
		for(int i = 0; i < startCharArr.length; i++) {
			for(int j = i+1; j < startCharArr.length ;j++) {
				for(int k = j+1 ; k < startCharArr.length; k++) {
					
					ans += (long)nameStartNum.get(startCharArr[i]) * (long)nameStartNum.get(startCharArr[j]) * (long)nameStartNum.get(startCharArr[k]);
				}
			}
		}
		
		System.out.println(ans);
		
	}
	
	
	void incrementMap(String key, HashMap<String, Integer> map) {
		int val = map.get(key);
		map.put(key, val+1);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}


}


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

int main(){
    char letter;

    cin >> letter ;

    switch (letter)
    {
    case 'a':
        cout << "vowel" << endl;
        break;
    case 'e':
        cout << "vowel" << endl;
        break;
    case 'i':
        cout << "vowel" << endl;
        break;
    case 'o':
        cout << "vowel" << endl;
        break;
    case 'u':
        cout << "vowel" << endl;
        break;
    
    default:
        cout << "consonant" << endl;
        break;
    }

}

Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int
	scanner.Scan()
	N, _ = strconv.Atoi(scanner.Text())
	var K int
	scanner.Scan()
	K, _ = strconv.Atoi(scanner.Text())
	p := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		p[i], _ = strconv.Atoi(scanner.Text())
	}
	fmt.Println(solve(N, K, p))
}
func solve(N int, K int, p []int) (sum int) {
	sort.Ints(p)
	for i := 0; i < K; i++ {
		sum += p[i]
	}
	return sum
}


Measured memory_bytes: 1780
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
using namespace std;


int main() {
	int n, a;
	cin >> n >> a;
	if (n % 500 <= a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include "stdc++.h"
using namespace std;
 
#define int long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
int MOD=1000000007;


int32_t main(){
  char c;
  cin>>c;
  int k=(int)c;
  cout<<(char)(k+1)<<'\n';

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main(){
  int x;
  cin>>x;
  cout<<x*360/__gcd(x,360)/x<<endl;
  return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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, a[10], b[10];
void solve(){
	cin >> n >> m;
	char c[3] = {'.','.','.'};
	for(int i = 0; i < m; i++){
		cin >> a[i] >> b[i];
		a[i]--;
		c[a[i]] = (char)('0'+b[i]);
	}
	
	for(int i = 0; i < m; i++){
		if(c[a[i]] != (char)('0'+b[i])){
			cout << -1 << endl;
			return;
		}
	}
	for(int i = 0; i < n; i++){
		if(c[i] == '.'){
			if(i == 0 && n != 1) cout << 1;
			else cout << 0;
		}
		else{
			if(i == 0 && c[i] == '0' && n != 1){
				cout << -1 << endl;
				return;
			}
			cout << c[i];
		}
	}
	cout << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 384
s = input()
t = input()
n = len(s)

a = [0 for i in range(26)]
b = [0 for i in range(26)]

for i in range(n):
    a[ord(s[i])-ord("a")] += 1
    b[ord(t[i])-ord("a")] += 1
    
a.sort()
b.sort()

if a == b:
    print("Yes")
else:
    print("No")


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

int main() {
  int n,k;cin>>n>>k;
  vector<int> vec(n);
  rep(i,n)cin>>vec[i];
  sort(all(vec));
  int ans=0;
  rep(i,k){
    ans+=vec[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
module Main where

import           Control.Monad
import           Data.List
import           Data.Ord
import           Data.List.Split
import           Data.Array.IO
import qualified Data.Vector.Unboxed as V

main :: IO ()
main = do
  x <- readLn :: IO Int
  print $ f x
  where
    f x | x == 1 = 1
        | otherwise = maximum [g x n (n * n) | n <- [2 .. x]]
    g x a aa | aa > x = 0
             | (aa * a) > x = aa
             | otherwise = g x a (aa * a)


Measured memory_bytes: 508
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });

            var S = ReadLine();
            if (S.Length == S.Distinct().Count())
                WriteLine("yes");
            else
                WriteLine("no");
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13268
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		ArrayList<Long>masu=new ArrayList<>(); 
		
		int a=0;
		int count=0;
		
		for(int i=0;i<n;i++) {
			masu.add(sc.nextLong());
		}
		
		
		for(int i=0;i<n-1;i++) {
			if(masu.get(i+1)<=masu.get(i)) {
				count++;
			}else {
				count=0;
			}
			if(a<count) {
				a=count;
			}
		}
		
		System.out.println(a);
		sc.close();
	}
}

Measured memory_bytes: 58164
import java.util.Scanner;

class Main {
	public static void main(String[] arg){
		Scanner in = new Scanner(System.in);
		int x = in.nextInt();	
		int y = in.nextInt();
		System.out.printf("%d %d %.8f\n",(int)x/y, x%y,x/(double)y);
	}
}

Measured memory_bytes: 17324
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int count;
		int n;
		
		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}
			count = 0;
			while (n != 1) {
				if (n % 2 == 0) {
					n /= 2;
				} else {
					n *= 3;
					n += 1;
				}
				count++;
			}
			System.out.println(count);
		}
	}
}

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

#define N 100123
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define fastio ios::sync_with_stdio(false); cin.tie(0)

vector<pair<int, int> > adj[N];
int color[N];

void dfs(int u, int prev, int col){
	color[u] = col;
	for(auto i : adj[u]){
		if(i.first != prev){
			int curr = col;
			if(i.second % 2) curr ^= 1;
			dfs(i.first, u, curr);
		}
	}
}

int main(){
    fastio;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.in", "r", stdin);
    //     freopen("output.out", "w", stdout);
    // #endif
    int u, v, w, n;
    cin >> n;
    for(int i = 1 ; i < n ; i++){
    	cin >> u >> v >> w;
    	adj[u].pb(mp(v,w));
    	adj[v].pb(mp(u,w));
    }

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

    return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define FINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int C,N,M;
int s[10010],p[10010];
int dp[2][10010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> C >> N >> M;
  REP(i,N) cin >> s[i] >> p[i];
  int cur = 0, nxt = 1;
  REP(i,N) {
    for (int j = 0; j <= C; j++) {
      CHMAX(dp[nxt][j],dp[cur][j]);
      if (j+s[i] <= C) CHMAX(dp[nxt][j+s[i]],dp[cur][j]+p[i]);
    }
    swap(cur,nxt);
  }
  FOR(i,1,M+1) cout << dp[cur][C/i]*i << endl;

  return 0;
}


Measured memory_bytes: 3480
import math
N = int(input())
sum=0
for i in range(1,N+1):
    for j in range(1,N+1):
        if math.gcd(i, j)==1:
            sum+=N
        else:
            for k in range(1,N+1):
                sum += math.gcd(math.gcd(i, j),k)
print(sum)

Measured memory_bytes: 9192
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


#define all(c) c.begin(), c.end()


using namespace std;

// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}

template<class T>
vector<T> next_vector(istream& in, size_t n) {
    vector<T> ret(n);
    for (size_t i = 0; i < n; ++i) {
        ret[i] = next<T>(in);
    }
    return ret;
}


void solve(istream& in, ostream& out) {
  auto n = next<int>(in);
  auto k = next<int>(in);
  auto a = next_vector<int>(in, n);
  map<int, int> counter;
  for (int i : a) {
    counter[i]++;
  }
  vector<int> groups;
  for (auto p : counter) {
    groups.push_back(p.second);
  }
  sort(all(groups));
  if (groups.size() <= k) {
    out << "0\n";
    return;
  }
  int res = 0;
  reverse(all(groups));
  while (groups.size() > k) {
    res += groups.back();
    groups.pop_back();
  }
  out << res << "\n";
}


//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



Measured memory_bytes: 11640
#include<bits/stdc++.h>
using namespace std;
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vll = vector<vl>;
using vii = vector<vi>;
using pii = pair<int, int>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


const int MOD = 1e9 + 7;


int main(){
  string s; cin >> s;
  int n = s.size();
  int a = abs(753 - stoi(s.substr(0, 3)));
  for(int i = 1; i < n - 2;i++){
    int k = abs(753 - stoi(s.substr(i, 3)));
    if(a > k) a = k;
  }
  cout << a << endl;
  return 0;
}

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

#define vl vector<ll>
#define vs vector<string>
#define vll vector< vector<ll> >
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define psl pair<string,ll>
#define tll tuple<ll, ll, ll>
#define vp vector< pair<ll,ll> >
#define vt vector< tuple<ll, ll, ll> >
#define all(c) c.begin(),c.end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

//command
//c++ atcoder.cpp -std=c++14
//./a.out

//cout << setprecision(12) << ans << endl;

#define NN 2020202

int main(){
  ll n, C;
  cin >> n >> C;
  vt vec;
  ll s, t, c;
  for (int i=0;i<n;i++){
    cin >> s >> t >> c;
    vec.push_back(tll(s,t,c));
  }

  sort(vec.begin(), vec.end());

  ll ans = 0;
  bool flag;
  pll ch[C];
  ch[0] = pll(get<1>(vec[0]), get<2>(vec[0]));

  for (int i=1;i<n;i++){
    flag = false;
    for (int j=0;j<=ans;j++){
      if (ch[j].first <= get<0>(vec[i]) && ch[j].second == get<2>(vec[i])){
        ch[j].first = get<1>(vec[i]);
        ch[j].second = get<2>(vec[i]);
        flag = true;
        break;
      }
      else if (ch[j].first < get<0>(vec[i]) && ch[j].second != get<2>(vec[i])){
        ch[j].first = get<1>(vec[i]);
        ch[j].second = get<2>(vec[i]);
        flag = true;
        break;
      }
    }
    if (!flag){
      ch[ans+1].first = get<1>(vec[i]);
      ch[ans+1].second = get<2>(vec[i]);
      ans += 1;
    }

    //for (int j=0;j<=ans;j++) cout << ch[j].first << " ";
    //cout << endl;
  }

  cout << ans+1 << endl;
}

Measured memory_bytes: 4980
#include<bits/stdc++.h>
using namespace std;
string str;
bool is(int x, int y);
int main()
{
	cin >> str;
	cout << ((is(0, str.length() - 1) && is(0, str.length() / 2 - 1) && is(str.length() / 2 + 1, str.length() - 1)) ? "Yes" : "No") << endl;
	return 0;
}
bool is(int x, int y)
{
	while (x <= y)
	{
		if (str[x] != str[y])
			return false;
		x++;
		y--;
	}
	return true;
}


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

#define min3(a,b,c)   min(a,min(b,c))
#define max3(a,b,c)   max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))

#define count_one(a) __builtin_popcount(a)  // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
#define parity(i)    __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)       __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)       __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
#define gcd(a,b)     __gcd(a,b)
#define lcm(a,b)     (a*(b/gcd(a,b)))

#define pb   push_back
#define PI   M_PI
#define endl "\n"
#define sc   scanf
#define pf   printf

#define ll  long long
#define ull unsigned long long

#define W(t)            while(t--)
#define rep1(i,n)       for(int i = 0; i < n; i++)
#define rep2(a,b)       for(int i = a; i <= b; i++)
#define rep3(a,b,c)     for(int i = a; i <= b; i+=c)
#define irep(a,b,c)     for(int i = b; i >=a; i-=c)
#define repit(it,type)  for(it = type.begin(); it != type.end(); it++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;
using namespace __gnu_cxx;

int main()
{
     IOS
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll n,k,q,i,x,q1;
    map<ll,ll> freq;

    cin>>n>>k>>q;
    q1 = q;

    W(q)
    {
         cin>>x;
         freq[x]++;
    }
    for(i = 1; i <= n; i++)
    {
         if(freq[i]+k-q1 > 0)
          cout<<"Yes\n";
         else
          cout<<"No\n";
    }

     return 0;
}



Measured memory_bytes: 9888
/*****************************************************

@author: vichitr
Compiled On: 27th April 2019

*****************************************************/

#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define pb push_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define ip pair<int, int>

#define loop(i,n) for(int i=0;i<n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;

const ll MOD = 1e9+7;
const ll SZ = 107;
const ll N = 2e5+7;

int pow(int x, int y)
{
    ll r = 1LL;
    while(y)
    {
        if(y&1)
            r = (r * x);
        y >>= 1;
        x = (x * x);
    }
    return r;
}

void solve()
{
    int n;cin>>n;
    int v[n], c[n], ans = 0;
    for(int i=0;i<n;i++) cin>>v[i];
    for(int i=0;i<n;i++) cin>>c[i];
    for(int i=0;i<n;i++)
    {
        if(v[i]>c[i])
            ans += v[i]-c[i];
    }
    cout<<ans;
}

signed main()
{
    fast;

    int t=1;
    // cin >>t;
    while(t--){
        solve();
    }
    return 0;
}

/*****************************


****************************/

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

#define all(x) (x).begin(),(x).end()
#define endl '\n'
//#define int long long


signed main() { //[J][O][L][S][K][E][Y]
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int n, m; cin >> n >> m;
        cout << n*(n-1) / 2 + m*(m - 1) / 2;
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int main(void){
    int n;cin>>n;
    string s;cin>>s;
    int ans = 1;
    char now = s.at(0);
    rep(i,n){
        if(s.at(i)!=now){
            ans++;
            now = s.at(i);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  int P[N];
  for (int i=0; i<N; i++){
    cin>>P[i];}
  int Q[N];
  for (int i=0; i<N; i++) Q[i]=P[i];
  sort(Q,Q+N);
  int counter=0;
  for (int i=0; i<N; i++){
    if (P[i]!=Q[i]) {counter++;}
  }
  if(counter<=2) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}
       
  
       

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

int main() {
    int n, t;
    scanf("%d %d", &n, &t);
    int ans = max(n-t, 0);
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 998244353;
const double pi = 3.141592653589793;

ll mypow(ll a, ll b)
{
	ll r = 1ll;
	while(b != 0){
		if(b&1) r = r * a % MOD;
		a = a * a % MOD;
		b /= 2;
	}
	return r;
}

vector<ll> fac;
vector<ll> ifac;

void factorial_init(ll n)
{
	fac.resize(n+1);
	ifac.resize(n+1);
	fac[0] = 1;
	ifac[0] = 1;
	REP(i,n) {
		fac[i+1] = fac[i] * (i + 1) % MOD;
		ifac[i+1] = ifac[i] * mypow(i + 1, MOD - 2) % MOD;
	}
}

ll Combination(ll a, ll b)
{
	if(a == 0 && b == 0) return 1;
	if(a < b || a < 0) return 0;
	ll r = ifac[a-b] * ifac[b] % MOD;
	return r * fac[a] % MOD;
}

int main()
{
	int n, m, k;
	ll ans = 0ll;
	cin>>n>>m>>k;

	factorial_init(n+1);

	REP(i,k+1) {
		ll tmp;
		tmp = (mypow(m-1, n-i-1) * m) % MOD;
		tmp *= Combination(n-1,i);
		ans += tmp;
		ans %= MOD;
		//cout<<i<<" "<<Combination(n-1,i)<<endl;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 6356
K = int(input())

G = [((10*i % K, 0), ((i+1) % K, 1)) for i in range(K)]
s = 1

dist = [10**9] * K
S = [s]
T = []
dist[s] = 0

d = 0
while S:
    while S:
        v = S.pop()
        for w, c in G[v]:
            if d+c < dist[w]:
                dist[w] = d+c
                if c:
                    T.append(w)
                else:
                    S.append(w)
    S, T = T, S
    d += 1

print(dist[0]+1)

Measured memory_bytes: 30488
import java.util.*;
public class Main {
	
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		long T = sc.nextLong();
		
		long start = sc.nextLong();
		long ans = T;
		for (int i = 1; i < N; i++) {
			long ti = sc.nextLong();
			ans += Math.min(T, ti - start);
			
			start = ti;
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 62436
#include <iostream>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
using namespace std;


int main()
{
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << H*W - h*W - H*w + h*w  << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

namespace Printer{
    void print(vector<int> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    void print(vector<vector<int> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};

//--global--//



//----------//

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    int n, m;
    cin >> n >> m;
    vector<int> used(n);
    vector<vector<int> > e(n);
    vector<pair<int, int> > inpE(m);
    fill(ALL(used), 0);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        e[a].push_back(b);
        e[b].push_back(a);
        inpE[i] = make_pair(a, b);
    }

    int ans = 0;
    rep(i, m){
        //cout << "----" << i << "----" << endl;
        //Printer::print(inpE[i]);
        fill(ALL(used), 0);
        queue<int> q;
        q.push(0);
        used[0] = 1;
        while(!q.empty()){
            int u = q.front(); q.pop();
            //cout << u << endl;
            rep(j, e[u].size()){
                int v = e[u][j];
                if(used[v] == 0){
                    if(!((inpE[i].first == u && inpE[i].second == v) || (inpE[i].first == v && inpE[i].second == u))){
                        q.push(v);
                        used[v] = 1;
                    }
                }
            }
        }
        bool ok = true;
        rep(j, n){
            if(used[j] == 0) ok = false;
        }
        if(!ok){
            ans++;
            //cout << "+" << endl;
        }
    }

    cout << ans << endl;
    


    
    return 0;
}



Measured memory_bytes: 256
from collections import defaultdict
S, T = map(lambda x: x.strip(), open(0).read().split())

ds, dt = defaultdict(str), defaultdict(str)
ans = 'Yes'
for s, t in zip(S, T):
    if not ds[s] or ds[s] == t:
        ds[s] = t
    else:
        ans = 'No'
        break
    if not dt[t] or dt[t] == s:
        dt[t] = s
    else:
        ans = 'No'
        break
print(ans)

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

int main(){
string s;
cin >> s;
int ans;
if(s=="SSS") ans = 0;
if(s=="RSS" || s=="SRS" || s=="SSR"||s=="RSR")ans =  1;
if(s=="RRS"|| s=="SRR")ans = 2;
if(s=="RRR") ans = 3;

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

Measured memory_bytes: 3548
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
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 all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll a,s,d;
  cin>>a>>s>>d;
  ll ans=0;
  while(1){
    if(ans==d) {
      COUT(d);
      break;
    }
    if(s<a){
      COUT(ans);
      break;
    }
    s-=a;
    ans++;
  }
}

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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb puah_back

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 dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(){
    int n, m; cin >> n>> m;
    vector<int> lis(n);
    double sum = 0;
    REP(i, 0, n){cin >> lis[i]; sum += lis[i];}
    double k = (sum*1.0) / (4.0*m);
    int count = 0;
    REP(i, 0, n){
        if(lis[i] >= k){
            count++;
        }
    }
    if(count >= m){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<limits.h>

int main(void){
    int N;
    scanf("%d", &N);
    char *S = (char*)malloc(N * sizeof(char));
    scanf("%s", S);
    int count = 0;
    int cmax = INT_MIN;
    int i, j;
    for(i=1; i<N; i++) {
        int A['z' + 1] = {0};
        count = 0;
        for(j=0; j<i; j++) {
            A[S[j]] = 1;
        }
        for(j=i; S[j] != '\0'; j++) {
            if(A[S[j]] == 1) {
                count++;
                A[S[j]] = 0;
            }
        }
        if(count > cmax) {
            cmax = count;
        }
    }
    printf("%d\n", cmax);
    free(S);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define For(i, j, k) for(int i = j; i <= k; ++i)
#define Forr(i, j, k) for(int i = j; i >= k; --i)
using namespace std;

inline int read() {
	int x = 0, p = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') p = -1; c = getchar(); }
	while(isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	return x *= p;
}

const int N = 1e5 + 10;
int n, A[N], GCD;

inline bool dfs() {
	int cnt1 = 0, cnt2 = 0, flag = 0;
	For(i, 1, n) {
		if(A[i] == 1) flag = 1;
		if(A[i] & 1) ++ cnt1;
		else ++ cnt2;
	}

	if(cnt2 & 1) return 1;
	else if(cnt1 == 1 && flag == 1 || cnt1 > 1) return 0;
	else {
		int GCD = 0;
		For(i, 1, n) {
			if(A[i] & 1) -- A[i];
			GCD = __gcd(GCD, A[i]);
		}	
		For(i, 1, n) A[i] /= GCD;
		return dfs() ^ 1;
	}
}

int main() {
	n = read();
	For(i, 1, n) A[i] = read();

	if(dfs()) puts("First");
	else puts("Second");

	return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;
class Main{
  public static void main(String[] args) {
  Scanner scan =  new Scanner(System.in);
 long a = scan.nextLong();
 long b = scan.nextLong();
 if(b>a*2){
 long c = b-a*2;
 long d = c/4;
   System.out.println(a+d);
 }else{
	 long c = b/2;
	 System.out.println(c);
 }
  }
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int m = n%10;
    if(m==2 || m==4 || m==5 || m==7 || m==9)
    {
      cout<<"hon";
    }
    else if(m==0 || m==1 || m==6 || m==8)
    {
      cout<<"pon";
    }
    else
    {
      cout<<"bon";
    }
    return 0;
         

}

Measured memory_bytes: 3652
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N, L;
  cin >> N >> L;
  string str;
  vector<string> v;
  for (int i = 0; i < N; i++) {
    cin >> str;
    v.push_back(str);
  }

  sort(v.begin(), v.end());
  string ans;

  for (int i = 0; i < N; i++) {
    ans += v[i];
  }

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

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y, h;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++)
		sum *= (x--);
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}
#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n;
	char u;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> u;
		if (u == 'Y') {
			cout << "Four\n";
			return 0;
		}
	}
	cout << "Three\n";
	getchar(); getchar();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int n, m, x;
    cin >> n >> m >> x;
    int l = 0, r = 0;
    forn(i, m) {
        int v;
        cin >> v;
        if (v > x) r++;
        if (v < x) l++;
    }
    cout << min(r, l) << endl;
    return 0;
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)
// Union-Find木
template<typename Abel>//加減可能のアーベル群
class UnionFind{
protected:
    vector<int> par;//親ノード
    vector<Abel> pod;//ポテンシャル
    Abel O=0;
public:
    UnionFind(int n,Abel zero=0) : par(n,-1),pod(n,zero){
        O=zero;
    }

    //根を求める（同時に経路圧縮）
    int root(int x){
        if(par[x]<0) return x;
        int r = root(par[x]);
        pod[x] +=pod[par[x]];
        return par[x]=r;
    }

    //根が等しいか判定
    bool issame(int x,int y){
        return root(x)==root(y);
    }

    //マージ
    bool unite(int base,int x){
        return unite(base,x,O);
    }
    bool unite(int base,int x,Abel pd){
        pd -=p(x) - p(base);
        base=root(base);x=root(x);
        if(base==x)return false;
        if(par[base]>par[x]) std::swap(base,x),pd=-pd;
        //baseがxの親になる
        par[base] +=par[x];//根は-(size)
        par[x]=base;
        pod[x]=pd;
        return true;
    }

    //属す根のサイズ
    int size(int x){
        return -par[root(x)];
    }

    //要素のポテンシャル
    Abel p(int x){
        root(x);//経路圧縮
        return pod[x];
    }

    //要素の相対ポテンシャル
    Abel diff(int base,int x){
        if(issame(base,x)) return pod[x]-pod[base];
        return 0;//同箇所にない場合は未定義
    }
};

int main() {
    int N,K,L;
    cin >>N>>K>>L;

    int x,y;
    UnionFind<int> road(N),train(N);
    rep(i,K){
        cin >> x>>y;x--;y--;
        road.unite(x,y);
    }
    rep(i,L){
        cin >> x>>y;x--;y--;
        train.unite(x,y);
    }
    //mapを用いてO(n)でcnt//mapのデフォが0なので便利
    map<pair<int,int >,int> mp;
    vector<pair<int,int>> vec(N);
    rep(i,N){
        vec[i]={road.root(i),train.root(i)};
        mp[vec[i]]++;
    }

    rep(i,N) cout << (i==0 ? "" :" ") << mp[vec[i]];
    cout <<endl;
    return (0);
}

Measured memory_bytes: 16640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;
int book[100005];
int main()
{
    int n;
    cin>>n;
    int flag=0;
    int number[1005][2];
    memset(book,0,sizeof(book));
    for(int i=1;i<=n;i++)
        cin>>number[i][0]>>number[i][1];
    for(int i=1;i<=n;i++)
        for(int j=number[i][0];j<=number[i][1];j++)
           if(!book[j])  book[j]=1;
     int sum=0;
     for(int i=1;i<=100000;i++)
        if(book[i]) sum++;
        cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 640
#conding utf-8
S=input()
ATGC=["A","T","G","C"]
ans=0
tmp=0
for i in range(len(S)):
  if S[i:i+1] in ATGC:
    tmp +=1
  else:
    tmp=0
  if ans<tmp:
    ans=tmp

print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#define N 100

int main()
{
    int a;
    int i;
    int array[N];

    scanf("%d", &a);
    for (i = 0; i < a; i++)
    {
        scanf("%d", &array[i]);
    }

    for (i = 1; i <= a; i++)
    {
        for (int j = 0; j < a; j++)
        {
            printf("%d", array[j]);
            if (j != a - 1)
                printf(" ");
        }
        printf("\n");
        int k = i;
        while (array[k - 1] >= array[k])
        {
            int temp = array[k-1];
            array[k - 1] = array[k];
            array[k] = temp;
            k--;
            if(k==0) break;
        }
    }
    return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>  
using namespace std; 
int a[100+1][100+1],dp[100+1][100+1];
int main(){
    string a;
    int ans=0;
    cin>>a;
    for(int i=0;i<a.size();i++){
        if(a[i]=='1')ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x,m,l;
	m=10*10*10*10*10*10*10*10*10;
	cin>>n>>x;
	vector<int>s(n);
	for(int i=0;i<n;i++){
		cin>>s.at(i);
		if(m>abs(s.at(i)-x))m=abs(s.at(i)-x);
	}
  if(n<2){
    cout<<abs(s.at(0)-x)<<endl;
    return 0;
  }
	for(int c=1;c<=m;c++){
		for(int i=0;i<n;i++){
			if((s.at(i)-x)%c!=0)break;
			if(i==n-1)l=c;
		}
	}
	cout<<l<<endl;
}

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

int main(){
 int r,c;
 cin>>r>>c;
 int num[101][101]={};
 for(int i=0;i<r;i++)
 for(int j=0;j<c;j++) cin>>num[i][j];

 for(int i=0;i<r;i++)
 for(int j=0;j<c;j++) num[r][c]+=num[i][j];

 for(int i=0;i<r;i++){
 int sum=0;
 for(int j=0;j<c;j++)sum+=num[i][j];
 num[i][c]=sum;
}

 for(int j=0;j<c;j++){
 int sum=0;
 for(int i=0;i<r;i++)sum+=num[i][j];
 num[r][j]=sum;
}
for(int j=0;j<c;j++){
 int sum=0;
 for(int i=0;i<r;i++)sum+=num[i][j];
 num[r][j]=sum;
}
 for(int i=0;i<=r;i++){
 for(int j=0;j<=c;j++){
 if(j) cout<<" ";
 cout<<num[i][j];
}
cout<<endl;
}
}


Measured memory_bytes: 3112
from collections import defaultdict

int_n = int(input())
ar_int_a = list(map(int, input().split()))

d_cnt = defaultdict(int)
for w in ar_int_a:
    d_cnt[w] += 1


st_int_group = set(ar_int_a)
max_count = 0

for i in st_int_group:
    max_count = max(d_cnt[i] + d_cnt[i - 1] + d_cnt[i + 1], max_count)

print(max_count)






Measured memory_bytes: 21472
#include "bits/stdc++.h"

#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define int long long
#define ll long long

ll INF = (1LL << 60);
int mod = 998244353;
using P = pair<int, int>;
using mint = modint998244353;
struct S {
	mint value;
	mint size;
};
using F = long long;

const F ID = 8e18;

S op(S a, S b) { return { a.value + b.value, a.size + b.size }; }
S e() { return { 0, 0 }; }
S mapping(F f, S x) {
	if (f != ID) x.value = f * x.size;
	return x;
}
F composition(F f, F g) { return (f == ID ? g : f); }
F id() { return ID; }
signed main() {
	int N, Q; cin >> N >> Q;
	vector<S>a(N);
	mint now = 1;
	for (int i = N - 1; i >= 0; i--) {
		a[i] = { now,now };
		now *= 10;
	}
	lazy_segtree<S, op, e, F, mapping, composition, id>seg(a);
	for (int i = 0; i < Q; i++) {
		int l, r, d; cin >> l >> r >> d; l--;
		seg.apply(l, r, d);
		cout << seg.all_prod().value.val() << endl;
	}
	return 0;
}


Measured memory_bytes: 10928
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    S = readline().decode('utf-8').strip()
    ans = 0
    for i in range(10):
        x = S.find(str(i), 0, N - 2)
        if x != -1:
            for j in range(10):
                y = S.find(str(j), x + 1, N - 1)
                if y != -1:
                    for k in range(10):
                        z = S.find(str(k), y + 1, N)
                        if z != -1:
                            ans += 1
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9260
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
typedef long long ll;
typedef pair<int,int> pii;

void A(){
	int a,b; cin>>a>>b;
	int cnt=0;
	while(a>0){
		a-=b;
		cnt++;
	}
	cout<<cnt<<endl;
	
}

void B(){
	int a,b,x,t=0;
	cin>>a>>b;
	while(b--){
		cin>>x;
		t+=x;
	}
	cout<<(t>=a?"Yes":"No")<<endl;
}

int main(){
	int n,k; cin>>n>>k;
	int arr[n];
	for(int i=0; i<n; i++){
		cin>>arr[i];
	}
	sort(arr, arr+n);
	ll ans = 0;
	for(int i=0; i<(n-k); i++){
		ans+=arr[i];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 4424
#!/usr/bin/env python
# coding: utf-8

def main():
    #raw = ["7",
    #       "6 7 8",
    #       "8 8 3",
    #       "2 5 2",
    #       "7 8 6",
    #       "4 6 8",
    #       "2 3 4",
    #       "7 5 1"]
    #N = int(raw[0])
    #data = [list(map(int, x.split())) for x in raw[1:]]
    import sys
    N = int(sys.stdin.readline()[:-1])
    data = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
    #
    dp = [[0, 0, 0] for _ in range(N)]
    dp[0] = data[0]
    for i in range(1, N):
        dp[i][0] = max(dp[i-1][1:]) + data[i][0]
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + data[i][1]
        dp[i][2] = max(dp[i-1][:2]) + data[i][2]
    print(max(dp[N-1]))

main()


Measured memory_bytes: 47384
//
//AtCoder Beginner Contest 120
//C
//https://atcoder.jp/contests/abc120/tasks/abc120_c
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    string s;
    cin >> s;

    int ans=0;
    pair<char,int> last = make_pair('a', 0);
    REP(i, s.size()){
        if (last.second==0){
            last.first = s[i];
            last.second++;
        }else{
            if (last.first == s[i]){
                last.second++;
            }else{
                ans+=2;
                last.second--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3760
#include <stdio.h>

int fibonacci(int);

int F[50];

int main(){
  int n, i;

  scanf("%d", &n);

  for(i = 0; i < n; i++) F[n] = 0;

  printf("%d\n", fibonacci(n));

  return 0;
}

int fibonacci(int n){
  if(n == 0 || n == 1) return F[n] = 1;
  if(F[n] != 0) return F[n];
  return F[n] = fibonacci(n-2) + fibonacci(n-1);
}

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;

int H, W, A, B;

int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	cin >> H >> W >> A >> B;

	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j)
			if (j <= 2 * A)
				cout << ((j & 1) ^ (i > B));
			else
				cout << (i > B);
		ndl;
	}

	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
    return 0;
}


Measured memory_bytes: 1280