akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

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

int main() {
    int i, n, q, key, sum = 0, S[10001];

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

    cin >> q;
    for (int t = 0; t < q; ++t) {
        cin >> key;
        if(search(S, n, key)) sum++;
    }
    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int m,d;
    std::cin >> m>>d;
    int ans=0;
    rrep(j,1,m+1)rrep(i,1,d+1){
        int a=i/10,b=i-a*10;
        if(a*b==j&&a>=2&&b>=2){
            ans++;
        //    std::cout << a<<b<<j << std::endl;
        }
    }std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int a[100000], b[100000];
int main() {
	int n, h, i, damage = 0, num = 0;
	scanf("%d%d", &n, &h);
	for (i = 0; i < n; i++) {
		scanf("%d%d", &a[i], &b[i]);
	}
	std::sort(a, a + n);
	std::sort(b, b + n);
	i = n - 1;
	while (damage < h&&a[n - 1] < b[i]) {
		damage += b[i];
		i--;
		num++;
	}
	if (damage < h) {
		num += (h - damage) / a[n - 1];
		if ((h - damage) % a[n - 1] != 0) {
			num++;
		}
	}
	printf("%d", num);
	return 0;
}

Measured memory_bytes: 896
N = int(input())

slist = []
tlist = []

for i in range(N):
    s,t = input().split()
    slist.append(s)
    tlist.append(int(t))

X = input()

ind = slist.index(X)
if ind == len(tlist) - 1:
    print(0)
else:
    itlist = tlist[(ind+1):]
    print(sum(itlist))

Measured memory_bytes: 3064
# Wrote in Feb 29, 2020 13:29 by reetok
def inp(type=:to_i,spst=" ")
  return eval("gets.chomp.split(#{spst}).map(&:#{type})")
end
def inpf() return self.inp(:to_f," ") end
def inps() return self.inp(:to_s," ") end
def r_up(a, b) (a/b).ceil end
def r_down(a, b) (a/b).floor end
def sum(a) a.inject(:+) end
def big(a,b) return (a>b)? a:b end
def small(a,b) return (a<b)? a:b end
def minp(n,datatype=:to_i)
  t = []
  n.times do
    t.push(eval("gets.chomp.#{datatype.to_s}"))
  end
end
def yes() puts "Yes" end
def no() puts "No" end
def ynju(bool,yes="Yes",no="No") puts (bool ? yes : no) end
#---------------

require 'time'
sec = gets.to_i
puts (Time.parse("1/1")+sec).strftime("%-H:%-M:%-S")



Measured memory_bytes: 7092
import scala.io.StdIn.{readLine,readInt}
import scala.language.postfixOps

object Main {
  private[this] var cnt = 0
  private[this] val l = new Array[Int](250001)
  private[this] val r = new Array[Int](250001)

  def merge(a:Array[Int],left:Int,mid:Int,right:Int) = {
    val n1 = mid-left
    val n2 = right-mid
    Array.copy(a,left,l,0,n1)
    l(n1) = Int.MaxValue
    Array.copy(a,mid,r,0,n2)
    r(n2) = Int.MaxValue
    var i=0
    var j=0
    for(k<-left until right) {
      if(l(i)<=r(j)){
        a(k) = l(i)
        i += 1
      } else  {
        a(k)=r(j)
        j += 1
      }
      cnt += 1
    }
  }

 def getSortIndex(n:Int):Iterator[IndexedSeq[(Int,Int)]] = {
    var w = n
    var h = 0
    while(w>1) {
      h += 1
      w = w/2
    }

    def scan(h:Int,l:List[IndexedSeq[(Int,Int)]]):List[IndexedSeq[(Int,Int)]] = {
      if(h==0) l
      else
        scan(h-1,(for(i<-l.head;j<-List((i._1,(i._2+i._1)/2),((i._2+i._1)/2,i._2))) yield j)::l)
    }
    scan(h-1,List(IndexedSeq((0,n/2),(n/2,n)))).to[Iterator]
  }

  def main(args:Array[String]) = {
    val n = readInt
    val a = readLine.split(" ").map(_.toInt)
    val l = getSortIndex(n)
    for(e2<-l) {
      for(e<-e2) {
        val mid = (e._2+e._1)/2
        if(e._2-e._1>1)
          merge(a,e._1,mid,e._2)
      }
    }
    merge(a,0,n/2,n)
    println(a.mkString(" "))
    println(cnt)
  }
}

Measured memory_bytes: 317212
#include<stdio.h>

int N,L,before_taste,after_taste;

int sum_of_taste(int n,int l){
  if(n>1){
    return l + sum_of_taste(n-1,l+1);
  }else{
    return l;
  }
}

int eat(int n,int l){
  if(l>=0){
    return l;
  }else if(l+n-1>=0){
    return 0;
  }else{
    return l+n-1;
  }
}

int main(){
  scanf("%d%d",&N,&L);
  before_taste = sum_of_taste(N,L);
  after_taste = before_taste - eat(N,L);
  printf("%d",after_taste);
  return 0;
}

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

int N;

void negabin(int N){
    if(!N)return;
    negabin(-(N - (N & 1)) / 2);
    putchar(48 + (N & 1));
}

int main(){
    cin >> N;
    if(!N)puts("0");
    else{
        negabin(N);
        puts("");
    }
    return 0;
}


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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  scanf("%d",&n);
  int a[100];
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int sum=0;
  for(i=0;i<n;i++) sum+=a[i];
  int min=0;
  for(i=1;i<n;i++) if(ABS(sum-n*a[i])<ABS(sum-n*a[min])) min=i;
  printf("%d\n",min);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int h,w,k;
  cin>>h>>w>>k;
  string a[h];
  int re=0;
  for(int i=0;i<h;i++){
    cin>>a[i];
  }
  for(int i=0;i<((1<<h)-1);i++){
    for(int j=0;j<((1<<w)-1);j++){
      int blackn=0;
      for(int p=0;p<h;p++){
        for(int l=0;l<w;l++){
          if(((i>>p)&1)==0&&((j>>l)&1)==0&&a[p][l]=='#'){
			  blackn++;
		  }
		}
      }    
      if(blackn==k){
        re++;
	  }
    }
  }
  cout<<re<<endl;
  return 0;
}


