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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	ll h, w;
	cin >> h >> w;
	
	ll ans = min(h,w);
	if(h % 3 == 0 || w % 3 == 0)
	{
		ans = 0;
		cout << ans << endl;
		return 0;
	}
	// ソレ以外の時、縦、横の区切りを一本ずつ入れる。
	rep(i,2){
		for(ll tate = 1; tate < h; tate++){
			ll one = tate * w;

			//残りの(h-tate)*wを2等分することを目指す。
			// 1~w-1のどこかに区切りを入れる。
			ll two, three;
			if(w % 2 == 0){
				// 残りは2等分できる。
				two = three = (h-tate) * (w/2);
				if(chmax(three,one)){
					one = two;
				}
			} else {
				// 残りは、1列分だけ差が出る
				two = (h - tate) * (w/2);
				three = (h - tate) * ((w+1)/2);
				if(two < one){
					three = max(one,three);
					one = two;
				}
			}
			chmin(ans,three-one);
		}
		swap(h,w);
	}
	cout << ans << endl;
}


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

using namespace std;
int N,T,c,t,j=0;
vector<int> vec;

int main() {
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		cin >> c >> t;
		if (t > T) { j++; }
		else {
			vec.push_back(c);
		}
	}
	if (j == N) {
		cout << "TLE" << '\n';
		return 0;
	}
	sort(vec.begin(), vec.end());

	cout << vec[0] << '\n';
	return 0;
}

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

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

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

using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 M = 0;

	cin >> N;
	cin >> M;

	SINT32 ANS = 0;
	
	if (N> M) {
		ANS = N;
		N--;
	} else {
		ANS = M;
		M--;
	}

	if (N> M) {
		ANS = ANS + N;
		N--;
	} else {
		ANS = ANS + M;
		M--;
	}

	cout << ANS << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();

Measured memory_bytes: 256
N = int(input())
S = input()

ans = S.count('R')*S.count('G')*S.count('B')

for i in range(N-2):
    for j in range(i+1,N-1):
        k = j-i + j
        if k < N and S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            ans -= 1

print(ans)

Measured memory_bytes: 9204
#include <iostream>
#include <cmath>

using namespace std;

const int D = 200, N = 200;

int temp[D];
int mint[N], maxt[N], c[N];
int a[D][N] = { { 0 } };

int main(){
	int d, n, r = 0;
	cin >> d >> n;
	for(int i = 0;i < d;++i){
		cin >> temp[i];
	}
	for(int i = 0;i < n;++i){
		cin >> mint[i] >> maxt[i] >> c[i];
	}
	for(int i = 1;i < d;++i){
		for(int j = 0;j < n;++j){
			if(mint[j] <= temp[i] && temp[i] <= maxt[j]){
				for(int k = 0; k < n;++k){
					if(mint[k] <= temp[i - 1] && temp[i - 1] <= maxt[k]){
						a[i][j] = max(a[i][j], a[i - 1][k] + abs(c[k] - c[j]));
					}
				}
			}
		}
	}
	for(int i = 0;i < n;++i){
		r = max(r, a[d - 1][i]);
	}
	cout << r << endl;
	return 0;
}



Measured memory_bytes: 3252
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

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

    int t=111;
    rep2(i,1,10)
    {
        if(n<=t*i)
        {
            cout<<t*i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
import java.util.*;
class Main{

	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int n=sc.nextInt();
		int x=sc.nextInt();
		int t=sc.nextInt();
		int time=n/x;
		if(n%x!=0) time++;
		int ans=time*t;
		System.out.println(ans);

	}

}


Measured memory_bytes: 35664
import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)

N = int(input())
S = input()

rgb = [0,0,0]
for i in range(N):
    if S[i] == 'R':
        rgb[0] += 1
    elif S[i] == 'G':
        rgb[1] += 1
    else:
        rgb[2] += 1

ans = rgb[0] * rgb[1] * rgb [2]
#print(ans)

for i in range(N):
    for j in range(1,(N-i+1)//2):
        if S[i] != S[i+j] and S[i] != S[i+2*j] and S[i+j] != S[i+2*j]:
            ans -= 1
#        print(ans,i,i+j,i+2*j)
print(ans)
            

Measured memory_bytes: 27144
#include <stdio.h>

int main() {
  int n,a[1000001],g[20],i,j,k,cnt=0;
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d",&a[i]);
  int m=0,x=1;
  for(i=0; x<=n; i++) {
    g[i]=x;
    x=x*3+1;
    m++;
  }
  for(k=m-1; k>=0; k--) {
    for(i=g[k]; i<n; i++) {
      int v=a[i];
      j=i-g[k];
      while(j>=0 && a[j]>v) {
	a[j+g[k]]=a[j];
	j=j-g[k];
	cnt++;
      }
      a[j+g[k]]=v;
    }
  }
  printf("%d\n",m);
  for(i=m-1; i>=0; i--) {
    printf("%d",g[i]);
    if(i) printf(" ");
  }
  printf("\n%d\n",cnt);
  for(i=0; i<n; i++) printf("%d\n",a[i]);
  return 0;
}


Measured memory_bytes: 4508
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.c
 * Author: kundaikwangwari
 *
 * Created on June 30, 2019, 8:32 PM
 */

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>

#define L 14
#define M 1500047 /* your task*/ //how big should my hash table be

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  //printf("sum is %lld\n",sum);
  return sum;
}

