akhauriyash/Code-Regression huggingface dataset:
///
// File:  2399.cpp
// Author: ymiyamoto
//
// Created on Mon Nov 13 21:04:52 2017
//

#include <algorithm>
#include <array>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int32_t main()
{
  while (true) {
    uint32_t N;
    cin >> N;

    if (N == 0) break;

    array<vector<uint32_t>, 101> mem;

    for (uint32_t i = 1; i <= N; i++) {
      uint32_t n;
      cin >> n;
      for (uint32_t j = 0; j < n; j++) {
        uint32_t m;
        cin >> m;
        mem[i].push_back(m);
      }
      sort(mem[i].begin(), mem[i].end());
    }

    vector<uint32_t> dis;
    uint32_t n;
    cin >> n;
    for (uint32_t i = 0; i < n; i++) {
      uint32_t m;
      cin >> m;
      dis.push_back(m);
    }
    sort(dis.begin(), dis.end());

    int32_t m = -1;
    for (uint32_t i = 1; i <= N; i++) {
      uint32_t all_found = true;
      for (uint32_t j = 0; j < dis.size(); j++) {
        uint32_t found = false;
        for (uint32_t k = 0; k < mem[i].size(); k++) {
          if (dis[j] == mem[i][k]) {
            found = true;
          }
        }
        all_found &= found;
      }

      if (all_found) {
        if (m != -1) {
          m = -1;
          break;
        } else {
          m = i;
        }
      }
    }
    cout << m << endl;
  }

  return 0;
}

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  for(int i=1;i<=9;i++){
    if(n<=111*i){
      cout << 111*i << endl;
      return 0;
    }
  }
  return 0;
}


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

typedef pair<int, int> ii;
const int maxn = 5e5 + 5;

int N;
int A[maxn], B[maxn];
int dA[maxn], dB[maxn];
vector<ii> G[maxn];
int on[maxn], U[maxn], V[maxn], id = 0;
int pairEdge[maxn];

int addEdge(int u, int v) {
	// cout << u << " " << v << endl;
	++id;
	U[id] = u, V[id] = v;
	G[u].push_back(ii(id, v));
	G[v].push_back(ii(id, u));
	return id;
}

void addToPar(int par[], int v, int offset) {
	if (par[v] == -1) addEdge(v + offset, 0);
	else addEdge(v + offset, par[v] + offset);
}

void dfs(int v, int ed) {
	on[ed] = (U[ed] == v ? -1 : 1);
	while (G[v].size()) {
		int u, w; tie(w, u) = G[v].back(); G[v].pop_back();
		if (on[w]) continue;
		dfs(u, w);
	}
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> N;
	for (int i = 1; i <= N; ++i) {
		cin >> A[i];
		if (A[i] != -1) ++dA[A[i]];
	}
	for (int i = 1; i <= N; ++i) {
		cin >> B[i];
		if (B[i] != -1) ++dB[B[i]];
	}
	for (int i = 1; i <= N; ++i) {
		if (dA[i] % 2 != dB[i] % 2) return cout << "IMPOSSIBLE\n", 0;
		if (dA[i] % 2 == 0) pairEdge[i] = addEdge(i, i + N);
	}
	for (int i = 1; i <= N; ++i) {
		addToPar(A, i, 0); addToPar(B, i, N);
	}
	dfs(0, 0);
	printf("POSSIBLE\n");
	for (int i = 1; i <= N; ++i) {
		if (dA[i] % 2 == 1) printf("0 ");
		else printf("%d ", on[pairEdge[i]]);
	}
	printf("\n");
}

Measured memory_bytes: 38400
// olaf_surgut
//        _        __                             _   
//   ___ | | __ _ / _|  ___ _   _ _ __ __ _ _   _| |_ 
//  / _ \| |/ _` | |_  / __| | | | '__/ _` | | | | __|
// | (_) | | (_| |  _| \__ \ |_| | | | (_| | |_| | |_ 
//  \___/|_|\__,_|_|___|___/\__,_|_|  \__, |\__,_|\__|
//                |_____|             |___/           
//
#pragma optimize ("Ofast")
#include <bits/stdc++.h>
#define st  first
#define nd  second
#define ll  long long
#define INF 1000000005LL
using namespace std;

void solve(){
  long double a, b;
  cin >> a >> b;
  cout << fixed << setprecision(0) << floor(a * b) << '\n';  
}

int main(){
#ifndef LOCAL
  ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
#endif
  int _ = 1;
  // cin >> _;
  while(_--)solve();
}

Measured memory_bytes: 3812
N=input()
a=map(int,raw_input().split())
d={}
for i in a:
        d[i]=1+d.get(i,0)
        d[i-1]=1+d.get(i-1,0)
        d[i+1]=1+d.get(i+1,0)
print max(d.values())

