akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
using namespace std;
int main(){
    int N,l[100005],r[100005],ans=0;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> l[i] >> r[i];
        ans = ans + (r[i]-l[i]+1); 
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include  <stdio.h>

int main(Void)
{
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/b;

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

	return 0;
}

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

int N,Q;
string S;
vector<set<int>> abc(26);

void add(int i, char c){//type1
	if(S[i] == c) return;
	abc[S[i]-'a'].erase(i);
	S[i] = c;
	abc[S[i]-'a'].insert(i);
}

void out(int l, int r){//type2
	int ans = 0;
	rep(i,26){
		if(abc[i].size() <= 0) continue;
		auto it = abc[i].lower_bound(l);
		if(it != abc[i].end() && *it <= r) ans++;
	}
	printf("%d\n",ans);
}

int main(){
	cin>>N>>S>>Q;
	rep(i,N) abc[S[i]-'a'].insert(i);
	rep(i,Q){
		int t,a;
		cin>>t;
		if(t-1){//type2
			int b;
			cin>>a>>b;
			out(a-1, b-1);
		}
		else{//type1
			char b;
			cin>>a>>b;
			add(a-1, b);
		}
	}
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

string S;

signed main()
{
  cin >> S;

  int A = (S[0]-'0') * 10 + (S[1]-'0');
  int B = (S[2]-'0') * 10 + (S[3]-'0');

  if(A == 0) {
    if(0 < B && B <= 12) {
      cout << "YYMM" << endl;
    } else  {
      cout << "NA" << endl;
    }
  } else if(B == 0) {
    if(0 < A && A <= 12) {
      cout << "MMYY" << endl;
    } else  {
      cout << "NA" << endl;
    }
  } else if(0 < A && A <= 12 && 0 < B && B <= 12){
    cout << "AMBIGUOUS" << endl;
  } else if(12 < A && 12 < B){
    cout << "NA" << endl;
  } else {
    if(0 < A && A <= 12) {
      cout << "MMYY" << endl;
    } else if(0 < B && B <= 12){
      cout << "YYMM" << endl;
    } else {
      cout << "NA" << endl;
    }
  }

  return 0;
}

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

int main() {
  int n,m,count,ma;
  cin>>n;
  vector<string> s(n);
  for(int i=0;i<n;i++)cin>>s.at(i);
  cin>>m;
  vector<string> t(m);
  for(int i=0;i<m;i++)cin>>t.at(i);
  count=0;
  ma=0;
  
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      if(s.at(i)==s.at(j))count++;
    }
    for(int j=0;j<m;j++){
      if(s.at(i)==t.at(j))count--;
    }
    ma=max(count,ma);
    count=0;
  }
  cout<<ma<<endl;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, char, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

static const ll INF = 1e15;

typedef ll Weight;
struct Edge {
	int from, to;
	Weight weight;
	Edge(int src, int dst, Weight weight) :
		from(src), to(dst), weight(weight) { }
};
bool operator < (const Edge& e, const Edge& f) {
	return e.weight != f.weight ? e.weight > f.weight :
	e.from != f.from ? e.from < f.from : e.to < f.to;
}

struct UndirectionalCompare {
	bool operator() (const Edge& e, const Edge& f) const {
		if (min(e.from, e.to) != min(f.from, f.to))
			return min(e.from, e.to) < min(f.from, f.to);
		return max(e.from, e.to) < max(f.from, f.to);
	}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;
typedef set<Edge, UndirectionalCompare> Edgeset;

struct articulationPoint_solver {

	void visit(const Graph& g, int v, int u,
		vector<int>& art, vector<Edgeset>& bcomp,
		stack<Edge>& S, vector<int>& num, vector<int>& low, int& time) {
		low[v] = num[v] = ++time;
		for(const auto& e : g[v]) {
			int w = e.to;
			if (num[w] < num[v]) S.push(e);            
			if (num[w] == 0) {
				visit(g, w, v, art, bcomp, S, num, low, time);
				low[v] = min(low[v], low[w]);
				if ((num[v] == 1 && num[w] != 2) ||        
					(num[v] != 1 && low[w] >= num[v])) art.push_back(v);
				if (low[w] >= num[v]) {                    
					bcomp.push_back(Edgeset());
					while (1) {
						Edge f = S.top(); S.pop();
						bcomp.back().insert(f);
						if (f.from == v && f.to == w) break;
					}
				}
			}
			else low[v] = min(low[v], num[w]);
		}
	}

	void articulationPoint(const Graph& g,
		vector<int>& art, vector<Edgeset>& bcomp) {
		const int n = g.size();
		vector<int> low(n), num(n);
		stack<Edge> S;
		rep(u, n) if (num[u] == 0) {
			int time = 0;
			visit(g, u, -1, art, bcomp, S, num, low, time);
		}
	}
};

int main(void)
{
	int v, e;
	cin >> v >> e;

	Graph g(v);
	rep(i, e) {
		int s, t;
		cin >> s >> t;
		g[s].push_back({s,t,0});
		g[t].push_back({t,s,0});
	}
	articulationPoint_solver solver;
	vector<int> art;
	vector<Edgeset> bcomp;
	solver.articulationPoint(g, art, bcomp);
	set<int> r;
	for (auto i : art) {
		r.insert(i);
	}
	for (auto i : r) {
		cout << i << endl;
	}
	return 0;
}



Measured memory_bytes: 10340
from heapq import heapify,heappush,heappop
import math

n,K = map(int,input().split())
v = list(map(int,input().split()))

ans = 0
sum_d = 0
d = []
heapify(d)
# i = 操作回数
# j = 取る回数 (i-j = 捨てる回数)
# k = 左から取る回数 (j-k = 右から取る回数)
for i in range(1,K+1):
	for j in range(math.ceil(i/2),min(i+1,n+1)):
		for k in range(j+1):
			#print(i,j,k,j-k,i-j,ans)
			# 左から取る
			for l in range(k):
				heappush(d,v[l])
				sum_d += v[l]
			# 右から取る
			for l in range(j-k):
				heappush(d,v[-l-1])
				sum_d += v[-l-1]
			for l in range(i-j):
				sum_d -= heappop(d)
			ans = max(sum_d,ans)
			sum_d = 0
			d = []
			heapify(d)
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
vector<long> data(100000);
int N;
int root(int x){
  if(data.at(x) == x)return x;
  return data.at(x) = root(data.at(x));
}
void unite(int x, int y){
  int rx = root(x);
  int ry = root(y);
  if(rx == ry)return ;
  data.at(rx) = ry;
}
int main () {
  long M;
  cin >> N >> M;
  for(int i = 0; i < N; i++)data.at(i) = i;
  long X, Y, Z;
  for(int i = 0; i < M; i++){
    cin >> X >> Y >> Z;
    X--;
    Y--;
    unite(X, Y);
  }
  set<long> ans;
  for(int i = 0; i < N; i++){
    ans.insert(root(i));
  }
  cout << ans.size() << endl;
  return 0;
}

Measured memory_bytes: 5760
from collections import Counter
n = int(input())
a = Counter((list(map(int, input().split()))))

b, c, d = 0, 0, 0
for i, v in a.items():
    if v >= 2:
        if b < i:
            b, c = i, b
        elif c < i:
            c = i

    if v >= 4:
        d = max(d, i)
print(max(b*c, d*d))

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

using namespace std;

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < v.size();i++)

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long int;
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int main(){
	int n,m,a[1000],b,p[1000]={};
	cin>>n>>m;
	REP(i,n){
		cin>>a[i];
	}
	REP(i,m){
		cin>>b;
		REP(j,n){
			if(a[j]<=b){
				p[j]++;
				break;
			}
		}
	}
	int mx=0,mxi;
	REP(i,n){
		//cout<<" "<<p[i]<<"\n";
		if(p[i]>mx){
			mx=p[i];
			mxi=i;
		}
	}
	cout<<mxi+1<<"\n";
	return 0;
}

Measured memory_bytes: 3092
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
using namespace std;
int n,cnt=0;
int a[52],b[52];
int main(){
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a[i];b[i]=a[i];
	}
	sort (a,a+n);
	for (int i=0;i<n;i++)
		if (a[i]!=b[i]) cnt++;
	if (cnt>2) cout<<"NO";
	else cout<<"YES";
}

