akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define pb push_back
using namespace std;
typedef long long ll;

int main(){
  int n,z,w;
  cin>>n>>z>>w;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  
  int dp[2005][2];
  for(int i=n;i>=0;i--){
    dp[i][0] = abs(a[n-1]-(i?a[i-1]:w));
    for(int j=1;j+i<n;j++) dp[i][0] = max(dp[i][0],dp[i+j][1]);
 
    dp[i][1] = abs(a[n-1]-(i?a[i-1]:z));
    for(int j=1;j+i<n;j++) dp[i][1] = min(dp[i][1],dp[i+j][0]);
  }
  
  cout << dp[0][0] << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
ll A[20];
ll x[20][20], y[20][20];

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

  rep( i, N )
  {
    std::cin >> A[i];

    rep( j, A[i] )
      std::cin >> x[i][j] >> y[i][j], --x[i][j];
  }

  ll ans = 0;

  rep( bit, 1<<N )
  {
    bool fl = true;

    rep( i, N ) rep( j, A[i] )
    {
      if( y[i][j] == 1 )
        fl &= (bit>>x[i][j]&1) || (!(bit>>i&1));
      else
        fl &= (!(bit>>x[i][j]&1)) || (!(bit>>i&1));
    }

    if( fl )
      chmax( ans, (ll)__builtin_popcount( bit ) );
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
 int h,w,a,b;
 int i,j,k;
 cin>>h>>w>>a>>b;
 vector<vector<int> > aux(h,vector<int>(w,0));
 vector<int> fila(h+1,0);
 vector<int> columna(w+1,0);
 if(w-a<a || h-b<b)
 {
  cout<<"-1";
  return 0;
 }
a=w-a;
b=h-b;
for(i=0;i<h;i++)
{
 for(j=0;j<w;j++)
 {
  if(fila[i]<a && columna[j]<b)
  {
   fila[i]+=1;
   columna[j]+=1;
   aux[i][j]=1; 
  }
 }
}
for(i=0;i<h;i++)
{
 for(j=0;j<w;j++)
 {
  cout<<aux[i][j]; 
 }
 if(i!=h-1) cout<<endl;
}
 
 return 0;  
}

Measured memory_bytes: 5120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String[] sArray = s.split("");
		for(int i =0;i < (sArray.length -1)/2;i++) {
			if(!sArray[i].equals(sArray[sArray.length-1-i])) {
				System.out.println("No");
				return;
			}
		}
		String left = s.substring(0, (s.length()-1)/2);
		String[] leftArray = left.split("");
		for(int i =0;i < leftArray.length/2;i++) {
			if(!leftArray[i].equals(leftArray[leftArray.length-1-i])) {
				System.out.println("No");
				return;
			}
		}

		String right = s.substring(((s.length()+3)/2) -1);
		String[] rightArray = right.split("");
		for(int i =0;i < rightArray.length/2;i++) {
			if(!rightArray[i].equals(rightArray[rightArray.length-1-i])) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");

	}
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int64_t MOD=1000000007;

int main() {
  int H,W,N;
  cin>>H>>W>>N;
  vector<int> S(N);
  for(int i=0;i<N;i++) cin>>S.at(i);
  queue<int> q;
  for(int i=0;i<N;i++){
    int k=S.at(i);
    while(k>0){
      q.push(i+1);
      k--;
    }
  }
  vector<vector<int>> ans(H,vector<int>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      ans.at(i).at(j)=q.front();
      q.pop();
    }
  }
  for(int i=0;i<H;i++){
    if(i%2==1) reverse(ans.at(i).begin(),ans.at(i).end());
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(j==W-1) cout<<ans.at(i).at(j)<<endl;
      else cout<<ans.at(i).at(j)<<' ';
    }
  }
}


Measured memory_bytes: 384
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func Max(A []int) int {
  max := 0
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}

func Hand(H []rune, R, S, P int) int {
  DP := make([][]int, len(H) + 1)
  for i := range DP {
    DP[i] = make([]int, 3)
  }
  for i, h := range H {
    for j := range DP[i + 1] {
      for k, dp := range DP[i] {
        if j == k { continue }
        if DP[i + 1][j] < dp { DP[i + 1][j] = dp }
      }
    }
    if h == 'r' {
      DP[i + 1][2] += P
    } else if h == 's' {
      DP[i + 1][0] += R
    } else {
      DP[i + 1][1] += S
    }
  }
  return Max(DP[len(H)])
}

