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

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

struct edge { int v, w1, w2; };
struct elem { int u, d, w2; };
bool operator<(const elem& a, const elem& b) {
	if (a.d != b.d) return a.d > b.d;
	else return a.w2 > b.w2;
}

int main() {
	for (;;) {
		int N, M; scanf("%d%d", &N, &M);
		if (N == 0 && M == 0) break;
		vector<vector<edge> > G(N, vector<edge>());
		for (; M > 0; M--) {
			int u, v, d, c; scanf("%d%d%d%d", &u, &v, &d, &c);
			edge e1 = {v - 1, d, c}; G[u - 1].push_back(e1);
			edge e2 = {u - 1, d, c}; G[v - 1].push_back(e2);
		}
		vector<int> d(N, INT_MAX), w2(N, INT_MAX);
		d[0] = 0; w2[0] = 0;
		priority_queue<elem> q;
		elem e = {0, 0, 0}; q.push(e);
		int ans = 0;
		while (!q.empty()) {
			elem e = q.top(); q.pop();
			int u = e.u;
			if (!(e.d == d[u] && e.w2 == w2[u])) continue;
			ans += e.w2;
			for (int i = 0; i < G[u].size(); i++) {
				edge e = G[u][i]; int v = e.v;
				if (d[u] + e.w1 < d[v] || (d[u] + e.w1 == d[v] && e.w2 < w2[v])) {
					d[v] = d[u] + e.w1; w2[v] = e.w2;
					elem _e = {v, d[v], w2[v]}; q.push(_e);
				}
			}
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 2228
import sys

n, s = sys.stdin.read().split()

def main():
    cnt = s.count('E')
    cur = 'E'
    res = cnt
    for c in s:
        if cur == 'W': cnt += 1
        if c == 'E': cnt -= 1
        res = min(res, cnt)
        cur = c
    print(res)
    
if __name__ ==  '__main__':
    main()

Measured memory_bytes: 3572
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        PriorityQueue<Integer> v = new PriorityQueue<Integer>();
        for(int i=0; i<n; i++) v.add(fs.nextInt());
        double v_last = (double)v.poll()/(Math.pow(2,n-1));
        for(int i=1; i<n; i++) {
            v_last += (double)v.poll()/(Math.pow(2,n-i));
        }
        System.out.println(v_last);

    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int 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 int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21076
#include <iostream>

using namespace std;

uint_fast64_t gcd(uint_fast64_t m, uint_fast64_t n)
{
    if (n == 0) {
        return m;
    }
    return gcd(n, m % n);
}

uint_fast64_t lcm(uint_fast64_t m, uint_fast64_t n)
{
    return m / gcd(m, n) * n;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    size_t n;
    uint_fast64_t l = 1;
    cin >> n;
    for (auto i = 0u; i < n; ++i) {
        uint_fast64_t t;
        cin >> t;
        l = lcm(l, t);
    }
    cout << l << endl;
    return 0;
}


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

int main(){
  int N,ans=0;
  cin >> N;
  for(int i=1; i<=N; i++){
    if(1<=i&&i<10){
      ans++;
    }
    if(100<=i&&i<1000){
      ans++;
    }
    if(10000<=i&&i<100000){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline

N, K = map(int, input().split())
D = input().split()

# 使える数字は？
nums = []
for c in list('0123456789'):
    if c in D:
        pass
    else:
        nums.append(c)

#print(nums)

ret = []
def dfs(next_value, nums, ans):
    ans += next_value

    if int(ans) >= N:
        ret.append(ans)
        return

    for c in nums:
        # 0 が結合し続けると無限ループになるはず
        if ans == '0' and c == '0':
            pass
        else:
            dfs(c, nums, ans)

    return ans

dfs('0', nums, '')

A = list(map(int, ret))
print(min(A))

Measured memory_bytes: 9240
let n = stdin.ReadLine() |> int

let counter input =
    let rec inner i count =
        if i > input then count 
        elif input%i = 0 then inner (i+1) (count+1)
        else inner (i+1) count
    inner 1 0

[for i in [1..2..n] do i] |> List.map counter |> List.filter (fun x -> x=8) |> List.length |> printfn "%d"

Measured memory_bytes: 30100
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(x, y):
    return (x * y) //gcd(x, y)

def acinput():
    return list(map(int, input().split(" ")))


a,b=acinput()

print(lcm(a,b))



Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main()
{
  unsigned long long N, P[6];
  cin >> N;
  for (int i = 0; i < 5; i ++)
    cin >> P[i];

  unsigned long long bn = P[0];
  for (int i = 1; i < 5; i++) {
    if (bn > P[i])
      bn = P[i];
  }

  unsigned long long sum = N / bn + 4;
  sum += N % bn ? 1 : 0;

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/ruby
# encoding: utf-8

N,T = gets.split.map(&:to_i)

c = []
t = []
N.times do 
  a,b = gets.split.map(&:to_i)
  c << a
  t << b
end

s = []
(0..N-1).each do |i|
  if t[i] <= T 
    s << c[i]
  end
end

if s.size == 0
  puts "TLE"
else
  puts s.min
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  int n;
  cin >> n;
  vector<int>a(100010);
  rep(i,n){
    int A;
    cin >> A;
    a[A]++;
  }
  int ans=0;
  rep(i,100010){
    if(i==0)ans=max(a[0]+a[1],ans);
    else if(i==100009)ans=max(ans,a[i]+a[i-1]);
    else ans=max(ans,a[i]+a[i-1]+a[i+1]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
N = int(input())
al = [[] for _ in range(N+1)]
for i in range(1,N+1):
    al[i] = int(input())
#print(al)

#初期値
n = 1
cnt = 1
visited = [0 for _ in range(N+1)]
visited[1] = 1
while al[n] != 2:
    cnt += 1
    n = al[n]
    if visited[n] == 1:
        print(-1)
        exit()
    else:
        visited[n] = 1
print(cnt)




Measured memory_bytes: 16848
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

typedef vector<int> vec;
typedef vector<vec> mat;

long long int M = 10000;

// A*B の計算
mat mul(mat &A, mat &B){
	mat C(A.size(), vec(B[0].size()));
	for(int i = 0; i < A.size(); i++){
		for(int k = 0; k < B.size(); k++){
			for(int j = 0; j < B[0].size(); j++){
				C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % M;
			}
		}
	}
	return C;
}

// A^n の計算
mat pow(mat A, long long int n){
	mat B(A.size(), vec(A.size()));
	for(int i = 0; i < A.size(); i++){
		B[i][i] = 1;
	}
	while(n > 0){
		if(n & 1){
			B = mul(B, A);
		}
		A = mul(A, A);
		n /= 2;
	}
	return B;
}

int main(){
	
	while(true){
		long long int n, a, b, c, T;
		cin >> n >> M >> a >> b >> c >> T;
		
		if(n == 0){
			break;
		}
		
		mat S(n + 2, vec(1));
		
		for(int i = 0; i < n; i++){
			cin >> S[i + 1][0];
		}
		
		mat P(n + 2, vec(n + 2));
		
		for(int i = 0; i < n; i++){
			P[i + 1][i] = a;
			P[i + 1][i + 1] = b;
			P[i + 1][i + 2] = c;
		}
		
		P = pow(P, T);
		
		mat ans = mul(P, S);
		
		for(int i = 1; i <= n; i++){
			printf("%d%c", ans[i][0], (i == n) ? '\n' : ' ');
		}
	}
	
	return 0;
}


Measured memory_bytes: 3156
#include <cstdio>
#define ll long long
ll gcd(ll x, ll y) {
  return y == 0 ? x : gcd(y, x%y);
}
ll lcm(ll x, ll y) {
  return  1ll * x /gcd(x,y) * y ;
}
ll ans = 1;
int main() {
#ifdef orz
    freopen("input", "r", stdin);
#endif
  ll n;
  scanf("%lld", &n);
  while(n--) {
    ll x;
    scanf("%lld", &x);
    ans = lcm(ans, x);
  }
  printf("%lld", ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};
 
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a<=c && c<=b){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e12;
 
struct Point{
    double x,y,z;
    Point(double x, double y, double z):x(x), y(y), z(z){}
    Point(){}
    Point &operator +=(const Point &a){ x+=a.x; y+=a.y; z+=a.z; return *this; }
    Point &operator -=(const Point &a){ x-=a.x; y-=a.y; z-=a.z; return *this; }
    Point &operator *=(const double &a){ x*=a; y*=a; z*=a; return *this; }
    Point operator +(const Point &a) const{ return Point(x+a.x, y+a.y, z+a.z); }
    Point operator -(const Point &a) const{ return Point(x-a.x, y-a.y, z-a.z); }
    Point operator *(const double &a) const{ return Point(a*x, a*y, a*z); }
    Point operator -() { return Point(-x, -y, -z); }
};

double dot(const Point &a, const Point &b){
    return a.x*b.x +a.y*b.y +a.z*b.z;
}
Point cross(const Point &a, const Point &b){
    return Point(a.y*b.z -a.z*b.y, a.z*b.x -a.x*b.z, a.x*b.y -a.y*b.x);
}
double abs(const Point &a){
    return sqrt(dot(a, a));
}
Point unit(const Point &a){
    return a *(1/abs(a));
}
bool operator ==(const Point &a, const Point &b){
    return abs(a-b) < EPS;
}
 
int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        vector<Point> p(n);
        for(int i=0; i<n; i++){
            cin >> p[i].x >> p[i].y >> p[i].z;
        }
        vector<bool> invalid(n, false);
        for(int i=0; i<n; i++){
            if(invalid[i]) continue;
            for(int j=i+1; j<n; j++){
                if(unit(p[i]) == unit(p[j])){
                    invalid[j] = true;
                }
            }
        }

        int m;
        cin >> m;
        int ans = 0;
        for(int i=0; i<m; i++){
            Point dir;
            double theta;
            cin >> dir.x >> dir.y >> dir.z >> theta;
            double costheta = cos(theta);
            for(int j=0; j<n; j++){
                if(invalid[j]) continue;
                if(dot(p[j], dir)/(abs(p[j])*abs(dir)) +EPS > costheta){
                    ans++;
                    invalid[j] = true;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3332
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int main() {

	string S;
	cin >> S;

	for (int i = 0; i < S.length(); i++) {
		if ('1' == S[i]) {
			S[i] = '9';
		}
		else {
			S[i] = '1';
		}
	}

	cout << stoi(S) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
int n,arr[200001];
map<pair<pair<int,int>,bool>,long long> memo;
long long dp(int index,int taken,bool prevtake){
    if (index>n){
        if (taken==n/2) return 0;
        return -1e15;
    }
    long long maxtake=taken;
    maxtake+=(n-index+2)/2;
    if (maxtake<n/2) return -1e15;
    if (memo.find(mp(mp(index,taken),prevtake))!=memo.end()){
        return memo[mp(mp(index,taken),prevtake)];
    }
    long long res=0;
    res=dp(index+1,taken,false);
    if (!prevtake){
        res=max(res,dp(index+1,taken+1,true)+arr[index]);
    }
    return memo[mp(mp(index,taken),prevtake)]=res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for (int i=1;i<=n;i++){
        cin>>arr[i];
    }
    /*
    for (int i=1;i<=n;i++){
        pre[i][0]=pre[i-1][0];
        pre[i][1]=pre[i-1][1];
        pre[i][i%2]+=arr[i];
    }
    for (int i=n;i>=1;i--){
        post[i][0]=post[i+1][0];
        post[i][1]=post[i+1][1];
        post[i][i%2]+=arr[i];
    }
    if (n%2==0){
        cout<<max(pre[n][0],pre[n][1]);
        return 0;
    }
    ans=pre[n][0];
    for (int i=1;i<=n;i++){
        //dont take i
        if (i%2==1){
            long long one=0,two=0;
            one=max(pre[i-1][0],pre[i-1][1]);
            two=max(pre[n][0]-pre[i][0],pre[n][1]-pre[n][1]);
            ans=max(ans,one+two);
        }
        else {
            long long one=0,two=0;
            one=pre[i-1][1];
            one+=pre[n][0]-pre[i][0];
            two=pre[i-1][0];
            two+=pre[n][1]-pre[i][1];
            ans=max(ans,one);
            ans=max(ans,two);
        }
    }
    */
    cout<<dp(1,0,false);
}

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BEvenDegrees {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    vector<vector<int>> G;
    vector<int> out;
    vector<P> ans;
    set<int> visited;
    set<P> path;

    void dfs(int v, int p) {
        visited.insert(v);

        int num = 0;
        REP(i, G[v].size()) {
            int to = G[v][i];
            if (to == p) continue;

            if (visited.count(to)) {
                if (path.count({v, to}) || path.count({to, v})) continue;
                ans.emplace_back(v, to);
                path.insert({v, to});
                out[v]++;
            } else {
                dfs(to, v);
            }
        }

        if (p != -1) {
            if (out[v] % 2 == 1) {
                ans.emplace_back(v, p);
                path.insert({v, p});
            } else {
                ans.emplace_back(p, v);
                path.insert({p, v});
                out[p]++;
            }
        }
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N, M;
        cin >> N >> M;
        G = vector<vector<int>>(N);
        out = vector<int>(N);
        REP(i, M) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            G[a].push_back(b);
            G[b].push_back(a);
        }

        if (M % 2 == 1) {
            cout << -1 << endl;
            return;
        }

        dfs(0, -1);

        REP(i, ans.size()) {
            cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BEvenDegrees solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 27504
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int h = in.nextInt();
        final int w = in.nextInt();
        final char[][] map = new char[h][w];
        for (int i = 0; i < h; i++) {
            final String line = in.next();
            map[i] = line.toCharArray();
        }

        final int[][] horizontal = new int[h][w];
        final int[][] vertical = new int[h][w];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (map[i][j] == '#') {
                    if (j > 0) {
                        final int sum = horizontal[i][j - 1];
                        for (int k = j - 1; k > j - 1 - sum; --k) {
                            horizontal[i][k] = sum;
                        }
                    }
                    if (i > 0) {
                        final int sum = vertical[i - 1][j];
                        for (int k = i - 1; k > i - 1 - sum; --k) {
                            vertical[k][j] = sum;
                        }
                    }

                } else if (map[i][j] == '.') {
                    if (j > 0) {
                        horizontal[i][j] = horizontal[i][j - 1] + 1;
                    } else {
                        horizontal[i][j] = 1;
                    }

                    if (i > 0) {
                        vertical[i][j] = vertical[i - 1][j] + 1;
                    } else {
                        vertical[i][j] = 1;
                    }
                }
            }
            final int sum = horizontal[i][w - 1];
            for (int k = w - 1; k > w - 1 - sum; --k) {
                horizontal[i][k] = sum;
            }
        }
        for (int i = 0; i < w; i++) {
            final int sum = vertical[h - 1][i];
            for (int k = h - 1; k > h - 1 - sum; --k) {
                vertical[k][i] = sum;
            }
        }

        int max = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                max = Math.max(max, vertical[i][j] + horizontal[i][j]);
            }
        }
        System.out.println(max-1);
    }
}


Measured memory_bytes: 109040
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
using namespace std;

vector<string> num;
int cnt;
void rec(vector<string>& vs,vector<int>& vi,string s,int i,int k){
	if(i==k){
		bool f=true;
		for(int j=0; j<num.size(); ++j){
			if(num[j]==s){
				f=false;
				break;
			}
		}
		if(f) {
			num.push_back(s);
			++cnt;
		}
		return;
	}
	for(int l=0; l<vi.size(); ++l){
		if(vi[l]==0){
			vi[l]=1;
			rec(vs,vi,s+vs[l],i+1,k);
			vi[l]=0;
		}
	}
}
int main(){
	int n,k;
	while(cin>>n>>k&&n!=0&&k!=0){
		cnt=0;
		vector<string> card(n);
		vector<int> ok(n);
		for(int i=0; i<num.size(); ++i){
			num[i]="";
		}
		for(int i=0; i<n; ++i){
			cin >> card[i];
		}
		rec(card,ok,"",0,k);
		/*for(int i=0; i<num.size(); ++i){
			cout << num[i] << "\n";
		}*/
		cout << cnt << "\n";
	}
	return 0;
}

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

int solve(int n) {
  int res = 0;
  for(int i = 0; i < 256; ++i) {
    if( i * i > n ) break;
    for(int j = i; j < 256; ++j) {
      if( i * i + j * j > n ) break;
      for(int k = j; k < 256; ++k) {
        if( i * i + j * j + k * k > n ) break;
        for(int w = k; w < 256; ++w) {
          if( i * i + j * j + k * k + w * w > n ) break;
          if( i * i + j * j + k * k + w * w == n ) {
            res += 1;
          }
        }
      }
    }
  }
  return res;
}

int main() {

  int n;
  for(;;) {
    std::cin >> n;
    if( n == 0 ) break;
    std::cout << solve(n) << std::endl;
  }
 
  return 0;
}
  

Measured memory_bytes: 3060
import fractions
N, X = map(int,input().split())
x = list(map(int,input().split()))
x.extend([X])
x.sort()
sa = [0]*(N)
for i in range(N):
    sa[i] = x[i+1]-x[i]
ans = max(x)
if len(sa) == 1:
    ans = sa[i]
else:
    for i in range(N-1):
        ans = min(ans, fractions.gcd(sa[i],sa[i+1]))
print(ans)
    

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

inline int f(int n){
    return n % 2 == 0 ? n / 2 : n * 3 + 1;
}

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

    vector<int> a(1000005);
    cin >> a[1];
    vector<bool> used(1000005);
    used[a[1]] = true;
    int ans = 1000000;
    REP(i, 2, 1000005){
        a[i] = f(a[i - 1]);
        if(used[a[i]]){
            ans = i;
            break;
        }
        used[a[i]] = true;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4352
object Main extends App {
	val Array(n, m) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	val tL = new Array[Int](m)
	val tR = new Array[Int](m)

	for(i<-0 until m){
		val Array(tp1, tp2) = scala.io.StdIn.readLine.split(" ").map(_.toInt - 1)
		
		tL(i) = tp1
		tR(i) = tp2

	}

	val maxL = tL.max
	val maxR = tR.min

	val ans = maxR - maxL + 1

	println(math.max(0, ans))
}

Measured memory_bytes: 52816
#include<bits/stdc++.h>
using namespace std;
int a,b,k;
int main(){
	cin>>a>>b>>k;
	for(int i=1;i<=k;i++){
		if(i&1){
			if(a&1){
				a--;
				b+=a/2;
				a>>=1;	
			}
			else{
				b+=a/2;
				a>>=1;
			}
		}
		else {
			if(b&1){
				b--;
				a+=b/2;
				b>>=1;	
			}
			else{
				a+=b/2;
				b>>=1;
			}
		}
	}
	cout<<a<<" "<<b<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい


//https://drken1215.hatenablog.com/entry/2018/06/08/210000
//https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
const int MAX = 200005;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void Main(){
  int N, M, K, ans = 0;
  cin >> N >> M >> K;

  COMinit();

  ll x=1;
  rep(j, N-1-K){
    x = x * (M-1) % MOD;
  }
  for(int k = K; k >= 0; k--){
    ans += (M * COM(N-1, k) % MOD) * x % MOD;
    ans %= MOD;
    x = x * (M-1) % MOD;
  }

  cout << ans << endl;

}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


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

#define ll long long
#define endl '\n'
#ifndef _WINDOWS
// no getchar_unlocked on Windows so just call getchar
#define getchar getchar_unlocked
#endif

template <typename Func>
inline void loop(int e, Func&& f) {
    for (int i = 0; i < e; i++) {
        std::forward<Func>(f)(i);
    }
}
template <typename Func>
inline void loop(int s, int e, Func&& f) {
    for (int i = s; i < e; i++) {
        std::forward<Func>(f)(i);
    }
}
template <typename T>
inline void scanpn(T& num) {
    int c;
    num = 0;
    c = getchar();
    // bool negative = false;
    // if (c == '-') {
    // 	negative = true;
    // 	c = getchar();
    // }
    for (; (c > 47 && c < 58); c = getchar()) num = num * 10 + c - 48;
    // if (negative)
    //     number = -number;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k, hi, lo;
    cin >> k >> lo >> hi;
    if ((lo / k) < (hi / k)) {
        cout << "OK" << endl;
    } else if (lo % k == 0 || hi % k == 0) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
import java.io.{BufferedReader, IOException, InputStream, InputStreamReader}
import java.util.StringTokenizer

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

object Main {
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()
    val T = sc.nextInt()
    val A = Array.ofDim[Int](N + 1)
    (1 to N) foreach (i => A(i) = sc.nextInt())

    // 無駄にDP
    val a_min = Array.ofDim[Int](N + 1)
    a_min(0) = Integer.MAX_VALUE
    val aa_max = Array.ofDim[Int](N + 1)
    val aa_max_cnt = Array.ofDim[Int](N + 1)

    (1 to N) foreach { i =>
      a_min(i) = min(a_min(i - 1), A(i))
      val aa = A(i) - a_min(i)
      aa_max(i) = max(aa_max(i - 1), aa)
      aa_max_cnt(i) =
        if (aa_max(i) != aa_max(i - 1))
          1
        else
          aa_max_cnt(i - 1) + (if (aa_max(i) == aa) 1 else 0)
    }

    println(aa_max_cnt(N))
  }

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



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

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

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

}


Measured memory_bytes: 38700
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M;
	int X[100001];
	scan(N);scan(M);
	rep(i,M) scan(X[i]);
	if(N>=M){
		prin(0);
		return 0;
	}
	sort(X,X+M);
	int sep[100001];
	rep(i,M-1){
		sep[i]=X[i+1]-X[i];
	}
	sort(sep,sep+M-1);
	ll ans=0;
	rep(i,M-N){
		ans+=sep[i];
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1000000;
int main(){
    ll n, k; cin >> n >> k;
    vector<ll> h(n);
    for(ll i=0; i<n; ++i){cin >> h[i];}
    vector<ll> dp(n, INF); dp[0] = 0; 
    for(ll i=1; i<n; ++i){
        for(ll j=1; j<=min(i,k); ++j){
            if(j==1){dp[i] = abs(h[i]-h[i-j]) + dp[i-j];}
            else{dp[i] = min(dp[i-j] + abs(h[i]-h[i-j]), dp[i]);}
          	//for(int k=0; k<n; ++k){cout << dp[k] << ",";} cout << endl;
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 4824
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector< vector<int> > field;

int calc_agp(int row, int col, int rr, int cr) {
	int lim = (1 << 28);
	int sum,wmax;
	sum = wmax = 0;
	for (int i = 0; i < rr; ++i) {
		for (int j = 0; j < cr; ++j) {
			if (i == 0||j == 0||i == rr-1||j == cr-1) {
				lim = min(field[row+i][col+j],lim);
			}
			else {
				wmax = max(field[row+i][col+j],wmax);
				sum += field[row+i][col+j];
			}
		}
	}
	if (wmax >= lim) {
		return 0;
	}
	return ((lim*(rr-2)*(cr-2))-sum);
}

int main(void) {
	int d,w;
	string str;
	while (cin >> d >> w,d,w) {
		int res = 0;
		field = vector< vector<int> >(d,vector<int>(w));
		for (int i = 0; i < d; ++i) {
			for (int j = 0; j < w; ++j) {
				cin >> field[i][j];
			}
		}
		for (int i = 0; i < d-2; ++i) {
			for (int j = 0; j < w-2; ++j) {
				for (int dd = 3; dd+i < d+1; ++dd) {
					for (int dw = 3; dw+j < w+1; ++dw) {
						res = max(calc_agp(i,j,dd,dw),res);
					}
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}



Measured memory_bytes: 3068
N,K = map(int, input().split())
p = list(map(int,input().split()))

pi = [0.5*i + 0.5 for i in range(1001)]
H = [pi[p[i]] for i in range(N)]
sum_list = [0 for i in range(N-K)]
added = sum(H[0:K])
max_added = added
for k in range(K,N):
    added = added + H[k] - H[k-K]
    if added > max_added:
        max_added = added

print(max_added)

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

int main(){
  int n;  cin >> n;
  int table[2][100005] = {0};    

  for(int i=0; i<n; i++){
    int v;  cin >> v;
    table[i%2][v]++;
  }

  vector<pair<int, int>> ruia, ruib;
  for(int i=0; i<1e5+5; i++){
    if(table[0][i])  ruia.push_back({table[0][i], i});
    if(table[1][i])  ruib.push_back({table[1][i], i});
  }
  sort(ruia.rbegin(), ruia.rend());
  sort(ruib.rbegin(), ruib.rend());

  long ans = 0;
  if(ruia[0].second == ruib[0].second){
    if(ruia.size() == 1 && ruib.size() == 1)
      ans = n / 2;
    else if(ruia.size() == 1)
      ans = n/2 - ruib[1].first;
    else if(ruib.size() == 1)
      ans = n/2 - ruia[1].first;
    else
      ans = min(n/2-ruib[0].first+n/2-ruia[1].first, n/2-ruia[0].first+n/2-ruib[1].first);
  }else{
    ans = n/2-ruia[0].first + n/2-ruib[0].first;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4788
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>

int main(int argc, char *argv[])
{
	int n;

	cin >> n;
	map<string,int> m;
	for (int i=0;i<n;i++)
	{
		string tmp;
		cin >> tmp;
		sort(tmp.begin(),tmp.end());
		if (m.count(tmp)==0) m[tmp]=1; else m[tmp]++;
	}
	long long a=0;
	for (auto i=m.begin(); i!= m.end(); i++)
	{
		long long x=i->second;
		a+=(x*(x-1)/2);
	}
	cout << a;
	return 0;
}



Measured memory_bytes: 11136
import java.io.*;

class Main {
	public static void main(String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String buf;

		try {
			while ((buf = br.readLine())!=null) {
				long S = 0;
				int d = Integer.parseInt(buf);
				for (int i=d;i+d<=600;i+=d) S += f(i)*d;
				System.out.println(S);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static long f(int x) {
		return (long)x*x;
	}
}

Measured memory_bytes: 16860
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
    ll A,B,C;
    cin>>A>>B>>C;
    ll K;
    cin>>K;
    ll ans=0;
    if(B>A)ans=0;
    else if(2*B>A)ans++;
    else if(4*B>A)ans=2;
    else ans=3;
    B=powerup(2,ans,MOD)*B;
    if(C>B)ans=ans;
    else if(2*C>B)ans++;
    else if(4*C>B)ans+=2;
    else if(8*C>B)ans+=3;
    else ans+=4;
    if(ans>K)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

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

using namespace std;


int main(){
	int a, b;
	cin >> a >> b;
	
	if(a <=b){ for(int i = 0; i < b; i++) cout << a;}
	else{ for(int i = 0; i < a; i++) cout << b;}
	return 0;
}
		
	


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;


int main(){
    int n,d;
    cin>>n>>d;
    int ans=n/(2*d+1);
    if(n%(2*d+1)!=0){
        ans++;
    }
    out(ans);
    return 0;
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string ans = "CODEFESTIVAL2016";
    string S;
    cin >> S;
    int answer = 0;
    for (int i = 0; i < 16; ++i) {
        if (S[i] != ans[i]) ++answer;
    }
    cout << answer << endl;
}

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

#define M 0x000fffff
#define NIL (-1)
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  return -1;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return key%L; }

int find(char str[]){
  int key = (int)(getKey(str)&0x7fffffff);
  return (H[h1(key)][h2(key)]=='\0'?0:1);
}

int insert(char str[]){
  int key = (int)(getKey(str)&0x7fffffff);
  H[h1(key)][h2(key)] = 't';
  return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 14924
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MOD = 1e9+7;

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

    int n;
    cin >> n;

    map<string,int> memo;
    rep(i,n){
        string s;
        cin >> s;
        memo[s]++;
    }

    int ans = memo.size();
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 19220
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

    double  L;
    cin >> L;

    cout << fixed << setprecision(12);
    cout << L*L*L/27 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>//aoj511
#include<algorithm>
using namespace std;
int main(void)
{
	int n[30],i,j=1,cnt=0;
	for(i=0;i<28;i++) cin>>n[i];
	sort(n,n+28);
	for(i=0;i<28;i++){
		if(n[i]!=j){
			cout<<j<<endl;
			cnt++;
			j++;
		}
		j++;
	}
	if(cnt==1) cout<<"30"<<endl;
	return 0;
}


Measured memory_bytes: 3156
/*بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم*/

#include <bits/stdc++.h>
using namespace std;

inline int ABS (int x)
{
    return x<0 ? -x : x;
}
int main ()
{
    int i,n,z,w,ara[2005];
    cin>>n>>z>>w;
    for (i=1;i<=n;i++) scanf ("%d",&ara[i]);
    if (n==1) cout<<ABS(w-ara[1])<<endl;
    else cout<<max(ABS(w-ara[n]),ABS(ara[n]-ara[n-1]))<<endl;

    return 0;
}


Measured memory_bytes: 256
//
// Created by tac on 2016/10/12.
//

#include <cstdlib>
#include <iostream>

int main() {
    int h, w;
    while (true) {
        std::cin >> h >> w;
        if (h <= 0 && w <= 0) {
            break;
        }
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                std::cout << "#";
            }
            std::cout << std::endl;
        }
        std::cout << std::endl;
    }
    return EXIT_SUCCESS;
}

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

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){

  int n;
  scanf("%d",&n);

  int a[n];
  for(int i = 0; i < n; ++i){
    scanf("%d",&a[i]);
  }

  int count = 0;
  for(int i = 0; i < n; i += 2){
    if(a[i] % 2 == 1) count ++;
  }

  printf("%d",count);

  return 0;
}


Measured memory_bytes: 1732
a,b,c=0,1,2
one,zero=3,4
x,y=5,6
pi,pj=7,8
z=9
def p(i,j,k):print("+",i,j,k)
def l(i,j,k):print("<",i,j,k)
def s(i,j):
    for k in range(j):p(i,i,i)
print(60452)
p(a,b,one);l(zero,one,one)
for i in range(29,-1,-1):
    p(one,zero,pi);s(pi,i)
    p(x,pi,pi);l(a,pi,pi);l(pi,one,pi)
    p(zero,zero,y)
    for j in range(29,-1,-1):
        p(one,zero,pj);s(pj,j)
        p(y,pj,pj);l(b,pj,pj);l(pj,one,pj)
        l(pi,pj,z);l(z,pj,z);s(z,i+j);p(c,z,c)
        s(pj,j);p(y,pj,y)
    s(pi,i);p(x,pi,x)

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

int main() {
  long long count=0;
  long long N,a,b,c,d,e;
  cin>>N>>a>>b>>c>>d>>e;
  cout<<(N-1+min(a,min(b,min(c,min(d,e)))))/min(a,min(b,min(c,min(d,e))))+4;
}

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

if contest_num >= 1999: # 不等号は=の手前に
    result_str = 'The contest has not been held'

elif contest_num < 1000:
    result_str = 'ABC'

elif contest_num >= 1000:
    result_str = 'ABD'

print(result_str)

Measured memory_bytes: 9156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
    FAST
    int n;
    cin>>n;
    string s;
    cin>>s;
    stack<char>stck;
    stck.push(s[0]);
    for(int i=1;i<n;i++){
        if(s[i]==stck.top())continue;
        else stck.push(s[i]);
    }
    cout<<stck.size();
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
  {      int n,t=0;
           cin>>n;
           int a[n];
           for(int i=0;i<n;i++)
              cin>>a[i];
           for(int i=1;i<n-1;i++)
           {
               if((a[i-1]<a[i] && a[i]<a[i+1]) ||  (a[i-1]>a[i] && a[i]>a[i+1]))

                          t++;

              }
            cout<<t++;

     return 0;
  }


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n, W;
int w[100], v[100];
int dp[101][10100];
//dp[i+1][j]:i???????????§???????????§?????????j??\??????????????¨?????????????????????????????§???

int main() {
	cin >> n >> W;
	for (int i = 0; i < n; i++)cin >> v[i] >> w[i];
	//for (int i = 0; i < n; i++) {
	//	for (int j = 0; j <= W; j++) {
	//		for (int k = 0; k*w[i] <= j; k++) {
	//			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - k*w[i]] + k*v[i]);
	//		}
	//	}
	//}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= W; j++) {
			if (j < w[i]) {
				dp[i + 1][j] = dp[i][j];
			}
			else {
				dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
			}
		}
	}

	//rep(i, n + 1) {
	//	rep(j, W + 1) {
	//		printf("%3d", dp[i][j]);
	//	}
	//	cout << endl;
	//}
	cout << dp[n][W] << endl;
}

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

using namespace std;



int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a>c)
    cout<<"NO";
    else
    {
    if((c-a)<b)
    cout<<"YES";
    else
    cout<<"NO";
    }

    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  int ans=0;
  int count1=0,count2=0;
  int kaage=1;
  for(int i=0;i<N;i++){
    string S;cin>>S;
    bool a=false,b=false;
    if(S.at(0)=='B'){a=true;count1++;}
    if(S.at(S.size()-1)=='A'){b=true;count2++;}
    if(!a&&!b)kaage++;
    for(int j=0;j<S.size()-1;j++){
      if(S.at(j)=='A'&&S.at(j+1)=='B')ans++;
    }
  }
  cout<<ans+min(min(count1,count2),max(0,N-kaage))<<endl;
}


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



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

    int count = 1;
    int mx = nums[0];
    for(int i = 1; i < n; ++i){
        if(nums[i] >= mx){
            count++;
        }
        mx = max(mx, nums[i]);
    }
    cout << count << endl;

}

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

using namespace std;

using ll = long long;

const long long MOD_NUMBER = 1000000007;
const double PI = 3.14159265358979323846;

// ベクトル要素の列挙
template <class T> void vector_print(vector<T> vec) {
  for (unsigned int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size()-1) {
      cout << " ";
    } else if (i == vec.size()-1) {
      cout << endl;
    }
  }
}
// エラトステネスの篩による素数配列の出力
vector<int> Eratosthenes(int N){
  vector<int> p = {2};
  int sqrtN = sqrt(N);
  for(int i = 3; i <= N; i++){
    p.push_back(i);
    for (int j = 0; p.at(j) <= sqrtN; j++) {
      if(i%p.at(j) == 0) {
        p.pop_back();
        break;
      }
    }
  }
  return p;
}
int main() {
  double rad, ans;
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  rad = 5.5*(h*60+m)*PI/180;
  ans = sqrt(a*a+b*b-2*a*b*cos(rad));
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 4128