Measured memory_bytes: 3604
S = input()

words = ['dream','dreamer','erase','eraser']

damm = True

T = ''

while damm:
    damm = False
    for test in words:
        if S.endswith(test+T):
            T = test + T
            damm = True
            break
    if S == T:
        damm = True
        break

if damm:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3428
#include <stdio.h>

int main(void){
	int h,w;
	int i,j;

	do{
		scanf("%d %d",&h,&w);
		if(h == 0&&w == 0){
			break;
		}

		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}while(1);
	
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#define INF 1000000000000000000
using namespace std;

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

int main() {

	int n;
	ll a[100] = { 0 };
	ll ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i != j) { ans = max(ans, abs(a[i] - a[j])); }
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int h, a, b;
    int ans = 0;
    scanf("%d %d %d", &h, &a, &b);
    for (int i = a; i <= b; i++) {
        if (!(h % i)) ans++;
    }
    printf("%d\n", ans);
    return 0;
}


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

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

    int a, b;
    cin >> a >> b;

    cout << max(a+b, max(a-b, a*b)) << endl;
}

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

bool check(int x) {
    if (x / 10000 != x % 10) {
        return false;
    }
    if ((x / 1000) % 10 != (x % 100) / 10) {
        return false;
    }
    return true;
}

int main(void) {
    int A, B;
    cin >> A >> B;
    int cnt = 0;
    for (int i = A; i <= B; i++) {
        if (check(i)){
            cnt++;
        }
    }
    cout << cnt << endl;
}

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


Measured memory_bytes: 128
import collection.mutable.ArrayBuffer
import scala.reflect.ClassTag
import scala.language.implicitConversions

trait Graph { 
    case class Edge[T:Numeric](from : Int, to : Int, cost : T)

    class Edges[T:Numeric](val data : ArrayBuffer[Edge[T]]) {
        def size = data.size
    }
    object Edges {
        def apply[T:Numeric](xs : Edge[T]*) = new Edges(ArrayBuffer(xs:_*))
        implicit def toUnderLying[T](x:Edges[T]) = x.data
    }

    class WeightedGraph[T:Numeric](val size : Int, val data : Array[Edges[T]]) {
        def this(size : Int) = this(size, Array.fill(size)(Edges()))
    }
    object WeightedGraph {
        def apply[T:Numeric](size : Int) = new WeightedGraph[T](size)
        implicit def toUnderLying[T](x:WeightedGraph[T]) = x.data
    }

    class UnWeightedGraph[T:Numeric](val size : Int, val data: Array[ArrayBuffer[T]]) {
        def this(size : Int) = this(size, Array.fill(size)(ArrayBuffer[T]()))
    }
    object UnWeightedGraph {
        def apply[T:Numeric](size : Int) = new UnWeightedGraph[T](size)
        implicit def toUnderLying[T](x:UnWeightedGraph[T]) = x.data
    }
   
    class Matrix[T:Numeric:ClassTag](val row : Int, val col : Int, val data : Array[Array[T]]) {
        def this(row : Int, col : Int) = this(row, col, Array.fill(row, col)(implicitly[Numeric[T]].zero))
        def this(size : Int) = this(size, size)
    }
    object Matrix {
        implicit def toUnderLying[T](x:Matrix[T]) = x.data
    }
}
import scala.collection.mutable.PriorityQueue

object Dijkstra extends Graph {
    def dijkstra[T:ClassTag](g : WeightedGraph[T], s : Int, INF : T)(implicit num : Numeric[T]) : Array[T] = {
        import num._
        val dist = Array.fill(g.size)(INF)
        dist(s) = zero
        // (shortest path candidate, vertex)
        val que = PriorityQueue()(Ordering.Tuple2[T, Int].reverse)
        que += ((zero, s))
        while(!que.isEmpty) {
            val (d, v) = que.dequeue
            if (dist(v) >= d) {
                for (e <- g(v)) {
                    val cost = dist(v) + e.cost
                    if (dist(e.to) > cost) {
                        dist(e.to) = cost
                        que += ((cost, e.to))
                    }
                }
            }
        }
        dist
    }
}

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A
import Dijkstra._

