akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define ull unsigned long long
#define ll long long
#define int long long
#define ld long double
 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
#define MX LLONG_MAX
#define MN LLONG_MIN
 
const int N=1e5+5;
const ll mod=1e9+7;
 
ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}          
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

int32_t main()                  
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    if(a>=13)
        cout<<b;
    else if(a<=5)
        cout<<0;
    else
        cout<<(b/2);
    return 0;
}  

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int a, b, d;
        cin >> a >> b >> d;
        if(a == 0)
            return 0;

        int x = -1;
        int y = -1;
        for(int x0=0; x0<=50000; ++x0){
            for(int i=0; i<2; ++i){
                int d1 = abs(d + a * x0 * (1-2*i));
                if(d1 % b == 0){
                    int y0 = d1 / b;
                    if(y0 >= 0 && (x == -1 || x0 + y0 < x + y || (x0 + y0 == x + y && x0*a + y0*b < x*a + y*b))){
                        x = x0;
                        y = y0;
                    }
                }
            }
        }

        cout << x << ' ' << y << endl;
    }
}

Measured memory_bytes: 0
import bisect,sys

while True:
    d = int(input())

    if d == 0 : break

    n = int(input())
    m = int(input())

    dis = [0]

    for i in range(n-1):
        dd = int(input())
        dis.append(dd)

    dis.sort()
    ans = 0
    for i in range(m):
        kk = int(input())
        pt = bisect.bisect_right(dis,kk)
        if (pt < n):
            ans += min(dis[pt]-kk ,kk - dis[pt-1])
        else :
            ans += min(kk - dis[pt-1],d-kk)

    print(ans)


Measured memory_bytes: 9952
#include<stdio.h>
#include<set>
using namespace std;
set<int> s;
int n,a[111111];
int main(){
	scanf("%d%*d",&n);
	for(int i=0; i<n; i++)
		scanf("%d",&a[i]);
	for(int i=0; i<n; i++)
		s.insert(a[i]);
	int X = 0, Y = 0;
	for(int i=0; i<n-1; i++){
		s.erase(a[i]);
		int now = *s.rbegin() - a[i];
		if(now > X){
			X = now;
			Y = 1;
		}else
		if(now == X)
			Y++;
	}
	printf("%d\n",Y);
	return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
 
#define INF 1234567890
#define ll long long

int N;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	ll res = 0;
	int mx = 0;
	for(int i=0; i<N; i++)
	{
		int x;
		cin >> x;
		mx = max(mx, x);
		res += mx-x;
	}
	cout << res;
	return 0;
}

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

int f(int n){
  if (n < 10) return n;
  return f(n/10) + n % 10;
}

int main(){
  int n; 
  
  cin >> n;
  printf("%s\n", (n % f(n) ? "No" : "Yes"));
  return 0;
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

def times2(dish):
    if 0<=dish & dish<=10:
        return 10-dish
    elif 11<=dish & dish<=20:
        return 20-dish
    elif 21<=dish & dish<=30:
        return 30-dish
    elif 31<=dish & dish<=40:
        return 40-dish
    elif 41<=dish & dish<=50:
        return 50-dish
    elif 51<=dish & dish<=60:
        return 60-dish
    elif 61<=dish & dish<=70:
        return 70-dish
    elif 71<=dish & dish<=80:
        return 80-dish
    elif 81<=dish & dish<=90:
        return 90-dish
    elif 91<=dish & dish<=100:
        return 100-dish
    elif 101<=dish & dish<=110:
        return 110-dish
    elif 111<=dish & dish<=120:
        return 120-dish
    elif 121<=dish & dish<=130:
        return 130-dish



    if int(dish/10)==0:
        return 0-dish
    elif int(dish/10)==1:
        return 10-dish
    elif int(dish/10)==2:
        return 20-dish
    elif int(dish/10)==3:
        return 30-dish
    elif int(dish/10)==4:
        return 40-dish
    elif int(dish/10)==5:
        return 50-dish
    elif int(dish/10)==6:
        return 60-dish
    elif int(dish/10)==7:
        return 70-dish
    elif int(dish/10)==8:
        return 80-dish
    elif int(dish/10)==9:
        return 90-dish
    elif int(dish/10)==10:
        return 100-dish
    elif int(dish/10)==11:
        return 110-dish
    elif int(dish/10)==12:
        return 120-dish
    else:
        pass

a_=times2(a)
b_=times2(b)
c_=times2(c)
d_=times2(d)
e_=times2(e)
s=[a_,b_,c_,d_,e_]
# print(s)
data=sorted(range(len(s)), key=lambda k: s[k])

ans=s[data[0]]+s[data[1]]+s[data[2]]+s[data[3]]+a+b+c+d+e
print(ans)

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <utility>

using namespace std;
struct Info {
    int mai;
    int cost;
    bool operator<(const Info& i) const
    {
        return (mai != i.mai) ? mai > i.mai : cost < i.cost;
    }
    bool operator==(const Info& i) const
    {
        return mai == i.mai and cost == i.cost;
    }
    Info operator+(const Info& i) const
    {
        return Info{mai + i.mai, cost + i.cost};
    }
};
constexpr int MAX = 100;
constexpr int RES = 49900;
constexpr int INF = 1 << 30;
const Info IINF = Info{0, INF};
Info dp[MAX + 100][RES + 100];

int main()
{
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        vector<int> p(n);
        for (int i = 0; i < n; i++) {
            cin >> p[i];
        }


        for (int i = 0; i <= MAX; i++) {
            for (int j = 0; j <= RES; j++) {
                dp[i][j] = IINF;
            }
        }
        dp[0][0] = Info{0, 0};

        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= RES; j++) {
                if (not(dp[i][j] == IINF)) {
                    const int price = p[i] % 1000;
                    dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
                    int rest = j - price;
                    for (int m = 0; m < 2 and m * 500 <= rest; m++) {
                        dp[i + 1][rest - m * 500] = min(dp[i + 1][rest - m * 500], dp[i][j] + Info{m, p[i]});
                    }
                    if (price != 0) {
                        rest = 1000 + j - price;
                        for (int m = 0; m < 2 and m * 500 <= rest; m++) {
                            dp[i + 1][rest - m * 500] = min(dp[i + 1][rest - m * 500], dp[i][j] + Info{m, p[i]});
                        }
                    }
                }
            }
        }

        Info mini = IINF;
        for (int j = 0; j <= RES; j++) {
            mini = min(mini, dp[n][j]);
        }
        cout << mini.mai << " " << mini.cost << endl;
    }
    return 0;
}

