akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[10000],b[10000];
int main()
{
	scanf("%s",a+1);
	scanf("%s",b+1);
	int l=strlen(a+1);
	for(int i=1;i<=l;i++)
	{
		if(a[i]!=b[i])
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
} 

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

int main() {
  int64_t N;
  cin >> N;
  vector<int64_t> vec = {2,1};
  int64_t L = 0;
  
  for(int i = 0;i<N-1; i++){
    L = vec.at(i) + vec.at(i+1);
    vec.push_back(L);
  }
  cout << vec.at(N) << endl;
    


 
}


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

int main(){
  while(true){
    int V,d;
    std::cin >> V >> d;
    if(std::cin.eof()) break;

    int fib[V];
    fib[0] = 2; fib[1] = 3;
    for(int i=2; i<V; i++){
      fib[i] = (fib[i-1]+fib[i-2])%1001;
    }

    std::sort(fib,fib+V);

    int ans = 1;
    for(int i=0; i<V-1; i++)
      if(fib[i+1]-fib[i]>=d)
	ans++;

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

Measured memory_bytes: 1180
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(A: int, B: int, X: int):
    print(YES) if(A <= X <= A+B) else print(NO)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(A, B, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int mind = 0;
		String input = new String();
		input = sc.next();
		for(int i = 0; i < 4; i++) {
			if(String.valueOf(input.charAt(i)).equals("+"))
				mind = mind + 1;
			else
				mind = mind - 1;
		}
		System.out.println(mind);
	}
}


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

#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007

ll power(ll a,ll b){ll ans=1;while(b>0){if(b&1){ans = (ans*a);}b>>=1;a=a*a;}return ans;}
ll gcd(ll a,ll b){if(b==0){return a;}return gcd(b,a%b);}

int main() {
   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   // cout << fixed << setprecision(10);
   ll t;
   cin>>t;
   ll d=t%10;
   if(d==3){
       cout<<"bon"<<endl;
   }
   else if(d==2 || d== 4 || d==5 || d==7 || d==9){
       cout<<"hon"<<endl;
   }else{
       cout<<"pon"<<endl;
   }
	return 0;
}


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

int main()
{
    long long n, m;
    while (cin >> n >> m) {
        if (n >= 2 && m >= 2)
            cout << (n - 2) * (m - 2) << endl;
        else if (n == 1 && m == 1)
            cout << 1 << endl;
        else if (n == 1)
            cout << max(m - 2, 0LL) << endl;
        else if (m == 1)
            cout << max(n - 2, 0LL) << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
	int count;
	int n=sc.nextInt();
	int[] S=new int[n];
	for(int i=0;i<n;i++){
	    S[i]=sc.nextInt();
	}
	count=mergeSort(S,0,n);
	for(int i=0;i<n-1;i++){
	    System.out.print(S[i]+" ");
	}
	System.out.println(S[n-1]);
	System.out.println(count);
    }
    public static int merge(int[] A,int left,int mid,int right){
	int n1 = mid - left;
	int n2 = right - mid;
	int count=0;
	int[] L=new int[n1+1];
	int[] R=new int[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]=Integer.MAX_VALUE;
	R[n2]=Integer.MAX_VALUE;
	int i=0;
	int j=0;
	for(int k=left;k<right;k++){
	    if(L[i]<=R[j]){
		A[k] = L[i];
		i+=1;
		count++;
	    }else{
		A[k]=R[j];
		j+=1;
		count++;
	    }
	}
	return count;
    }
    public static int mergeSort(int[] A,int left,int right){
	int c;
	if(left+1<right){
	    int mid=(left+right)/2;;
	    c=mergeSort(A,left,mid);
	    c+=mergeSort(A,mid,right);
	    c+=merge(A,left,mid,right);
	    return c;
	}else{
	    return 0;
	}
    }
}


Measured memory_bytes: 169432
import sys

card = []
for i in range(3):
    card.append([int(x) for x in input().split()])

N = int(input())
numbers = set()
for i in range(N):
    numbers.add(int(input()))


def checker(aa):
    if len(aa) == 1 and 'x' in aa:
        print('Yes')
        sys.exit()


for i in range(3):
    for j in range(3):
        if card[i][j] in numbers:
            card[i][j] = 'x'

# checks to see if the rows
for row in card:
    s = set()
    for col in row:
        s.add(col)
    checker(s)

# checks to see if the columns
for i in range(3):
    s = set()
    for j in range(3):
        s.add(card[j][i])
    checker(s)
# diagonals
s = set()
for i in range(3):
    s.add(card[i][i])
checker(s)

a = set()
a.add(card[0][2])
a.add(card[1][1])
a.add(card[2][0])
checker(a)


print('No')


Measured memory_bytes: 3188
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
int a[maxn],b[maxn];
int n;
int main()
{
	n=read();
	ll sum=0;
	for(int i=1;i<=n;i++){
		a[i]=read()<<1;
		if(i&1)sum+=a[i];
		else sum-=a[i];
	}
	b[1]=sum>>1;
	for(int i=2;i<=n;i++)
		b[i]=a[i-1]-b[i-1];
	for(int i=1;i<=n;i++)
		writesp(b[i]);
	return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> inline void add(T &x,const T y){x=mm(x+y);}
    inline ll qpower(ll x,ll e)
    {
        ll ans=1;GG(e<0);
        while(e){if(e&1)ans=ans*x%MOD;x=x*x%MOD;e>>=1;}return ans;
    }
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e5+10;

    ll q[N],a[N];int m;
    map<ll,ll> go[N];
    void main()
    {
        int n=qread(),qq=qread();m=0;q[0]=n;
        while(qq--){ll num=qread();while(m>=0 and q[m]>=num)m--;q[++m]=num;}
        go[m][q[m]]=1;
        fd(i,m,0)
        {
            for(map<ll,ll>::iterator it=go[i].begin();it!=go[i].end();it++)
            {
                ll ln=it->FR,val=it->SE;
                if(i==0 or ln<=q[0]){a[1]+=val;a[ln+1]-=val;continue;}
                int pos=lower_bound(q,q+i,ln)-q-1;
                go[pos][q[pos]]+=(ln/q[pos])*val;
                go[pos][ln%q[pos]]+=val;
            }
        }
        fo(i,2,n) a[i]+=a[i-1];fo(i,1,n) write2(a[i]);
    }
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 34944
#include<bits/stdc++.h>
using namespace std;
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,a=-1,b=-1,m=0;
    cin>>n;
    vector<int> p(n),q(n),v(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    for(int i=0;i<n;i++){
        cin>>q[i];
    }
    for(int i=0;i<n;i++){
        v[i]=i+1;
    }
    do {
        if(a==-1){
            bool bo=true;
            for(int j=0;j<n;j++){
                if(p[j]!=v[j]){bo=false;}
            }
            if(bo){a=m;}
        }
        if(b==-1){
            bool bi=true;
            for(int j=0;j<n;j++){
                if(q[j]!=v[j]){bi=false;}
            }
            if(bi){b=m;}
        }
        m++;
    }while(next_permutation(v.begin(),v.end()));
    cout<<abs(a-b)<<endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  vector<double> p(N);
  for (int i = 0; i < N; i++) cin >> p[i];
  
  vector<double> exp_sum(N);
  
  double sum = 0;
  
  for (int i = 0; i < N; i++) {
    sum += (p[i] + 1) * 0.5;
    exp_sum[i] = sum;
  }
  
  double max;
  
  for (int i = 0; i <= N - K; i++) {
    if (i == 0) {
      max = exp_sum[K-1];
    }
    else if ((exp_sum[K+i-1] - exp_sum[i-1]) > max) {
      max = exp_sum[K+i-1] - exp_sum[i-1];
    }
  }
  
  printf("%10f", max);
  
  return 0;
}


Measured memory_bytes: 3328
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	nums := sc.nextIntSlice(3)
	sort.Sort(sort.Reverse(sort.IntSlice(nums)))
	fmt.Println(nums[0]*10 + nums[1] + nums[2])
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int x = scanner.nextInt();
        final int divide = x / 100;
        final int mod = x % 100;
        if(mod <= divide*5) {
            System.out.println(1);
            return;
        }
        final boolean[][] table = new boolean[6][x + 1];

        for (int i = 0; i < 6; i++) {
            final int price = 100 + i;
            if (x % price == 0) {
                System.out.println(1);
                return;
            }

            for (int j = 0; j <= x; j += price) {
                table[i][j] = true;
            }

            if (i == 0) {
                continue;
            }

            for (int j = price; j <= x; j++) {
                table[i][j] |= table[i - 1][j - (price)];
            }
        }

        System.out.println(table[5][x] ? 1 : 0);
    }
}


Measured memory_bytes: 23892
#include <iostream>
using namespace std;
int H, W;
char A[10][10];

int main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) cin >> A[i];
    
    int cnt = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] == '#') cnt++;
        }
    }
    if (cnt == H + W - 1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define tc ll t; cin >> t; while (t--)
#define yes cout << "APPROVED" << endl
#define no cout << "DENIED" << endl
#define sz(c) (ll) c.size()
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define trav(x,c) for(auto &x : c)
#define _for(i,a,n) for(ll i = a ; i < n ; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) trav(x,c) cout << x << " "; cout << endl;
#define dm(m) trav(x,m) cout << x.f << " " << x.s << endl;
#define godspeed ios::sync_with_stdio(0); cin.tie(0);

int main() {
    godspeed;
    map<string,ll> mp;
    ll n; cin >> n;
    ll mx = 0;
    while(n--) {
        string s; cin >> s;
        mp[s]++;
        mx = max(mp[s], mx);
    }

    trav(x,mp) if(x.s == mx) cout << x.f << endl;
}

Measured memory_bytes: 19252
#include<bits/stdc++.h>
#include<atcoder/lazysegtree>
#include<atcoder/modint>
using namespace atcoder;
using namespace std;
using lli = long long;
using mint = modint998244353;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

const mint inv9 = mint(1)/9;

struct S{
    mint x, w;
	S(mint x = 0, mint w = 1):x(x), w(w){}
};
using F = long long;

S op(S a, S b){ return S(a.x*b.w+b.x, a.w*b.w);}
S e(){ return S(); }
S mapping(F f, S a){
    if(f == 0) return a;
    return S((a.w-1)*inv9*f, a.w);
}
F composition(F f, F g){
	if(f == 0) return g;
	return f;
}

F id(){ return 0; }

lli n, q;

int main(void){
	cin >> n >> q;
	std::vector<S> v(n, {1, 1});
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);
	rep(i, n) seg.set(i, S(1, 10));
	mint ans;
	rep(i, q){
		lli l, r, d;
		cin >> l >> r >> d;
		l--;
		seg.apply(l, r, d);
		ans = seg.all_prod().x;
		printf("%d\n", ans.val());
	}
	return 0;
}