func main() {
  NK := NextIntVec()
  K := NK[1]
  RSP := NextIntVec()
  R, S, P := RSP[0], RSP[1], RSP[2]
  T := NextLine()
  H := make([][]rune, K)
  for i := range H {
    H[i] = make([]rune, 0)
  }
  for i, t := range T {
    H[i % K] = append(H[i % K], t)
  }
  cnt := 0
  for _, h := range H {
    cnt += Hand(h, R, S, P)
  }
  Write(cnt)
  Output()
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

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

    queue<i64> que;

    for (int i = 1; i < 10; i++)
    {
        que.push(i);
    }
    for (int i = 1; i <= k - 1; i++)
    {
        i64 x = que.front();
        que.pop();
        int d = x % 10;

        if (d != 0)
            que.push(10 * x + d - 1);
        que.push(10 * x + d);
        if (d != 9)
            que.push(10 * x + d + 1);
    }

    debug(que.front());

    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();

            int[][] a = new int[M][2];
            for (int i = 0; i < a.length; i++) {
                a[i][0] = in.nextInt();
                a[i][1] = in.nextInt();
            }

            boolean[] from1 = new boolean[N + 1];
            boolean[] toN = new boolean[N + 1];
            for (int i = 0; i < a.length; i++) {
                if (a[i][0] == 1) {
                    from1[a[i][1]] = true;
                }
                if (a[i][1] == N) {
                    toN[a[i][0]] = true;
                }
            }

            for (int i = 0; i < toN.length; i++) {
                if (from1[i] && toN[i]) {
                    System.out.println("POSSIBLE");
                    return;
                }
            }

            System.out.println("IMPOSSIBLE");
        }
    }
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll a,b;cin >>a>>b;
    if(a*b<=0){
        puts("Zero");
    }
    else {
        if(a>0)puts("Positive");
        else {
            if((b-a)%2==1)puts("Positive");
            else puts("Negative");
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

vector<P> cnt1(100010);
vector<P> cnt2(100010);

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	rep(i, n) {
		if (i % 2 == 0) {
			cnt1[a[i]].first++; cnt1[a[i]].second = a[i];
		}
		else {
			cnt2[a[i]].first++; cnt2[a[i]].second = a[i];
		}
	}
	sort(ALLR(cnt1)); sort(ALLR(cnt2));
	int ans = 0;
	if (cnt1[0].second == cnt2[0].second) {
		if (cnt1[1].first < cnt2[1].first) {
			ans += n / 2 - cnt1[0].first;
			ans += n / 2 - cnt2[1].first;
		}
		else {
			ans += n / 2 - cnt1[1].first;
			ans += n / 2 - cnt2[0].first;
		}
	}
	else {
		ans += n / 2 - cnt1[0].first;
		ans += n / 2 - cnt2[0].first;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    int N,a,b;
    cin >> N>>a>>b;

    cout << min(N*a,b) << endl;

   return 0;
}

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

int se,deta[1000];

void pu1(int a){
  deta[++se] = a;
}


int cal(){
  se--;
  return deta[se+1];
}

int main(){
  int x,y;
  se = 0;
  char r[100];

  while( scanf("%s",r) != EOF){
    if(r[0] == '+'){
      x = cal();
      y= cal();
      pu1(x+y);
    }
    else if(r[0] == '-'){
      y = cal();
      x = cal();
      pu1(x-y);
    }

    else if(r[0] == '*'){
      x = cal();
      y = cal();
      pu1(x*y);
    }

    else{
      pu1(atoi(r));
    }
  }

  printf("%d\n",cal());

  return 0;
}



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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        --a[i];
    }
    vector<int> b(n);
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    vector<int> c(n - 1);
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }

    int sum = 0;
    for(int i = 0; i < n; i++){
        sum += b[a[i]];
        if(i > 0 && a[i] == a[i - 1] + 1){
            sum += c[a[i - 1]];
        }
    }

    cout << sum << endl;
   return 0;
}