object Main {
    def main(args: Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        val V, E, r = sc.nextInt
        val edges = WeightedGraph[Int](V)
        for (_ <- 1 to E) {
            val s, t, c = sc.nextInt
            edges(s) += Edge(s, t, c)
        }
        val res = dijkstra(edges, r, Int.MaxValue)
        if (res.isEmpty) println("NEGATIVE CYCLE")
        else {
            for (d <- res)
            if (d == Int.MaxValue) println("INF")
            else println(d)
        }
    }
}


Measured memory_bytes: 497056
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#ifdef TEST
#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock
#endif
#define int long long
#define ins insert
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define pp pop
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef double db;
typedef long long ll;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int N, _frt[10005];

inline int frt(int x) {
	if (x <= 0) return 0;
	return _frt[x] = (_frt[x] ? _frt[x] : (int)sqrt(x));
}

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	for (int n = 1, cnt, lo, hi; n <= N; n++) {
		cnt = 0;
		for (int i = 1, tmp = frt(n); i <= tmp; i++)
			for (int j = 1, tmp2 = frt(n - i * i); j <= tmp2; j++) {
				lo = 1, hi = frt(n - i * i - j * j - i * j);
				while (lo <= hi) {
					int mid = (lo + hi) >> 1ll, res = i * i + j * j + mid * mid + i * j + j * mid + i * mid;
					if (res == n) {
						cnt++;
						break;
					} else if (res > n) hi = mid - 1;
					else lo = mid + 1;
				}
			}
		cout << cnt << '\n';
	}
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> *i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

int lcs(string a,string b) {
    int n=a.size(),m=b.size();
    vector<vector<int>> dp(n+1,vector<int>(m+1,0));
    for(int i=0;i<n;i++) {
        for(int j=0;j<m;j++) {
            if(a[i]==b[j]) {
                dp[i+1][j+1]=dp[i][j]+1;
            } else {
                dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
            }
        }
    }
    return dp[n][m];
}
signed main() {
    int q;
    cin>>q;
    while(q--) {
        string x,y;
        cin>>x>>y;
        cout<<lcs(x,y)<<endl;
    }
    return 0;
}

Measured memory_bytes: 10728
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, h, m int
	fmt.Scanf("%d %d %d %d", &a, &b, &h, &m)
	answer := colon(float64(a), float64(b), float64(h), float64(m))
	fmt.Println(answer)
}

func colon(a, b, h, m float64) float64 {
	angleM := 6.0 * m
	angleH := 30.0*h + 0.5*m
	angleMH := abs(angleH - angleM)
	radian := angleMH * math.Pi / 180.0
	x := abs(b - (math.Cos(radian) * a))
	y := abs(math.Sin(radian) * a)
	return math.Sqrt(math.Pow(x, 2.0) + math.Pow(y, 2.0))
}

func abs(x float64) float64 {
	if x < 0.0 {
		return -x
	}
	return x
}


Measured memory_bytes: 1820
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N, M;
    cin >> N >> M;
    int p[M];
    string S[M];
    rep(i, M) cin >> p[i] >> S[i];
    int is_ac[N] = {0}; //その問題で、ACがとれているかどうか（取れていれば1, 取れていなければ0）
    int count_wa[N] = {0}; //その問題で、初めてACが出るまでにWAが出た回数
    rep(i, M){
        if(S[i] == "WA" && is_ac[p[i]-1] == 0){
            count_wa[p[i]-1]++;
        }
        if(S[i] == "AC") is_ac[p[i]-1] = 1;
    }
    int sum_ac = 0;
    int sum_wa = 0;
    for(int i = 0; i < N; i++){
        sum_ac += is_ac[i];
        if(is_ac[i] == 1){
            sum_wa += count_wa[i];
        }
    }
    cout << sum_ac << " " << sum_wa << endl;
    return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#define DEBUG false
using namespace std;

int nn, s;
int cmb;

void count( int n ,int k,int sa ){
  if( sa>s )
    return;

  if( DEBUG )
    cout << "n="<<n<<" k="<< k << " sa="<<sa 
	 << " cmb="<<cmb << endl;
  if( n==nn ){
    if( sa==s ) ++cmb;
    return;
  }

  for( int i=k;i<=9;i++ ){
    count( n+1,i+1, sa+i );
  }
}