Measured memory_bytes: 10924
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char notes[110][10];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	string s;
	cin >> s;
	ll ans = 0;
	rep(i, 3) {
		if (s[i] == 'R')ans++;
	}
	if (ans == 2 && s[1] == 'S')ans--;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
using namespace std;
using ll = long long;
const int mod = 10000007;

int main() {
	ll h, w, n;
	vector<ll> y[200000];//y[x]はXがxの時のyのvector
	cin >> h >> w >> n;
	for(int i=0;i<n;i++){
		ll asd,sdf;
		cin>>asd>>sdf;
		y[asd-1].push_back(sdf-1);
	}
	for (int i = 0; i < n; i++) {
		if(!y[i].empty())sort(y[i].begin(), y[i].end());
	}
	ll memo = 0;
	for (int i = 0; i < h; i++) {
		if (y[i].empty())continue;
		if (y[i].front() <= i - 1 - memo) {
			cout << i << endl;
			return 0;
		}
		for (int j = 0; j < y[i].size(); j++) {
			if (y[i][j] == i - memo)memo++;
		}
	}
	cout << h << endl;
}


Measured memory_bytes: 11136
#include <stdio.h>
#include <iostream>
#define Re register int

int N,A[3005];
long long s[3005],f[3005][3005];

template <typename T> inline void read(T &var)
{
	T x=0; int w=0; char ch=0;
	while (!isdigit(ch)) w|=ch=='-',ch=getchar();
	while (isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	var=w?-x:x;
}
long long Solve(int l,int r)
{
	if (f[l][r]) return f[l][r];
	f[l][r]=s[r]-s[l-1]-std::min(Solve(l+1,r),Solve(l,r-1));
	return f[l][r];
}
int main(int argc, char const *argv[])
{
	read(N); for (Re i=1; i<=N; ++i) read(A[i]),f[i][i]=A[i],s[i]=s[i-1]+A[i];
	if (N==1) {printf("%d\n",A[1]); return 0;}
	printf("%lld\n",Solve(1,N)-std::min(Solve(1,N-1),Solve(2,N)));
	//for (Re i=1; i<=N; ++i)
	//	for (Re j=i; j<=N; ++j)
	//		printf("%d %d f=%d\n",i,j,f[i][j]);
	return 0;
}

Measured memory_bytes: 70144
n,k=map(int,input().split())
l=list(map(int,input().split()))

s=1
q=[0]*n
q[0]=1
r=[1]
for i in range(k):
  s=l[s-1]
  if q[s-1]==0:
    q[s-1]+=1
    r.append(s)
    if i==k-1:
      print(s)
  else:
    x=r.index(s)
    mod=len(r)-x
    t=(k-i-1)%mod
    print(r[x+t])
    break

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

int main()
{
    char b; cin >> b;
    if (b == 'A') {
        cout << "T" << endl;
    }
    else if (b == 'C') {
        cout << "G" << endl;
    }
    else if (b == 'G') {
        cout << "C" << endl;
    }
    else {
        cout << "A" << endl;
    }


}


Measured memory_bytes: 3512
//http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2676345#1
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<fstream>
#include<cstring>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define P pair<int,int>
#define ll __int64

int n,k;
int f,to,from,cost;
const int INF=222222222;

vector<P> G[1000];//first→終点 second→cost
int dist[1000];//頂点iへの最小距離

int keiro(int from,int to){
	for(int i=0;i<=n;i++)dist[i]=INF;
	//dist[from]=0;
	priority_queue<P,vector<P>,greater<P> >bfs;//first→頂点へのコスト second→頂点


	bfs.push(mp(0,from));


	while(!bfs.empty()){
		P now=bfs.top();
		bfs.pop();

		int index=now.second,ncost=now.first;


		if(dist[index]!=INF)continue;
		//cout<<index<<" "<<ncost<<endl;
		dist[index]=ncost;

		for(int i=0;i<G[index].size();i++){

			bfs.push(mp(ncost+G[index][i].second,G[index][i].first));
			//cout<<G[index][i].first<<" "<<G[index][i].second<<endl;
		}
	}

//rep(i,n+1)cout<<dist[i]<<" ";
	if(dist[to]==INF)return -1;
	return dist[to];
}
int main(){
while(cin>>n>>k,n||k){
for(int i=0;i<200;i++)G[i].clear();

for(int i=0;i<k;i++){
	cin>>f;
	if(!f){
		cin>>from>>to;
		cout<<keiro(from,to)<<endl;
	}
	else{
		cin>>from>>to>>cost;
		G[from].push_back(mp(to,cost));
		G[to].push_back(mp(from,cost));
	}
}
}
	return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	cout << (x - a) % b << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    while(n%111>0){
        n++;
    }
    cout << n << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl
#define CE cout<<endl
#define V <<" "<<

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[200010];
bool r,ra,rb,rc[200010];
string s,sa,sb,sc;
char ca,cb,cc,cd[200010];
vector<ll> va,vb,vc,vd,ve;
set<int> st;


int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>aa[i];
    }

    m=0;

    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            if(i!=j)m+=aa[i]*aa[j];
            //C aa[i]*aa[j] E;
        }
    }
    C m E;

}