Measured memory_bytes: 42580
import Control.Monad
import Data.Array

main = do
  li <- getLine
  let [n,k,q] = map read $ words li
  as <- forM [1..q] (\_ -> do
    li <- getLine
    return $ read li
    )
  let ans = compute n k q as
  mapM_ putStrLn ans

compute :: Int -> Int -> Int -> [Int] -> [String]
compute n k q as =
    [ if a > 0 then "Yes" else "No" | a <- elems ar ]
  where
    ar = accumArray (+) (k-q) (1,n) [ (a,1) | a <- as ]

-- Kポイント持っているので、負けがK-1までなら勝ち残る。
-- 負けとは、自分以外の人が答えること。
-- 逆に言うと、一つも答えなかった人はK-Qポイントになる。
-- そこから、答えた数だけ+1される。
-- その結果が1以上か0以下かを判定すればよい。


Measured memory_bytes: 44796
#include<iostream>
#include<vector>
#include<string>
#include<cstdio>
#include<set>
#include<algorithm>
#define ll long long
using namespace std;

int c[200000]{};
int f[200000]{};
int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	for (int d = 0; d < b; d++) {
		int e;
		scanf("%d",&e);
		f[d] = e;
	}
	for (int g = 0; g < b - 1; g++) {
		c[min(f[g], f[g + 1])-1]++;
		c[max(f[g], f[g + 1])-1]--;
	}
	int s = 0;
	ll p = 0;
	for (int h = 0; h < a - 1; h++) {
		s += c[h];
		ll x, y, z;
		cin >> x >> y >> z;
		ll o= min(z + y*s, x*s);
		p += o;
	}
	cout << p << endl;
}

Measured memory_bytes: 3912
import java.io.*;
import java.util.regex.*;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader reader = new BufferedReader(
                    new InputStreamReader(System.in));
            String l;

            // 入力行数を読み飛ばす
            l = reader.readLine(); 
            Pattern a = Pattern.compile(">'(=+)#\\1~");
            Pattern b = Pattern.compile(">\\^(Q=)+~~");
            while ((l = reader.readLine()) != null) {
                Matcher ma = a.matcher(l);
                Matcher mb = b.matcher(l);
                if (ma.matches()) {
                    System.out.println("A");
                } else if (mb.matches()) {
                    System.out.println("B");
                } else {
                    System.out.println("NA");
                }
            }
        } catch (IOException e) {}
    }
}

Measured memory_bytes: 11000
#include <iostream>
#include <deque>

using namespace std;

int main() {
  int n, x;
  cin >> n;
  deque<int> a;
  for (int i = 0; i != n; ++i) {
    cin >> x;
    if (i % 2) a.push_front(x);
    else a.push_back(x);
  }
  for (int i = 0; i != n; ++i) {
    cout << (i?" ":"")<< a[n%2?n-i-1:i];
  }
  cout << endl;
}


Measured memory_bytes: 4372
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define D double
#define int long long
#define outdicimal out << fixed << setprecision(10)//TODO 小数点以下の桁数の変更


