akhauriyash/Code-Regression huggingface dataset:
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    R, C, K = map(int, input().split())

    field = [[0 for j in range(C)] for i in range(R)]

    for _ in range(K):
        r, c, v = map(int, input().split())
        field[r - 1][c - 1] += v

    #    dp = [[0] * 4 for j in range(C)]
    dp0 = [0] * C
    dp1 = [0] * C
    dp2 = [0] * C
    dp3 = [0] * C

    for i in range(R):
        for j in range(C):
            ct = field[i][j]
            premax = max(dp0[j], dp1[j], dp2[j], dp3[j])

            if ct == 0:
                if j > 0:
                    dp0[j] = max(dp0[j - 1], premax)
                    dp1[j] = dp1[j - 1]
                    dp2[j] = dp2[j - 1]
                    dp3[j] = dp3[j - 1]
                else:
                    dp0[j] = premax

                # for k in range(1, 4):
                #     if j > 0:
                #         dp[j][k] = dp[j - 1][k]
                #




            # else:
            #     if j > 0:
            #         dp[j][0] = max(dp[j - 1][0], premax)
            #         dp[j][1] = max(ct + max(dp[j - 1][0], premax), dp[j - 1][1])
            #     else:
            #         dp[j][0] = premax
            #         dp[j][1] = premax + ct
            #     for k in range(2, 4):
            #         if j > 0:
            #             dp[j][k] = max(dp[j - 1][k - 1] + ct, dp[j - 1][k])
            else:
                if j > 0:
                    dp0[j] = max(dp0[j - 1], premax)
                    dp1[j] = max(ct + max(dp0[j - 1], premax), dp1[j - 1])
                    dp2[j] = max(dp1[j - 1] + ct, dp2[j - 1])
                    dp3[j] = max(dp2[j - 1] + ct, dp3[j - 1])
                else:
                    dp0[j] =premax
                    dp1[j] = premax+ct

    #print(max(dp[C - 1]))
    print(max(dp0[C-1], dp1[C-1], dp2[C-1], dp3[C-1]))

if __name__ == "__main__":
    main()


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

int cnt_digits(long long N){
    int digits=0;

    while(N>0){
        N/=10;
        digits++;
        }
        return digits;
}

 int main(){
     long long N;
 cin >> N;
 int ans = cnt_digits(N);
 for(long long A=1LL; A * A <= N; A++){
     if(N % A != 0) continue;
     long long  B = N/A;
     int cur=max(cnt_digits(A),cnt_digits(B));
     if(ans>cur){
         ans=cur;
         }
 }
 cout << ans << endl;
  }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

ll n;
ll a[100005];
ll x, y;

int main()
{
    scanf("%lld", &n);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
    }
    sort(a, a + n);
    if(a[n - 1] - a[0] > 1)
    {
        printf("No\n");
        return 0;
    }
    if(a[n - 1] == a[0])
    {
        if(a[0] == n - 1) printf("Yes\n");
        else if(a[0] <= n / 2) printf("Yes\n");
        else printf("No\n");
        return 0;
    }
    x = upper_bound(a, a + n, a[0]) - lower_bound(a, a + n, a[0]);
    y = n - x;
    if(x + y / 2 < a[n - 1]) printf("No\n");
    else if(a[n - 1] >= n) printf("No\n");
    else if(a[n - 1] <= x) printf("No\n");
    else if(y <= 1) printf("No\n");
    else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

long long gcd(long long a, long long b)
{
    if (a < b)
        return gcd(b, a);
    long long r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

int main()
{
    long long A, B, C, D;
    cin >> A >> B >> C >> D;
    long long count = 0;

    count += B / C + B / D - B / ((C * D) / gcd(C, D));
    count -= (A-1) / C + (A-1) / D - (A-1) / ((C * D) / gcd(C, D));

    cout << B - A +1 - count << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)

	n := nextInt()
	m := make(map[string]int)

	for i := 0; i < n; i++ {
		t := []byte(next())
		sort.Slice(t, func(i, j int) bool { return t[i] < t[j] })
		s := string(t)
		m[s]++
	}

	var r uint64 = 0
	for _, c := range m {
		if c >= 2 {
			t := uint64(c - 1)
			r += (1 + t) * t / 2
		}
	}

	fmt.Println(r)
}

Measured memory_bytes: 14652
using System;


namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int H = int.Parse(input[0]);
            int S = int.Parse(input[1]);
            char[,] data = new char[H, S];
            for (int i = 0; i < H; i++)
            {
                string input_data = Console.ReadLine();
                for(int j = 0; j < S; j++)
                {
                    data[i, j] = input_data[j];
                }
            }
            for(int i = 0; i < H; i++)
            {
                for(int j = 0; j < S; j++)
                {
                    if (data[i, j] != '#')
                    {
                        FindMine(data, i, j);
                    }
                    else
                    {
                        Console.Write('#');
                    }
                    
                }
                Console.Write('\n');
            }
        }
        static void FindMine(char[,] data,int i,int j)
        {
            int result = 0;
            try //1
            {
                if (data[i-1, j] == '#')
                {
                    result++;
                }
            }
            catch{
            }
            try //2
            {
                if (data[i-1, j-1] == '#')
                {
                    result++;
                }
            }
            catch
            {
            }
            try //3
            {
                if (data[i-1, j+1] == '#')
                {
                    result++;
                }
            }
            catch
            {
            }
            try //4
            {
                if (data[i, j-1] == '#')
                {
                    result++;
                }
            }
            catch
            {
            }
            try //5
            {
                if (data[i, j+1] == '#')
                {
                    result++;
                }
            }
            catch
            {
            }
            try //6
            {
                if (data[i+1, j-1] == '#')
                {
                    result++;
                }
            }
            catch
            {
            }
            try //7
            {
                if (data[i+1, j] == '#')
                {
                    result++;
                }
            }
            catch
            {
            }
            try //8
            {
                if (data[i+1, j+1] == '#')
                {
                    result++;
                }
            }
            catch
            {
            }
            Console.Write(result);
        }
    }
}