Measured memory_bytes: 2304
import math
import heapq

n,m=map(int,input().split())
a=list(map(lambda x:int(x)*(-1),input().split()))

#map()とlambdaをあわせて使うことで、リストの要素をすべて-1倍した。


heapq.heapify(a) # リストのheap化(プライオリティキューにしてる)

#heapはsortではないので、割と順番はあべこべ。ただ最小値が先頭に来る。

for i in range(m):
    x=heapq.heappop(a) # heap化されたリストaから最小値を削除&その最小値を出力
    heapq.heappush(a, math.ceil(x/2)) # heap化されたリストaに要素を加える。正の数なら切り捨てはmath.floorやけど、負の数なのでmath.ceilを用いる。

print(sum(a)*(-1))

Measured memory_bytes: 14380
#include<iostream>
#include <algorithm>

using namespace std;

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

    int ab = a + b;
    int bc = b + c;
    int ca = c + a;

    cout << min(min(ab,bc),min(bc,ab)) << endl;
    */
    /*
    if(a < b){
        if(b < c) cout << a + b << endl;
        else cout << a + c << endl;
    }
    else{
        if(a < c) cout << a + c << endl;
        else cout << b + c << endl;
    }
    */
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3); 
    cout << a[0] + a[1] << endl;
    return 0;
}

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