Measured memory_bytes: 16360
#include<iostream>
#include<vector>
#include<queue>
#include <bitset>
using namespace std;
template< typename FirstType, typename SecondType >
struct PairComparator {
  bool operator()( const pair<FirstType, SecondType>& p1, const pair<FirstType, SecondType>& p2 ) const 
    {  
		return p1.first > p2.first;
    }
};
bool inMST(vector< std::pair<int,int> > & MST,int j) {
	for (int k=0;k<(int)MST.size();++k){
		if(j == MST[k].second)
			return true;
	}
	return false;
}
int main(){
	int n;
	cin >> n;
	//vector<int> E(n*n,-1);
	vector<vector<pair<int,int> > > edge(n);
	vector<int> DPG(n,-1);
	vector< std::pair<int,int> > MST;
	std::bitset<10000> flg;

	{
		for(int j=0;j<n;++j) {
			int u,k; 
			cin >> u >> k;
			edge[u].resize(k);
			for(int i=0;i<k;++i){
				int v,c;
				cin >> v >> c;
				edge[u][i] = make_pair(v,c);
			}
		}
	}
	priority_queue<pair<int,pair<int,int> >,vector< pair<int,pair<int,int> > >,
		PairComparator<int,pair<int,int> > > r;

	int cost = 0;
	int i=0;
	MST.push_back(pair<int,int>(i,i));
	flg.set(i);
	DPG[i] = 0;
	while((int)MST.size() < n) {
		int ii=i*n;
//		for (int j=0;j<n;++j) 
		for (int p=0;p<(int)edge[i].size();++p)
		{
			pair<int,int> add = std::make_pair(i,edge[i][p].first);
//			if (!inMST(MST,add.second))
			if (!flg.test(edge[i][p].first))
			{
				r.push(std::pair<int,std::pair<int,int> >(edge[i][p].second+DPG[i],add));
			}
		}
		pair<int,pair<int,int> > top;
		while (!r.empty()) {
			top = r.top();
			r.pop();
//			if (!inMST(MST,top.second.second))
			if (!flg.test(top.second.second))
			{
				break;
			}
		}
		cost += top.first;
		MST.push_back(top.second);
		flg.set(top.second.second);
		i = top.second.second;
		DPG[i] = top.first;
//		for(int j=0;j<n;++j)
		for (int p=0;p<(int)edge[i].size();++p)
		{
			int j = edge[i][p].first;
			if (DPG[j] < 0)continue;
			DPG[j] = std::min(DPG[j],DPG[i] + edge[i][p].second);
		}
	}
	for (int j=0;j<n;++j) {
		cout << j << " " <<  DPG[j] << endl;
	}
}

Measured memory_bytes: 9600
#include<stdio.h>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>b){
        printf("a > b\n");
    }else if(a<b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2100
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def main():
    N = I()
    A = []
    B = []
    ans = 0

    for i in range(N):
        a, b = MI()
        A.append(a)
        B.append(b)

    A.sort()
    B.sort()

    if N % 2 == 1:
        mid = N // 2
        print(B[mid] - A[mid] + 1)
    else:
        mid1 = N // 2
        mid2 = mid1 - 1
        r = B[mid1] + B[mid2]
        l = A[mid1] + A[mid2]
        print(r - l + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26284
package main

import "fmt"

func main() {
	var N, M int
	var tmp string
	m := make(map[string]int)
	fmt.Scan(&N)
	for i := 0; i < N; i++ {
		fmt.Scan(&tmp)
		m[tmp]++
	}
	fmt.Scan(&M)
	for i := 0; i < M; i++ {
		fmt.Scan(&tmp)
		m[tmp]--
	}
	c := 0
	for _, v := range m {
		if v > c {
			c = v
		}
	}
	fmt.Println(c)
}


Measured memory_bytes: 512
# ABC151 C
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))
from collections import defaultdict
n,m=map(int, input().split())
ac=set()
ac_cnt=0
wa_cnt=0
d_ac=defaultdict(int)
d_wa=defaultdict(int)
for i in range(m):
    p,s=nm()
    if s=='AC':
        if int(p) in ac:
            continue
        ac.add(int(p))
        ac_cnt+=1
    elif s=='WA':
        if int(p) in ac:
            continue
        d_wa[p]+=1

for a in ac:
    wa_cnt+=d_wa[str(a)]

print(ac_cnt,wa_cnt)



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