Measured memory_bytes: 3600
(let* ((n (read))
       (k (read))
       (p (make-array (list n)))
       (ans 0))
  ; read
  (loop :for i :from 0 :to (1- n)
        :do (setf (aref p i) (read)))
  (setf p (sort p #'<))
  ;
  (loop :for i :from 0 :to (1- k)
        :sum (incf ans (aref p i)))
  (format t "~A~%" ans))


Measured memory_bytes: 25140
import std.stdio, std.string, std.conv;
import std.regex;

void main() {
	string l;
	string[] i;
	while ((l = stdin.readln.chomp) != "") i ~= l;
	auto d = i.join.toLower.replaceAll(regex(r"[^a-z]"), "").dup.representation;
	foreach (cp; 97..123) {
		char c = cp.to!char;
		"%c : %d".writefln(c, d.count(c));
	}
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=5005;
int n,S[N],T[N],ans=1e9;
char s[N],t[N];
void work(int v1,int v2){
	int ans=0;
	For(i,1,v1-1) ans+=S[i];
	For(i,1,v2-1) ans+=T[i];
	for (;v1<=*S&&v2<=*T;v1++,v2++)
		ans+=abs(S[v1]-T[v2]);
	for (;v1<=*S;v1++) ans+=n-S[v1];
	for (;v2<=*T;v2++) ans+=n-T[v2]; 
	::ans=min(::ans,ans);
}
int main(){
	scanf("%d%s%s",&n,s+1,t+1);
	s[0]=97-s[1]; s[n+1]=97-s[n];
	t[0]=97-t[1]; s[n+1]=97-t[n];
	For(i,1,n+1) if (s[i]!=s[i-1]) S[++*S]=i-1;
	For(i,1,n+1) if (t[i]!=t[i-1]) T[++*T]=i-1;
	For(i,1,*S) if (s[S[i]]==t[T[1]]) work(i,1);
	For(i,1,*T) if (s[S[1]]==t[T[i]]) work(1,i);
	printf("%d",ans);
}

Measured memory_bytes: 384
/* ***********************************************************************************************************
                Created By - TANISHQ GUPTA (tanishq_code_c)                                   
   ************************************************************************************************************/
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>



using namespace std;

#define int             long long
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

void stringsplitter(string s, string delim,string arr[]){
    char *ptr = strtok((char *)s.c_str(), (char *)delim.c_str());
    int i=0;
    while(ptr!=NULL){
        arr[i]=((string)ptr);
        ptr = strtok(NULL,(char *)delim.c_str());
        i++;
    }
}

int string_to_int(string s){
    int ans = 0;
    int p=1;
    for(int i=s.size()-1;i>=0;i--){
        ans += (s[i]-'0')*p;
        p *= 10;
    }
    return ans;
}


void t_c_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    
    int n;cin >> n;
    int ld = n%10;
    if(ld==2||ld==4||ld==5||ld==7||ld==9){
        cout << "hon";
    }
    else if(ld==3) cout << "bon";
    else cout << "pon"<<endl;


}



int32_t main()
{
    t_c_c();
    return 0;
}


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

typedef struct Node {
	int key;
	struct Node *prev, *next;
}Node;

Node *nil;

void init(){
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void insert(int key){
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

Node* listSearch(int key){
	Node *cur = nil->next;
	while(cur != nil && cur->key != key){
		cur = cur->next;
	}
	return cur;
}

void deleteNode(Node *t){
	if(t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst(){
	deleteNode(nil->next);
}

void deleteLast(){
	deleteNode(nil->prev);
}

void deleteKey(int key){
	deleteNode(listSearch(key));
}

int main(){
	int i,j=0,num,key;
	char order[15];
	Node *cur;
	
	scanf("%d",&num);
	init();
	for(i=0; i<num; i++){
		scanf("%s%d",order,&key);
		if(order[0]=='i') insert(key);
		else if(order[0]=='d'){
		if(order[6]=='F') deleteFirst();
		else if(order[6]=='L') deleteLast();
		else deleteKey(key);
		}
	}
	cur  = nil->next;
	while(1){
		if(cur == nil) break;
		if(j++ > 0) printf(" ");
		printf("%d",cur->key);
		cur = cur->next;
	}
	printf("\n");
		
	return 0;
}

Measured memory_bytes: 31788
/*@author hussein zayed ;
        ___  ___
       |\  \|\  \
       \ \  \_\  \
        \ \   ___ \USSEIN
         \ \  \\ \ \
          \ \__\\ \_\
           \|__| \|__|
    ****************************************
    */

    #include <bits/stdc++.h>
    using namespace std;
    #define fr for(int i=0;i<n;++i)
    #define fr1 for(int i=1;i<=n;++i)
    #define cinA for(int i=0;i<n;++i){cin>>arr[i];}
    #define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
    #define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
    #define ll long long
    #define lnarray sizeof(arr)/sizeof(*arr)
    #define vi vector<int>
    #define vs vector<string>
    void Fast()
    {
        ios_base :: sync_with_stdio( 0 ) ;
        cin.tie( 0 ) ;
        cout.tie( 0 ) ;
    }
    inline int RD()
    {
        int i ;
        cin>>i;
        return i;
    }

    inline float RF()
    {
        float i ;
        cin>>i;
        return i;
    }

    inline double RDO()
    {
        double i ;
        cin>>i;
        return i;
    }

    inline string RS()
    {
        string i ;
        cin>>i;
        return i;
    }

    inline ll RLL()
    {
        ll i ;
        cin>>i;
        return i;
    }



    ll sumSet(ll n)
    {
        return (1ll*n*(n+1))/2;
    }
    string s;


    bool isPrime(int n)
    {
        if(n==1)
            return false;
        for(int i=2; i*i<=n; ++i)
        {
            if(n%i==0)
                return false;
        }
        return true;
    }
    int sumDigit(int n){
    int sum =0;
      while (n != 0)
        {
            sum+=  n % 10;
            n = n / 10;
        }
        return sum;
    }

    ll power2(int n){
      ll ans=(1<<n);
      return ans;
    }

    ll sumpow2(ll n){
     ll sum=(n*(n+1)*(2*n-1))/6;
     return sum;
    }
    vi vr;
  void printDivisors(int n)
{
vr.clear();
    for (int i=2;i<=n;i++)
        if (n%i==0)
           vr.push_back(i);
}
    int main(){
        Fast();
    //freopen("output.txt" , "w" , stdout);
    //freopen("wall.in" , "r" , stdin);
   int a,b,c;
   cin>>a>>b;
   cout<<max(a+b,max(a-b,a*b));

    }


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	const inputLines = input.split("\n");
	const line0 = inputLines[0];
	const line0vars = line0.split(" ");
	const line1 = inputLines[1];
	const line1vars = line1.split(" ");

	const n = parseInt(line0vars[0], 10);
	const k = parseInt(line0vars[1], 10);
	
	const prices = [];
	line1vars.forEach(v => prices.push(parseInt(v, 10)));

	prices.sort((a, b) => a - b);

	var result = 0;

	for (var i = 0; i < k; i++) {
		result += prices[i];
	}

	// console.log({
	// 	line1vars: line1vars,
	// 	prices: prices,
	// 	result: result
	// });

	console.log(result);

	// tmp = input[1].split(" ");
	// //文字列から10進数に変換するときはparseIntを使います
	// var a = parseInt(input[0], 10);
	// var b = parseInt(tmp[0], 10);
	// var c = parseInt(tmp[1], 10);
	// var s = input[2];

	//出力
	// console.log('%d %s',a+b+c,s);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

// node index.js
// 1
// 2 3
// test
// (Ctrl + D)


Measured memory_bytes: 29768
main(){
	int q[4],a[4],i,j;
	while(~scanf("%d%d%d%d",q,q+1,q+2,q+3)){
		int h=0,b=0;
		scanf("%d%d%d%d",a,a+1,a+2,a+3);
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(q[i]==a[j]){
					if(i==j)	h++;
					else		b++;
				}
			}
		}
		printf("%d %d\n",h,b);
	}
	exit(0);
}

Measured memory_bytes: 0
#include<iostream>
#include<cstring>
using namespace std;
int x[8]= {-1,-1,-1,0,1,1,1,0};
int y[8]= {-1,0,1,1,1,0,-1,-1}; 
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	char map[55][55];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			scanf("\n%c",&map[i][j]);
		}
	int a[55][55];
	memset(a,0,sizeof(a));
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(map[i][j]=='#')
				a[i][j]=-1;
			else
			{
				int dx,dy;
				for(int k=0;k<8;k++)
				{
					dx = i + x[k];
					dy = j + y[k];
					if(dx>=1&&dx<=n&&dy>=1&&dy<=m&&map[dx][dy]=='#')
					{
						a[i][j] ++;
					}
				}
				
			}
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(a[i][j] == -1)
				printf("#");
			else
				cout<<a[i][j];
			if(j==m)
				cout<<endl;
		}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int n, k;
	char str[20];
	int i, j;

	scanf("%d", &n);
	scanf("%s", str);
	scanf("%d", &k);

	for (i = 0; str[i] != '\0'; i++) {
		if (str[k-1] != str[i]) {
			str[i] = '*';
		}
	}
	printf("%s", str);
	return 0;
}

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

int main() {
    int ret = 10000000;
    std::string s;
    std::cin >> s;
    for (char m = 'a'; m <= 'z'; m++) {
        auto tmp = 0, c = 0;
        for (auto ch : s) {
            if (ch == m) {
                tmp = (c > tmp ? c : tmp);
                c = 0;
            } else {
                c++;
            }
        }
        tmp = (c > tmp ? c : tmp);
        ret = (tmp < ret ? tmp : ret);
    }
    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 256
S = input()
AS = ''
flag = False
hereC = 0

if S[0]=='A' and S[2:-1].count('C') == 1:
    flag = True
    hereC = S[2:-1].find('C')+2
for i in range(1,len(S)):
    if i != hereC:
        AS += S[i]

if flag and AS.islower():
    print('AC')
else:
    print('WA')


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
  int a,b,c,d,e;
  scanf("%d %d",&a,&b);
  c=a+b;
  d=a-b;
  e=a*b;
  if(c>=d&&c>=e)
    printf("%d",c);
  if(d>e&&d>c)
    printf("%d",d);
  if(e>c&&e>d)
  	printf("%d",e);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <queue>
using namespace std;

int main() {
	int N;
	int map[9][9];
	bool flg[9][9];
	cin >> N;
	while (N--) {
		memset(flg, 0, sizeof(flg));
		for (int i=0; i<9; i++)
		for (int j=0; j<9; j++)
			cin >> map[i][j];

		int cnt[3][9];

		for (int i=0; i<9; i++) {
			memset(cnt, 0, sizeof(cnt));
			for (int j=0; j<9; j++) {
				cnt[0][map[i][j]-1]++;
				cnt[1][map[j][i]-1]++;
				cnt[2][map[3*(i/3)+j/3][3*(i%3)+j%3]-1]++;
			}
			queue<int> q;
			for (int j=0; j<9; j++) {
				for (int k=0; k<3; k++) {
					if (cnt[k][j] > 1) q.push(k);
				}
				while (!q.empty()) {
					int p = q.front(); q.pop();
					for (int k=0; k<9; k++) {
						if (p==0&&map[i][k]==j+1) flg[i][k] = true;
						if (p==1&&map[k][i]==j+1) flg[k][i] = true;
						if (p==2&&map[3*(i/3)+k/3][3*(i%3)+k%3]==j+1) flg[3*(i/3)+k/3][3*(i%3)+k%3] = true;
					}
				}
			}
		}

		for (int i=0; i<9; i++) {
			for (int j=0; j<9; j++)
				cout << (flg[i][j] ? '*':' ') << map[i][j];
			cout << endl;
		}

		if (N) cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(){
	int K,S,sunadatyan=0;
	cin>>K>>S;
	for(int X=0;X<=K;X++){
		for(int Y=0;Y<=K;Y++){
			int Z=S-(X+Y);
			if(X+Y+Z==S&&Z<=K&&0<=Z){
				sunadatyan=sunadatyan+1;
			}
		}
	}
	cout<<sunadatyan<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
#include<string>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
#define PI 3.141592
#define MOD 1e9+7
using namespace std;

void solve() {
	string s, t;
	int n;
	cin >> n;
	cin >> s;
	cin >> t;

	int j = 0, k = 0;
	for (int i = 0; i < 2 * n; ++i) {
		if (i % 2 == 0) {
			cout << s[k] << flush;
			j++;
		}
		else {
			cout << t[k] << flush;
			++k;
		}
	}
	cout << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define INF 2147483647

typedef struct {
  int s[N];
}queue;

queue Q;

int n, a[N][N];
int head, tail, d[N];


void initialize(){
  head = 0;
  tail = 0;
}

void enqueue(int num){
  if(head == (tail + 1) % N){
    printf("overflow\n");
  }else{
    Q.s[tail] = num;
    if(tail + 1 == N){
      tail = 0;
    }else{
      tail++;
    }
  }
}

int dequeue(){
  int num;
  if(head == tail){
    printf("underflow\n");
    return -1;
  }else{
    num = Q.s[head];
    if(head + 1 == N){
      head = 0;
    }else{
      head++;
    }
    return num;
  }
}

void BFS(int num){
  int i, u, v;
  enqueue(num);
  for(i = 0; i < n; i++){
    d[i] = INF;
  }
  d[num] = 0;
  while(head != tail){
    u = dequeue();
    for(v = 0; v < n; v++){
      if(a[u][v] == 0) continue;
      if(d[v] != INF) continue;
      d[v] = d[u] + 1;
      enqueue(v);
    }
  }
  for(i = 0; i < n; i++){
    printf("%d ", i+1);
    if(d[i] == INF){
      printf("-1\n");
    }else{
      printf("%d\n", d[i]);
    }
  }
}

int main(){
  int i, j, u, k, v;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      a[i][j] = 0;
    }
  }
  
  for(i = 0; i < n; i++){
    scanf("%d%d", &u, &k);
    u--;
    for(j = 0; j < k; j++){
      scanf("%d", &v);
      v--;
      a[u][v] = 1;
    }
  }

  initialize();

  BFS(0);
  
  return 0;
}



Measured memory_bytes: 2148
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef long long int ll;
const int MOD = 1e9 + 7;

int main() {
    string s;
    string ans;
    cin >> s;
    for(char c : s){
        if(c == 'B'){
            if(ans.length() > 0){
                ans.pop_back();
            }
        }else{
            ans.push_back(c);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	auto a=-1%2;
	ll N;
	cin>>N;
	if(N==0)
	{
		cout<<0<<endl;
		return 0;
	}
	string res;
	for(;N!=0;)
	{
		ll r=N%2;
		if(r<0)r+=2;
		N=(N-r)/(-2);
		res.push_back((char)('0'+r));
		
	}
	reverse(res.begin(),res.end());
	cout<<res<<endl;
}


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

int main(void){
    int n;
    std::cin >> n;

    if(n == 25)
        printf("Christmas\n");
    else if(n == 24)
        printf("Christmas Eve\n");
    else if(n == 23)
        printf("Christmas Eve Eve\n");
    else if(n == 22)
        printf("Christmas Eve Eve Eve\n");

    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int N, M, Count[100005][2];
int main(){
  scanf("%d%d", &N, &M);

  for (int i = 0; i < M; i++){
    int P; string S; cin >> P >> S;
    if (Count[P][0]) continue;
    
    if (S[0] == 'A') Count[P][0]++;
    else Count[P][1]++;
  }

  int AC = 0, WA = 0;
  for (int i = 0; i < 1e5 + 5; i++){
    if (Count[i][0] == 0) continue;
    AC += Count[i][0];
    WA += Count[i][1];
  }
  cout << AC << " " << WA << endl;
  
  return 0;
}


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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	int result[100] = {};
	int pos = 0;
	while (1) {
		int n;
		int s[101] = {};
		int mini = 1001;
		int maxi = -1;
		int total = 0;

		cin >> n;
		if (n == 0) {
			break;
		}
		pos++;
		FOR(i, 1, n) {
			cin >> s[i];
			if (maxi < s[i]) {
				maxi = s[i];
			}
			if (mini > s[i]) {
				mini = s[i];
			}
			total += s[i];
		}
		result[pos] = (total - maxi - mini) / (n - 2);
		cout << result[pos] << endl;
	}
	FOR(i, 1, pos) {
		//cout << result[i] << endl;
	}

}


Measured memory_bytes: 2992
import java.util.Scanner;

public class Main {

	public static void main(String[] args){

		Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int score[] = new int[n];

        for(int i=0;i<n;i++)score[i]=0;

        for(int s=0;s<n*(n-1)/2;s++){
            int a=in.nextInt();
            int b=in.nextInt();
            a=a-1;
            b=b-1;
            int t=in.nextInt();
            int m=in.nextInt();
            if(t>m)score[a]+=3;
            else if(t<m)score[b]+=3;
            else if(t==m){
                score[a]++;
                score[b]++;
            }
        }

        int rnk[] = new int[n];

        for(int s=0;s<n;s++){
            int cnt=1;
            for(int i=0;i<n;i++){
                if(score[s]<score[i])cnt++;
            }
            rnk[s]=cnt;
        }
        for(int i=0;i<n;i++)System.out.println(rnk[i]);

	}

}


Measured memory_bytes: 47804
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define MAXM 100001
int N,M;
bool sor(pair<pair<int,int>,int> a,pair<pair<int,int>,int> b){
    if(a.first.first==b.first.first)return a.second<b.second;
    return a.first.first<b.first.first;
}
bool sor2(pair<pair<int,int>,int> a,pair<pair<int,int> ,int> b){
    return a.first.second< b.first.second;
}
int main(){
    cin >> N >> M;
    vector<pair<pair<int,int> ,int> > PV(M);
    rep(i,M){
        int P,Y;
        cin >> P >> Y;
        PV[i].first.first = P;
        PV[i].first.second = i;
        PV[i].second= Y;
    }
    sort(PV.begin(),PV.end(),sor);
    PV[0].second = 1;
    rep(i,M-1){
        if(PV[i].first.first==PV[i+1].first.first){
            PV[i+1].second = PV[i].second+1;
        }else{
            PV[i+1].second = 1;
        }
    }
    sort(PV.begin(),PV.end(),sor2);
    rep(i,M){
        printf("%06d%06d\n",PV[i].first.first,PV[i].second);
    }
    return 0;
}

Measured memory_bytes: 2688
#!/usr/bin/env python3
import sys
from collections import defaultdict

def solve(N: int, S: "List[str]"):
    d = defaultdict(int)
    for s in S:
        d[s]+=1
    print("AC x {}".format(d["AC"]))
    print("WA x {}".format(d["WA"]))
    print("TLE x {}".format(d["TLE"]))
    print("RE x {}".format(d["RE"]))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 80424
class Main
  def self.main lines
    s = lines[0].split("")
    st = []
    c = 0
    while s.length > 0
      if st.length == 0 then
        st.push s.pop
      else
        x = s.last + st.last
        if x == "01" || x == "10" then
          s.pop
          st.pop
          c += 2
        else
          st.push s.pop
        end
      end
    end
    c
  end
end

if $0 == __FILE__
#  $stdout = open('/dev/null', 'w')
  r = Main.main STDIN.readlines
#  $stdout = STDOUT
  puts r
end

Measured memory_bytes: 11388
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let n = n%1000;
    if n == 0 {
        println!("0");
    } else {
        println!("{}", 1000-n);
    }
}

Measured memory_bytes: 2160
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
char s[4];
cin >> s;
int ans=0;
REP(i,4) {
  if(s[i]=='+') {
    ans++;
  } else {
    ans--;
  }
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> a(N);
    vector<string> b(N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
        if(1 <= a[i] && a[i] < 400) b[i] = "Grey";
        else if(400 <= a[i] && a[i] < 800) b[i] = "Brawn";
        else if(800 <= a[i] && a[i] < 1200) b[i] = "Green";
        else if(1200 <= a[i] && a[i] < 1600) b[i] = "Cyan";
        else if(1600 <= a[i] && a[i] < 2000) b[i] = "Blue";
        else if(2000 <= a[i] && a[i] < 2400) b[i] = "Yellow";
        else if(2400 <= a[i] && a[i] < 2800) b[i] = "Orange";
        else if(2800 <= a[i] && a[i] < 3200) b[i] = "Red";
        else if(a[i] >= 3200) b[i] = "Black";
    }
    map<string,int> mp;
    int SS = 0;
    int SB = 0;
    for(int i = 0; i < N; i++){
        if(b[i] == "Black") SB++;
        else if(mp.count(b[i])) mp[b[i]]++;
        else{
            mp[b[i]] = 1;
            SS++;
        }
    }
    if(SS == 0) cout << 1 << " " << SB << endl;
    else cout << SS << " " << SS + SB << endl;    
}

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

const int maxn = 30005;
int n;
string s;
int d[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n >> s;
    for (int i = 0; i < n; i++) {
        d[i] = s[i]-'0';
    }
    int ans = 0;
    for (int d1 = 0; d1 <= 9; d1++) {
        for (int d2 = 0; d2 <= 9; d2++) {
            for (int d3 = 0; d3 <= 9; d3++) {
                vector<int> v = {d1,d2,d3};
                int p = 0;
                for (int i = 0; i < n; i++) {
                    if (p < 3 && d[i] == v[p]) {
                        p++;
                    }
                }
                if (p == 3) {
                    ans++;
                }
            }
        }
    }
    cout << ans << '\n';
}



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

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

#define pb push_back
#define pf push_front
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, a;
  cin >> n;
  deque<int> b;
  rep(i, n) {
    cin >> a;
    if (i % 2 == 0) b.pb(a);
    else b.pf(a);
  }
  if (n % 2 == 1) reverse(b.begin(), b.end());
  cout << b[0];
  FOR(i, 1, n) cout << " " << b[i];
  cout << endl;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;


int main() {

    int N; cin >> N;
    int _max = 0;
    map<string, int> _str;
    REP(i, N){
        string s;
        cin >> s;
        _str[s]++;
    }

    for(auto itr = _str.begin(); itr != _str.end(); ++itr) {
        _max = max(_max, itr->second);
    }
    for(auto itr = _str.begin(); itr != _str.end(); ++itr) {
        if( itr->second == _max ){
            cout << itr->first << endl;
        }
    }
    
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 25216
#include <stdio.h>
#define NUMBER 100

void print_array(int array[],int num){
	int i;
	
	for(i = 0; i < num - 1; i++)
		printf("%d ", array[i]);
	
	//スペースを出力したくないので最後の要素だけfor文外で出力
	printf("%d\n", array[i]);
}

void insertionSort(int array[],int num){
	int i, j, v;
	for(i = 1; i <= num - 1 ; i++){
		v = array[i];
		j = i - 1;
		while(j >= 0 && array[j] > v){
			array[j + 1] = array[j];
			j--;
		}
		array[j + 1] = v;
		//配列の出力
		print_array(array, num);
	}
}

int main(void){
	int array[NUMBER];
	int num, i;
	
	scanf("%d", &num);
	
	for(i = 0; i < num; i++){
		//配列を入力
		scanf("%d", &array[i]);
	}
	print_array(array, num);
	
	//挿入ソート
	insertionSort(array, num);

	
	return 0;
}


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

// 入力
int N, M;
bool a[100010];

// DP テーブル
long long dp[100010];

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

    cin >> N >> M;
    for (int i = 0; i < M; ++i){
    	int x; cin >> x;
    	a[x] = true;
    }

    // 初期化 (最小化問題なので INF に初期化)
    memset(dp, 0, sizeof(dp));

    // 初期条件
    dp[0] = 1;
    if(a[1]) dp[1] = 0;
    else dp[1] = 1;

    // ループ
    for (int i = 2; i <= N; ++i) {
        if(a[i]) dp[i] = 0;
        else dp[i] = (dp[i-1] + dp[i-2]) % 1000000007;
    }

    // 答え
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1152
h, w, k = map(int, input().split())

r_n = [0] * h
c_n = [0] * w
bomb_table = set()
for i in range(k):
    hi, wi = map(int, input().split())
    hi -= 1
    wi -= 1
    r_n[hi] += 1
    c_n[wi] += 1
    bomb_table.add((hi, wi))

max_x = max(c_n)
max_y = max(r_n)
ans = max_x + max_y

max_x_table = set()
max_y_table = set()

for i in range(h):
    if r_n[i] == max_y:
        max_y_table.add(i)

for i in range(w):
    if c_n[i] == max_x:
        max_x_table.add(i)

for i in max_y_table:
    for j in max_x_table:
        if (i, j) not in bomb_table:
            print(ans)
            exit(0)
print(ans - 1)


Measured memory_bytes: 215772
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <queue>

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;
#define HMAX 50
int H,W;
bool white[HMAX][HMAX];
bool alr[HMAX][HMAX];
int dx[4] = {0 , -1 , 0 , 1};
int dy[4] = {1 , 0 , -1 , 0};
bool ans = false;
int ans_count = 0;

queue<int> nx;
queue<int> ny;
queue<int> cot;

void BFS(int co,int x,int y){
	if(x == W-1 && y == H-1){
		ans = true;
		ans_count = co;
	}
	rep(i,0,4){
		if(0<=x+dx[i] && x+dx[i]<W && 0<=y+dy[i] && y+dy[i]<H && !alr[y+dy[i]][x+dx[i]] && white[y+dy[i]][x+dx[i]] && !ans){
			nx.push(x+dx[i]);
			ny.push(y+dy[i]);
			cot.push(co+1);
			alr[y+dy[i]][x+dx[i]] = true;
		}
	}
}

int main(){
	char C;
	cin >> H >> W;
	int kosu=0;
	rep(i,0,H){
		rep(j,0,W){
			cin >> C;
			alr[i][j] == false;
			if(C == '.'){
				white[i][j] = true;
				kosu++;
			}else{
				white[i][j] = false;
			}
		}
	}
	alr[0][0] = true;
	nx.push(0);ny.push(0);cot.push(1);
	while(!nx.empty()){
		BFS(cot.front(),nx.front(),ny.front());
		nx.pop();
		ny.pop();
		cot.pop();
	}
	if(ans){
		cout << kosu - ans_count << endl;
	}else{
		cout << "-1" << endl;
	}
}


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

int main()
{
	int InArray[200000] = {0};		// end is linked to start (Baumkuchen is round)
	int N;							// total data input
	int i;							// for counter
	int inputBuffer;				// buffer for input data
	int a1, a2, a3;					// the start index of each region
	long long sum;					// buffer for sum
	long long average, average2;	// sum / 3, (sum - region1) / 2
	long long a1_sum, a2_sum;		// sum of region1, region2
	long long MaxMin;				// final result
	
	scanf("%d", &N);
	for(i = 0; i < N; i++){
		cin >> inputBuffer;
		InArray[i] = inputBuffer;
		InArray[i + N] = inputBuffer;
	}

	
	// Calculate sum and average
	sum = 0;
	for(i = 0; i < N; i++){
		sum += InArray[i];
	}
	if(sum % 3 == 0){
		average = sum / 3;
	}else{
		average = sum / 3 + 1;
	}
	
	MaxMin = 0;
	for(a1 = 0; a1 < N; a1++){
		a1_sum = 0;
		for(a2 = a1 + 1; a2 < (a1 + N); a2++){
			a1_sum += InArray[a2 - 1];
			if(a1_sum < average) continue;
			
			if((sum - a1_sum) % 2 == 0){
				average2 = (sum - a1_sum) / 2;
			}else{
				average2 = (sum - a1_sum + 1) / 2;
			}
			
			a2_sum = 0;
			for(a3 = a2 + 1; a3 < (a1 + N); a3++){	// left 1 for a3_sum
				a2_sum += InArray[a3 -1];
				if(a2_sum < average2) continue;
								
				if(a2_sum - InArray[a3 -1] > MaxMin){
					MaxMin = a2_sum - InArray[a3 -1];
				}
				if(sum - a1_sum - a2_sum   > MaxMin){
					MaxMin = sum - a1_sum - a2_sum;
				}
				break;
			}
			break;
		}
	}
	
	printf("%lld\n", MaxMin);
	
	return 0;
}

Measured memory_bytes: 3984
fun main() {
    val n = readLine()!!.toInt()
    val verdicts = mutableMapOf<String, Int>()
    repeat(n) {
        val verdict = readLine()!!
        verdicts[verdict] = verdicts[verdict]?.plus(1) ?: 1
    }
    listOf("AC", "WA", "TLE", "RE").forEach { verdict -> println("$verdict x ${verdicts[verdict] ?: 0}") }
}


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

int main(){
  
  int c[3][3];
  for(int i=0;i<3;i++){
    cin>>c[i][0]>>c[i][1]>>c[i][2];
  }
  int a[3],b[3];
  a[0]=0;
  for(int i=0;i<3;i++){
    b[i]=c[0][i];
  }
  for(int i=1;i<=2;i++){
    a[i]=c[i][0]-b[0];
    if(a[i]+b[1]!=c[i][1]||a[i]+b[2]!=c[i][2]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	// your code goes here
	int a, b, c;
	cin >> a >> b;
	if(a == 1 and b == 2) cout << 3;
	if(a == 1 and b == 3) cout << 2;
	if(a == 2 and b == 1) cout << 3;
	if(a == 2 and b == 3) cout << 1;
	if(a == 3 and  b== 1) cout << 2;
	if(a == 3 and b == 2) cout << 1;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=(ll)1e9;

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

    int left_insert=0;
    int right_insert=0;

    for(int i=0;i<N;i++){
        if(S[i]=='(') right_insert++;
        else{
            if(right_insert==0) left_insert++;
            else right_insert--;
        }
    }

    string ans=string(left_insert,'(')+S+string(right_insert,')');
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>
#include <map>
#include <set>
#include <functional>

using namespace std;

const string YES = "Yes";
const string NO = "No";

int main()
{
  int A, B, C, K;

  cin >> A >> B >> C >> K;

  while (K > 0) {
    if (A >= B) {
      B *= 2;
    }
    else if (B >= C) {
      C *= 2;
    }

    K--;
  }

  if (A < B && B < C) {
    cout << YES << endl;
  }
  else {
    cout << NO << endl;
  }

  return 0;
}


Measured memory_bytes: 3624
j = gets.chomp.to_i

while j != 0 do
    g = []
    j.times do
        g.push(gets.chomp.to_i)
    end
    g.sort!.pop
    g.shift

    sum = 0
    (j - 2). times do |i|
        sum += g[i]
    end
    p sum / (j -2)
    j = gets.chomp.to_i
end


Measured memory_bytes: 6848
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string s, t;
  cin >> s >> t;
  int dp[3010][3010] = {0};
  for(int i = 1; i <= s.size(); i++){
    for(int j = 1; j <= t.size(); j++){
      if(s[i-1] == t[j-1]){
        dp[i][j] = dp[i-1][j-1] + 1;
      }
      else{
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }
    }
  }
  string ans = "";
  int i = (int)s.size();
  int j = (int)t.size();
  while(i>0 && j >0){
    if(dp[i][j] == dp[i-1][j]){
      i--;
    }
    else if(dp[i][j] == dp[i][j-1]){
      j--;
    }
    else{
      ans = s[i-1] + ans;
      i--;
      j--;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int niza[n];
    for(int i=0; i<n; i++)
    {
        cin>>niza[i];
    }
    int dp[n];
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    dp[1]=abs(niza[1]-niza[0]);
    for(int i=2; i<n; i++)
    {
        dp[i]=min(dp[i-1]+abs(niza[i]-niza[i-1]),dp[i-2]+abs(niza[i]-niza[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<fstream>
#include<algorithm>

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

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
    long long m,n,i,a;
    string s;
    while(cin>>n)
    {
        cin>>s;
        a=0;m=0;
        for(i=0;i<n;i++)
        {
            if(s[i]=='I')
                a++;
            else a--;
            m=max(a,m);

        }
        cout<<m<<endl;
    }
    return 0;
}


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

int main()
{
	int n,m;
	cin>>n>>m;
	
	long long k;
	cin>>k;
	
	long long DP[n],DP1[m];
	
	cin>>DP[0];
	for(int i=1;i<n;i++)
	{
		cin>>DP[i];
		DP[i]+=DP[i-1];
	}
	
	cin>>DP1[0];
	for(int i=1;i<m;i++)
	{
		cin>>DP1[i];
		DP1[i]+=DP1[i-1];
	}
	
	int ma=upper_bound(DP1,DP1+m,k) - DP1;
	
	for(int i=0;i<n;i++)
	{
		if(DP[i]<=k)
			ma=max(ma,(int)(i+1+upper_bound(DP1,DP1+m,k-DP[i])-DP1));
	}
	cout<<ma<<endl;
	return 0;
}

Measured memory_bytes: 6752
import math

n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]

distance = 0
count = 0
for i in range(n-1):
    for j in range(i+1, n):
        combined1 = [x - y for (x, y) in zip(x[i], x[j])]
        distance = math.sqrt(sum(list(map(lambda x: x**2, combined1))))
        if distance%1 == 0:
            count += 1

print(count)

Measured memory_bytes: 38384