typedef long long ll;
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
const int MAXN=7e6+10;
const int MAXM=2e3+10;
const int INF=10000000;
const int mod=1e9+7;

int n,m,f[MAXM][MAXM][2],s[MAXM][MAXM][2];

int get(int x1,int x2,int y1,int y2,int k){
    if (min(x1,x2)<0 || max(x1,x2)>=2*m) return 0;
    if (min(y1,y2)<0 || max(y1,y2)>=2*m) return 0;
    if (x1<x2) swap(x1,x2);
    if (y1<y2) swap(y1,y2);
    int sum=s[x1][y1][k];
    if (x2>0) sum-=s[x2-1][y1][k];
    if (y2>0) sum-=s[x1][y2-1][k];
    if (x2>0 && y2>0) sum+=s[x2-1][y2-1][k];
    //printf("%d %d %d %d %d\n",x1,y1,x2,y2,sum);
    return sum;
}

int main(){
    scanf("%d%d",&n,&m);
    memset(f,0,sizeof(f));
    for(int i=1;i<=n;i++){
        int a,b; char ch; scanf("%d%d %c",&a,&b,&ch);
        f[a%(2*m)][b%(2*m)][ch=='B']++;
    }
    for(int i=0;i<2*m;i++)
        for(int j=0;j<2*m;j++){
            for(int k=0;k<2;k++){
                s[i][j][k]=f[i][j][k];
                if (i!=0) s[i][j][k]+=s[i-1][j][k];
                if (j!=0) s[i][j][k]+=s[i][j-1][k];
                if (i!=0 && j!=0) s[i][j][k]-=s[i-1][j-1][k];
            }
        }
    int ans=0;
    for(int x=0;x<m;x++){
        for(int y=0;y<m;y++){
            //if (get(x,x+m,y,y+m,0)+get(0,x-1,y+1,2*m,0)+get(x+m+1,2*m,y+m+1,2*m,0)+get(0,x-1,0,y-1,0)+get(x+m+1,2*m,0,y-1,0)+get(0,x-1,y,y+m,1)+get(x,x+m,0,y-1,1)+get(x,x+m,y+m+1,2*m,1)+get(x+m+1,2*m,y,y+m,1)==6) cout<<x<<' '<<y<<endl;
            ans=max(ans,get(x,x+m-1,y,y+m-1,0)+
                        get(0,x-1,y+m,2*m-1,0)+
                        get(x+m,2*m-1,y+m,2*m-1,0)+
                        get(0,x-1,0,y-1,0)+
                        get(x+m,2*m-1,0,y-1,0)+
                        get(0,x-1,y,y+m-1,1)+
                        get(x,x+m-1,0,y-1,1)+
                        get(x,x+m-1,y+m,2*m-1,1)+
                        get(x+m,2*m-1,y,y+m-1,1));
            //if (get(x,x+m,y,y+m,1)+get(0,x-1,y+1,2*m-1,1)+get(x+m+1,2*m-1,y+m+1,2*m-1,1)+get(0,x-1,0,y-1,1)+get(x+m+1,2*m-1,0,y-1,1)+get(0,x-1,y,y+m,0)+get(x,x+m,0,y-1,0)+get(x,x+m,y+m+1,2*m-1,0)+get(x+m+1,2*m-1,y,y+m,0)==5) cout<<x<<' '<<y<<endl;
            ans=max(ans,get(x,x+m-1,y,y+m-1,1)+
                        get(0,x-1,y+m,2*m-1,1)+
                        get(x+m,2*m-1,y+m,2*m-1,1)+
                        get(0,x-1,0,y-1,1)+
                        get(x+m,2*m-1,0,y-1,1)+
                        get(0,x-1,y,y+m-1,0)+
                        get(x,x+m-1,0,y-1,0)+
                        get(x,x+m-1,y+m,2*m-1,0)+
                        get(x+m,2*m-1,y,y+m-1,0));
        }
    }
    printf("%d\n",ans);
    return 0;
}

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

