akhauriyash/Code-Regression huggingface dataset:
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
double n,m,a,b,c,d,x,y,z;
string s,t;
//

signed main() {
  RAPID;
  IN3(x,a,b);
  x-=a;
  while(x>=b) x-=b;
  OUT(x);
}

Measured memory_bytes: 256
// #pragma GCC optimize(3,"Ofast","inline")
// #pragma GCC optimize(2)
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
#include <list>
#include <cstdlib>
#include <bitset>
#include <assert.h>
#include <time.h>
#include <iomanip>
// #define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
// char buf[(1 << 21) + 1], * p1 = buf, * p2 = buf;
// #define int long long
#define lowbit(x) (x & (-x))
#define lson root << 1, l, mid
#define rson root << 1 | 1, mid + 1, r
#define pb push_back
typedef unsigned long long ull;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
#define bug puts("BUG")
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-6;
template <class T>
inline void read(T &x)
{
    int sign = 1;char c = getchar();x = 0;
    while (c > '9' || c < '0'){if (c == '-')sign = -1;c = getchar();}
    while (c >= '0' && c <= '9'){x = x * 10 + c - '0';c = getchar();}
    x *= sign;
}
#ifdef LOCAL
    FILE* _INPUT=freopen("input.txt", "r", stdin);
    // FILE* _OUTPUT=freopen("output.txt", "w", stdout);
#endif
using namespace std;
const int maxn = 2e5 + 10;
ll a[maxn];
int main()
{
    map<ll, ll> cnt;
    int n;
    read(n);
    for (int i = 1; i <= n; ++i)
    {
        read(a[i]);
        cnt[a[i] + i]++;
    }
    ll res = 0;
    for (int i = n; i >= 1; --i)
    {
        --cnt[a[i] + i];
        res += cnt[i - a[i]];
    }
    printf("%lld\n", res);
}

Measured memory_bytes: 27880
#include <bits/stdc++.h>
#define ll long long int
#define maxy __LONG_LONG_MAX__
#define mod 1000000007
using namespace std;
int main() {
    ll n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	if(n<=3)
	cout<<abs(a[n-1]-a[0]);
	else 
	{
		ll dp[n];
		dp[1]=abs(a[1]-a[0]);
		dp[2]=abs(a[2]-a[0]);
		for(int i=3;i<n;i++)
		{
			dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
		}
		cout<<dp[n-1]<<endl;
	}
    return 0;
}


Measured memory_bytes: 1792
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
tot = sum(A)
for i in range(n):
    en = A[i] + A[i+1]
    A[i] = max(A[i] -B[i],0)
    if A[i] == 0:
        A[i+1] = max(en - B[i],0)
        #print(A[i],A[i+1])
print(tot-sum(A))

Measured memory_bytes: 19156
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
void print(const char *s, int n, int m)
{
  int i;
  if(n <= m){
    if(s == NULL){
      cout << n << endl;
    }else{
      cout << s << n << endl;
    }
    for(i=n-1;i>=1;i--){
      char t[80];
      if(s == NULL){
	sprintf(t, "%d ",i);
      }else{
	sprintf(t,"%s%d ", s, i);
      }
      print(t, n-i, i);
    }
  }else{
    for(i=m; i>=1; i--){
      char t[80];
      if(s == NULL){
	sprintf(t, "%d ",i);
      }else{
	sprintf(t,"%s%d ", s, i);
      }
      print(t, n-i, i);
    }
  }
}
int main()
{
  int n;
  for(;;){
    cin >> n;
    if(n==0)break;
    print(NULL,n,n);
  }
  return 0;
}

Measured memory_bytes: 912
import itertools

#n桁のm値のbitを生成
def bit(n, m):
    bit_list = list(itertools.product([i for i in range(m)], repeat=n))
    return bit_list

N = int(input())

A = []
for i in range(N):
    n = int(input())
    L = [list(map(int, input().split())) for _ in range(n)]
    A.append(L)

bits = bit(N, 2)
res = 0
for ptr in bits:
    flag = True
    result = [0 for _ in range(N)]

    for i in range(N):
        if ptr[i] == 1:
            result[i] = 1 # 真
        else:
            result[i] = -1 # 戯

    for i in range(N):
        if ptr[i] == 1:
            for j in range(len(A[i])):
                if A[i][j][1] == 0:
                    if result[A[i][j][0] - 1] == 1:
                        flag = False
                        break
                else:
                    if result[A[i][j][0] - 1] == -1:
                        flag = False
                        break
        else:
            if result[i] == 1:
                break
            result[i] = -1

        if flag == False:
            break

    if flag:
        tmp = 0
        for i in range(N):
            if result[i] == 1:
                tmp += 1

        res = max(res, tmp)