class AEntranceExamination {
public:
    void solve(std::istream &in, std::ostream &out) {
      int t, x;
      in >> t >> x;
      outdicimal << (D) t / x << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  AEntranceExamination solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
ll INF = (1LL << 40) - 1;
int MOD = 1e9+7;
main(){
    int A,B,Q;
    cin >> A >> B >> Q;
    vector<ll> S(A+2),T(B+2);
    S[0] = T[0] = -INF;
    S[A+1] = T[B+1] = INF;
    rep(i,1,A+1)cin >> S[i];
    rep(i,1,B+1)cin >> T[i];
    rep(i,0,Q){
        ll x;
        cin >> x;
        auto itrr = upper_bound(S.begin(), S.end(), x);
        auto itrl = itrr;
        itrl--;
        auto itrr2 = upper_bound(T.begin(), T.end(), x);
        auto itrl2 = itrr2;
        itrl2--;
        ll a = max(*itrr, *itrr2) - x;
        ll b = x - min(*itrl, *itrl2);
        ll c = *itrr - *itrl2 + min(*itrr - x, x - *itrl2);
        ll d = *itrr2 - *itrl + min(*itrr2 - x, x - *itrl);
        ll mini = min({a,b,c,d});
        //cout << *itrr << "," << *itrr2 << endl;
        //cout << *itrl << "," << *itrl2 << endl;
        //cout << a << " " << b << " " << c << " " << d << endl;
        cout << mini << endl;
    }
}

Measured memory_bytes: 2944
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

N=ri()
A=rr(5)
ma=min(A)
ans = 5+N//ma
ans -= 1 if N%ma==0 else 0
print(ans)

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

int main(){
    int n;cin>>n;
    ll mod=1e9+7;
    vector<int> a(n);
    vector<int> b(n+1);
    rep(i,n){
        cin>>a[i];
        b[i+1]=(b[i]+a[i])%mod;
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ll tmp=b[n]-b[i+1];
        if(tmp<0)tmp+=mod;
        ans+=(a[i]*tmp)%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4752
import sys

N,M = map(int, input().split())
li = list(map(int, input().split()))

li.sort()
x = []

if N == 1:
  print(abs(li[-1] - li[0]))
  sys.exit()
elif N >= M:
  print(0)
  sys.exit()

for index, i in enumerate(li):
  if index+1 > len(li) - 1:
    break

  x.append(abs(li[index] - li[index+1]))

x.sort(reverse=True)

for i in range(N-1):
  x.pop(0)


print(sum(x))

Measured memory_bytes: 13968
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
    execute();
    }

    private static void execute() throws IOException {
        BufferedReader br =
                new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int k = Integer.parseInt(br.readLine());
        int x = Integer.parseInt(br.readLine());
        int y = Integer.parseInt(br.readLine());
        System.out.println(calcHotelFee(n, k, x, y));
    }

    public static int calcHotelFee(int stayNum, int feeChangeDays, int feeX, int feeY) {
        if (stayNum <= feeChangeDays) {
            return stayNum * feeX;
        }
        return feeChangeDays * feeX + (stayNum - feeChangeDays) * feeY;
    }
}

Measured memory_bytes: 20692
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val a = sc.nextInt
  val b = sc.nextInt
  val c = sc.nextInt
  val d = sc.nextInt

  val res =
    if(a + b < c + d) "Right"
    else if (a + b == c + d) "Balanced"
    else "Left"

  println(res)
}

Measured memory_bytes: 25504
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数
using namespace std;

signed main() {
  int a, b;
  cin >> a >> b;
  if (a * b % 2 == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.io.{BufferedReader, InputStream, InputStreamReader, PrintWriter}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val S = sc.next
    val w = sc.nextInt()
    val ans = ((0 until S.length) filter(i => i % w == 0) map S.apply).mkString
    out.println(ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

  private def rep(n: Int)(f: Int => Unit): Unit = (0 until n) foreach f

  private def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    (0 until n) foreach (i => res(i) = f(i))
    res
  }

  private implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }

    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
      rep(a => map.getOrElseUpdate(f(a), ArrayBuffer()) += a)
      map
    }

    def rep(f: A => Unit): Unit = {
      as.indices foreach (i => f(as(i)))
    }

    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      var sum = num.zero
      rep(a => sum = num.plus(sum, f(a)))
      sum
    }

    def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.lt)
    }

    def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.gt)
    }

    private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {
      var limA = as(ixRange.head)
      var limB = f(limA)

      for (i <- ixRange.tail) {
        val a = as(i)
        val b = f(a)
        if (cmp(b, limB)) {
          limA = a
          limB = b
        }
      }
      (limA, limB)
    }
  }

  private implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
    }
  }
}


Measured memory_bytes: 27332
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    auto q = BinaryHeap!(int[])(new int[2_000_001], 0);

    string s;
    while ((s = readln.chomp).length > 0) {
        if (s == "end")
            break;

        if (s[0] == 'e') { // extract
            writeln(q.front);
            q.popFront;
        }
        else {
            auto ss = s.split;
            int x = ss[1].to!int;
            q.insert(x);
        }
    }
}