#define ll long long
#define ar array

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n, a, b;
    cin >> n >> a >> b;
    cout << n / (a + b) * a + min(a, (n % (a + b))) << "\n";
}


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

int main() {
  int n,x,y;
  cin >> n >> x >> y;
  bool ans=false;
  for(int i=x; i<=y; i++){
    if(i%n==0) ans=true;
  }
  if(ans==true) cout << "OK" << endl;
  else cout << "NG" << endl;
}


Measured memory_bytes: 3636
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
 
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
//ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N;
ll A[114514],B[114514];
int main(){
	cin>>N;
	ll sumA=0,sumB=0;
	rep(i,N){
		cin>>A[i];
		sumA+=A[i];
	}
	rep(i,N){
		cin>>B[i];
		sumB+=B[i];
		A[i]-=B[i];
	}
	if(sumB>sumA)cout<<-1<<endl;
	else{
		sort(A,A+N);
		int ans=0;
		ll sum_abs=0;
		rep(i,N){
			if(A[i]<0){
				ans++;
				sum_abs-=A[i];
			}
		}
		for(int i=N-1;i>=0;i--){
			if(sum_abs>0){
				sum_abs-=A[i];
				ans++;
			}
			
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
int main()
{
	long long int i,n,p,x;
	
	cin>>n;
	long long int min=n-1;
	for(i=2;i<=sqrt(n);i++) 
    {  
        if(n%i==0)  
        {  
            p= n/i; 
			x=i+p-2;
			if(x<=min)
				min=x; 
        }  
    }  
    cout<<min<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
using namespace std;

ll n,m,ar[N],sum,t,tut[N];



int main()
{
	fast;
	cin>>n;
	fs(ar,n);
	fo(i,1,n)
	tut[ar[i]]=i;
	ll l=1;
	fo(i,2,n)
	{
		sum=max(sum,l);
		if(tut[i-1]<tut[i])
			l++;
		else
			l=1;
	}
	sum=max(sum,l);
	// cout<<sum<<endl;
	cout<<n-sum;

}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

Measured memory_bytes: 5888
#include <bits/stdc++.h>
    
using namespace std;
    
using ll = long long;
using Pii = pair<int, int>;
    
const ll INF = (ll)1e11;
    
int main() {
    string s;
    cin >> s;
    
    string w = "";
    for (auto itr = s.rbegin(); itr != s.rend(); ++itr) {
        if (w == "dreamer" || w == "eraser") {
            w = *itr;
        }
        else if (w == "dream" || w == "erase") {
            w = *itr;
        }
        else if (w.length() < 7) {
            w = *itr + w;
        } 
        else {
            cout << "NO" << endl;
            return 0;
        }
    }
    if (w == "dreamer" || w == "eraser" || w == "dream" || w == "erase") {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
 
int main()
{
  string s;
  cin >> s;
  map<char, int> mp;
  rep(i, s.size()) {
    mp[s[i]]++;
  }
  string ans = "Yes";
  if ((mp['N']==0 && mp['S']!=0) || (mp['N']!=0 && mp['S']==0)) ans = "No";
  if ((mp['E']==0 && mp['W']!=0) || (mp['E']!=0 && mp['W']==0)) ans = "No";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int h, w;
    cin >> h >> w;
    while(h!=0 || w!=0){
        int i, j;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                cout << "#" ;
            }
            cout << endl ;
        }
        cout << endl ;
        cin >> h >> w ;
    }
    return 0 ;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define dlwlrma ios::sync_with_stdio(0); cin.tie(0);
#define ll long long
int main(){
    dlwlrma
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = -1e18;
    ans=max(ans,a*c);
    ans=max(ans,a*d);
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    cout << ans << "\n";
}

Measured memory_bytes: 3644
while True:
    try:
        a,b,c,d,e,f = [int(x) for x in input().split()]
        x = (c*e - b*f)/(a*e - b*d)
        y = (c*d - a*f)/(b*d - a*e)
        if(x == 0):
            x = 0
        if(y == 0):
            y = 0

        print("{0:.3f} {1:.3f}".format(x,y))
        
    except:
        break


Measured memory_bytes: 5620
import math
n, d = map(int, input().split())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]

count = 0

for i in range(n):
    if math.sqrt((x[i] * x[i] + y[i] * y[i])) <= d:
        count += 1

print(count)

Measured memory_bytes: 116660
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_num(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int e, y;

int main() {
	cin >> e >> y;
	if (e == 0) {
		if (1868 <= y&&y <= 1911) {
			cout << "M" << y - 1868 + 1 << endl;
		}
		if (1912 <= y&&y <= 1925) {
			cout << "T" << y - 1912 + 1 << endl;
		}
		if (1926 <= y&&y <= 1988) {
			cout << "S" << y - 1926 + 1 << endl;
		}
		if (1989 <= y&&y <= 2016) {
			cout << "H" << y - 1989 + 1 << endl;
		}
	}
	if (e == 1) {
		cout << 1868 + y - 1 << endl;
	}
	if (e == 2) {
		cout << 1912 + y - 1 << endl;
	}
	if (e == 3) {
		cout << 1926 + y - 1 << endl;
	}
	if (e == 4) {
		cout << 1989 + y - 1 << endl;
	}
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD1 1000000007
#define MOD2 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ll t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<ll,ll> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m,ll MOD){if(m==0)return 1;ll t=mpowe(n,m/2,MOD);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;if(n==0) return -1;return logtwo(n/2)+1;}
int main()
{
    fastio();
   
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n,k;
        cin>>n>>k;
        ll a[n];
        cn(a,n);
        sort(a,a+n);
        ll sum=0;
        for(int i=0;i<k;i++)
            sum+=a[i];
        cout<<sum<<endl;
    }
    
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    string s;
    cin >> s;
    int n = s.size();
    vi a(n,0);
    rep(i,n){
        a[i] = s[i] -'0';
    }
    int ans = 1000; 
    rep(i,n-2){
        int tmp = 100*a[i]+10*a[i+1]+a[i+2];
        ans = min(ans,abs(753-tmp));
    }
    cout << ans << endl;
    return 0;
}
    

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

#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
#define EPS = 1e-14;
using std::vector;
using std::cout;
using std::cin;
using std::endl;
using std::max;
using std::min;
using std::swap;
using std::string;
using std::fill;
using std::pair;
using std::sort;
using std::reverse;
using std::pair;
using std::greater;
using std::priority_queue;
using std::ostream;
typedef std::complex<int> P;

template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i] << endl;
	}
	return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last) {
			out << ",";
		}
	}
	out << "]";
	return out;
}