int main(){
  while( cin>>nn>>s && (nn||s) ){
    if( DEBUG )
      cout << "\nnn="<<nn<<" s="<<s << endl;
    cmb = 0;
    count( 0,0,0 );
    cout << cmb << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
struct node{
  int key;
  struct node *next;
  struct node *prev;
};
 
typedef struct node * Node;
Node nil;
 
 
Node search(int key){
  Node x;
    
  x = nil->next;
    
  while(x != nil && x->key != key){
    x = x->next;
  }
  return x;
    
}
  
void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}
  
void printList(){
  Node cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}
  
void deleteNode(Node t){
  if ( t == nil ) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  
}
  
void deleteFirst(){
  deleteNode(nil->next);
}
  
void deleteLast(){
  deleteNode(nil->prev);
}
  
void delete(int key){
  Node x;
  
  if((x = search(key))!=NULL){
  
    deleteNode(x);
  }
   
}
  
  
void insert(int key){
  Node x;
  x = malloc(sizeof(struct node));
  x->key = key;
  
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
    
}
  
int main(){
  int key, n, i;
  int size = 0, np = 0, nd = 0;
  char order[20];
  
  scanf("%d", &n);

  init();

  for (i = 0 ; i < n ; i++){
    scanf("%s%d", order, &key);
    if ( order[0] == 'i' ) {
      insert(key);
      np++;
      size++;}
    else if ( order[0] == 'd' ) {
      if (strlen(order) > 6){
    if ( order[6] == 'F' ) 
      deleteFirst();
    else if ( order[6] == 'L' ) 
      deleteLast();
      } 
      else{
	  delete(key); 
	  nd++; 
      }
      size--;
    }
  }
  
  printList();
  return 0;
}

Measured memory_bytes: 34976
open System

[<EntryPoint>]
let main argv = 
    
    let inputs = stdin.ReadLine().Split(' ') |> Array.map int

    let age = inputs.[0]
    let fee = inputs.[1]

    match age with
    | age when age >= 13             -> printfn "%d" fee
    | age when age >= 6 && age <= 12 -> printfn "%d" (fee/2)
    | _                              -> printfn "%d" 0

    0 // return an integer exit code


Measured memory_bytes: 13916
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] kx = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int min = kx[1] - (kx[0] - 1);
            int max = kx[1] + (kx[0] - 1);
            
            for (int i = min; i <= max; i++)
            {
                Console.Write(i);
                if(i != max) { Console.Write(' '); }
            }
        }
    }
}


