akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,m,n) for(int i=m;i<n;i++)
typedef long long ll;

int main() {
  int n,m;
  cin>>n>>m;
  ll l;
  cin>>l;
  ll d[n][n];
  rep(i,0,n){
    rep(j,0,n){
      d[i][j]=3e11;
    }
  }
  rep(i,0,n){
    d[i][i]=0;
  }
  rep(i,0,m){
    int a,b;
    cin>>a>>b;
    ll c;
    cin>>c;
    if(c<=l){
      d[a-1][b-1]=c;
      d[b-1][a-1]=c;
    }
  }
  rep(k,0,n){
    rep(i,0,n){
      rep(j,0,n){
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  
  rep(i,0,n){
    rep(j,0,n){
      if(d[i][j]>0 && d[i][j]<=l){
        d[i][j]=1;
      }
    }
  }
  
  rep(k,0,n){
    rep(i,0,n){
      rep(j,0,n){
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  
  int q;
  cin>>q;
  rep(i,0,q){
    int s,t;
    cin>>s>>t;
    if(d[s-1][t-1]==3e11) cout<<-1<<endl;
    else cout<<d[s-1][t-1]-1<<endl;
  }
}


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

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

    int n,i,j;
    cin>>n;
    vector<long long int> a(n),b(n),c(n);
    for(i=0;i<n;i++)
        cin>>a[i]>>b[i]>>c[i];
    for(i=1;i<n;i++)
    {
        a[i]+=max(b[i-1],c[i-1]);
        b[i]+=max(a[i-1],c[i-1]);
        c[i]+=max(b[i-1],a[i-1]);
    }
    cout<<max({a[n-1],b[n-1],c[n-1]});

}

Measured memory_bytes: 2560
N = gets.chomp.to_i
H = gets.chomp.split().map(&:to_i)

s = 0
N.times do |i|
  if i == 0
    s += H[0]
  elsif H[i-1] < H[i]
    s += H[i] - H[i-1]
  end
end

puts s


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> d_list(0);
    for (int i = 1; i * i <= m; i++){
        if (m % i == 0){
            d_list.push_back(i);
            if (i * i < m) {
                d_list.push_back(m / i);
            }
        }
    }
    sort(d_list.begin(), d_list.end());
    int d_max = m / n;
    int index = (upper_bound(d_list.begin(), d_list.end(), d_max) - d_list.begin() - 1);
    cout << d_list[index] << endl; 
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();

		// 計算
		int result = 700;
		for(int i = 0; i < s.length(); i++){
		    if(s.charAt(i) == 'o') result += 100;
		}
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 22100
N = int(input())
if N/1.08 == -(-N//1.08):
    print(int(N/1.08))
# もとの数の商より大きく，+1の商より小さい整数
else:
    if not -(-N//1.08) == -(-(N+1)//1.08):
        print(int((N+1)//1.08))
    else:
        print(':(')

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
int main() {

	bool flag = true;
	int n;
	vector<int> x(100000);
	vector<int> y(100000);
	vector<int> t(100000);
	x[0] = y[0] = t[0] = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> t[i];
		cin >> x[i];
		cin >> y[i];
	}
	for (int i = 1; i <= n; i++) {
		if (((t[i]-t[i-1])* (t[i] - t[i - 1]) % 2 == (x[i]-x[i-1]+ y[i]-y[i-1])* (x[i] - x[i - 1] + y[i] - y[i - 1]) % 2)&&((x[i]-x[i-1]+y[i]-y[i-1])* (x[i] - x[i - 1] + y[i] - y[i - 1]) <=(t[i]-t[i-1])* (t[i] - t[i - 1]))) {
			flag = true;
		}
		else
		{
			flag = false;
			break;
		}
	}
	if (flag) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string A,B;
    cin >> A >> B;
    if(A.size() > B.size()){
        cout << "GREATER" << "\n";
    }else if(A.size() < B.size()){
        cout << "LESS" << "\n";
    }else if(A == B){
        cout << "EQUAL" << "\n";
    }else{
        REP(i,A.size()){
            if(A[i] == B[i])continue;
            if(A[i] > B[i]){
                cout << "GREATER" << "\n";
                break;
            }else{
                cout << "LESS" << "\n";
                break;
            }
        }
    }
}

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

int main() {
	int N;
	scanf("%d", &N);
	int *x = new int[N];
	int *y = new int[N];
	for (int i = 0; i < N; i++) {
		scanf("%d %d", &x[i], &y[i]);
	}

	int most_zero = 0;
	for (int i1 = 0; i1 < N; i1++) {
		for (int i2 = 0; i2 < N; i2++) {
			if (i1 == i2)continue;
			int zero = 0;
			int dx = x[i1] - x[i2];
			int dy = y[i1] - y[i2];
			for (int j1 = 0; j1 < N; j1++) {
				for (int j2 = 0; j2 < N; j2++) {
					if (j1 == j2)continue;
					if (x[j1] - x[j2] == dx && y[j1] - y[j2] == dy) {
						zero++;
					}
				}
			}
			if (most_zero < zero)most_zero = zero;
		}
	}
	printf("%d", N - most_zero);
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <string>
#include <utility>
#include <iostream>
#include <algorithm>
using namespace std;
using worker_t = pair<string,int>;

int main() {
	while (true) {
		int n; // number of workers
		cin >> n;
		if (n == 0) {
			break;
		}
		vector<worker_t> v;
		while (n--) {
			string i;
			int q,p;
			cin >> i >> q >> p;
			auto w_itr = find_if(v.begin(),v.end(),[i](worker_t w) { return w.first == i; });
			if (w_itr == v.end()) { // if the worker not exist
				v.push_back({i,q*p});
			} else {
				w_itr->second += q*p;
			}
		}
		int count = 0;
		for (auto itr = v.begin();itr != v.end();++itr) {
			if (itr->second >= 1000000) {
				cout << itr->first << endl;
				++count;
			}
		}
		if (count == 0) {
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 3216
def e_common_subsequence(N, M, S, T, MOD=10**9 + 7):
    # dp[i][j]: S[i], T[j] まで考慮したとき、この2つをペアにしたときの場合の数
    dp = [[0] * (M + 1) for _ in range(N + 1)]

    # S, T のどちらかを見ていない場合、空整数列のみが等しい整数列となる
    for i in range(N + 1):
        dp[i][0] = 1
    for j in range(M + 1):
        dp[0][j] = 1

    for i in range(N):
        for j in range(M):
            if S[i] == T[j]:
                # S[i], T[j] までで作れた等しい整数列に対して
                # 1つ新しい要素を付け加えられる。よって次式のように和を取る
                dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j]
            else:
                # S[i], T[j] は付け加えられないので、その分引く
                dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j] - dp[i][j] + MOD
            dp[i + 1][j + 1] %= MOD
    return dp[N][M]

N, M = [int(i) for i in input().split()]
S = [int(i) for i in input().split()]
T = [int(i) for i in input().split()]
print(e_common_subsequence(N, M, S, T))

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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

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

    int n, k;
    cin >> n >> k;

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

    vi win(k + 1, 0);
    for (int i = 1; i <= k; ++i) {
        for (int x : a) {
            if (x > i)
                break;
            if (!win[i - x]) {
                win[i] = true;
                break;
            }
        }
    }

    cout << (win[k] ? "First" : "Second") << '\n';

    return 0;
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Random;
import java.util.Scanner;
import java.util.concurrent.SynchronousQueue;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		HashMap hm = new HashMap();
		int ans = 0;
		for (int i = 0; i < n; ++i) {
			int a = sc.nextInt();
			if (hm.containsKey(a)) {
				hm.delete(a);
				--ans;
			} else {
				hm.put(a, 0);
				++ans;
			}
		}
		System.out.println(ans);
	}

	static class HashMap {
		class Pair {
			long key;
			long value;

			public Pair(long key_, long value_) {
				key = key_;
				value = value_;
			}
		}

		Random rand = new Random();
		long p = (long) 1e6 + 7;
		long a = rand.nextInt((int) p - 1) + 1;
		long b = rand.nextInt((int) p - 1) + 1;
		int sz = 16;
		int cnt = 0;
		LinkedList<Pair>[] list;

		public HashMap() {
			list = new LinkedList[sz];
			for (int i = 0; i < list.length; ++i) {
				list[i] = new LinkedList<>();
			}
		}

		public HashMap(int sz_) {
			sz = sz_;
			list = new LinkedList[sz];
			for (int i = 0; i < list.length; ++i) {
				list[i] = new LinkedList<>();
			}
		}

		boolean delete(long key) {
			int id = hash(key);
			boolean ret = false;
			for (int i = 0; i < list[id].size(); ++i) {
				if (list[id].get(i).key == key) {
					list[id].remove(i);
					ret = true;
					break;
				}
			}
			if (sz >= 3 * cnt) {
				changeSize(sz / 2);
			}
			return ret;
		}

		void put(long key, long value) {
			int id = hash(key);
			for (int i = 0; i < list[id].size(); ++i) {
				if (list[id].get(i).key == key) {
					list[id].get(i).value = value;
					return;
				}
			}
			list[id].add(new Pair(key, value));
			++cnt;

			if (cnt > sz) {
				changeSize(2 * sz);
			}

			return;
		}

		long get(long key) {
			int id = hash(key);
			for (int i = 0; i < list[id].size(); ++i) {
				if (list[id].get(i).key == key) {
					return list[id].get(i).value;
				}
			}
			throw new AssertionError();
		}

		boolean containsKey(long key) {
			int id = hash(key);
			for (int i = 0; i < list[id].size(); ++i) {
				if (list[id].get(i).key != key) {
					continue;
				}
				return true;
			}
			return false;
		}

		int hash(long v) {
			return (int) ((a * v % p + b) % p % sz);
		}

		void changeSize(int sz_) {
			LinkedList<Pair>[] tmp = new LinkedList[sz];
			for (int i = 0; i < tmp.length; ++i) {
				tmp[i] = new LinkedList<>();
				tmp[i].addAll(list[i]);
			}
			sz = sz_;
			list = new LinkedList[sz];
			for (int i = 0; i < list.length; ++i) {
				list[i] = new LinkedList<>();
			}
			cnt = 0;
			for (int i = 0; i < tmp.length; ++i) {
				for (Pair p : tmp[i]) {
					put(p.key, p.value);
				}
			}
		}
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

Measured memory_bytes: 77312
N, W = map(int, input().split())
w, v = [0], [0]
for i in range(N):
    w_i, v_i = map(int, input().split())
    w.append(w_i)
    v.append(v_i)
DP = [[0 for c in range(W+1)] for i in range(N+1)]
for i in range(1, N+1):
    for c in range(1, W+1):
        if c - w[i] < 0:
            DP[i][c] = DP[i-1][c]
        else:
            DP[i][c] = max(DP[i-1][c], DP[i-1][c-w[i]] + v[i])
print(DP[N][W])

Measured memory_bytes: 217544
N = int(input())
H = list(map(int, input().split()))
rH = list(reversed(H))
for idx, val in enumerate(rH):
    if idx == len(rH) - 1:
        break
    if rH[idx + 1] > val:
        rH[idx + 1] -= 1
        if rH[idx + 1] > val:
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B;
  cin >> A >> B;
  
  int x=abs(A-B);
  
  if(x>1){
    cout << max(2*A-1,2*B-1) << endl;
  }else{
    cout << A+B << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

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

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

struct segtree {
    int n;
    vi seg;

    void init(int n_)
    {
        n = 1;
        while (n < n_) n *= 2;
        seg.resize(2 * n - 1);
        rep(i, 2 * n - 1) seg[i] = 0;
    }

    int update(int k, int a)
    {
        k += n - 1;

        seg[k] += a;

        while (k > 0) {
            k = (k - 1) / 2;
            seg[k] += a;
        }
    }

    int query(int a, int b, int k, int l, int r)
    {
        if (r <= a || b <= l) return 0;

        if (a <= l && r <= b) return seg[k];

        int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);

        return vl + vr;
    }

    int query(int a, int b)
    {
        return query(a, b, 0, 0, n);
    }
};

signed main()
{
    int N, Q; cin >> N >> Q;

    segtree s;

    s.init(N);

    rep(i, Q) {
        int c, x, y; cin >> c >> x >> y;

        if (c == 0) {
            -- x;
            s.update(x, y);
        } else {
            -- x; -- y;
            cout << s.query(x, y + 1) << endl;
        }
    }
}

Measured memory_bytes: 2060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	string s;
	int h;
	while(true){
		cin >> s;
		if(s == "-")break;
		cin >> h;
		int m;
		for(int i = 0; i < h; i++){
			cin >> m;
			s = s.substr(m,s.size() - m) + s.substr(0,m);
		}
		cout << s << endl;
	}
	return 0;
}


Measured memory_bytes: 3168
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static int queryCount=0;
    public static void main(String[] args) {
	// write your code here
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int[] ints=new int[n];
        int[] howMany=new int[n];
        for(int i=0;i<n;i++){
            ints[i]=scanner.nextInt();
            howMany[i]=howManyCanDiv2(ints[i]);
        }
        int min=Integer.MAX_VALUE;
        for(int i=0;i<n;i++){
            if(min>howMany[i])min=howMany[i];
        }
        System.out.println(min);
    }
    public static int howManyCanDiv2(int n){
        int result=0;
        while(n%2==0){
            result++;
            n=n/2;
        }
        return result;
    }
}


Measured memory_bytes: 23764
def main():
    a, b, c = map(int, input().split())

    flag = False

    if a == b + c :
        flag = True
    if b == a + c :
        flag = True
    if c == b + a :
        flag = True

    if flag == True:
        print("Yes")
    else:
        print("No")
main()

Measured memory_bytes: 2940
# import sys
# sys.setrecursionlimit(10 ** 6)
from itertools import combinations_with_replacement

int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def solve():
    n = II()
    divisors = make_divisors(n)

    ans = 1001001001001001
    for a, b in combinations_with_replacement(divisors, 2):
        if a * b != n:
            continue
        step = (a-1) + (b-1)
        ans = min(step, ans)
    print(ans)



if __name__ == '__main__':
    solve()


Measured memory_bytes: 3288
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 1000000007

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;


void solvec(){
    int n;
    cin>>n;
    ll count=0;
    for(int i=1;i<=n;i++){
        if(n%i==0){
            count+=(n/i-1);
        }
        else{
            count+=(n/i);
        }
    }
    cout<<count;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int T = 1;
    //cin >> T;

    while (T--)
    {
        solvec();
    }

    return 0;
}

Measured memory_bytes: 3684
#include <iostream>

using namespace std;

int main()
{
    long long n, k;
    cin >> n >> k;
    
    long long d = n / k;
    long long v1 = n - k * d;
    long long v2 = (-1) * (v1 - k);

    cout << (v1 < v2 ? v1 : v2) << endl;

    return 0;
}


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

l=list(map(int,input().split()))
l[0]-=1
Switch=True

for i in range(N-1):

    if l[i+1]==l[i]:
        pass
    elif l[i+1]>l[i]:
        l[i+1]-=1
    else:
        print("No")
        Switch=False
        break
    if i==N-2:
        print("Yes")
        Switch=False
    
if Switch:
    print("Yes")



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


int N, K, R, S, P;
string T;


int main() {
    cin >> N >> K >> R >> S >> P;
    cin >> T;
    map<char, int> m;
    m['r'] = P;
    m['s'] = R;
    m['p'] = S;
    ll ans = 0;
    for (int i = 0; i < min(N, K); i++) {
        ans += m[T[i]];
    }
    for (int i = K; i < N; i++) {
        if (T[i] == T[i-K]) {
            T[i] = 'z';
            continue;
        }
        ans += m[T[i]];
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const int N = 200200;
int n;
pll a[N];
ll sum0[N];
ll sum1[N];
ll sum2[N];
ll dp[N];
pii st[N];
int stSz;
bool inQ[N];

ll g(ll L, ll R) {
	ll val = (R - L) * a[L].first + (R - L) * a[R].first;
	val -= 2 * (L + R) * (sum1[R] - sum1[L + 1]);
	val += 2 * L * R * (sum0[R] - sum0[L + 1]);
	val += 2 * (sum2[R] - sum2[L + 1]);
	return val;
}

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i].first);
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i].second);
	int pos = 0;
	for (int i = 0; i < n; i++)
		if (a[i] > a[pos])
			pos = i;
	rotate(a, a + pos, a + n);
	a[n] = a[0];
	for (int i = 0; i < n + 1; i++) {
		sum0[i + 1] = sum0[i] + a[i].second;
		sum1[i + 1] = sum1[i] + a[i].second * i;
		sum2[i + 1] = sum2[i] + a[i].second * (ll)i * i;
	}
	
	ll ans = 0;
	for (int i = 0; i < n; i++)
		ans += g(i, i + 1);
	set<int> setik;
	for (int i = 0; i <= n; i++)
		setik.insert(i);
	vector<int> q;
	for (int i = 1; i < n; i++) {
		q.push_back(i);
		inQ[i] = 1;
	}
	while(!q.empty()) {
		int v = q.back();
		q.pop_back();
		assert(inQ[v]);
		inQ[v] = 0;
		auto it = setik.lower_bound(v);
		assert(*it == v);
		it++;
		int r = *it;
		it--;
		it--;
		int l = *it;
		it++;
		if (g(l, r) < g(l, v) + g(v, r)) continue;
		ans += g(l, r) - g(l, v) - g(v, r);
		setik.erase(v);
		if (l != 0 && l != n && !inQ[l]) {
			inQ[l] = 1;
			q.push_back(l);
		}
		if (r != 0 && r != n && !inQ[r]) {
			inQ[r] = 1;
			q.push_back(r);
		}
	}

	printf("%.15lf\n", (double)ans / (2 * n));

	return 0;
}


Measured memory_bytes: 21420
#include <bits/stdc++.h>
long long int m,n,z,ans;
using namespace std;
long long int vp[200010],sum;
map<long long int,long long int>q;
int main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&vp[i]);
        vp[i]+=vp[i-1]-1;
    }
    for(int i=1;i<=n;i++)
        vp[i]%=k;
    q[0]++;
    for(int i=1;i<=n;i++)
    {
        if(i>=k)
            q[vp[i-k]]--;
sum+=q[vp[i]];
        q[vp[i]]++;

    }
    printf("%lld",sum);
}

Measured memory_bytes: 14336
N, M = gets.split.map(&:to_i)
x_list = gets.split.map(&:to_i)
sorted = x_list.sort
diff_list = sorted.each_cons(2).map do |(a, b)|
  b - a
end
ans = diff_list.sort_by { |n| -n }.drop(N - 1).reduce(0, &:+)
puts ans


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

#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define per(i,n) for (int i=(int)(n)-1;i>=0;i--)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define Rep(i,n) for (int i=0;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define Max(a,b,c) max(a,max(b,c))
#define Min(a,b,c) min(a,min(b,c))
#define fore(i,x) for (auto &i:x)
#define cmax(x,y) x=max(x,y)
#define cmin(x,y) x=min(x,y)
#define pii pair<int,int>
#define vi vector <int>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define pb push_back
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=1e5+3;

ll n,m,ACC;
ll acc[MAXN*2],a[MAXN];
ll ans,ms,k[MAXN],v[MAXN*2],now,V;

inline ll ov(const ll &x){
	if (x>m) re x-m;
	re x;
}

int main(){
	fio;
	cin>>n>>m;
	rep(i,n){
		cin>>a[i];
	}
	rep(i,n-1){
		int l=a[i],r=a[i+1];
		if (r<l) r+=m;
		acc[l+1]++;
		acc[r+1]--;
		ans+=r-l;
		v[r+1]-=(r-l);
	}
	For(i,m*2){
		int ii=ov(i);
		now+=ACC;
		ACC+=acc[i];
		now+=v[i];
		k[ii]+=now;
	}
	For(i,m){
		cmax(ms,k[i]);
	}
	cout<<ans-ms<<endl;
	re 0;
}

Measured memory_bytes: 4224
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll a,b,n; cin >> a >> b >> n; ll x = 0;
  
  if(n < b) x = n;
  else x = n - (n % b) - 1;
  
  cout << floor(a*x/b) - a*floor(x/b) << endl;
}

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

int main(){
  int N; cin >> N;
  rep(i, N) for (int j = i + 1; j < N; j++) {
    int d = j - i;
    int level = 1;
    while (true) {
      if (d & 1) {
        cout << level << endl;
        break;
      }
      d /= 2;
      level++;
    }
  }
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main(void){
	int N,M,Day;
	int i;
	char str[10000000];
 
	fgets(str, sizeof(str), stdin);
	N=atoi(strtok(str," "));
	M=atoi(strtok(NULL," "));


	fgets(str, sizeof(str), stdin);
	Day=N-atoi(strtok(str," "));
	for(i=1;i<M;i++){
		Day-=atoi(strtok(NULL," "));
	}

	if(Day>=0){
		printf("%d\n",Day);
 	}else{
		printf("-1\n");
	}

	return 0;
}

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

int main(){
  int a,b;cin>>a>>b;
  if(b%a==0){cout<<a+b;}
  else{cout<<b-a;}
  
}

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

int main() {
  int w, h;
  string s;
  cin >> w >> h;
  for (int i = 0; i < h + 2; i++) {
    cout << "#";
  }
  cout << endl;
  for (int i = 0; i < w; i++) {
    cin >> s;
    cout << "#" << s << "#" << endl;
  }
  for (int i = 0; i < h + 2; i++) {
    cout << "#";
  }
}
  

Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int


// quoted from beet-aizu
template <typename T,typename E, typename F, typename G, typename H>
struct LazySegmentTree{
    //using F = function<T(T,T)>;
    //using G = function<T(T,E)>;
    //using H = function<E(E,E)>;
    int n,height;
    F f;
    G g;
    H h;
    T ti;
    E ei;
    vector<T> dat;
    vector<E> laz;
    LazySegmentTree(F f,G g,H h,T ti,E ei):
        f(f),g(g),h(h),ti(ti),ei(ei){}

    void init(int n_){
        n=1;height=0;
        while(n<n_) n<<=1,height++;
        dat.assign(2*n,ti);
        laz.assign(2*n,ei);
    }
    void build(const vector<T> &v){
        int n_=v.size();
        init(n_);
        for(int i=0;i<n_;i++) dat[n+i]=v[i];
        for(int i=n-1;i;i--)
            dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
    }
    inline T reflect(int k){
        return laz[k]==ei?dat[k]:g(dat[k],laz[k]);
    }
    inline void eval(int k){
        if(laz[k]==ei) return;
        laz[(k<<1)|0]=h(laz[(k<<1)|0],laz[k]);
        laz[(k<<1)|1]=h(laz[(k<<1)|1],laz[k]);
        dat[k]=reflect(k);
        laz[k]=ei;
    }
    inline void thrust(int k){
        for(int i=height;i;i--) eval(k>>i);
    }
    inline void recalc(int k){    
        while(k>>=1)
            dat[k]=f(reflect((k<<1)|0),reflect((k<<1)|1));
    }
    void update(int a,int b,E x){
        thrust(a+=n);
        thrust(b+=n-1);
        for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
            if(l&1) laz[l]=h(laz[l],x),l++;
            if(r&1) --r,laz[r]=h(laz[r],x);
        }
        recalc(a);
        recalc(b);
    }
    void set_val(int a,T x){
        thrust(a+=n);
        dat[a]=x;laz[a]=ei;
        recalc(a);
    }
    T query(int a,int b){
        thrust(a+=n);
        thrust(b+=n-1);
        T vl=ti,vr=ti;
        for(int l=a,r=b+1;l<r;l>>=1,r>>=1) {
            if(l&1) vl=f(vl,reflect(l++));
            if(r&1) vr=f(reflect(--r),vr);
        }
        return f(vl,vr);
    }
};

signed main(){
    
    int n, q; cin >> n >> q;
    auto f = [](int a, int b){ return min(a, b); };
    auto g = [](int a, int b){ return a + b; };
    auto h = [](int a, int b){ return a + b; };
    LazySegmentTree<int, int, decltype(f), decltype(g), decltype(h)> sg(f, g, h, INT_MAX, 0);
    sg.build(vector<int>(n, 0));
    for(int i = 0; i < q; i++){
        int com; cin >> com;
        if(!com){
            int s, t, x; cin >> s >> t >> x;
            sg.update(s, t + 1, x);
        }else{
            int s, t; cin >> s >> t;
            cout << sg.query(s, t + 1) << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 7572
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
char s;
bool fl;
struct edge{int to,cost;};
V g[ohara];
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    rep(i,n){
        rep(j,n){
            cin>>s;
            if(s=='0')continue;
            g[i].p_b(j);
        }
    }
    int ans=0;
    rep(i,n){
        //開始地点固定
        int dat[n+10]={};
        queue<int> que;
        que.push(i);
        dat[i]=1;
        int ok=1;
        while(1){
            if(que.empty())break;
            int moto=que.front();
            que.pop();
            if(moto!=i&&dat[moto]!=0)continue;
            ll mi=LINF,ma=-LINF;
            int vi[300]={};
            rep(j,Size(g[moto])){
                ll to=g[moto][j];
                if(dat[to]==0){
                    que.push(to);
                    continue;
                }
                mi=min(mi,(ll)dat[to]);
                ma=max(ma,(ll)dat[to]);
                vi[dat[to]]=1;
            }
            if(ma-mi>=3||ma-mi==1){
                ok=0;
                break;
            }
            if(ma-mi==0){
                dat[moto]=ma+1;
            }
            else if(ma-mi==2){
                if(vi[(ma+mi)/2]==1){
                    ok=0;
                    break;
                }
                dat[moto]=(ma+mi)/2;
            }
        }
        int cnt=0;
        rep(j,n){
            cnt=max(cnt,dat[j]);
            if(dat[j]==0){ok=0;break;}
        }
        if(!ok)continue;
        ans=max(ans,cnt);
    }
    if(ans==0)Cout(-1);
    else Cout(ans);
    return 0;
}


Measured memory_bytes: 24064
import math
N=int(input())
ans=[0]*N

for i in range(1,math.floor(math.sqrt(N))+1):
  for j in range(i,math.floor(math.sqrt(N))+1):
    for k in range(j,math.floor(math.sqrt(N))+1):
      if i == j == k and i*i+j*j+k*k+i*j+j*k+k*i-1 <= N-1:
        ans[i*i+j*j+k*k+i*j+j*k+k*i-1] += 1
      elif (i == j or j == k) and i*i+j*j+k*k+i*j+j*k+k*i-1 <= N-1:
        ans[i*i+j*j+k*k+i*j+j*k+k*i-1] += 3
      elif i*i+j*j+k*k+i*j+j*k+k*i-1 <= N-1:
        ans[i*i+j*j+k*k+i*j+j*k+k*i-1] += 6

for n in range(N):
  print(ans[n])

Measured memory_bytes: 9408
def man(xns, yns)
  (xns[0] - yns[0]).abs + (xns[1] - yns[1]).abs
end

n, m = gets.split.map(&:to_i)
xs = []
n.times { xs.push(gets.split.map(&:to_i)) }
ys = []
m.times { ys.push(gets.split.map(&:to_i)) }
n.times do |i|
  mi = 0
  mv = 1 << 31
  m.times do |j|
    mh = man(xs[i], ys[j])
    if mh < mv
      mi = j + 1
      mv = mh
    end
  end
  p mi
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <iomanip>
#include <math.h>
#include <algorithm>
#define hmm "\n"
#define test() int t; cin>>t; while(t--)
#define ll long long int
#define ull unsigned long long
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
void solve()
{
    ll a=1,b=1,n; cin>>n;
    vector<ll> p(n),q(n);
    for(int i=0; i<n; i++){
        cin>>p[i];
    }
    for(int i=0; i<n; i++){
        cin>>q[i];
    }

    while (prev_permutation(p.begin(),p.end())){
        a++;
    }
    while (prev_permutation(q.begin(),q.end())){
        b++;
    }
    cout<<abs(a-b)<<hmm;
}
int main()
{
    fastIO
    //test()
    solve();
}



Measured memory_bytes: 3668
import java.io.*;
    
class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int i, j;
        int count = 0;
    
        for(i=0; i<n; i++){
            int a = Integer.parseInt(br.readLine());
            for(j=2; (j*j)<=a; j++){
                if(a%j == 0) break;
            }
            if((j*j)>a) count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 28356
using System;

namespace Touitsu
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Char[] a = Console.ReadLine().ToCharArray();
            Char[] b = Console.ReadLine().ToCharArray();
            Char[] c = Console.ReadLine().ToCharArray();

            int result = 0;
            for(int i = 0 ; i < n; i++){
                int count=0;
                if(a[i]== b[i]) count++;
                if(b[i]== c[i]) count++;
                if(a[i]== c[i]) count++;
                if (count==1){
                    result++;
                }
                else if(count==0)
                {
                    result+=2;
                }
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
using namespace std;
int main(){
    int n,t,a,b,sum;
    while(cin >> t,t){
        sum = 0;cin >>n;
        for(int i =0;i <n;i++){
            cin >> a >>b;
            sum += b - a;
        }
        if(sum >= t) cout << "OK" <<endl;
        else cout << t - sum << endl;
    }
}


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

ll gcd(ll a, ll b) {
  if (!b) return a;
  else return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a / g * b;
}

int main() {
  int N;
  cin >> N;
  ll ans = 1LL;
  for (int i=0; i<N; i++) {
    ll T;
    cin >> T;
    ans = lcm(ans, T);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
loop do
  n, k = gets.split.map(&:to_i)
  break if n == 0
  points =
    k.times.map do
      c, a, b = gets.split
      a = a.to_i; b = b.to_i
      case c
      when 'xy'
        [a, b, 0]
      when 'yz'
        [0, a, b]
      when 'xz'
        [a, 0, b]
      end
    end

  cross_points = {}
  points.combination(2).each do |a, b|
    c = a.zip(b)
    if c.all?{ |p, q| !(p == 0 && q == 0) } && c.any?{ |p, q| p == q }
      p = c.map{ |p, q| [p, q].max }
      cross_points[p] ||= 0
      cross_points[p] += 1
    end
  end
  cross_points.each{ |k, v| cross_points[k] -= 1 if v == 3 }
  plus = cross_points.empty? ? 0 : cross_points.values.reduce(:+)
  puts n * n * n - k * n + plus
end

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

using namespace std;

int main() {
    int n;
    cin >> n;

    long long t = 1, a = 1;
    for (int i = 0; i < n; ++i) {
        long long T, A;
        cin >> T;
        cin >> A;
        long long k = max((t + T - 1) / T, (a + A - 1) / A);
        t = k * T;
        a = k * A;
    }
    
    cout << t + a << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

immutable int INF = 1 << 29;

bool solve() {
    auto N = readln.chomp.to!int;
    auto P = readln.split.map!(to!int).array;
    auto X = readln.split.map!(to!int).array;
    auto edges = new int[][](N);
    foreach (i; 0..N-1) {
        edges[i+1] ~= P[i]-1;
        edges[P[i]-1] ~= i+1;
    }

    int dfs(int n, int p) {
        auto dp = new int[][](2, X[n]+1);
        int cur = 0, tar = 1;
        dp[cur].fill(INF);
        dp[cur][0] = 0;

        foreach (m; edges[n]) {
            if (m == p) continue;
            dp[tar].fill(INF);
            int w = dfs(m, n);
            int b = X[m];
            foreach (i; 0..X[n]+1) {
                if (dp[cur][i] != INF) {
                    if (i + w <= X[n]) {
                        dp[tar][i+w] = min(dp[tar][i+w], dp[cur][i]+b);
                    }
                    if (i + b <= X[n]) {
                        dp[tar][i+b] = min(dp[tar][i+b], dp[cur][i]+w);
                    }
                }
            }

            cur ^= 1, tar ^= 1;
        }

        return dp[cur].reduce!min;
    }

    return dfs(0, -1) != INF;
}

void main() {
    writeln( solve ? "POSSIBLE" : "IMPOSSIBLE" );
}


Measured memory_bytes: 18428
#include <stdio.h>

int A[50];

int fib(int i){
  if(i==0 || i==1)return A[i]=1;
  if(A[i] != -1)return A[i];
  return A[i] = fib(i-1)+fib(i-2);
}

int main(){
  int i,n;

  for(i=0;i<50;i++){
    A[i]=-1;
  }

  scanf("%d",&n);
  printf("%d\n",fib(n));

  return 0;
}


Measured memory_bytes: 2132
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;

vector<long long> bucket(200005,0);

int main(){
    int n;
    cin>>n;
    bucket.resize(n);
    vector<long long> a(n);
    for(int i=0;i<n;++i){
        int temp; cin>>temp;
        --temp;
        a[i]=temp;
        ++bucket[temp];
    }

    long long sum=0;
    for(int i=0;i<n;++i) sum+=bucket[i]*(bucket[i]-1)/2;
    for(int i=0;i<n;++i){
        long long temp=bucket[a[i]];
        long long before=temp*(temp-1)/2;
        long long after=(temp-1)*(temp-2)/2;
        long long ans=sum-before+after;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 6388
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextLong();
		}

		long sum1 = 0;
		long sum2 = 0;
		long ans1 = 0;
		long ans2 = 0;


		for (int i = 0; i < n; i++) {//偶数添字が正
			sum1 += a[i];
			if (i%2 == 0) {
				if (sum1 > 0) continue;
				else {
					ans1 += (1 + Math.abs(sum1));
					sum1 = 1;
				}
			}
			else if (i%2 == 1) {
				if (sum1 < 0) continue;
				else {
					ans1 += (sum1 + 1);
					sum1 = -1;
				}
			}
		}

		for (int i = 0; i < n; i++) {//奇数添字が正
			sum2 += a[i];
			if (i%2 == 1) {
				if (sum2 > 0) continue;
				else {
					ans2 += (1 + Math.abs(sum2));
					sum2 = 1;
				}
			}
			else if (i%2 == 0) {
				if (sum2 < 0) continue;
				else {
					ans2 += (sum2 + 1);
					sum2 = -1;
				}
			}
		}

		if (sum1 == 0) {
			ans1++;
		}
		if (sum2 == 0) {
			ans2++;
		}
		System.out.println(Math.min(ans1, ans2));
	}
}


Measured memory_bytes: 58672
/*
ID:xmydada1
LANG:C++
TASK:
*/
#include<bits/stdc++.h>
#define reg register

using namespace std;

int m,n,ans=0,sum=0,p;

inline int read() {
reg int s = 0, t = 0; reg char ch = getchar();
while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
return t ? -s : s;
}

inline void print(reg long long x) {
if(x < 0) putchar('-'), x = -x;
if(x > 9) print(x / 10);
putchar(x % 10 + 48);
}
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read();m=read();
	for(int i=1;i<=n;i++)
	{
		p=read();
		ans+=p;
		if(ans<=m)sum++;
	}
	cout<<sum+1;
	

return 0;
}



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

if 1<=X<100 or 106<=X<200 or 211<=X<300 or 316<=X<400 or 421<=X<500 or 526<=X<600 or 631<=X<700 or 736<=X<800 or 841<=X<900 or 946<=X<1000 or 1051<=X<1100 or 1156<=X<1200 or 1261<=X<1300 or 1366<=X<1400 or 1471<=X<1500 or 1576<=X<1600 or 1681<=X<1700 or 1786<=X<1800 or 1891<=X<1900 or 1996<=X<2000:
    print(0)
else:
    print(1)


Measured memory_bytes: 9128
n = int(input())
a = [0] + list(map(int, input().split())) + [0]

diff = [abs(i-j) for i, j in zip(a, a[1:])]
sum = sum(diff)

for i in range(n):
    print(sum - diff[i] - diff[i+1] +abs(a[i+2] - a[i]))

Measured memory_bytes: 14048
#include <iostream>
using namespace std;
int main(void){
    int m,f,r;
    while(1){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r==-1)break;
        if(m == -1 || f == -1){
            cout << "F";
        }else if( m+f >= 80){
            cout << "A";
        }else if(m+f >= 65 && m+f < 80){
            cout << "B";
        }else if((m+f >= 50 && m+f < 65) || r >= 50){
            cout << "C";
        }else if(m+f >= 30 && m+f < 50){
            cout << "D";
        }else if(r>=50){
            cout << "C";
        }else if(m+f<30){
            cout << "F";
        }
        
        cout << endl;
        
    }
}



Measured memory_bytes: 3104
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<bitset>
typedef long long ll;
double pi=3.1415926535897931159979635;

using namespace std;
int main()
{
int n,k; cin>>n>>k;
int ar[n];
for(int i=0; i<n; i++) cin>>ar[i];
sort(ar,ar+n);
ll sum=0;
for(int i=0; i<k; i++)
sum+=ar[i];

cout<<sum<<"\n";



return 0;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
const int N=2e3+7;
int dp[N][N];
int a[N],b[N];
const ll mod=1e9+7;
int n,m;
ll solve(int i,int j){
	if(dp[i][j]!=-1) {
		return dp[i][j];
	}
	if(i==n+1||j==m+1) {
		return 0;
	}
	ll ans=0;
	if(a[i]==b[j]) {
		ans= 1+solve(i,j+1)+solve(i+1,j);
	}
	else {
		ans=solve(i,j+1)+solve(i+1,j)-solve(i+1,j+1);
	}
	ans+=mod;
	ans%=mod;
	return dp[i][j]=ans;
}
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	cin>>n>>m;
	memset(dp,-1,sizeof dp);
	for(int i=1; i<=n; i++) cin>>a[i];
	for(int i=1; i<=m; i++) cin>>b[i];

	//ans%=mod;
	cout<<solve(1,1)+1<<endl;


	return 0;
}


Measured memory_bytes: 16256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

int main() {
	bool p[1000001];
	int n, x;

	p[0] = false;
	p[1] = false;
	for(int i = 2; i <= 1000000; i++) {
		p[i] = true;
	}

	for(int i = 2; i * i <= 1000000; i++) {
		for(int j = 2; j * i <= 1000000; j++) {
			p[i * j] = false;
		}
	}

	while( true ) {
		cin >> n >> x;

		if(n == 0 && x == 0) {
			break;
		}

		vector< bool > dp(x + 1, false);
		int money;
		dp[0] = true;

		for(int i = 0; i < n; i++) {
			cin >> money;
			for(int j = 0; j <= x - money; j++) {
				if( dp[j] ) {
					dp[j + money] = true;
				}
			}
		}


		int ans = 0;
		for(int i = x; i >= 0; --i) {
			if(p[i] && dp[i]) {
				cout << i << endl;
				break;
			} else if(i == 0) {
				cout << "NA" << endl;
			}
		}
	}
}

Measured memory_bytes: 2292
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int Q; cin >> Q;
    vl A(Q), B(Q);
    REP(i, Q) cin >> A[i] >> B[i];

    REP(i,Q) {
        if(A[i] == B[i]) {
            cout << (2 * A[i] - 2) << endl;
            continue;
        }

        ll l = 1, r = A[i] + B[i];
        while(r - l > 1) {
            ll m = (l + r) / 2;
            ll pd = (m + 1) / 2 * (m + 1 - (m + 1) / 2);

            if (pd < A[i]*B[i]) l = m;
            else r = m;
        }

        ll ans = l - 1;
        cout << ans << endl;
    }

    return 0;
}

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

public class Main {
	public static void main(String[] a) {
		int[] takasa = new int[10];
		Scanner scan = new Scanner(System.in);
		for (int i = 0; i < 10; i++) {

			takasa[i] = Integer.valueOf(scan.next());
		}
		Arrays.sort(takasa);
		for (int i = 9; i > 6; i--)
			System.out.println(takasa[i]);
	}

}

Measured memory_bytes: 17128
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
#include <math.h>
#include <string> 
#include <bits/stdc++.h>
using namespace std;

int main(){
    int A,B;
    cin >> A >> B;
    int P[20];
    int minA;
    int maxA;
    int X=0;
    if(A*100%8 ==0){
        minA = A*100/8;
    }else{
        minA = A*100/8+1;
    }
    if((A+1)*100%8==0){
        maxA = (A+1)*100/8-1;
    }else{
        maxA = (A+1)*100/8;
    }
    int k=0;
    for(int i=minA;i<=maxA;i++){
        P[k]=i;
        k=k+1;
    }
    for(int i=0;i<=k;i++){
        if(P[i]>=10*B && P[i]<10*(B+1)){
            X=P[i];
            break;
        }
    }
    if(X==0){
        cout << "-1" << endl;
    }else{
        cout << X << endl;
    }


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N,M; cin >> N >> M;
    vector<string> A(N);
    vector<string> B(M);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int i=0;i<M;i++){
        cin >> B[i];
    }
    bool f=false;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i+M-1>=N || i+M-1>=N) continue;
            bool mm=true;
            for(int y=0;y<M;y++){
                for(int x=0;x<M;x++){
                    if(A[i+y][j+x]!=B[y][x]) mm=false;
                }
            }
            if(mm) f=true;
        }
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3632