const int MAX_QUAD = 182;
const int INF = 100000000;
const int MAX_N = 1000100;
int quad[MAX_QUAD], qodd[MAX_QUAD];
int dp[MAX_N], dp_odd[MAX_N];
int n, ODD_SIZE;

void init() {
	int m = 1;
	ODD_SIZE = 0;
	rep(k,1,MAX_QUAD)
	{
		quad[k] = k * (k + 1) * (k + 2) / 6;
		if (quad[k] % 2 != 0) {
			qodd[m] = quad[k];
			m++;
			ODD_SIZE = max(ODD_SIZE, m);
		}
	}
}

void doDP() {
	fill(dp, dp + MAX_N, INF);
	dp[0] = 0;
	rep(i,1,MAX_N)
	{
		rep(k,1,MAX_QUAD)
		{
			if (i - quad[k] >= 0) {
				dp[i] = min(dp[i - quad[k]] + 1, dp[i]);
			}
		}
	}
	//odd
	fill(dp_odd, dp_odd + MAX_N, INF);
	dp_odd[0] = 0;
	rep(i,1, MAX_N)
	{
		rep(k,1,ODD_SIZE)
		{
			if (i - qodd[k] >= 0) {
				dp_odd[i] = min(dp_odd[i - qodd[k]] + 1, dp_odd[i]);
			}
		}
	}
}