int h1(int key){ 
    int value = key % M;
    return value;
}

int h2(int key){ 
    int value = 1 + (key% (M-1));
    return value; }

int find(char str[]){

    long long k = getKey(str);
    for(int i = 0; ;i++){
        long long key = (h1(k) + i*h2(k))%M;
        if(H[key][0] == '\0')return 0; //the search failed
        if(strcmp(H[key],str) == 0)return 1;
        //break statement or condition
    //insert str into hash table
    //H[key][str];
    /* your task */
    }
}

int insert(char str[]){

    long long k = getKey(str);
    for(int i = 0; ;i++){
        long long key = (h1(k) + i*h2(k))%M;
        if(H[key][0] == '\0'){
            //printf("key is %lld\n",key);
            strcpy(H[key],str);
            return 1;
    } 
        //break statement or condition
    //insert str into hash table
    //H[key][str];
    /* your task */
    }
    
}
/*
 * 
 */
int main(int argc, char** argv) {

    
    
    int n, h;
    char str[L], com[9];
    for (int i = 0;i < M; i++)H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 22300
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    (a+b>c+d) ? puts("Left") :
        (a+b==c+d) ? puts("Balanced") : puts("Right");
    return 0;
}

Measured memory_bytes: 256
def solve():
    N = input()
    T,A = map(int, input().split())
    temperature = lambda x: T-0.006*x
    H = list(map(int, input().split()))
    diff_h = abs(A-temperature(H[0]))
    ret = 0
    for i,h in enumerate(H):
        if abs(A-temperature(H[i])) <= diff_h:
            diff_h = abs(A-temperature(H[i]))
            ret = i
            
    print(ret+1)
    
solve()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>

using namespace std;

string Permute(const string &src_str){
  int foundpos=0;
  string dst_str=src_str;
  while((foundpos=dst_str.find("Hoshino"))!=string::npos)
    dst_str[foundpos+6]='a';
  return dst_str;
}

int main(){
  int n;
  cin>>n;
  vector<string> dataset(n);
  cin.get();
  for(int i=0;i<n;i++){
    getline(cin,dataset[i]);
  }
  for(int i=0;i<n;i++)
    cout<<Permute(dataset[i])<<endl;

}

Measured memory_bytes: 1220
import java.util.*;
 public class Main
{ public static void main(String args[])
    { Scanner sc=new Scanner(System.in);
       String s=sc.next();int f=0;
       s=s.toUpperCase();
       for(int i=0;i<2;i++)
       { char ch=s.charAt(i);
          if(ch=='A')
          { if(s.charAt(i+1)=='B')
             {  f=1;break;}
              
            }
            else
            { if(s.charAt(i+1)=='A')
                { f=1;
                    break;
                }
            }
        }
        if(f==1)
        System.out.println("Yes");
        else
        System.out.println("No");
    }
}

Measured memory_bytes: 21460
#include<cstdio>
using namespace std;
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);if(a%2||b%2||c%2) {printf("0\n");return 0;}
	for(int i=1;;++i) {
		int x=a,y=b,z=c;
		a=y+z>>1,b=x+z>>1,c=x+y>>1;
		if(a%2||b%2||c%2) {printf("%d\n",i);return 0;}
		else if(a==b&&b==c) break;
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 128
import itertools
import numpy as np
 
N, M, X = map(int, input().split())
c_list = []
for _ in range(N):
  c_list.append(list(map(int, input().split())))
  
cand = []
e_list = [i for i in range(N)]
for n in range(1, N+1):
  for e in itertools.combinations(e_list, n):
    sum_list = np.zeros(M)
    sum_maney = 0
    for i in set(e):
      sum_list += np.array(c_list[i][1:])
      sum_maney += c_list[i][0]
    flag = True
    for m in range(M):
      if not sum_list[m] >= X:
        flag = False
    if flag:
      cand.append(sum_maney)
if cand == []:
  print(-1)
else:
  print(min(cand))

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

int main(){
  vector<int> A(3);
  for( int i= 0; i < 3; i ++ ){
    cin >> A.at(i);
  }
  
  sort(A.begin(), A.end());
  
  cout << A.at(0) + A.at(1) << endl;
}
  

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int N = int.Parse(ReadLine());
            int BほにゃA = 0;int BほにゃnotA = 0;int notBほにゃA = 0;
            int ans = 0;
            for (int i = 0; i < N; i++)
            {
                string s = ReadLine();

                if (s.StartsWith("B")&&s.EndsWith("A"))
                {
                    BほにゃA++;
                }
                if (s.StartsWith("B")&& !s.EndsWith("A"))
                {
                    BほにゃnotA++;
                }
                if (!s.StartsWith("B") && s.EndsWith("A"))
                {
                    notBほにゃA++;
                }
                
                for (int j = 0; j < s.Length-1; j++)
                {
                    if (s.Substring(j,2) == "AB")
                    {
                        ans++;
                    }
                }
            }
            if (BほにゃA == 0)
            {
                WriteLine(ans + Min(BほにゃnotA, notBほにゃA));
            }
            else if (BほにゃnotA + notBほにゃA == 0)
            {
                WriteLine(ans + BほにゃA - 1);
            }
            else
            {
                WriteLine(ans + BほにゃA + Min(BほにゃnotA, notBほにゃA));
            }
        }
    }
}