Measured memory_bytes: 13268
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int cost = 0;
		if (a >= 13) {
			cost = b;
		} else if (a >= 6) {
			cost = b / 2;
		}
		System.out.println(cost);
	}
}


Measured memory_bytes: 23380
#include "stdio.h"
#include "stdlib.h"
#include "iostream"
#include "math.h"
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include "algorithm"
#include <time.h>


using namespace std;
#define fori0(G) for(int i=0;i<G;i++)
#define fori1(G) for(int i=1;i<=G;i++)
#define forj0(G) for(int j=0;j<G;j++)
#define forj1(G) for(int j=1;j<=G;j++)
#define fork0(G) for(int k=0;k<G;k++)
#define fork1(G) for(int k=1;k<=G;k++)
int dx[] = { -1,0,1,0 ,0 }, dy[] = { 0,1,0,-1,0 };
#define nxnycon (0<=nx&&nx<h&&0<=ny&&ny<w) 
#define lo long long int
#define  NN cout << "No"<<endl;
#define  YY cout << "Yes"<<endl;

int n,m,a[100000],b,c,t;
lo s;
map<int, int> ml,mr;


int main() {
	cin >> n>> m;
	fori0(n) {
		cin >> a[i];
		t = (t + a[i]) % m;
	}
	ml[0]++;
	fori0(n ) {
		b = (b + a[i]) % m;
		ml[b]++;
	}
	s += ml[t];
	for (int i = n - 1;i >= 0;i--) {
		c = (c + a[i]) % m;
		s += ml[(t - c + m) % m];
		
	}
	
	cout << (lo)(s-n-1)/2;
	//system("pause");
	return 0;

}



Measured memory_bytes: 3584
a=input()
flag = 0
for i in range(len(a)-1):
  if flag == 0:
    if a[i]==a[i+1]:
      print("{0} {1}".format(i+1,i+2))
      flag = 1
    elif i+2!=len(a) and a[i]==a[i+2]:
      print("{0} {1}".format(i+1,i+3))
      flag = 1
if flag == 0:
  print("-1 -1")


Measured memory_bytes: 3188
a, b, c, x = map(int, [input() for _ in range(4)])

n_combinations = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                n_combinations += 1

print(n_combinations)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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 int INF=1e18;
const int MOD=1e9+7;