print(res)
                





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

int main(){
    int N;
    int AC = 0;
    int WA = 0;
    int TLE = 0;
    int RE = 0;
    string S;
    cin >> N;
    rep(i, N){
        cin >> S;
        if(S == "AC") AC++;
        if(S == "WA") WA++;
        if(S == "TLE") TLE++;
        if(S == "RE") RE++;
    }
    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
}


Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
    int i,x,n,j,flag,temp=0;
    scanf("%d",&n);
    int a[n];


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

    for(i=0; i<n; i++)
    {
        if(a[i]!=i+1)
        {
            flag=1;
            break;
        }
    }
    for(j=0; j<n; j++)
    {
        if(a[j]==i+1)
        {
            break;
        }
    }
    if (flag==1)
    {
        x=a[i];
        a[i]=a[j];
        a[j]=x;
    }


    for(i=0; i<n-1 ; i++)
    { if(a[i]>a[i+1])

    {
            printf("NO");
            temp=1;
            break;
    }
    }
    if (temp==0)
    printf("YES");
    return 0;
}


Measured memory_bytes: 128
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <locale>
#include <queue>
#include <tuple>
#include <map>
#include <fstream>

using namespace std;


#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))




int main() {
	int cnt = 0;
	while(1){
		cnt++;
		int a;
		cin >> a;
		if(a==0){
			cout << cnt<<endl;
			break;
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define int long long
const long long LINF=1e18;

signed main(){
  int n,k;cin>>n>>k;
  vector<int> v(n),w(n);
  for(int i=0;i<n;i++){cin>>v[i];w[i]=-v[i];}
  sort(v.begin(),v.end());sort(w.begin(),w.end());
  int ng=-LINF,ok=LINF;
  while(ok-ng>1){
    int mid=(ok+ng)>>1,tmp=0;
    for(int i=0;i<n;i++){
      if(v[i]>0){
        int l=-1,r=n;
        while(r-l>1){
          int m=(r+l)>>1;
          (v[i]*v[m]>mid?r:l)=m;
        }
        tmp+=r-(v[i]*v[i]<=mid);
      }
      if(!v[i]&&mid>=0)tmp+=n-1;
      if(v[i]<0){
        int l=-1,r=n;
        while(r-l>1){
          int m=(r+l)>>1;
          (-v[i]*w[m]>mid?r:l)=m;
        }
        tmp+=r-(v[i]*v[i]<=mid);
      }
    }
    if(tmp>=k*2)ok=mid;
    else ng=mid;
  }
  cout<<ok<<endl;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

template<class T>
struct SegTree {
  using F = std::function<T(T, T)>;

  ll n;
  F op;
  T id;
  std::vector<T> dat;

  SegTree()
  {}

  SegTree( F op, T id )
  : op(op), id(id)
  {}

  void init( ll n_ ) {
    n = 1;
    while( n < n_ )
      n <<= 1;
    
    dat.assign( n<<1, id );
  }

  void build( const std::vector<T> &vs ) {
    ll n_ = vs.size();
    init(n_);
    
    rep( i, n_ )
      dat[n+i] = vs[i];
    
    for( ll i = n-1; i; --i )
      dat[i] = op( dat[(i<<1)|0], dat[(i<<1)|1] );
  }

  void update( ll k, T x ) {
    dat[k += n] = x;

    while( k >>= 1 )
      dat[k] = op( dat[(k<<1)|0], dat[(k<<1)|1] );
  }

  T query( ll a, ll b ) {
    if( a >= b )
      return id;

    T vl = id, vr = id;

    for( ll l = a+n, r = b+n; l < r; l >>= 1, r >>= 1 ) {
      if( l&1 )
        vl = op( vl, dat[l++] );
      if( r&1 )
        vr = op( dat[--r], vr );
    }

    return op( vl, vr );
  }
};

ll H, W, M;
ll h[300010], w[300010];
ll cntH[300010], cntW[300010];

using Tup = std::tuple<ll, ll, ll>;

std::vector<Tup> ts;

int main() {
  std::cin >> H >> W >> M;
  
  rep( i, M ) {
    std::cin >> h[i] >> w[i];
    --h[i]; --w[i];
    ++cntH[h[i]];
    ++cntW[w[i]];

    ts.emplace_back( h[i], w[i], -1 );
    ts.emplace_back( h[i]+1, w[i], 1 );
  }

  SegTree<ll> seg( [&]( ll a, ll b ) { return std::max(a,b); }, 0 );

  seg.init( W+10 );

  rep( j, W ) {
    seg.update( j, cntW[j] );
  }

  std::sort( all(ts) );

  ll prvH = 0;
  ll ans = 0;

  for( auto t : ts ) {
    auto [i, j, x] = t;

    if( prvH != i ) {
      chmax( ans, cntH[prvH]+seg.query( 0, W ) );
    }

    ll y = seg.query( j, j+1 );
    seg.update( j, y+x );

    prvH = i;
  }

  std::cout << ans << endl;

  return 0;
}

Measured memory_bytes: 36772
//============================================================================
// Name        : aaa.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

int main() {
	int N;
	int K;
	cin >> N >> K;
	int count = 0;
	for(int i = 0; i < N; ++i){
		int h;
		cin >> h;
		if(K <= h) ++count;
	}
	cout << count << endl;
}



Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]
a = 0
b = 0
ab = 0
for i in range(n):
    if s[i][0] == "B" and s[i][-1] == "A":
        ab += 1
    elif s[i][0] == "B":
        b += 1
    elif s[i][-1] == "A":
        a += 1
c = min(a, b)
ans = c
if ab > 0:
    ans += ab
if a== 0 and b==0 and not ab==0: #not abは盲点
    ans = ab - 1
for S in s:
    for i in range(len(S)-1):
        if S[i: i + 2] == "AB":
            ans += 1
print(ans)

Measured memory_bytes: 9668
N, A, B = STDIN.gets.split(' ').map{|s| s.to_i}

if A == 0
  puts 0

else
  ab = A + B
  n = N / ab
  m = N % ab
  mb = (m <= A) ? m : A
#  puts "ab:#{ab} n:#{n} m:#{m} mb:#{mb}"
  puts n * A + mb

end




Measured memory_bytes: 1788
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main()
{
    long long x, k, d, ans;
    cin >> x >> k >> d;
    if(x < 0) x *= -1;
    long long quo = x / d;
    long long rem = x % d;
    if(k <= quo){
        ans = x - (d * k);
        cout << ans << endl;
        return 0;
    }
    long long kRem = k - quo;
    if(kRem % 2 == 0){
        cout << rem << endl;
    }
    else{
        ans = d - rem;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3632
object Main {
  def main(args: Array[String]): Unit = {
    val before_weather = scala.io.StdIn.readLine
    var weather = ""
    if      (before_weather == "Sunny")  weather = "Cloudy"
    else if (before_weather == "Cloudy") weather = "Rainy"
    else if (before_weather == "Rainy")  weather = "Sunny"

    println(weather)
  }
}

Measured memory_bytes: 25252
#include <iostream>
#include <vector>
#include <set>

long memo[100010] = {0};

long f2(int n, std::set<int>& s) {
    if (n < 0) {
        return 0;
    }
    if (n == 0) {
        return 1;
    }

    if (memo[n] != -1) {
        return memo[n];
    }

    if (s.find(n) != s.end()) {
        memo[n] = 0;
    } else {
        memo[n] = (f2(n - 1, s) + f2(n - 2, s)) % 1000000007;
    }
    return memo[n];
}

long f(int n, std::vector<int> a) {

    for (int i = 0; i < 100010; i++) {
        memo[i] = -1;
    }

    std::set<int> s;
    for (int i = 0; i < a.size(); i++) {
        s.insert(a[i]);
    }

    return f2(n, s);
}

int main() {

    int n, m;
    std::cin >> n >> m;

    std::vector<int> a;
    for (int i = 0; i < m; i++) {
        int tmp;
        std::cin >> tmp;
        a.push_back(tmp);
    }

    long result = f(n, a);
    std::cout << result << std::endl;

    return 0;
}


Measured memory_bytes: 6520
// ABC171A - 

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

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	char C;
	cin >> C;

	if (('A' <= C)&&(C <= 'Z')) {
		cout << "A" << endl;
	} else {
		cout << "a" << endl;
	}

	return 0;
}


Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (Math.abs(a-b) >= Math.abs(a-c) && Math.abs(a-b) >= Math.abs(b-c)) {
			System.out.print(Math.abs(a-c) + Math.abs(b-c));
		} else if (Math.abs(b-c) >= Math.abs(a-b) && Math.abs(b-c) >= Math.abs(a-c)) {
			System.out.print(Math.abs(a-c) + Math.abs(a-b));
		}else {
			System.out.print(Math.abs(a-b) + Math.abs(b-c));
		}
	}
}

Measured memory_bytes: 21972
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;

ll n, a;

int main() {
    scanf("%lld %lld", &n, &a);

    if (n == 1) {
        puts("1");
        return 0;
    }

    ll ans = n;
    for (int k = 0; k < 44; k++) {
        for (int s = 2; s <= 1000001; s++) {
            ll cki = 1, sec = 0;
            for (int i = 0; i < k && cki < n; i++) {
                cki *= s;
                sec += s+a;
            }
            while (cki < n) {
                cki *= (s+1);
                sec += s+1+a;
            }
            if (cki >= n) {
                ans = min(ans, sec - a);
            }
        }
    }

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define method(name,res,...) function<res (__VA_ARGS__) > name = [&](__VA_ARGS__) -> res
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int pow2(int x){
  return x * x;
}

bool operator<(pii x,pii y){
  int l = pow2(x.first)+pow2(x.second);
  int r = pow2(y.first) + pow2(y.second);
  if(l>r)return false;
  if(l<r)return true;
  return x.first < y.first;
}

pii func(int h,int w){
  pii res(150,150);
  rep(y,1,151){
    rep(x,y+1,151){
      if(pii(y,x)==pii(h,w))continue;
      pii k = pii(y,x);
      if(k<pii(h,w))continue;
      if(k<res)res=k;
    }
  }
  return res;
}

int main(){
  int h;
  int w;
  while(true){
    h = in();
    w = in();
    if(!h)break;
    pii ans = func(h,w);
    cout << ans.first << " " << ans.second << endl;
  }
  return 0;
}



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

vector<ll> to[100005];

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

Measured memory_bytes: 9780
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _2104
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            for (int i = 0 ; i < n ; i++)
            {

                int[] line = ReadIntAr();
                int[] housesPosition = ReadIntAr();

                int[] houseRanges = new int[line[0] - 1];
                for (int j = 0 ; j < line[0] - 1 ; j++)
                {
                    houseRanges[j] = housesPosition[j + 1] - housesPosition[j];
                }

                Array.Sort(houseRanges);
                int res = 0;
                for (int j = 0 ; j < line[0]-line[1] ; j++)
                {
                    res += houseRanges[j];
                }
                Console.WriteLine(res.ToString());
            }

        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 38692
/* Priyansh Agarwal*/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<algorithm>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<map>
#include<chrono>
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define nline "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define debug(x) cout << #x << " " << x <<endl;
#define set_bits __builtin_popcount
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > pbds;
/*---------------------------------------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll expo(ll a, ll b, ll mod) {ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
void extendgcd(ll a, ll b, ll*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size 3
ll mminv(ll a, ll b) {ll arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
bool revsort(ll a, ll b) {return a > b;}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
ll combination(ll n, ll r, ll m, ll* fact) {ll val1 = fact[n]; ll val2 = mminvprime(fact[r], m); ll val3 = mminvprime(fact[n - r], m); return ((val1 * val2) % m * val3) % m;}
void google(int t) {cout << "Case #" << t << ": ";}
vector<int> sieve(int n) {int*arr = new int[n + 1](); vector<int> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
/*--------------------------------------------------------------------------------------------------------------------------*/
void solve()
{
	int t;
	// cin >> t;
	t = 1;
	while (t--)
	{
		int n;
		cin >> n;
		string s;
		cin >> s;
		int count = 0;
		for (int i = 0; i <= n - 3; i++)
		{
			if (s.substr(i, 3) == "ABC")
				count++;
		}
		cout << count << "\n";
	}
}
int main()
{
	fastio();
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
	freopen("Error.txt", "w", stderr);
#endif
	auto start1 = high_resolution_clock::now();
	solve();
	auto stop1 = high_resolution_clock::now();
	auto duration = duration_cast<microseconds>(stop1 - start1);
#ifndef ONLINE_JUDGE
	cerr << "Time: " << duration.count() / 1000.0 << endl;
#endif
	return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
typedef long long int lld;

int main(void) {
  lld n, s = 0;
  scanf("%lld", &n);
  for (int i = 0; i <= n; i++) {
    if (i % 3 * i % 5 != 0) {
      s += i;
    }
  }
  printf("%lld\n", s);
}

Measured memory_bytes: 1732
use std::io;

/// 一行を読み込んで、空白で区切ったベクタにして返す
#[allow(dead_code)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect()
}

/// n行を読み込んで、数字を空白で区切って二次元のベクタにして返す
#[allow(dead_code)]
fn read_table<T>(n: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut ret: Vec<Vec<T>> = Vec::new();
    for _ in 0..n {
        ret.push(read::<T>());
    }
    ret
}

/// n行を読み込んで、1文字ずつを二次元のベクタにして返す
#[allow(dead_code)]
fn read_char_table(n: usize) -> Vec<Vec<char>> {
    let mut ret: Vec<Vec<char>> = Vec::new();
    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let chr = buf.trim().chars().collect();
        ret.push(chr);
    }
    ret
}

/// n行を読み込んで、一次元のベクタにして返す
#[allow(dead_code)]
fn read_array<T>(n: usize) -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut array = Vec::new();

    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        array.push(buf.trim().parse().unwrap());
    }
    array
}