Measured memory_bytes: 13408
import math
A, B, H, M = map(int, input().split())
H *= 5
deg =abs(H+(M/12)-M)*6
deg = min(360-deg, deg)
if deg==0:
    print(abs(B-A))
    exit()
elif deg==180:
    print(A+B)
    exit()
else:
    cos = math.cos(math.radians(deg))
    print(((A**2)+(B**2)-2*A*B*cos)**0.5)


Measured memory_bytes: 9524
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

struct UnionFind {
    int N;
    vector<int> parents;

    UnionFind(int _N) : N(_N){
        parents.assign(N,-1);
    }

    int find(int x) { //xの親を返す
        if (parents[x] < 0) return x;
        return parents[x] = find(parents[x]);
    }
    
    void unite(int x, int y) {  //xとyの含むグループを併合
        int px = find(x);
        int py = find(y);
        if (parents[px] > parents[py]) swap(px,py); 
        if (px != py) {
            parents[px] += parents[py];
            parents[py] = px;
        }     
    }

    bool same(int x, int y) { //x,yが同じグループにいるか判定
        return find(x) == find(y);
    }

    int size(int x) { //xと同じグループのメンバーの個数
        return -parents[find(x)];
    }
    
    vector<int> root() {//ufの根を列挙
        vector<int> res;
        for (int i = 0; i < N; i ++) {
            if (parents[i] < 0) res.push_back(i);
        }
        return res;
    }

    int group_count() { //ufのグループの数を数える
        int cnt = 0;
        for (int i = 0; i < N; i ++) {
            if (parents[i] < 0) cnt ++;
        }
        return cnt;
    }
};

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

    int N,M; cin >> N >> M;
    UnionFind uf(N);
    rep(i,M) {
        int a,b;cin >> a >> b;
        --a; --b;
        uf.unite(a,b);
    }
    int ans = 0;
    rep(i,N) ans = max(ans,uf.size(i));
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3984
#include <iostream>
#include <cstring>

using namespace std;

const int Q=100007;

char v[Q];

int n;

