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

// 度->ラジアンの変換
#define DEGtoRAD(X) (X*PI)/180.0
// 円周率
const double PI = 2 * acos(0.0);
// 許容誤差.問題によって変える
const double EPS = 1e-9;

struct point{
    double x, y;
    point(){ x = y = 0.0;}
    point(double _x, double _y) : x(_x), y(_y) {}

    // 不等号のオーバーロード.x座標,y座標で昇順ソート
    bool operator < (const point other) const{
        if(fabs(x - other.x) > EPS)
            return x < other.x;
        else
            return y < other.y;
    }

    // 等号のオーバーロード.
    bool operator == (const point other) const{
        return fabs(x - other.x) < EPS &&
                fabs(y - other.y) < EPS;
    }
};

// 2つのpoint間の距離 std::hypotenuse(斜辺)を利用
double dist(point p1, point p2){
    return hypot(p1.x - p2.x, p1.y - p2.y);
}

// ベクトル
struct vec{
    double x, y;
    vec(double _x, double _y) : x(_x), y(_y) {}
};

// 2つのpoint a,b をvec a->b に変換
vec toVec(point a, point b){
    return vec(b.x - a.x, b.y - a.y);
}

// vecの外積
double cross(vec v1, vec v2){
    return v1.x * v2.y - v1.y * v2.x;
}

bool ccw(point p, point q, point r){
    return cross(toVec(p, q), toVec(p, r)) > 0;
}

// 3つのpointが単一直線上にあるかどうかの判定
bool collinear(point p, point q, point r){
    return fabs(cross(toVec(p, q), toVec(p, r))) < EPS;
}

// 凸包を求めるのに用いる一連の関数
point pivot(0.0, 0.0);

// Graham's Scanの前準備で必要な,pivotからの偏角でソートするときに必要な比較関数
bool angleCmp(point a, point b){
    // 偏角が同じ(pivot,a,bが単一直線上に乗っている)場合は,pivotからの距離が近い方を優先
    if(collinear(pivot, a, b)){
        return dist(pivot, a) < dist(pivot, b);
    }

    double d1x = a.x - pivot.x, d1y = a.y - pivot.y;
    double d2x = b.x - pivot.x, d2y = b.y - pivot.y;

    return (atan2(d1y, d1x) - atan2(d2y, d2x)) < 0;
}

// 与えられた点群から凸包を求める(Graham's Scan)
vector<point> ConvexHull(vector<point> P){
    int i, j, n = (int)P.size();

    // 点群が3つしかない場合,P[0]をPに加える(輪っかのイメージ)
    if(n <= 3){
        if(!(P[0] == P[n-1]))  P.push_back(P[0]);
        return P;
    }

    // pivotを定める.最下,最右の点
    int P0 = 0;
    for(i = 1; i < n; i++){
        if(P[i].y < P[P0].y || 
           (P[i].y == P[P0].y && P[i].x > P[P0].x)){
               P0 = i;
        }
    }

    // P[0]とpivotとして選ばれたP[P0]をスワップ
    point temp = P[0];
    P[0] = P[P0];
    P[P0] = temp;

    pivot = P[0];
    sort(++P.begin(), P.end(), angleCmp);

    vector<point> S;
    S.push_back(P[n-1]);
    S.push_back(P[0]);
    S.push_back(P[1]);
    
    i = 2;
    while(i < n){
        j = (int)S.size() - 1;

        if(ccw(S[j-1], S[j], P[i]))
            S.push_back(P[i++]);
        else
            S.pop_back();
    }

    return S;
}

int main(){
    int n;
    vector<point> p, ch;
    while(1){
        scanf("%d", &n);
        if(n == 0)  break;

        p.clear();
        ch.clear();
        double x, y;
        for(int i = 0; i < n; i++){
            scanf("%lf,%lf", &x, &y);
            p.push_back(point(x,y));
        }

        ch = ConvexHull(p);
        
        printf("%d\n", n-ch.size()+1);
    }

    return 0;
}


Measured memory_bytes: 3328
fun main(args: Array<String>) {
    var str = readLine()
    if(str != null) {
        val ary = str.split(Regex("\\s+"))
        val v = arrayOf(ary[0].toInt(),ary[1].toInt(),ary[2].toInt())
        v.sort()
        println("${v[0]} ${v[1]} ${v[2]}")
    }
 }


Measured memory_bytes: 29660
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Numerics;