fn main() {
    let s = read::<String>();
    let s = &s[0];

    let mut cflag = false;
    let sc = s.chars().collect::<Vec<char>>();
    let count = s.chars().count();

    if sc[0] != 'A' {
        println!("WA");
        return;
    }

    if sc[1] == 'C' || sc[1].is_uppercase() {
        println!("WA");
        return;
    }

    if sc[count - 1] == 'C' || sc[count - 1].is_uppercase() {
        println!("WA");
        return;
    }

    for num in 2..count - 1 {
        if sc[num] == 'C' {
            if cflag == false {
                cflag = true;
                continue;
            } else {
                println!("WA");
                return;
            }
        }

        if sc[num].is_uppercase() {
            println!("WA");
            return;
        }
    }

    if cflag == false {
        println!("WA");
    } else {
        println!("AC");
    }
}


Measured memory_bytes: 4352
//****** @author mdazmat9 **********
#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll fast_pow(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

void solve() {
    ll a,b,k;cin>>a>>b>>k;
    ll aa=max(0ll,a-k);
    k-=(a-aa);
    //cout<<k<<endl;
    b=max(0ll,b-k);
    cout<<aa<<" "<<b;


}
int main()
{
    IOS;
    ll test=1;
   // cin>>test;
    while(test--){
        solve();
    }
    return 0;
}


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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    int N;
    cin >> N;
    vector<int> WA(N), SA(N);
    int x, y;
    for (int i = 0; i < N; i++)
    {
        cin >> x >> y;
        WA[i] = x + y;
        SA[i] = x - y;
    }
    sort(WA.begin(), WA.end());
    sort(SA.begin(), SA.end());
    cout << max(WA[N - 1] - WA[0], SA[N - 1] - SA[0]);
}