void solve() {
	init();
	doDP();
	while (cin >> n, n) {
		printf("%d %d\n", dp[n], dp_odd[n]);
	}
}

int main() {
	solve();
}

Measured memory_bytes: 10948
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Wed Jan  2 22:05:19 2019
//
package main

import (
	"fmt"
	"sort"
)

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

func main() {
	var N int
	fmt.Scan(&N)
	arr1 := make([]int, N)
	arr2 := make([]int, N)

	for i := range arr1 {
		fmt.Scan(&arr1[i])
	}

	for i := range arr2 {
		fmt.Scan(&arr2[i])
	}

	for i := range arr1 {
		if i+1 < len(arr1) {
			arr1[i+1] += arr1[i]
			arr2[i+1] += arr2[i]
		}
	}

	ans := 0
	for i := range arr1 {
		l := 0
		if i > 0 {
			l = arr2[i-1]
		}
		ans = max(ans, arr1[i]+arr2[len(arr2)-1]-l)
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();

		long min = Long.MAX_VALUE;
		long max = Long.MIN_VALUE;

		long a = 0;

		for(int i = 0;i<N;i++){
			a = sc.nextLong();
			if(a < min){
				min = a;
			};
			if(a > max){
				max = a;
			};
		}
		System.out.println(max - min);
	}
}