int main()
{
	//freopen("data.in", "r", stdin);

	cin>>v+1;

	n=strlen(v+1);

	int st=1;
	int dr=n;

	int ps,pd;

	int rez=0;

	while(st<dr)
	{
		//cerr<<st<<" "<<dr<<"\n";
		ps=0;
		pd=0;
		while(v[st]=='x')
		{
			st++;
			ps++;
		}
		while(v[dr]=='x')
		{
			dr--;
			pd++;
		}

		if(v[st]!=v[dr])
		{
			cout<<"-1\n";
			return 0;
		}
		else
		{
			if(ps>pd)
				rez+=ps-pd;
			else
				rez+=pd-ps;
		}

		st++;
		dr--;

	}

	cout<<rez<<"\n";

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
long long h,w,ans=1e9,a,b,c;
int main(){
    cin>>h>>w;
    for(int i=0;i<2;i++){
        if(i){
            long long t=h;
            h=w;
            w=t;
        }
        for(int i=1;i<h;i++){
            a=i*w;
            b=max((h-i)*(w/2),((h-i)/2)*w);
            c=h*w-a-b;
            ans=min(max(a,max(b,c))-min(a,min(b,c)),ans);
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, sum;
lli a[301][301];
bool b[301][301];
int main() {
  cin >> n;
  sum = 0;
  for (lli j=0; j<n; ++j) {
    for (lli i=0; i<n; ++i) {
      cin >> a[i][j];
      sum += a[i][j];
    }
  }
  sum /= 2;
  for (lli j=0; j<n; ++j) fill(begin(b[j]), end(b[j]), false);

  for (lli k=0; k<n; ++k) {
    for (lli j=0; j<n; ++j) {
      if (k==j) continue;
      for (lli i=j+1; i<n; ++i) {
        if (k==i) continue;
        lli c = a[i][j], d = a[i][k] + a[k][j];
        if (c > d) { cout << -1 << endl; return 0; }
        if (c == d && !b[i][j]) {
          sum -= c;
          b[i][j] = true;
        }
      }
    }
  }
  cout << sum << endl;
  return 0;
}



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

# C - XYZ Triplets
def calc(x, y, z):
	return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x


N = int(input())
ans = [0] * (N + 1)

for x in range(1, 100):
	for y in range(1, 100):
		for z in range(1, 100):
			i = calc(x, y, z)
			
			if i > N:
				break
			else:
				ans[i] += 1

for i in range(1, N + 1):
	print(ans[i])

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

int n;
int A[2000];

int devide(int i,int m){
    if(m==0)return 1;
    if(i>=n)return 0;
    int res=devide(i+1,m)||devide(i+1,m-A[i]);
    return res;
}

int main(void){
    int k,m;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    scanf("%d",&k);
    for(int i=0;i<k;i++){
        scanf("%d",&m);
        if(devide(0,m))printf("yes\n");
        else printf("no\n");
    }
    return 0;
}



Measured memory_bytes: 3164
#include <iostream>
#include <vector>
//#include <algorightm>
#include <map>
#include <tuple>
//#include <cstudio>

int main() {
    int N,K;
    std::cin >> N >> K ;
    int x = 1;
    while (N > 0){
        if(2 * x > x + K) x+=K;
        else x*=2;
        --N;
    }
    std::cout << x << std::endl;
}


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

int n,q;
int a[30][1000005];

char s[500005];

int lowbit(int n)
{
	return n&(-n);
}

int get(char x)
{
	return x-'a'+1;
}

inline void change(int num,int rt,int plus)
{
	while (rt<=n)
	{
		a[num][rt]+=plus;
		rt+=lowbit(rt);
	}
}

inline int get_sum(int num,int r)
{
	int sumv=0;
	while (r>=1)
	{
		sumv+=a[num][r];
		r-=lowbit(r);
	}
	return sumv;
}

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>s[i];
		change(get(s[i]),i,1);
	}
	cin>>q;
	
	while (q--)
	{
		int flag,t1,t2;
		cin>>flag;
		
		if (flag==1)
		{
			char x;
			cin>>t1>>x;
			change(get(s[t1]),t1,-1);
			change(get(x),t1,1);
			s[t1]=x;
		}
		else if (flag==2)
		{
			int tot=0;
			
			cin>>t1>>t2;
			for (int i=1;i<=26;i++)
			{
				if (get_sum(i,t2)-get_sum(i,t1-1))  tot++;
			}
			cout<<tot<<endl;
		}
	}
	return 0;
}

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

int main() 
{
	int n;
	vector<int> x;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		x.push_back(t);
	}
	double ave = 0;
	for (int i = 0; i < n; i++) {
		ave += x[i];
	}
	ave /= n;
	int p = round(ave);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += pow(x[i] - p, 2);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
from collections import Counter

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = np.array(list(input()))

i = 0
minus = 0
for i in np.arange(K):
    arr = T[np.arange(i, N, K)]
    c = 1
    for j in np.arange(arr.shape[0] - 1):
        if arr[j] == arr[j + 1]:
            c += 1
        else:
            if c >= 2:
                if arr[j] == 'r':
                    score = P
                elif arr[j] == 's':
                    score = R
                else:
                    score = S
                minus += c // 2 * score
            c = 1
    else:
        if c >= 2:
            if arr[j] == 'r':
                score = P
            elif arr[j] == 's':
                score = R
            else:
                score = S
            minus += c // 2 * score

counter = Counter(T)


max_score = 0
for i, j in counter.items():
    if i == 'r':
        max_score += P * j
    elif i == 's':
        max_score += R * j
    else:
        max_score += S * j
print(max_score - minus)


Measured memory_bytes: 21512
import math

X, Y = map(int, input().split())

a = X / 0.08
b = Y / 0.1

ans = min(a, b)

while math.floor(ans * 0.08) != X or math.floor(ans * 0.1) != Y:
	ans += 1
	if math.floor(ans * 0.08) > a or math.floor(ans * 0.1) > b:
		ans = -1
		break

print(int(ans))

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;
typedef unordered_map<int,int> uoii;
typedef unordered_map<string,int> uosi;

const int MOD = 1e9+7;

const int INF = 1e10;




int32_t main()
{
    IOS
    int a[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>a[i][j];
        }
    }
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if(x==a[i][j])
                    a[i][j]=-1;
            }
        }
    }
    
    bool ans=false;
    for(int i=0;i<3;i++){
        int t=0;
        for(int j=0;j<3;j++){
            if(a[i][j]==-1){
                t++;
            }
        }
        if(t==3)
            ans=true;
    }
    for(int i=0;i<3;i++){
        int t=0;
        for(int j=0;j<3;j++){
            if(a[j][i]==-1){
                t++;
            }
        }
        if(t==3)
            ans=true;
    }
    if(a[0][0]==-1&&a[1][1]==-1&&a[2][2]==-1) ans=true;
    if(a[2][0]==-1&&a[1][1]==-1&&a[0][2]==-1) ans=true;
    if(ans){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

const int INF=5e8;
int n,m;
int ar[200005];
pi que[200005];

int cnt[200005];

int dp[200005];

int br[200005];
int emp;
void add(int x){
  int p=max(0,x-cnt[x]);
  if(p>0 && br[p]==0) --emp;
  ++br[p];
  ++cnt[x];
}
void rem(int x){
  --cnt[x];
  int p=max(0,x-cnt[x]);
  --br[p];
  if(p>0 && br[p]==0) ++emp;
}
int main(){
  cin>>n>>m;
  emp=n;
  REP(i,n){
    scanf("%d",&ar[i]);
    add(ar[i]);
  }
  REP(hoge,m){
    int x,y;scanf("%d%d",&x,&y);--x;
    rem(ar[x]);
    add(y);
    ar[x]=y;
    printf("%d\n",emp);
  }


  return 0;
}





Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;

#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
ll mod = (1000000007LL);
inline ll Mod(ll a, ll b){return (a%b);}
inline ll poww(ll a, ll b){ll res = 1;while (b > 0){if(b & 1) res = (res * a)%mod;a = (a * a)%mod;b >>= 1;}return res;}
ll gcd (ll a, ll b) { while (b) { a %= b,swap(a, b);}return a;}
void read(vector<int> &w, int n){w.resize(n);for(int i = 0; i < n; i++) cin>>w[i];}
void print(vector<int> &w){for(int i =0; i < sz(w); i++){if(i == sz(w) - 1) cout<<w[i]<<"\n";else cout<<w[i]<<" ";}}
int prodmod(vector<int> w);
//MATH
void crivo(vector<int> &w, int TAM);
void inverso(vector<int> &inv, int TAM);
void fat_inverso(vector<int> &inv, int TAM);
int choose(int a, int b);
void get_fat();

///CUIDADO COM MAXN
#define N 2000020
int fat[N];

int n, m, q, k, v[N], ans;
pii w[N];
string s;
int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>k;
	cin>>s;
	int n=sz(s);
	for(int i=n;i<=n+k;i++){
		int A = choose(i-1,n-1);
		A = (poww(25, i-n)*A)%mod;
		A = (poww(26,n+k-i)*A)%mod;
		ans += A;
		ans %=mod;
	}
	cout<<ans<<"\n";
}
/*
    CUIDADO COM MAXN, MOD, OVERFLOW 
    >Colocar (>DEFINE INT LONG LONG<) no inicio do template
    >mod = (1e9 + 7), por padrao (NAO ESQUECER DE ALTERAR)
    >NAO ESQUECER DEFINE INT LONG LONG
    > N = 1 ? 
*/
int prodmod(vector<int> w){int curr = 1;
for(int i = 0; i < sz(w); i++){if(w[i] >= mod) w[i] %= mod;curr = (curr * w[i]) % mod;if(curr < 0) curr += mod;}return curr;}
void get_fat(){if(fat[0] != 0) return;fat[0]=1;for(int i = 1; i < N; i ++) fat[i]=(i*fat[i-1])%mod;}
int choose(int a, int b){get_fat();if(b>a) return 0;if(!b) return 1;
int A = fat[a];int B= (poww(fat[b],mod-2)*poww(fat[a-b], mod - 2))%mod;A = (A*B)%mod;return A;}
void inverso(vector<int> &inv, int TAM){inv.resize(TAM);inv[1] = 1;for (int i=2; i<TAM; ++i){inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}}
void fat_inverso(vector<int> &inv, int TAM){inverso(inv, TAM);for(int i = 2; i < TAM; i++) inv[i] = (inv[i] * inv[i-1])%mod;}
void crivo(vector<int> &w, int TAM){
	w.resize(TAM + 1);w[0]=1;
	for(int i = 2; i < TAM; i++)
		if(!w[i]) // i é um fator primo de J
			for(int j = 2*i; j < TAM; j += i) w[j]=1;
}


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

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  vector<int> v;
  for (int i = 1; i <= min(A, B); i++) {
    if ((A % i == 0) and (B % i == 0)) v.push_back(i);
  }
  cout << v[v.size() - K] << endl;
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define print(x) (cout << x << endl)