Measured memory_bytes: 256
n, x = map(int, input().split())
a = input().split()
a = [int(m) for m in a]
ans = 0
for i in range(1, n):
    t = a[i] + a[i - 1]
    if t <= x:
        pass
    else:
        ans += a[i] - (x - a[i - 1])
        if i == 1:
            if x - a[i - 1] < 0:
                a[i] = 0
                a[i - 1] = x
            else:
                a[i] = x - a[i - 1]
        else:
            a[i] = x - a[i - 1]
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define SIZE 300001
using namespace std;

int n , a[SIZE] , b[SIZE] , c[SIZE] , dp[SIZE][3];

int main(){
    cin >> n;
    for (int i = 1;i <= n;i++) {
		cin >> a[i] >> b[i] >> c[i];
	} 
    for (int i = 1;i <= n;i++) {
        dp[i][0] = max(dp[i - 1][1] , dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0] , dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][1] , dp[i - 1][0]) + c[i];
    }
    cout << max(dp[n][0] , max(dp[n][1] , dp[n][2])) << endl;
    return 0;
}


Measured memory_bytes: 5632
// #define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(ll i = (n); i <(m); i++)
#define rrep(i,n,m) for(ll i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

const ll MOD = 1000000007;

vector<ll> primes;
void init_primes(ll N)
{
    vector<bool> is_prime(N+1, true);
    is_prime[0] = is_prime[1] = false;
    rep(i, 2, N+1)
    if (is_prime[i])
    {
        primes.push_back(i);
        for (ll j = (ll)i*i; j<=N; j += i)
            is_prime[j] = false;
    }
}

ll power_mod(ll n, ll m)
{
    ll res = 1;
    ll base = n;
    while (m > 0)
    {
        if (m&1) res = (res * base) % MOD;
        base = (base * base) % MOD;
        m >>= 1;
    }
    return res;
}