Measured memory_bytes: 11116
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
long long MAX(long long a,long long b){
    return a>b?a:b;
}
long long MIN(long long a,long long b){
    return a<b?a:b;
}
int main()
{   long long h,w;
    scanf("%lld%lld",&h,&w);
    if(h%3==0||w%3==0){
        printf("0");
        return 0;
    }
    long long min=114514;
    for(int i=1;i<h;i++){
        if(MAX(w*i,(h-i+1)/2*w)-MIN(w*i,(h-i)/2*w)<min){
            min=MAX(w*i,(h-i+1)/2*w)-MIN(w*i,(h-i)/2*w);
        }
        if(min>MAX(w*i,(w+1)/2*(h-i))-MIN(w*i,w/2*(h-i))){
            min=MAX(w*i,(w+1)/2*(h-i))-MIN(w*i,w/2*(h-i));
        }
    }
    for(int i=1;i<w;i++){
        if(MAX(h*i,(w-i+1)/2*h)-MIN(h*i,(w-i)/2*h)<min){
            min=MAX(h*i,(w-i+1)/2*h)-MIN(h*i,(w-i)/2*h);
        }
        if(min>MAX(h*i,(h+1)/2*(w-i))-MIN(h*i,h/2*(w-i))){
            min=MAX(h*i,(h+1)/2*(w-i))-MIN(h*i,h/2*(w-i));
        }
    }
    
    printf("%lld",min);
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N, Q, cnt = 0, flag = 0, L, total=0;
  string S;
  vector<long long int> l_v, r_v, s_v;
  vector<vector<long long int>> hit_v;
  cin >> N >> L;
  //cin >> S;
  for (int i = 0; i < N; i++) {
    long long int sum = 0;
    for (int j = 0; j < N; j++) {
      if (j == i) {;}
      else {
        //cout << i << " " << j << endl;
        sum += (L + j);
        //cout << sum  << endl;
      }
    }
    s_v.push_back(sum);
    total += (L + i);
  }
  long long int min = 200000;
  for (int i = 0; i < N; i++) {
    if (abs(total-min) > abs(total - s_v[i])) 
      min = s_v[i];
    //cout << s_v[i] << endl;
  }
  //cout << total << endl;
  cout << min << endl;
  // for (int i = 0; i < Q; i++) {
  //   long long int l, r;
  //   cin >> l >> r;
  //   l_v.push_back(l);
  //   r_v.push_back(r);
  // }

  // for (int i = 0; i < S.size()-1; i++) {
  //   if (S[i] == 'A' && S[i+1] == 'C') {
  //     cnt++;
  //     hit_v.push_back({i, i+1});
  //   }
  // }
  // for (int i = 0; i < Q; i++) {
  //   cnt = 0;
  //   for (int j = 0; j < hit_v.size(); j++) {
  //     if (l_v[i]-1 <= hit_v[j][0] && hit_v[j][1] <= r_v[i]-1) {
  //       cnt ++;
  //     }
  //     else if (hit_v[j][1] > r_v[i]-1) {
  //       break;
  //     }
  //   }
  //   cout << cnt << endl;
  // } 
  
  // char S[1000000] = {0};
  // vector<int> s_v, s_01v, s_10v;
  // cin >> S;
  // //cout << strlen(S) << endl;
  // for (int i = 0; i < strlen(S); i++) {
  //   s_v.push_back(S[i] - '0');
  //   switch(i%2) {
  //   case 0:
  //     s_01v.push_back(0);
  //     s_10v.push_back(1);
  //     break;
  //   case 1:
  //     s_01v.push_back(1);
  //     s_10v.push_back(0);
  //     break;
  //   }
  // }
  // long long int cnt_01 = 0, cnt_10 = 0;

  // for (int i = 0; i < strlen(S); i++) {
  //   if (s_01v[i] != s_v[i]) cnt_01++;
  //   if (s_10v[i] != s_v[i]) cnt_10++;
  // }
  // if (cnt_01 > cnt_10) {
  //   cout << cnt_10 << endl;
  // }
  // else {
  //   cout << cnt_01 << endl;
  // }
  // for (int i = 0; i < strlen(S); i++) {
  //   printf("%d ", s_v[i]);
  // }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int c, w, n;
    int[] bag;
    int min = Integer.MIN_VALUE;
    Item[] item;
    int ansW, ansN;

    void run(){
	c = 1;
	while(sc.hasNext()){
	    w = sc.nextInt();
	    if(w==0) break;
	    System.out.println("Case "+c+":");
	    c++;

	    n = sc.nextInt();
	    item = new Item[n];
	    for(int i=0; i<n; i++)
		item[i] = new Item(sc.next().split(","));

	    ansW = min;
	    ansN = min;
	    bag = new int[w+1];
	    solve();

	    for(int i=w; i>=0; i--)
		if(ansN < bag[i]){
		    ansN = bag[i];
		    ansW = i;
		}
		else if(ansN==bag[i] && ansW>i)
		    ansW = i;

	    System.out.println(ansN);
	    System.out.println(ansW);
	}
    }

    void solve(){
	for(int k=0; k<item.length; k++){
	    int size = item[k].getW();
	    int worth = item[k].getN();
	    for(int i=w; i>=0; i--){
		if(bag[i]!=min && i+size<bag.length)
		    bag[i+size] = Math.max(bag[i+size], bag[i]+worth);
	    }
	}
    }

    class Item{
	int w, n;
	Item(String[] a){
	    n = Integer.parseInt(a[0]);
	    w = Integer.parseInt(a[1]);
	}
	int getW(){ return w; }
	int getN(){ return n; }
    }
}

Measured memory_bytes: 24048
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, K, Q, A, c[111111] = {0};

  std::cin >> N >> K >> Q;

  for (int i = 0; i < Q; i ++) {
    std::cin >> A;

    c[A - 1] ++;
  }

  for (int i = 0; i < N; i ++)
    std::cout << (c[i] + K - Q > 0 ? "Yes" : "No") << std::endl;
  
  return 0;
}


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

