akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define MAX 100000
struct Card{
  char a;
  int b;
};
struct Card L[MAX/2+2], R[MAX/2+2];
int n;

void merge(struct Card A[], int left, int mid, int right){
  int n1, n2, i, j, k;

  n1 = mid - left;
  n2 = right - mid;

  for(i = 0; i <= n1-1; i++) L[i] = A[left + i];
  for(i = 0; i <= n2-1; i++) R[i] = A[mid + i];
  L[n1].b = 1000000001;
  R[n2].b = 1000000001;
  i = j = 0;
  for(k = left; k <= right-1; k++){
    if(L[i].b <= R[j].b){
      A[k] = L[i++];
    }
    else{
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int left, int right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A,left, mid);
    mergeSort(A,mid, right);
    merge(A,left, mid, right);
  }
}
int partition(struct Card A[], int p, int r){
  int i, j;
  struct Card x, t;
  x = A[r];
  i = p - 1;
  for(j = p; j < r; j++){
    if(A[j].b <= x.b){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;
  return i+1;
}

void Quicksort(struct Card A[], int p, int r){
  int q;
  if(p < r){
    q = partition(A, p, r);
    Quicksort(A, p, q-1);
    Quicksort(A, q+1, r);
  }
}
int main()
{
  int i, v, f = 0;
  struct Card x[MAX], y[MAX];
  char s[10];

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%s %d", s, &v);
    x[i].a = y[i].a = s[0];
    x[i].b = y[i].b = v;
  }
  Quicksort(x, 0, n-1);
  mergeSort(y, 0, n);

  for(i = 0; i < n; i++){
    if(x[i].a != y[i].a) f = 1;
  }
  if(f == 0) printf("Stable\n");
  else printf("Not stable\n");

  for(i = 0; i < n; i++) printf("%c %d\n", x[i].a, x[i].b);
  return 0;
}

Measured memory_bytes: 2952
#include "bits/stdc++.h"
using namespace std;
int main(){
    string s;
    cin >> s;
    int i,j,even,n,N=s.size();//n:途中の長さ N:はじめの長さ
    if(N%2) n = N-1;
    else n = N-2;
    for(i=0;i<N;i++){
        even = 1;
        for(j=0;j<n/2;j++){
            if(s.at(j) != s.at(n/2+j))even = 0;
        }
        if(even)break;
        else n -= 2;
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		vi nums;
		reep(i, 1, n)
			nums.push_back((i*i)%n);
		
		sort(nums.begin(), nums.end());
		nums.erase(unique(nums.begin(), nums.end()), nums.end());
		
		vi ans((n+1)/2, 0);
		rep(i, nums.size()){
			rep(j, i+1){
				int p = abs(nums[i]-nums[j]);
				if(p>(n-1)/2) p = n - p;
				++ans[p];
			}
		}
		reep(i, 1, (n+1)/2)
			printf("%d\n", ans[i]*2);
	}
	
	return 0;
}

Measured memory_bytes: 920
H, W = list(map(int, input().split()))
S = ['.' + input() + '.' for _ in range(H)]

game = []
game.append([0 for _ in range(W + 2)])
game.extend([[0 if c == '.' else -1 for c in line] for line in S])
game.append([0 for _ in range(W + 2)])

for y in range(H + 2):
    for x in range(W + 2):
        if game[y][x] == -1:
            for i in (-1, 0, 1):
                for j in (-1, 0, 1):
                    if game[y + i][x + j] != -1:
                        game[y + i][x + j] += 1

for line in game[1:-1]:
    print(''.join(map(str, line[1:-1])).replace('-1', '#'))

Measured memory_bytes: 3064
import fractions

n, x = map(int, input().split())
cities = [int(x) for x in input().split()]
cities.append(x)
cities = sorted(cities)

gaps = []

for c in range(len(cities)-1):
    gaps.append(cities[c+1] - cities[c])

A = 0

for g in sorted(gaps):
    A = fractions.gcd(A, g)

print(A)



Measured memory_bytes: 16280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int N;
  cin>>N;
  vector<long long int> as(N);
  for(int i=0;i<N;i++){cin>>as.at(i);}
  sort(as.begin(),as.end());
  long long int first=0,second=0;
  for(int i=N-1;i>0;i--){
    if(as.at(i)==as.at(i-1)&&first==0){first=as.at(i);i--;}
    else if(as.at(i)==as.at(i-1)){
      second=as.at(i);
      cout<<first*second<<endl;
      return 0;
    }
  }
  cout<<0<<endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    int ops, to_add;
    cin >> ops >> to_add;

    int num = 1;
    while (ops > 0 && num <= to_add) {
        num *= 2;
        ops -= 1;
    }
    num += ops * to_add;

    cout << num << "\n";
    return 0;
}


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