using namespace std;

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  // const int M = 1e9 + 7;
  
  string a, b;
  cin >> a >> b;

  int n = a.length(), m = b.length();
  vector<vector<int>> dp(n + 1, vector<int> (m + 1));

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i - 1] == b[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }

  // for (auto u : dp) {
  //   for (auto v : u) {
  //     cout << v << " ";
  //   }
  //   cout << endl;
  // }

  string ans = "";
  int i = n, j = m;
  while (i > 0 && j > 0) {
    if (a[i - 1] == b[j - 1]) {
      ans += a[i - 1];
      i--; j--;
    } else if (dp[i][j] == dp[i - 1][j]) {
      i--;
    } else {
      j--;
    }
  }

  // cout << dp[n][m] << endl;
  reverse(ans.begin(), ans.end());
  cout << ans << endl;

}
    // cout << "Case #" << C++ << ": " << cur_max << endl;  



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

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair

typedef long long llong;
typedef pair<int, int> pii;

void solve(){

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

	if(a > 0){
		cout << "Positive";
	}else if(a <= 0 && b >= 0){
		cout << "Zero";
	}else{

		int len = b - a + 1;

		if(len % 2) cout << "Negative";
		else cout << "Positive";

	}

}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {



    public static void main(String[] args) {
    	Scanner input = new Scanner(System.in);
    	String str = input.nextLine();
    	String ans = "No";
    	int cnt = 1;
    	char ch = str.charAt(0);
    	for (int i = 0; i < str.length(); i++) {

    		if ((i+1) == str.length()) {
    			break;
    		}

    		if (ch==str.charAt(i + 1)) {
    			cnt++;
    		}else {
    			cnt = 1;
    			ch = str.charAt(i + 1);
    		}
    		if (cnt == 3) {
    			ans = "Yes";
    			break;
    		}
    	}
    	System.out.println(ans);
    }
}