int main() {
    ll N; cin >> N;
    ll ans = 0;
    for (int i = 1; i <= sqrt(N); i++){
        if (N % i == 0){
            ans = N / i;
        }
    }
    int cnt = 1;
    while (ans >= 10){
        ans /= 10;
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
n=int(input())
l=input()
l1=[]
c=0
for i in range(n):
  if l[i]=="#":
    c+=1
  l1.append(c)
l2=[]
for i in range(n):
  l2.append(n-(i+1)-(c-l1[i])+l1[i])
print(min(min(l2),c,n-c))
  


Measured memory_bytes: 19332
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	s := nextLine()
	d := strings.Split(s, " ")

	n, _ := strconv.Atoi(d[0])
	m, _ := strconv.Atoi(d[1])
	island := map[int][]int{}
	for i := 0; i < m; i++ {
		s = nextLine()
		d = strings.Split(s, " ")
		a, _ := strconv.Atoi(d[0])
		b, _ := strconv.Atoi(d[1])
		if _, ok := island[a]; ok {
			island[a] = append(island[a], b)
		} else {
			island[a] = []int{b}
		}
	}
	list := island[1]
	flag := 0
	for _, element := range list {
		to := island[element]
		for _, last := range to {
			if last == n {
				flag = 1
				break
			}
		}
	}
	if flag == 1 {
		fmt.Println("POSSIBLE")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}


Measured memory_bytes: 21376
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    a=list(map(int,input().split()))
    ans=INF
    for i in range(-100,101):
        tmp=0
        for x in a:
            tmp+=(x-i)**2
        ans=min(ans,tmp)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38768
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

const int maxn = 1e5 + 10;

ll max(ll x, ll y)
{
	return x < y ? y : x;
}

ll n, m, w[maxn], v[maxn], f[maxn];

int main()
{
    cin >> n >> m;
    
    for(int i = 1; i <= n; i++)
    {
        cin >> v[i] >> w[i];
    }
    
    for(int i = 1; i <= n; i++)
    {
        for(int j = m; j >= v[i]; j --)
        {
            f[j] = max(f[j], f[j - v[i]] + w[i]);
        }
    }
    cout << f[m] << endl;
    
    return 0;
}

Measured memory_bytes: 1024
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Sat Feb  9 21:24:56 2019
//
package main

import (
	"fmt"
	"sort"
)

func max(slice ...int) int {
	sort.Ints(slice)
	return slice[len(slice)-1]
}

func main() {
	var K, A, B int
	fmt.Scan(&K, &A, &B)

	n := K - (A - 1)
	if n <= 0 {
		fmt.Println(K + 1)
		return
	}

	if n%2 == 0 {
		fmt.Println(max(1+K, A+(n/2)*(B-A)))
	} else {
		fmt.Println(max(1+K, A+(n/2)*(B-A)+1))
	}

}


Measured memory_bytes: 512
H,W,K = map(int,input().split())

c = []
for _ in range(H):
    c.append(input())

ans = 0
for i in range(2**(H+W)):
    list = [[0 for _ in range(W)] for _ in range(H)]
    for j in range(H+W):
        if (i >> j) % 2 == 0:
            if j < H:
                for k in range(W):
                    list[j][k] += 1 #j行目に全部プラス1する
            else:
                for k in range(H):
                    list[k][H-j] += 1 #H-j列目に全部プラス1する
    count_k = 0
    for h in range(H):
        for w in range(W):
            if list[h][w] == 0 and c[h][w] == "#":
                count_k += 1
    if count_k == K:
        ans += 1

print(ans)

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

using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class T> ostream& operator<<(ostream &os, set<T> S){os << "{ "; for(auto s:S) os<<s<<" "; return os<<"}";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {os << "{ "; for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") "; return os<<"}";}
#ifdef np
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>void __f(const char *name, Arg1 &&arg1) { cout<<name<<" : "<<arg1<<endl;}
template<typename Arg1, typename ... Args>void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,','); cout.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif


int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
	

    int n ; cin>>n;
    int ans = 0 ;
    vi v(n); rep(i,0,n) cin>>v[i];
    
    for(int i = 0 ; i<n ;++i){
		for(int j= i+1 ; j<n; ++j){
			ans += (v[i]*v[j]);
		}
	}
	cout<<ans<<endl;
    

#ifdef np
    cerr <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
 return 0; 
 }


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;

class Point{
    int x;
    int y;
    int s;
    public Point(){
        
    }
    public Point(int x,int y,int s){
        super();
        this.x=x;
        this.y=y;
        this.s=s;
        
    }
}
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic 
        Scanner sc=new Scanner(System.in);
        int h=sc.nextInt();
        int w=sc.nextInt();
        int dis=0,white=0;
        char map[][]=new char[h][w];
        int book[][]=new int[h][w];
        int next[][]=new int[][]{{1,0},{0,1},{-1,0},{0,-1}}; 
        for(int i=0;i<h;i++){
            String s=sc.next();
            map[i]=s.toCharArray();
        }
        for(int i=0;i<h;i++)
            for(int j=0;j<w;j++){
                if(map[i][j]=='.') white++;
                book[i][j]=0;
            }
        ArrayDeque<Point> q=new ArrayDeque<Point>();
        Point start=new Point(0,0,1);
        book[0][0]=1;
        q.add(start);
        while(!q.isEmpty()){
            Point now=q.poll();
            int nowx,nowy,nows; 
            if(now.x==h-1&&now.y==w-1){
         //       System.out.println(now.s);
                dis=now.s;
                break;
            }
            for(int i=0;i<4;i++){
                nowx=now.x+next[i][0];
                nowy=now.y+next[i][1];
                if(nowx<0||nowx>=h||nowy<0||nowy>=w)
                    continue;
                if(book[nowx][nowy]==0&&map[nowx][nowy]=='.'){
                    book[nowx][nowy]=1;
                    nows=now.s+1;
                    q.add(new Point(nowx,nowy,nows));
                }
                
            }
        }
     //   System.out.println(white);
    if(dis>0)    System.out.println(white-dis);
    else System.out.println("-1");
        
        
    }
}


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