Measured memory_bytes: 13268
h, w = map(int, input().split())
s = [input().split() for _ in range(h)]
al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in range(h):
  for j in range(w):
    if s[i][j] == "snuke":
      print("{}{}".format(al[j], i+1))
      exit()
    else:
      pass

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N,C;
  cin >> N >> C;
  vector<vector<int>> value(C+1,vector<int> (C+1));
  for(int i=1; i<=C; i++){
    for(int j=1; j<=C; j++){
      cin >> value[i][j];
    }
  }
  vector<vector<int>> G(N+1, vector<int> (N+1));
  for(int i=1; i<=N; i++){
    for(int j=1; j<=N; j++){
      cin >> G[i][j];
    }
  }
  vector<vector<int>> sum(3,vector<int> (C+1,0));
  for(int i=1; i<=N; i++){
    for(int j=1; j<=N; j++){
      sum[(i+j)%3][G[i][j]]++;
    }
  }
  int ans = 1e9;
  for(int i=1; i<=C; i++){
    for(int j=1; j<=C; j++){
      for(int k=1; k<=C; k++){
        if(i==j || i==k || j==k) continue;
        int temp = 0;
        for(int l=1; l<=C; l++){
          if(i==l) continue;
          temp += sum[0][l]*value[l][i];
        }
        for(int l=1; l<=C; l++){
          if(j==l) continue;
          temp += sum[1][l]*value[l][j];
        }
        for(int l=1; l<=C; l++){
          if(k==l) continue;
          temp += sum[2][l]*value[l][k];
        }
        chmin(ans,temp);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1280
import sys
from bisect import bisect as br
readline = sys.stdin.readline

'''
def debug(rl, s):
    PAA = []
    pre = 0
    for f, g in zip(rl, s):
        if f-pre:
            PAA.extend([g]*(f-pre))
        pre = f
    print('d',med,  ''.join(map(str, PAA)))
'''
def check(x):
    s = [0, 0]
    rl = [0, A[0]]
    for a in A[1:]:
        if rl[-1] < a:
            s.append(0)
            rl.append(a)
            continue
        idx = br(rl, a-1)
        s = s[:idx+1]
        rl = rl[:idx] + [a]
        while idx and s[idx] == x-1:
            s.pop()
            rl.pop()
            idx -= 1
        if idx == 0:
            return False
        if rl[-2] == rl[-1] - 1:
            s[-1] += 1
        else:
            rl[-1] -= 1
            rl.append(rl[-1]+1)
            s.append(s[-1]+1)
        if rl[-1] != a:
            rl.append(a)
            s.append(0)
        
    return True

N = int(readline())
A = list(map(int, readline().split()))

ok = N
ng = 0
while abs(ok - ng) > 1:
    med = (ok+ng)//2
    if check(med):
        ok = med
    else:
        ng = med
print(ok)

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

using namespace std;

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

    string s,t;
    cin >> s >> t;

    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());

    cout << (s < t ? "Yes" : "No") << endl;

    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n, count = 0, flag = 0;
  char a[101], b[101], c[101];

  scanf("%d%s%s%s", &n, a, b, c);
  for (int i = 0; i < n; i++)
  {
    if (a[i] == b[i] == c[i])
    {
      count += 1;
      if (count == n)
        break;
    }
  }

  /////////////////////////////
  for (int i = 0; i < n; i++)
  {
    if (a[i] == b[i] && b[i] != c[i])
    {
      count += 1;
      if (count == n)
        break;
    }
  }
  /////////////////////////////

  /////////////////////////////
  for (int i = 0; i < n; i++)
  {
    if (b[i] == c[i] && c[i] != a[i])
    {
      count += 1;
      if (count == n)
        break;
    }
  }
  /////////////////////////////

  /////////////////////////////
  for (int i = 0; i < n; i++)
  {
    if (c[i] == a[i] && a[i] != b[i])
    {
      count += 1;
      if (count == n)
        break;
    }
  }
  /////////////////////////////

  if (count < n)
  {
    for (int i = 0; i < n; i++)
    {
      if (a[i] != b[i] && a[i] != c[i] && b[i] != c[i])
      {
        flag += 1;
        count += 1;
        if (count == n)
          break;
      }
    }
  }

  printf("%d\n", count + flag);
  return 0;
}

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

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

 string Res;


 if(S == "Sunny") {
	Res="Cloudy";
 } else if(S == "Cloudy") {
	Res="Rainy";
 } else {
	Res="Sunny";
 }

 cout << Res << endl;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
vl modinv;
void fillModInv(ll n, ll mod){
  modinv = vl(n+1);
  modinv[1] = 1;
  FOR(i,2,n+1){
    modinv[i] = modinv[mod%i] * (mod - mod/i) % mod;
  }
}
/*}}}*/
int main() {
  ll n,k;
  cin >> n >> k;
  vl h(n);
  REP(i,n) cin >> h[i];
  sort(h.begin(),h.end());
  ll ans = 0;
  REP(i,n-k) ans += h[i];
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin>>n;
    const int INF = 1e9;
    vector<int> h(n);
    for(int i =0; i<n; i++) 
        cin>>h[i];
    

    vector<vector<int> > dp(n, vector<int> (2, INF));

    dp[0][0] = dp[0][1] = 0;
    for(int i =1; i< n; i++)
    {
        dp[i][0] = min(dp[i-1][0],dp[i-1][1]) + abs(h[i] - h[i-1]);
        if(i>=2)
            dp[i][1] = min(dp[i-2][0],dp[i-2][1]) + abs(h[i] - h[i-2]);
    }

    
    cout<<min(dp[n-1][0] , dp[n-1][1])<<"\n";
}

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

using namespace std;

void input();
string s;
long long  a;
long long  b;
long long v,w,t;
void solve(){
    if( v<=w){
        cout<<"NO\n";
    }
    else{
        long long d = (v-w)*t;
      	
        if(abs(a-b)<=d){
            cout<<"YES\n";
        }
        else{
            cout<<"NO\n";
        }
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    input();
    solve();
}

void input(){
    cin>>a>>v>>b>>w;
    cin>>t;
}


Measured memory_bytes: 3604
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	minPoint, maxPoint := 123, 0
	for i := 0; i < 5; i++ {
		input, _ := strconv.Atoi(scanLine(scanner))

		if minPoint > input {
			minPoint = input
		}

		if maxPoint < input {
			maxPoint = input
		}
	}

	k, _ := strconv.Atoi(scanLine(scanner))

	if k < maxPoint - minPoint {
		fmt.Print(":(");
	} else {
		fmt.Print("Yay!");
	}
}

func scanLine(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

Measured memory_bytes: 640
import fractions as fr

N = int(input())
A = list(map(int,input().split()))

l = [0,A[0]]
r = [0,A[-1]]
for i in range(1,N-1):
    l.append(fr.gcd(l[i],A[i]))
    r.append(fr.gcd(r[i],A[-i-1]))

ans = 0
for i in range(N):
    ans = max(ans, fr.gcd(l[i],r[-i-1]))
print(ans)


Measured memory_bytes: 94816
#include <iostream>
#include <stdlib.h>
using namespace std;
#define inf 100000000000;

void merge(long* A, int left, int mid, int right, long* counter);
void mergeSort(long* A, int left, int right,long* counter);
void addCounter(long* counter);

int main(void){
  int n;
  cin>>n;
  long* A=(long*)malloc(n*sizeof(long));
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  long* counter=(long*)malloc(sizeof(long));
  *counter=0;
  mergeSort(A,0,n,counter);
  for(int i=0;i<n-1;i++){
    cout<<A[i]<<" ";
  }
  cout<<A[n-1]<<endl;
  cout<<(*counter)<<endl;
  return 0;
}


void merge(long* A, int left, int mid, int right,long* counter){
  int n1=mid-left;
  int n2=right-mid;
  long* L=(long*)malloc(sizeof(long)*(n1+1));
  long* R=(long*)malloc(sizeof(long)*(n2+1));
  for(int i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(int i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1]=inf;
  R[n2]=inf;
  int i=0;
  int j=0;
  for(int k=left;k<right;k++){
    if (L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }
    else{
      A[k]=R[j];
      j++;
    }
    addCounter(counter);
  }
}

void mergeSort(long* A, int left, int right, long* counter){
  if (left+1<right){
    int mid=(left+right)/2;
    mergeSort(A,left,mid,counter);
    mergeSort(A,mid,right,counter);
    merge(A,left,mid,right,counter);
  }
}

void addCounter(long* counter){
  *counter=(*counter)+1;
}



Measured memory_bytes: 101376
#include<bits/stdc++.h>
using namespace std;
     
#define int long long
#define hell 1000000007  
#define endl "\n"
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX_SIZE 10000000000


int32_t main()
{   
    io

    int a, b, c;
    cin>>a>>b>>c;

    cout<<min(a+b, min(b+c, c+a));

return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<queue>
#include<assert.h>
#include<tuple>
#include<string>
#include<algorithm>
#include<iostream>
#include<map>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef tuple<int,int,int> t3;

const int MX = 20;
const int MM = 1000000007;

char D[MX][MX];

int main()
{
	int N, M, cnt = 0;;
	scanf("%d%d", &N, &M);
	for(int i = 0; i < N; i++) scanf("%s", D[i]);
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			cnt += D[i][j] == '#';
		}
	}
	if( cnt != N+M-1 ) return !printf("Impossible\n");
	int x = 0, y = 0;
	for(int i = 1; i < cnt; i++){
		if( D[x+1][y] == '#' ) x++;
		else if( D[x][y+1] == '#' ) y++;
		else return !printf("Impossible\n");
	}
	printf("Possible\n");
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-9
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,K,P[200001];
	scan(N>>K);
	rep(i,N) scan(P[i]);
	set<int> st;
	int hudo=0;
	int junnum=0;
	int now=INF,rennum=1;
	bool hudof[200001]={};
	rep(i,N){
		if(P[i]>now){
			rennum++;
		}
		else{
			rennum=1;
		}
		now=P[i];
		if(rennum>=K){
			hudo++;
			hudof[i]=1;
		}

	}
	rep(i,K) st.insert(P[i]);
	rep(i,N-K){
		int le=P[i],ri=P[i+K];
		int flag1=0,flag2=0;
		if(st.lower_bound(le)==st.begin()) flag1=1;
		if(st.lower_bound(ri)==st.end()) flag2=1;
		if(flag1&&flag2&&hudof[i+K]==0) junnum++;
		st.erase(le);
		st.insert(ri);
	}
	prin(N-K+1-max(hudo-1,0)-junnum);
	return 0;
}


Measured memory_bytes: 10624
import sys
k, n = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split()))
L=[]
for i in range(0, n-1):
    L.append(abs(A[i+1]-A[i]))