using namespace std;


int h,g[11][11];

bool fall(int x,int y){

  if(g[y][x]==0)return false;

  bool fg=false;
  int tmp=g[y][x];
  g[y][x]=0;
  while(y>0 && g[y-1][x]==0)y--,fg=true;
  g[y][x]=tmp;
  return fg;
}

int remove(int x,int y){

  if(g[y][x]==0)return 0;
  
  int res=g[y][x],cnt=0;
  while(g[y][x]==g[y][x+cnt])cnt++;

  if(cnt<3)return 0;
    
  for(int i=0;i<cnt;i++)g[y][x+i]=0;
  
  return res*cnt;
}

void print(){
    for(int i=h-1;i>=0;i--){
      for(int j=0;j<5;j++)if(g[i][j]<0)cout << "*";else cout << g[i][j];
      cout << endl;
    }
}

int solve(){

  bool fg;
  int res=0;

  while(true){
    fg=false;
    
    for(int i=0;i<h;i++){
      for(int j=0;j<5;j++){
	res+=remove(j,i);
      }
    }

    for(int i=0;i<h;i++){
      for(int j=0;j<5;j++){
	fg|=fall(j,i);
      }
    }

    if(!fg)return res;
  }
}

int main(void){
  
  while(cin >> h,h){

    for(int i=0;i<11;i++)
      for(int j=0;j<11;j++)g[i][j]=0;

    for(int i=h-1;i>=0;i--){
      for(int j=0;j<5;j++)cin >> g[i][j];
    }

    cout << solve() << endl;
  }

  return 0;
}

Measured memory_bytes: 1164
<?php
fscanf(STDIN, "%d", $n);
for($i = 0; $i < $n; $i++){
    $f[] = array_map('intval', explode(' ', fgets(STDIN)));
}
for($i = 0; $i < $n; $i++){
    $p[] = array_map('intval', explode(' ', fgets(STDIN)));
}

$a = [];
$ans = -10000000000;

function calc(){
    global $ans;
    global $a;
    global $n;
    global $f;
    global $p;
    $r = 0;
    for($i = 0; $i < $n; $i++){
        $cnt = 0;
        for($j = 0; $j < 10; $j++){
            if($f[$i][$j] == 1 && $a[$j] == 1) $cnt++;
        }
        $r += $p[$i][$cnt];
    }
    $ans = max($ans, $r);
}

function dfs($pos){
    global $a;
    if($pos == 10){
        if(array_sum($a) == 0) return;
        calc();
        return;
    }
    $a[$pos] = 0; dfs($pos + 1);
    $a[$pos] = 1; dfs($pos + 1);
}

dfs(0);
echo $ans;

Measured memory_bytes: 5240
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string s = Console.ReadLine();
    int n = s.Length;
		long answer = 0;
    long leftCount = 0;
    long rightCount = 0;

    for(int i = 0; i < n; i++)
    {
      if(s[i] == '<' && i > 0)
      {
        if(s[i-1] == '>')
        {
          answer += Math.Max(leftCount,rightCount) *(Math.Max(leftCount,rightCount)+1) /2;

          answer += Math.Min(leftCount,rightCount) *(Math.Min(leftCount,rightCount)-1) /2;

          leftCount = 0;
          rightCount = 0;
        }
      }
    
      if(s[i] == '<') leftCount++;
      else rightCount++;
    }
    answer += Math.Max(leftCount,rightCount) *(Math.Max(leftCount,rightCount)+1) /2;
    answer += Math.Min(leftCount,rightCount) *(Math.Min(leftCount,rightCount)-1) /2;

		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 12896
#include <stdio.h>

int main(void)
{
  int n;
  int max = 0, sec = 0, midx;
  
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    if (max < a) {
      sec = max;
      max = a;
      midx = i;
    }
    else if (sec < a)
      sec = a;
  }
  
  int ridx = n - midx - 1;
  while (midx--)
    printf("%d\n", max);
  printf("%d\n", sec);
  while (ridx--)
    printf("%d\n", max);
  
  return 0;
}


