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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int MOD = (int) 1e9 + 7;
const int inf = (int) 1e9;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 5e5 + 20;

int n, m;
char mp[2222][2222];
int d[4][2222][2222];

void work()
{
    cin >>n >>m;
    for(int i = 1; i <= n; i++) scanf("%s", mp[i] + 1);

    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            if(mp[i][j] != '#')
                d[0][i][j] = d[0][i - 1][j] + 1,
                d[1][i][j] = d[1][i][j - 1] + 1;
    for(int i = n; i >= 1; i--)
        for(int j = m; j >= 1; j--)
            if(mp[i][j] != '#')
                d[2][i][j] = d[2][i + 1][j] + 1,
                d[3][i][j] = d[3][i][j + 1] + 1;

    int ans = 0;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            if(mp[i][j] != '#')
            {
                int t = 0;
                for(int k = 0; k < 4; k++)
                    t += d[k][i][j];
                Max(ans, t - 3);
            }
    cout <<ans <<endl;
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
    int tc = 1;
//    cin >>tc;
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 82176
n = int(input())
s = str(input())
s = [str(i) for i in s]
d = int(n/2)
w, e = [], []
w.append(1) if s[0] == "W" else w.append(0)
e.append(1) if s[-1] == "E" else e.append(0)
for i in range(1, n):
    w.append(w[i-1] + 1) if s[i] == "W" else w.append(w[i-1])
    e.append(e[i-1] + 1) if s[n-1-i] == "E" else e.append(e[i-1])
e.reverse()
ans = [w[i-1] + e[i+1] for i in range(1, n-1)]
ans.insert(0, e[0])
ans.insert(-1, w[-1])
print(min(ans))

Measured memory_bytes: 32192
k, n = list(map(int, input().split()))
a = list(map(int, input().split()))
d = []
for i in range(n):
    if i == n - 1:
        d.append(a[0] + (k - a[i]))
    else:
        d.append(a[i + 1] - a[i])
d.sort()
print(sum(d[:-1]))

Measured memory_bytes: 104104
#include<stdio.h>
#include<queue>
#define MAX 101
using namespace std;

int G[MAX][MAX], d[MAX];
queue<int> Q;

void adjacency_matrices(int n) {
    int i, j, u, m, k;

    for (i=1; i<=n; i++) {
        scanf("%d", &u);
        scanf("%d", &m);
        for (j=1; j<=m; j++) {
            scanf("%d", &k);
            G[u][k] = 1;
        }
    }
}

void breadth_first_search(int n, int i, int dist) {
    int k;
    d[i] = dist++;
    for (int j=1; j<=n; j++) {
        if (G[i][j]==1 && d[j]==-1) {
            Q.push(j);
            d[j] = dist;
        }
    }

    while(!Q.empty()) {
        dist++;
        int length = Q.size();
        for (int j=1; j<=length; j++) {
            k = Q.front(); Q.pop();
            for (int m=1; m<=n; m++) {
                if (G[k][m]==1 && d[m]==-1) {
                    Q.push(m);
                    d[m] = dist;
                }
            }
        }
    }
}

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

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

    adjacency_matrices(n);

    breadth_first_search(n, 1, 0);

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


Measured memory_bytes: 2764
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int x,cnt=0;
  cin>>x;
  if(x/500>0)
  {
    cnt += (x/500)*1000;
    x = x-(x/500)*500;
  }
  if(x/5>0)
  {
    cnt += (x/5)*5;
    x = x-(x/5)*5;
  }
  cout<<cnt;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a,b;
  scanf("%d%d",&a,&b);
  if (a>b) printf("%d\n",2*a-1);
  else if (a<b) printf("%d\n",2*b-1);
  else printf("%d\n",a+b);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define endl 		"\n"
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1) {std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " : " << arg1;
	ZZ(comma, args...);
}