Measured memory_bytes: 21844
import math
n=int(raw_input())
x=list(map(int,raw_input().split()))
y=list(map(int,raw_input().split()))
z=[0]*n
zz=[0]*n
zzz=[0]*n
for i in range(n):
	x.append(y[i])
for i in range(n):
	z[i]=math.fabs(x[i]-x[n+i])
	zz[i]=z[i]**2
	zzz[i]=z[i]**3
print sum(z)
print math.sqrt(sum(zz))
print sum(zzz)**(1/3.0)
print max(z)

Measured memory_bytes: 4464
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
ll k;
cin >> k;
vector<ll> a;
for(int i=1;i<=9;i++) a.push_back(i);
while(1){
    if (k <= a.size()) {
        cout << a[k-1] << endl;
        return 0;
    }
    k -= a.size();
    vector<ll> old;
    swap(old,a);
    for(ll x : old) {
        for(int i = -1;i <= 1;i++){
            int d = x%10 + i;
            if(d < 0 || d > 9) continue;
            ll nx = x*10 + d;
            a.push_back(nx);
        }
    }
}

return 0;

}


Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
#define int long long
//template
void fin(int n){
  cout<<n<<endl;
  exit(0);
}
//main
signed main(){
  int N,K;cin>>N>>K;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  std::vector<int> a(N,0),b(N,0);
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(v[j]>v[i])a[i]++;
      if(j>i)continue;
      if(v[j]>v[i])b[i]++;
    }
  }
  int ans=0;
  for(int i=0;i<N;i++){
    ans+=(b[i]-a[i]+MOD)*K%MOD;ans%=MOD;
    int res=K*(K+1)/2;res%=MOD;
    ans+=res*a[i]%MOD;ans%=MOD;
  }
  ans+=MOD;ans%=MOD;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		
		while(true){
			int baggageNum = stdIn.nextInt();
			if(baggageNum == 0)break;
			int cost = 0;
			for(int i=0;i < baggageNum;i++){
				int size = 0;
				for(int j=0;j<3;j++)size += stdIn.nextInt();
				int w = stdIn.nextInt();
				if(size <= 60 && w <= 2){
					cost += 600;
				}else if(size <= 80 && w <= 5){
					cost += 800;
				}else if(size <= 100 && w <= 10){
					cost += 1000;
				}else if(size <= 120 && w <= 15){
					cost += 1200;
				}else if(size <= 140 && w <= 20){
					cost += 1400;
				}else if(size <= 160 && w <= 25){
					cost += 1600;
				}
			}
			System.out.println(cost);
		}
	}
}