Measured memory_bytes: 1536
s = list(input())
A = int(s[0])
B = int(s[1])
C = int(s[2])
D = int(s[3])
if A + B + C + D == 7:
    print(str(A) + "+" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
elif A + B + C - D == 7:
    print(str(A) + "+" + str(B) + "+" + str(C) + "-" + str(D) + "=7")
elif A + B - C + D == 7:
    print(str(A) + "+" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
elif A + B - C - D == 7:
    print(str(A) + "+" + str(B) + "-" + str(C) + "-" + str(D) + "=7")
elif A - B + C + D == 7:
    print(str(A) + "-" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
elif A - B + C - D == 7:
    print(str(A) + "-" + str(B) + "+" + str(C) + "-" + str(D) + "=7")
elif A - B - C + D == 7:
    print(str(A) + "-" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
elif A - B - C - D == 7:
    print(str(A) + "-" + str(B) + "-" + str(C) + "-" + str(D) + "=7")


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

int main(void) {
    int n,ans = 0;
    string s;
    cin >> n;
    cin >> s;
    for(int i = 0; i < s.length()-2;i++) {
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C' ) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

ll modPow(ll m, ll n) {
    if (n == 0) return 1; 
    if (n % 2) return m * modPow(m, n-1) % MOD;
    else modPow(m * m % MOD, n / 2);
}

int main() {
    ll m, n; cin >> m >> n;
    cout << modPow(m, n) << endl; 
}


Measured memory_bytes: 3092
#include <iostream>
using namespace std;
 
int main() {
	int n; cin >> n; bool OK = false;
	for (int j = 0; j <= n / 4; j++) {
		for (int k = 0; k <= n / 7; k++) {
			if (4 * j + 7 * k == n) OK = true;
		}
	}
	if (OK == false) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3620
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	a := nextInt()
	b := nextInt()
	c := nextInt()
	fmt.Println(min(b/a, c))
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
int dp[101][101][101],a[101],m,mo,n,ans;
bool cmp(int aa,int bb){return(aa<bb);}
int main()
{
	scanf("%d",&n);
	m=2*n-1;
	for(int i=1;i<=m;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+m,cmp); 
	dp[n][1][1]=1;
	mo=1000000007;
	for(int i=n-1;i>=1;i--)
	{
		int l=0,r=0;
		if(a[i]!=a[i+1])l=1;
		if(a[m-i+1]!=a[m-i]) r=1;
		for(int j=2*(n-i)-1;j>=1;j--)
		for(int k=1+l;k<=j+l;k++)
		for(int ii=1;ii<=j+l+r;ii++)
		{
			if(ii>k) dp[i][k+1][j+l+r-(ii-k-1)]=(dp[i][k+1][j+l+r-(ii-k-1)]+dp[i+1][k-l][j])%mo;
			if(ii==k) dp[i][k][j+l+r]=(dp[i][k][j+l+r]+dp[i+1][k-l][j])%mo;
			if(ii<k) dp[i][ii][j+l+r-(k-ii-1)]=(dp[i][ii][j+l+r-(k-ii-1)]+dp[i+1][k-l][j])%mo;
		}
	}
	ans=0;
	for(int i=1;i<=m;i++)
	for(int j=1;j<=m;j++) ans=(ans+dp[1][i][j])%mo;
	printf("%d\n",ans);
} 

Measured memory_bytes: 1280
import sys
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(200000)
class uf:
    def __init__(self,n):
        self.n=n
        self.l=[-1]*n
    def ro(self,n):
        if self.l[n]<0:
            return n
        r=self.ro(self.l[n])
        self.l[n]=r
        return r
    def me(self,a,b):
        ra=self.ro(a)
        rb=self.ro(b)
        if self.l[ra]>self.l[rb]:
            ra,rb=rb,ra
        if ra!=rb:
            self.l[ra]+=self.l[rb]
            self.l[rb]=ra
    def size(self,n):
        return -self.l[self.ro(n)]
    def sa(self,a,b):
        return self.ro(a)==self.ro(b)
N,M,K=map(int,input().split())
u=uf(N)
l=[-1]*N
for i in range(M):
    A,B=map(lambda x: int(x)-1,input().split())
    u.me(A,B)
    l[A]-=1
    l[B]-=1
for i in range(N):
    l[i]+=u.size(i)
for i in range(K):
    C,D=map(lambda x: int(x)-1,input().split())
    if u.sa(C,D):
        l[C]-=1
        l[D]-=1
print(*l)

Measured memory_bytes: 77656
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define MN 200005
using namespace std;
inline int in(){
    int x=0;bool f=0;char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
int a[MN],n,x;
ll res;
int main()
{
	n=in();
	for (int i=1;i<=n;++i) a[i]=in()-i;
	sort(a+1,a+n+1);x=a[(n+1)>>1];
	for (int i=1;i<=n;++i) res+=1ll*abs(a[i]-x);
	printf("%lld",res);return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if (a % 2 == 1 && b % 2 == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    string S,T;cin>>S>>T;
    int ans;ans=0;
    for(int i=0;i<=2;i++){
        if(S[i]==T[i]){
            ans++;
        }
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
list=[a,b,c,d,e]
min=10**16
ans=0
for i in range(5):
    if list[4-i]<min:
        min=list[4-i]
        ans=4-i
        x=4-i
ans+=6-(x+2)
ans+=-(-n//min)
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

int main() { 
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	ll ans = 1;
	rep(i, s.size() - 1) {
		char now = s[i];
		if (s[i + 1] != now) {
			ans++;
		}
	}
	cout << ans - 1 << endl;
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<pair<int64_t,int64_t>> itv(N);
  for(int i=0;i<N;++i){
    int64_t X,L;
    cin>>X>>L;
    itv[i]=make_pair(X+L,X-L);
  }
  sort(itv.begin(),itv.end());

  int ans=0;
  int64_t t=-1000000001;
  for(int i=0;i<N;++i){
    if(t<=itv[i].second){
      ++ans;
      t=itv[i].first;
    }
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 1792
/* Justin Choi */
#include <bits/stdc++.h>
using namespace std;

string FILENAME = "filename";
#define io ifstream fin(FILENAME + ".in"); ofstream fout(FILENAME + ".out")
#define fwrite(X) fout << X;
#define fwriteln(X) fout << X << endl;

#define forl(V, N) for(int V = 0; V < N; V++)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
#define rem(X) X.top(); X.pop()
#define setmin(A, B) A = min(A, B)
#define setmax(A, B) A = max(A, B)
#define graph unordered_map<int, unordered_set<int>>
#define vi vector<int>
#define pb push_back
#define ll long long

graph G;

vi topological() {
    vi top, degree(G.size()+1);
    fore(V, G) fore(child, V.second) degree[child]++; 
    queue<int> q;
    forl(i, G.size()) if(degree[i+1] == 0) q.push(i+1);
    while(!q.empty()) {
        int val = q.front();
        q.pop();
        top.pb(val);
        fore(child, G[val]) {
            if(--degree[child] == 0) q.push(child);
        }
    }
    return top;
}

vi dp(200000);

int main() {
    int N, M;
    cin >> N >> M;
    forl(i, N) G[i+1] = {};
    forl(i, M) {
        int A, B;
        cin >> A >> B;
        G[A].insert(B);
    }
    vi ord = topological();
    fore(V, ord) {
        fore(child, G[V]) setmax(dp[child], dp[V]+1);
    }
    println(*max_element(dp.begin(), dp.end()));
}

Measured memory_bytes: 17316
#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
using namespace std;

#define MAX_SENTENTCE_SIZE 1999
#define ALFABET_SIZE 26

int main() {
  char str[MAX_SENTENTCE_SIZE];
  char alphabetical_count[ALFABET_SIZE] = {};

  while(true) {
    cin.getline(str, MAX_SENTENTCE_SIZE);
    if(cin.eof()) {
      break;
    }

    int str_size = strlen(str);

    // count
    for(int i = 0; i < str_size; i++) {
      char letter = tolower(str[i]);

      if(!(letter >= 'a' && letter <= 'z')) {
        continue;
      };

      alphabetical_count[letter - 'a'] += 1;
    }
  }
  // output
  for(int i = 0; i < ALFABET_SIZE; i++) {
    printf("%c : %d\n", i + 'a', alphabetical_count[i]);
  }
}



Measured memory_bytes: 3172
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int ans;
		int free = a - b;
		if (free > 0) {
			if (free > c) {
				ans = 0;
			} else {
				ans = c - free;
			}
		} else {
			ans = c;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 23636
N=int(input())
if N == 10**5:
  print("90909")
elif N >= 10**4:
  resid=N-10**4+1
  print(str(9+900+resid))
elif N >= 10**3:
  print("909")
elif N >= 10**2:
  resid=N-10**2+1
  print(str(9+resid))
elif N >= 10:
  print("9")
else:
  print(str(N))

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

int main(){
  int n, m, A[100][100], b[100], c[100];
      
      cin >> n >> m;
      for ( int i = 0; i < n; i++ )
          for ( int j = 0; j < m; j++ ) cin >> A[i][j];
      
      for ( int i = 0; i < m; i++ ) cin >> b[i];
          
          for ( int i = 0; i < n; i++ ){
          c[i] = 0;
          for ( int j = 0; j < m; j++ ){
             c[i] += A[i][j]*b[j];
          }
      }
    
    for ( int i = 0; i < n; i++ ) cout << c[i] << endl;
            
  return 0;
}    

Measured memory_bytes: 1200
def calcCost(ave_num, num):
    cost = (num - ave_num) ** 2
    return cost
 
N = int(input())
numbers = [int(i) for i in input().split()]
 
if len(set(numbers)) == 1:
    print(0)
else :
    
    ave_num = round(sum(numbers) / N)
 
    total_cost = 0
    for num in numbers:
        total_cost += calcCost(num, ave_num)
    
    print(total_cost)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi acos(-1)
#define mod 1000000007
#define all(x) x.begin(), x.end()
using namespace std;

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

    int tc = 1;
    //cin >> tc;
    while(tc--){
        ll l, r, d;
        cin >> l >> r >> d;
        cout << r /d - (l - 1) / d << endl;
    }
}



Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    double n; cin >> n;
    vector<double> v(n);
    double num=0;
    rep(i,n){
        cin >> v[i];
        num += v[i];
    }
    int ans = 0;
    int  avr = round(num/n);
    for(auto all : v){
        ans += pow(abs(all-avr),2);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
N, = map(int, input().split())
Xs = list(map(int, input().split()))
Ys = sorted(Xs)
for i in range(N):
    if Xs[i] > Ys[N//2-1]:
        print(Ys[N//2-1])
    else:
        print(Ys[N//2])


Measured memory_bytes: 93780
#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';

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		=  	1e+9 + 7;


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

ll T = 1;
ll n, x, m, y, k, z, N;
string s, t, d, c;


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



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

void MAIN() {
	cin>>s;
	if(s == "a" || s == "e" || s == "i" || s == "o" || s == "u") cout<<"vowel\n";
	else cout<<"consonant\n";
}

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


Measured memory_bytes: 3548
K=int(input())
GCD=[[0]*(K+2) for _ in range(K+2)]
import math
def make_GCD(K):
    for a in range(1,K+1):
        for b in range(1,K+1):
            GCD[a][b]=math.gcd(a,b)            
make_GCD(K)

def gcd3(a,b,c):
    a=GCD[a][b]
    return GCD[a][c]
ans=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans += gcd3(a,b,c)            
print(ans)

Measured memory_bytes: 9412
from collections import Counter
N = int(input())
D = list(map(int, input().split()))
D.sort()
d = [0]*25
d[0] = d[-1] = 1
for i in range(N):
    if i & 1:
        d[D[i]] += 1
    else:
        d[24-D[i]] += 1
for i in range(25):
    if d[i] > 1:
        print(0)
        exit()
last, ans = 0, 24
for i in range(1, 25):
    if d[i]:
        ans = min(i-last, ans)
        last = i
print(ans)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
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; }
signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c; cin>>a>>b>>c;
    if(a + b+ c >= 22) cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}


Measured memory_bytes: 256
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

max_a = max(a for a, _ in ab)
dp = [0] * (h+max_a)

for i in range(0, h+max_a):
    if i <= 0:
        dp[i] = 0
    else:
        dp[i] = min(dp[i-a] + b for a,b in ab) 

print(min(dp[h:]))

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;

// typedef
typedef pair<int, int> P;
typedef tuple<int, int, int> P3;
typedef vector<vector<int>> Graph;
#define PI 3.14159265358979

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    if (x > a * a * b / 2) {
        double tan = a * a * a / (2 * (a * a * b - x));
        cout << setprecision(12) << 90 - (atan(tan) * 180 / PI) << endl;
    } else {
        double tan = 2 * x / (b * b * a);
        cout << setprecision(12) << 90 - (atan(tan) * 180 / PI) << endl;
    }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
main()
{
    int n,sm=0;
    cin>>n;
    int tm=n;
    while(n>0)
    {
        sm+=n%10;
        n/=10;
    }
    if(tm%sm==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


Measured memory_bytes: 3624
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cstdint>
#include<vector>
#include<cstddef>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using usize = uint_fast64_t;
#define rep(i, n) for (usize i = 0; i < (usize)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i64 n,k;
cin >> n >> k;
vector<vector<i64>> doubling(64,vector<i64> (n));
rep(i,n){
    cin >> doubling[0][i];
    doubling[0][i]--;
}
rep(i,63){
    rep(j,n){
        doubling[i + 1][j] = doubling[i][doubling[i][j]];
    }
}
i64 now = 0;
for(i64 i = 63; 0 <= i; i--){
    if(k & ((i64)(1) << i))now = doubling[i][now];
}
cout << now + 1 << endl;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	vector<pair<int, int>> b(m);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(begin(a), end(a));
	for (int i = 0; i < m; i++) {
		cin >> b[i].second >> b[i].first;
	}
	sort(b.rbegin(), b.rend());
	int j = 0;
	for (int i = 0; i < n; i++) {
		if (j == m) break;
		while (i < n && a[i] <= b[j].first && b[j].second > 0) {
			a[i] = b[j].first;
			b[j].second--;
			i++;
		}
		i--;
		j++;
	}
	long long res = 0;
	for (int i = 0; i < n; i++) {
		res += a[i];
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 4540
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int A, B, K;
  cin >> A >> B >> K;
  if (K <= A) {
    cout << A - K << " " << B << endl;
  } else if (K <= A + B) {
    cout << "0 " << B - (K - A) << endl;
  } else {
    cout << "0 0" << endl;
  }
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 256
S = input()
T = input()
a,b,c = 0,0,0

# if S[0] == T[0]:
#     a=1
# if S[1] == T[1]:
#     b=1
# if S[2] == T[2]:
#     c=1

for i in range(3):
    if S[i]==T[i]:
        a+=1
print(a)

Measured memory_bytes: 2940
#include <stdio.h>

int main(void)
{
    int tate, yoko;
    int area, length;

    scanf("%d %d", &tate, &yoko);

    area = tate*yoko;
    length = 2*(tate + yoko);

    printf("%d %d\n", area, length);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define SEKAI_NO_OWARI return 0;
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

void solve() {
	int n, x; cin >> n >> x;
	vector<int> L(n);
	rep(i, n) scanf("%d", &L[i]);

	int res = 1, sum = 0;
	rep(i, n) {
		if (sum + L[i] <= x) {
			sum += L[i];
			res++;
		}
		else {
			break;
		}
	}
	cout << res << endl;
}

int main(void) {
	solve();
	SEKAI_NO_OWARI
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e17+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

///2009~
int main(void){
	int n,g=0,i,a,b;cin>>n;
	vector<pair<llint,llint>>w(n);
	for(i=0;i<n;i++){cin>>w[i].sec>>w[i].fir;}
	SO(w);
	for(i=0;i<n;i++){
		g+=w[i].sec;
		if(w[i].fir<g){cout<<"No"<<endl;return 0;}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int n ;
vector<int> v[2] ;
int dfs(int x,int y,int sum){
    sum += v[x][y] ;
    if ( x == 1 && y == n-1 ){
        return sum ;
    }
    int right = 0, left = 0 ;
    if ( y + 1 < n )
        right = dfs(x,y+1,sum);
    if ( x + 1 < 2 )
        left = dfs(x+1,y,sum);
    return max(right,left);
}
int main(){
    cin >> n ;
    for(int i=0;i<n;i++){
        int x ;
        cin >> x ;
        v[0].push_back(x);
    }
    for(int i=0;i<n;i++){
        int x ;
        cin >> x ;
        v[1].push_back(x);
    }
    cout << dfs(0,0,0) << endl;

    return 0 ;
}


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

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

    vector<vector<int>> Graph(N);
    vector<int> A(N - 1), B(N - 1);
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        A[i] = a, B[i] = b;
        Graph[a].push_back(b);
        Graph[b].push_back(a);  //無向グラフ
    }

    vector<int> dist(N, -1);  // -1: 未訪問
    queue<P> que;

    dist[0] = 0;
    que.push(make_pair(0, -1));
    map<P, int> mp;
    int MAX = 1;
    while (!que.empty()) {
        int v = que.front().first;
        int col = que.front().second;
        que.pop();

        int nextcol = 0;
        for (int nv : Graph[v]) {
            if (dist[nv] != -1) continue;

            ++nextcol;
            if (nextcol == col) ++nextcol;
            dist[nv] = 1;
            mp[make_pair(min(v, nv), max(v, nv))] = nextcol;
            que.push(make_pair(nv, nextcol));
        }
        MAX = max(MAX, nextcol);
    }

    cout << MAX << endl;
    rep(i, N - 1) cout << mp[make_pair(A[i], B[i])] << endl;
}

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

int main() {
  int d;
  cin >> d;
  vector<int> c(26);
  rep(i, 26) cin >> c[i];
  vector<vector<int>> s(d, vector<int>(26));
  rep(i, d) rep(j, 26) cin >> s[i][j];
  ll score = 0;
  vector<int> last(26, 0);
  for (int i = 1; i < d+1; i++) {
    // i日目
    ll temp = score;
    int temp_type = 0;
    rep(j, 26) {
      // Type jのコンテストを開催したとすると
      ll cur = score;
      cur += s[i-1][j];
      rep(k, 26) {
        cur -= c[k] * (i - last[k]);
      }
      cur += c[j] * (i - last[j]); // 引いた分、戻す
      if (cur > temp) {
        temp = cur;
        temp_type = j;
      }
    }
    score = temp;
    last[temp_type] = i;
    cout << temp_type + 1 << '\n';

  }
  //cout << score << '\n';
  return 0;
}

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

int main(){
  string s, t;
  cin >> s >> t;
  cout << t<< s<< "\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
        double A,B,C,D;
        int S;
        scanf("%lf %lf %lf %lf",&A,&B,&C,&D);
        S=fmin(B,D)-fmax(A,C);
        if(S<0) S=0;
        printf("%d\n",S);
        return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<queue>
#define int long long
#define mod (int)(1000000007)
using namespace std;
int test[213456];
signed main() {
	int n, m, a, b = 0, ans = 0; cin >> n >> m;
	for (int h = 0; h < n; h++) {
		cin >> test[h];
	}
	sort(test, test + n);
	for (int h = 0; h < n - m; h++) {
		ans += test[h];
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define int long long
#define F first
#define S second
#define pb push_back
#define p2(n) (1<<(n))
#define lg2(n) __lg(n)
using namespace std;
using pii = pair<long long,long long>;
using ld = long double;
mt19937 mt_rand(time(0));
const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);

int x,k,d;

void solve(){
    cin >> x >> k >> d;
    x = abs(x);
    int div = x/d;
    if(div>=k)
        cout << abs(x-d*k) << '\n';
    else{
        x = x%d;
        if((k-div)&1)
            x -= d;
        cout << abs(x) << '\n';
    }
}

signed main(){
    Rushia_mywife
    solve();
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int d;
  cin>>d;

  vector<ll> p(26);
  rep(i,26) {
    cin>>p[i];
  }


  vector<vector<ll>> q(d,vector<ll>(26));
  rep(i,d) {
    rep(j,26) {
      cin>>q[i][j];
    }
  }

  ll pre=0;
  vector<int> r(26,0);
  rep(i,d-5){
    ll ans=-INF;
    ll memo;
    rep(j,26){
      ll sum=pre;
      auto last=r;
      sum+=q[i][j];
      last[j]=i+1;
      rep(k,26){
        sum-=5.25*p[k]*(i+1-last[k]);
      }
      if(sum>ans) {
        memo=j;
        chmax(ans,sum);
      }
    }
    cout << memo+1 << endl;
    pre=ans;
    r[memo]=i+1;
  }

  ll answer=-INF;
  ll A,B,C,D,E;
  vector<int> zen(5);
  rep(i,26){
    rep(j,26){
      rep(k,26){
        rep(l,26){
          rep(m,26){
            zen[0]=i;
            zen[1]=j;
            zen[2]=k;
            zen[3]=l;
            zen[4]=m;

            ll sum=0;
            auto last=r;
            rep(n,5){
              sum+=q[d-5+n][zen[n]];
              last[zen[n]]=d-5+n+1;
              rep(o,26){
                sum-=p[o]*(d-5+n+1-last[o]);
              }
            }

            if(sum>answer) {
              A=zen[0];
              B=zen[1];
              C=zen[2];
              D=zen[3];
              E=zen[4];
            }
            chmax(answer,sum);

          }
        }
      }
    }
  }

  cout << A+1 << endl;
  cout << B+1 << endl;
  cout << C+1 << endl;
  cout << D+1 << endl;
  cout << E+1 << endl;
  
}

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

int n, m, q;
int ans = 0;
vector<int> a, b, c, d;
vector<int> A;

void UpdateAnswer() {

    // for(int i = 0; i < n; i++) cout << A[i];    

    int point = 0;
    for(int i = 0; i < q; i++) {
        if(A[b[i]] - A[a[i]] == c[i]) point += d[i];
    }
    
    // cout << " : " << point << endl;

    ans = max(ans, point);
}

void dfs(int depth, int forward) {
    if(depth == n) {
        UpdateAnswer();
    } else {
        for(int i = forward; i <= m; i++) {
            A.push_back(i);
            dfs(depth + 1, i);
            A.pop_back();
        }
    }
}

int main() {
    cin >> n >> m >> q;
    for(int i = 0; i < q; i++) {
        int aa, bb, cc, dd;
        cin >> aa >> bb >> cc >> dd;
        aa--;
        bb--;
        a.push_back(aa);
        b.push_back(bb);
        c.push_back(cc);
        d.push_back(dd);
    }

    dfs(0, 1);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3644
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a1:i8,
        a2:i8,
        a3:i8,
    }
    let a =  a1+a2+a3;
    if a >= 22 {
        println!("bust");
    }else{
        println!("win");
    }
}

Measured memory_bytes: 4352
module Main where
import Control.Monad
import Data.Bits

solve :: Integer -> Integer
solve n
    | r == 1 = (q+1) `mod` 2
    | r == 0 = n `xor` solve (n-1)
    where r = n `mod` 2
          q = n `div` 2

main :: IO ()
main = do
    [a,b] <-(map read. words)<$> getLine
    print (solve (a-1) `xor` solve b)

Measured memory_bytes: 508
#include <iostream>
using namespace std;
int main(void){
    int X,Y,Z;
    cin>>X>>Y>>Z;
    int a=0;
    int answer;
    while (X-2*Z-Y-a*(Y+Z)>=0){
        answer=a;
        a++;
    }
    cout<<answer+1<<endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] arr = new int[n];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextInt();
    }
    Arrays.sort(arr);
    long sum=0;
    for(int i=0;i<n-k;i++){
      sum=sum+arr[i];
    }
    System.out.println(sum);
  }
}

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

using namespace std;

int main () {
	int n, l;
	cin >> n >> l;
	int tot, a[n], fl;
	tot = fl = a[0] = l;
	for (int i=1; i<n; i++){
		a[i] = (i + l);
		tot += a[i];
		fl = (abs(a[i]) < abs(fl)) ? a[i] : fl;
	}
	cout << tot - fl << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
class Program{
	public static void Main(){
		int X = int.Parse(Console.ReadLine());
		int A = int.Parse(Console.ReadLine());
		int B = int.Parse(Console.ReadLine());
		X -= A;
		int n = X / B;
		X -= B * n;
		Console.WriteLine(X);
	}
}

Measured memory_bytes: 11092
import java.util.Scanner;

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

        int price = sc.nextInt();
        int money = sc.nextInt();
        int count = sc.nextInt();

        if(price * count < money) {
        	System.out.println(count);
        }else{
        	System.out.println(money/price);
        }     
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	ll ans=INF*INF;
	FOR(i,1,n) {
		string a=to_string(i),b=to_string(n-i);
		ll buf=0;
		REP(j,(ll)a.size()) buf+=(a[j]-'0');
		REP(j,(ll)b.size()) buf+=(b[j]-'0');
		ans=min(ans,buf);
	}
	cout<<ans<<endl;
}


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

int n,m,k;
int A[100];
int ans[100];

int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++)cin>>A[i],A[i]--;
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      cin>>k;
      k--;
      if(k==A[i])ans[j]++;
      else ans[A[i]]++;
    }
  }
  for(int i=0;i<n;i++)cout<<ans[i]<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
using namespace std;

int max(int x, int y);
int min(int x, int y);
int gcd(int x, int y);	/*最大公約数*/
int lcm(int x, int y);	/*最小公倍数*/
void swap(int* x, int* y);	/*値の交換*/
void downsort(int* a, int n);	/*降順ソート*/
void upsort(int* a, int n);	/*昇順ソート*/

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*/

/*ここからmain関数*/

int main()
{
	int N, V[20], C[20];
	cin >> N;
	for (int i = 0;i < N;i++)
		cin >> V[i];
	for (int i = 0;i < N;i++)
		cin >> C[i];

	int A=0;
	for (int i = 0;i < N;i++)
		if (V[i] - C[i] > 0)
			A += V[i] - C[i];

	cout << A;

	return 0;
}

/*2数の大きい方を返す*/
int max(int x, int y)
{
	int max;

	if (x < y)
		max = y;
	else
		max = x;

	return max;
}

/*2数の小さい方を返す*/
int min(int x, int y)
{
	int min;

	if (x < y)
		min = x;
	else
		min = y;

	return min;
}

/*2数の最大公約数を返す*/
int gcd(int x, int y)
{
	int m;
	int gcd = 1;

	m = min(x, y);

	for (int i = 1;i <= m; i++)
	{
		if (x%i == 0 && y%i == 0)
			gcd = i;
	}

	return gcd;
}

/*2数の最小公倍数を返す*/
int lcm(int x, int y)
{
	int m;

	for (int i = 1;i <= y;i++)
	{
		if ((x*i) % y == 0) {
			m = x * i;
			break;
		}
	}

	return m;
}

/*2数の値を交換する*/
void swap(int* px, int* py)
{
	int temp;

	temp = *px;
	*px = *py;
	*py = temp;
}

/*クイックソートによる降順並べ替え*/
void downsort(int* a, int n)
{
	//初期設定
	int l = 0, r = n - 1;

	// ピボットの決定
	int piv = *a;

	//ピボットより大を左に、ピボット以下を右に
	while (l < r)
	{
		if (*(a + l) > piv)
			l++;
		else if (*(a + r) <= piv)
			r--;
		else
			swap(a + l, a + r);
	}

	//再帰処理
	if (n == 2)
		return;
	else if (l == 1 || l == 0)
		downsort(a + 1, n - 1);
	else if (r == n - 1)
		downsort(a, n - 1);
	else
	{
		downsort(a, l);
		downsort(a + l, n - l);
	}
}

/*クイックソートによる昇順ソート*/
void upsort(int* a, int n)
{
	downsort(a, n);

	for (int i = 0;i < n / 2;i++)
		swap(a[i], a[n - 1 - i]);
}

Measured memory_bytes: 256