Measured memory_bytes: 4840
#include<stdio.h>

int main()
{
	int h,a,i=0;
	scanf("%d%d",&h,&a);
	while(h>0)
	{ h=h-a;
		i++;
	}
	if(h<0)printf("%d",i);
	else printf("%d",i);
		
	
	return 0;
		
	
}

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

int main(){
 int N;  cin>>N;
 string S;  cin>>S;
  
  int x=0, max=0;
  for(int i=0; i<N; i++){
   if(S[i]=='I'){x++;}
   else{x--;}
   if(max<x){max=x;} 
  }
  
  cout<<max;
}


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

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a > 12) {
    cout << b << '\n';
  } else if (a > 5) {
    cout << b / 2 << '\n';
  } else {
    cout << 0 << '\n';
  }
  return 0;
}


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

using namespace std;
typedef long long ll;

ll k;
string s;
int main()
{
	cin>>s>>k;
	for(int i=0; i<k; i++)
		if(s[i]!='1')
			return cout<<s[i]<<endl,0;
	cout<<"1"<<endl;
	return 0;
}


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

int main()
{
   int n;
   cin>>n;
   int a[3]={};
   while(n--)
   {
       string s;
       cin>>s;
       if(s=="AC")a[0]++;
       if(s=="WA")a[1]++;
       if(s=="TLE")a[2]++;
       if(s=="RE")a[3]++;
   }
   cout<<"AC x "<<a[0]<<endl;
   cout<<"WA x "<<a[1]<<endl;
   cout<<"TLE x "<<a[2]<<endl;
   cout<<"RE x "<<a[3]<<endl;
}