signed main(){
    int n, m, v, p; cin >> n >> m >> v >> p;
    vector<int>a(n);
    REP(i,n) cin >> a[i];
    sort(a.rbegin(),a.rend());
    int ans = p;
    int over = 0;
    for(int i = p;i < n; i++){
        if(a[i] == a[p-1]) ans++;
        else{
            int z = max(v - (p-1 + n-i), 0ll);
            if(m * z - over <= (a[i] + m - a[p-1]) * (i-p+1) and a[p-1] - a[i] <= m) ans++;
            else break;
            over += a[p-1] - a[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
X = int(input())

if 400 <= X < 600:
  print(8)
elif 600<= X < 800:
  print(7)
elif 800<= X < 1000:
  print(6)
elif 1000<= X < 1200:
  print(5)
elif 1200<= X < 1400:
  print(4)
elif 1400<= X < 1600:
  print(3)
elif 1600<= X < 1800:
  print(2)
elif 1800<= X < 2000:
  print(1)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

#define ll long long
#define ldb long double
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mpa make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(i,a,b) for (int i = (a); i < (b); ++i)
#define rrof(i,a,b) for (int i = (b)-1; i >= (a); --i)


const int MOD = 1e9+7;
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n){
	ll res=1;

	while(n){
		if(n%2)
		res*=a;
		a*=a;
		n/=2;
	}
	
	return res;
}

ll int h=power(10,9);

ll int fun(int x,int*a,ll int*dp){
	if(x<=0)
	return 0;
	
	if(x==1){
		return abs(a[1]-a[0]);
	}
		
	if(dp[x]==-1){
		dp[x]=min(fun(x-1,a,dp)+abs(a[x]-a[x-1]),fun(x-2,a,dp)+abs(a[x]-a[x-2]));
	}
	
	return dp[x];
}

int main(){
	fast;
	
	int n;
	cin>>n;
	
	int a[n];
	forr(i,0,n)
	cin>>a[i];
	
	ll int dp[n+1];
	for(int i=0;i<=n;i++)
	dp[i]=-1;
	
	ll int ans=fun(n-1,a,dp);
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=998244353;

int N,ans,cnt;int X;
string x;
struct p{int n,s;};
vector<p> v;

int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}

int f(int a){//長さaのループがX以下に何種類存在するか
  int res=0;
  for(int i=0;i<a;i++)if(x[i]=='1')res+=pw(2,a-i-1),res%=MOD;//桁DPっぽいところ
  {//最初a文字がXと完全に一致しているやつがx以下かどうかの判定
    string A=x.substr(0,a),s;
    while(s.size()<N)s+=A;
    for(int i=0;i<s.size();i++)if((i/a)&1)s[i]=(s[i]-'0')^1+'0';
    //sがx以下かどうか判定する
    for(int i=a;i<N;i++){
      if(x[i]=='1'&&s[i]=='0'){res++;break;}
      if(x[i]=='0'&&s[i]=='1')break;
      if(i==N-1)res++;
    }
  }
  return res;
}

int INT(string x){//xを数字に変換する
  int res=0;
  for(char p:x){
    res*=2;
    res+=(p=='1');
    res%=MOD;
  }
  return res;
}

signed main(){
  cin>>N>>x;
  for(int i=1;i<N;i++)
    if(N%i==0&&(N/i)&1)
      v.push_back({i,f(i)});
  for(int i=0;i<v.size();i++){
    for(int j=i+1;j<v.size();j++)
      if(v[j].n%v[i].n==0)
        v[j].s-=v[i].s;
    ans+=v[i].s*2*v[i].n;ans%=MOD;
    cnt+=v[i].s;cnt%=MOD;
  }
  int nomal=(INT(x)+1-cnt)%MOD;//2*Nでループするやつの個数
  ans+=nomal*N*2%MOD;ans%=MOD;if(ans<0)ans+=MOD;
  cout<<ans<<endl;
}


Measured memory_bytes: 1040
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define SIZE (1046527)
#define FOUND (-1)
#define L (14)

char H[SIZE][L];

u64 string2int(const char* str);
u64 h1(u64 key) { return key % SIZE; }
u64 h2(u64 key) { return 1 + key % (SIZE - 1); }
s64 find(const char* str);
int insert(const char* str);

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

    int n;
    char op[7];
    char str[13];

    rep (i, SIZE)
    {
        H[i][0] = '\0';
    }

    cin >> n;
    rep (i, n)
    {
        cin >> op >> str;
        if (op[0] == 'i')
        {
            insert(str);
        }
        else if (op[0] == 'f')
        {
            if (find(str) == FOUND)
            {
                cout << "yes\n";
            }
            else
            {
                cout << "no\n";
            }
        }
    }

    return 0;
}

u64 string2int(const char* str)
{
    u64 sum = 0;
    while (*str)
    {
        sum *= 5;
        if (*str == 'A') sum += 1;
        else if (*str == 'C') sum += 2;
        else if (*str == 'G') sum += 3;
        else if (*str == 'T') sum += 4;
        else return 0;

        ++str;
    }

    return sum;
}

s64 find(const char* str)
{
    u64 index;
    u64 key = string2int(str);

    for (int i = 0;; ++i)
    {
        index = (h1(key) + h2(key) * i) % SIZE;
        if (strcmp(H[index], str) == 0) return FOUND;
        else if (strlen(H[index]) == 0) return index;
    }

    return FOUND;
}

int insert(const char* str)
{
    u64 index;
    if ((index = find(str)) != FOUND)
    {
        strcpy(H[index], str);
        return 0;
    }

    return 1;
}




Measured memory_bytes: 17440
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        char sent[] = new char[input.length()];

        for(int i=0;i<input.length();i++){
            sent[i] = input.charAt(i);
            if(Character.isUpperCase(sent[i]))
                sent[i] = Character.toLowerCase(sent[i]);
            else sent[i] = Character.toUpperCase(sent[i]);    
        }
        for(int i=0;i<input.length();i++) System.out.print(sent[i]);
        System.out.println("");
        sc.close();
    }
}