int n,a[200005],b[200005];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i];
    }
    sort(a+1,a+1+n);
    sort(b+1,b+1+n);
    if(n&1){
        cout<<b[n+1>>1]-a[n+1>>1]+1<<endl;
    }else{
        cout<<b[n>>1]+b[(n>>1)+1]-a[n>>1]-a[(n>>1)+1]+1<<endl;
    }

    return 0;
}

Measured memory_bytes: 5208
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL h,i,j,k,l,m,n,p,t,v,w,x,y,a[200040];
string s[6];
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(;i<n;i++)cin>>a[i],a[i]=-a[i];
	sort(a,a+n);
	for(i=0;++i<n;)t-=a[i/2];
	cout<<t;
}

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

using namespace std;

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

    long long n;
    cin >> n;

    if(n%2==1) cout << 0;
    else{
        long long counter = 0;
        for(long long i=10; i<=n; i*=5) counter+=(n/i);
        cout << counter;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7; 

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF_INT (1<<30)
#define INF_LL (1ll<<62)

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

map<string,int> mp;
int N;
string S;

int main(){
    cin>>N;
    rep(i,N){
        cin>>S;
        auto itr = mp.find(S);
        if(itr!=mp.end()){
            mp[S] += 1;
        } else {
            mp[S] = 1;
        }
    }
    pair<int,string> p[N];
    int now=0;
    for(auto m = mp.begin(); m!=mp.end();m++){
        p[now] = make_pair(m->second,m->first);
        now++;
    }
    sort(p,p+N,greater<pair<int,string>>());
    vector<string> ans;
    int maxi=p[0].first;
    rep(i,N)if(maxi==p[i].first)ans.push_back(p[i].second);
    sort(ALL(ans));
    for(auto aa:ans)out(aa);
    
    
}

Measured memory_bytes: 30068
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

H, W = map(int, input().split())

graph_list = []
for i in range(H):
    temp_graph_str = str(input())
    temp_list = [1 if i == "." else 0 for i in temp_graph_str]
    graph_list.append(temp_list)

graph_tree_list = []
for i in range(H):
    for j in range(W):
        temp_list = [0 for x in range(H * W)]
        if graph_list[i][j] == 1:
            if i > 0:
                if graph_list[i - 1][j] == 1:
                    temp_list[(i - 1) * W + j] = 1
            if i < H - 1:
                if graph_list[i + 1][j] == 1:
                    temp_list[(i + 1) * W + j] = 1
            if j > 0:
                if graph_list[i][j - 1] == 1:
                    temp_list[i * W + (j - 1)] = 1
            if j < W - 1:
                if graph_list[i][j + 1] == 1:
                    temp_list[i * W + (j + 1)] = 1
        graph_tree_list.append(temp_list)

graph_tree_array = np.array(graph_tree_list)

sp = shortest_path(graph_tree_array, directed=False, unweighted=True)

# print(sp)
sp[np.isinf(sp)] = 0
print(int(np.max(sp)))

Measured memory_bytes: 18676
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define D(x) cerr << #x << " = " << (x) << '\n'
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	ll n;
	set<ll> answer;
	cin >> n;
	for(ll i = 1; i * i <= n - 1; ++ i) {
		if((n - 1) % i == 0) {
			answer.insert(i);
			if(i != (n - 1) / i) answer.insert((n - 1) / i);
		}
	}
	for(ll i = 2; i * i <= n; ++ i) {
		ll x = n;
		while(x % i == 0) x /= i;
		if(x % i == 1) answer.insert(i);
	}
	cout << sz(answer) << '\n';
}


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

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

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;

void compute(ll n,int e){
  ll remain = n;
  int cnt = 0;
  while( remain && cnt+1 < e ) {
      remain /= 2;
      ++cnt;
  }
  if( remain ) {
    if( remain+(ll)cnt <= 50LL ) {
      cnt = cnt + (int)remain;
    } else {
      cnt = 50;
    }
  }
  cnt = min(cnt,50);

  cout << cnt << endl;
}


double eps = 1e-7;
#define equals(a,b) (fabs((a)-(b))<eps)