public class Program
{
    public static void Main(string[] args)
    {
        //string[] line = Console.ReadLine().Split(' ');

        long N = long.Parse(Console.ReadLine());
        long[] v = new long[N];
        for (long i = 0; i < v.Length; i++)
        {
            v[i] = long.Parse(Console.ReadLine());
        }

        long[,] dp = new long[N + 1, 5];
        for (long x = 0; x < dp.GetLength(0); x++)
        {
            for (long y = 0; y < dp.GetLength(1); y++)
            {
                dp[x, y] = long.MaxValue;
            }
        }

        for (long i = 0; i < 5; i++)
        {
            dp[0, i] = 0;
        }

        for (long i = 0; i < N; i++)
        {
            long cost1 = v[i];
            dp[i + 1, 0] = Math.Min(dp[i + 1, 0], dp[i, 0] + cost1);

            long cost2 = (v[i] == 0) ? 2 : v[i] % 2;
            long min2 = (new long[] { dp[i, 0], dp[i, 1] }).Min();
            dp[i + 1, 1] = Math.Min(dp[i + 1, 1], min2 + cost2);

            long cost3 = (v[i] == 0) ? 1 : ((v[i] % 2 == 0) ? 1 : 0);
            long min3 = (new long[] { dp[i, 0], dp[i, 1], dp[i, 2] }).Min();
            dp[i + 1, 2] = Math.Min(dp[i + 1, 2], min3 + cost3);

            long cost4 = (v[i] == 0) ? 2 : v[i] % 2;
            long min4 = (new long[] { dp[i, 0], dp[i, 1], dp[i, 2], dp[i, 3] }).Min();
            dp[i + 1, 3] = Math.Min(dp[i + 1, 3], min4 + cost4);

            long cost5 = v[i];
            long min5 = (new long[] { dp[i, 0], dp[i, 1], dp[i, 2], dp[i, 3], dp[i, 4] }).Min();
            dp[i + 1, 4] = Math.Min(dp[i + 1, 4], min5 + cost5);
        }

        long ans = long.MaxValue;

        for (long i = 0; i < 5; i++)
        {
            ans = Math.Min(ans, dp[N, i]);
        }


        Console.WriteLine(ans);
        Console.ReadLine();
    }
}


Measured memory_bytes: 26560
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int dfs(vector<set<int>> &F, vector<int> &seen, int n, int id) {
    seen[n] = id;
    int count = 1;
    for (auto f : F[n]) {
        if (seen[f]) continue;
        count += dfs(F, seen, f, id);
    }
    return count;
}

int main() {
    int N, M, K; cin >> N >> M >> K;
    vector<set<int>> F(N), B(N);
    REP(i, 0, M) {
        int a, b; cin >> a >> b; a--; b--;
        F[a].insert(b);
        F[b].insert(a);
    }
    REP(i, 0, K) {
        int a, b; cin >> a >> b; a--; b--;
        B[a].insert(b);
        B[b].insert(a);
    }

    vector<int> seen(N); vector<int> groups; int id = 1;
    REP(i, 0, N) {
        if (seen[i]) continue;
        groups.push_back(dfs(F, seen, i, id++));
    }

    REP(i, 0, N) {
        int ans = groups[seen[i] - 1] - 1 - F[i].size();
        for (auto b : B[i]) if (seen[i] == seen[b]) ans--;
        cout << ans;
        if (i != N - 1) cout << " ";
    }
    cout << endl;
    return 0;
}

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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) (1 + (int)((a) - 1)/(int)(b))
#define int long long

signed main() {
    int n; cin >> n;
    cout << n/3 << endl;
}

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

#define ff first
#define ss second
#define pb push_back

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 200005;
const int mod = 1e9+7;

ll n;
ll c[N];
ll fat[N];
ll p2[N];
ll inv2;

ll solve(int id){
	if(id == n) return 0;
	ll ans = 0;
	ll lef = p2[id];
	ll rig = (n-id-1 ? p2[n-id-2] : 0) * (n-id+1);
	if(!rig) rig = 1;
	rig %= mod;
	lef *= rig;
	lef %= mod;
	ans = c[id] * lef;
	ans %= mod;
	ans *= p2[n];
	ans = ans + solve(id+1);
	return ans % mod;
}

int main(){
	fat[0] = 1;
	p2[0] = 1;
	for(int i = 1; i < N; i++){
		fat[i] = (fat[i-1] * i) % mod;
		p2[i] = (2 * p2[i-1]) % mod;
	}

	scanf("%lld", &n);
	for(int i = 0; i < n; i++){
		scanf("%lld", c+i);
	}
	sort(c, c + n);
	printf("%lld\n", solve(0));
	return 0;
}


Measured memory_bytes: 11136
import math
N = int(input())
if N == 2:
    print("0")
    exit(0)