Measured memory_bytes: 3596
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll NN, HH, WW;

  std::cin >> NN >> HH >> WW;

  ll row = (NN - HH) + 1;
  ll col = (NN - WW) + 1;

  if (row < 0 || col < 0) {
    std::cout << 0 << '\n';
  }else{
    std::cout << row * col << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int MOD=1000000007;

int n,k;
vector<int> pos,neg;
ll ppos[200005],pneg[200005];
long double dpos[200005],dneg[200005];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>k;
	
	if (n==k){
		int t;
		bool negative=false;
		ll ans=1;
		
		rep(x,0,n){
			cin>>t;
			
			if (t<=0) ans=ans*-t%MOD,negative^=true;
			else ans=ans*t%MOD;
		}
		
		if (negative) cout<<(MOD-ans)%MOD;
		else cout<<ans<<endl;
		
		return 0;
	}
	
	int t;
	rep(x,0,n){
		cin>>t;
		
		if (t<=0) neg.push_back(-t);
		else pos.push_back(t);
	}
	
	sort(all(neg)),reverse(all(neg));
	sort(all(pos)),reverse(all(pos));
	
	pneg[0]=1;
	dneg[0]=0;
	rep(x,0,sz(neg)){
		pneg[x+1]=(pneg[x]*neg[x])%MOD;
		dneg[x+1]=dneg[x]+log((long double)neg[x]);
	}
	
	ppos[0]=1;
	dpos[0]=0;
	rep(x,0,sz(pos)){
		ppos[x+1]=(ppos[x]*pos[x])%MOD;
		dpos[x+1]=dpos[x]+log((long double)pos[x]);
	}
	
	bool used=false;
	
	long double best=-1e100;
	ll ans=0;
	
	//cerr<<sz(pos)<<" "<<sz(neg)<<endl;
	
	rep(x,0,sz(neg)+1){
		if (x%2==1 || sz(neg)<x) continue;
		int y=k-x;
		
		if (y<0 || sz(pos)<y) continue;
		
		//cerr<<x<<" "<<y<<endl;
		//cerr<<best<<endl;
		
		used=true;
		long double temp=dneg[x]+dpos[y];
		
		if (best<temp){
			best=temp;
			ans=pneg[x]*ppos[y]%MOD;
		}
	}
	
	if (!used){
		ll ans=1;
		
		rep(x,sz(neg)-k,sz(neg)) ans=ans*neg[x]%MOD;
		
		cout<<(MOD-ans)%MOD;
	}
	else{
		cout<<ans;
	}
	
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    ll n,k;
    cin >> n >> k;
    ll a=n/k;
    ll x,y;
    x=a*k;
    y=(a+1)*k;
    cout << min(abs(x-n),abs(y-n));


    
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
class Simple
{
    string s;
    void Solve() {
        //input
        s = io.String;
        //cal
        var ans = s.First().ToString() + (s.Length-2) + s.Last().ToString();
        //ret
        WriteLine(ans);
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] { ' ', '"', ',' };
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
        AutoFlush = false
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if (_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == "")
            st = ReadLine();
        if (st != null)
            _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else
            st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


Measured memory_bytes: 11220
#include <stdio.h>

int main(void){
    int height;
    int width;
    int not_zero=1;
    int i,j=0;


    while(not_zero){
        scanf("%d",&height);
        scanf("%d",&width);

        if(height==0&&width==0){
            not_zero=0;
        }

        for(i=0;i<height;i++){
            for(j=0;j<width;j++){
                printf("#");
            }
            printf("\n");
        }

        if(not_zero){
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 2028
def gcd(a, b):
    if a == 0:
        return b
    else:
        return gcd(b%a, a)

class SegmentTree:
    def __init__(self, size, f=lambda x,y : x+y, default=0):
        self.size = 2**(size-1).bit_length()
        self.default = default
        self.dat = [default]*(self.size*2)
        self.f = f

    def update(self, i, x):
        i += self.size
        self.dat[i] = x
        while i > 0:
            i >>= 1
            self.dat[i] = self.f(self.dat[i*2], self.dat[i*2+1])

    def query(self, a, b=None):
        if b is None:
            b = a + 1
        l, r = a + self.size, b + self.size
        lres, rres = self.default, self.default
        while l < r:
            if l & 1:
                lres = self.f(lres, self.dat[l])
                l += 1

            if r & 1:
                r -= 1
                rres = self.f(self.dat[r], rres)
            l >>= 1
            r >>= 1
        res = self.f(lres, rres)
        return res

n = int(input())
a = list(map(int, input().split()))
s = SegmentTree(n, gcd)
for i in range(n):
    s.update(i,a[i])

ans = 1
for i in range(n):
    left = s.query(0,i)
    right = s.query(i+1,n)
    res = gcd(left, right)
    if ans < res:
        ans = res
print(ans)


Measured memory_bytes: 117400
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
using namespace std;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
int main(){
    int w,n;
    cin >> w >> n;
    vector<int> vec;
    rep(i,w){
        vec.push_back(i+1);
    }
    rep(i,n){
        int a,b;
        scanf("%d,%d",&a,&b);
        a--; b--;
        //cout << a << " " << b << endl;;
        swap(vec[a],vec[b]);
    }
    rep(i,w) cout << vec[i] << endl;
    return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
//#define int long long
using namespace std;
const int MOD=1e9+7;
//const int INF=1e10;

using namespace std;
int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  int ans=a*x+b*y;
  //cout<<ans<<endl;
  for(int i=0;i<200001;i+=2){
    int tmp_x=x-i/2;
    int tmp_y=y-i/2;
    int sum=a*max(tmp_x,0)+b*max(tmp_y,0)+c*i;
    ans=min(ans,sum);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

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

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

int main()
{
	ll A, B;
	cin >> A >> B;
	cout << lcm(A, B) << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        int totalMin = 60 * h + m; // 分単位で求められる
        double angularA = Math.PI / 360 * totalMin;
        double angularB = Math.PI / 30 * totalMin;
        double theta = Math.abs(angularA - angularB);
        System.out.println(Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(theta)));
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

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

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

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

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

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 33324
using System;
using System.Linq;

namespace ABC143_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = ab[0];
            var b = ab[1];
            Console.WriteLine(Math.Max(0, a - b * 2));
        }
    }
}


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

int main(){
    int N, K, ball = 0, result = 0;

    cin >> N >> K;

    while(N > 0){
        cin >> ball;

        if(K - ball > ball){
            result += ball;
        }else{
            result += (K - ball);
        }

        N--;
    }

    result *= 2;

    cout << result;
}

Measured memory_bytes: 256
n,T=map(int,raw_input().split())
t=map(int,raw_input().split())
i=1
now=T
ans=T
while i<n:
    if t[i]+T<now:
        while t[i]+T<now:
            i+=1
    if t[i]>=now:
        now=t[i]+T
        ans+=T
        i+=1
    elif t[i]+T>=now:
        ans+=t[i]+T-now
        now=t[i]+T
        i+=1
print ans


Measured memory_bytes: 20036
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define int long long
#define LONG LLONG_MAX/3;
#define INT INT_MAX/3;
#define mod 1000000007
typedef long long ll;
using namespace std;

pair<P,int> p[100000];
string s[100000];

int keta(int a){
	int b=0;
	while(a){
		a/=10;
		b++;
	}
	return b;
}
int mypow(int a,int b){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1)*a%mod;
	return mypow(a,b/2)*mypow(a,b/2)%mod;
}
int kaijo(int n){
	int ans=1;
	for(int i=1;i<=n;i++){
		ans*=i;
		ans%=mod;
	}
	return ans;
}
int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}

signed main(){
	int n,m,x=1;
	cin>>n>>m;
	f(i,m){
		cin>>p[i].first.first>>p[i].first.second;
		p[i].second=i;
	}
	sort(p,p+m);
	f(i,m){
		if(i){
			if(p[i].first.first==p[i-1].first.first) x++;
			else x=1;
		}
		f(j,6-keta(p[i].first.first)) s[p[i].second]+="0";
		s[p[i].second]+=to_string(p[i].first.first);
		f(j,6-keta(x)) s[p[i].second]+="0";
		s[p[i].second]+=to_string(x);
	}
	f(i,m) cout<<s[i]<<endl;
	return 0;
}


Measured memory_bytes: 10880
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;

ll MOD = 1000000007;

int main(){
    int N, M;
    cin >> N >> M;

    vector<vector<pair<ll, int> > > constraints(N+1);
    
    for(int i=0;i<M;i++){
        ll l, r;
        int x;
        cin >> l >> r >> x;
        constraints[r].push_back(make_pair(l, x));
    }
    

    vector<ll> dpr1(N+1, 0);
    vector<vector<ll> > dpr2(N+1, dpr1);
    vector<vector<vector<ll> > > dp(N+1, dpr2);

    dp[0][0][0] = 1;

    for(int k1=0;k1<N;k1++){
        for(int k2=0;k2<=k1;k2++){
            for(int k3=0;k3<=k2;k3++){
                //check if valid
                bool good = true;
                for(int i=0;i<constraints[k1].size() && good;i++){
                    ll L = constraints[k1][i].first;
                    int x = constraints[k1][i].second;
                    if(x==1){
                        if(k2>=L){
                            good = false;
                        }
                    }else if(x==2){
                        if(k2<L || k3>=L){
                            good = false;
                        }
                    }else if(x==3){
                        if(k3<L){
                            good = false;
                        }
                    }
                }

                if(good){
                    dp[k1][k2][k3]%=MOD;
                    dp[k1+1][k2][k3] += dp[k1][k2][k3];
                    dp[k1+1][k1][k3] += dp[k1][k2][k3];
                    dp[k1+1][k1][k2] += dp[k1][k2][k3];
                }
            }
        }
    }

    ll ans = 0;
    for(int k2=0;k2<=N;k2++){
        for(int k3=0;k3<=k2;k3++){
            bool good = true;
            for(int i=0;i<constraints[N].size() && good;i++){
                ll L = constraints[N][i].first;
                int x = constraints[N][i].second;
                if(x==1){
                    if(k2>=L){
                        good = false;
                    }
                }else if(x==2){
                    if(k2<L || k3>=L){
                        good = false;
                    }
                }else if(x==3){
                    if(k3<L){
                        good = false;
                    }
                }
            }

            if(good){
                ans += dp[N][k2][k3];
            }
        }
    }

    ans %= MOD;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 216960
#include <bits/stdc++.h>
#define mod 1000000007
#define maxn 25
using namespace std;

int a[maxn][maxn];
int n;
int f[3100000];

int main()
{
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cin>>a[i][j];
        }
    }
    int len = 1<<n;f[0] = 1;
    for(int i=1;i<len;i++)
    {
        int cnt = 0;
        for(int j=1,nh=1;j<=n;j++,nh<<=1)
        {
            if(i&nh) cnt++;
        }
        for(int j=1,nh=1;j<=n;j++,nh<<=1)
        {
            if((i&nh)&&a[cnt][j]) f[i] = (f[i]+f[i^nh])%mod;
        }
    }
//    for(int i=0;i<len;i++) cout<<f[i]<<' ';
//    cout<<endl;
    cout<<f[len-1];
    return 0;
}


Measured memory_bytes: 10496
#include<iostream>
#include<cstdio>
#include<bitset>
using namespace std;
const int N=18;

int a[N][2];
int oe[1<<N];
bitset<N*N/2>f[1<<N][N];

int main()
{
	int n,i,j,k,cnt;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i][1]);
	for(i=0;i<n;i++)
		scanf("%d",&a[i][0]);
	for(i=1;i<(1<<n);i++)
		oe[i]=oe[i^(i&-i)]^1;
	for(i=1;i<(1<<n);i++){
		if(i==(i&-i)){
			for(j=0;j<n;j++)
				if(i&(1<<j))f[i][j][0]=1;
			continue;
		}
		for(j=0;j<n;j++)
			if(i&(1<<j)){
				cnt=0;
				for(k=n-1;k>=0;k--)
					if(i&(1<<k)){
						if(k!=j&&a[k][oe[i]^(k&1)]>=a[j][oe[i]^(j&1)^1])
							f[i][k]|=f[i^(1<<k)][j]<<cnt;
						++cnt;
					}
			}
	}
	for(i=0;i<N*N/2;i++)
		for(j=0;j<n;j++)
			if(f[(1<<n)-1][j][i]){
				printf("%d",i);
				return 0;
			}
	printf("-1");
	return 0;
}

Measured memory_bytes: 111872