int main(){
  // ll n ;
  // cin >> n;
  // if( n == 0 ) cout << 0 << endl;
  // else {
  //   int cnt = 0;
  //   while( n ){
  //     n >>= 1;
  //     ++cnt;
  //   }
  //   cout << cnt << endl;
  // } return 0;
  srand((unsigned int)time(NULL));
  int n,m;
  cin >> n >> m;

  if( n & 1 ) {
    rep(i,(int)(n/2)) cout << "0 ";
    double maxi = 0;
    int v = -1;
    rep(i,m+1) {
      double avg = ( ((int)(n/2))*m + i ) / (double)n;
      double diff = fabs((double)i-avg);
      if( equals(diff,maxi) ) {
        v = i;
      } else if( diff > maxi ) {
        v = i;
          maxi = diff;
      }
    }
    assert( v != -1 );
    vector<int> vec;
    vec.push_back(v);
    rep(i,(int)(n/2)) vec.push_back(m);
    random_shuffle(vec.begin(),vec.end());
    rep(i,vec.size()) {
      if( i ) cout << ' ';
      cout << vec[i];
    } puts("");
  } else {
    int half = n / 2 - 1;
    vector<int> vec;
    rep(i,half) vec.push_back(0);
    
    double maxi = 0;
    int v=-1,w=-1;
    rep(i,m+1){
      rep(j,m+1){
        double avg = ( i+j+half*m ) / (double)n;
        double diff = fabs(((double)(i+j)/2.0)-avg);
        if( equals(diff,maxi) ) {
          v = i;
          w = j;
        } else if( diff > maxi ) 
          {
          v = i;
          w = j;
          maxi = diff;
        }
      }
    }
    assert( v != -1 );
    assert( w != -1 );
    vec.push_back(v);
    vec.push_back(w);
    
    rep(i,half) vec.push_back(m);
    random_shuffle(vec.begin(),vec.end());
    rep(i,vec.size()) {
      if( i ) cout << ' ';
      cout << vec[i];
    } puts("");
  }
  return 0;
  int T;
  cin >> T;
  while( T-- ) {
    ll N;
    int E;
    cin >> N >> E;
    compute(N,E);
  }
  return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;

llong A, B, C, D;

llong gcd(llong x, llong y) {
    while(x != 0 && y != 0) {
        if(x > y)
            x = x % y;
        else
            y = y % x;
    }
    return x == 0 ? y : x;
}

//正剰余
static llong modulo(llong left, llong right) {
    llong res = left % right;
    return res < 0 ? res + abs(right) : res;
}


//|{ x ∈ [1, right]; x ≡ m (mod r) }|
llong modcnt(llong right, llong r, llong m) {
    if(right == 0) return 0;
    m = modulo(m, r), r = abs(r);
    return right / r + (m <= right % r && m != 0);
}

//|{ x ∈ [left, right]; x ≡ m (mod r) }|
llong modcnt(llong left, llong right, llong r, llong m) {
    llong res = 0;
    if(left > 0)
        res -= modcnt(left - 1, r, m);  // [1, left - 1]
    else if(left < 0)
        res += modcnt(-left, r, r - m);    // [left, -1]
    
    if(right > 0)
        res += modcnt(right, r, m); // [1, right]
    else if(right < 0)
        res -= modcnt(-right - 1, r, r - m);    // [right + 1, -1]
    
    if(left <= 0 && right >= 0)
        res += m % r == 0;  // {0}
    return res;
}

int main(int argc, char **argv) {
    cin >> A >> B >> C >> D;

    llong GCD = gcd(C, D);
    llong LCM = C * D / GCD;

    llong all = B - A + 1;
    llong c_wareru = modcnt(A, B, C, 0);
    llong d_wareru = modcnt(A, B, D, 0);
    llong cd_wareru = modcnt(A, B, LCM, 0);

    llong res = all - (c_wareru + d_wareru - cd_wareru);
    cout << res << endl;
}

Measured memory_bytes: 256
{-#LANGUAGE FlexibleContexts#-}
import Control.Monad
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Bool
import Data.Fixed
import Data.Tuple
import Data.Ratio
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V

getI = read <$> getLine :: IO Int
getIs = map read . words <$> getLine :: IO [Int]
getD = read <$> getLine :: IO Double
getDs = map read . words <$> getLine :: IO [Double]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]

type Row = Integer
type Col = Integer
type PointI = (Integer, Integer)
type Point = (Int, Int)

mmm = 1000000007
fact n
    | n < 1 = 1
    | True = foldr1 (*) [1..n]
ti = toInteger
fi = fromInteger
fig = fromIntegral
rf = realToFrac

(.<.) :: Integer -> Integer -> Integer
(.<.) f g -- combination
    | g < 1 || f < 1 || f < g = 1
    | True = foldr1 (*) (take (fi g) [f,f-1..]) `div` fact g
(.>.) f g --combination with repetition
    | g < 1 || f < 1 = 1
    | True = fact (f + g - 1) `div` (fact (f - 1) * fact g)
comb = (.<.)
combWp = (.>.)

unique a = unique_ (reverse . sort $ a) [] Nothing
    where
        unique_ [] arr _ = arr
        unique_ (x:xs) arr n
            | n == Just x = unique_ xs arr n
            | otherwise = unique_ xs (x:arr) $ Just x
 
zeroume keta num
    | (length . show $ num) > keta = show num
    | otherwise = do 
        let zeros = take keta $ repeat '0'
        reverse . take keta $ (reverse . show $ num) ++ zeros
 
i2b num
    | num < 2 = show num
    | otherwise = i2b_ num []
        where
            i2b_ num str
                | num == 0 = str
                | num == 1 = '1':str
                | otherwise = do
                    let next = num `div` 2
                    let this = if odd num then '1' else '0'
                    i2b_ next (this:str)

mapIncr = mapPlus 1
mapPlus n Nothing = Just n
mapPlus n a = (+) n <$> a

countIf f = length . filter f

enumDivisor :: Int -> [Int]
enumDivisor n = do
    let sqrted = floor $ sqrt (fromIntegral n)
        smaller = filter (\x -> mod n x == 0) [1..sqrted]
        bigger = reverse $ map (div n) smaller
    if head bigger == sqrted then smaller ++ (init bigger)
    else smaller ++ bigger

-- 
--
--

main = length . unique <$> getIs >>= putStrLn . show 


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<ll,ll>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const long double eps = 1e-10;
//const double PI = M_PI; 
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/* Coding Space. */
int main(){
  string s; cin >> s;
  ll ans = INF;
  rep(i,s.size()-2){
    ans = min(ans, abs(753 - stoll(s.substr(i,3))));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define y1 stupid_cmath
#define left stupid_left
#define right stupid_right
#define vi vector <int>
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))

const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);