P = [1]
for k in range(2,math.floor(math.sqrt(N))+1):
    if N % k == 0:
        if N//k-1 > k:
            P.append(min(k,N//k))
ans = 0
for p in P:
    ans += N//p - 1
print(ans)

Measured memory_bytes: 40428
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AX solver = new AX();
        solver.solve(1, in, out);
        out.close();
    }

    static class AX {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int a = s.nextInt();
            int b = s.nextInt();
            out.println(Math.max(a + b, Math.max(a * b, a - b)));
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22484
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
#define INF	100000000
#define pb	push_back
#define fi first
#define sec second
#define SS stringstream
using namespace std;
typedef pair<int, int> P;
typedef long long int	ll;

bool sosuu[1000000] = {false};
int a;

int main(){
	int x;
	int p = 1000000;
	x = floor(sqrt(p));
	for(int i = 2; i < x+1; i++){
		if(sosuu[i] == true){
			continue;
		}
		for(int j = 2*i; j < p+1; j = j+i){
			sosuu[j] = true;
		}
	}
	while(cin >> a){
		if(a == 0) break;
		ll ans = 0;
		int t = 0;
		for(int i = 2; i < p+1; i++){
			if(sosuu[i] == false){
				t++;
				ans += i;
				if(t == a) break;
			}
		}
		cout << ans	<< endl;
	}
}

Measured memory_bytes: 2132
N, M = map(int, input().split())
X, Y, Z = [0]*N, [0]*N, [0]*N
for i in range(N):
  X[i], Y[i], Z[i] = map(int, input().split())

U = [0] * N
answer = []
for i in range(2):
  for j in range(2):
    for k in range(2):
      for n in range(N):
        U[n] = X[n]*(-1)**i + Y[n]*(-1)**j + Z[n]*(-1)**k
      U.sort()
      U = U[::-1]
      answer.append(sum(U[:M]))
print(max(answer))

Measured memory_bytes: 39792
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXN = 1e7 + 5;
LL cnt[MAXN]; 
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    LL n; cin >> n;
    memset(cnt, 0, sizeof(cnt));
    for (int i = 1 ; i < MAXN ; i++)
        for (int j = i ; j < MAXN ; j += i)
            cnt[j]++;
    LL ans = 0;
    for (int i = 1 ; i <= n ; i++) {
        ans += cnt[i] * i;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 81776
cin = open(0).read().strip().split('\n')
n, k = map(int, cin[0].split(' '))
a = list(map(int, cin[1].split(' ')))

ret = float('inf')
for idx in range(2**(n)):
    colors = 0
    res = 0
    left = 0
    for i in range(n):
        if (idx>>i) & 1:
            colors += 1
            res += max(left+1 - a[i] , 0)
            left = max(a[i], left+1)
        else:
            colors += 1 if left < a[i] else 0
            left = max(left, a[i])


    if colors >= k:
        ret = min(ret, res)

print(ret)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int A,B,C,D;
int main(){
    cin >> A >> B >> C >> D;
    cout << max(0,min(B,D)-max(A,C)) << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    string s;
    cin >> s;
    for(char c = 'a'; c <='z';c++) {
        if (s.find(c) == string::npos) {
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<map>
#include<algorithm>
#include<string>

using namespace std;

int main(void){
  int N, M;
  map<string, int> m;
  cin >> N;
  for(int i = 0; i < N; i++){
    string s;
    cin >> s;
    m[s]++;
  }
  cin >> M;
  for(int i = 0; i < M; i++){
    string t;
    cin >> t;
    m[t]--;
  }
  int ans = 0;
  for(auto itr = m.begin(); itr != m.end(); itr++) ans = max(ans, itr -> second);
  cout << ans << endl;
  return 0;
}
  

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)

int main()
{
    ll a,b,c;cin>>a>>b>>c;
    ll minm=1000000;
    minm = min(minm, a+b);
    minm = min(minm, c+b);
    minm = min(minm, a+c);

    cout << minm << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll x1=a*c;
	ll x2=a*d;
	ll x3=b*c;
	ll x4=b*d;
	ll x=max(x1,x2);
	x=max(x,x3);
	x=max(x,x4);
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 3188
#include<stdio.h>
int main()
{
	int a, b, d, r ;
	double f;
		scanf("%d %d", &a, &b);
		
		d = a / b;
		r = a % b;
		f = (double)a / b;

		printf("%d %d %f\n", d, r, f);

		return 0;
}


Measured memory_bytes: 2736
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int n,h,w;
    cin >> n >> h >> w;

    cout << (n-h+1) * (n-w+1) << endl;
}


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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int A[N];
	for (int i = 1; i < N; i++)
	{
		cin >> A[i];
	}
	
	vector<int> ans(N, 0);
	for (int i = 1; i < N; i++)
	{
		ans[A[i]-1]++;
	}
	
	for (int i = 0; i < N; i++)
	{
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 4752
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long V = sc.nextLong();
		long B = sc.nextLong();
		long W = sc.nextLong();
		long T = sc.nextLong();
		long sa = B-A;
		if (sa<0) {
			sa = -sa;
		}
		if (V<W) {
			System.out.println("NO");
			return ;
		}
		if (sa<=(V-W)*T) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 35784
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();    
        int N = r.i();
        int[] a = r.ii(N);
        for(int i = 1, count = 0; count < N;){
            i = a[i-1];
            count++;
            if(i == 2){
                println(count);
                return;
            } 
        }
        println(-1);
    }

    static void print(Object o){
        System.out.print(o.toString());
    }

    static void println(Object o){
        System.out.println(o.toString());
    }

    static int Int(String s){
        return Integer.parseInt(s);
    }

    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s() throws IOException{
            return readLine();
        }

        String[] ss() throws IOException{
            return s().split(" ");
        }

        int i() throws IOException{
            return Int(s());
        }

        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }

        long l() throws IOException{
            return Long(s());
        }

        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }

        int[] ii(int N) throws IOException{
            int[] ii = new int[N];
            for(int i = 0; i < N; i++) ii[i] = i();
            return ii;
        }

    }
}

Measured memory_bytes: 30440
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<ll,ll>
    #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))
    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):0;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    inline ll qpower(ll x,ll e)
    {
        ll ans=1;
        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;

	int to(int x,int y)
	{
		if(x==y) return 0;
		int ans=2e9+10;
		if(x<y)
		{
			chmin(ans,y-x);
			if(x<0 and y>0 and abs(x)<=abs(y)) chmin(ans,1+to(-x,y));
			else if(x<0 and y>0 and abs(x)>abs(y)) chmin(ans,1+abs(abs(x)-abs(y)));
		}
		else
		{
			if(x<0) chmin(ans,to(-x,y)+1);
			else if(y>=0) chmin(ans,to(-x,y)+1);
			else chmin(ans,abs(abs(x)-abs(y))+1);
		}
		return ans;
	}
	void main()
	{
		int x=qread(),y=qread();
		write(to(x,y));
	}
};
int main()
{
	mine::main();
}