Measured memory_bytes: 27056
#include <bits/stdc++.h>
using namespace std;
bool oks, okr, okp;
int n, k, r, s, p;
string t;
int ans;
void rck(string tmp){
  for (int i = 0; i < k; i++){
    if (t[i] == 's'){
      ans += r;
      tmp[i] = 'r';
    }
  }
  for (int i = k; i < t.size(); i++){
    if (t[i] == 's'){
      if (tmp[i-k] == 'r')  
        tmp[i] = 's';
      else {
        tmp[i] = 'r';
        ans+=r;
      }
    }
  }
}
void pp(string tmp){
  for (int i = 0; i < k; i++){
    if (t[i] == 'r'){
      ans += p;
      tmp[i] = 'p';
    }
  }
    for (int i = k; i < t.size(); i++){
      if (t[i] == 'r'){
        if (tmp[i - k] == 'p')
          tmp[i] = 'r';
        else{
          tmp[i] = 'p';
          ans += p;
        }
    }
  }
}
void sc(string tmp){
  for (int i = 0; i < k; i++){
    if (t[i] == 'p'){
      ans += s;
      tmp[i] = 's';
    }
  }
  for (int i = k; i < t.size(); i++){
    if (t[i] == 'p'){
      if (tmp[i-k] == 's')
        tmp[i] = 'p';
      else{
        tmp[i] = 's';
        ans += s;
      }
    }
  }
}
int main(){

  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k >> r >> s >> p;
  cin >> t;
  string tmp(n, '0');
  if (r >= s && r >= p){
    rck(tmp);
    if (s > p){
      sc(tmp);
      pp(tmp);
    }
    else{
      pp(tmp);
      sc(tmp);
    }
  }
  else{
    if (s >= r && s >= p){
      sc(tmp);
      if (r > p){
        rck(tmp);
        pp(tmp);
      }
      else{
        pp(tmp);
        rck(tmp);
      }
    }
  else{
    if (p >= r && p >= s){
      pp (tmp);
      if (r > s){
        rck(tmp);
        sc(tmp);
      }
      else{
        sc(tmp);
        rck(tmp);
      }
      }
    }
  }
  cout << ans << '\n';
   
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int q[1000][1000];
int main(){
int c=1,a[1000]={};
  string b;
  cin>>b;
  for(int i=0;i<b.size();i++){
    a[b[i]]++;
    if(a[b[i]]>=2) c=0;
  }
  if(c) cout<<"yes";
  else cout<<"no";
  cout<<"\n";
}

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

int main() {
	// your code goes here
	string s; cin>>s; 
	int n = s.size();
	stack<char>stk;
	for(int i=0;i<n;i++){
		if(s[i]=='0' or s[i]=='1') stk.push(s[i]);
		else if(!stk.empty()) stk.pop();
	}
	s = "";
	while(!stk.empty()){
		s+=stk.top();
		stk.pop();
	}
	reverse(s.begin(),s.end());
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 250
#define NIL -201
struct Node_struct{int id, p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];

void print(int u){
  printf("node %d: key = %d, ", u, T[u].id);

  if(u != 1) printf("parent key = %d, ", T[u].p);
  if(T[u].l != NIL) printf("left key = %d, ", T[u].l);
  if(T[u].r != NIL) printf("right key = %d, ", T[u].r);

  printf("\n");
}


int main(){
  int i;
  int n;
  int id;

  scanf("%d", &n);
  for(i=1; i<=n; i++) T[i].id = T[i].p = T[i].l = T[i].r = NIL;

  for(i=1; i<=n ; i++){
    scanf("%d", &T[i].id);
    if(i != 1) T[i].p = T[i/2].id;
    if(T[i/2].l == NIL) T[i/2].l = T[i].id;
    else T[i/2].r = T[i].id;
    
  }

  //出力 (output)
  for(i=1; i<=n; i++) print(i);

  return 0;
}



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

int main()
{
    int a, b;
    char in[110] = {};
    cin >> a >> b;
    string A = {};
    string B = {};

    for (int i = 0; i < b; ++i)
    {
        in[i] = '0' + a;
    }
    A = in;
    for (int i = 0; i < a; ++i)
    {
        in[i] = '0' + b;
    }
    in[a] = 0;
    B = in;
    cout << ((A < B) ? A : B) << endl;
}


Measured memory_bytes: 256
#pragma warning(disable:4996)
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iostream>
#include<time.h>
#include<map> 
#include<set>
#include<sstream>
#include<cassert>
using namespace std;
const int INF = 0x3f3f3f3f;

int p1()
{
    int a,b;
    cin >> a >> b;
    return (a+b+24)%24;
}

int main()
{
    cout<< p1() <<endl;
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const long long MOD = 1000000007;

void update(int &a, int b) {
    a = min(a, b);
    return;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int h, n;
    cin >> h >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    vector<int> dp(h + 1, INT_MAX);
    dp[0] = 0;
    for (int i = 0; i < h; i++) {
        if (dp[i] == INT_MAX) continue;
        for (int j = 0; j < n; j++) {
            update(dp[min(i + a[j], h)], dp[i] + b[j]);
        }
    }
    cout << dp[h];
    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++)
#define rep_in(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef int64_t ll;

int main() {
  int n,k;
  cin>>n>>k;

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

  set<int> s;
  rep(i,k){
    s.insert(p[i]);
  }
  int out=1;
  rep(i,n-k){
    s.insert(p[i+k]);
    if(*s.begin()!=p[i]||*s.rbegin()!=p[i+k]) out++;
    s.erase(p[i]);
  }

  int sorted_seq=0;
  int len=0;
  rep(i,n-1){
    if(p[i]>p[i+1]) len=0;
    len++;
    if(len==k){
      sorted_seq++;
    }
  }
  out-=(sorted_seq-(sorted_seq>0));

  cout<<out<<endl;
}


Measured memory_bytes: 10368
#include <stdio.h>

int main(void)
{
  int n;
  int h[100];
  int count = 0;
  int max = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &h[i]);
    if (h[i] >= max) {
      max = h[i];
      count++;
    }
  }
  printf("%d\n", count);
}


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

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    for(int i=1;i<s.size();++i){
        if(s[i] != s[i-1])cnt++;
    }

    cout << cnt << endl;

    return 0;
}


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

int main() {
	int n,i,r,min = 1000000000,max = -1000000000;
	
	cin >> n;
	
	cin >> min;
	for(i=1;i<n;++i){
		cin >> r;
		
		if(r - min > max){
			max = r - min;
		}
		if(r < min){
			min = r;
		}
	}
	
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<int,int>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i,n) for (ll i=(ll)n-1;i>=0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
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; }
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
#define INF 1<<30
#define INFTY 1LL<<60
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}//最大公約数
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}//最小公倍数
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
const int MOD = 1000000007;

inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;
x=x*x%mod;n>>=1;}return res;}
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back
int main(){
    int n;cin>>n;
    VI D1(n),D2(n);
    rep(i,n){
        cin>>D1[i]>>D2[i];
    }
    rep(i,n-2){
        if(D1[i]==D2[i] && D1[i+1]==D2[i+1] && D1[i+2]==D2[i+2]){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3620
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	h := getNextInt(scanner)
	w := getNextInt(scanner)
	grid := make([]string, h)

	for i := 0; i < h; i++ {
		grid[i] = getNextString(scanner)
	}

	dd := make([][]int, h)
	for i := 0; i < h; i++ {
		dd[i] = make([]int, w)
	}

	dy := [4]int{
		-1,
		1,
		0,
		0,
	}
	dx := [4]int{
		0,
		0,
		-1,
		1,
	}
	max := 0
	for y := 0; y < h; y++ {
		for x := 0; x < w; x++ {
			if grid[y][x] == '#' {
				continue
			}
			for i := 0; i < h; i++ {
				dd[i] = make([]int, w)
				for j := 0; j < w; j++ {
					dd[i][j] = math.MaxInt32
				}
			}

			q := make([]Point, 0)
			q = append(q, Point{
				y: y,
				x: x,
				d: 0,
			})
			for len(q) > 0 {
				p := q[0]
				q = q[1:]
				if max < p.d {
					max = p.d
				}
				if dd[p.y][p.x] < math.MaxInt32 {
					continue
				}
				dd[p.y][p.x] = p.d
				for i := 0; i < 4; i++ {
					yy := p.y + dy[i]
					xx := p.x + dx[i]
					if yy < 0 {
						continue
					}
					if yy >= h {
						continue
					}
					if xx < 0 {
						continue
					}
					if xx >= w {
						continue
					}
					if grid[yy][xx] == '#' {
						continue
					}
					if dd[yy][xx] < math.MaxInt32 {
						continue
					}
					q = append(q, Point{
						y: yy,
						x: xx,
						d: p.d + 1,
					})
				}
			}
		}
	}

	fmt.Fprintln(writer, max)
}

type Point struct {
	y, x, d int
}


Measured memory_bytes: 6144
def is_prime(x) :
    if x == 2 :
        return True
    if x < 2 or x % 2 == 0 :
        return False

    return pow(2, x-1, x) == 1

def main() :
    n = int(input())
    nums = []
    for _ in range(n) :
        x = int(input())
        nums.append(x)

    count = 0
    for num in nums :
        if is_prime(num) :
            count += 1

    print(count)

if __name__ == '__main__' :
    main()

Measured memory_bytes: 8184
#include <stdio.h>

int main(){
	int x,a,b;
	int jarak1,jarak2;
	scanf("%d %d %d",&x,&a,&b);
	jarak1 = x-a;
	jarak2 = x-b;
	jarak1<0 ? jarak1*=-1 : jarak1;
	jarak2<0 ? jarak2*=-1 : jarak2;
	jarak1<jarak2? puts("A") : puts("B");
 	return 0;
}

Measured memory_bytes: 2072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(p,a,b)    for(int p=a;i<b;i++)
#define INF 0x3f3f3f3f

int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("o2.txt", "w", stdout);
    #endif

    map<int,int> m;
    int n,i,x;
    cin>>n;
    for(i=0 ; i<n-1 ; i++)
    {
        cin>>x;
        m[x]++;
    }
    for(i=1 ; i<=n ; i++)
    {
        cout<<m[i]<<"\n";
    }
    
    return 0;
}

Measured memory_bytes: 12892
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

string lcs(vector<vector<int>> &dp, string &s1, string &s2){
	for(int i=1;i<=s1.size();i++){
		for(int j=1;j<=s2.size();j++){
			if(s1[i-1]==s2[j-1])dp[i][j] = dp[i-1][j-1] + 1;
			else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}
	string result = "";
	int i = s1.size();
	int j = s2.size();
	while(i>0 && j>0){
		if(dp[i-1][j]==dp[i][j])i--;
		else if(dp[i][j]==dp[i][j-1])j--;
		else{
			result += s1[i-1];
			i--;
			j--;
		}
	}
	reverse(result.begin(), result.end());
	return result;
}

int main() {
	// your code goes here
	string s1;
	string s2;
	cin>>s1>>s2;
	vector<vector<int>> dp(s1.size() + 1, vector<int>(s2.size() + 1, 0));
	cout<<lcs(dp, s1, s2)<<endl;
	return 0;
}

Measured memory_bytes: 38304
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))

if n >= m:
    print(0)
else:
    diff = sorted([abs(x[i-1] - x[i]) for i in range(1, m)], reverse=True)
    print(sum(diff[n-1:]))
        

Measured memory_bytes: 13968
#include <iostream>
#include <algorithm>