void solve() {
	int n;
	cin >> n;
	if(n>=30)cout<<"Yes";
	else cout<<"No";


}
int main() {
	fast_io;
	int t = 1;
	// cin>>t;
	while (t--) {
		solve();
	}
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
main(){
  int kazu[5];
  int i,j,k;
  int count;
  int count2;
  int tmp;
  int temp[5];
  while(scanf("%d,%d,%d,%d,%d",&kazu[0],&kazu[1],&kazu[2],&kazu[3],&kazu[4])!=EOF){
    for(i=0;i<4;i++){
      for(j=4;j>i;j--){
	if(kazu[j]<kazu[j-1]){
	  tmp=kazu[j];
	  kazu[j]=kazu[j-1];
	  kazu[j-1]=tmp;
	}
      }
    }
    count=1;
    count2=1;
    for(i=0;i<4;i++){
      if(kazu[i]==kazu[i+1]){
	count++;
      }
      if(kazu[i]!=kazu[i+1] && count!=1) break;
    }
    for(i=i;i<4;i++){
      if(kazu[i]==kazu[i+1]){
	count2++;
      }
    }
    
    if(count==2 && count2==1) printf("one pair\n");
    else if(count==2 && count2==2) printf("two pair\n");
    else if(count==3 && count2==1) printf("three card\n");
    else if(count==4 && count2==1) printf("four card\n");
    else if(count==3 && count2==2 || count==2 && count2==3) printf("full house\n");
    else{
      count=0;
      if(kazu[0]==1 && kazu[1]==10 && kazu[2]==11 && kazu[3]==12 && kazu[4]==13){
	printf("straight\n");
      }
      else{
	for(i=0;i<4;i++){
	  if(kazu[i+1]-kazu[i]==1) count++;
	}
	if(count==4) printf("straight\n");
	else printf("null\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 576
#include<stdio.h>
#include<math.h>
double change_rad(double C)
{
  int deg;
  double rad;
  double PI=acos(-1);
  rad=C*PI/180;
  return rad;
}
double distance(double x1,double y1,double x2,double y2)
{
  double dis,X,Y;
  X=(x1-x2)*(x1-x2);
  Y=(y1-y2)*(y1-y2);
  dis=sqrt(X+Y);
  return dis;
}
int main(void)
{
  double a,b,C,S,L,h;
  scanf("%lf %lf %lf",&a,&b,&C);
  //printf("a:%f b:%f C:%f\n",a,b,C);
  C=change_rad(C);
  S=0.5*(a*b*sin(C));
  L=a+b+sqrt(a*a+b*b-2*a*b*cos(C));
  h=b*sin(C);
  printf("%f\n",S);
  printf("%f\n",L);
  printf("%f\n",h);
  return 0;
}



Measured memory_bytes: 2040
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U>
inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U>
inline void cmin(T& a, U b) { if (a > b) a = b; }

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
  }
} io_setup;

constexpr char el = '\n';
#line 2 "b.cpp"

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

  ll n = s.size();

  bool f = 1;

  rep(i, n) {
    if (s[i] != s[n-1-i]) {
      f = 0;
    }
  }

  ll m = (n-1)/2;
  rep(i, m) {
    if (s[i] != s[m-1-i]) {
      f = 0;
    }
  }

  ll ind = n-1;
  for (ll i = (n+3)/2-1; i < n; i++) {
    if (s[i] != s[ind]) {
      f = 0;
    }
    ind--;
  }

  if (f) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  cout << flush;
}


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

int main(){
    int D;cin>>D;
    string nameOfDay[26];
    nameOfDay[25]="Christmas";
    nameOfDay[24]="Christmas Eve";
    nameOfDay[23]="Christmas Eve Eve";
    nameOfDay[22]="Christmas Eve Eve Eve";
    cout<<nameOfDay[D]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<map>
#include<vector>
#include<set>
#include<cctype>
#include<string>
using namespace std;


set <int >a[26], b[26];

int main()
{
	int n;
	string y,x;
	cin >> x >> y;
	for (int i = 0; i < x.size(); i++)
	{
		a[x[i] - 'a'].insert(y[i] - 'a');
		b[y[i] - 'a'].insert(x[i] - 'a');
	}
	for (int i = 0; i <= 25; i++)
	{
		if (a[i].size() > 1 || b[i].size() > 1)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 776
#include <iostream>
#include <cstdio>
#include <queue>
#define N 200005
using namespace std;

struct st{
	int x, y, l, r;
} t;
int n, a[N], d[N][20];
priority_queue<st> qu;

bool operator < (st p, st q) {
	return !(a[p.x] < a[q.x]);
}

int mn(int p, int q) {
	return a[p] < a[q] ? p : q;
}

int f(int p, int q) {
	int i;
	if (p > q) return p;
	for (i = 1; 1 << i <= q - p + 1; i++);
	i--;
	return mn(d[p][i], d[q - (1 << i) + 1][i]);
}

void add(int p, int q) {
	int x, y;
	if (p > q) return;
	x = f(p, q);
	y = mn(f(x + 1, q - 1), q);
	qu.push({x, y, p, q});
}

int main()
{
	int i, j, k;
	cin >> n;
	for (i = 0; i < n; i++) scanf("%d", &a[i]), d[i][1] = i;
	for (j = 2; 1 << j <= n; j++) {
		k = 1 << j;
		for (i = 0; i + k <= n; i++) {
			d[i][j] = mn(d[i][j - 1], d[i + k / 2][j - 1]);
		}
	}
	add(0, n - 1);
	while (!qu.empty()) {
		t = qu.top(), qu.pop();
		printf("%d %d ", a[t.x], a[t.y]);
		add(t.l, t.x - 1);
		add(t.x + 1, t.y - 1);
		add(t.y + 1, t.r);
	}
    return 0;
}

Measured memory_bytes: 18676
x,y = map(int,input().split())
count = 1

if x*y > 0:
  if x < y:
    count = y - x
  elif x > y:
    count = 2 + abs(y-x)
  elif abs(x) == abs(y):
    count = 0
elif x*y < 0:
  if x > y or x < y:
    count = 1 + abs(abs(x) - abs(y))
  elif abs(x) == abs(y):
    count = 0
else:
  if x != 0:
    count = abs(x)
    if x > 0:
      count += 1
  elif y != 0:
    count = abs(y)
    if y < 0:
      count += 1
  else:
    count = 0

print(count)


Measured memory_bytes: 3064
/*...Part - 01...*/

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <iterator>
#include <bitset>
#include <assert.h>
#include <new>
#include <sstream>
//#include <bits/stdc++.h>
using namespace std ;

/*...Part - 02...*/

typedef long long               ll ;
typedef long double             ld ;
typedef unsigned long long      ull ;
typedef pair<int,int>           pii ;
typedef pair<ll,ll>             pll ;
typedef vector<int>             vi ;
typedef vector<ll>              vll ;
typedef vector<vector<int>>     vvi ;

int Int(){int x ; scanf("%d",&x) ; return x ;}
ll Long(){ll x ; scanf("%lld",&x) ; return x ;}

/*...Part - 03...*/
/*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

/*...Part - 04...*/
/*...Needed to change according to problem requirements...*/

const int N          = (int)2e5 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;

/*..........................................................*/
/*...Part - 05...*/

#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e))  ; i += 1 - 2 * ((b) > (e)))
#define     Int         Int()
#define     Long        Long()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)

/*...Part - 06...*/
/*...... ! Code start from here ! ......*/

ll dp[21][1 << 21] ;

int n, a[22][22] ;

ll call(int pos, int mask){
	int f = __builtin_popcount(mask) ;
	if(f == n)return 1 ;
	ll& ret = dp[pos][mask] ;
	if(~ret)return ret ;
	ret = 0 ;
	for(int i = 0 ; i < n ; ++i){
		if(!(mask & (1 << i)) and a[pos][i]){
			ret += call(pos + 1, mask | (1 << i));
			if(ret >= Mod)ret -= Mod ;
		}
	}
	return ret ;
}


int main(){
    int test = 1 , tc = 0 ;
    while(test--){
        n = Int ;
        for(int i = 0 ; i < n ; ++i){
        	for(int j = 0 ; j < n ; ++j){
        		a[i][j] = Int ;
        	}
        }
        memn(dp) ;
        cout << call(0 , 0) << '\n' ;
    }
    return 0 ;
}

/*...Always look at the part - 04...*/
/*...............END................*/




Measured memory_bytes: 344448
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))

#define INF 200000000000

using namespace std;

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

struct OwnEdge
{
	ll from, to, cost;
	OwnEdge() :from(-1), to(-1), cost(-1) {}
	OwnEdge(ll from, ll to, ll cost) : from(from), to(to), cost(cost) {}
};

OwnEdge edges[10000];
ll tod[100][100];

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

	int V, E;
	scanf("%d %d", &V, &E);

	for (int i = 0; i < V; i++)for (int j = 0; j < V; j++)
	{
		tod[i][j] = INF;
	}

	for (int i = 0; i < E; i++)
	{
		int s, t, d;
		scanf("%d %d %d", &s, &t, &d);

		edges[i] = OwnEdge(s, t, d);
	}

	for (int k = 0; k < V; k++)
	{
		tod[k][k] = 0;

		bool ns = false;
		for (int i = 0; i < V; i++)
		{
			for (int j = 0; j < E; j++)
			{
				OwnEdge t = edges[j];
				if (tod[k][t.from] != INF&&tod[k][t.to]>(tod[k][t.from] + t.cost))
				{
					tod[k][t.to] = (tod[k][t.from] + t.cost);
					if (i == (V - 1))
					{
						ns = true;
					}
				}
			}
		}
		if (ns)
		{
			printf("NEGATIVE CYCLE\n");
			return 0;
		}
	}

	for (int i = 0; i < V; i++)
	{
		for (int j = 0; j < V; j++)
		{
			if (j == 0)
			{
				printf(tod[i][j] == INF ? "INF" : "%lld", tod[i][j]);
			}
			else
			{
				printf(tod[i][j] == INF ? " INF" : " %lld", tod[i][j]);
			}
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
ll a[maxn];

int main()
{
    ll n;
    while(cin>>n){
        ll sum=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            sum^=a[i];
        }
        if(sum==0){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
N,K=map(int,input().split())
a = list(map(int,input().split()))
dictionary = {}
for number in a:
    if number not in dictionary:
        dictionary[number] = 1
    else:
        dictionary[number] += 1
sortedDictionary = sorted(dictionary.items(), key=lambda x: x[1])
#print(sortedDictionary)
kind = len(sortedDictionary)
ans = 0
index = 0
while kind > K:
    ans += sortedDictionary[index][1]
    kind -= 1
    index +=1
print(ans)

Measured memory_bytes: 38968
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char c[101][101];//神奇的二维字符数组
int main()
    {
    int a,b;
    cin>>a>>b;//输入矩阵大小
    for(int i=0;i<a;i++)
        for(int j=0;j<b;j++)//嵌套循环输入
        {
        cin>>c[i][j];//输入每个位置上的情况
        }
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++)//循环输出，判断周围是否有雷
            {
            int sum=0;
            if(c[i][j]=='#') cout<<'#';//如果该位置有雷，直接输出‘*’
            else         //判断，周围有雷自+1；
                {
                if(c[i-1][j+1]=='#') sum++;
                if(c[i][j+1]=='#') sum++;
                if(c[i+1][j+1]=='#') sum++;
                if(c[i-1][j]=='#') sum++;
                if(c[i+1][j]=='#') sum++;
                if(c[i-1][j-1]=='#') sum++;
                if(c[i][j-1]=='#') sum++;
                if(c[i+1][j-1]=='#') sum++;
                cout<<sum;//判断完毕后直接输出sum
                }
            }
            cout<<endl;//换行
    }   
    return 0;     
    }

Measured memory_bytes: 256
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	a,b,c,d = tin()
	#s = input()
	return max(a*c, a*d,b*c, b*d)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

const int maxn = 2e5 + 10;
int c[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, k; cin >> n >> k;
    int t = 0;
    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        if (c[a] == 0) ++t;
        ++c[a];
    }
    sort(c, c + maxn);
    int p = 0;
    while (p < maxn && c[p] == 0) ++p;
    int ans = 0;
    for (int i = p, j = 0; j < t - k; ++i, ++j) ans += c[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;


int32_t main(){
	ios::sync_with_stdio(false);
    char a;
    cin>>a;
    if(a=='A'){
        cout<<"T"<<"\n";
    }
    if(a=='T'){
        cout<<"A"<<"\n";
    }
    if(a=='C'){
        cout<<"G"<<"\n";
    }
    if(a=='G'){
        cout<<"C"<<"\n";
    }



	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int64_t A, B, K, tmp;
	cin >> A >> B >> K;
	if (K > A)
	{
		tmp = K - A;
		if (tmp > B)
		{
			cout << "0 0" << endl;
		}
		else
		{
			B -= tmp;
			cout << "0 " << B << endl;
		}
	}
	else
	{
		cout << A - K << " " << B << endl;
	}
}

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

int main(){
  long long n;
  cin >> n;
  long long b[n];
  REP(i,n){
    long long a;
    cin >> a;
    b[i] = a-(i+1);
  }
  sort(b,b+n);
  long long b_min = b[n/2];
  long long ans = 0;
  REP(i,n){
    ans += abs(b[i]-b_min);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 210;
string s, t;

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	int n;
	cin >> n;
	getline(cin, s);
	getline(cin, s);
	getline(cin, t);
	for (int l = n; l <= 2 * n; ++l) {
		bool ok = 1;
		forn(i, l) {
			if (i < n && l - i <= n) {
				debug(i);
				if (s[i] != t[i - (l - n)])
					ok = 0;
			}
		}
		if (ok) {
			cout << l << endl;
			return 0;
		}
	}	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <array>
#include<unordered_map>
#include<unordered_set>

using namespace std;
#define IO                 \
	ios::sync_with_stdio(0); \
cin.tie(0);              \
cout.tie(0);
#define forn(i, n) for (int i = 0; i < n; i++)
#define forse(i, s, e) for (int i = s; i < e; i++)
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define mp make_pair
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define getcurrtime() \
	cerr << "Time = " << ((double)clock() / CLOCKS_PER_SEC) << endl

#define watch(x) cerr << (#x) << " is " << (x) << endl;

#ifndef LOCAL
#define cerr if(false)cerr
#endif
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll P=1e9+7;
double PI=3.141592653589793;
const int arrn = 2e5 + 1;


void solve(){
	ll x;
	cin >> x;
	set<ll> proc;
	map<ll,int> val;
	ll t=0;
	while(t*t*t*t*t<=1e18){
		proc.insert(t*t*t*t*t);
		val[t*t*t*t*t]=t;
		t++;
	}
	for(auto i:proc){
		if(proc.find(i-x)!=proc.end()){
			cout << val[i] << ' ' << val[i-x];
			return;
		}else if(proc.find(x-i)!=proc.end()){
			cout << val[i] << ' ' << -val[x-i];
			return;
		}
	}
}

int main() {
	IO;
	int T=1;
//	cin >> T;
	forn(c,T){
		solve();
	}
}



Measured memory_bytes: 4092
/*input
198 1.10
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

void run() {
	ll a;
	string b;
	cin >> a >> b;
	ll x = (b[0]-'0')*100 + (b[2]-'0')*10 + (b[3]-'0');
	a *= x;
	a /= 100;
	cout << (ll) a << endl;
}

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

Measured memory_bytes: 3680
#include<bits/stdc++.h>
#define ll long long
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPN(i,n) for(int i=1;i<=(n);i++)
using namespace std;
int dp[105][4][2];
int main()
{
	int ans;
	string s;
	cin>>s;
	ll n=s.size();
	ll K;
	cin>>K;
	dp[0][0][0]=1;
	REP(i,n)
	{
		REP(j,4)
		{
			REP(k,2)
			{
				ll nd=s[i]-'0';
				REP(d,10)
				{
					ll ni=i+1,nj=j,nk=k;
					if(d!=0)
					{
						nj++;
					}
					if(nj>K)
					{
						continue;
					}
					if(k==0)
					{
						if(d>nd)
						{
							continue;
						}
						if(d<nd)
						{
							nk=1;
						}
					}
					dp[ni][nj][nk]+=dp[i][j][k];
				}
			}
		}
	}
	ans=dp[n][K][0]+dp[n][K][1];
	cout<<ans<<endl;
	return 0;	
} 

Measured memory_bytes: 256
N = int(input())
S = list(input())
max_ntypes = 0
for i in range(N):
    left = set(S[0:i+1])
    right = set(S[i+1:N])
    n = len(list(left & right))
    if n > max_ntypes:
        max_ntypes = n
print(max_ntypes)

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

int main() {
    string S, T;
    cin >> S >> T;
    int N = S.size(), M = T.size();
    S += S;
    map<char, vector<int>> mp;
    for(int i = 0; i < 2 * N; ++i) mp[S[i]].push_back(i);
    int64_t ans = -1;
    for(auto &c : T) {
        int i = ans % N;
        auto it = upper_bound(mp[c].begin(), mp[c].end(), i);
        if(it == mp[c].end()) {
            cout << -1 << '\n';
            return 0;
        }
        ans += *it - i;
    }
    cout << ans + 1 << '\n';
    return 0;
}


Measured memory_bytes: 4712
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define VECCIN(x) for(auto&youso_: (x) ) cin >>  youso_
#define VECCOUT(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << endl
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head

int main(){
    int n,k,ans=inf;
    cin >>n >> k;
    for range(bit,pow(2,n)){
        int candi=1;
        for range(i,n){
            if (bit>>i & 1){
                candi*=2;
            }
            else{
                candi+=k;
            }
        }
        chmin(ans,candi);
    }
    cout << ans << endl;
}

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

int main() {
  int N, W; cin >> N >> W;

  vector<long long> dp(W + 1);

  rep(i, N) {
    int w, v; cin >> w >> v;
    vector<long long> ndp(dp);
    rep(k, W + 1) {
      if (k + w > W) continue;
      ndp[k + w] = max(dp[k + w], dp[k] + v);
    }
    swap(dp, ndp);
  }

  long long ans = 0;
  rep(i, W + 1) ans = max(ans, dp[i]);
  cout << ans << endl;
}

Measured memory_bytes: 1804
#include <stdio.h>
#define LL long long

int main()
{
    int h, n;
    LL N;

    scanf("%ld", &N);

    for (h = 1; h <= 3500; h++) {
        for (n = 1; n <= 3500; n++) {
            LL x = N * h * n;
            LL y = 4 * n * h - N * n - N * h;
            if (y > 0 && x % y == 0) {
                LL w = x / y;
                printf("%d %d %lld\n", h, n, w);
                return 0;
            }
        }
    }
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
    int q;
    cin >> q;
    ll a[101], b[101];
    for(int i = 0; i < q; i++){
        cin >> a[i] >> b[i];
        ll med = sqrt(a[i] * b[i]);
        if(a[i] * b[i] == med * med){
            if(a[i] == b[i]){
                cout << med * 2 - 2 << endl;
            }
            else{
                cout << med * 2 - 3 << endl;
            }
        }
        else if(med * (med + 1) >= a[i] * b[i]){
            cout << med * 2 - 2 << endl;
        }
        else{
            cout << med * 2 - 1 << endl;
        }
    }
}

Measured memory_bytes: 256
/* KYA CODEFORCES MERE BAS KI BAT NHI HAI  */
 
 #include<iostream>
 #include<cstring>
 #include<string>
 #include<vector>
 #include<utility>
 #include<stdlib.h>
 #include<limits.h>
 #include<cmath>
 #include<set>
 #include<initializer_list>
 #include<unordered_set>
 #include<unordered_map>
 #include<map>
 #include<iomanip>
 #include<algorithm>
 #include<queue>
 #include<stack>
#include <cstdint>
  
 #define sze 1000005
 #define ld long double
 //#define ll unsigned long long
 #define ll long long
 #define endl "\n"
 #define pb push_back
 #define mkp make_pair
 #define mod 1000000007
 #define ff first
 #define ss second
 #define F(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 all(c) (c).begin(),(c).end()
 #define pi                   pair<int,int>
 #define pll                  pair<ll,ll>
 #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
 using namespace std;
 
//cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;
 //const ll inf=1ll<<60;
 //const double pi = 3.14159265358979323846;


 int main()
 {
     int n; cin>>n;
     vector<pair<int,int>> vect(n);
     int c=0,f=0;
     F(i,0,n-1)
     {
         cin>>vect[i].ff>>vect[i].ss;
         if(vect[i].ff==vect[i].ss)
         {
             c++;
             if(c>=3)f=1;
         }
         else
         {
             c=0;
         }
     }
     if(f==1)cout<<"Yes"<<endl;
     else
         cout<<"No"<<endl;
 }


Measured memory_bytes: 3628
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){

 int x,i,j;
 cin>>x;
 for(i=1;i<=9;i++)
 {
     for(j=1;j<=9;j++)
     {
         if(i*j==x)
         {
             cout<<"Yes"<<endl;
             return 0;
         }
     }
 }
 cout<<"No"<<endl;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

	static final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

	public static void main(String[] args) throws Exception {

		Set<String> data = new HashSet<>();

		// --- input ---
		int num = Integer.parseInt(in.readLine());
		for(int i=0; i < num; i++) {
			data.add(in.readLine());
		}
		in.close();

		// --- resolv ---
		System.out.println(data.size());
	}
}


Measured memory_bytes: 22740
N = int(input())
task = []
for i in range(N):
    task += [ [int(x) for x in input().split()] ]

task = sorted(task, key = lambda x: x[1])

time, i = task[0][0], 0
while time <= task[i][1]:
    i += 1
    if i >= N:  break
    time += task[i][0]

if i == N:    print('Yes')
else:   print('No') 

Measured memory_bytes: 42836
import java.util.*;
public class Main{
    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        Pair[] pairs = new Pair[M];
        for(int i = 0;i < M;i++){
            Pair ps = new Pair();
            ps.from = sc.nextInt();
            ps.end = sc.nextInt();
            pairs[i] = ps;
        }
        Arrays.sort(pairs);
        int cnt = 0;
        int nowclear = 0;
        for(int i = 0; i<M; i++){
            int nowfrom = pairs[i].from;
            int nowend = pairs[i].end;
            if(nowclear < nowfrom){
                cnt++;
                nowclear = nowend - 1;
            }
        }
        System.out.println(cnt);
    }
}

class Pair implements Comparable{
    int from;
    int end;
    public int compareTo(Object other){
        Pair otherpair = (Pair) other;
        return end - otherpair.end;
    }
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    int cnt0 = 0;
    int cnt1 = 0;
    int cnt2 = 0;

    rep(i, N) {
        int a;
        cin >> a;
        if (a % 4 == 0) {
            cnt0++;
        } else if (a % 2 == 0) {
            cnt1++;
        } else {
            cnt2++;
        }
    }

    if (cnt1 != 0) cnt2++; // ２の倍数のまとまりをcnt2の一つとみなす

    if (cnt0 >= cnt2 - 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

public class Main {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        int x = in.nextInt();
        int y = in.nextInt();
        System.out.println(group(x) == group(y) ? "Yes" : "No");
    }

    int group(int x) {
        if(x == 2) return 0;
        else if(x == 4 || x == 6 || x == 11 || x == 9) {
            return 1;
        }else return 2;
    }
}

@SuppressWarnings("serial")
class MultiSet<T> extends HashMap<T, Long>{
    @Override public Long get(Object key){return containsKey(key)?super.get(key):0L;}
    public void add(T key,long v){put(key,get(key)+v);}
    public void add(T key){put(key,get(key)+1);}
    public void sub(T key){final long v=get(key);if(v==1)remove(key);else put(key,v-1);}
    public MultiSet<T> merge(MultiSet<T> set)
    {MultiSet<T>s,l;if(this.size()<set.size()){s=this;l=set;}else{s=set;l=this;}
        for(Entry<T,Long>e:s.entrySet())l.add(e.getKey(),e.getValue());return l;}
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
#define dbg(x) cout<<#x<<" : "<<x<<endl;
using namespace std;
int ANS=-999;int j;
int main(){
    int n,a[99999];
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    int ans=0;
    for(int i=1;i<=n-1;i++){
        if(a[i+1]<=a[i])ans++;
        else{
            ANS=max(ANS,ans);
            ans=0;
        }
    }
    ANS=max(ANS,ans);
    cout<<ANS<<endl;
    return 0;
}


Measured memory_bytes: 640
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}


int n, arr[100005];


int main(){

    ios_base::sync_with_stdio(0);

    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>arr[i];

    int ans = 0;
    for(int i=1;i<=n;i++)
        if(arr[i] > i && arr[arr[i]] == i)
            ans++;

    cout<<ans;
    return 0;
}






Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N,K;
int A[100000];

int main(){
    cin>>N>>K;
    rep(i,N) cin>>A[i];

    int ans=ceil((double)(N-1)/(K-1));
    
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,m;cin>>n>>m;
	string s;cin>>s;
	int cnt = 0;
	int tmp = 0;
	for(int i = 0; i < n + 1; i++) {
		if(s[i] == '0'){
			tmp = max(tmp,cnt);
			cnt = 0;
		}
		else{
			cnt ++;
		}
	}
	tmp = max(tmp,cnt);
	if(tmp >= m){
		cout << -1 << endl;
		return 0;
	}
	reverse(ALL(s));
	int i = 0;
	vector<int> ans;
	while(i < n){
		int right = min(n,i + m);
		for(int j = right; j > i; j--) {
			if(s[j] == '1'){
				continue;
			}
			else{
				ans.pb(j - i);
				i = j;
				break;
			}
		}
	}

	for(int i = 0; i < ans.size(); i++) {
		cout << ans[ans.size() - i - 1] << " ";
	}

	return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int calc(const string& str, int R, int S, int P){
  if(str.size() == 0) return 0;

  vector<vector<int>> dp(3, vector<int>(str.size()+1, 0));

  int N = str.size();
  rep(i,N){
    rep(j,3){
      rep(k,3){
        if(j==k) continue;
        
        if(str[i] == 'r'){
          if(k==2){
            dp[k][i] = max(dp[k][i], P + (i-1>=0?dp[j][i-1]:0));
          }else{
            dp[k][i] = max(dp[k][i], 0 + (i-1>=0?dp[j][i-1]:0));
          }
        }
        else if(str[i] == 's'){
          if(k==0){
            dp[k][i] = max(dp[k][i], R + (i-1>=0?dp[j][i-1]:0));
          }else{
            dp[k][i] = max(dp[k][i], 0 + (i-1>=0?dp[j][i-1]:0));
          }
        }
        else{
          if(k==1){
            dp[k][i] = max(dp[k][i], S + (i-1>=0?dp[j][i-1]:0));
          }else{
            dp[k][i] = max(dp[k][i], 0 + (i-1>=0?dp[j][i-1]:0));
          }
        }
      }
    }
  }

  return max({dp[0][N-1], dp[1][N-1], dp[2][N-1]});
}

int main(){
  int N, K;
  cin >> N >> K;
  int R, S, P;
  cin >> R >> S >> P;
  string T;
  cin >> T;
  vector<string> v(K,"");
  rep(i,T.size()){
    v[i%K] += T[i];
  }

  int ret = 0;
  rep(i,K){
    ret += calc(v[i], R, S, P);
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 6096
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using ll = long long;
#define ull unsigned ll
//#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppi pair<int, pii>
#define mt make_tuple
#define eb emplace_back
#define pcii pair<char, pair<int, int>>
using namespace std;

const ll N = 1e5 + 5, mod = 1e9 + 7;
const ll inf = 1e18 + 5;

void solve(){
    int x;
    cin >> x;
    if(x >= 400 && x <= 599){
        cout << 8 << endl;
    }
    if(x >= 600 && x <= 799){
        cout << 7 << endl;
    }
    if(x >= 800 && x <= 999){
        cout << 6 << endl;
    }
    if(x >= 1000 && x <= 1199){
        cout << 5 << endl;
    }
    if(x >= 1200 && x <= 1399){
        cout << 4 << endl;
    }
    if(x >= 1400 && x <= 1599){
        cout << 3 << endl;
    }
    if(x >= 1600 && x <= 1799){
        cout << 2 << endl;
    }
    if(x >= 1800 && x <= 1999){
        cout << 1 << endl;
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
//#include <vector>
#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    string s;
    string t;
    bool ans=true;
    cin >> s;
    cin >> t;
    if(s.size()+1!=t.size()){
        ans=false;
    }
    for(int i=0; i<s.size(); i++){
        if(s[i]!=t[i]){
            ans=false;
        }
    }

    if(ans==true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3568
S=input()
K=int(input())
count=1
ans=0
old='old'
for x in S:
    if old==x:
        count+=1
    else:
        ans+=count//2
        count=1
    old=x

ans+=count//2
check1=0
check1+=ans

ans-=count//2

for x in S:
    if old==x:
        count+=1
    else:
        ans+=count//2
        count=1
#     print(count)
    old=x

ans+=count//2
check2=0
check2+=ans

ans-=count//2

for x in S:
    if old==x:
        count+=1
    else:
        ans+=count//2
        count=1
#     print(count)
    old=x

ans+=count//2

# print(check1,check2,ans)

if K==1:
    print(check1)
elif K==2:
    print(check2)
elif K==3:
    print(ans)
else:
    if (check2-check1)==(ans-check2):
        print((check2-check1)*(K-1)+check1)
    else:
        print((check2-check1)*((K-1)//2+(K-1)%2)+ (ans-check2)*((K-1)//2) +check1)



Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
	/*「P回以下の攻撃で倒すことができるか？」というのは、以下のように調べることができる：
	各iごとに、max(0,1+(h[i]-(P*B)-1)/(A-B))を足して、それがP以下ならばよい。*/
	long long N,A,B,h[100000];
	long long i,Pmin,Pmax,P,sum;

	scanf("%lld %lld %lld",&N,&A,&B);
	for(i=0;i<N;i++){
		scanf("%lld",&h[i]);
	}
	/*Pmin以下では倒せない、Pmax以下なら倒せる*/
	Pmin = 0;
	Pmax = 1000000000;
	P = (Pmin+ Pmax)/2;
	while(Pmax - Pmin>=2){
		/*P以下で倒せるか？*/
		sum = 0;
		for(i=0;i<N;i++){
			if(h[i]-P*B > 0){
				sum = sum + 1+ (h[i]-(P*B)-1)/(A-B);
			}
		}
		if(sum<= P){
			/*倒せる*/
			Pmax = P;
		}else{
			/*倒せない*/
			Pmin = P;
		}
		P = (Pmax+Pmin)/2;
	}
	printf("%lld\n",Pmax);
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    int n, k;

    cin >> n >> k;

    ll ans = 0;

    if(k == 0) {
        cout <<(ll) n * n << endl;
        return 0;
    }
    
    for(int i = k + 1; i <= n; i++) {
        ans += (i - k) * (n/i) ;
        if(n%i >= k)
            ans += (n%i) - k + 1;
    }
    
    cout << ans << endl;
  
    return 0;
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int h,w; cin >> h >> w;
  vector<vector<char> > g(h,vector<char>(w));
  rep(i,h)rep(j,w){
    cin >> g[i][j];
  }
  map<char,int> mp;
  rep(i,h)rep(j,w){
    mp[g[i][j]]++;
  }
  int cnt4=0;
  int cnt1=0;
  for(auto c:mp){
    cnt4+=c.second/4;
    if(c.second%2==1) cnt1++;
    if(cnt1>1){
      cout << "No" << endl;
      return 0;
    }
  }
  if((h%2==0||w%2==0)&&cnt1>0){
    cout << "No" << endl;
    return 0;
  }
  int hh=h,ww=w;
  if(h%2==1) hh=h-1;
  if(w%2==1) ww=w-1;
  int cnt41=hh*ww/4;
  if(cnt4>=cnt41){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
def bubbleSort(A,N):
    flag = 1
    cnt = 0
    while flag:
        flag = 0
        for j in range(N-1,0,-1):
            if A[j] < A[j-1]:
                tmp = A[j]
                A[j] = A[j-1]
                A[j-1] = tmp
                flag = 1
                cnt +=1
    print(*A)
    print(cnt)

n = int(input())
ls = list(map(int,input().split()))

bubbleSort(ls,len(ls))



Measured memory_bytes: 5608
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  string S,T;
  cin >> S >> T;
  bool ans  = false;
  for (int i=0; i<S.size(); i++) {
    if (S == T) {
      ans = true;
      break;
    }
    S = S.back() + S.substr(0,S.size()-1);
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

char s[100005];

int main(){
	scanf("%s", s);
	
	int l = strlen(s);
	int res = 0;
	int st = 0;
	int ed = l - 1;
	
	while(st <= ed){
		if(s[st] == s[ed]){
			st++;
			ed--;
		}
		else if(s[st] == 'x'){
			st++;
			res++;
		}
		else if(s[ed] == 'x'){
			ed--;
			res++;
		}
		else
		return 0 * printf("-1\n");
	}
	
	printf("%d\n", res);
}


Measured memory_bytes: 384