Measured memory_bytes: 256
module ABC124

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public :: task_B

  ! constants for this <module>
  integer(kind=INT8), parameter, private :: num_mountains_max = 100_INT8

  ! variables for this <module>
  integer(kind=INT8) :: num_mountains_all
  integer(kind=INT8) :: num_mountains_visible
  integer(kind=INT8) :: height_mountain(1:num_mountains_max)
  logical            :: is_visible

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_B

    ! variables for this <subroutine>
    integer(kind=INT8) :: itr_Mt, itr_ToWest

    ! STEP.01
    ! read out the number of the mountains
    read(unit=INPUT_UNIT, fmt=*) num_mountains_all

    ! STEP.02
    ! read out the heights of the mountains
    read(unit=INPUT_UNIT, fmt=*) height_mountain(1:num_mountains_all)

    ! STEP.03
    ! count up the number of mountains which you can see the sea from the top of the mountain
    num_mountains_visible = 0_INT8

    do itr_Mt = 1_INT8, num_mountains_all, 1_INT8
      
      is_visible = .true.

      do itr_ToWest = itr_Mt-1_INT8, 1_INT8, -1_INT8
        if (height_mountain(itr_ToWest) .gt. height_mountain(itr_Mt)) then
          is_visible = .false.
          exit
        end if
      end do

      if (is_visible) num_mountains_visible = num_mountains_visible + 1_INT8

    end do

    ! STEP.04
    ! output the result
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') num_mountains_visible

    ! STEP.END
    return

  end subroutine task_B

end module ABC124

program main

  ! <module>s to import
  use, non_intrinsic :: ABC124

  ! require all variables to be explicitly declared
  implicit none

  call task_B

end program main

Measured memory_bytes: 256
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    int count = 0;
    for (int i = 1; i <= N; i++) {
      int v = sc.nextInt();
      if (v != i) {
        count++;
      }
      if (count > 2) {
        System.out.println("NO");
        return;
      }
    }
    System.out.println("YES");
  }
}

Measured memory_bytes: 21844
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val s, t = sc.next()
  val result =
    if (s.toSeq.sorted.unwrap < t.toSeq.sorted(Ordering[Char].reverse).unwrap) {
      "Yes"
    } else {
      "No"
    }
  println(result)
}


Measured memory_bytes: 55500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> lP;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int main(){
    ll n,m;
    cin>>n>>m;

    vector<vector<ll>> frie (n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        frie[a].push_back(b);
        frie[b].push_back(a);
    }

    queue<ll> que;
    ll ans=1;

    vector<bool> dist(n,false);

    rep(i,n){
        que.push(i);
        if(dist[i]) continue;
        dist[i]=true;
        ll count=1;
        while(!que.empty()){
            ll v=que.front();
            que.pop();
            for (auto next:frie[v]){
                if(dist[next]) continue;
                dist[next]=true;
                count++;
                ans=max(ans,count);
                que.push(next);
            }
        }
    }

    cout<<ans<<endl;


}


