akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
	int n , k=0 , i , l =3e5 ;
	cin >> n ;
	int a[n] ;
	for(i=0;i<n;i++)
	{
		cin >> a[i] ;
	}
	for(i=0;i<n;i++)
	{
	   if(a[i]<l)
	   {
	   k++;
	   l=a[i];
	   }
	}
	cout << k ;
	return 0;
}

Measured memory_bytes: 4384
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long int

void findAns()
{


    int n;
    cin >> n;

    int a[4];

    memset(a, 0, sizeof(a));
    string s;
    for (int i = 0; i < n; i++)
    {
        cin >> s;

        if (s == "AC") a[0]++;
        else if (s == "WA") a[1]++;
        else if (s == "TLE") a[2]++;
        else
            a[3]++;

    }

    cout << "AC x " << a[0] << "\n";
    cout << "WA x " << a[1] << "\n";
    cout << "TLE x " << a[2] << "\n";
    cout << "RE x " << a[3] << "\n";


}
int main()
{
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
//     freopen("test.txt", "w", stdout);
//     cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s" << "\n";
// #endif

    FAST;
    ll  t = 1;
    //cin >> t;

    while (t--) findAns();
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

void factorial(int n){
	int fact[10] = {0};
	fact[0] = 1;
	for(int i=1; i<=n; i++){
		REP(j, 10){
			fact[j] *= i;
		}
		REP(j, 9){
			fact[j+1] += fact[j] / 10000;
			fact[j] -= (fact[j] / 10000) * 10000;
		}
	}
	int i;
	for(i=9; i >= 0; i--) {
		if (fact[i] != 0) {
			printf("%d", fact[i]);
			i--;
			break;
		}
	}
	while (i >= 0) {
		printf("%04d", fact[i]);
		i--;
	}
	cout << endl;
}

int main(){
    int n;
    cin >> n;
    factorial(n);
}


Measured memory_bytes: 3116
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
B = LIST()

su = B[0]
for i in range(1, N - 1):
	su += min(B[i - 1], B[i])

print(su + B[len(B) - 1])

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

int main() {
  int N;
  cin >> N;
  int p[20];
  for (int i = 0; i < N; i++) cin >> p[i];

  sort(p, p + N);
  p[N - 1] /= 2;

  int ans = 0;
  for (int i = 0; i < N; i++) ans += p[i];

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int N;
  while(cin>>N && N){
    int cur; cin>>cur;
    int ans = cur;
    bool error = false;
    REP(i, N){
      int inc, dec;
      cin>>inc>>dec;
      cur = cur + inc - dec;
      if(cur < 0) error = true;
      if(cur > ans) ans = cur;
    }
    if(error) ans = 0;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#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 llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

int main(){

    ll n,h;
    cin >> n >> h;
    vector<ll> a(n),b(n);
    REP(i,n){
        cin >> a[i] >> b[i]; 
    }

    sort(a.begin(),a.end(),greater<ll>());
    sort(b.begin(),b.end(),greater<ll>());
    
    ll cut_damage = a[0];
    ll count = 0;

    bool flag = true;/*操作の継続条件*/

    while(flag){

        for(int i = 0;i < n;i++){
            /*切るダメージが投げるダメージを超えるまではひたすら投げる*/
            if(h <= 0){
                flag = false;
                break;
            }

            if(b[i] <= cut_damage){
                /*切るダメージのほうが大きくなるので投げるのを終了*/
                break;
            }else{
                /*投げるダメージのほうが大きい*/
                if(b[i] >= h){
                    /*この投げる操作でダメージが0になるのでカウントして操作を終了する*/
                    count++;
                    flag = false;
                    h -= b[i];
                }else{
                    /*投げてダメージを減らす*/
                    h -= b[i];
                    count++;
                }
            }
        }

        if(h <= 0){
            break;
        }

        /*この時点で残りは切るのみ*/


        if(h % cut_damage == 0){
            count += h/cut_damage;
            flag = false;
        }else{
            count += h/cut_damage + 1;
            flag = false;
        }
    }
    cout << count << endl;
    return 0;
}

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

int main(){
	int n,a,b,digitSum,sum=0;
	cin >> n >> a >> b;
	for(int i=1; i<=n; i++){
		int temp = i;
		digitSum = 0;
		while(temp>0){
			digitSum += temp%10;
			temp /= 10;
		}
		if(digitSum >= a && digitSum <= b)sum+=i;
	}
	cout << sum <<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s; cin >> s;
    if(s == "AAA" || s == "BBB") No;
    else Yes;

    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	H, W, K := getStdinInt3()
	C := make([][]string, H)

	for i := 0; i < H; i++ {
		C[i] = make([]string, W)
		c := getStdin()
		for j := 0; j < len(c); j++ {
			C[i][j] = string(c[j])
		}
	}

	ans := 0
	for y := 0; y < (1<<H)-1; y++ {
		for x := 0; x < (1<<W)-1; x++ {
			sum := 0
			for n := 0; n < H; n++ {
				if ((1 << n) & y) != 0 {
					continue
				}

				for m := 0; m < W; m++ {
					if ((1 << m) & x) != 0 {
						continue
					}
					if C[n][m] == "#" {
						sum++
					}
				}
			}
			if sum == K {
				ans++
			}
		}
	}
	fmt.Printf("%d\n", ans)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2164
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main{
	public static void main(String[]args){
	Scanner scan=new Scanner(System.in);
		String a=scan.next();
		int count=0;
		List<Integer>list=new ArrayList<Integer>();
		for(int i=0;i<a.length();i++) {
			list.add(Integer.valueOf(a.charAt(i)));
		}
		for(int i=0;i<list.size()-1;) {
			if(list.get(i)!=list.get(i+1)) {
				count+=2;
				list.remove(i);
				list.remove(i);
				i=0;
			}
			else {
				i++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 26352
while(1):
    n=int(raw_input())
    if n==0:
        break
    else:
        t=[]
        for i in range(n):
            t.append(int(raw_input()))
        t.sort()
        s=[0]
        for i in range(n-1):
            s.append(s[i]+t[i])
        print sum(s)

Measured memory_bytes: 4976
using System.Collections.Generic;
using System.Linq;
using System;
public class Yoko
{
    public int hight { get; set; }
    public int tate1 { get; set; }
    public int tate2 { get; set; }
}
    
    
    public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);
            var a = int.Parse(line[2]);
            if (n == 0 && m == 0 && a == 0) break;
            var templist = new List<Yoko>();
            for (int i = 0; i < m; i++)
            {
                string[] line2 = Console.ReadLine().Trim().Split(' ');
                var buf = new Yoko();
                buf.hight = int.Parse(line2[0]);
                buf.tate1 = int.Parse(line2[1]);
                buf.tate2 = int.Parse(line2[2]);
                templist.Add(buf);
            }
            var yokos = templist.OrderByDescending(x => x.hight).ToList();
            var watchline = a;
            foreach (var x in yokos)
            {
                if (x.tate1 == watchline) watchline = x.tate2;
                else if (x.tate2 == watchline) watchline = x.tate1;
            }
            Console.WriteLine(watchline);
        }
    }
}

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

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 long long INF = 1LL << 60;
long long a[100010],b[100010],c[100010];

// DP テーブル
long long dp[100010][3];

int main ()
{
    int n,k;  cin >> n ;
    long long a[100010][3];
    for(int i=0;i<n;i++)  for(int j=0;j<3;j++)  cin >> a[i][j]; 

    for(int i=0;i<=n;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j==k) continue;
                 chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }
    long long res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[n][j]);
    cout << res << endl;

}


Measured memory_bytes: 6656
package main

import (
	"fmt"
)

func main() {
	var h,w,k int
	fmt.Scan(&h, &w, &k)

	s := make([][]byte, h)
	for i := 0; i < h; i++ {
		fmt.Scan(&s[i])
	}

	minc := int(1e5)
	for i := 0; i < 1<<uint(h-1); i++ {
		m := make([]int, h)
		var cnt int
		var ng bool
		pj := -1
		for j := 0; j < w; j++ {
			var sm int
			var con bool
			for l := 0; l < h; l++ {
				sm += m[l]
				if s[l][j] == '1' {
					sm++
				}
				//fmt.Println("i,j,l,ml,sm:", i,j,l,m[l],sm)
				if sm > k {
					m = make([]int, h)
					cnt++
					if j == pj {
						ng = true
						//fmt.Println("ng")
						break
					}
					pj = j
					j--
					con = true
					break
				}
				if i&(1<<uint(l)) > 0 {
					//fmt.Println("reset")
					sm = 0
				}
			}
			if ng {
				break
			}
			if con {
				continue
			}
			for l := 0; l < h; l++ {
				if s[l][j] == '1' {
					m[l]++
				}
			}
		}
		if !ng {
			for j := 0; j < h-1; j++ {
				if i&(1<<uint(j)) > 0 {
					cnt++
				}
			}
			//fmt.Println("i,cnt:", i, cnt)
			if cnt < minc {
				minc = cnt
			}
		}
	}
	fmt.Println(minc)
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
const int M=4444;
int n,k,tot,val[N*4*20],son[N*4*20][2],root[M];
struct P{int x,y;}p[N<<1]; 
inline int cmp(const P&a,const P&b){return a.x<b.x;}
void ins(int p,int l,int r,int&x,int y){
	x=++tot;
	val[x]=val[y]+1;
	if(l==r)return;
	int mid=(l+r)>>1;
	if(p<=mid){
		ins(p,l,mid,son[x][0],son[y][0]);
		son[x][1]=son[y][1];
	}else{
		son[x][0]=son[y][0];
		ins(p,mid+1,r,son[x][1],son[y][1]);
	}
}
int ask(int L,int R,int l,int r,int x,int y){
	if(l>=L&&r<=R)return val[x]-val[y];
	int mid=(l+r)>>1,t=0;
	if(L<=mid)t+=ask(L,R,l,mid,son[x][0],son[y][0]);
	if(R>mid)t+=ask(L,R,mid+1,r,son[x][1],son[y][1]);
	return t;
}
int main(){
	//freopen("aa.in","r",stdin);
	int i,j;char op[5];
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;++i){
		int x,y,z;
		scanf("%d%d%s",&x,&y,op);
		x=x%(2*k),y=y%(2*k);
		if(op[0]=='W')x=(x+k)%(2*k);
		++x;++y;
		p[i].x=x,p[i].y=y;
	}
	sort(p+1,p+1+n,cmp);
	for(i=1;i<=n;++i)p[n+i]=p[i],p[n+i].x+=2*k;
	for(i=1,j=1;i<=4*k;++i){
		root[i]=root[i-1];
		for(;j<=2*n&&p[j].x==i;++j){
			ins(p[j].y,1,4000,root[i],root[i]);
			ins(p[j].y+2*k,1,4000,root[i],root[i]);
			//printf("%d %d\n",p[j].y,p[j].y+2*k);
		}
	}
	int ans=0;
	for(i=k;i<=3*k;++i){
		//int tmp=0;
		for(j=1;j<=2*k;++j){
			int tmp=0;
			tmp+=ask(j,j+k-1,1,4000,root[i],root[i-k]);
			tmp+=ask(j+k,j+k+k-1,1,4000,root[i+k],root[i]);
			ans=max(ans,tmp);
		}
		//ans=max(ans,tmp);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 65792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    ll a;
    string b;
    cin >> a >> b;
    ll b_ll = (b[0]-'0')*100 + (b[2]-'0')*10+(b[3]-'0');
    ll ans = a*b_ll/100;
    cout << ans << endl;
}


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

int main(){
    long long n;
    cin>>n;
    long long a[n];
    for(long long i=0;i<n;i++){
        cin>>a[i];
    }
    long long sum=0;
    long long dp[200001]={0};
    for(long long i=0;i<n;i++){
        sum+=a[i];
        dp[a[i]]++;
    }
    long long q;
        long long b,c;
    cin>>q;
    while(q--){

        cin>>b>>c;
        sum=sum-dp[b]*b+dp[b]*c;
        dp[c]+=dp[b];
        dp[b]=0;
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 5944
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
ll dp[3001][3001][3], a[3001][3001];
 
ll func(int r, int c, int cnt, int row, int col) {
    if(r > row-1 || c > col-1 || cnt < 0) return 0;
    if(dp[r][c][cnt] != -1) return dp[r][c][cnt];
    return dp[r][c][cnt] = max({func(r+1, c, 2, row, col) + a[r][c], func(r, c+1, cnt, row, col), func(r, c+1, cnt-1, row, col) + a[r][c]});
}
 
int main() {
    ll r,c,items, x , y, v, maxi = 0;
    cin >> r >> c >> items;
    while(items--) {
    	cin >> x >> y >> v;
    	a[x-1][y-1]=v;
    }
    for(int i=0;i<r;i++) for(int j=0;j<c;j++) for(int k=0;k<4;k++) dp[i][j][k] = -1;
    maxi = func(0, 0, 2, r, c);
    cout << maxi;
	return 0;
}

Measured memory_bytes: 285248
#include <iostream>
#include <vector>

using namespace std;

struct union_find {
    vector<int> par, sz;

    union_find(int N): par(N), sz(N) {
        for (int i = 0; i < N; i++) {par[i] = i; sz[i] = 1;}
    }

    int root(int x) {
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        if (root(x) == root(y)) return;
        else {sz[root(x)] += sz[root(y)]; par[root(y)] = root(x); return;}
    }

    bool find(int x, int y) {return root(x) == root(y);}

    int size(int x) {return sz[root(x)];}
};

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

    vector<int> A(M), B(M);
    for (int i = 0; i < M; i++) cin >> A[i] >> B[i];

    long long inc = (long long)N*(N - 1)/2;
    vector<long long> ans = {inc};

    union_find uf(N + 1);
    for (int i = M - 1; i >= 0; i--) {
        int x = A[i], y = B[i];

        if (!(uf.find(x, y))) {
            inc -= uf.size(x)*uf.size(y);
            uf.unite(x, y);
        }

        ans.push_back(inc);
    }

    for (int i = ans.size() - 2; i >= 0; i--) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3828
# -*- coding: utf-8 -*-
from copy import deepcopy


def main():
    n = int(input())
    p = list(map(int, input().split()))

    for i in range(n):
        for j in range(i, n):
            # if i == j:
            #     continue
            p_temp = deepcopy(p)
            temp = p_temp[i]
            p_temp[i] = p_temp[j]
            p_temp[j] = temp
            # print(p, p_temp)
            if p_temp == sorted(p):
                print('YES')
                return

    print('NO')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3444
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int a, b;
   cin >> a >> b;
   cout << (a + b) % 24 << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define FOR(i,n) for(size_t i=0;i<(n);i++)
#define cinv(v,n) for(size_t i=0;i<(n);i++){cin>>(v)[i];}
#define nvec(type,v,n) vector<type> v(n);cinv(v,n)
#define npairs(type1,type2,v,n) vector<pair<type1,type2>> v(n);for(size_t i=0;i<(n);i++){cin>>v[i].first>>v[i].second;}

#define min_index(v) size_t(min_element(all(v))-(v).begin())
#define max_index(v) size_t(max_element(all(v))-(v).begin())
#define min_e(v) *min_element(all(v))
#define max_e(v) *max_element(all(v))

#define count_le(v,a) size_t(upper_bound(all(v),a)-(v).begin())
#define count_lt(v,a) size_t(lower_bound(all(v),a)-(v).begin())
#define count_ge(v,a) size_t((v).end()-lower_bound(all(v),a))
#define count_gt(v,a) size_t((v).end()-upper_bound(all(v),a))

#define order(neq_sl) [](const &auto s, const &auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(all(v),0l)

int main() {
  int n,l;
  cin>>n>>l;
  vector<int> v;
  int min = 1000;
  FOR(i,n){
    v.push_back(l+int(i));
    if(abs(min)>abs(l+(int)i)){
      min=l+i;
    }
  }
  cout<<SUM(v)-min;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;
int main(){
    while (true) {
        int n;
        cin >> n;
        if(n==0) break;
        int currentx=10,currenty=10;
        bool treasure[21][21];
        rep(i,21){
            rep(j,21){
                treasure[i][j]=false;
            }
        }
        rep(i,n){
            int x,y;
            cin >> x >>y;
            treasure[x][y]=true;
        }
        int count=0;
        int m;
        cin >> m;
        rep(i,m){
            char direction;
            int step;
            cin >> direction >> step;
            repi(j,1,step+1){
                switch (direction) {
                    case 'E':
                        currentx++;
                        break;
                    case 'N':
                        currenty++;
                        break;
                    case 'S':
                        currenty--;
                        break;
                    case 'W':
                        currentx--;
                        break;
                }
                if(treasure[currentx][currenty]){
                    count++;
                    treasure[currentx][currenty]=false;
                }
            }
        }
        cout << (count==n ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 2968
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;
const int MOD = 1e9+7;

//C++17
template<typename Type>
Type GCD(Type a,Type b){ return b ? GCD(b,a%b) : a ;}
template<typename Type>
Type LCM(Type a,Type b){ return a*b / GCD(a,b) ;}

template<typename Type>//文字列の置換/Boost:replace_all()
Type replace_str(Type str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main() {
    int n;cin >> n;
    vector<int> h(n);
    rep(i,n)cin >> h[i];
    vector<int> dp(n,INF);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i],dp[i-1]+abs(h[i] - h[i-1]));
        dp[i] = min(dp[i],dp[i-2]+abs(h[i] - h[i-2]));
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
*A, = map(int, input().split())
S = sum(A)
subset_sum = 1
for a in A:
    subset_sum |= subset_sum << a
ans = (S + 1) // 2
subset_sum >>= ans
while subset_sum & 1 == 0:
    subset_sum >>= 1
    ans += 1
print(ans)

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

int gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	long long a, b;

	while (cin >> a >> b) {
		cout << gcd(a, b) << " " << a * b / gcd(a, b) << endl;
	}
}


Measured memory_bytes: 2984
import string
import bisect
S = input()
T = input()
n = len(S)
sa = {_: [] for _ in string.ascii_lowercase}
for i, s in enumerate(S):
    sa[s] += [i]
ans = 0
i = -1
for t in T:
    if sa[t]:
        j = bisect.bisect_left(sa[t], i + 1)
        if j == len(sa[t]):
            ni = sa[t][0] + n
        else:
            ni = sa[t][j]
        ans += ni - i
        i = ni % n
    else:
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 8312
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  ll L,R;
  cin>>L>>R;
  ll mod=2019;
  R=min(L+mod,R);
  ll ans=L*(L+1)%mod;
  rep(i,R-L+1) rep(j,R-L+1) if(i!=j) if(ans>(L+i)*(L+j)%mod) ans=(L+i)*(L+j)%mod;
  cout<<ans<<endl;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

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

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

struct DSU {
    vi p; void init(int n) {p = vi (n, -1);}
    int findSet(int x) { return p[x] < 0 ? x : findSet(p[x]);}
    bool sameSet(int a, int b) { return findSet(a) == findSet(b); }
	int size(int x) { return -p[findSet(x)]; }
	bool joinSet(int x, int y) { // union-by-rank
		x = findSet(x), y = findSet(y); if (x == y) return 0;
		if (p[x] > p[y]) swap(x,y);
		p[x] += p[y]; p[y] = x; return 1;
	}
};

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vector<pair<pii, int>> points (N);

	DSU dsu; dsu.init(N);

	F0R(i, N) {
		int x, y; cin >> x >> y;
		points[i] = {{x, y}, i};
	}

	
	sort(points.begin(), points.end());
	
	// print(points);
	
	vector<pair<pii, int>> todo;
	for (pair<pii, int> data : points) {
		int curx = data.first.first;
		int cury = data.first.second;

		bool first = true;
		pair<pii, int> good = data;
		while (todo.size() > 0 && todo.back().first.second < cury) {
			if (first) {good = todo.back(); first = false;}
			dsu.joinSet(data.second, todo.back().second);
			todo.pop_back();
		}
		todo.push_back(good);
	}

	F0R(i, N) print(dsu.size(i));

}

Measured memory_bytes: 6944
#include <iostream>

bool isInside(int w, int h, int x, int y, int r) {
	return !(x - r < 0 || x + r > w || y - r < 0 || y + r > h);
}

int main(void) {
	int w, h, x, y, r;
	std::cin >> w >> h >> x >> y >> r;
	std::cout << (isInside(w, h, x, y, r) ? "Yes" : "No") << std::endl;
	return 0;
}

Measured memory_bytes: 3108
package main

import (
	"fmt"
)

func main() {
	var (
		r, g, b int
	)

	fmt.Scan(&r, &g, &b)

	ans := r*100 + g*10 + b

	if ans%4 == 0 {
		fmt.Print("YES")
	} else {
		fmt.Print("NO")
	}
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
#define pb push_back
#define mp make_pair
#define inff 100000
#define ff first
#define ss second
#define sz(x) ((int) (x).size())
#define fast cin.sync_with_stdio(0);cin.tie(0)
#define rep(i,N) for(int i = 0;i < N;i++)
#define frep(i,a,b) for(int i = a;i <= b;i++)
#define pii pair<int , int>
#define pll pair<ll , ll>
#define vii vector<int>
#define vpii vector< pii >
#define fill(A,v) memset(A,v,sizeof(A))
#define setbits(x) __builtin_popcountll(x)
#define print(A,j,k) for(int ii=j;ii<k;ii++)cout<<A[ii]<<" ";cout<<"\n"
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
#define CASES int t;cin>>t;while(t--)
#define FILE freopen("inp.txt" , "r" , stdin);
#define ld long double


const int MOD = 1e9 + 7;
const int N = 1e6 + 5;
const int K = (1 << 17) + 10;
const ll INF = 2e18 + 500;
const int inf = 2e9 + 500;
const int SQRT = 500;
const int lgN = 20;

int main(int argc, char const *argv[])
{
	fast;

	int a , b , c;
	cin >> a >> b >> c;

	if ((a * 100 + b * 10 + c) % 4 == 0) cout << "YES\n";
	else cout << "NO\n";

	return 0;
}

Measured memory_bytes: 256
n,h = map(int, input().split())
ab = []
for _ in range(n):
    data = list(map(int,input().split()))
    ab.append(data)

ab.sort()
ab.reverse()

max_a = ab[0][0]

throw_dmgs = []
for tmp in ab:
    if tmp[1] > max_a:
        throw_dmgs.append(tmp[1])

throw_dmgs.sort()
throw_dmgs.reverse()

ans=0
for i in range(len(throw_dmgs)):
    ans+=1
    h -= throw_dmgs[i]
    if h <= 0:
        print(ans)
        exit()
import math

swing = math.ceil(h / max_a)
print(ans+swing)

Measured memory_bytes: 28404
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, C, K;
    cin >> N >> C >> K;
    int T[N];
    rep(i, N) cin >> T[i];
    sort(T, T+N);
    int i = 0;
    int ans = 0;
    while(i < N){
        int tmp = T[i];
        int previ = i;
        while(T[i] <= tmp + K && previ + C > i) i++;
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
s = input()
s_lst = []
for i in s:
    s_lst.append(i)
q = int(input())
order = [0] * q
for i in range(q):
    order[i] = input().split()
    order[i][1] = int(order[i][1])
    order[i][2] = int(order[i][2])
for i in range(q):
    if order[i][0] == "print":
        s = "".join(s_lst)
        # print(order[i], s_lst )
        print(s[order[i][1]:order[i][2]+1])
    elif order[i][0] == "reverse":
        for j in range((order[i][2]-order[i][1]+1)//2):
            s_lst[order[i][1]+j], s_lst[order[i][2]-j] = s_lst[order[i][2]-j], s_lst[order[i][1]+j]
        # print(order[i], s_lst )
    elif order[i][0] == "replace":
        for j in range(len(order[i][3])):
            s_lst[order[i][1] + j] = order[i][3][j]
        # print(order[i], s_lst )


Measured memory_bytes: 5624
import java.util.Scanner;
import java.io.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n, b, f, r, v;
		n = sc.nextInt();
		int kosha[][][] = new int[5][4][11];
		for (int i = 0; i < 5; i++)
		{
			for (int j = 0; j < 4; j++)
			{
				for (int k = 0; k < 11; k++)
				{
					kosha[i][j][k] = 0;
				}
			}
		}
		for (int i = 0; i < n; i++)
		{
			b = sc.nextInt();
			f = sc.nextInt();
			r = sc.nextInt();
			v = sc.nextInt();
			kosha[b][f][r] += v;
		}
		for (int i = 1; i < 5; i++)
		{
			for (int j = 1; j < 4; j++)
			{
				for (int k = 1; k < 11; k++)
				{
					System.out.print(" " + kosha[i][j][k]);
				}
				System.out.println();
			}
			if(i < 4)
			{
				for (int k = 1; k < 21; k++)
				{
					System.out.print("#");
				}
				System.out.println();
			}
		}
		sc.close();
	}
}


Measured memory_bytes: 29484
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
    long long a,b,c;
    cin>>a>>b>>c;
    if(a+b<=c)
        cout<<0<<' '<<0<<endl;
    if(a+b>c)
        if(a>c)
            cout<<a-c<<' '<<b<<endl;
        else
            cout<<0<<' '<<b-(c-a)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
 int a[32]={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};
 int k;
 scanf("%d",&k);
 printf("%d",a[k-1]);

}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
	int X, A, B;
	cin >> X;
	cin >> A;
	cin >> B;
	
	if (B - A <= 0) {
		cout << "delicious" << endl;
	}
	else if (B - A > 0 && (B - A) <= X) {
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}
	return 0;
}

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

size_t search(int n, size_t base/*6or9*/) {
  if (n < base) {
    return n;
  }
  return n % base + search(n / base, base);
}

int main(void) {
  int n;

  std::cin >> n;

  size_t count = 100000;
  for (size_t i = 0; i <= n; i++) {
    size_t cnt = search(i, 6) + search(n-i, 9);
    if (count > cnt) {
      count = cnt;
    }
  }

  std::cout << count << std::endl;

  return 0;
}

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

int main(){
  int n,f=0;cin>>n;
  while(n>28) n-=28;
  REP(i,8) REP(j,5) if(n==i*4+j*7) f=1;
  cout<<(f?"Yes":"No");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

int n, k, ans;

int main() {
    scanf("%d %d", &n, &k);
    ans = n - k + 1;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
import static java.lang.System.*;

import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public void solve() {
		int K = nextInt();
		int X = nextInt();

		if(K*500 >= X){
			out.println("Yes");
		}else {
			out.println("No");
		}
	}

	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	long lcm(long a, long b) {
		return a * b / gcd(a, b);
	}

	double sqrt(double x) {
		return Math.sqrt(x);
	}

	double pow(double x, double y) {
		return Math.pow(x, y);
	}

	public static void main(String[] args) {
		Main m = new Main();

		m.solve();
	}

}


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

int main(){
    long long x, amari;
    cin >> x;
    amari = x % 11;
    if( amari > 6 )
    {
        cout << 2*(x/11) + 2 << endl;
    }
    else if ( amari >=1 && amari <=6 )
    {
        cout << 2*(x/11) + 1 << endl;
    }
    else
    {
        cout << 2*(x/11) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

char f(char c) {
	return c - 'A' + 'a';
}

int main() {

	int n, k; cin >> n >> k;

	string s; cin >> s;

	s[k - 1] = f(s[k - 1]);
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<cstring>
inline int $(){
	register int x = 0;register char ch = getchar();
	while(!isdigit(ch))ch = getchar();
	for(;isdigit(ch);ch = getchar())x = (x << 1) + (x << 3) + (ch ^ 48);
	return x;
}
#define MAXN 100010
#include<set>
#include<map>
#include<queue>
std::set<int> next[MAXN];
std::map<std::pair<int, int>, int> M;
std::queue<std::pair<int, int> > Q;
int n = $();
int p[MAXN];
inline int find(int x){return x == p[x] ? x : p[x] = find(p[x]);}
int main(){
	for(int i = 1;i <= n;i++)p[i] = i;
	for(int i = 2;(i >> 1) < n;i++){
		int x = $(), y = $();
		if(x > y)std::swap(x, y);
		next[x].insert(y);next[y].insert(x);
		if(++M[std::make_pair(x, y)] == 2)Q.push(std::make_pair(x, y));
	}
	for(int i = 1;i < n;i++){
		register int x = 0, y = 0;
		while(x == y){
			if(Q.empty())return puts("NO"), 0;
			x = find(Q.front().first), y = find(Q.front().second);
			Q.pop();
		}
		if(next[x].size() > next[y].size())std::swap(x, y);
		p[x] = y;
		for(auto i : next[x]){
			if(find(i) == y)continue;
			next[y].insert(find(i));
			std::pair<int, int> add = std::make_pair(std::min(find(i), y), std::max(find(i), y));
			if(++M[add] == 2)Q.push(add);
		}
		next[y].erase(x);
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 44672
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

#x,y = [int(i) for i in readline().split()]
MOD = 998244353
n = int(input())
s = input()

R = B = G = 0
ans = 1
for i in s:
    m = sorted([R,G,B])
    if i == "R":
        c = R
        R += 1
    elif i == "G":
        c = G
        G += 1
    elif i == "B":
        c = B
        B += 1
    if c == m[-1]:
        ans *= n-m[-1]
    elif c == m[1]:
        ans *= m[2]-m[1]
    else:
        ans *= m[1]-m[0]
    
    ans %= MOD

print(ans)


Measured memory_bytes: 44904
#include<stdio.h>
int main(void){
    int a, b, i;
    scanf("%d",&a);
    if (a <= 1000)
    {
        a = 1000 - a;
        printf("%d\n",a);
    }
    else
    {
        for ( i = 0; i < 10; i++)
        {
            a = a - 1000;
            if (a <= 1000)
            {
                a = 1000 - a;
                printf("%d\n",a);
                break;
            }
            
        }
        
    }
    
    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;

int euclid(int a, int b) {
	int m = min(a, b);
	if (a % b == 0 || b % a == 0) {
		return m;
	}
	else {
		int n = max(a % m, b % m);
		return euclid(m, n);
	}
}

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int d = euclid(a, b);
	if (c % d == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n;
    cin>>n;
    Vec a(n);
    cin>>a;
    ll ans = INF;
    rep(i,300){
        ll c = 0;
        ll x = i-150;
        rep(j,n){
            c += pow(a[j]-x,2);
        }
        chmin(ans,c);
    }
    cout<<ans<<endl;
    return  0;
}


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

int main(){
  int n,k;
  cin >> n >> k;
  //vector<int> d(k);
  //int d;
  //vector<int> a;
  vector<int> flag(n,0);
  rep(i,k){
    int d;
    cin >> d;
    vector<int> a;
    rep(j,d){  
      int a_y;
      cin >> a_y;
      a.push_back(a_y);
    }

    rep(j,d){
      flag[a[j]-1] = 1;
    }
  }
  int ans=n;
  for(int p : flag){
    if(p) ans--;
  }
  if(ans<=0) ans = 0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = 0; i < (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void)
{
  int N, T;
  int num;
  int prev = 0;
  int sum = 0;
  cin >> N >> T;
  REP(i, N)
  {
    cin >> num;
    sum += min(T, num - prev);
    prev = num;
  }
  sum += T;
  cout << sum << endl;

  return 0;
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = l[0], Y = l[1];

            for (var i = 0; i <= N && i * 10000 <= Y; i++)
            {
                for (var j = 0; j <= N - i; j++)
                {
                    if (i * 10000 + j * 5000 + (N - i - j) * 1000 == Y)
                    {
                        Console.WriteLine($"{i} {j} {N - i - j}");
                        return;
                    }
                }
            }
            Console.WriteLine("-1 -1 -1");
        }
    }
}


Measured memory_bytes: 13396
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll h,w;
  cin>>h>>w;
  vector<string> vs;
  rep(y,0,h){
    string s;
    cin>>s;
    vs.pb(s);
  }
  vector<string> v1;
  vector<string> v2;
  rep(y,0,h){
    string ss;
    rep(x,0,w){
      ss+=".";
    }
    v1.pb(ss);
    v2.pb(ss);
  }
  rep(i,0,w){
    v1[0][i]='#';
    v2[h-1][i]='#';
  }
  rep(i,1,h-1){
    rep(j,0,w){
      if(j%2==0){
        v1[i][j]='#';
      }
      else{
        v2[i][j]='#';
      }
    }
  }
  rep(y,0,h){
    rep(x,0,w){
      if(vs[y][x]=='#'){
        if(x%2==0){
          v2[y][x]='#';
        }
        else{
          v1[y][x]='#';
        }
      }
    }
  }
  rep(y,0,h){
    cout<<v1[y]<<endl;
  }
  cout << endl;
  rep(y,0,h){
    cout<<v2[y]<<endl;
  }
  return 0;
}




Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int n,x,a[101],sum,ans,ans1;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	sum/=n;
	for(int i=1;i<=n;i++)
	{
		ans+=(a[i]-sum)*(a[i]-sum);
		ans1+=(a[i]-sum-1)*(a[i]-sum-1);
	}
	printf("%d",min(ans,ans1));
	return 0;
}


Measured memory_bytes: 256