akhauriyash/Code-Regression huggingface dataset:
/*input
1 100000
1
*/
 
 
#include <bits/stdc++.h>
using namespace std;
 
#define ld long double
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define se second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define INTMAX  2147483647
#define INTMIN  -2147483648
#define LLMAX 9223372036854775807
#define LLMIN -9223372036854775808
#define MOD 1000000007
typedef map<long long int, long long int> mpi;
typedef set<long long int> seti;
typedef multiset<long long int> mseti;
typedef priority_queue<long long int> pq;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define PI 3.1415926535
#define dbg(x) cerr << "\n" << (#x) << " = " << (x) << endl ;
//#define cerr if(false)cerr

// cout<<fixed<<setprecision(10)<<(v1+v2+v3)<<endl;
  
struct node{
    ll val;
};


long long int minimum = 100000000000000;

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

struct ct_s_h {long long int cts, cth, index;};

bool compare(long long int a, long long int b) {
	if(gcd(a,b) < minimum)
		return 1;
	else return 0;
}




vector <ll> dp;

int main(){
	ll n,k; cin>>n>>k;
	vll a(n,0); rep(i,n)cin>>a[i];
	repA(i,0,k){dp.pb(0);}
	repA(i,0,k){
		rep(j,a.size()){
			if(i-a[j]>=0 && dp[i-a[j]]==0)
				dp[i]=1;
		}
	}
	if(dp[k])cout<<"First\n";
	if(dp[k]==0)cout<<"Second\n";
	return 0;	
}















 


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

struct Node {
    int key;
    Node *parent, *left, *right;
};
Node *root, *NIL;