Measured memory_bytes: 18148
#include <iostream>

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    
    while (!(H == 0 && W == 0)) {
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++)
                cout << '#';
            cout << endl;
        }

        cout << endl;
        cin >> H >> W;
    }

    return 0;
}


Measured memory_bytes: 3076
#include<iostream>
#include<map>
using namespace std;
typedef pair<int,int> P;
#define X first
#define Y second
int main(){
  int n;cin>>n;
  map<P,int> m;
  P p;
  int i,j,k;
  int w;
  for(i=0;i<n;i++){
    cin >> p.X >> p.Y >> w;
    m[p]+=w;
  }
  int o=0;
  for(map<P,int>::iterator it=m.begin();it!=m.end();++it){
    p=it->first;
    w=it->second;
    //cout << p.X << p.Y << w << endl;
    k=0;
    k+=w;
    p.X++;
    if(m.find(p)!=m.end())
       k+=m[p];
    p.Y++;
    if(m.find(p)!=m.end())
      k+=m[p];
    p.X--;
    if(m.find(p)!=m.end())
      k+=m[p];
    o=max(o,k);
    p=it->first;
    k=0;
    k+=w;
    p.X--;
    if(m.find(p)!=m.end())
       k+=m[p];
    p.Y++;
    if(m.find(p)!=m.end())
      k+=m[p];
    p.X++;
    if(m.find(p)!=m.end())
      k+=m[p];
    o=max(o,k);
    p=it->first;
    k=0;
    k+=w;
    p.X++;
    if(m.find(p)!=m.end())
       k+=m[p];
    p.Y--;
    if(m.find(p)!=m.end())
      k+=m[p];
    p.X--;
    if(m.find(p)!=m.end())
      k+=m[p];
    o=max(o,k);
  }
  cout << o << " / 1" << endl;
  return 0;
}

