akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;
using P = pair<int, int>;

#define roop(i, n) for(int i = 0;i < n;i++)
#define INF -1

int h, w;
vector<string> field;

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

int main(void){

    cin >> h >> w;
    roop(i, h){
        string s; cin >> s;
        field.push_back(s);
    }

    queue<P> que;
    vector<vector<int>> value(h, vector<int>(w, INF));

    roop(i, h){
        roop(j, w){
            if(field[i][j] == '#'){
                value[i][j] = 0;
                que.push(P(i, j));
            }
        }
    }


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

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

        for(int i = 0;i < 4;i++){
            int ny = y + dy[i];
            int nx = x + dx[i];
            if(nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
            if(value[ny][nx] != INF) continue;

            que.push(P(ny, nx));
            value[ny][nx] = value[y][x] + 1;
        }
    }

    int ans = 0;
    roop(i, h){
        roop(j, w){
            ans = max(ans, value[i][j]);
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int count = 0;
	for (int i = 0; i < s.length() - 2; ++i)
	{
		string s1 ="";
		s1 += s[i];
		for (int j = i + 1; j < i + 3; ++j)
		{
			s1 += s[j];
		}
		if(s1 == "ABC") {
			count++;
		}
	}
	cout<<count;
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <math.h>

using namespace std;

int main()
{
	int n;
	bool prime[300000];

	for (int i = 0; i < 300000; i++){
		prime[i] = true;
	}
	prime[0] = prime[1] = false;

	for (int i = 2; i < 300000; i++){
		if (prime[i]){
			for (int j = 0; i * (j + 2) < 300000; j++){
				prime[i * (j + 2)] = false;
			}
		}
	}

	while (true){
		scanf("%d", &n);
		if (n == 0){
			break;
		}

		int cnt = 0;
		for (int i = n + 1; i <= n * 2; i++){
			if (prime[i]){
				cnt++;
			}
		}

		printf("%d\n", cnt);
	}

	return (0);
}

Measured memory_bytes: 1480
N,K=map(int, input().split())
a_ls=list(map(int, input().split()))

j=1
step=0
s=set([])
l=[]
loop_s=-1
loop_g=-1

while True:
	s.add(j)
	l+=[j]
	j=a_ls[j-1] #update
	if j in s:
		loop_s=l.index(j)
		loop_g=len(l)
		break


#print(l)
#print(loop_s)
#print(loop_g)

if K<loop_s:
	print(l[K])
elif (K+1-loop_s)%(loop_g-loop_s)!=0:
	print(l[loop_s+(K+1-loop_s)%(loop_g-loop_s)-1])
else:
	print(l[-1])



Measured memory_bytes: 32256
#include <bits/stdc++.h>
using namespace std;
long long dp[100007][3]={};
int main(){
  int n;
  cin >> n;
  int a[n],b[n],c[n];
  for(int i=0;i<n;i++) cin >> a[i] >> b[i] >> c[i];
  dp[0][0]=0;
  dp[0][1]=0;
  dp[0][2]=0;
  for(int i=1;i<=n;i++){
    dp[i][0] += max(dp[i-1][1]+a[i-1],dp[i-1][2]+a[i-1]);
    dp[i][1] += max(dp[i-1][0]+b[i-1],dp[i-1][2]+b[i-1]);
    dp[i][2] += max(dp[i-1][0]+c[i-1],dp[i-1][1]+c[i-1]);
  }
  cout << max(max(dp[n][0],dp[n][1]),dp[n][2]) << endl;
}

Measured memory_bytes: 3712
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

int D, G;
int p[11];
int c[11];
int ans;

signed main() {
	cin >> D >> G;
	for (int i = 1;i <= D;i++) {
		cin >> p[i] >> c[i];
	}

	int ss[11];
	for (int i = 1;i <= D;i++) {
		ss[i] = i;
	}

	int ans = 1100000;
	do {
		//for (int aaa = 1;aaa <= D;aaa++) {
		//	cout << ss[aaa] << " ";
		//}
		//cout << endl;
		int sum = 0;
		int n = 0;
		for (int i = 1;i <= D;i++) {
			int a = ss[i];
			if (sum + 100 * a*p[a] + c[a] > G) {
				for (int k = 0;k < p[a];k++) {
					sum += 100 * a;
					n++;
					if (sum >= G) break;
				}
				sum += c[a];
			}
			else {
				sum += 100 * a*p[a] + c[a];
				n += p[a];
			}
			if (sum >= G) break;
		}
		//cout << n << endl;
		if (n < ans) ans = n;
	} while (next_permutation(ss+1, ss + 1 + D));

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main (void) {
      int n=0,i=0,count=0,s=0;

      int cnt = 0;
      int a;
      //scanf("%d",&n);

      std::cin >> a;
      //printf("約数は、");
      for (n = 1; n <= a; n++){
            count = 0;
            for(i=1;i<=n;i++){
                  if(n%i==0){
                        //printf("%d、",i);
                        s=s+i;
                        count++;
                  }

            }
            if (n == 105){
                  //std::cout << count << '\n';
            }
            if (count == 8){
                  cnt++;
            }
            //std::cout << n << '\n';
            n = n + 1;
      }
      //std::cout << n << '\n';

      std::cout << cnt << '\n';

      return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


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

	int x = 1;
	int n = 0;
	while (x < b && n < a)
	{
		x *= 2;
		n += 1;
	}
	while ( n < a)
	{
		x += b;
		n += 1;
	}
	cout << x;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<map>
using namespace std;

int main()
{
	int a,b,x;
	cin>>x>>a>>b;
	int sum=(x-a)/b;
	cout<<x-a-sum*b<<endl;
	return 0;
}

Measured memory_bytes: 256
n = input() 
arr = [int(x) for x in n.split()] 
a=arr[0]
b=arr[1]
c=arr[2]

if c<=a+b:
   print("No") 

else:
    d = (4*a*b)
    e = (c-a-b)*(c-a-b)

    if e>d:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 38384
#include <iostream>
#include <cstdlib>
#include<cmath>
using namespace std;
int main()
{
    int x,a,b;cin>>x>>a>>b;if(a+x<b)cout<<b-a-x<<endl;else if(b+x<a)cout<<a-b-x<<endl;else cout<<0<<endl;
}


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

public class AtCoderB
{
    static void Main()
    {
        var sc = new Scanner();

        int[] n = new int[] { sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt() };

        int answer = 0;
        int minMod = int.MaxValue;
        for (int i = 0; i < 5; i++)
        {
            int mod = n[i] % 10;
            if (mod == 0)
            {
                mod = 10;
            }
            minMod = Math.Min(minMod, mod);

            answer += 10 * ((n[i] + 9) / 10);
        }
        answer = answer - 10 + minMod;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;
int main(void){
    int N;
    cin>>N;
    pair<pair<string , int>,int> p[N];
    for(int i=0;i<N;i++){
        string s;
        int a;
        cin>>s>>a;
        p[i].first.first=s;
        p[i].first.second=-1*a;
        p[i].second=i;
    }
    sort(p,p+N);
    for(int i=0;i<N;i++){
        cout<<p[i].second+1<<endl;
    }
}


Measured memory_bytes: 256
S = input()

lst = [1 if S[0]=='<' else -1]
for i in range(1, len(S)):
    if S[i] == S[i - 1]:
        lst[-1] += 1 if S[i]=='<' else -1
    else:
        lst.append(-1 if S[i]=='>' else 1)
        
ans = [0]

for i in range(len(lst)):
    if lst[i] > 0:
        ans += list(range(1,lst[i]+1))
    else:
        ans[-1] = max(ans[-1], -lst[i])
        ans += list(range(-lst[i]-1,-1, -1))

print(sum(ans))


Measured memory_bytes: 27676
unittest
{
	assert( [ "3", "7 1", "2", "5", "10" ].parse.expand.solve == 8 );
	assert( [ "2", "8 20", "1", "10" ].parse.expand.solve == 29 );
	assert( [ "5", "30 44", "26", "18", "81", "18", "6" ].parse.expand.solve == 56 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	input.popFront;
	auto dx = input.front.split.to!( long[] );
	auto as = new long[ n ];
	foreach( ref a; as )
	{
		input.popFront;
		a = input.front.strip.to!( long );
	}
	return tuple( dx[ 0 ], dx[ 1 ], as );
}

auto solve( long d, long x, long[] as )
{
	auto c = 0L;
	
	foreach( a; as )
	{
		for( auto i = 1; i <= d; i += a )
		{
			c++;
		}
	}
	c += x;
	
	return c;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main(){
  string s;
  bool f=0;
  cin>>s;
  if(s.size()%2 == 1){
    cout<<"No\n";
  } else {
    for(int i=0;i<s.size();i+=2){
      if(s[i] != 'h' || s[i+1] != 'i'){
        f=1;
      }
    }
    if(f){
      cout<<"No\n";
    } else {
      cout<<"Yes\n";
    }
  }
  return(0);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int a = 0;
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		a += sc.nextInt();
		a += sc.nextInt();

		if (a > 21) {
			System.out.println("bust");
		} else {
			System.out.println("win");
		}
	}
}


Measured memory_bytes: 21972
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N,M = map(int, input().split())
    print(N*M)

if __name__ == '__main__':
    main()


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

int main()
{
    int X, N, atai, M=0,M2=0;
    cin >> X >> N;
    vector<int> p(N + 1);
    bool dekita = false;
    p.at(0) = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> p.at(i);
    }
    if (p.at(0) == 0)
    {
        dekita = true;
        atai = X;
    }
    sort(p.rbegin(), p.rend());

    for (int i = 0; i <= 100; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (X - i == p.at(j))
            {
                M = j;
            }
            if (X + i == p.at(j))
            {
                M2 = j;
            }
        }
            if(dekita==true)
            {
                cout << atai << endl;
                break;
            }
            else if (X - i != p.at(M)&&X-i!=p.at(M2))
            {
                atai = X - i;
                cout << atai << endl;
                break;
            }
            else if (X + i != p.at(M)&&X+i!=p.at(M2))
            {
                atai = X + i;
                cout << atai << endl;
                break;
            }
    }
}


Measured memory_bytes: 3604
s=input()
n=int(len(s))
S=list(s)
l=int(0)
f=int(0)

while l<((n-1)/2):
  if S[l]==S[int(((n+1)/2)+l)]:
    l+=1
    continue
  else:
    f=1
    break
    
if f==1:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 3064
void solve();

int main() {
	solve();
	return 0;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
using namespace std;

int A, B;

void solve() {
	cin >> A >> B;
	cout << max(max(A + B, A - B), A * B) << endl;
	return;
}

Measured memory_bytes: 256
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_   }
#else
#define MY_NAMESPACE(ns)
#define MY_NAMESPACE_
#endif

#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


MY_NAMESPACE(ABC168D)
int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n, m;
	cin >> n >> m;
	vector<vector<int>> passages(n);
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		passages[a].emplace_back(b);
		passages[b].emplace_back(a);
	}

	vector<int> signposts(n, -2);
	queue<int> q;
	signposts[0] = -1;
	q.push(0);
	while (!q.empty())
	{
		int this_room = q.front();
		q.pop();
		for (auto next_room : passages[this_room])
		{
			if (signposts[next_room] == -2)
			{
				q.push(next_room);
				signposts[next_room] = this_room;
			}
		}
	}

	for (auto this_signpost : signposts)
	{
		if (this_signpost == -2)
		{
			cout << "No" << "\n";
			return 0;
		}
	}
	cout << "Yes" << endl;
	for (int j = 1; j < n; j++)
	{
		cout << signposts[j] + 1 << "\n";
	}

	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 10272
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define F(i,a,b) for(int i= (int)(a); i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define what_is(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
const int N = 1e6+7 ;
string s ;

int main(){fast ;
	int n,k=0 ;
	cin >> s ;
	stack<char> stk ;
	stk.push('$') ;
	for(char i : s){
		if(i == '0' and stk.top() == '1'){
			stk.pop() ;
			k++ ;
		}
		else if(i == '1' and stk.top() == '0'){
			stk.pop() ;
			k++ ;
		}
		else stk.push(i) ;
	}
	cout << 2*k << endl ;
}




Measured memory_bytes: 512
program low_elements
  implicit none
  integer :: n, p(200000) = 0, i, x = 0, m = 1e9
  read(*,*) n
  read(*,*) p(1:n)
  do i = 1, n
    if (m > p(i)) x = x+1
    m = min(m,p(i))
  end do
  write(*,'(i0)') x
end program low_elements

Measured memory_bytes: 1536
S = input().strip()

result = [0]*len(S)
mem = [0] + [i for i in range(1, len(S)) if S[i-1] != S[i]] + [len(S)]

for i in range(1, len(mem)-1, 2):
  R = mem[i] - mem[i-1]
  L = mem[i+1] - mem[i]
  result[mem[i]-1] = ((R+1)//2) + (L//2)
  result[mem[i]] = (R//2) + ((L+1)//2)

print(*result)

Measured memory_bytes: 10276
package main

import "fmt"

func main() {
	var n, y int

	fmt.Scan(&n)
	fmt.Scan(&y)

	for i := 0; i < n+1; i++ {
		for j := 0; j <= n-i; j++ {
			k := n - i - j
			if y == 10000*i + 5000*j + 1000*k {
				fmt.Printf("%d %d %d\n", i, j, k)
				return
			}
		}
	}

	fmt.Printf("%d %d %d\n", -1, -1, -1)
}


Measured memory_bytes: 1832
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
vector<vector<ll>> vec;
vector<ll> ans;
vector<bool> note;
vector<ll> p;

void dfs(ll t,ll count) {
  ans[t-1]=p[t-1]+count;
  note[t-1]=true;
  for(ll x:vec[t-1]) {
if(note[x-1]) {
continue;
}
   dfs(x,count+p[t-1]);
  }
  return ;
}
  

 
int main() {
  ll N,Q;
  cin>>N>>Q;
  note=vector<bool> (N,false);
  ans=vector<ll> (N);
 vec= vector<vector<ll>> (N,vector<ll>(0));
  for(ll i=0;i<N-1;i++) {
ll A,B;
    cin>>A>>B;
    vec[A-1].push_back(B);
    vec[B-1].push_back(A);
  }
  
  p=vector<ll> (N,0);
  for(ll i=0;i<Q;i++) {
ll P,X;
    cin>>P>>X;
    p[P-1]+=X;
  }
  
  dfs(1,0);
 for(ll x:ans) {
cout<<x<<" ";
 }
  cout<<endl;
}
  
  
  
  
  
  
  
  
  

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

int main() {
  int N,X,a;
  cin >> N >> X;
vector<int>L(N),p(10001),c(10001);
  p[0]=1;
  a=0;
  for(int i=0;i<N;i++){
    cin>>L[i];
    a+=L[i];
    p[a]++;
  }
  c[0]=1;
  for(int i=1;i<10001;i++){
c[i]=c[i-1]+p[i];
  }
  cout << c[X] <<endl;
 
}


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

int main()
{
    int M,D,d1,d10,r=0;
    cin>>M>>D;
    for(int i=1;i<=D;i++){
        for(int j=1;j<=M;j++){
            d10=i/10;
            d1=i-d10*10;
            if(d1>=2&&d10>=2&&d1*d10==j){
                r++;
            }
        }
    }
    cout <<r<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=6009;int mod;
	inline int add(int x,int y){return x+y>=mod?x-mod+y:x+y;}
	int f[N][(N<<1)+3],n;
	int main(){
		n=read<int>()*3,mod=read<int>();
		f[0][N]=1;
		for(int i=0;i<n;i++)
			for(int j=-i;j<=i;j++){
				f[i+1][j+1+N]=add(f[i+1][j+1+N],f[i][j+N]);
				f[i+2][j-1+N]=add(f[i+2][j-1+N],1LL*f[i][j+N]*(i+1)%mod);
				f[i+3][j+N]=add(f[i+3][j+N],1LL*f[i][j+N]*(i+1)%mod*(i+2)%mod);
			}

		int ans=0;
		for(int j=0;j<=n;j++) ans=add(ans,f[n][j+N]);
		printf("%d\n",ans);
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 280320
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9 + 7, A = 1e3 + 2;
int n;
string s;
bool valid(int len) {
    int p2 = len;
    string t = s.substr(0, len);
    map<string, vector<int>> mop;
    mop[t].pb(p2);
    while(p2 < n) {
        t.erase(t.begin()), t.pb(s[p2++]);
        mop[t].pb(p2);
    }
    for (auto i : mop) {
        int mn = i.S[0], mx = i.S[0];
        for (auto j : i.S)
            mn = min(mn, j), mx = max(mx, j);
        if (mx - mn >= len)
            return 1;
    }
    return 0;
}
int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin >> n >> s;
    int ans = 0, low = 1, high = n / 2, mid;
    while(low <= high) {
        mid = (low + high) / 2;
        if (valid(mid))
            low = mid + 1, ans = mid;
        else
            high = mid - 1;
    }
    cout << ans;
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

bool check[100005];

void Main() {
    ll N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;
    string T;
    cin >> T;
    ll ans = 0;
    rep(i, N) {
        if (i - K >= 0 && T[i] == T[i-K] && check[i - K]) {
            check[i] = false;
        } else {
            if (T[i] == 'r') {
                ans += P;
                check[i] = true;
            } else if (T[i] == 's') {
                ans += R;
            } else {
               ans += S;
            }
            check[i] = true;
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 592
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
const int maxn=100005;
struct edge{
	int u,v,w;
};
vector<edge> E;
vector<int> g[maxn];
int s,t,n,deep[maxn]={0},r[maxn];
bool vis[maxn]={0};
void dfs(int u,int d){
	deep[u]=d;
	vis[u]=1;
	int size=g[u].size();
	for(int i=0;i<size;i++){
		edge e=E[g[u][i]];
		if(!vis[e.v])
			dfs(e.v,d+e.w);
	}
}
bool cmp(int a,int b){
	return deep[a]>deep[b];
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		r[i]=i;
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		E.push_back((edge){u,v,w});
		g[u].push_back(E.size()-1);
		E.push_back((edge){v,u,w});
		g[v].push_back(E.size()-1);
	}
	r[0]=0;
	dfs(0,0);
	sort(r,r+n,cmp);
	s=r[0];
	memset(vis,0,sizeof(vis));
	dfs(s,0);
	sort(r,r+n,cmp);
	t=r[0];
	printf("%d\n",deep[t]);
	return 0;
}

Measured memory_bytes: 16132
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <ctype.h>
typedef long long int ll;

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

int comp(const void* a, const void* b){
  return *(int*)a - *(int*)b;
}
ll gcd(ll x, ll y) {
  return y? gcd(y, x%y): x; 
}
int min(int a, int b) { return (a<b)? a: b; }
int max(int a, int b) { return (a>b)? a: b; }

int n, m, a, b, c, t, cst, ans;
int main(void){
  int key[2001], cost[2001], dp[5010];
  rep(i, 2001) {
    key[i] = 0;
    cost[i] = INF;
  }
  rep (i, 5010) {
    dp[i] = INF;
  }
  scanf("%d%d", &n, &m);
  rep(i, m) {
    scanf("%d%d", &a, &b);
    cost[i] = a;
    rep(j, b) {
      scanf("%d", &c);
      key[i] |= 1<<(--c);
    }
    // printf("DEBUG:%d, %x\n", cost[i], key[i]);
  }
  dp[0] = 0;
  rep(s, 1<<n) {
    t = 0;
    cst = 0;
    rep(i, m) {
      // printf("DEBUG:1<<n:%x, 1<<s:%x, i:%x, m:%d\n",1<<n, s, i, m);
      t = s | key[i];
      cst = dp[s] + cost[i];
      dp[t] = min(dp[t], cst);
      // printf("DEBUG:dp[t]:%d\n", dp[t]);
    }
  }
  ans = dp[(1<<n)-1]>=INF? -1: dp[(1<<n)-1];
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){

	long long n,m,ans=0,z=0;
	cin>>n>>m;
	vector<long long> a1,a2,b1,b2,c1,c2,sum;
	for(long long i=0;i<n;i++){
		long long a,b,c;
		cin>>a>>b>>c;
		a1.push_back(a);
		b1.push_back(b);
		c1.push_back(c);
		a2.push_back(-a);
		b2.push_back(-b);
		c2.push_back(-c);
		sum.push_back(0);
	}
	for(int i=0;i<2;i++){
		vector<long long> a;
		if(i)a=a2;
		else a=a1;
		for(int j=0;j<2;j++){
			vector<long long> b;
			if(j) b=b2;
			else b=b1;
			for(int k=0;k<2;k++){
				vector<long long>c;
				if(k)c=c2;
				else c=c1;
				for(int l=0;l<n;++l){
					sum[l]=a[l]+b[l]+c[l];
				}
				sort(sum.begin(),sum.end());
				z=0;
				for(int i=0;i<m;i++)z+=sum[n-1-i];
				ans=max(ans,z);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <queue>

using namespace std;

class node {
public:
    int size;
public:
    int number;
public:
    int child1, child2;
};

int main() {
    string s;
    cin >> s;
    map<char, int> m;
    for (int i = 0; i < s.size(); i++)m[s[i]]++;

    vector<node> tree;// node の集合体のこと
    priority_queue<vector<int>, vector<vector<int>>, greater<>> que;

    vector<pair<char, int>> v(m.begin(), m.end());

    for (int i = 0; i < v.size(); i++) { // 初期状態から全てのnodeを作成する
        node n;
        n.size = v[i].second;
        n.number = i;
        n.child1 = -1;
        n.child2 = -1;
        tree.push_back(n);

        vector<int> a(2);
        a[0] = n.size;
        a[1] = n.number;
        que.push(a);
    }

    int nextnum = v.size();

    while (true) {
        // 現時点で一番出現頻度の低い2つを出す
        vector<int> a = que.top();// aにはサイズと番号が入っている
        que.pop();
        if (que.empty())break;
        vector<int> b = que.top();// bにはサイズと番号が入っている
        que.pop();

        node n;//新しいノードのこと
        n.size = a[0] + b[0];// 新しいノードのサイズはもちろん aとbのサイズの和
        n.number = nextnum;// n.number = nextnumですがnextnumはv.size() + x 今まで使ってない番号を入れる
        nextnum++;//新しい番号を使う時のために加算しておく
        n.child1 = a[1];// 新しいノードを追加する際に、今までの子供のノードの番号を覚えておく
        n.child2 = b[1];// 新しいノードを追加する際に、今までの子供のノードの番号を覚えておく
        tree.push_back(n);// 木に新しいnode n を突っ込む

        vector<int> c(2);// cは新しい情報
        c[0] = n.size; // c には a+bのサイズが入る
        c[1] = n.number; // c にはnの番号が入る
        que.push(c);
    }

    long long ret = 0;
    queue<int> nodequeue;
    nodequeue.push(nextnum - 1);//一番最後にしたノードの番号を入れる
    nodequeue.push(-1);// 現時点では用途不明 下を見ると 深さを管理するためのフラグ的な使い方をしている ある点から左と右を見たあとに深さを加算している
    //幅優先的な感じをするために-1を使っている
    int depth = 0;
    while (true) {
        int nextnode = nodequeue.front();// 次に見るノードは一番上にあるやつ
        nodequeue.pop();// 一番上にあるやつを取り除く
        if (nextnode == -1) {
            if (nodequeue.empty())break;
            depth++;//深さを++する
            nodequeue.push(-1);
        } else {
            if (nextnode < v.size())//葉っぱだった場合
                ret += depth * v[nextnode].second;//出現回数に深さをかける やばいなこの実装天才か？
            if (tree[nextnode].child1 >= 0)
                nodequeue.push(tree[nextnode].child1);
            if (tree[nextnode].child2 >= 0)
                nodequeue.push(tree[nextnode].child2);
        }
    }

    if (ret == 0)ret += s.size();
    cout << ret << endl;
    return 0;
}



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

int main() {
    int n, m;
    cin >> n >> m;
    int k[n], a[n][30];
    for (int i = 0; i < n; i++) {
        int l;
        cin >> l;
        k[i] = l;
        for (int j = 0; j < l; j++)
            cin >> a[i][j];
    }
    vector<int> v(31, 0);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < k[i]; j++) {
            v[a[i][j]]++;
        }
    }
    int ans = 0;
    for (int i = 1; i <= 30; i++) {
        if (v[i] == n)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define INF 100000000


int main(){
	int table1[201]={};
	vector<int> table2;
	for(int i=1;i<201;i++){
		table1[i-1]=i*(i+1)*(i+2)/6;
		if(table1[i-1]%2!=0){
			table2.push_back(table1[i-1]);
		}
	}
	int count1[1000001];
	int count2[1000001];
	for(int i=0;i<1000001;i++){
		count1[i]=INF;
		count2[i]=INF;
	}
	count1[0]=0;
	count2[0]=0;
	count1[1]=1;
	count2[1]=1;
	for(int i=2;i<1000001;i++){
		for(int j=0;j<201;j++){
			if(table1[j]>i)break;
			count1[i] = min(count1[i],count1[i-table1[j]]+1);
		}
	}
	for(int i=2;i<1000001;i++){
		for(int j=0;j<201;j++){
			if(table2[j]>i)break;
			count2[i] = min(count2[i],count2[i-table2[j]]+1);
		}
	}
	int n;
	while(cin>>n&&n!=0){
		cout << count1[n] << " " << count2[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 10900
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))

x = l()

x.sort()

print(x[0]+x[1])



Measured memory_bytes: 38384
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
c = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [[-1, -1] for i in range(n+1)]
dp[0] = [0, 0]
for i in range(1, n+1):
    for ai in a:
        ci = c[ai]
        if i - ci >= 0 and dp[i-ci] != -1:
            if dp[i][0] < dp[i-ci][0] + 1:
                dp[i] = [dp[i-ci][0] + 1, ai]
i = n
ans = []
while i > 0:
    ai = dp[i][1]
    ans.append(ai)
    i -= c[ai]
ans.sort(reverse=True)
print("".join(map(str, ans)))


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	ll a, b, n; cin >> a >> b >> n;
	
	if (n >= b - 1) {
		cout << (a * (b - 1) / b) << endl;
	} else {
		cout << (a * n / b) << endl;
	}
}


Measured memory_bytes: 3640
n=int(input())
M=A=R=C=H=0
for i in range(n):
    s=input()
    if s[0]=="M":   M+=1
    elif s[0]=="A": A+=1
    elif s[0]=="R": R+=1
    elif s[0]=="C": C+=1
    elif s[0]=="H": H+=1
a=[M,A,R,C,H]
from itertools import combinations
ans=0
for L in list(combinations(a,3)):
    ans+=L[0]*L[1]*L[2]
print(ans)

Measured memory_bytes: 3064
#from math import sqrt
#from heapq import heappush, heappop
#from collections import deque

#a, b = [int(v) for v in input().split()]


def main():
    N = int(input())
    S = input()

    count = 0
    state = 0

    for c in S:
        if c == 'A':
            state = 1
        elif state == 1:
            if c == 'B':
                state = 2
            else:
                state = 0
        elif state == 2:
            if c == 'C':
                count += 1
            state = 0

    print(count)


main()


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();

        int n = scanner.nextInt();
        int i = 1;
        do {
            int x = i;
            if (x % 3 == 0) {
                sb.append(" ");
                sb.append(i);
            } else {
                while (true) {
                    if (x % 10 == 3) {
                        sb.append(" ");
                        sb.append(i);
                        break;
                    }else {
                        x /= 10;
                        if (x == 0) {
                            break;
                        }
                    }
                }
            }


        }while( ++i <= n );
        
        System.out.println(sb.toString());

    }


}


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

using namespace std;

bool goodh[110], goodw[110];

int main() {
	string board[110];
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> board[i];
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (board[i][j] == '#') {
				goodh[i] = true;
				goodw[j] = true;
			}
		}
	}
	// cout << "----------------------" << endl;
	for (int i = 0; i < H; i++) {
		if (goodh[i]) {
			for (int j = 0; j < W; j++) {
				if (goodw[j]) {
					cout << board[i][j];
				}
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for(int i=0; i<n; i++)
#define reps(i,s,n) for(int i=s; i<n; i++)

using namespace std;

bool is_ac(string s) {
    if (s[0] != 'A') return false;

    int Cs = 0;
    reps(i, 2, s.size()-1) {
        Cs += s[i] == 'C';
    }
    if (Cs != 1) return false;

    reps(i, 1, s.size()) {
        if ('a' <= s[i] and s[i] <= 'z');
        else if(s[i] == 'C');
        else return false;
    }
    return true;
}

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

    if (is_ac(s)) cout << "AC" << endl;
    else cout << "WA" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
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(){
    ll n;
    cin >> n;
    vll a(n+1), b(n+1);
    REP(i, n+1){
        cin >> a[i] >> b[i];
    }
    Sort(a);
    Sort(b);
    ll ans = 0;
    if(n%2 == 1){
        ans = b[(n+1)/2] - a[(n+1)/2];
    }
    else {
        ans = (b[(n+1)/2] + b[(n+1)/2+1]);
        ans -= (a[(n+1)/2] + a[(n+1)/2+1]);
    }
    cout << ++ans << endl;
    return 0;
}


Measured memory_bytes: 6436
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;


vector<ll> a;

int main(){
    int n;
    cin >> n;
    rep(i, n){
        ll tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

    sort(a.begin(), a.end(), greater<ll>());

    ll ans1 = 0;
    ll ans2 = 0;


    if (n%2 != 0){
        int m = n - 2;
        int l = (m + 1) / 2;
        int p = m - l;

        rep(i, n) {
            if (i < l) ans1 += 2 * a[i];
            else if (i < l + 2) ans1 -= a[i];
            else ans1 -= 2 * a[i];
        }
        rep(i, n) {
            if (i < p) ans2 += 2 * a[i];
            else if (i < p + 2) ans2 += a[i];
            else ans2 -= 2 * a[i];
        }
    }
    else {
        int m = n - 2;
        int l = m / 2;
        rep(i, n) {
            if (i < l) ans1 += 2 * a[i];
            else if (i < l + 1) ans1 += a[i];
            else if (i < l + 2) ans1 -= a[i];
            else ans1 -= 2 * a[i];
        }
    }

    cout << max(ans1, ans2) << endl;

    return 0;
}

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

const int N = 1e5;
const int lgn = 17;

int n,q,L;
int li[N+5];

int sparse[lgn+1][N+5];

void make_sparse(){
	for(int i=1;i<=lgn;i++){
		for(int j=1;j<=N;j++){
			sparse[i][j] = sparse[i-1][sparse[i-1][j]];
		}
	}
	return;
}

int find_day(int x, int y){
	int ret = 0;
	for(int i=lgn;i>=0;i--){
		if(sparse[i][x]<y){
			ret+=(1<<i);
			x = sparse[i][x];
		}
	}
	return ret+1;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&li[i]);
	}
	scanf("%d",&L);
	scanf("%d",&q);
	int r = 1;
	for(int i=1;i<=n;i++){
		while(r <= n && li[r] - li[i] <= L) r++;
		sparse[0][i] = r-1;
	}
	make_sparse();
	for(int i=1;i<=q;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		if(u>v) swap(u,v);
		int ans = find_day(u,v);
		printf("%d\n",ans);
	}
	return 0;
}

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

char tolower(char ch){
  if( 'A' <= ch && ch <='Z' ){
    return ch-'A'+'a';
  }else{
    return ch;
  }
}

int main(){
  int count=0;
  string W;
  cin>>W;
  string str;
  while(1){
    cin>>str;
    if(str=="END_OF_TEXT")break;
    for(int i=0;i<(int)str.size();i++){
      str[i]=tolower(str[i]);
    }
    if(str==W){
      count++;
    }
  }
  cout<<count<<endl;
  return 0;
}
			



Measured memory_bytes: 3224
X,Y = map(int,input().split())

ans = 0
m1 = 300000
m2 = 200000
m3 = 100000
for i in [X,Y]:
  if i == 1:
    ans += m1
  elif i == 2:
    ans += m2
  elif i == 3:
    ans += m3

if X==1 and Y == 1:
  ans += 400000

print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<string>
 
using namespace std;
 
class compute
{
private:
        vector<int> sum;
        int carry, temp;
        void Init();
public:
        void calc(string s1, string s2);
};
 
void compute::Init()
{ sum.clear(); }
 
void compute::calc(string s1, string s2)
{
        Init();
        int a = s1.size();
        int b = s2.size();
 
        if(a > 80 || b > 80){ cout << "overflow" << endl; return; }
        
        a--; b--;
        carry = 0;
        
        while(a >= 0 || b >= 0){
                temp = 0;
                if(a >= 0){ temp += (s1[a]-'0'); }
                if(b >= 0){ temp += (s2[b]-'0'); }
                sum.push_back((temp+carry)%10);
                carry = (temp+carry)/10;
                a--; b--;
        }
        if(carry){ sum.push_back(carry); }
        if(sum.size() > 80){ cout << "overflow" << endl; return; }
        for(int i = sum.size()-1; i >= 0 ; i--){
                cout << sum[i]; 
        }
        cout << endl;
}
 
int main(void)
{
 
        int n;
        string s1, s2;
        compute s;
        
        cin >> n;
        
        while(n-->0){
                cin >> s1 >> s2;
                s.calc(s1, s2);
        }
 
        return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<map>
#include<cmath>
#include<iomanip>
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;

#define INF 1e20
#define min_3(a, b, c) min(a, min(b, c));
typedef long long ll;

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

  double ans = 0;
  double points;
  for (int i = 1; i <= n; i++)
  {
    points = i;
    double tmp = 1.0 / n;
    while(points < k){
      points *= 2;
      tmp /= 2;
    }

    ans += tmp;
  }
  
  cout << setprecision(12) << ans << endl;
}


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

using namespace std;

int main() {
	int n, x, l[100];
	cin >> n >> x;
	for (int i = 0; i < n; i++)
	{
		cin >> l[i];
	}

	int p = 0;
	int ans = 1;
	for (int i = 0; i < n; i++)
	{
		p += l[i];
		if (p <= x)ans++;
		else break;
	}

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

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import *
from math import gcd

N = int(input())
cnt = defaultdict(int)
abzero = 0
azero = 0
bzero = 0

for _ in range(N):
    A, B = map(int, input().split())
    
    if A==0 and B==0:
        abzero += 1
        continue
    elif A==0:
        azero += 1
        continue
    elif B==0:
        bzero += 1
        continue
        
    G = gcd(abs(A), abs(B))
    A //= G
    B //= G
    
    if (A<0 and B>0) or (A<0 and B<0):
        A *= -1
        B *= -1
    
    cnt[(A, B)] += 1

ans = 1
MOD = 10**9+7
visited = set()

for k in cnt.keys():
    if k in visited:
        continue
    
    if k[0]>0 and k[1]>0:
        k2 = (k[1], -k[0])
    else:
        k2 = (-k[1], k[0])
    
    if k2 not in cnt:
        ans *= pow(2, cnt[k], MOD)
        ans %= MOD
    else:
        ans *= pow(2, cnt[k], MOD)+pow(2, cnt[k2], MOD)-1
        ans %= MOD
        visited.add(k2)

ans *= pow(2, azero, MOD)+pow(2, bzero, MOD)-1
ans %= MOD
ans += abzero-1
ans %= MOD
print(ans)


Measured memory_bytes: 112564
#include<iostream>
#define MAX_BALL 10
using namespace std;

int ball[MAX_BALL];
int n;
int r = 0, l = 0;
bool flag = 0;

void dfs(int x)
{
	if (x == MAX_BALL)
	{
		flag = true;
		return;
	}
	if (ball[x] >= r)
	{
		r = ball[x];
		dfs(x + 1);
	}
	if (ball[x] >= l)
	{
		l = ball[x];
		dfs(x + 1);
	}
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		flag = false;
		r = 0;
		l = 0;
		for (int j = 0; j < MAX_BALL; j++)
			cin >> ball[j];
		dfs(0);
		if (flag)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

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

public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn = null;
		int[][] map = new int[14][14];
		int max = 0;
		int count = 100;
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			while( stdIn.hasNext() ){
				String str = stdIn.next();
				String[] p = new String[3];
				p = str.split(",");
				int[] s = new int[3];
				for(int i = 0; i < 3; i++){
					s[i] = Integer.parseInt(p[i]);
				}
				
				if( s[2] == 1 ){
					map[s[0]+2][s[1]+2]++; map[s[0]+3][s[1]+2]++; map[s[0]+1][s[1]+2]++;
					map[s[0]+2][s[1]+3]++; map[s[0]+2][s[1]+1]++;
				} else if( s[2] == 2 ){
					map[s[0]+2][s[1]+2]++; map[s[0]+1][s[1]+1]++; map[s[0]+2][s[1]+1]++;
					map[s[0]+3][s[1]+1]++; map[s[0]+1][s[1]+2]++; map[s[0]+3][s[1]+2]++;
					map[s[0]+1][s[1]+3]++; map[s[0]+2][s[1]+3]++; map[s[0]+3][s[1]+3]++;
				} else if( s[2] == 3 ){
					map[s[0]+2][s[1]+2]++; map[s[0]+1][s[1]+1]++; map[s[0]+2][s[1]+1]++;
					map[s[0]+3][s[1]+1]++; map[s[0]+1][s[1]+2]++; map[s[0]+3][s[1]+2]++;
					map[s[0]+1][s[1]+3]++; map[s[0]+2][s[1]+3]++; map[s[0]+3][s[1]+3]++;
					map[s[0]][s[1]+2]++; map[s[0]+4][s[1]+2]++; map[s[0]+2][s[1]]++;
					map[s[0]+2][s[1]+4]++;
				}
			}
			
			for(int i = 2; i < 12; i++){
				for(int j = 2; j < 12; j++){
					if( map[i][j] != 0 ){
						count--;
						if( map[i][j] > max ){
							max = map[i][j];
						}
					}
				}
			}
			
			System.out.println(count);
			System.out.println(max);	
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

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

class Point{
    public:
    double x, y, z;
    Point( double x = 0, double y = 0, double z = 0):x(x), y(y),z(z){}
};

double getDist( Point p1, Point p2 ){
    return sqrt( (p1.x-p2.x)*(p1.x-p2.x) +  (p1.y-p2.y)*(p1.y-p2.y) + (p1.z-p2.z)*(p1.z-p2.z));
}

bool eq( double a, double b ){
    return fabs(a-b) < 0.0000001;
}

void compute(){
    Point P[100];
    double QR, RP, PQ, x, y, z;
    cin >> QR >> RP >> PQ;
    int n; cin >> n;
    for ( int i = 0; i < n; i++ ){
	cin >> x >> y >> z;
	P[i] = Point(x, y, z);
    }

    bool finished = false;
    for ( int p = 0; p < n; p++ ){
	for ( int q = 0; q < n; q++ ){
	    for ( int r = 0; r < n; r++ ){
		if ( p == q || p == r || q == r ) continue;
		double rate = PQ/getDist(P[p], P[q]);
		if ( !eq(rate, RP/getDist(P[r], P[p]))) continue;
		if ( !eq(rate, QR/getDist(P[q], P[r]))) continue;
		if ( finished ) continue;
		cout << p+1 << " " << q+1 << " " << r+1 << endl;
		finished = true;
	    }
	}
    }

    
}

main(){
    int tcase; cin >> tcase;
    for ( int i = 0; i < tcase; i++ ) compute();
}

Measured memory_bytes: 0
#include <iostream>
#include <map>
#include <vector>

using namespace std;


long long combination_2(long long k) {
    return (k*(k-1))/2;
}


    int main() {
    int n; cin >> n;
    vector<long long> a(n);
    for (long long i = 0; i < n; i++) cin >> a[i];

    map<long long, long long> counter;
    for (long long a_i : a) {
        if (counter.find(a_i) == counter.end()) counter[a_i] = 1;
        else counter[a_i]++;
    }

    long long ans = 0;
    for (pair<long long, long long> count: counter) ans += combination_2(count.second);
    for (long long k=0; k < n; k++) cout << ans - (counter[a[k]]-1) << endl;
    return 0;
}


Measured memory_bytes: 11904
import numpy as np
import numba as nb


@nb.njit('(i1[:],)', cache=True)
def solve(s):
    n = len(s)
    size = n // 2
    MOD = 998244353
    dp_can = np.zeros((n + 1, size + 1, size + 1), dtype=np.int8)
    dp_cnt = np.zeros((n + 1, size + 1, size + 1), dtype=np.int64)

    dp_cnt[n, 0] = 1
    for j in range(size):
        dp_cnt[n, j + 1] = np.cumsum(dp_cnt[n, j]) % MOD

    for i in range(n - 1, -1, -1):
        if s[i] == 0:
            for j in range(size + 1):
                dp_cnt[i, j] = np.cumsum(dp_cnt[i + 1, j]) % MOD
        else:
            for k in range(size + 1):
                dp_cnt[i, :, k] = np.cumsum(dp_cnt[i + 1, :, k]) % MOD

    dp_can[0, 0, 0] = 1
    for i in range(n):
        for j in range(size):
            for k in range(size):
                if dp_can[i, j, k] == 0:
                    continue
                dp_can[i + 1, j, k] = 1
                if j > 0 and s[i] == 1:
                    dp_can[i + 1, j - 1, k + 1] = 1
                if k > 0 and s[i] == 0:
                    dp_can[i + 1, j + 1, k - 1] = 1
                if i < n - 1:
                    if s[i] == 0 or s[i + 1] == 0:
                        dp_can[i + 2, j + 1, k] = 1
                    if s[i] == 1 or s[i + 1] == 1:
                        dp_can[i + 2, j, k + 1] = 1
    dp_can[1:, 0, 0] = 0

    ans = 0

    for i in range(n, -1, -1):
        for j in range(size + 1):
            for k in range(size + 1):
                if dp_can[i, j, k] == 0:
                    continue

                ans = (ans + dp_cnt[i, j, k]) % MOD

                a, b = j, k
                for h in range(i - 1, -1, -1):
                    if s[h] == 0:
                        a -= 1
                    else:
                        b -= 1
                    if a < 0 or b < 0:
                        break
                    dp_can[h, a, b] = 0

    return ans


s = np.array([int(c) for c in input()], dtype=np.int8)
print(solve(s))


Measured memory_bytes: 167480
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	bucket := make([]int, 26)
	for _, i := range s {
		bucket[i-97]++
	}

	for i, v := range bucket {
		if v == 0 {
			fmt.Printf(string(i + 97))
			return
		}
	}
	fmt.Println("None")
}


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

bool min(int a, int b, int c){
    return (a > b && b > c) || (a < b && b < c);
}

int main(){
    int n;
    int count=0;
    cin >> n;
    int p[20];
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    for(int i = 0; i < n - 2; i++){
        if(min(p[i], p[i + 1], p[i + 2]))count++;
    }
    cout << count << endl;
    return 0;
}

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

int main() {
	int n;
	char ch;
	std::string str1, str2;
	std::cin >> str1>>str2;

	for (int i = 0; i<str1.size(); i++) {
		if (str1 == str2) {
			std::cout <<"Yes"<< std::endl;
			exit(0);
		}

		n = str1.size() - 1;
		
		ch = str1[n];

		for (int j = 0; j<n; j++) {
			str1[n - j] = str1[n - 1 - j];
		}

		str1[0] = ch;

		//std::cout << str1 << std::endl;
	}




	std::cout<<"No"<<std::endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  while (N>=10){
    N -=10;
  }
  if(N == 3){
    cout << "bon" << endl;
  }
  else if (N == 0){
    cout << "pon" << endl;
  }
  else if (N == 1){
    cout << "pon" << endl;
  }
  else if (N == 6){
    cout << "pon" << endl;
  }
  else if (N == 8){
    cout << "pon" << endl;
  }
  else cout << "hon" << endl;
}

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

#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#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 mpr 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(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const ll INF = 1e18; 
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 abst(ll a)
{
 return ((a<0)?(-1*a):(a));
}

int main()
{
   int n;
   int f=1;
   cin>>n;
   map<int,int> mp;
   for(int i=0;i<n;i++)
   {
       int x;
       cin>>x;
       mp[x]++;
       if(mp[x]>1)
        f=0;
   }
   if(f)
    cout<<"YES\n";
    else
     cout<<"NO\n";
    return 0;
}

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

#define MAX_H 301
int H, W;
char c[MAX_H][MAX_H];
int cost[MAX_H][MAX_H] = {0};
int dp[MAX_H][MAX_H] = {0};

void solve(){
    int total_cost = 0;
    for(int k = 1; k < W; k++){
        for(int i = 1; i <= H; i++){
            for(int j = 1; j <= H; j++){
                cost[i][j] = cost[i - 1][j - 1] + (c[i][k] == c[j][k + 1]);
                dp[i][j] = min(dp[i][j - 1], dp[i - 1][j]) + cost[i][j];
            }
        }
        total_cost += dp[H][H];
    }
    cout << total_cost << endl;
    return ;
}


int main(){
    cin >> H >> W;
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            cin >> c[i][j];
        }
    }
    
    solve();
    return 0;
}

Measured memory_bytes: 1152