void insert(int k) {
    Node *y = NIL; //xの親
    Node *x = root;
    Node *z;
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

Node * find(int tgt) {
    Node *x = root;
    while (x != NIL) {
        if (tgt == x->key) {
            return x;
        } else if (tgt < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    return NIL;
}

Node * treeMinimum(Node *x) {
    while (x->left != NIL) x = x->left;
    return x;
}

void treeDelete(Node *z) {
    Node *y; //削除する対象
    Node *x; //yの子
    //削除する節点を決める
    if (z->left == NIL || z->right == NIL) y = z;
    else y = treeMinimum(z->right);

    //yの子xを決める
    if (y->left != NIL) {
        x = y->left;
    } else {
        x = y->right;
    }

    if (x != NIL) {
        x->parent = y->parent;
    }

    if (y->parent == NIL) {
        root = x;
    } else {
        if (y == y->parent->left) {
            y->parent->left = x;
        } else {
            y->parent->right = x;
        }
    }

    if (y != z) {
        z->key = y->key;
    }
    free(y);
}

void inOrder(Node *u) {
    if (u == NIL) return;
    inOrder(u->left);
    cout << " " << u->key;
    inOrder(u->right);
}

void preOrder(Node *u) {
    if (u == NIL) return;
    cout << " " << u->key;
    preOrder(u->left);
    preOrder(u->right);
}

int main() {
    int m, k;
    cin >> m;
    string order;
    for (int i = 0; i < m; i++) {
        cin >> order;
        if (order == "insert") {
            cin >> k;
            insert(k);
        }
        if (order == "print") {
            inOrder(root);
            cout << endl;
            preOrder(root);
            cout << endl;
        }
        if (order == "find") {
            cin >> k;
            Node *x = find(k);
            if (x != NIL) {
                cout << "yes";
            } else {
                cout << "no";
            }
            cout << endl;
        }
        if (order == "delete") {
            cin >> k;
            treeDelete(find(k));
        }
    }

    return 0;
}


Measured memory_bytes: 21816
#include <bits/stdc++.h>
#include <fstream>
#include <iostream>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define maxim INT_MAX
#define fi first
#define se second

/* 1. If you can't keep solution in mind, then visualize it on a paper.
 * 2. Try to identify the type of problem - DP, Greedy, Graph, Constructive,
 * 	  Prefix/Suffix, Difference Array, BIT/Segment Tree, etc.
 * 3. Look at the problems from different perspectives - reverse the problem,
 * 	  add instead of delete (maybe?)
 * 4. Divide difficult solutions into cases and/or sequences.
 * 5. Use math rules to solve Nested Summation.
 * 6. Optimisation problems are generally solved with DP, greedy, binary search or brute-force.
 * 7. Try fixing a solution then proving we can't do better or worse than that.
 * ------------------------------------------------------------------
 */

 ll dp[100005];
 ll ans=0;
 ll k;
 ll y=LONG_MAX;
 ll cost(ll ar[],ll i,ll n)
 {


     if(i>=n)
        return 0;
    if(dp[i]!=-1)
        return dp[i];

        vector <ll> v;
    for(ll j=1;j<=k;j++)
    {
        ll x;
        if(i+j<=n)
        v.pb(cost(ar,i+j,n)+abs(ar[i+j]-ar[i]));
        else
        {
            v.pb(cost(ar,i+j,n)+abs(ar[n]-ar[i]));
        }

    }
    ans=*min_element(v.begin(),v.end());
    dp[i]=ans;
    return dp[i];
 }
 int main()
 {
     ll n;
     cin>>n>>k;
     ll ar[n+1];
     for(ll i=1;i<=n;i++)
        cin>>ar[i];
     ar[0]=0;
     memset(dp,-1,sizeof(dp));
     ll ans=cost(ar,(ll)1,n);
     cout<<ans<<endl;

 }


Measured memory_bytes: 17556
/*
ID: arthurc4
TASK: test
LANG: C++11
*/
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <random>
#include <stack>
#include <deque>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++)
#define REPb(j, d, c) \
for (int j = int(d); j >= int(c); j--)
#define pb \
push_back
#define ff \
first
#define ss \
second
int main()
{
	//ifstream cin("input.txt");
	//ifstream cin("test.in");
	//ofstream cout("test.out");

	int n;
	cin >> n;

	vector<ll> A, B, C;

	REP(i,1,n)
	{
		ll a, b, c;
		cin >> a >> b >> c;
		A.pb(a);
		B.pb(b);
		C.pb(c);
	}

	vector<ll> a_dp(n+1);
	vector<ll> b_dp(n+1);
	vector<ll> c_dp(n+1);

	REP(i,1,n)
	{
		a_dp[i]=A[i-1]+max(b_dp[i-1],c_dp[i-1]);
		b_dp[i]=B[i-1]+max(c_dp[i-1],a_dp[i-1]);
		c_dp[i]=C[i-1]+max(a_dp[i-1],b_dp[i-1]);

		//cout << i << " " << a_dp[i] << " " << b_dp[i] << " " << c_dp[i] << endl;		
	}

	cout << max({a_dp[n],b_dp[n],c_dp[n]}) << endl;

	return 0;
}

Measured memory_bytes: 5216
#include<bits/stdc++.h>
#define fr(i,c,b) for(int i=c;i<b;i++)
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define MAX 1000001
typedef long long int ll;

using namespace std;



int main(){
    si(n);
    string s; cin>>s;
    if(n<3200)
        cout<<"red";
    else
        cout<<s;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[200];
int l;
int main ()
{
    cin>>s;
    l=strlen(s);
    for(int i=0;i<l;i++)
    {
        if(s[i]=='C')
        {
            for(int j=i+1;j<l;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
    int kaisuu[100][2];
    int i,j;
    int num;
    int temp;
    for(i=0;i<100;i++) {
        kaisuu[i][0]=0;
        kaisuu[i][1]=i+1;
    }
    while(1) {
        if(scanf("%d",&num)==-1)break;
        kaisuu[num-1][0]++;
    }
    for(i=99;i>0;i--) {
        for(j=0;j<i;j++) {
            if(kaisuu[j][0]<kaisuu[j+1][0]) {
                temp=kaisuu[j][0];
                kaisuu[j][0]=kaisuu[j+1][0];
                kaisuu[j+1][0]=temp;
                temp=kaisuu[j][1];
                kaisuu[j][1]=kaisuu[j+1][1];
                kaisuu[j+1][1]=temp;
            }
        }
    }
    printf("%d\n",kaisuu[0][1]);
    for(i=1;i<100;i++) {
        if(kaisuu[i][0]!=kaisuu[i-1][0])break;
        printf("%d\n",kaisuu[i][1]);
    }
    return 0;
}

Measured memory_bytes: 596
#!/usr/bin/env python3
#ABC143 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b = LI()
print(max(0,a - 2*b))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
int n;
cin>>n;
vector<int>a(n+2),b(n+2),c(n+2);
b[0]=0;
c[n+1] =0;
for(int i =1; i<= n;i++)
    cin>>a[i];
for(int i=1; i<=n ;i++){
    b[i] = __gcd(a[i] ,b[i-1]);
}
for(int i =n; i>=1 ;i--){
    c[i] =__gcd(c[i+1] , a[i]);
}

int ans=0;
for( int i =1 ;i <= n; i++){

    ans= max(ans , __gcd(b[i-1] , c[i+1]));

}
cout<<ans<<endl;






   }


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

int main(){
  int s; cin>>s;
  int a_n1,a_n,a_min,cnt=0;
  bool flag=true;
  a_n=s;
  a_min=s;
  while(flag){
    cnt++;
    if(a_n==1 || a_n==2 || a_n==4){cnt+=3; flag=false;}
    if(a_n%2==0)a_n1=a_n/2;
    else a_n1=3*a_n+1;
    a_n=a_n1;
  }
  cout <<cnt <<endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, x) = readLine()!!.split(" ").map { it.toInt() }
    val l = readLine()!!.split(" ").map { it.toInt() }
    var d = 0
    var cnt = 1
    for (ll in l) {
        d += ll
        if (d > x) break
        cnt += 1
    }
    print(cnt)
}

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

using namespace std;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == b) && (b == c)) {
		cout << 1 << endl;
	}
	else if ((a == b) || (b == c) || (c == a)) {
		cout << 2 << endl;
	}
	else {
		cout << 3 << endl;
	}
	return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

bool solve(char c1,char c2, char c3){
  if(c1 == c2 && c2 == c3 && c1 != '+'){
    cout << c1 << endl;
    return true;
  }
  return false;
}
int a[] = {0,3,6};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,s2;
  while(1){
    bool f = false,f2 = false;
    s.clear();
    rep(i,3){
      cin >> s2;
      if(s2 == "0"){
        f2 = true;
        break;
      }
      s += s2;
    }
    if(f2) break;
    rep(i,3){
      if(solve(s[a[i]],s[a[i]+1],s[a[i]+2])){
        f = true;
        break;
      }
    }
    if(!f){
      rep(i,3){
        if(solve(s[i],s[i+3],s[i + 6])){
          f = true;
          break;
        }
      }
    }
    if(!f){
      if(!solve(s[0],s[4],s[8])){
        if(solve(s[2],s[4],s[6])){
          f = true;
        }
      }
      else f = true;
    }
    if(!f){
      cout << "NA"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

bool CanPaint(int x, int y, const vector<string> field) {
  struct Diff {
    int x;
    int y;
  };
  Diff d[4] {{1,0}, {-1,0}, {0,1}, {0,-1}};
  for (int i = 0; i < 4; ++i) {
    if (x + d[i].x < 0 || x + d[i].x >= field[y].size()) continue;
    if (y + d[i].y < 0 || y + d[i].y >= field.size()) continue;
    if (field[y + d[i].y][x + d[i].x] == '#') return true;
  }
  return false;
}

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> field(h);
  for (int i = 0; i < h; ++i) {
    cin >> field[i];
  }
  for (int y = 0; y < h; ++y) {
    for (int x = 0; x < w; ++x) {
      if (field[y][x] == '#'&& !CanPaint(x, y, field)) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	int n;
	while(cin>>n,n) 
	{
		int f[n+1][n+1];
		memset(f,0,sizeof(f));
		for(int i = 0; i < n; ++i)
		{
			for(int j = 0; j < n; ++j)
			{
				cin>>f[i][j];
				f[i][n]+=f[i][j];
				f[n][j]+=f[i][j];
				f[n][n]+=f[i][j];
			}
		}
		for(int i = 0; i <= n; ++i)
		{
			for(int j = 0; j <= n; ++j)
			{
				printf("%5d",f[i][j]);
			}
			cout<<endl;
		}
	}
  return 0;
}

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

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define all(c) (c).begin(),(c).end()
#define endl '\n'
using namespace std;

//                                          mdsaqib
signed main(){
    fast;
    int n;
    cin >> n;
    vector <int> A(n,0);
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    sort(all(A));
    reverse(all(A));
    int sum=A[0];
    n-=2;
    int i=1;
    while(n>0){
        if(n>1){
            sum+=2*A[i];
            i++;
        }
        else{
            sum+=A[i];
            i++;
        }
        n-=2;
    }
    cout << sum;
}

Measured memory_bytes: 4760
import sys

N = input()

A=int(N[0])
B=int(N[1])
C=int(N[2])
D=int(N[3])

def myprint(lst):
	s=str(A)+lst[0]+str(B)+lst[1]+str(C)+lst[2]+str(D)+"=7"
	print(s)


def calc2(a,b,op):
	if(op=="-"):
		return a-b
	else:
		return a+b

def calc(lst):
	sum=calc2(calc2(calc2(A,B,lst[0]),C,lst[1]),D,lst[2])
	return sum


lst=["+","+","+"]

lst2=0
while(True):
	if(calc(lst)==7):
		myprint(lst)
		break
	lst2+=1
	temp=format(lst2,"03b")
	for i in range(3):
		if(temp[i]=="0"):
			lst[2-i]="-"
		else:
			lst[2-i]="+"

Measured memory_bytes: 3064
def is_prime? n
    return true if n == 2
    2.upto Math.sqrt(n).ceil do |i|
        return false if n % i == 0
    end
    true
end

x = gets.to_i

x.upto Float::INFINITY do |n|
    if is_prime? n
        puts n
        break
    end
end

Measured memory_bytes: 1788
/* Manish Pant - insider_pants, hello_my_friend */
    
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define endl "\n"
#define pb push_back

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

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const multiset<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.F << ' ' << v.S; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.F << " => " << i.S << ')' << ' '; return os; } 

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

ll a, b, n;

void solve()
{
    ll best = (a * min(b - 1, n)) / b;

    ll temp = b - 1 + b;
    while(1)
    {
        if(temp > n) break;
        ll t = ((a * min(temp, n)) / b) - a * (temp / b);
        if(t > best)
        {
            best = t;
        }
        else break;

        temp += b;
    }

    cout << best << endl;
}

int main()
{
    fast();
    cin >> a >> b >> n;
    solve();
}

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

int bit[200005];
inline void add(int i, int x){
  i++;
  while(i<200005){
    bit[i]+=x;
    i+=i&-i;
  }
}
inline int sum(int i){
  i++;
  int ret=0;
  while(i){
    ret+=bit[i];
    i-=i&-i;
  }
  return ret;
}

string str;
int nxt[26];
int main(){
  int k;
  cin >> str >> k;
  int n=str.length();
  fill(bit, bit+200005, 0);
  for(int i=0; i<n; i++) add(i, 1);
  fill(nxt, nxt+26, 0);
  for(int i=0; i<26; i++){
    while(nxt[i]<n && str[nxt[i]]!='a'+i) nxt[i]++;
  }
  for(int i=0; i<n; i++){
    for(int j=0; j<26; j++){
      if(nxt[j]==n) continue;
      int cnt=sum(nxt[j]-1);
      if(cnt<=k){
        k-=cnt;
        add(nxt[j], -1);
        cout << (char)('a'+j);
        nxt[j]++;
        while(nxt[j]<n && str[nxt[j]]!='a'+j) nxt[j]++;
        break;
      }
    }
  }
  cout << endl;
}

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

main() {
  int H, W; cin >> H >> W;
  vector<string> a(H);
  int cnt[26]{};
  for (int i = 0; i < H; i++) {
    cin >> a[i];
    for (int j = 0; j < W; j++) {
      cnt[a[i][j] - 'a']++;
    }
  }
  sort(cnt, cnt + 26, greater<int>());

  int group[3]{};
  if (H % 2 == 1 && W % 2 == 1) group[0] = 1;
  if (H % 2 == 1) group[1] += W / 2;
  if (W % 2 == 1) group[1] += H / 2;
  group[2] = (H * W - group[0] - group[1] * 2) / 4;

  for (int i = 0; i < 26; i++) {
    while (cnt[i] >= 4 && group[2]) {
      cnt[i] -= 4;
      group[2]--;
    }
    while (cnt[i] >= 2 && group[1]) {
      cnt[i] -= 2;
      group[1]--;
    }
    if (cnt[i] >= 1 && group[0]) {
      cnt[i]--;
      group[0]--;
    }
  }

  bool ans = true;
  for (int i = 0; i < 3; i++) {
    if (group[i]) ans = false;
  }
  cout << ( (ans) ? "Yes" : "No" ) << endl;
}


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

using namespace std;

int main() {
    vector<char> v;
    v.push_back('a');
    v.push_back('i');
    v.push_back('u');
    v.push_back('e');
    v.push_back('o');
    char c;
    cin >> c;
    if (find(v.begin(), v.end(), c) != v.end()) {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#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,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
    int n;
    cin >> n;
    int sum = 0, p=1, q=0;
    rep(i, 1, n+1){
        sum += i;
        if(sum > n){
            p = i;
            q = sum - n;
            break;
        }
    }
    rep(i, 1, p+1){
        if(i == q)continue;
        cout << i << endl;
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

int main(){
  int N;
  cin >> N;
  cout << N*800 - (N/15)*200 << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};



int main(){
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    vector<int> query(Q), F(Q);
    vector<char> C(Q);
    for(int i = 0; i < Q; i++){
        int T;
        cin >> T;
        query[i] = T;
        if(T == 2){
            cin >> F[i] >> C[i];
        }
    }
    bool re = false;
    string mae = "";
    string ushiro = "";
    for(int i = 0; i < Q; i++){
        if(query[i] == 1){
            if(re) re = false;
            else re = true;
        }else{
            if((re and F[i] == 1) or (!re and F[i] == 2)) ushiro+=C[i];
            if((re and F[i] == 2) or (!re and F[i] == 1)) mae+= C[i];
        }
    }
    reverse(all(mae));
    string ans = mae + S + ushiro;
    if(re) reverse(all(ans));
    cout << ans << endl;

}

Measured memory_bytes: 5884
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a.at(i);
    long long x=1000;
    long long y=0;
    if(a.at(0)<a.at(1)){
        y+=x/a.at(0);
        x-=(x/a.at(0))*a.at(0);
    }
    for(int i=1;i<n-1;i++){
        if(a.at(i-1)>=a.at(i) && a.at(i)<a.at(i+1)){
            y+=x/a.at(i);
            x-=(x/a.at(i))*a.at(i);
        }
        if(a.at(i-1)<=a.at(i) && a.at(i)>a.at(i+1)){
            x+=a.at(i)*y;
            y=0;
        }
    }
    x+=a.at(n-1)*y;
    cout<<x;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	
	bool ok = true;
	ok &= A + B - 1 <= N;
	ok &= N <= (ll)A * B;
	
	if (!ok) {
		puts("-1");
		return 0;
	}
	
	vector<int> ans;
	int last = 0;
	for (int i = B; i > 0; --i) ans.emplace_back(i);
	
	last = B;
	int dupc = A - 1;
	for (int i = A - 1; i >= 0; --i) {
		int diff = N - ans.size();
		int cur = min(B - 1, diff - i) + 1;
		for (int j = last + cur; j > last; --j) ans.emplace_back(j);
		last = last + cur;
	}
	
	for (int i = 0; i < ans.size() - 1; ++i) printf("%d%c", ans[i], i + 1 == ans.size() ? '\n' : ' ');
	
	return 0;
}


Measured memory_bytes: 3440
N = int(input())
A = list(map(int, input().split()))
rain = []
S = sum(A)
sub = sum(A[1:N:2])
rain.append(S - sub * 2)
while len(rain) != N:
    rain.append(A[len(rain) - 1] * 2 - rain[-1])
for _ in rain:
    print(_)

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

int main(){
  int N,Z,W;
  cin>>N>>Z>>W;
  int a[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  int ans=0;
  
  //N=1のとき
  if(N==1){
    ans=abs(a[0]-W);
    cout<<ans<<endl;
    return 0;
  }
  
  //N>1のとき
  int x1,x2,y1,y2;
  x1=a[N-2];
  y1=a[N-1];
  x2=a[N-1];
  y2=W;
  if(abs(x1-y1)>abs(x2-y2)){
    ans=abs(x1-y1);
  }
  else{
    ans=abs(x2-y2);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3684
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,a[200040];
string s;
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout<<fixed<<setprecision(12);
	cin>>s;
	for(;i<3;i++)
	{
		if(s[i]=='R')
		{
			k++;
			m=max(m,k);
		}
		else k=0;
	}
	cout<<m;
}

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

int main(){
  ll n;
  cin >> n;
  vector<ll> l(100);
  l[0]=2;
  l[1]=1;
  for(int i=2;i<=n;++i){
    l[i]=l[i-1]+l[i-2];
  }
  cout << l[n] << endl;
  return 0;
}


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

int a[MAXN];
int b[MAXN];

int a1[MAXN];
int b1[MAXN];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;

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

	for(int i = 0; i < n; i++)
		cin >> b[i];
	int ans = 0;
	for(int i = 0; i < 29; i++){
		int T = (1 << i);
		for(int i = 0; i < n; i++){
			a1[i] = (a[i]) % (T << 1);
			b1[i] = (b[i]) % (T << 1);
		}
		sort(a1, a1+n);
		sort(b1, b1+n);
		
		int cnt = 0;


		for(int i = 0; i < n; i++){
			cnt += (lower_bound(b1, b1+n, (T << 1) - a1[i]) - lower_bound(b1, b1+n, T - a1[i]));
			cnt += (lower_bound(b1, b1+n, (T << 2) - a1[i]) - lower_bound(b1, b1+n, 3*T - a1[i]));
		}
		if(cnt & 1)
			ans += (1 << i);
	}
	
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define pii 3.14
#define mod (ll)(998244353)
#define inf (ll)(1e18)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(2e5+5)

void solve()
{
    int x,n,y;
    cin>>x>>n;

    set<int> s;
    for(int i=0;i<n;i++)
    {
        cin>>y;
        s.insert(y);
    }

    int ans , mind=500;
    for(int i=0;i<=101;i++)
    {
        if(s.find(i) != s.end())
            continue;
        if(abs(x-i) < mind)
        {
            mind = abs(x-i);
            ans = i;
        }
        else if(abs(x-i) == mind && i<ans)
            ans = i;
    }

    cout<<ans;
}

int main()
{
    fio;
    ll tc = 1;
    //cin>>tc;
    while(tc--)
    {
        solve();
    }
}


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

typedef long long ll;
using namespace std;

// まず山0の降雨を頑張って求め、あとは山1 = 2* A_0 - 山0 ...
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        ll a;
        cin >> a;
        A.at(i) = a;
    }
    ll mt0 = accumulate(A.begin(), A.end(), 0ll);
    for (int j = 1; j <= N - 2; ++ ++j) {
        mt0 -= 2 * A.at(j);
    }
    // 山0が求まった
    cout << mt0 << " ";
    ll lastMtPrecipi = mt0;
    for (int k = 0; k <= N - 2; ++k) { // 最後 Mt(N-1) = 2*A[N-2]-Mt(N-2)
        ll thisMtPrecipi = 2 * A.at(k) - lastMtPrecipi;
        cout << thisMtPrecipi;
        (k == N - 2) ? cout << "\n" : cout << " ";
        lastMtPrecipi = thisMtPrecipi;
    }
    return 0;
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
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;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    int X,N; cin >> X >> N;
    vector<int> P(N);
    set<int> S;
    REP(i,N){
        int p; cin >> p;
        S.insert(p);
        P[i] = p;
    }

    int ans = -1;
    int d = 1e9;

    FORq(q,0,102){
        int nans = 0;
        if (SIN(q,S)) continue;
        nans += abs(X - q);
        if (nans < d){
            d = nans;
            ans = q;
        } 
    }
    cout << ans << endl;
}

Measured memory_bytes: 3548
# ARC100D

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))


n = int(input())
a = list(map(int, input().split()))
ca = [None] * n #ca[i] = a0~aiの和
s = 0
for i,num in enumerate(a):
    s += a[i]
    ca[i] = s

diff = [None] * n

s = 0
t = 1
v1 = 0 # a[:s]
v2 = a[0] # sum(a[s:t])
diff[t-1] = (v1,v2)
while t<n:
#     print(t, v1-v2)
    t += 1
    v2 += a[t-1]
    while v1<v2 and s<t:
        if diff[t-1] is None or abs(v1-v2)<abs(diff[t-1][0] - diff[t-1][1]):
            diff[t-1] = (v1,v2)
        s += 1
        v1 += a[s-1]
        v2 -= a[s-1]
    if diff[t-1] is None or abs(v1-v2)<abs(diff[t-1][0] - diff[t-1][1]):
        diff[t-1] = (v1,v2)        
    if v1>v2 and s>=1:
        v1 -= a[s-1]
        v2 += a[s-1]
        s -= 1

diff2 = [None] * n

s = n
t = n-1
v1 = 0 # sum(a[s:])
v2 = a[-1] # sum(a[t:s])
diff2[t] = (v1,v2)
while t>=1:
    # print(t, v1, v2)
    t -= 1
    v2 += a[t]
    while v1<v2 and s>t:
        if diff2[t] is None or abs(v1-v2)<abs(diff2[t][0] - diff2[t][1]):
            diff2[t] = (v1,v2)
        s -= 1
        v1 += a[s]
        v2 -= a[s]
    if diff2[t] is None or abs(v1-v2)<abs(diff2[t][0] - diff2[t][1]):
        diff2[t] = (v1,v2)        
    if v1>v2 and s<=n-2:
        v1 -= a[s]
        v2 += a[s]
        s += 1
print(min((max(diff[i][0], diff[i][1],diff2[i+1][0],diff2[i+1][1]) - min(diff[i][0], diff[i][1],diff2[i+1][0],diff2[i+1][1])) for i in range(n-1)))

Measured memory_bytes: 94912
N = int(input())
A = list(map(int,input().split()))

ans = [0 for i in range(N)]
for i in range(N-1,-1,-1):
    val = i+1
    if val*2>N:
        if A[i]==0:
            ans[i] = 0
        else:
            ans[i] = 1
    else:
        tmp = 0
        res = val
        while(1):
            if val>N:
                break
            tmp += ans[val-1]
            val += res

        if A[i]==0:
            if tmp%2==0:
                ans[i]=0
            else:
                ans[i]=1
        else:
            if tmp%2==0:
                ans[i]=1
            else:
                ans[i]=0
#print(*ans)
cnt = 0
b=[]
for i in range(N):
    if ans[i]==0:
        continue
    cnt += 1
    b.append(i+1)

print(cnt)
print(*b)


Measured memory_bytes: 107520
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 100005
#define eps 1e-10
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
const int MOD = 998244353;
vector<int> num[7],x,g,t;
int N;
char s[4005];
vector<int> gcd(vector<int> a,vector<int> b) {
	if(a.size() < b.size()) swap(a,b);
	if(b.size() == 1 && b[0] == 0) return a;
	vector<int> d(a.size());
	int t = a.size() - 1;
	for(int i = b.size() - 1 ; i >= 0 ; --i) {
		d[t] = a[t] ^ b[i];
		--t;
	}
	for(int i = t ; i >= 0 ; --i) d[i] = a[i];
	while(d.size() > 1) {
		if(d.back() == 0) d.pop_back();
		else break;
	}
	return gcd(b,d);
}
void Init() {
	read(N);
	scanf("%s",s + 1);
	int len = strlen(s + 1);
	for(int i = len ; i >= 1 ; --i) {
		x.pb(s[i] - '0');
	}
	for(int i = 1 ; i <= N ; ++i) {
		scanf("%s",s + 1);
		len = strlen(s + 1);
		for(int j = len ; j >= 1 ; --j) num[i].pb(s[j] - '0');
	}
	g = num[1];
	for(int i = 2 ; i <= N ; ++i) g = gcd(g,num[i]);
}
void Solve() {
	t = x;
	if(g.size() > x.size()) {out(1);enter;return;}
	int l = x.size() - g.size() + 1;
	int d = x.size() - 1;
	int ans = 0;
	for(int i = 0 ; i < l ; ++i) {
		ans = (1LL * ans * 2 + x[d - i]) % MOD;
	}
	ans = (ans + 1) % MOD;
	for(int i = l ; i < x.size() ; ++i) t[d - i] = 0;
	for(int i = 0 ; i < l ; ++i) {
		if(t[d - i] == 1) {
			int k = g.size() - 1;
			for(int j = 0 ; j < g.size() ; ++j) {
				t[d - i - j] = t[d - i - j] ^ g[k - j];
			}
		}
	}
	for(int i = l ; i < x.size() ; ++i) {
		if(t[d - i] != x[d - i]) {
			if(t[d - i] > x[d - i]) ans = (ans + MOD - 1) % MOD;
			break;
		}
	}
	out(ans);enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Init();
	Solve();
}


Measured memory_bytes: 97664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl

int main(){
    string S; cin>>S;
    for(int i=0; i<S.size(); i++){
        cout<<'x';
    }
    cout<<endl;
}


Measured memory_bytes: 3608
#include <iostream>
using namespace std; //头文件和命名空间
inline bool IsAddable(int iNum, int iLBound, int iUBound){ //判断是否满足要求的函数，iNum-判断的数字；iLBound-各位和下界；iUBound-各位和的上界
    int iSum = 0; //各位和
    while (iNum){ //求各位和
        iSum += iNum % 10; //加上最后一位
        iNum /= 10; //消去最后一位
    }
    return (iLBound <= iSum && iSum <= iUBound); //判断
}
int main(){
    ios::sync_with_stdio(false); //输入输出加速
    int iEnd, iLB, iUB; //区间结尾以及各位数字之和的上下界
    cin >> iEnd >> iLB >> iUB; //读入限制条件
    register int i; //循环变量
    register long long iSum = 0; //累加器
    for (i = 1; i <= iEnd; ++i){ //枚举
        if (IsAddable(i, iLB, iUB)) //判断是否相加
            iSum += i; //若满足则累加
    }
    cout << iSum << endl; //输出和，勿忘换行
    return 0; //结束
}

Measured memory_bytes: 3576
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int K;
	cin >> K;
	cout << a[K - 1] << endl;
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
const ll MOD=1000000007;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const vector<pll> dir={{0,1},{1,0},{-1,0},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}};
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
#define range(i) (i).begin(),(i).end()
#define rrange(i) (i).rbegin(),(i).rend()
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll lcm (ll a,ll b) {return a*b/gcd(a,b);}
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}

vector<ll> func,inv;
void init(ll n){
    func.resize(n+1);inv.resize(n+1);
    func[0]=1;
    rep(i,0,n) {func[i+1]=func[i]*(i+1)%MOD;}
    inv[n]=intpow(func[n],MOD-2);
    rrep(i,1,n+1) {inv[i-1]=inv[i]*i%MOD;}
}
ll comb(ll a,ll b) {return func[a]*inv[b]%MOD*inv[a-b]%MOD;}

inline long double median(vector<ll> v){
    ll size=v.size();
    sort(v.begin(),v.end());
    if (size % 2 == 1) return v[(size - 1) / 2];
    else return v[(size / 2) - 1] ;
}
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;}

int main(){
  ll n,d;
  cin>>n>>d;
  ll ans=n/(2*d+1);
  if(n%(2*d+1)) ans++;
  cout<<ans;  
}


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const int N = 1e5+10;

ll n;
ll k,r,s,p,a[N];
string t;
ll dp[3][N];
map<char, ll> m;

int main () {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin >> n >> k >> r >> s >> p >> t;
  m['s'] = r; m[0] = r;
  m['p'] = s; m[1] = s;
  m['r'] = p; m[2] = p;
  // rep(i,n) {
  //   if(t[i] = 'r') a[i] = 0;
  //   else if(t[i] = 's') a[i] = 1;
  //   else a[i] = 2;
  // }
  rep(i,3) dp[i][0] = 0;
  for(int i = 1; i <= k; i++) {
    ll tt[3] = {0,0,0};
    if(t[i-1] == 's') tt[0] = r;
    else if(t[i-1] == 'p') tt[1] = s;
    else tt[2] = p;
    rep(j,3) {
      dp[j][i] = tt[j];
    }
    // rep(l,3) cout << i << " : " << dp[l][i] << ' ';
    // cout << endl;
    for(int j = i+k; j <= n; j += k) {
      ll tt[3] = {0,0,0};
      if(t[j-1] == 's') tt[0] = r;
      else if(t[j-1] == 'p') tt[1] = s;
      else tt[2] = p;
      dp[0][j] = max(dp[1][j-k] + tt[0], dp[2][j-k] + tt[0]);
      dp[1][j] = max(dp[2][j-k] + tt[1], dp[0][j-k] + tt[1]);
      dp[2][j] = max(dp[1][j-k] + tt[2], dp[0][j-k] + tt[2]);
      // rep(l,3) cout << j << " : " << dp[l][j] << ' ';
      // cout << endl;
    }
  }
  ll result = 0;
  rep(i,k) {
    result += max({dp[0][n-i], dp[1][n-i], dp[2][n-i]});
    // cout << dp[0][n-i] << " : " << dp[1][n-i] << " : " << dp[2][n-i] << "    ";
    // cout << max({dp[0][n-i], dp[1][n-i], dp[2][n-i]}) << endl;
  }
  cout << result << endl;
}


Measured memory_bytes: 2896
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc= new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    char[] s1 = s.toCharArray();
    char[] t1 = t.toCharArray();
    int count=0;
    for(int i=0;i<s.length();i++)
    {
      if(s.charAt(i)!=t.charAt(i))
        count++;
    }
    System.out.println(count);
    
  }
}