Measured memory_bytes: 12000
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int main()
{
	deque<int> Q;
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		if (i % 2 == 0) Q.push_back(a);
		else Q.push_front(a);
	}
	VI V;
	while (!Q.empty()) {
		int u = Q.front();
		Q.pop_front();
		V.push_back(u);
	}

	if (n & 1) reverse(ALL(V));

	for (int i = 0; i < n; i++) {
		if (i) printf(" ");
		printf("%d", V[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 3960
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
#include<regex>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y))
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl; }
const LL MOD = 1e9 + 7;
const LL INF = 1LL << 60;


//H*W*3 → だいたい10^5
int main(void) {
	LL H, W;
	cin >> H >> W;

	vector<string> grid(H);
	rep(i, H) cin >> grid[i];

	vector<vector<LL> > light_map(H, vector<LL>(W));
	
	//Xについて
	for (LL y = 0; y < H; y++) {
		LL count = 0;
		for (LL x = 0; x < W; x++) {
			if (grid[y][x] == '.') {
				count++;
			}
			else {
				for (LL k = x - 1; k >= x - count; k--) {
					light_map[y][k] += count;
				}
				count = 0;
			}
		}
		for (LL k = W - 1; k >= W - count; k--) {
			light_map[y][k] += count;
		}
	}

	//Yについて
	for (LL x = 0; x < W; x++) {
		LL count = 0;
		for (LL y = 0; y < H; y++) {
			if (grid[y][x] == '.') {
				count++;
			}
			else {
				for (LL k = y - 1; k >= y - count; k--) {
					light_map[k][x] += count;
				}
				count = 0;
			}
		}
		for (LL k = H - 1; k >= H - count; k--) {
			light_map[k][x] += count;
		}
		count = 0;
	}

	//検討
	LL ans = 0;
	for (LL y = 0; y < H; y++) {
		for (LL x = 0; x < W; x++) {
			chmax(ans, light_map[y][x] - 1);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 35712
r,c,k=map(int, input().split())
grid=[[0]*(c+1) for _ in range(r+1)]
for i in range(k):
    ri,ci,vi=map(int, input().split())
    grid[ri][ci]=vi

dp=[[[0]*(c+1) for _ in range(r+1)] for _ in range(4)]

for i in range(1,r+1):
    for j in range(1,c+1):
        for k in range(4):
            dp[0][i][j]=max(dp[0][i][j],dp[k][i-1][j])
            dp[k][i][j]=max(dp[k][i][j],dp[k][i][j-1])
        if grid[i][j]!=0:
            dp[1][i][j]=max(dp[1][i][j],dp[0][i-1][j]+grid[i][j])
            for k in range(1,4):
                dp[1][i][j]=max(dp[1][i][j],dp[k][i-1][j]+grid[i][j])
                dp[k][i][j]=max(dp[k][i][j],dp[k-1][i][j-1]+grid[i][j])

ans=0
for k in range(4):
    ans=max(ans,dp[k][-1][-1])
print(ans)

Measured memory_bytes: 428704
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include<iomanip>
using namespace std;
using P = pair<int, int>;

int N, K;
double p[200010];

int main()
{
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}
	double ans = 0;
	double E = 0;
	for (int i = 0; i < K; i++) {
		E += (1 + p[i]) / 2;
	}
	ans = E;
	for (int i = K; i < N; i++) {
		E -= (1 + p[i - K]) / 2;
		E += (1 + p[i]) / 2;
		ans = max(ans, E);
	}
	cout << fixed << setprecision(10) << ans << endl;
}

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

int main(void){
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> cnt(n+1);
    rep(i,n-1){
        cnt[i+1] += cnt[i];
        if (s[i] == 'A' && s[i+1] == 'C') {
            cnt[i+2]++;
        }
    }
    cnt[n] += cnt[n-1];
    rep(i,q){
        int l,r;
        cin >> l >> r;
        // [l,r)
        cout << cnt[r] - cnt[l] << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <map>
#include <cstdio>
using namespace std;

int main(){
	int n;scanf("%d", &n);
	char s[7], str[13];
	map<string, int> m;
	for(int i = 0;i < n;i++){
		scanf("%s %s", s, str);
		if(s[0] == 'i')m[str] = 1;
		else puts(m[str] ? "yes" : "no");
	}
	return 0;
}
//1.78

Measured memory_bytes: 47584
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int ans = 0;
    rep(i, N + 1) rep(j, N + 1) {
        int b = -(i*R + j*G - N)/B;
        if (i*R + j*G + b*B == N && b >= 0) ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
vector <int> v;
int p,n,a,i,c=0,l=0,as=0;
cin>>p>>n;
for(i=0;i<n;i++)
{
	cin>>a;
	v.push_back(a);
	
}
for(i=0;i<n-1;i++)
{
	l=v[i+1]-v[i];
	c=max(c,l);
	
}
l=p-v[n-1]+v[0];
	c=max(c,l);
    as=p-c;
	cout<<as;	
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
string S, T;
int main() {
    cin >> S >> T;
    if (S.size() >= T.size()) {
        for (int i = 0; i <= S.size() - T.size(); i++) {
            if (T == S.substr(i, T.size())) {
                printf("%d\n",i);
            }
        }
    }
}

Measured memory_bytes: 2052
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().rstrip().split()
def S(): return sys.stdin.readline().rstrip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 998244353

n = I()
x = S()
rx=x.replace("1","2").replace("0","1").replace("2","0")
D = []
for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        if n // i % 2:
            D += [i]
        if i != n // i and i % 2:
            D += [n // i]

D.sort()
cnt = [0]*len(D)
ans=0
for k in range(len(D)):
    t=x[:D[k]]
    rt=rx[:D[k]]
    f=(t+rt)*(n//D[k]//2)+t
    cnt[k]=cnt[k]+int(f<=x)+int(t,2)
    cnt[k]%=mod
    ans += cnt[k]*D[k]*2
    for kk in range(k + 1, len(D)):
        if D[kk] % D[k] == 0:
            cnt[kk] -= cnt[k]
            cnt[kk]%=mod

print(ans % mod)


Measured memory_bytes: 108616
import java.io.*;
import java.util.*;

public class Main {
  public static void main(String[] args) throws IOException {
    Scanner cin = new Scanner(System.in);
    while (cin.hasNext()) {
      final int a = cin.nextInt();
      final int b = cin.nextInt();
      System.out.println(a+b);
    }
  }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef pair<int, int> P;
typedef struct{
  int first;
  int second;
  int third;
}T;

//昇順
bool comp_Se(T& l, T& r){
  return l.second < r.second;
}

ll mod =  1e9+7;
int main(void){
  int i,j,N,X;
  cin >> N >> X;
  vector<ll> v(N);
  REP(i,N) cin >> v[i];
  sort(v.begin(),v.end());

  //dp[i][j]:jをXの最初として，i+1回操作(ただしi+1番目まで)を行った時の総和
  ll dp[N][X+1];
  REP(j,X+1){
    dp[0][j] = j%v[0];
  }
  for(i=1;i<N;i++){
    REP(j,X+1){
      //dp[i-1][j%v[i]]:最初に行う場合
      //dp[i-1][j]*i 最初に行わない場合
      dp[i][j] = dp[i-1][j%v[i]] + dp[i-1][j] * i; 
      dp[i][j] %= mod;
    }
  }
  cout << dp[N-1][X] << endl;
  return 0;
}


Measured memory_bytes: 156544
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	static long mod=1000000007L;
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		long[] dp=new long[N+1];
		Arrays.fill(dp,0);
		dp[0]=1;
		int[] dan=new int[M];
		for(int i=0; i<M; i++) {
			dan[i]=sc.nextInt();
		}
		for(int i=1; i<M; i++) {
			if(dan[i]-dan[i-1]==1) {
				pl(0);
				System.exit(0);
			}
		}
		int counter=0;
		for(int i=1; i<=N; i++) {
			if(i==1) {	//2段前がない
				if(counter<M && dan[counter]==i) {
					dp[i]=0;	//踏めない
					counter++;
				}
				else {
					dp[i]=1;	//踏める
				}
			}
			else {
				if(counter<M && dan[counter]==i) {
					dp[i]=0;
					counter++;
				}
				else {
					dp[i]=dp[i-1]+dp[i-2];
					dp[i]%=mod;
				}
			}
		}
		pl(dp[N]);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 31832
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt int Q[100005]={0}
#define mp make_pair
#define test() int t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<int>()) 
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(int i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(int i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=mpowe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
int logtwo(int n){if(n==1)return 0;return logtwo(n/2)+1;}
vector <int> v[200005] ;   //Vector for maintaining adjacency list explained above
int level[200005];
bool vis[200005]; //Mark the node if visited 
void bfs(int s) 
{
    queue <int> q;
    q.push(s);
    level[ s ] = 0 ;  //Setting the level of the source node as 0
    vis[ s ] = true;
    while(!q.empty())
    {
        int p = q.front();
        q.pop();
        for(int i = 0;i < v[ p ].size() ; i++)
        {
            if(vis[ v[ p ][ i ] ] == false)
            {
        //Setting the level of each node with an increment in the level of parent node
                level[ v[ p ][ i ] ] = level[ p ]+1;                 
                 q.push(v[ p ][ i ]);
                 vis[ v[ p ][ i ] ] = true;
            }
        }
    }
}
int main()
{
    fastio();
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    ll n,a,b;
    cin>>n>>a>>b;
    ll na=1,nrn=1;
    for(ll i=1;i<=a;i++)
    {
        na=(na*i)%MOD;
    }
    for(ll i =n;i>=n-a+1;i--)
    {
        nrn = (nrn*i)%MOD;
    }
    ll nca = (nrn*mpowe(na,MOD-2)%MOD)%MOD;
    na =1;
    nrn=1;
    for(ll i=1;i<=b;i++)
    {
        na=(na*i)%MOD;
    }
    for(ll i =n;i>=n-b+1;i--)
    {
        nrn = (nrn*i)%MOD;
    }
    ll ncb = (nrn*mpowe(na,MOD-2)%MOD)%MOD;
    //cout<<ncb<<endl;
    ll ans = (mpowe(2,n)-1-nca-ncb+2*MOD)%MOD;
    cout<<ans<<endl;
}



Measured memory_bytes: 4992
#include<stdio.h>
 
int main()
{
  int length = 0;
  int height = 0;
  int area = 0;
  int cir = 0;
 
  scanf("%d %d", &length, &height);
  area = length * height;
  cir = length*2 + height*2;
 
  printf("%d %d\n", area, cir);
 
  return 0;
}

Measured memory_bytes: 2696
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,n,s) for(int i=s;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

  ll ans = (ll)1e13;

  REP(i, ceil(sqrt(n))) {
    if(n % (i+1) == 0) {
      ans = min(ans, (i+1) + (ll)(n/(i+1)) - 2);
    }
  }

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


Measured memory_bytes: 256
def main():
	N, X = map(int, input().split())
	m = [0] * N

	for i in range(N):
		m[i] = int(input())

	X -= sum(m)

	cnt = N
	cnt += X // min(m)
	
	print(cnt)

  
if __name__ == "__main__":
  	main()

Measured memory_bytes: 8924