L.append(k-A[-1]+ A[0])
#print(L)
print(sum(L)-max(L))

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

int main() {
 int H,W;
 cin>>H>>W;
 for(int i=0;i<W+2;i++){
   cout<<'#';
 }
 cout<<endl<<'#';
 for(int j=0; j<H;j++){
     string A;
     cin>>A;
     cout<<A;
   cout<<'#'<<endl;
   cout<<'#';
 }
  for(int i=0;i<W+1;i++){
    cout<<'#';
  }
cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  vector<vector<int>> A(3, vector<int>(3));
  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      cin >> A.at(i).at(j);
    }
  }
  int N;
  cin >> N;
  vector<int> b(N);
  for (int i = 0; i < N; i++)
  {
    cin >> b.at(i);
  }

  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      for (int k = 0; k < N; k++)
      {
        if(A.at(i).at(j) == b.at(k))
        {
          A.at(i).at(j) = 0;
        }
      }
    }
  }

  string ans = "No";
  for (int i = 0; i < 3; i++)
  {
    if(A.at(0).at(i) == A.at(1).at(i) && A.at(1).at(i) == A.at(2).at(i))
    {
      ans = "Yes";
    }
  }
  for (int i = 0; i < 3; i++)
  {
    if(A.at(i).at(0) == A.at(i).at(1) && A.at(i).at(1) == A.at(i).at(2))
    {
      ans = "Yes";
    }
  }
  if(A.at(0).at(0) == A.at(1).at(1) && A.at(1).at(1) == A.at(2).at(2))
  {
    ans = "Yes";
  }
  if(A.at(0).at(2) == A.at(1).at(1) && A.at(1).at(1) == A.at(2).at(0))
  {
    ans = "Yes";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
a_list = [int(elem) for elem in input().split(' ')]

a_count = Counter(a_list)

max_num_x = 0
for key, value in a_count.items():
    num_x = a_count[key-1] + a_count[key] + a_count[key+1]
    if num_x > max_num_x:
        max_num_x = num_x

print(max_num_x)


Measured memory_bytes: 14564
#include<bits/stdc++.h>
using namespace std;
char s[51],h[51];
int a,b,i,j;
int main()
{
    scanf("%s%s",s+1,h+1);
    a=strlen(s+1);
    b=strlen(h+1);
    if(a==b)
    {
        for(i=1;i<=a;++i)printf("%c%c",s[i],h[i]);
    }
    else 
    {
        for(i=1;i<=b;++i)printf("%c%c",s[i],h[i]);
        printf("%c",s[a]);
    }
    printf("\n");
}

Measured memory_bytes: 256
N=int(input())

dp=[0]*(N+1)
for i in range(1,N+1):
  dp[i]=dp[i-1]+1
  power6=1
  while((6**power6)<=i):
    dp[i]=min(dp[i],dp[i-(6**power6)]+1)
    power6+=1
  power9=1
  while((9**power9)<=i):
    dp[i]=min(dp[i],dp[i-(9**power9)]+1)
    power9+=1
print(dp[N])

Measured memory_bytes: 3828
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>

using namespace std;

int main() {
	long long n, m, l, a[100][100], b[100][100], c[100][100]{0};
	cin >> n >> m >> l;
	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++)
		for (int j = 0; j < l; j++)cin >> b[i][j];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < m; k++)c[i][j] += a[i][k] * b[k][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			if (j == 0)cout << c[i][j];
			else cout << " " << c[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3236
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rrep(i,n) for(long long i=(n);i>=0;--i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif

int main() {
  string T;
  ins(T);

  stack<char> st;
  rrep(i, T.size()-1) {
    if (T[i] != '?')
      st.push(T[i]);
    else {
      st.push('D');
    }
  }
  while (!st.empty()) {
    cout << st.top(); st.pop();
  }
  cout << endl;


  return 0;
}


Measured memory_bytes: 3844
#include<bits/stdc++.h>
#define reps(i,j,k) for(int i=j;i<k;i++)
#define rep(i,j) reps(i,0,j)
#define fs first
#define sc second 

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;

int main(){
	vi a(3);
	rep(i,3)cin >> a[i];
	sort(a.begin(), a.end());

	cout << a[0] + a[1] + a[2]*10 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mid (l+r)/2
#define L (x<<1)
#define R (L+1)
int dp[1000000];
int tree[4000000];
int query(int x,int l,int r,int s,int e){
    if (s>r || e<l)return 0;
    if (l>=s && r<=e)return tree[x];
    return max(query(L,l,mid,s,e),query(R,mid+1,r,s,e));
}
void upd(int x,int l,int r,int v,int val){
    if (v>r || v<l)return;
    if (l==r)tree[x]=val;
    else {
        upd(L,l,mid,v,val);
        upd(R,mid+1,r,v,val);
        tree[x]=max(tree[R],tree[L]);
    }
}
map<int,int> mp;
set<int> s;
int a[1000000];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for (int i=1;i<=n;i++) cin>>a[i], s.insert(a[i]);
    int cur=1;
    for (auto x:s){
        mp[x]=cur++;
    }
    int ret=0;
    for (int i=1;i<=n;i++) {
        a[i]=mp[a[i]];
        dp[i]=query(1,0,cur,a[i],cur)+1;
        upd(1,0,cur,a[i],dp[i]);
        ret=max(ret,dp[i]);
    }
    cout<<ret<<endl;
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { int N;
  cin >> N;
  cout << 800 * N - 200 * (N / 15) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
	int m,n;
	int a[105];
	int cnt = 0;
	int sum = 0;
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= n;i++){
		scanf("%d",&a[i]);
		sum += a[i];
	}
	double hh = (double) sum / (4 * m);
	for(int i = 1;i <= n;i++)
		if((double)a[i] >= hh) cnt++;
	if(cnt >= m) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 888
#include <cstdio>
int N, A, B, C, X, Y[109];
int main() {
	while(scanf("%d%d%d%d%d", &N, &A, &B, &C, &X), N) {
		for(int i = 0; i < N; i++) scanf("%d", &Y[i]);
		int P = 0, ret = -1;
		for(int i = 0; i <= 10000; i++) {
			if(X == Y[P]) {
				if(++P == N) {
					ret = i; break;
				}
			}
			X = (A * X + B) % C;
		}
		printf("%d\n", ret);
	}
}

Measured memory_bytes: 2596
#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
typedef unsigned long long int   ull;
typedef long long int            ll;
#define pi                 acos(-1);
int main()
{
    ull n,i,s=100,j,p;
    cin>>n;
    for(i=s,j=1;s<n;i++,j++)
    {
        p=s/100;
        s+=p;
    }
    cout<<j-1<<endl;
    return 0;
}


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

using namespace std;

long long int gcd(long long int x,long long int y) {
  return y ? gcd(y, x%y) : x;
}

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

    cout << min(abs(N-K*(N/K)),abs(N-K*(1+N/K))) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
 
int main(){
  int N;
  cin >> N;
  vector<int> A(N+1);
  vector<int> B;
  A[0] = -3;
  for(int i=1;i<=N;i++) cin >> A[i];
  bool ans1 = true;
  while(B.size() < N){
    bool ans = true;
    for(int i=A.size()-1;i>0;i--){
      if(A[i] == i){
        B.push_back(i);
        A.erase(A.begin() + i);
        ans = false;
        break;
      }
    }
    if(ans){
      ans1 = false;
      break;
    }
  }
  if(ans1){
    for(int i=N-1;i>=0;i--){
      cout << B[i] << endl;
    }
  }
  else cout << -1 << endl;
}

Measured memory_bytes: 256
dic = dict()
n, m = map(int, input().split())
A = list(map(int, input().split()))
for a in A:
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1
for i in range(m):
    b, c = map(int, input().split())
    if c in dic:
        dic[c] += b
    else:
        dic[c] = b
dic = sorted(dic.items(), key=lambda x: x[0], reverse=True)
ans = 0
for d in dic:
    if n - d[1] > 0:
        ans += d[0] * d[1]
        n -= d[1]
    else:
        ans += d[0] * n
        break
print(ans)


Measured memory_bytes: 43040
#include <utility>
#include <vector>
#include <iostream>
#include <cstdlib>
#include<bits/stdc++.h>
#include <limits>
#include <set>
#include <map>
#include <string>
#include <sstream>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef long long ll;
ul gcd(ul a, ul b){return b? gcd(b, a%b):a;}
using namespace std;

unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    char D[K];
    for(int i = 0; i < K; i++){
        cin >> D[i];
    }

    int ans = 0;
    for(int i = N; ; i++){
        int digit = GetDigit(i);
        bool notGood = false;
        for(int j = 0; j < digit; j++){
            char current = to_string(i).at(digit-1-j);
            for(int k = 0; k < K; k++){
                if(current == D[k]){
                    notGood = true;
                    k = K;
                }
            }
            if(notGood){
                j = digit;
            }
        }
        if(notGood == false){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


    


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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
const lli mod = 1000000007;


void precal() {

	return;
}

bool solve() {
	lli n = 1, o, p;
	string s;
	if ( cin >> n >> o >> p );
	else return false;
	
	cout << n+o+p - max( { n, o, p } ) << '\n';
	
	return true;
}

int main() {
	precal();
	int t = INT_MAX;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		if ( !solve() ) break;
	}
	return 0;
}


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

int n,a[200010];
long long ans=0,tot,r=1;

#define rep(i,n) for(int i=1;i<=n;i++)
int main()
{
	scanf("%d",&n);
	rep(i,n) scanf("%d",&a[i]);
	long long suma=0,sumb=0;
	rep(i,n)
	{
		while(  r<=n+1  &&  suma == sumb  )
		{
			suma^=a[r];
			sumb+=a[r];
			r++;
		}
		suma^=a[i]; sumb-=a[i];
		suma^=a[r-1]; sumb-=a[r-1];
		ans+=r-i-1;
		r--;
	}
	printf("%lld",ans);
	return 0;
} 

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

int i,j,k,set,map[150][150],sss[150][150],q[20000][2],blk,ans;
int m,n,s,t,x,y;

void mark(int x,int y){
	if(x<0 || y<0 || x>=m || y>=n)return;
	if(sss[x][y]!=set){
		map[x][y]=map[q[i][0]][q[i][1]]+1;
		sss[x][y]=set;
		q[j][0]=x;q[j][1]=y;
		j++;
	}
}

void search(int x,int y){
	mark(x-1+y%2,y-1);
	mark(x+y%2,y-1);
	mark(x-1,y);
	mark(x+1,y);
	mark(x-1+y%2,y+1);
	mark(x+y%2,y+1);
}

void check2(int x,int y,int k){
	if(x<0 || y<0 || x>=m || y>=n)return;
	if(sss[x][y]>=set || map[x][y]<=k)return;
	sss[x][y]=set+k;
	q[j][0]=x;q[j][1]=y;
	j++;
}

void check(int x,int y,int k){
	check2(x-1+y%2,y-1,k+1);
	check2(x+y%2,y-1,k+1);
	check2(x-1,y,k+1);
	check2(x+1,y,k+1);
	check2(x-1+y%2,y+1,k+1);
	check2(x+y%2,y+1,k+1);
}

int main(){
	while(scanf("%d",&m)*m){
		set+=300;
		scanf("%d %d",&n,&s);
		for(i=0;i<s;i++){
			scanf("%d %d",&x,&y);
			y--;x--;
			map[x][y]=0;
			sss[x][y]=set;
			q[i][0]=x;
			q[i][1]=y;
		}
		i=0;j=s;
		while(i<j){
			search(q[i][0],q[i][1]);
			i++;
		}
		
		scanf("%d",&t);
		ans=0;
		for(i=0;i<t;i++){
			scanf("%d %d",&x,&y);
			x--;y--;set+=300;
			blk=0;j=1;
			q[0][0]=x;q[0][1]=y;
			sss[x][y]=set;
			while(blk<j){
				check(q[blk][0],q[blk][1],sss[q[blk][0]][q[blk][1]]-set);
				blk++;
			}
			if(ans<blk)ans=blk;
		}
		printf("%d\n",ans);

	}
	return 0;
}

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

void swap(int *,int*);

int main()
{
  int a,b,c;
  cin>>a>>b>>c;

  if(a<b) swap(&a,&b);
  if(a<c) swap(&a,&c);
  if(b<c) swap(&b,&c);

  cout<<a*10+b+c<<endl;

  return 0;
}

void swap(int *a, int *b)
{
  int c;
  c = *a;
  *a = *b;
  *b = c;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int N;
	cin >> N;
	set<char>s;
	rep(i, N) {
		char c;
		cin >> c;
		s.insert(c);
	}
	if (s.size() == 3)cout << "Three";
	else cout << "Four";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <math.h>

using namespace std;
typedef pair<int, int> pii;
typedef pair<int, long double> pild;
typedef pair<long double, int> pldi;

void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
int N;
int arr[100000];
long int dp[100000][2];

void solve() {
	cin >> N;
	for (int n = 0; n < N; n++) cin >> arr[n];
	dp[1][0] = -arr[0]-arr[1];
	dp[1][1] = arr[0]+arr[1];
	for (int n = 2; n < N; n++) {
		dp[n][0] = max(dp[n-1][0]+2*arr[n-1]-arr[n],dp[n-1][1]-2*arr[n-1]-arr[n]);
		dp[n][1] = max(dp[n-1][0]+arr[n],dp[n-1][1]+arr[n]);
	}
	cout << max(dp[N - 1][0], dp[N - 1][1]) << endl;
	return;
}

Measured memory_bytes: 2176