Measured memory_bytes: 41636
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

string T[] = { "dream","dreamer","erase","eraser" };
int main()
{
	string S;
	cin >> S;
	reverse(S.begin(), S.end());
	for (int i = 0; i < 4; i++) reverse(T[i].begin(), T[i].end());
	int i = 0;
	while (i < S.size()) {
		bool out = true;
		for (int j = 0; j < 4; j++) {
			if (i + T[j].size() > S.size()) continue;
			string tmp = S.substr(i, T[j].size());
			if (tmp == T[j]) {
				out = false;
				i += T[j].size();
				break;
			}
		}
		if (out) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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 mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n, k;
    cin >> n >> k;
    vector<int> p;
    map<int, int> mp;
    rep(i,n){
        int a;
        cin >> a;
        mp[a]++;
    }
    for(auto e : mp){
        p.push_back(e.second);
    }
    sort(p.begin(), p.end());
    int ans = 0;
    int b = mp.size() - k;
    if(b >= p.size()){cout << 0 << endl;return 0;}
    rep(i,b){
        ans += p[i];
    }
    cout << ans <<endl;
}

Measured memory_bytes: 10748
import java.util.*;
public class Main {
  	static int mod = 1000000007;
  static int size = 200001;
	static long[] fac = new long[size];
	static long[] finv = new long[size];
	static long[] inv = new long[size];
	static int INF = Integer.MAX_VALUE;
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	// 整数の入力
	int N = sc.nextInt();
	int[] A = new int[N];
  int[] B = new int[N];
  int[] C = new int[N-1];
  int i=0;
  int sum=0;
  int befor=-1;
  for(i=0;i<N;i++){
    A[i]=sc.nextInt();
  }
  for(i=0;i<N;i++){
    B[i]=sc.nextInt();
  }
  for(i=0;i<N-1;i++){
    C[i]=sc.nextInt();
  }
  sum=B[A[0]-1];
  for(i=1;i<N;i++){
    sum=sum+B[A[i]-1];
    befor=A[i-1];
    if(befor+1==A[i]){
      sum=sum+C[befor-1];
    }
  }
    System.out.println(sum);



} 

 //fac, inv, finvテーブルの初期化、これ使う場合はinitComb()で初期化必要
	public static  void initComb(){
		fac[0] = finv[0] = inv[0] = fac[1] = finv[1] = inv[1] = 1;
		for (int i = 2; i < size; ++i) {
			fac[i] = fac[i - 1] * i % mod;
			inv[i] = mod - (mod / i) * inv[(int) (mod % i)] % mod;
			finv[i] = finv[i - 1] * inv[i] % mod;
		}
	}
 
	//nCk % mod
	public static long comb(int n, int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
		return fac[n] * finv[k] % mod * finv[n - k] % mod;
	}
 
	//n! % mod
	public static long fact(int n){
		return fac[n];
	}
 
	//(n!)^-1 with % mod
	public static long finv(int n){
		return finv[n];
	}
  
}

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