ll read_long() {
    ll ans = 0;
    char c;
    bool started = false;
    bool is_negative = false;
    while (true) {
        c = getchar();
        if ((c < '0' || c > '9') && c != '-' && !started) continue;
        if ((c < '0' || c > '9') && c != '-' && started) break;
        if (started) {
            ans = ans * 10;
        }
        started = true;
        if (c == '-') is_negative = true;
        else ans += c - '0';
    }
    if (is_negative) ans *= -1;
    return ans;
}

int __gcd(int a, int b) {
    if (a == 0 || b == 0) return a + b;
    if (a > b) swap(a, b);
    return __gcd(b % a, a);
}

bool solve(int n) {

    if (n == 3) {
        cout << "2 5 63" << endl;
        return true;
    }

    vector<int> v2, v3, v6;
    for (int i = 2; i <= 30000; i++) {
        if (i % 2 == 0 && i % 3 == 0) {
            v6.pb(i);
        } else if (i % 2 == 0) v2.pb(i);
        else if (i % 3 == 0) v3.pb(i);
    }

    for (int x = 2; x <= sz(v2) && x < n; x += 2) {
        int ymin = 1, ymax = sz(v3) / 2;
        // x + y <= n
        // n - x - y <= sz(v6)
        // y <= n - x
        // n - x - sz(v6) <= y
        int ry = (n - x) / 2;
        int ly = (max(0, n - x - sz(v6)) + 1) / 2;
        if (ly <= ry && max(ly, ymin) <= min(ymax, ry)) {
            int y = max(ly, ymin) * 2;
            if (n - x - y >= 0 && n - x - y <= sz(v6)) {
                for (int i = 0; i < x; i++) cout << v2[i] << " ";
                for (int i = 0; i < y; i++) cout << v3[i] << " ";
                for (int i = 0; i < n - x - y; i++) cout << v6[i] << " ";
                cout << endl;
                return true;
            }
        }
    }

    return false;
}

int main(){

    int n;
    cin >> n;

    solve(n);
    return 0;

    for (int i = 3; i <= 30000; i++) {
        if (!solve(i)) cout << i << " NO" << endl;
        if (i % 1000 == 0) cout << i << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
	int i,n,flag=0;
	char c;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>c;
		if(c=='Y') flag=1;
	}
	if(flag==1) cout<<"Four";
	else if(flag==0) cout<<"Three"; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(){
    ll n;
    cin >> n;
    string s;
    while(n>0){
        --n;
        s += (char)(n % 26 + 'a');
        n /= 26;
    }
    reverse(s.begin(), s.end());
    cout << s;
    return 0;
}


Measured memory_bytes: 3620
n, m = map(int, input().split())
x = list(map(int, input().split()))
x_sort = sorted(x)
ans = 0
if n < m:
    span = []
    for i in range(m - 1):
        span.append(x_sort[i + 1] - x_sort[i])
    span_sort = sorted(span)
    for j in range(m - n):
        ans += span_sort[j]
print(ans)

Measured memory_bytes: 13964
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    int len = s.length(), res = 0;
    for (int i = 0; i < len; i++) {
        for (int j = i + 1; j < len; j++) {
            if (s[i] == s[j]) res++;
        }
    }
    if (res) cout << "no" << endl;
    else cout << "yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void solve()
{
    long long int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a)
    {
        cout<<k;
        return;
    }
    if(k<=a+b)
    {
        cout<<a;
        return;
    }
    if(k>=a+b)
    {
        cout<<a-(k-(a+b));
        return;
    }
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String S=sc.next();
        
        if(S.equals("AAA")||S.equals("BBB")){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}


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

#define eb emplace_back
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
#define ull unsigned long long
#define all(s) s.begin(), s.end()
#define sz(a) (int)a.size()

const int INF = (int)1e9 + 7;
const int N = (int)7070 + 7;
const int MAXN = (int)5e5 + 228;

using namespace std;

int n, m, a, b;
int cntr[1010], cntc[1010], grid[1010][1010];

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

#ifdef Local
  freopen(".in", "r", stdin);
#else
  // freopen("sum.in", "r", stdin);
  // freopen("sum.out", "w", stdout);
#endif
  cin >> n >> m >> a >> b;
  for (int i = 1; i <= n - b; ++i) {
    for (int j = 1; j <= m - a; ++j) {
      grid[i][j] = 1;
    }
  }
  for (int i = n - b + 1; i <= n; ++i) {
    for (int j = m - a + 1; j <= m; ++j) {
      grid[i][j] = 1;
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cout << grid[i][j];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 5248
#include <iostream>
using namespace std;
 
int main(){
    int x, y;
 
    while(1){
        cin >> x >> y;
        if(x==0 && y==0){ 
            break;
        }else if(x < y){
            cout << x << " " << y << endl;
        }else{
            cout << y << " " << x << endl;
        }
    }
 
    return 0;
}

Measured memory_bytes: 1160