Measured memory_bytes: 7448
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h + 2; i++) {
        for (int j = 0; j < w + 2; j++) {
            if (i == 0 || i == h + 1 || j == 0 || j == w + 1) {
                cout << "#";
            } else {
                char c;
                cin >> c;
                cout << c;
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
class BIT
  attr_reader :bit
  def initialize(n)
    @n = n
    @bit = Array.new(@n + 1, 0)
  end
  def sum(i)
    s = 0
    while i > 0
      s +=  @bit[i]
      i -= i & -i
    end
    return s
  end
  def add(i, x)
    i += 1
    while i <= @n
      @bit[i] += x
      i += i & -i
    end
  end
end

n, k = gets.chomp.split(" ").map(&:to_i)
a = [0]
a += readlines.map{|x| x.chomp.to_i - k}

b = [0]
n.times do |i|
  b << b[i] + a[i+1]
end

b_s = b.sort
c = b.map{|e| b_s.bsearch_index{|x| x >= e}}

bit = BIT.new(n+1)

ans = 0
c.each do |i|
  ans += bit.sum(i+1)
  bit.add(i, 1)
end
puts ans

Measured memory_bytes: 29416
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
#include <math.h>
using namespace std;

struct obj {
	string tp;
	int h;
};

bool cmp(const obj &a, const obj &b)
{
    return a.h > b.h;
}

int main(void) {
	
	int N, H;
	cin >> N >> H;
	vector<obj> list(N * 2);

	for (int i = 0; i < N * 2; i++)
	{
		list[i].tp = "b";
		if (i % 2 == 0)
		{
			list[i].tp = "a";
		}
		
		cin >> list[i].h;
	}

	sort(list.begin(), list.end(), cmp);

	long long int cnt = 0;
	for (int i = 0; i < N * 2; i++)
	{
		if (list[i].tp == "a")
		{
			cnt += H / list[i].h;
			int a = H % list[i].h;
			if (a != 0)
			{
				cnt++;
			}
			break;
		}
		else
		{
			H -= list[i].h;
			cnt++;
			if (H <= 0)
			{
				break;
			}
		}
	}

	cout << cnt << endl;

	return 0;
}

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

//#define getchar getchar_unlocked
//#define putchar putchar_unlocked
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define ff first
#define ss second
#define err stderr
#define out stdout

typedef long long int ll;
typedef long double ld;
typedef short int sh;

inline void readI(int *i)
{
	register int t=0;
	register char z=getchar();
	int znak=1;
	if (z=='-')
	{
		znak=-1;
	}
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
		if (z=='-')
		{
			znak=-1;
		}
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*i=(t*znak);
}
inline void readUI(int *i)
{
	register int t=0;
	register char z=getchar();
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*i=t;
}
inline void readL(ll *l)
{
	register ll t=0;
	register char z=getchar();
	int znak=1;
	if (z=='-')
	{
		znak*=-1;
	}
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
		if (z=='-')
		{
			znak=-1;
		}
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*l=(t*znak);
}
inline void readUL(ll *l)
{
	register ll t=0;
	register char z=getchar();
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*l=t;
}
inline void writeL(ll l)
{
	if (l==0)
	{
		putchar(48);
	}
	else
	{
		if (l<0)
		{
		   l*=-1;
		   putchar(45);
		}
		int _tab[21];
		int wsk=0;
		while (l>0)
		{
			++wsk;
			_tab[wsk]=(l%10)+48;
			l/=10;
		}
		for (int j=wsk; j>=1; --j)
		{
			putchar(_tab[j]);
		}
	}
}
inline void writeS(string s)
{
	int l=s.length();
	for (int i=0; i<l; ++i)
	{
		putchar(s[i]);
	}
}
inline void space()
{
	putchar(32);
}
inline void endl()
{
	putchar(10);
}

#define debug if(0)
#define debug2 if(1)
#define debug3 if(1)
#define debug4 if(1)
#define MAXN 1005

int n, a, b, c;
struct trojka
{
	int w;
	int s;
	int v;
};
vector <trojka> v;
ll dp[MAXN*10];
ll odp;

bool comp(trojka a, trojka b)
{
	return a.s-b.w>b.s-a.w;
}
int main()
{
	readUI(&n);
	for (int i=1; i<=n; ++i)
	{
		readUI(&a);
		readUI(&b);
		readUI(&c);
		v.eb(trojka{a, b, c});
	}
	sort(v.begin(), v.end(), comp);
	for (int i=0; i<n; ++i)
	{
		int masa=v[i].w;
		int stam=v[i].s;
		int war=v[i].v;
		debug
		{
			fprintf (err, "i=%d masa=%d stam=%d war=%d\n", i, masa, stam, war);
		}
		for (int j=masa; j<=10000; ++j)
		{
			dp[min(stam, j-masa)]=max(dp[min(stam, j-masa)], dp[j]+war);
		}
		dp[stam]=max(dp[stam], (ll)war);
	}
	for (int i=0; i<=10000; ++i)
	{
		odp=max(odp, dp[i]);
	}
	fprintf (out, "%lld\n", odp);
	return 0;
}
/*
*/




Measured memory_bytes: 384
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace MinPro2019B
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(int.Parse, 6);

            var cs = new int[4];
            foreach (var n in N) cs[n - 1]++;

            var ans = cs.Count(x => x == 1) == 2 && cs.Count(x => x == 2) == 2;
            sw.WriteLine(ans ? "YES" : "NO");
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 13396
#include "bits/stdc++.h"
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<vector <pair<int, bool> > > edge(n);
    for(int i = 0; i < n-1; i++){
        int u,v,w;
        cin >> u >> v >> w;
        u--; v--;
        bool f = w%2==0;
        edge[u].push_back(make_pair(v,f));
        edge[v].push_back(make_pair(u,f));
    }

    vector<int> ans(n,-1);
    ans[0] = 0;
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int point = q.front();
        q.pop();
        for(auto p : edge[point]){
            int next = p.first;
            bool even = p.second;
            if(ans[next] == -1){
                ans[next] = (even ? ans[point] : (ans[point]+1) % 2);
                q.push(next);
            }
        }
    }

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

Measured memory_bytes: 6784
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

using namespace std;

int main() {

	long n,b[101],sum=0;

	cin >> n;

	for (int i = 1; i < n; i++) {
		cin >> b[i];
	}

	b[0] = b[1];

	for (int i = n-1; i > 0; i--) {
		sum = sum + min(b[i], b[i - 1]);
	}

	cout << sum+b[n-1] << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
int n;
ll a[200010];
ll ans;
ll absx(ll x)
{
    if(x>0)  return x;
    return -x;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)  cin>>a[i];
    for(int i=1;i<=n;i++)  a[i]=a[i]-(ll)i;
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)  ans+=absx(a[i]-a[n/2+1]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {

	int n, i;
	int a[100];

	scanf("%d", &n);

	for (i = 0; i < n; i++) {

		scanf("%d", &a[i]);

		}	
	
	for (i = n-1; i >= 0;i--) {
	
		if (i > 0) {
			printf("%d ", a[i]);
		}
		else
			printf("%d", a[i]);
	}
	printf("\n");

	return(0);

}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    ll keta = 0;
    ll tmp = k;
    while(tmp){
        tmp >>= 1;
        ++keta;
    }
    ll ans = 0;
    for(i = 60;i >= keta;--i){
        rep(j,n){
            if(a.at(j) & (1ll << i)) ans += (1ll << i);
        }
    }
    bool flag = true;
    for(i = keta-1;i >= 0;--i){
        ll k1 = 0;
        ll k2 = 0;
        rep(j,n){
            if(a.at(j) & (1ll << i)) k1 += 1;
            else k2 += 1;
        }
        if(!flag) ans += max(k1,k2)*(1ll << i);
        else{
            if(!(k & (1ll << i))) ans += k1*(1ll << i);
            else if(k1 >= k2){
                ans += k1*(1ll << i);
                flag = false;
            }else{
                ans += k2*(1ll << i);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	char c;
	cin >> c;
	if ('A' <= c && c <= 'Z') cout << 'A';
	else cout << 'a';
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main()
{
    vector<int> num(4);
    int N;
    cin >> N;
    for (int i = 0; i < 4; i++)
    {
        num[i]=N/pow(10,3-i);
        N=N-pow(10,3-i)*num[i];
    }
    
    

    if (0<num[0]*10+num[1]&&num[0]*10+num[1]<13)
    {
        
        if(0<num[2]*10+num[3]&&num[2]*10+num[3]<13)
        {
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "MMYY" << endl;
        }
    
    }
    else
    {
        if(0<num[2]*10+num[3]&&num[2]*10+num[3]<13)
        {
            cout << "YYMM" << endl;
        }else
        {
            cout << "NA" << endl;
        }
    }
    
}

Measured memory_bytes: 256
n,l=map(int,input().split())
a=list(map(int,input().split()))
f=True
for i in range(n-1):
  if a[i]+a[i+1]>=l:
    print("Possible")
    print("\n".join([str(j) for j in range(1,i+1)]+[str(j) for j in range(n-1,i+1,-1)]+[str(i+1)]))
    f=False
    break
if f:
  print("Impossible")

Measured memory_bytes: 87744
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
     
#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long
#define ld long double
     
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
     
#define infi INT_MAX
#define infl LONG_LONG_MAX
#define infd LDBL_MAX
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
#define F first
#define S second
#define G(a,b) get<a>(b)
#define MP make_pair
#define MT make_tuple
#define pll pair<ll,ll> 
#define endl "\n"
#define ALL(v) v.begin(),v.end()
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;
#define deb printf("***************************************************************************************\n");
#define moshi printf("moshi moshi ! \n");
#define hi printf("hi ! \n");
#define bye printf("bye bye ! \n");
#define o_set(ll) tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define number_of_set_bits  __builtin_popcountll  
const ld PI=3.1415926535897932384626433; 



void func()
{ 
  string s;
  cin>>s;
  cout<<s[0]<<s[1]<<s[2]<<endl;
}   
     
     
int main() 
{
    fast

    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE*/
        
     
    ll ntc=1;
    //cin>>ntc;
     
    f(i,1,ntc+1)
    {
      //cout<<"Case #"<<i<<": ";
      func();
    }     
    return 0;
}

Measured memory_bytes: 3652
S = input()[::-1]
day_dream_word = ["dreamer", "dream", "eraser", "erase"]
day_dream_word = list(map(lambda s: s[::-1], day_dream_word))
T = ""
Tindex = 0
res = False
partial_res = True
while not res and partial_res:
  partial_res = False
  for add_word in day_dream_word:
    nextTindex = Tindex + len(add_word)
    
    if S[Tindex:nextTindex] == add_word:
      if len(S) == nextTindex:
        res = True
        break
      else:
        partial_res = True
        break
  Tindex = nextTindex

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

Measured memory_bytes: 40432
//Volume0-0057
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//declare
		int n,sum;

        //input
        Scanner sc = new Scanner(System.in);
        while((sc.hasNext())){
        	n = sc.nextInt();

        	//calculate
        	sum = 1;
        	for(int i=1;i<=n;i++){
        		sum += i;
        	}

        	//output
        	System.out.println(sum);
        }
	}
}

Measured memory_bytes: 18116
#include<stdio.h>
int main()
{
int N;
int i;
long long int min=1000000000, max=1;
long long int input;
scanf("%d",&N);
for(i=0;i<N;i++)
{
scanf("%lld",&input);
if(input>max)
max=input;
if(input<min)
min=input;
}
printf("%d",max-min);
return 0;
}


Measured memory_bytes: 128
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
import std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	char[] s = readln.chomp.to!(char[]);
	
	int ans = 10000;
	foreach(c; s){
		int x = solve(s, c);
		if(x < ans) ans = x;
		}
	
	bool flag = 1;
	foreach(c; s) if(c != s[0]) flag = 0;
	if(flag) ans = 0;
	
	ans.writeln;
	
	}

int solve(char[] s, char c){
	char[] s1 = s;
	int count;
	while(1){
		bool flag = 1;
		char[] s2;
		for(int i = 0; i < s1.length - 1; i ++){
			if(s1[i] == c || s1[i + 1] == c) s2 ~= c;
			else{
				flag = 0;
				s2 ~= ' ';
				}
			}
		s1 = s2;
		count += 1;
		if(flag) break;
		}
	return count;
	}


Measured memory_bytes: 1276
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll N, M;
	cin >> N >> M;
	vl A(M);
	rep(i, M)
		cin >> A[i];

	ll ans = N;
	rep(i, M)
		ans -= A[i];
	if (ans < 0)
		ans = -1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <map>

using namespace std;

int main()
{
  int n;
  cin >> n;
  
  string s;
  map<string,int> m;
  
  for (int i=0; i<n; ++i)
  {
    cin >> s;
    ++m[s];
  }
  
  cout << "AC x " << m["AC"] << '\n';
  cout << "WA x " << m["WA"] << '\n';
  cout << "TLE x " << m["TLE"] << '\n';
  cout << "RE x " << m["RE"];
}

Measured memory_bytes: 3632
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ALucky7 solver = new ALucky7();
        solver.solve(1, in, out);
        out.close();
    }

    static class ALucky7 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String i = in.next();

            out.println(i.contains("7") ? "Yes" : "No");
        }

    }

    static class Scanner {
        private final InputStream in;
        private final byte[] buffer;
        private int ptr;
        private int buflen;

        public Scanner(InputStream in) {
            this.in = in;
            this.buffer = new byte[1024];
            this.ptr = 0;
            this.buflen = 0;
        }

        private boolean hasNextByte() {
            if (ptr < buflen) return true;
            else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) return false;
            }
            return true;
        }

        private byte readByte() {
            if (hasNextByte()) return buffer[ptr++];
            return -1;
        }

        private boolean isPrintableChar(byte c) {
            return '!' <= c && c <= '~';
        }

        private void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
        }

        public boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            byte b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

    }
}