int main(void) {
  int N, L;
  string S[110];
  
  cin >> N >> L;
  for (int i = 0; i < N; i++) cin >> S[i];
  
  sort(S, S+N);
  int sum = 0;
  for (int i = 0; i < N; i++) cout << S[i];
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;

int main() {
    int a; cin >> a;
    cout << a + a * a  + a * a * a << endl;
}




Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
ll gcd(ll a,ll b){
    return b==0?a:gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}

ll extgcd(ll a,ll b,ll &x,ll &y){
    if(!b){
        x=1;y=0;
        return a;
    }
    ll d=extgcd(b,a%b,y,x);
    y-=a/b*x;
    return d;
}
int main(){
    int n,m;
    cin>>n>>m;
    vi vec(n);
    REP(i,n){
        cin>>vec[i];
    }
    int ans=abs(m-vec[0]);
    REP(i,n){
        ans=gcd(ans,abs(m-vec[i]));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp {
    char name[100];
    int t; 
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
	Q[tail] = x;
	tail = (tail + 1) % LEN;
} 

P dequeue() {
	P x = Q[head];
	head = (head + 1) % LEN;
    return x;
}

int min(int a, int b) {
	return a < b ? a : b;
}

int main() {
	int elaps = 0, c;
	int i, q;
	P u;
	scanf("%d %d", &n, &q);
	
	for (i=1; i<=n; i++) {
		scanf("%s", &Q[i].name);
	    scanf("%d", &Q[i].t);
	}
	head = 1; tail = n+1;
	
	while (head != tail) {
		u = dequeue();
		c = min(q, u.t);
		u.t -= c;
		elaps += c;
		if (u.t> 0) enqueue(u);
		else {
			printf("%s %d\n", u.name, elaps);
		}
	}
	return 0;
}

Measured memory_bytes: 12848
#include <iostream>

int main()
{
    long long N, K;
    std::cin >> N >> K;

    if(K == 0){
        std::cout << N*N << std::endl; return 0;
    }
    
    long long count = 0;
    for(int i=K+1; i<=N; i++){
        count += (N / i) * (i - K);
        count += (N % i) >= K ? (N % i) - K + 1 : 0;
        // printf("%d %lld\n", i, count);
    }

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

Measured memory_bytes: 256