ll inv_mod(ll n)
{
    return power_mod(n, MOD-2);
}

vector<ll> factorials;
void init_factorial(ll N)
{
    factorials.assign(N+1, 1);
    rep(i, 2, N+1)
    {
        factorials[i] = factorials[i-1] *i;
        factorials[i] %= MOD;
    }
}

ll comb(ll n, ll m)
{
    m = min(m, n-m);
    ll res = factorials[n];
    debug(n, factorials[n]);
    res *= inv_mod(factorials[n-m]);
    res %= MOD;
    res *= inv_mod(factorials[m]);
    res %= MOD;
    debug(n, m, res);
    return res;
}

int main()
{
    // init primes
    init_primes(200010);
    init_factorial(200010);
    debug(primes);

    // read data
    ll N, M;
    cin >> N >> M;

    ll ans = 1;
    for (auto prime: primes)
    {
        // decompose
        ll cnt = 0;
        while (M%prime==0)
        {
            ++cnt;
            M /= prime;
        }
        if (cnt == 0) continue;

        // cnt 
        debug(M, prime, cnt, ans);
        ans *= comb(cnt+N-1, N-1);
        ans %= MOD;
    }
    if (M>1)
    {
        ans *= N;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2152
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;

public class Main {
    private static final ReadableByteChannel channel = Channels.newChannel(System.in);

    public static void main(String[] args) throws IOException {
	buf.clear();
	channel.read(buf);
	buf.flip();
	int n;
	while ((n = nextInt()) != 0) {
	    int[][] map = new int[21][21];
	    for (int i = 0; i < n; i++) {
		map[nextInt()][nextInt()] = 1;

	    }
	    int m = nextInt();
	    int x = 10;
	    int y = 10;
	    int count = 0;
	    for (int i = 0; i < m; i++) {
		char c = getChar();
		int l = nextInt();
		if (count != n) {
		    int dx = 0;
		    int dy = 0;
		    if (c == 'N') {
			dy = 1;
		    } else if (c == 'E') {
			dx = 1;
		    } else if (c == 'S') {
			dy = -1;
		    } else if (c == 'W') {
			dx = -1;
		    }
		    for (int j = 0; j < l; j++) {
			count += map[x][y];
			map[x][y] = 0;
			x += dx;
			y += dy;
		    }
		    count += map[x][y];
		    map[x][y] = 0;
		}
	    }
	    if (count == n) {
		System.out.println("Yes");
	    } else {
		System.out.println("No");
	    }
	}
    }

    private static char getChar() throws IOException {
	int c = ' ';
	while (c < 'E' || 'W' < c) {
	    c = buf.get();
	}
	return (char) c;
    }

    static ByteBuffer buf = ByteBuffer.allocateDirect(10000000);

    private static int nextInt() throws IOException {
	char c = (char) buf.get();
	while ((c < '0' || '9' < c) && c != '-') {
	    c = (char) buf.get();
	}
	if (c == '-') {
	    return -nextInt();
	}
	int result = 0;
	while ('0' <= c && c <= '9') {
	    result = result * 10 + (c - '0');
	    c = (char) buf.get();
	}
	return result;
    }
}

Measured memory_bytes: 35204
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
total=0
for i in range(N):
    total+=B[i]

for j in range(N-1):
    if (A[j])+1==A[j+1]:
        total+=C[A[j]-1]
print(total) 

Measured memory_bytes: 3188
//
// Created by 10940 on 2020/7/11.
//

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

int main() {
    int N;
    cin >> N;
    int a[200];
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
        if (i % 2 != 0 && a[i] %2 != 0) {
            ans++;
        }
    }

    cout << ans;


    return 0;
}

Measured memory_bytes: 3592
"""
どんなに操作をおこなっても、全てのi,j(i<j)に関して、Ai,Ajの絶対値の差がsum(A)より大きくなることはない。
したがって、答えがsum(A)より大きくなることはない。
さらに言うなら、数値の状態がワイルドカードである0がベストなので負の値にする必要もない。

また、答えはsum(A)の約数になる。
答えをXとおくと、全ての数はXで割り切れる＝Xの倍数である。
Ai/X = Biとおくと、XBi = Ai　と表すことができる。。
X*sum(B) = sum(A)なので、答えXはsum(A)の約数であることがわかる。

解法：
基本方針としては、sum(A)の約数を列挙して、K回以内の操作で大きい順に実現可能かどうかを調べる。
実現可能かどうかは、各Aiを数が引かれる方と足される方に分けることで考えることができる。
"""
from itertools import accumulate
N,K = map(int,input().split())
A = list(map(int,input().split()))

sumA = sum(A)

#sumAの約数を列挙する。
yakusu = []
d = 1
while d*d < sumA:
    if sumA%d == 0:
        yakusu.append(d)
        yakusu.append(sumA//d)
    d += 1
if d*d == sumA:
    yakusu.append(d)
yakusu.sort(reverse=True)

for d in yakusu:
    X = [A[i]%d for i in range(N)]
    X.sort()
    Y = [d-x for x in X]
    Y.sort()
    X = list(accumulate(X))
    Y = list(accumulate(Y))
    Y = Y[::-1]
    for i in range(N-1):
        if X[i] == Y[i+1] and X[i]<=K:
            print(d)
            exit()
    if X[N-1] == 0:
        print(d)
        exit()

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

using namespace std;
typedef long long ll;
int main() {
  ll N, M;
  cin >> N >> M;
  if (N == 1 && M == 1) {
    cout << 1 << endl;
  } else if (N == 1 || M == 1) {
    cout << max(N,M) - 2 << endl;
  } else {
    cout << (N - 2) * (M - 2) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;

/// 数列の読み込み
auto readNums(T = int)() {
	return readln().chomp.split.map!(to!T).array;
}

/// 数の読み込み
auto readNum(T = int)() {
	return readNums!T.front;
}

/// 指定行数読み込み
auto readRows(size_t rows) {
	return generate(() => readln().chomp).take(rows).array;
}

/// 範囲の計算
auto range(T)(T a, T b, T c, T d) {
    auto start = max(a, c);
    auto end = max(b, d);
    return (start < end) ? tuple(start, end) : tuple(cast(T) 0, cast(T) 0);
}

auto maxElement(R)(R r) {
    return r.reduce!((a, b) => max(a, b));
}

auto minElement(R)(R r) {
    return r.reduce!((a, b) => min(a, b));
}

auto minIndex(T)(T[] r) {
    return r.length - r.minPos.length;
}

void main() {
    const nk = readNums();
    immutable n = nk[0] - 1;
    immutable k = nk[1] - 1;
    const nums = readNums();
    
    writefln("%d", (n + (k - 1)) / k);
}


Measured memory_bytes: 4028
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main()
{
    int n,a=0,b=0,x,i;
    cin >> n;
    cin >> x;
    a=b=x;
    for(i=0;i<n-1;i++)
    {
        cin >> x;
        if(x<a)
            a=x;
        if(x>b)
            b=x;
    }
    cout << b-a <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n,sn=0,temp;
    scanf("%d",&n);
    temp=n;
    while(temp!=0){
        sn+=temp%10;
        temp/=10;
    }
    if(n%sn==0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


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

bool isACGT(char c) {
  if ( c == 'A' || c == 'C' || c == 'G' || c == 'T' ) { return true; }
  return false;
}

int main() {
  string s;
  cin >> s;

  int len = 0;
  int mx = 0;
  for ( int i = 0; i < s.length(); i++ ) {
    len = ( isACGT(s[i]) ) ? len+1 : 0;
    if ( mx < len ) { mx = len; }
  }

  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define all(v) v.begin(), v.end()
  #define mod 1000000007
  //direction arrays
  int dx[8]={0,0,-1,+1,+1,-1,+1,-1};
  int dy[8]={+1,-1,0,0,+1,-1,-1,+1};
  int modexp(int x, int y)
  {
      int res = 1;
      x = (x % mod + mod) % mod;
      while(y)
      {
          if(y & 1)
              res = (res*x) % mod;
          y >>= 1;
          x = (x*x) % mod;
      }
      return res%mod; 
  }
  
  int32_t main()
  { 
    /*#ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif*/
    
    IOS
    int x;
    cin>>x;
    //upper bound on X is 1e18
    //I wonder why modexp isnt working here
    
    vector<pair<int,int>> v;
    for(int i=-5000;i<=5000;i++)
    {
      
      int y=i*i*i*i*i;
      v.pb({y,i});
    }
    int a=-1,b=-1;
    sort(all(v));
    
    for(int i=0;i<v.size();i++)
    {
      for(int j=i+1;j<v.size();j++)
      {
        if(abs(v[j].f-v[i].f)==x)
        {
         
          a=v[i].s;
          b=v[j].s;
          break;
        }
      }
    }
    //cout<<a<<"        "<<b<<endl;
    if(a>b)
    {
      cout<<a<<" "<<b;
    }
    else
    {
      cout<<b<<" "<<a;
    }
    return 0;
  }
    

Measured memory_bytes: 3776
package main

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

func main() {
	N := getStdinInt()
	if N%1000 == 0 {
		fmt.Printf("%d\n", 0)
	} else {
		fmt.Printf("%d\n", 1000-N%1000)
	}
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2184
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define itc ll t;cin>>t;while(t--)
#define otc ll t=1;while(t--)
#define ll long long int
#define ld long double
#define pb push_back
#define gcd(a,b) __gcd(a,b)
#define fi first
#define se second
#define ull unsigned long long int
#define memset(arr) memset(arr, 0, sizeof(arr));
bool sortinrev(const pair<ll, ll> &a, const pair<ll, ll> &b)
{return (a.fi > b.fi);}//sort by first in descending order
bool sortbysec(const pair<ll, ll> &a, const pair<ll, ll> &b)
{ return (a.se < b.se); }//sort by second in ascending order
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
int main()
{
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	ll n, k;
	cin >> n >> k;
	ll ar[n + 1];
	for (ll i = 1; i <= n; i++)cin >> ar[i];

	ll dp[n + 1] ;
	for (ll i = 0; i <= n; i++)
		dp[i] = 1e10;


	dp[1] = 0;

	for (ll i = 2; i <= n; i++)
	{
		for (ll j = max(1LL, i - k); j < i; j++)
		{
			dp[i] = min(dp[i], abs(ar[i] - ar[j]) + dp[j]);
		}

	}
	cout << dp[n] << endl;





	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

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

		while (true) {
			int n = scan.nextInt();
			int pointT = 0, pointH = 0;

			for (int i = 0; i < n; i++) {
				String T = scan.next();
				String H = scan.next();
				if (T.compareTo(H) < 0)
					pointH += 3;
				else if (T.compareTo(H) == 0) {
					pointT++;
					pointH++;
				} else
					pointT += 3;
			}
			System.out.println(pointT + " " + pointH);
			break;
		}
		scan.close();
		System.exit(0);
	}

}

Measured memory_bytes: 30332
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

ll dp[105][80000];
ll sdp[105][80000];

int main(int argc, char* argv[])
{
    int n, k;
    scanf("%d%d", &n, &k);

    int m = sqrt((double)n);
    vector<int> a;
    int i,j;
    for(i=1; i<m; i++) {
        a.push_back(i);
    }
    a.push_back(m);
    if(n/m>m) a.push_back(n/m);
    for(i=m-1; i>=1; i--) {
        a.push_back(n/i);
    }
    int nn=(int)a.size();

    dp[0][0]=1;
    for(j=0; j<nn; j++) sdp[0][j]=1;
    for(i=1; i<=k; i++) {
        for(j=0; j<nn; j++) {
            dp[i][j]=sdp[i-1][nn-1-j];
            sdp[i][j]=((j==0? 0: sdp[i][j-1]) + dp[i][j] * (j==0? a[j]: (a[j]-a[j-1])))%MOD;
        }
    }
    printf("%lld\n", sdp[k][nn-1]);
    
    return 0;
}


Measured memory_bytes: 127228
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n,m;
long long tot,ans,k=1;
char s[200010];
map<int,int> sum;
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s);
	if(m!=2&&m!=5)
	{
		for(int i=n-1;i>=0;i--)
		{
			ans=(ans+1ll*(s[i]-'0')*k)%m;
			k=(k*10)%m;
			sum[ans]++;
		}
		tot=sum[0];
		for(int i=0;i<=m-1;i++)
		{
			tot+=(1ll*(sum[i]-1)*sum[i])/2;
		} 
	}else{
		for(int i=n-1;i>=0;i--)
		{
			if((s[i]-'0')%m==0)
			{
				tot+=i+1;
			}
		}
	}
	printf("%lld\n",tot);
	return 0;
} 

Measured memory_bytes: 896
import sys
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())

def main():
    mod = 10**9+7
    n = ii()
    a = li()
    bi = [0]*60
    for x in a:
        for i in range(60):
            if (x>>i)&1:
                bi[i]+= 1
    ans = 0
    for i in range(60):
        tmp = bi[i]*(n-bi[i])*(1<<i)
        tmp %= mod
        ans += tmp
        ans %= mod

    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 115556
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int inf =1000000007;
signed main(){
  int n;cin>>n;
  vector<int> p(n);
  rep(i,n)cin>>p[i];
  int min=inf;
  int res=0;
  rep(i,n){
    if(min>=p[i]){
      res++;
      min=p[i];
    }
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 1792
N, M = map(int, input().split())

accepted = [False] * N
temp_p = [0] * N
p = 0
for i in range(M):
    pi, Si = input().split()
    pi = int(pi) - 1
    if not accepted[pi]:
        if Si == 'AC':
            p += temp_p[pi]
            accepted[pi] = True
        else:
            temp_p[pi] += 1
print(accepted.count(True), p)


Measured memory_bytes: 4596
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<lint> vl;
typedef pair<lint,lint> pll;
#define mpr make_pair

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

    int l ,r, d;  cin>>l>>r>>d;
    l--;

    auto cnt = [](int l, int d)->int{
        return l/d;
    };

    cout<<cnt(r, d) - cnt(l, d);

}


Measured memory_bytes: 3608
//************************
//*  Date: 2018.9.22     *
//*  Problem:            *
//*  Author: xuziyuan    * 
//************************
 
#include <bits/stdc++.h>
 
#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))
 
using namespace std;
 
const LL MOD=1e9+7;
 
int n,a[100010];
pii ev[100010],od[100010];

bool sot(pii a,pii b)
{
	return a.fi>b.fi;
}
 
int main()
{
	cin>>n;
	repn(i,100005) od[i].se=i,ev[i].se=i;
	repn(i,n)
	{
		cin>>a[i];
		if(i%2==1) od[a[i]].fi++;
		else ev[a[i]].fi++;
	}
	sort(ev,ev+100005,sot);
	sort(od,od+100005,sot);
	//cout<<ev[0].se<<' '<<od[0].se<<endl;
	if(ev[0].se==od[0].se)
	{
		cout<<min(n-od[0].fi-ev[1].fi,n-ev[0].fi-od[1].fi)<<endl;
		rt0;
	}
	cout<<n-ev[0].fi-od[0].fi<<endl;
	rt0;
}

Measured memory_bytes: 2176
octD = {"0":0, "1":1, "2":2, "3":3, "4":5, "5":7, "6":8, "7":9}

while True :
    n = int(input())
    
    if n == 0 :
        break
    
    else :
        N = list(format(n, "o"))
        # nを8進数に変換
        
        for i in range(len(N)) :
            print(octD[N[i]], end = "")
        print()


Measured memory_bytes: 5628
#include <cstdio>
#include <cstring>

int main()
{
  char s[101];
  scanf("%s", s);
  
  const char c[2] = {'L', 'R'};
  
  for (int i = 0; i < strlen(s); ++i)
  {
    if (s[i] == c[i & 1])
    {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.util.Scanner;

public class Main{

	public static void main(String args[]) throws IOException {
		Scanner scan = new Scanner(System.in);
		int x1 = scan.nextInt();
		int x2 = scan.nextInt();

		System.out.println(Math.abs(x1 - x2));

		scan.close();
	}

}


Measured memory_bytes: 26200
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  char c;
  cin>>c;
  if('A'<=c&&c<='Z'){
    cout<<"A"<<endl;
  }else{
    cout<<"a"<<endl;
  }

  return 0;
}




Measured memory_bytes: 3644
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<limits.h>
#include<float.h>

int main(){
	char s[11];
	int min = INT_MAX;
	int tmp;
	scanf("%s\n", &s);
	for(int i=0; s[i+2]; i++){
		tmp = abs((s[i]-'0') * 100 + (s[i+1]-'0') * 10 + (s[i+2]-'0') - 753);
		if(tmp < min) min = tmp;
	}
	printf("%d\n", min);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll n; cin>>n;
	vl v(n);
	rep(i,0,n) cin>>v[i];
	vl x=v;
	sort(all(x));
	int m1,m2;
	bool p=false;
	m1=x[n-1];
	for(int i=n-2;i>=0;--i){
		if(x[i]!=m1){
			m2=x[i];
			break;
		}
		else p=true;
	}
	rep(i,0,n){
		if(v[i]!=m1) cout<<m1<<endl;
		else if(p) cout<<m1<<endl;
		else cout<<m2<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 4736
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n,m;
    cin >> n >> m;
    vector<int>h(n);
    rep(i,n) cin >> h[i];
    vector<vector<int>>g(n);
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ans = 0;
    rep(i,n) {
        bool flag = true;
        for(int v:g[i]) {
            if(h[i] <= h[v]) flag = false;
        }
        if(flag) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8752
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

#define INF 10000000

typedef pair<int, int> P;

int main() {
	int n, m;
	long long int l;
	while (cin >> n >> m >> l) {
		if (n == 0 && m == 0 && l == 0) {
			break;
		}
		vector< vector<long long int> > dp(n, vector<long long int>(l+1, INF));
		vector< vector<P> > mp(n, vector<P>(n, P(-1, -1)));
		int a, b, d, e;
		for (int i = 0; i < m; i++) {
			cin >> a >> b >> d >> e;
			a--;
			b--;
			mp[a][b] = mp[b][a] = P(d, e);
		}
		bool h = true;
		for (int i = 0; i <= l; i++) {
			dp[0][i] = 0;
		}
		while (h) {
			h = false;
			vector< vector<long long int> > dp2;
			dp2 = dp;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if ((mp[i][j]).first != -1) {
						for (int k = l; k >= 0; k--) {
							if (dp2[j][k] > dp[i][k] + (mp[i][j]).second) {
								h = true;
								dp2[j][k] = dp[i][k] + (long long int)(mp[i][j]).second;
							}
							if (k - (mp[i][j]).first >= 0) {
								if (dp2[j][k - (mp[i][j]).first] > dp[i][k]) {
									h = true;
									dp2[j][k - (mp[i][j]).first] = dp[i][k];
								}
							}
						}
					}
				}
			}
			dp = dp2;
		}
		long long int ans = INF;
		for (int i = 0; i <= l; i++) {
			ans = min(ans, dp[n - 1][i]);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n;
    string s;
    cin >> n >> s;
    string t1 = s.substr(0, n / 2);
    string t2 = s.substr(n / 2);
    if(t1==t2) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int M, K;
  cin >> M >> K;

  if (M <= 1) {
    if (K) {
      cout << -1;
    }
    else {
      F0R(i, M + 1) {
        cout << i << ' ' << i << ' ';
      }
    }
  }
  else {
    if (!K) {
      F0R(i, 1 << M) {
        cout << i << ' ';
      }
      RF0(i, 1 << M) {
        cout << i << ' ';
      }
    }
    else if (K >= 1 << M) {
      cout << -1;
    }
    else {
      cout << "0 " << K << " 0 ";
      FOR(i, 1, 1 << M) {
        if (i == K) continue;
        cout << i << ' ';
      }
      cout << K << ' ';
      RFO(i, 1, 1 << M) {
        if (i == K) continue;
        cout << i << ' ';
      }
    }
  }
}
#endif


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

int N;
int A[16];
int x[16][16],y[16][16];

bool check(int bit){
	for(int i = 0; i < N; i++){
		if(bit & (1<<i)){
			for(int j = 0; j < A[i]; j++){
				int p = x[i][j] - 1;
				int q = y[i][j];
				if((bit & (1<<p)) && q == 0) return false;
				if(!(bit & (1<<p)) && q == 1) return false;
			}
		}
	}
	return true;
}

int count(int bit){
	int ans = 0;
	for(int i = 0; i < N; i++){
		if(bit & (1<<i)) ans++;
	}
	return ans;
}

int main(){
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> A[i];
		for(int j = 0; j < A[i]; j++){
			cin >> x[i][j] >> y[i][j];
		}
	}
	int ans = 0;
	for(int i = 0; i < (1<<N); i++){
		int c = count(i);
		if(c > ans && check(i)){
			ans = c;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
arr = gets.split.map(&:to_i)
arr.sort_by!{|x|x}
# p arr
dist = []
1.upto(M-1) do |i|
  dist << (arr[i] - arr[i-1]).abs
end
if dist.empty? || dist.size <= N - 1
  puts 0
  exit
end

dist.sort_by!{|x|-x}
# p dist
puts dist[(N-1)..-1].inject(:+)


Measured memory_bytes: 11720
import java.util.*;
import java.io.*;
class Main
{
	static boolean visited[];
	static long MOD=1000000007;
	public static void main(String args[]) throws java.lang.Exception
	{
		BufferedReader inp = new BufferedReader (new InputStreamReader(System.in));
			// String h[]=inp.readLine().split(" ");
			// String h[]=inp.readLine().split(" ");

			int n=Integer.parseInt(inp.readLine());
			// int k=Integer.parseInt(h[1]);
			int arr[][]=new int[n][n];
			for(int i=0;i<n;i++)
			{
				String h[]=inp.readLine().split(" ");
				for(int j=0;j<n;j++)
				{
					arr[i][j]=Integer.parseInt(h[j]);
				}
			}
			visited=new boolean[(int)Math.pow(2,n+1)-1];
			System.out.println(dp(new long[(int)Math.pow(2,n+1)-1],0,arr,0)%MOD);
					
		
	}
	static long get(long dp[][], int c[][], int l, int r)
	{
		if(l==r){return 0;}
		System.out.println(l+" "+r+" "+dp[l][r]);
		return dp[l][r]+get(dp,c,l,c[l][r])+get(dp,c,c[l][r]+1,r);
	}
	static long dp(long dp[], int i, int arr[][], int state)
	{
		if(i==arr.length){return 1;}
		if(visited[state]){return dp[state];}
		long ans=0;
		int k=1;
		for(int j=0;j<arr[i].length;j++)
		{
			if(arr[i][j]==1 && (state &k)==0) 
			{
				ans=(ans%MOD+dp(dp,i+1,arr,state+k)%MOD)%MOD;
			}
			k*=2;

		}
		visited[state]=true;
		dp[state]=ans;
		return ans;

	}
}
class Pair
{
	int a;
	long b;
	
	Pair(int e, long f)
	{
		a=e;
		b=f;
		
	}
}

Measured memory_bytes: 61012
function Main(input) {
  "use strict"
	const temp = input.split(" ");

	const a = parseInt(temp.shift());
	const b = parseInt(temp.shift());
	const c = parseInt(temp.shift());
  const rest = (c + b - a > 0) ? c + b - a: 0;
  console.log(rest)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string.h>
using namespace std;
int main()
{
	int n;
	int a[33] = { 0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	cin >> n;
	cout << a[n] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
int main(){
        int h,n;
        while(~getII(h,n)){
                int sum=0;
                while(n--){
                        VgetI(x);
                        sum+=x;
                }
                printf("%s\n",sum>=h?"Yes":"No");
        }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int dp[k+1]={0};
    for(int i=0;i<=k;i++){
        for(int j=0;j<n;j++){
            if(i>=a[j] && !dp[i-a[j]])
            dp[i]=1;
        }
    }
    cout<<(dp[k]?"First":"Second");
    return 0;
}


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

int main (){
    ll H, W, K;
    cin>>H>>W>>K;
    vector<vector<char>> A(H, vector<char>(W));
    vector<int> Yok(H);
    int X;
    for(int i=0; i<H; i++){
        X=0;
        for(int j=0; j<W; j++){
            cin>>A.at(i).at(j);
            if(A.at(i).at(j)=='#'){
                X++ ;
            }
        }
        Yok.at(i)=X;
    }
    vector<vector<int>> Ans(H, vector<int>(W));
    int Pass = 0;
    int Current = 1;
    bool Start = true;
    for(int i=0; i<H; i++){
        if(Yok.at(i)==0){
            Pass ++;
            continue;
        }
        else{
            Start = true;
            for(int j=0; j<W; j++){
                if(Start){
                    Ans.at(i).at(j)=Current;
                    if(A.at(i).at(j)=='#'){
                        Start = false;
                    }
                }
                else{
                    if(A.at(i).at(j)=='#'){
                        Current ++;
                    }
                    Ans.at(i).at(j)=Current;
                
                }

            }
            for(int j=1; j<Pass+1; j++){
                for(int k=0; k<W; k++){
                    Ans.at(i-j).at(k)=Ans.at(i).at(k);
                }
            }
          	Current ++;
          	Pass=0;
        }
    }
    if(Pass > 0){
        for(int j=1; j<Pass+1; j++){
                for(int k=0; k<W; k++){
                    Ans.at(H-j).at(k)=Ans.at(H-Pass-1).at(k);
                }
            }
    }
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(j>0){
                cout<<" ";
            }
            cout<<Ans.at(i).at(j);
        }
        cout<<endl;
    }
}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
 
int main(){
  ll n, m, sum=0;
  priority_queue<ll> q;
  cin >> n >> m;
  rep(i, n){
    ll tmp;
    cin >> tmp;
    q.push(tmp);
  }
  rep(i, m){
    ll max = q.top();
    q.pop();
    q.push(max/2);
  }
  rep(i, n){
    sum += q.top();
    q.pop();
  }
  cout << sum << endl;
}

Measured memory_bytes: 1400
a,b,c,d,e,f = map(int, input().split())
mx=0
swmx=a*100
smx=0
 
for i in range(0,31):
    for j in range(0,31):
        for k in range(0,1000):
            for l in range(0,1000):
                w=0
                s=0
                w+=100*a*i+100*b*j
                s+=c*k+d*l
                targ=w+s
                if targ>f:
                    break
                elif targ==0:
                    break
                elif s>e*w/100:
                    break
                elif  mx<s/(w+s):
                    mx=s/targ
                    swmx=targ
                    smx=s
print(swmx,smx)

Measured memory_bytes: 73732
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = new List<int>();
            for (int i = 0; i < 4; i++)
            {
                a.Add(int.Parse(Console.ReadLine()));
            }
            int ans = Math.Min(a[0], a[1]);
            ans += Math.Min(a[2], a[3]);
            Console.WriteLine(ans);
        }

        static int[] ReadInt()
        {
            return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        }
        static char[] ReadStringToCharArray()
        {
            return Console.ReadLine().ToArray();
        }
    }
}



Measured memory_bytes: 13140
import sys

def input(): return sys.stdin.readline()[:-1]

#mod = 10**9+7
#w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

#N = int(input())
N, S = map(int, input().split())
#L = [int(input()) for i in range(N)]
A = tuple(map(int, input().split()))
#S = [list(map(int, input().split())) for i in range(N)]
mod=998244353

ans=0
dp=[0]*(S+1)
for a in A:
    dp[0]+=1
    for i in range(S,a-1,-1):
        dp[i]+=dp[i-a]
        dp[i]%=mod
    ans+=dp[-1]
    ans%=mod
    #print(dp)

print(ans)


Measured memory_bytes: 68712
a,b,k = map(int,input().split())
for i in range(k):
    if not i % 2:
        if a % 2:
            a-= 1
        b += a//2
        a//=2
    else:
        if b % 2:
            b -= 1
        a += b//2
        b//=2
print(a,b)

Measured memory_bytes: 9080
#include<bits/stdc++.h>
using namespace std;
#define int long long

int c[10][10];

signed main(){

  int H,W; cin >> H >> W;
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      cin >> c[i][j];
    }
  }

  for(int k = 0; k < 10; k++){
    for(int i = 0; i < 10; i++){
      for(int j = 0; j < 10; j++){
        c[i][j] = min(c[i][j],c[i][k]+c[k][j]);
      }
    }
  }

  int ans = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      int a; cin >> a;
      if(a != -1) ans += c[a][1];
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
dat = list(map(int, input().split()))

cnt = 0

for i in range(1, n-1):
  sub = dat[i-1:i+2]
  # print(sub, max(sub), min(sub))
  if max(sub) != sub[1] and min(sub) != sub[1]:
    cnt += 1

print(cnt)

Measured memory_bytes: 38384
s = list(str(input()))
t = list(str(input()))

def judge(S,T):
    start = [-1 for i in range(26) ] 
    goal = [-1 for i in range(26)]
    for i in range(len(S)):
        a = ord(S[i]) - ord('a')
        b = ord(T[i]) - ord('a')
        if start[a] != -1 or goal[b] != -1:
            if start[a]!= b or goal[b] !=a:
                print("No")
                break
        else:
            start[a] = b
            goal[b] =a
        if i==len(S)-1:
            print("Yes")
            
judge(s,t)

Measured memory_bytes: 6704
import java.util.Scanner;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		String str=sc.nextLine();
		
		char[] c=str.toCharArray();
		for(int i=0;i<c.length;i++){
			if('a'<=c[i] &&c[i]<='z'){
				c[i]=(char)(c[i]-'a'+'A');
			}else if('A'<=c[i] &&c[i]<='Z'){
				c[i]=(char)(c[i]-'A'+'a');
			}
		}
		ln(String.copyValueOf(c));
	}
	public static void main(String[] args) {
		new Main().run();
	}

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

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

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000