int main(){
  int a, b;
  cin >> a >> b;
  int ans = max(a+b, a-b);
  ans = max(ans, a*b);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
X=int(input())
Y=0
if X>=400 and X<=599:
  Y=8
elif X>=500 and X<=799:
  Y=7
elif X>=800 and X<=999:
  Y=6
elif X>=1000 and X<=1199:
  Y=5
elif X>=1200 and X<=1399:
  Y=4
elif X>=1400 and X<=1599:
  Y=3
elif X>=1600 and X<=1799:
  Y=2
elif X>=1800 and X<=1999:
  Y=1

print(Y)

Measured memory_bytes: 9120
#include<iostream>
using namespace std;
#define MAX 10
#define floor 3
#define rooms 10
#define line 20

int main()
{
	int b,f,r,v,n,i,j;
	int first[3][MAX]={0};
	int second[3][MAX]={0};
	int third[3][MAX]={0};
	int fourth[3][MAX]={0};
	char str;

	cin >> n;
	for(i=0;i<n;i++)
	{
		cin >> b >> f >> r >> v;

		if(b==1)
		{
			first[f-1][r-1] += v ;
		}

		else if(b==2)
		{
			second[f-1][r-1] += v ;
		}
			
		else if(b==3)
		{
			third[f-1][r-1] += v ;
		}
	
		else
		{
			fourth[f-1][r-1] += v ;
		}
	}

	for(i=0;i<floor;i++)
	{
		for(j=0;j<rooms;j++)
		{
			cout << ' ' <<first[i][j]  ;
		}

		cout << endl ;
	}

	for(i=0;i<line;i++)
	{
		cout << '#' ;
	}

	cout << endl ;

	for(i=0;i<floor;i++)
	{
		for(j=0;j<rooms;j++)
		{
			cout << ' ' << second[i][j] ;
		}

		cout << endl ;
	}

	for(i=0;i<line;i++)
	{
		cout << '#' ;
	}

	cout << endl ;

	for(i=0;i<floor;i++)
	{
		for(j=0;j<rooms;j++)
		{
			cout << ' ' << third[i][j] ;
		}

		cout << endl ;
	}

	for(i=0;i<line;i++)
	{
		cout << '#' ;
	}

	cout << endl ;
	
	for(i=0;i<floor;i++)
	{
		for(j=0;j<rooms;j++)
		{
			cout << ' ' << fourth[i][j]  ;
		}

		cout << endl ;
	}

	return 0;
}

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

int main()
{
    int a,b,k;
    scanf("%d%d%d",&a,&b,&k);
    int len = b - a + 1;
    int vo = b - k + 1;
    int cnt = 1;
    for(int i = a; i <= b; i++)
    {
        if(cnt <= k)
        {
            printf("%d\n",i);
            cnt++;
        }
        else if(i >= vo)
        {
            printf("%d\n",i);
        }

    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int in;
  while(cin>>in,in){
    double mini=1e9;
    rep(i,in/500+1){
      if(in-i*500>=0)rep(j,(in-i*500)/300+1){
      if(in-i*500-j*300>=0)rep(k,(in-i*500-j*300)/200+1){
          if(in!=i*500+j*300+k*200)continue;
          //          cout<<i<<" "<<j<<" "<<k<<endl;
          double sum=850*(i%3)+850*(i/3)*3*0.88;
          sum+=550*(j%4)+550*(j/4)*4*0.85;
          sum+=380*(k%5)+380*(k/5)*5*0.80;
          mini=min(mini,sum);
          //          cout<<i<<" "<<j<<" "<<k<<" "<<sum<<endl;
        }
    }
    }
    cout<<(int)mini<<endl;
  }
 
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

typedef long long ll;
typedef pair<int, int> ii;

ll n, s;

ll calc(ll b){

	ll tmp = n;
  ll ret = 0;
  while(tmp != 0){
      ret += tmp % b;
      tmp /= b;
	}
  return ret;
}

int main() {

	cin >> n >> s;

	if(n == s){
		cout << n+1 << endl;
		return 0;
	}

	if(n <= 1000){
		for(ll i = 2; i < n+1; i++){
			if(calc(i) == s){
				cout << i << endl;
				return 0;
			}
		}
		cout << -1 << endl;
		return 0;
	}

	ll cnt = 1;
	ll target = n / cnt;
	ll next = n / (cnt + 1);
	ll ans = LLINF;
	while(target > next + 1){
		ll tmp = calc(target);
		if(s >= tmp && (s - tmp) % cnt == 0 && (s - tmp) / cnt < target - next) ans = target - (s - tmp) / cnt;
		cnt++;
		target = next;
		next = n / (cnt + 1);
	}
	for(ll i = 2; i < target + 1; i++){
		if(calc(i) == s){
			cout << i << endl;
			return 0;
		}
	}

	if(ans == LLINF) cout << -1 << endl;
	else cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
<?php

for ($i = 0; $i < 10; $i++) {
    $w[] = trim(fgets(STDIN));
}
for ($i = 0; $i < 10; $i++) {
    $k[] = trim(fgets(STDIN));
}
rsort($w);
rsort($k);

echo array_sum(array_slice($w, 0, 3)) ." ". array_sum(array_slice($k, 0, 3)) . PHP_EOL;


Measured memory_bytes: 9224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vp;
typedef vector<vp> vpp;
typedef vector<vector<ll> > graph;
#define pb push_back
#define mp make_pair
#define maxi INT_MAX
#define mini INT_MIN
#define endl '\n'
void set_val(vector<ll>& v, ll val){for(ll i=0;i<v.size();i++) v[i]=val;}

ll mod = pow(10,9) + 7;
ll modulo = 998244353;
ll i_mov[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
ll j_mov[8] = {1, 1, 1, 0, -1, -1, -1, 0};

vector<vector<int>> g;
vector<int> parent, depth, subsize;

ll power(ll a, ll n)
{
    if(n==0)
    return 1;
    ll temp = power(a,n/2);
    if(n%2==0)
    return (temp*temp)%mod;
    return (((temp*temp)%mod)*a)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // cout<<fixed;
    // cout<<setprecision(18);
    ll n, k;
    cin>>n>>k;
    cout<<min(n%k, k-n%k);
    
}

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

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    int flag = 0;
    if(A == 7){
        if(B == 5 && C == 5) flag++;
    }
    if(B == 7){
        if(A == 5 && C == 5) flag++;
    }
    if(C == 7){
        if(B == 5 && A == 5) flag++;
    }

    if(flag == 1) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int N,i,j,A[100],flag=1,B,count=0;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  while(flag){
    flag=0;
    for(j=N-1;j>0;j--){
      if(A[j] < A[j-1]){
	B=A[j];
	A[j]=A[j-1];
	A[j-1]=B;
	flag=1;
	count++;
      }
    }
  }
  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i != N-1)
      printf(" ");
    else printf("\n");
  }
  printf("%d\n",count);
  return 0;
}


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

int searchQ(int A[],int n,int key){
	int i=0;
	A[n] = key;
	while(A[i]!=key) i++;
	return i!=n;
}

int main() {
	
	int n,A[10000+1],q,key,sum=0;
	
	cin>>n;
	for(int i=0;i<n;i++) cin>>A[i];
	
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>key;
		sum+=searchQ(A,n,key);
	} 
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3120
#include <stdio.h>

int main(void) {
  char a[1000], b[1000], c;
  int i, j , k, t;
  
  while (scanf("%s", a) != EOF) {
    j = 0;
    for (i = 0; a[i] != '\0'; i++) {
      if (a[i] != '@') 
	b[j++] = a[i];
      else {
	t = a[i+1] - '0';
	c = a[i+2];
	for (k = 0; k < t; k++) 
	  b[j++] = c;
	i += 2;
      }
    }
    b[j] = '\0';
    printf("%s\n", b);
  }
  return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>
struct Monster {
	int position; long long int health;
};
int main() {
	int n, range; long long int damage; std::cin >> n >> range >> damage;
	std::vector<Monster> monsters(n); for (auto& m : monsters) std::cin >> m.position >> m.health;
	std::sort(monsters.begin(), monsters.end(), [](const Monster a, const Monster b) {return a.position < b.position; });
	std::queue<std::pair<int, int>> queue;
	long long int count = 0, sum = 0;
	for (auto m : monsters) {
		while (!queue.empty() && queue.front().first + range < m.position) {
			count -= queue.front().second;
			queue.pop();
		}
		m.health -= count * damage;
		if (m.health > 0) {
			queue.emplace(m.position + range, (m.health + damage - 1) / damage);
			count += (m.health + damage - 1) / damage;
			sum += (m.health + damage - 1) / damage;
		}
	}
	std::cout << sum << std::endl;
}

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

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

using namespace std;
using lint=long long;

int main(){
	lint k,a,b; cin>>k>>a>>b;
	lint ans=k+1;
	if(k>=a-1){
		k-=a-1;
		ans=max(ans,a+k/2*(b-a)+k%2);
	}
	cout<<ans<<'\n';
	return 0;
}


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

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


int main()
{
    int a,b;
    scanf("%d\n%d",&a,&b);
    if(a<=8&&b<=8)
    {
        printf("Yay!\n");
    }
    else printf(":(");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  char array[4] ;
  char a,b;
  int flag = 1;

  scanf("%s",array);
  a = array[0];

  if(a != array[1]){
    b = array[1];

  if(a != array[2] && b != array[2])
    flag = 0;

  if(a != array[3] && b != array[3])
    flag = 0;

  if(a == b)
    flag = 0;
  }
  else {
    b = array[2];
    if(b != array[3])
      flag = 0;
    if(a == b)
      flag = 0;
  }

  if(flag == 0)
    printf("No\n");
  else
    printf("Yes\n");


  return 0;
}


Measured memory_bytes: 128
S = input()

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

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

print(sum(ans))


Measured memory_bytes: 24100
N, K = gets.split(' ').map(&:to_i)
R, S, P = gets.split(' ').map(&:to_i)
T = gets.chomp
# r グー, s チョキ p パー
result = 0
N.times do |i|

  rsp = T[i]
  skips = {}
  if i < K || rsp != T[i-K]
    if rsp == "r"
      result += P
    elsif rsp == "s"
      result += R
    else
      result += S
    end
  else
    T[i] = "!"
  end
end
puts result

Measured memory_bytes: 2044
a = [0 for i in range(51)]
for i in range(10):
  for j in range(10):
    for k in range(10):
      for l in range(10):
        a[i + j + k + l] += 1
while True:
  try:
    n = int(input())
    print(a[n])
    
  except EOFError:
    break


Measured memory_bytes: 5596
#include<iostream>
#include<algorithm>
#include<cstdio>
#define c 13
using namespace std;

int main()
{
	int  b ,n, i, S[c] = { 0 }, H[c] = { 0 }, C[c] = { 0 }, D[c] = { 0 };
	char a;

	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> a >> b;
		if (a == 'S') S[b-1] = 1;
		if (a == 'H') H[b-1] = 1;
		if (a == 'C') C[b-1] = 1;
		if (a == 'D') D[b-1] = 1;
	}

	for (i = 0; i < c; i++)
	{
		if (S[i] == 0)cout << "S " << i+1 << endl;
	}
	for (i = 0; i < c; i++)
	{
		if (H[i] == 0)cout << "H " << i+1 << endl;
	}
	for (i = 0; i < c; i++)
	{
		if (C[i] == 0)cout << "C " << i+1 << endl;
	}
	for (i = 0; i < c; i++)
	{
		if (D[i] == 0)cout << "D " << i+1 << endl;
	}
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

void solve() {
	int a,b,h;
	cin >> a;
	cin >> b;
	cin >> h;
	
	cout << (min(a,b)*h) + ((max(a,b)-min(a,b))*h)/2 << endl;
}
		
			
		

int32_t main() {
	IOS;
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;
ll func(ll a)
{
  if(a < 0)
  {
    return func(a+MOD);
  }
  else
  {
    return a%MOD;
  }
}
ll power(ll x,ll y,ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}
int main()
{
  int n;
  cin>>n;
  ll a = power(10,n,MOD);
  ll b = power(8,n,MOD);
  ll c = power(9,n,MOD);
  cout<<func(a+b-2*c)<<"\n";
}

Measured memory_bytes: 3616
local n, m = io.read("*n", "*n")
local left, right = {}, {}
local idx = {}
for i = 1, m do
  left[i], right[i] = io.read("*n", "*n")
  idx[i] = i
end
local function sortfunc(a, b)
  if right[a] == right[b] then
    return left[a] < left[b]
  else
    return right[a] < right[b]
  end
end
table.sort(idx, sortfunc)

local cnt = 0
local curleft = 1
for i = 1, m do
  local l, r = left[idx[i]], right[idx[i]]
  if curleft <= l then
    curleft = r
    cnt = cnt + 1
  end
end
print(cnt)


Measured memory_bytes: 6520
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K;
    cin >> K;
    ll num[32] = {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};
    ll ans = num[K - 1];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ll long long
#define pb push_back
#define PII pair<int,int>
#define X first
#define Y second
#define MP make_pair
#define PI acos(-1.0)
#define eps 1e-8
const int maxn=3e5+10;
const int maxm=1.5e7+10;
const int mod=1e9+7;
using namespace std;

ll a,b,c;

int main()
{
    scanf("%lld%lld%lld",&a,&b,&c);
    if(4*a*b<(c-a-b)*(c-a-b)&&(c-a-b)>0)
        printf("Yes");
    else 
        printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
typedef vector<Int> veci;
typedef vector<double> vecd;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<pii> vecpii;
typedef vector<veci> mati;
typedef vector<vecd> matd;
#define A first
#define B second
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(auto i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
#define DUMP(a) do { std::cout << #a " = " << (a) << ", "; } while(false)
#define DUMPLN(a) do { std::cout << #a " = " << (a) << std::endl; } while(false)
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
template<typename T> vector<T> getVector(const int n) { return vector<T>(n); }
template<typename T> vector<T> getVector(const int n, const T a) { return vector<T>(n, a); }
template<typename T> vector<T> getEmptyVector() { return vector<T>(); }
template<typename T> void appendAll(vector<T> &a, vector<T> b) { a.insert(a.end(), b.begin(), b.end()); }
// #define X first
// #define Y second
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const ll MOD = 1000000007;
const int MAXN = 1<<17;
const int inf = 1<<28;
const int NIL = -inf;
int popcount(int x)  { return __builtin_popcount(x); }



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    veci A(N);
    FORO(i, N) {
        cin >> A[i];
    }
    for(int i = K;i < N;i++) {
        if(A[i - K] < A[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

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

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

  int n,m;
  cin >> n >> m;
  int lmax = 0;
  int rmin = 99999999;
  int l,r;
  REP(i, m) {
    cin >> l >> r;
    lmax = max(l, lmax);
    rmin = min(r, rmin);
  }

  if(lmax > rmin || lmax > n) {
    cout << 0 << endl;
  } else {
    cout << min(rmin, n) - min(lmax, n) + 1 << endl;
  }
  return 0;
}


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

using namespace std;

#define debug(x) cout << '[' << #x << " is: " << x << "] " << '\n';
#define imod(a , n) (a % n + n ) % n

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define inF freopen("milkvisits.in","r",stdin );
#define outF freopen("milkvisits.out" , "w" , stdout ) ;
#define sor(v) sort(v.begin() , v.end());
#define print(v) for(auto f : v ) cout << f << " " ;
#define rsor(v) sort(v.rbegin() , v.rend());
#define rev(v) reverse(v.begin() , v.end());
#define lp(i , n) for(int x = i ; x < n ; x ++)
#define ll long long
#define read(arr , x , n) for(int i = x ; i < n ; i ++ )cin >> arr[i];
const double eps = 1e-6 , PI = acos(-1) ;
const long long OO = 1e18 ;
const ll N = 22  , oo = 1e9 + 1  , M = 2000002, mod = 1e9 + 7 , K = 12;


//                                                +_+
int32_t main(){
    // inF;outF;
    fastio;
    // Dont Forget memset
    ll n , sum = 0 ;
    cin >> n ;
    vector<ll>v(n);
    for(auto &it : v){
        cin >> it ;
        sum += it ;
    }
    ll ans = 0 ;
    for(auto f : v){
        sum -= f ;
        ans += (sum % mod ) * f ;
        ans %= mod ;
    }
    cout << ans ;
}


Measured memory_bytes: 4772
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String line = sc.next();
		char[] s = line.toCharArray();
		line = sc.next();
		char[] t = line.toCharArray();
		String ans = "";
		for(int i = 0; i < n; i++){
			ans += s[i];
			ans += t[i];
		}
		System.out.println(ans);
	}
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k, p, m, y;
string s, t;
ld w;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> k;
	ll ans = 0;
	
	for(ll i=1;i<=n;i++) {
		ll q = (n )/i;
		ll r = n%i;
		
		if((i-1) < k) continue;

		//cout<<q<<" "<<r;newl;
		//if(r==0) r=i;
		ans += min(n,(q)*(i-k) + max(0ll,(r - k + 1)));
		
		//cout << (q)*(i-k) << " " << max(0ll,(r - k + 1));newl; 
		//cout<<ans<<" ";newl;
	}
	cout<<ans;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

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

int main(){
    int coin[6] = {1, 5, 10, 50, 100, 500};

    int ideal[500] = {};
    for(int i = 1; i < 500; i++){
        int tmp = i;
        for(int j = 5; j >= 0; j--){
            ideal[i] += tmp/coin[j];
            tmp %= coin[j];
        }
    }

    int p, n[6];
    while(cin >> p, p){
        for(int i = 0; i < 6; i++)  cin >> n[i];
        int ans = 100000;
        for(int i = 0; i < 500; i++){
            int pay = 0, tmp = p+i;
            for(int j = 5; j >= 0; j--){
                int use = min(n[j], tmp/coin[j]);
                pay += use;
                tmp -= coin[j]*use;
            }
            if(tmp) break;
            ans = min(ans, pay+ideal[i]);
        }
        cout << ans << endl;
    }

    return 0;
}


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

typedef long long int Long;
typedef long double Double;
const int MAXN = 1e5 + 4;

int n, ans, k, x;
map<int, int> M;
set<pair<int, int>> S;

int main() {
	scanf("%d%d", &n, &k);
	while(n--) {
		scanf("%d", &x);
		++M[x];
	}

	if(k >= (int) M.size())
		return 0 * puts("0");

	for(auto p : M)
		S.emplace(p.second, p.first);

	int need = ((int) M.size()) - k;
	ans = 0;
	while(need-- && S.size()) {
		auto p = S.begin();
		S.erase(p);

		ans += p->first;
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 18944
while True:
	n = int(input())
	if n == 0:
		break
	a = [list(map(int, input().split())) for i in range(n)]
	t = [[0 for i in range(n + 1)] for i in range(n + 1)]
	for i in range(n):
		for j in range(n):
			t[i][j] = a[i][j]
			t[i][n] += a[i][j]
			t[n][j] += a[i][j]
			t[n][n] += a[i][j]
	for i in range(n + 1):
		print("".join(map("{0:>5}".format,t[i])))

Measured memory_bytes: 7748
n = int(input())
a = []

for i in range(n):
    a.append(int(input()))

maxa = max(a)
maxcnt = 0
maxidx = 0

for i in range(n):
    if maxcnt == 0:
        maxidx = i
    if a[i] == maxa:
        maxcnt += 1
    


for i in range(n):
    if maxcnt == 1 and i == maxidx:
        a[maxidx]=0
        print(max(a))
    else:
        print(maxa)

Measured memory_bytes: 12520
import java.util.*;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int cnt = 0;
		for (int i = 1; i < n ; i++) {
			List<String> l = new ArrayList<>();
			String a = s.substring(0,i);
			String b = s.substring(i);
			int c = 0;
			if (i < n / 2) {
				for (int k = 0 ; k < a.length() ; k++) {
					String t = a.substring(k, k+1);
					if (b.contains(t) && !l.contains(t)) {
						c++;
						l.add(t);
					}
				}
			} else {
				for (int k = 0 ; k < b.length() ; k++) {
					String t = b.substring(k, k+1);
					if (a.contains(t) && !l.contains(t)) {
						c++;
						l.add(t);
					}
				}
			}
			if (cnt < c) {
				cnt = c;
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 23764
#pragma region head
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using vv = vector<vector<T>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rrepi(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bit(n) (1LL << (n))
template <class T>
inline bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const int INF = 1002003004;
const ll LINF = 1002003004005006007ll;
struct preprocess {
    preprocess() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} ____;
#pragma endregion head

#pragma region library
struct RollingHash {
    using u64 = uint_fast64_t;
    using i128 = __int128_t;
    const u64 MOD = (1ul << 61) - 1;
    string str;
    u64 base;
    vector<u64> hashval, pow;

    u64 mul(i128 x, i128 y) const {
        i128 tmp = x * y;
        tmp = (tmp >> 61) + (tmp & MOD);
        if (tmp >= MOD) return tmp - MOD;
        return tmp;
    }

    RollingHash(const string &str, u64 base = 86637781) : str(str), base(base) {
        int sz = str.length();
        hashval.resize(sz + 1);
        pow.resize(sz + 1);
        pow[0] = 1;
        for (int i = 0; i < sz; i++) {
            hashval[i + 1] = mul(hashval[i], base) + str[i];
            pow[i + 1] = mul(pow[i], base);
            if (hashval[i + 1] >= MOD) hashval[i + 1] -= MOD;
        }
    }

    u64 hash() const {
        return hashval.back();
    }
    u64 hash(int l, int r) const {
        u64 res = MOD + hashval[r] - mul(hashval[l], pow[r - l]);
        if (res >= MOD) return res - MOD;
        return res;
    }
    int LCP(int a, int b) const {
        int len = (int)hashval.size() - max(a, b);
        int ok = 0, ng = len;
        while (ok + 1 < ng) {
            int m = (ok + ng) / 2;
            if (hash(a, a + m) == hash(b, b + m))
                ok = m;
            else
                ng = m;
        }
        return ok;
    }
};
#pragma endregion library

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

    RollingHash rh(s);
    int ans = 0;
    rep(i,n)rep(j,i){
        int lcp = rh.LCP(i,j);
        lcp = min(lcp, i-j);
        chmax(ans, lcp);
    }
    cout << ans << '\n';
    
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int day;
  if(s=="SUN") day=7;
  if(s=="MON") day=6;
  if(s=="TUE") day=5;
  if(s=="WED") day=4;
  if(s=="THU") day=3;
  if(s=="FRI") day=2;
  if(s=="SAT") day=1;
  cout << day << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long double X[200100];
int N;
long long Count(long double len)
{
  long long Ans=0;
  for(int i=0;i<N;i++)
  {
    Ans+=(long long)(X[i]/len);
    //Ans+= (ceil(X[i])-1/len);
  }
  return Ans;
}
int main()
{
  long long K;
  cin>>N>>K;
  for(int i=0;i<N;i++)
{
	cin>>X[i];
	//X[i]-=0.1;
}
  long double l=1,r=1e9;
  //while(l<r-0.1)
	for(int i=0;i<35;i++)
  //while(((long long)(r)-(long long)(l)) > 1)
  //while(!((ceil(r)-ceil(l)) == 0))
  {
    //long double mid=(l+r+0.1)/2;
    long double mid=(l+r)/2;
  //  cout<<l<<" "<<r<<" "<<mid<<endl;
    if(Count(mid)<=K) r=mid;
    else	l=mid;
    //else	l=mid+0.01;
  }
  cout<<(long long)(l+0.999)<<endl;
  return 0;
}

Measured memory_bytes: 6820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    int sl = s.length();
    ll ans = 0, acnt = 0;
    
    rep(i, sl) {
        if ((i < (sl - 2)) && (s[i] == 'A') && (s[i + 1] == 'B') && (s[i + 2] == 'C')) {
            s[i] = 'B';
            s[i + 1] = 'C';
            s[i + 2] = 'A';
            
            if (acnt > 0) {
                s[i + 1] = 'A';
            }
            
            ans += 1 + acnt;
            acnt--;
        }
        else if (s[i] == 'A') {
            acnt++;
        }
        else {
            acnt = 0;
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int D; cin >> D;
    vector C(26, 0);
    rep(i,26) cin >> C.at(i);
    vector S(D, vector(26, 0));
    vector MA(D,0);
    rep(i, D) {
        int ma = 0;
        int maj = 0;
        rep(j, 26) {
            cin >> S[i][j];
            if (ma < S[i][j]) {
                ma = S[i][j];
                maj = j;
            }
        }
        MA[i] = maj;
    }
    vector last(26, 0);
    rep(d,D) {
            int ma = 0;
            int mai = 0;
            rep(i,26) {
                if (ma < (d + 1 - last[i]) * C[i]) {
                    ma = (d + 1 - last[i]) * C[i];
                    mai = i;
                }
            }
            int j;
            if (ma == 0) j = MA[d]; else j = mai;
            int sat = 0;
            last[j] = d + 1;
            rep(i,26) sat -= (d + 1 -last[i] * C[i]);
            
            sat += S[d][j];
        cout << j+1 << endl;
    }
}

Measured memory_bytes: 3664
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>


int main(){
    

    int R;
    scanf("%d",&R);
    int X[R],Y[R];

    for(int i =0;i<R;i++){
        scanf(" %d",&X[i]);
    }
    for(int i =0;i<R;i++){
        scanf(" %d",&Y[i]);
    }

    double p1=0,p2=0,p3=0,pInf;

    for(int i =0;i<R;i++){
        p1 += abs(X[i] - Y[i]);
    }

    for(int i =0;i<R;i++){
        p2 += pow(X[i] - Y[i],2);
    }
    p2 = sqrt(p2);

    for(int i =0;i<R;i++){
        p3 += pow(abs(X[i] - Y[i]),3);
    }
    p3 = pow(p3,1.0/3.0);

    for(int i =0;i<R;i++){
        if(pInf < abs(X[i] - Y[i])){
            pInf = abs(X[i] - Y[i]);
        }
    }


    printf("%lf\n%lf\n%lf\n%lf\n",p1,p2,p3,pInf);

    return 0;
}



Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end());
using namespace std;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;

int main(){
	int a,b;
	cin>>a >>b;
	vector<char> S(a+b+1);
	bool ans = true;
	rep(i,a+b+1){
		cin>>S[i];
	}
	rep(i,a+b+1){
		if(i==a){
		if(S[i]=='-'){
		}
		else{
			cout<<"No"<<endl;
			ans = false;
			break;
		}
		}
		else{
			if(S[i]=='-'){
			ans = false;
				cout<<"No"<<endl;
				break;
			}
			}
	}
			if(ans){
				cout<<"Yes"<<endl;
			}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
char c;
  cin>>c;
  if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o') cout<<"vowel"<<endl;
  else cout<<"consonant"<<endl;
  return 0;
}







Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a,b,i = 0,judge = 0;
	char op;
	int ans[100];
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		switch(op){
			case '+':
				ans[i]=a+b;
				break;
			case '-':
				ans[i]=a-b;
				break;
			case '*':
				ans[i]=a*b;
				break;
			case '/':
				ans[i]=a/b;
				break;
			case '?':
				judge = 1;
			default:
				break;
		}
		if(judge==1)break;
		i++;
	}

	for(a=0;a<i;a++){
		printf("%d\n",ans[a]);
	}

	return 0;

}

Measured memory_bytes: 600
/*
 *    author:  Gary Shih
 *    created: 2020-05-06 15:57:01
 */
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

// Debug {{{
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) { return '"' + s + '"'; }

string to_string(const char* s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// }}}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.setf(ios::fixed), cout.precision(9);
  int n;
  cin >> n;
  vector<vector<long long>> a(n, vector<long long>(n));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) cin >> a[i][j];

  vector<long long> dp(1 << n);

  for (int i = 1; i < (1 << n); ++i) {
    for (int j = 0; j < n; ++j)
      for (int k = 0; k < n; ++k)
        if ((i & (1 << j)) && (i & (1 << k))) dp[i] += a[j][k];
    dp[i] /= 2;
    dp[i] = max(dp[i], 0ll);
  }
  for (int i = 1; i < (1 << n); ++i) {
    if (__builtin_popcount(i) <= 2) continue;
    vector<bool> choose(n);
    function<void(int, int)> dfs = [&](int now, int subMask) {
      if (now == n) {
        dp[i] = max(dp[i], dp[subMask] + dp[i - subMask]);
        return;
      }
      dfs(now + 1, subMask);
      if (i & (1 << now)) dfs(now + 1, subMask + (1 << now));
    };
    dfs(0, 0);
  }
  cout << dp.back() << '\n';
}


Measured memory_bytes: 768
s = gets.chomp
t = gets.chomp

# "aiueo" + "aiueo"
# "aiueoaiueo" # 5文字
s2 = s + s

(0...s.length).each { |i|
    if s2[i...(i + s.length)] == t
        puts "Yes"
        exit
    end
}

puts "No"


Measured memory_bytes: 14248
#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;
int n, val, ans;
string s;
int main(){
    cin >> n >> s;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'D') {
            val--;
            if (val > ans)
                ans = val;
        }
        else {
            val++;
            if (val > ans)
                ans = val;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        int[] AB = cin.ArrayInt(2,0);
        Console.WriteLine((AB[0]+AB[1])%24);
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
    public static void IntArrayAns(int[,]x)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1);j++)
            {
                if(j!=x.GetLength(1)-1)Console.Write(x[i,j]+" ");
                else Console.WriteLine(x[i,j]);
            }
        }
    }//Scanner.IntArrayAns(x);
    public static void CharArrayAns(char[,]x)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1);j++)
            {
                if(j!=x.GetLength(1)-1)Console.Write(x[i,j]+" ");
                else Console.WriteLine(x[i,j]);
            }
        }
    }
}


Measured memory_bytes: 11092