int main()
{
    int n;
    std::cin >> n;

    int a, b, c;
    int dp[100010][3] = { 0 };

    for (int i = 0; i < n; ++i)
    {
        std::cin >> a >> b >> c;
        if (i == 0)
        {
            dp[i][2] = c;
            dp[i][1] = b;
            dp[i][0] = a;
        }
        else
        {
            dp[i][0] = std::max(dp[i - 1][1], dp[i - 1][2]) + a;
            dp[i][1] = std::max(dp[i - 1][2], dp[i - 1][0]) + b;
            dp[i][2] = std::max(dp[i - 1][1], dp[i - 1][0]) + c;
        }
    }

    std::cout << std::max(dp[n - 1][0], std::max(dp[n - 1][1], dp[n - 1][2]));
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N,M;
  cin >> N >> M;
  vi L(M),R(M),D(M);
  vector<vpii> v(N);
  rep(i,M) {
    cin >> L[i] >> R[i] >> D[i];
    L[i]--;R[i]--;
    v[L[i]].push_back(make_pair(R[i],D[i]));
    v[R[i]].push_back(make_pair(L[i],-D[i]));
  }
  
  vi x(N);
  bool flag=true;
  vector<bool> check(N);
  queue<int> que;
  rep(j,N) {
    if(!v[j].size()||check[j]) continue;
    que.push(L[j]);
    check[L[j]]=true;
    while(que.size()) {
      int q=que.front();
      que.pop();
      rep(i,v[q].size()) {
        if(check[v[q][i].first]) {
          if(x[v[q][i].first]!=x[q]+v[q][i].second) flag=false;
        }
        else {
          x[v[q][i].first]=x[q]+v[q][i].second;
          que.push(v[q][i].first);
          check[v[q][i].first]=true;
        }
      }
    }
    if(!flag) break;
  }
  
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
int main(){
        int a,b,c;
        cin >> a >> b >> c;
        if(a<b){
                if(b<c){
                        cout << "Yes" << endl;
                }else{
                        cout << "No" << endl;
                }
        }else{
                cout << "No" << endl;
        }
}



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

struct UnionFind{
    vector<int> data;
    UnionFind(int size) : data(size, -1){}
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x != y){
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
    }
    int root(int x) {return data[x] < 0 ? x : data[x] = root(data[x]);}
    int size(int x) {return -data[root(x)];}
};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    UnionFind uf(n);
    while (q--){
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0){
            uf.unite(x, y);
        }else{
            if (uf.root(x) == uf.root(y)){
                cout << 1 << '\n';
            }else{
                cout << 0 << '\n';
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
int N, K, Q;
vector<int> A;

int main()
{
    cin >> N >> K >> Q;
    A.resize(N);
    priority_queue<P, vector<P>, greater<P>> pq;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        pq.push(make_pair(A[i], i));
    }

    int ans = 1000000000;
    for (int i = 0; i < N - Q + 1; i++)
    {
        P p = pq.top();
        pq.pop();
        int bound = p.first;
        // cout << bound << endl;
        priority_queue<int, vector<int>, greater<int> > successive, useful;
        for (auto v : A)
        {
            if (v < bound)
            {
                if (successive.size() >= K)
                {
                    int num = successive.size() - K + 1;
                    for (int j = 0; j < num; j++)
                    {
                        useful.push(successive.top());
                        successive.pop();
                    }
                }
                successive = priority_queue<int, vector<int>, greater<int> >();
            }
            else
            {
                successive.push(v);
            }
        }
        if (successive.size() >= K)
        {
            int num = successive.size() - K + 1;
            for (int j = 0; j < num; j++)
            {
                useful.push(successive.top());
                successive.pop();
            }
        }

        // cout << useful.size() << endl;
        if (useful.size() >= Q)
        {
            int a = useful.top();
            for (int j = 0; j < Q - 1; j++)
                useful.pop();
            ans = min(ans, useful.top() - a);
        }
    }

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

Measured memory_bytes: 256
n = gets.chop.to_i
s = Array.new(n,0).map{ |e| Array.new(n, 0)}
n.times do |i|
  s[i] = gets.chop.split("")
end
st = s.transpose
count = 0
n.times do |a|
  s.map{ |e| e.rotate! }
  st.rotate!
  count += 1 if s == st
end

p count*n


Measured memory_bytes: 10616
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define MAX 1000003
#define F first
#define S second
ll prime[MAX];
unordered_map<ll,ll> max_map;
ll binpow(ll x,ll y){
    ll res=1;
    x%=mod;
    while(y>0){
        if(y&1)
            res=(res*x)%mod;
        y>>=1;
        x=(x*x)%mod;
    }
    return res;
}
void sieve(){
    prime[0] = prime[1] = 1;
    for (ll i = 2; i < MAX; i++) {
        if (prime[i] == 0) {
            for (ll j = i * 2; j < MAX; j += i) {
                if (prime[j] == 0)
                    prime[j] = i;
            }
            prime[i] = i;
        }
    }
}
ll lcmModuloM(const ll* ar,ll n){
    for(ll i=0;i<n;i++) {
        ll num=ar[i];
        unordered_map<ll,ll> temp;
        while(num>1){
            ll factor=prime[num];
            temp[factor]++;
            num/=factor;
        }
        for(auto it:temp)
            max_map[it.first]=max(max_map[it.first],it.second);
    }
    ll ans = 1;
    for (auto it : max_map) {
        ans = (ans * binpow(it.F, it.S)) % mod;
    }
    return ans;
}
ll modinv(ll a,ll m){
    assert(m>0);
    if(m==1)
        return 0;
    a%=m;
    if(a<0)
        a+=m;
    assert(a!=0);
    if(a==1)
        return 1;
    return m-modinv(m,a)*m/a;
}
ll mulmod(ll a,ll b){
    ll res=0;
    a%=mod;
    while(b){
        if(b&1)
            res=(res+a)%mod;
        a=(2*a)%mod;
        b>>=1;
    }
    return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    sieve();
    ll n,i,gcd=0,prod=1,ans=0;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
        cin>>arr[i];
    ll lcm=lcmModuloM(arr,n);
    for(i=0;i<n;i++)
        ans=((ans%mod)+mulmod(lcm,modinv(arr[i],mod))%mod)%mod;
    cout<<ans<<endl;
    return 0;
}


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

#define rd(x) x=read()

#define int long long

using namespace std;

int a,b;

inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

inline void write(int x)
{
    if(x<0){putchar('-');x=-x;}
    if(x>=10)write(x/10);
    putchar(x%10+'0');
}

signed main()
{
	rd(a),rd(b);
    if(a>0)cout<<"Positive"<<endl;
    else if(a==0||(a<0&&b>0))cout<<"Zero"<<endl;
    else if((abs(b)-abs(a))&1)cout<<"Positive"<<endl;
    else cout<<"Negative"<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main() {
  int N;
  double T,A;
  scanf("%d",&N);
  scanf("%lf %lf",&T,&A);
  int p=1;
  double min;
  for (int i = 0; i < N; i++) {
    int hight;
    double dif;
    if (i == 0) {
      scanf("%d",&hight);
      min=fabs((T-(double)hight*0.006)-A);
    }
    else {
      scanf("%d",&hight);
      dif=fabs((T-(double)hight*0.006)-A);
      if (min > dif) {
        min = dif;
        p = i+1;
      }
    }
  }
  printf("%d\n",p);
  return 0;
}


Measured memory_bytes: 256
program rgb_triplets
  implicit none
  integer :: n, i, j, a(4000) = 0, p, q
  integer(8) :: c(3) = 0_8, x = 0_8
  character(4000) :: s
  read(*,*) n
  read(*,*) s
  do i = 1, n
    if (s(i:i) == "R") then
      a(i) = 1
    else if (s(i:i) == "G") then
      a(i) = 2
    else
      a(i) = 3
    end if
    c(a(i)) = c(a(i))+1_8
  end do
  x = c(1)*c(2)*c(3)
  do j = 1, n
    do i = 1, n
      p = i+j
      q = p+j
      if (q > n) exit
      if (a(i) == a(p) .or. a(p) == a(q) .or. a(q) == a(i)) cycle
      x = x-1_8
    end do
  end do
  write(*,'(i0)') x
end program rgb_triplets

Measured memory_bytes: 2928
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

const i64 MOD = 998244353;

int main()
{
  i64 N, K;
  cin >> N >> K;
  vector<i64> L(N), R(N);
  for (i64 i = 0; i < N; i++)
    cin >> L[i] >> R[i];
  vector<i64> dp(N + 1), sumDp(N + 1);
  dp[1] = 1, sumDp[1] = 1;
  for (i64 i = 2; i <= N; i++)
  {
    for (i64 j = 0; j < K; j++)
      (dp[i] += (sumDp[max(0LL, i - L[j])] - sumDp[max(0LL, i - R[j] - 1)] + MOD) % MOD) %= MOD;
    (sumDp[i] = sumDp[i - 1] + dp[i]) %= MOD;
  }
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 9540
// inputに入力データ全体が入る
function Main(input) {
	input = input.split("\n");
	var a = parseInt(input[0], 10);
	var b = input[1];

	console.log( ((a<3200)? "red":b) );
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
int p[100],arr[]={1,4,7,9};
main()
{
	int t;
	for(int i = 0;i < 4;i++)
	{
		scanf("%d",&t);
		p[t]=1;
	}
	for(int i = 0;i < 4;i++)
	{
		if(p[arr[i]]==0)
		{
			printf("NO");
			return 0;
		}
	}
	printf("YES");
}

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

#define ll long long
#define mod 1000000007

ll ar[1000005];

ll bigmod(ll n,ll p){if(p==0) return 1;if(p==1)return (n+mod)%mod;if(p%2)return (bigmod(n,p-1)*n+mod)%mod;else{ll x=bigmod(n,p/2);return (x*x+mod)%mod;}}
ll modinverse(ll n){return bigmod(n,mod-2)%mod;}


int main()
{
    int x,y;
    scanf("%d%d",&x,&y);

    ar[0]=1;

    for(ll i=1;i<=1000001;i++)
    {
        ar[i]=((ar[i-1]%mod)*(i%mod))%mod;
    }


    if((x+y)%3!=0)
    {
        printf("0\n");
        return 0;
    }

    ///equation n+2m=x,2n+m=y

    int m=(2*x-y)/3;
    int n=(2*y-x)/3;

    if(m<0 || n<0)
    {
         printf("0\n");
        return 0;
    }
    //cout<<n<<" "<<m<<endl;
    
    ///(m+n)C(n) 

    ll re= (ar[m+n]*(modinverse(ar[n])*modinverse(ar[m])%mod))%mod;

    //re=(re+n)%mod;

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


    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> b(N);
  for(int i=0;i<N-1;i++){
    int k;
    cin >> k;
    b.at(k-1)++;
  }
  for(int i=0;i<N;i++){
    cout << b.at(i) << endl;
  }
}

Measured memory_bytes: 3972
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int n, m, x, y;
    vector<int> x_arr, y_arr;

    cin >> n >> m >> x >> y;

    x_arr.resize(n);
    y_arr.resize(m);
    for(int i = 0; i < n; i++) cin >> x_arr[i];
    for(int i = 0; i < m; i++) cin >> y_arr[i];
    sort(x_arr.begin(), x_arr.end());
    sort(y_arr.begin(), y_arr.end());

    int max_X = max(x, x_arr[n - 1]);
    int min_Y = min(y, y_arr[0]);

    if(max_X < min_Y) cout << "No War" << endl;
    else              cout << "War" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int r;cin>>r;
  if(r<1200){
    cout<<"ABC";
  }
  else if(r<2800)cout<<"ARC";
  else cout<<"AGC";
  cout<<endl;
  return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int h,w; cin>>h>>w;
	cout<<string(w+2,'#')<<endl;
	rep(i,h){
		string s; cin>>s;
		cout<<"#"<<s<<"#"<<endl;
	}
	cout<<string(w+2,'#')<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n, k;
	cin >> n >> k;
	map<int,int> m;
	
	for(int i = 0; i < k; i++){
		int x;
		cin >> x;
		for(int j = 0; j < x; j++){
			int p;
			cin >> p;
			m[p]++;
		}
	}
	cout << n - m.size() << endl;

	return 0;
}



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


#define ll long long
#define pb push_back
#define mp make_pair
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, a, b) for(int i = (a); i > (b); --i)

typedef pair <int,int> ii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <ll> vl;

const int mod = 1e9+7;
const int inf = 2e18+5;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s , t , ans="";
    cin>>s>>t;
    int slen=s.length() , tlen=t.length();
    int dp[slen+1][tlen+1];
    memset(dp,0,sizeof(dp));
    s=" "+s;
    t=" "+t;
    loop(i,1,slen+1){
      loop(j,1,tlen+1){
        if(s[i]==t[j])
          dp[i][j] = dp[i-1][j-1] + 1;
        else
          dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);
        }
    }
    int i=slen;
    int j=tlen;
    while(i>0 && j>0){

      if(dp[i][j]==dp[i-1][j])
        i--;
      else if(dp[i][j]==dp[i][j-1])
        j--;
      else{
          ans = s[i]+ans;
          i--;
          j--;
      }
    }
    
    cout<<ans;
    return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> g(h);
  rep(i,h) cin >> g[i];

  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(g[i][j] == '#') continue;
      int cnt = 0;
      for(int k = -1; k < 2; k++){
        for(int l = -1; l < 2; l++){
          if(k == 0 && l == 0) continue;
          if(i+k < 0 || i+k > h-1 || j+l<0 || j+l>w-1) continue;
          if(g[i+k][j+l] == '#') cnt++;
        }
      }
      g[i][j] = cnt + '0';
    }
  }

  rep(i,h) cout << g[i] << endl;

}


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

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

 int* A = new int[n];
 for(int i=0;i<n;i++){
   cin >> A[i]; 
 }

 for(int i=0;i<n;i++){
   int v = A[i],j= i-1;
   while(j>=0 && A[j] > v){
     A[j+1] = A[j];
     j--;
   }
   A[j+1] = v;
   for(int k=0;k<n;k++){
     cout << (k != 0 ? " ": "") << A[k];
   }
   cout << endl;
 }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  ll m = n % 2 + 1;
  ll dp[n + 1][m + 1][2] = {};
  rep(i, n + 1) rep(j, m + 1) rep(k, 2) dp[i][j][k] = -1e18;
  dp[0][0][0] = 0;
  rep(i, n) rep(j, m + 1) rep(k, 2) {
    if(k == 1)
      dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
    else {
      if(j != 0 || i != n - 1)
        dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][k] + a[i]);
      if(j < m) dp[i + 1][j + 1][0] = max(dp[i + 1][j + 1][0], dp[i][j][k]);
    }
  }
  ll ans = -1e18;
  rep(j, m + 1) rep(k, 2) ans = max(ans, dp[n][j][k]);
  cout << ans << endl;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int cnt = 0;
	REP(i, n) {
		int a;
		cin >> a;
		if (a % 2 == 1)cnt++;
	}
	if (cnt % 2 == 0)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
using ll = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<int> d(n);
    rep(i,0,n) {
        cin >> d[i];
        ++a[d[i]];
    }
    const ll MOD = 998244353;
    ll ans = a[0]==1?1:0;
    if(d[0]!=0) ans = 0;
    rep(i,1,n) {
        rep(j,0,a[i]) {
            ans = (ans*a[i-1])%MOD;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void) {
  string s, t;
  bool f;
  cin>>s>>t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  for(int i=0; i<=s.size(); i++) {
    if(s[i]=='\0') {
      if(t[i]=='\0') {
	cout<<"No"<<endl;
	break;
      } else {
	cout<<"Yes"<<endl;
	break;
      }
    } else if(t[i]=='\0') {
      cout<<"No"<<endl;
      break;
    } else if(s[i]<t[i]) {
      cout<<"Yes"<<endl;
      break;
    } else if(s[i]>t[i]) {
      cout<<"No"<<endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256