Measured memory_bytes: 21844
/*
There was a time, looking through myself
Wanting to pretend
If I escaped, I could fill myself
I don't think you can
Been far and wide
But that hole inside
Never really leaves
When I went away, what I really left
Left behind was me

It's telling me
To be on my way home
Million miles away
I can't stay

Each passing day, every passing face
Seems like such a blur
I long to be
Home, silently
Lying next to her
Just to get back, by her side is all
All I need to be
Cause I went away
But what I really left
Left behind was me

I need to be
Getting on my way home
A million miles away
Million miles away
I can't take
*/

//#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 510031;

int n;

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	cin>>n;
	int f=0;
	int res=n;
	while (res){
		f+=res%10;
		res/=10;
	}
	if (n%f==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main()
{
	int R[MAX],n;
	
	cin >> n;
	
	for(int i=0;i<n;i++) cin >> R[i];
	
	int maxv = -2000000000;
	int minv=R[0];
	
	for(int i=1;i<n;i++){
		maxv = max (maxv, R[i]-minv);
		minv = min (minv, R[i]);
	}
	
	cout << maxv << endl;
	return 0;
}

Measured memory_bytes: 3868
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int a,b; cin >> a >> b;
	if(a>b)swap(a,b);
	for(int i=0;i<b;i++){
		cout << a;
	}
	cout << endl;
}

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

int u1 , u2 , v1 , v2 , x1 , x2 , x , t;

int main(){
	scanf("%d %d %d %d %d" , &u1 , &u2 , &v1 , &v2 , &t);
	x1 = u1 * 60 + u2 , x2 = v1 * 60 + v2 , x = x2 - x1;
	printf("%d" , x - t);
	return 0;
}

Measured memory_bytes: 3760
//In the name of God
//SMani24
#include<bits/stdc++.h>
using namespace std;

int n;
string s;

int main() {
    cin >> s;
    n = s.size();
    string cps = s;
    reverse(cps.begin(), cps.end());
    if (s != cps) {
        cout << "No" << endl;
        return 0;
    }
    string a;
    for (int i = 0; i < (n - 1) / 2; i++)
        a += s[i];
    string b = a;
    reverse(b.begin(), b.end());
    if (a != b) {
        cout << "No" << endl;
        return 0;
    }
    a = b = "";
    for (int i = (n + 3) / 2 - 1; i < n; i++)
        a += s[i];
    b = a;
    reverse(b.begin(), b.end());
    if (a != b) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

#define LOOP(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) LOOP(i, 0, n)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359

int main(void) {
  vector<string> ans;
  while (true) {
    string s;
    getline(cin, s);
    if (s == ".")
      break;
    stack<int> st;
    bool flag = true;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '(')
        st.push(1);
      else if (s[i] == '[')
        st.push(2);
      else if (s[i] == ')') {
        if (!st.empty() && st.top() == 1)
          st.pop();
        else {
          flag = false;
          break;
        }
      } else if (s[i] == ']') {
        if (!st.empty() && st.top() == 2)
          st.pop();
        else {
          flag = false;
          break;
        }
      }
      /*
      stack<int> debug;
      debug = st;
      while (!debug.empty()) {
        cout << debug.top() << " ";
        debug.pop();
      }
      cout << endl; */
    }
    if(!st.empty()) flag = false;
    if (flag) {
      ans.push_back("yes");
    } else {
      ans.push_back("no");
    }
  }

  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 3332
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  
  if (A == 0) {
    cout << 0 << endl;
  } else if (B == 0) {
    cout << N << endl;
  } else {
    ll bai = N / (A+B);
    ll ans = bai * A;
    ll nokori = N - bai * (A+B);
    if (nokori > A) ans += A;
    else ans += nokori;
    cout << ans << endl;
  }
  
  return 0;
}


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

#define task "C" //ABC133
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define pb push_back
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;

// Limit

// Struct

// Variables
int L,R;
// Function

int main()
{
	//freopen(task".in","r",stdin);
	//freopen(task".out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	cin >> L >> R;
	if (R-L+1>=2019) {cout << 0;return 0;}
	R%=2019;
	L%=2019;
	if (R<L-1) cout << 0;
	else
    {
        int res=2018;
        rep(i,L,R) rep(j,L,R)
        {
            if (i==j) continue;
            res=min(res,(i*j)%2019);
        }
        cout << res;
    }
}


Measured memory_bytes: 256