Measured memory_bytes: 25552
N=int(input())
if len(str(N))==1:print(N)
elif len(str(N))==2:print(9)
elif len(str(N))==3:print(9+N-100+1)
elif len(str(N))==4:print(9+999-100+1)
elif len(str(N))==5:print(9+999-100+1+N-10000+1)
else:print(9+999-100+1+99999-10000+1)

Measured memory_bytes: 9100
n = int(input())
hf = [[None] for i in range(n)]

for i in range(n):
    tmp = []
    for j in range(int(input())):
        tmp.append(list(map(int, input().split())))
    hf[i] = tmp
ans = 0
for i in range(2 ** n):
    f = 0
    b = bin(i)[2:].zfill(n)
    for j in range(n):
        if b[j] == "0":
            continue
        else:
            for x, y in hf[j]:
                if b[x - 1] != str(y):
                    f = 1
    if f == 0:
        ans = max(ans, b.count("1"))
print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
#define NIL -1
struct Node{int parent,left,right;};
struct Node T[41];
int n,P[41],I[41];
int search(int x[],int target,int size){
    for(int i=0;i<size;i++){
        if(x[i]==target) return i;
    }
    return 0;
}
bool tansaku(int target,int x[],int size){
    for(int i=0;i<size;i++){
        if(x[i]==target) return true;
    }
    return false;
}
void Postorder(int x){
    if(x!=NIL){
        Postorder(T[x].left);
        Postorder(T[x].right);
        if(x==P[0]) cout<<x;
        else cout<<x<<" ";
    }
}
void saisei(int x[],int s,int p,int size){
    int l=0,r=0,mid=search(x,s,size);
    int L[40],R[40];
    
    for(int i=0;i<size;i++){
        if(i<mid){L[l]=x[i];l++;}
        else if(i>mid){R[r]=x[i];r++;}
    }
    if(l!=0){
        
            T[P[p]].left=P[p+1];
            T[P[p+1]].parent=P[p];
            saisei(L,P[p+1],p+1,l);
        
    }
    if(r!=0){
       
            T[P[p]].right=P[p+l+1];
            T[P[p+l+1]].parent=P[p];
            saisei(R,P[p+l+1],p+l+1,r);
        
    }
    
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++) cin>>P[i];
    for(int i=0;i<n;i++) {
        cin>>I[i];
        T[i+1].parent=T[i+1].left=T[i+1].right=NIL;
    }
    saisei(I,P[0],0,n);
    Postorder(P[0]); cout<<endl;
    return 0;
}


Measured memory_bytes: 3104