akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
using namespace std;

int x,y,H,W,c[110][110]/*d[110][110]*/;
string s;

int main(){
  while(true){
    for(int i=0;i<101;i++){
      for(int j=0;j<101;j++)
	{c[i][j]=6;}
    }

    scanf("%d%d",&H,&W);
    if(H==0&&W==0){break;}
    for(int i=0;i<H;i++){
      cin>>s;
      for(int j=0;j<W;j++){
	if(s.substr(j,1)==">"){c[i][j]=1;}
	if(s.substr(j,1)=="<"){c[i][j]=2;}	
	if(s.substr(j,1)=="^"){c[i][j]=3;}
	if(s.substr(j,1)=="v"){c[i][j]=4;}
	if(s.substr(j,1)=="."){c[i][j]=5;}
      }
    }///c[h][w]
    x=0;
    y=0;
    while(true){
      if(c[x][y]==1)
	{c[x][y]=0;
	  y++;}
      if(c[x][y]==2)
	{c[x][y]=0;
	  y--;}
      if(c[x][y]==3)
	{c[x][y]=0;
	  x--;}
      if(c[x][y]==4)
	{c[x][y]=0;
	  x++;}
      if(c[x][y]==5)
	{printf("%d %d\n",y,x);break;}
      if(c[x][y]==0)
	{printf("LOOP\n");break;}
    }
  }
}

Measured memory_bytes: 1300
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
	puts(a+c==b+b?"YES":"NO");
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  string s,t;
  cin >> s >> t;
  sort(all(s));
  sort(all(t));
  reverse(all(t));
  if(s<t) cout << "Yes" << endl;
  else cout << "No" <<endl;
  return 0;
}


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

int main()
{
    int N, M;
    cin >> N >> M;
    if (M <= N)
    {
        cout << 0 << endl;
        return 0;
    }
    vector<int> X(M);
    for (int i = 0; i < M; i++)
    {
        cin >> X[i];
    }
    sort(X.begin(), X.end());

    vector<int> sub;
    for (int i = 1; i < X.size(); i++)
    {
        sub.push_back(abs(X[i] - X[i - 1]));
        // cout << abs(X[i] - X[i - 1]) << endl;
    }
    sort(sub.begin(), sub.end());

    cout << accumulate(sub.begin(), sub.end() - (N - 1), 0LL);

    return 0;
}

Measured memory_bytes: 1276
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

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

  int n;
  cin >> n;
  vector<int> a(3 * n);
  for (int i = 0; i < a.size(); i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<int>());
  int64_t ans = 0;
  for (int i = 1; i <= 2 * n; i += 2) {
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
// earlier we had dp[n][w]
// but now we have dp[n][v] we will see if we have 
const ll inf = 1e15;
signed main(){
	ll n, i, j, w;
	cin >> n >> w;
	vector<pair<ll,ll>> v(n);
	ll sum_value = 0;
	for( i = 0 ; i < n ; i++ ){
		cin >> v[i].second >> v[i].first; // weight - value
		sum_value += v[i].first;
	}
	sort(v.begin(),v.end()); // value -> weight
	vector<ll> dp(sum_value+1,inf);
	dp[0] = 0;
	for( i = 0 ; i < n ; i++ ){
		for( j = sum_value ; j >= v[i].first ; j-- ){
			dp[j] = min( dp[j], dp[j-v[i].first] + v[i].second );
		}
	}
	ll ans = 0;
	for( j = sum_value ; j >= 0 ; j-- ){
		if( dp[j] <= w ){
			ans = j;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define MAX 100010

bool ans[MAX];

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

	ans[0]=true;
	for(int i=0;i<MAX;i++){
		if(ans[i]){
			for(int j=0;j<6;j++){
				if(i+100+j>100000)continue;
				ans[i+(100+j)]=true;
			}
		}
	}

	if(ans[x])cout<<1<<endl;
	else cout<<0<<endl;
	

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
int main () {
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx, dy = ty - sy;
    cout << string(dx, 'R') << string(dy, 'U');
    cout << string(dx, 'L') << string(dy, 'D');
    cout << 'D' << string(dx + 1, 'R') << string(dy + 1, 'U') << 'L';
    cout << 'U' << string(dx + 1, 'L') << string(dy + 1, 'D') << 'R';
    cout << endl;
    return 0 ;

}

 


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    ll n;
    cin >> n;
    vector<ll> w(n);
    for(int i = 0; i < n; i++){
        cin >> w[i];
    }

    ll ans = 9999999;
    for(int i = 0; i < n; i++){
        ll s1 = 0;
        ll s2 = 0;
        for(int j = 0; j < i; j++){
            s1 += w[j];
        }
        for(int j = i; j < n; j++){
            s2 += w[j];
        }
        ans = min(ans, abs(s1-s2));
    }
    cout << ans << endl;

    return 0;
}


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

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

int main(){
    long long a,b;
    cin >> a >> b;
    cout << (a*b)/gcd(a, b);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl enjoy_codeforces
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::vector<lint>a={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};
    lint k;std::cin>>k;
    std::cout<<a.at(k-1)<<'\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<typename T>
void print(T &arr){
    ll sz = sizeof(arr)/sizeof(arr[0]);
    for(int i = 0;i < sz-1;i++){cout << arr[i] << ' ';}
    cout << arr[sz-1] << endl;
}


ll get_sum(vvl &sum, ll xs, ll ys, ll xe, ll ye){
    ll res;
    res = sum[xe][ye] - sum[xe][ys] - sum[xs][ye] + sum[xs][ys];
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,k; cin >> n >> k;
    vector<ll> x(n),y(n);
    map<ll,ll> x_mp,y_mp,x_mp_rev,y_mp_rev;
    set<ll> x_st,y_st;
    rep(i,n){
        cin >> x[i] >> y[i];
        x_st.insert(x[i]);
        y_st.insert(y[i]);
    }
    ll cnt = 0;
    for(auto itr = x_st.begin();itr != x_st.end();++itr){
        x_mp[cnt] = *itr;
        x_mp_rev[*itr] = cnt++;
    }
    // cout << x_mp[1] << endl;
    cnt = 0;
    for(auto itr = y_st.begin();itr != y_st.end();++itr){
        y_mp[cnt] = *itr;
        y_mp_rev[*itr] = cnt++;
    }
    ll x_n = x_st.size(), y_n = y_st.size();

    vvl a(x_n,vector<ll>(y_n,0));
    vvl sum(x_n+1,vector<ll>(y_n+1,0));
    rep(i,n){
        ll xt = x_mp_rev[x[i]], yt = y_mp_rev[y[i]];
        a[xt][yt]++;
    }
    rep(i,x_n)rep(j,y_n){
        sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + a[i][j];
    }

    ll res = LLONG_MAX;
    rep(i,x_n+1)rep(ii,x_n+1){
        rep(j,y_n+1)rep(jj,y_n+1){
            if(ii <= i)continue;
            if(jj <= j)continue;
            ll temp = get_sum(sum,i,j,ii,jj);
            if(k <= temp){
                // ma = temp;
                debug(temp);
                res = min(res,(x_mp[ii-1]-x_mp[i]) * (y_mp[jj-1]-y_mp[j]));
            }
        }
    }

    // print(sum);

    cout << res << endl;
    
}

Measured memory_bytes: 384
PROGRAM rally
      IMPLICIT NONE
      integer(16) :: n,ans,val,best,i
      integer(16),allocatable :: x(:)
      
      read*,n
      allocate(x(n))
      read*,x(:)
      
      best = huge(best)
      do i = 1,100
        val = sum( (x(:)-i)*(x(:)-i) )
        
        if( val<=best )then
          best = val
          ans  = i
        end if
      end do
      
      print*,best
      
      
      
      END PROGRAM

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

using namespace std;

#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i,x,n) for(i=x;i<n;++i)
#define f(n) for(int i=0;i<n;++i)
#define fr(i,x,n) for(i=x;i>=n;--i)
#define endl '\n'

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a[1000000];
    int ans[1000000];
    int n;
    cin>>n;
    f(n){
        cin>>a[i+1];
    }
    int x=n;
    int y=1;
    for(int i=n;i-1>=0;i-=2){
        ans[y]=a[i];
        ans[x]=a[i-1];
        x--;
        ++y;
    }
    if(n%2==1){
        ans[(n+1)>>1]=a[1];
    }
    f(n){
        cout<<ans[i+1]<<" ";
    }
    cout<<endl;



    return 0;
}



Measured memory_bytes: 8832
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  1000008
ll lpf[N], mobius[N]; 
ll a[N];
ll fre[N]; 
ll n;
// Function to calculate least 
// prime factor of each number 
void least_prime_factor() 
{ 
    for (ll i = 2; i < N; i++) 
  
        // If it is a prime number 
        if (!lpf[i]) 
  
            for (ll j = i; j < N; j += i) 
  
                // For all multiples which are not 
                // visited yet. 
                if (!lpf[j]) 
                    lpf[j] = i; 
} 
  
// Function to find the value of Mobius function 
// for all the numbers from 1 to n 
void Mobius() 
{ 
    for (ll i = 1; i < N; i++) { 
  
        // If number is one 
        if (i == 1) 
            mobius[i] = 1; 
        else { 
  
            // If number has a squared prime factor 
            if (lpf[i / lpf[i]] == lpf[i]) 
                mobius[i] = 0; 
  
            // Multiply -1 with the previous number 
            else
                mobius[i] = -1 * mobius[i / lpf[i]]; 
        } 
    } 
} 
  
// Function to find the number of pairs 
// such that gcd equals to 1 
ll gcd_pairs() 
{ 
    // To store maximum number 
    ll maxi = 0; 
  
    // To store frequency of each number 
    
  
    // Find frequency and maximum number 
    for (ll i = 0; i < n; i++) { 
        fre[a[i]]++; 
        maxi = max(a[i], maxi); 
    } 
  
    least_prime_factor(); 
    Mobius(); 
  
    // To store number of pairs with gcd equals to 1 
    ll ans = 0; 
  
    // Traverse through the all possible elements 
    for (ll i = 1; i <= maxi; i++) { 
        if (!mobius[i]) 
            continue; 
  
        ll temp = 0; 
        for (ll j = i; j <= maxi; j += i) 
            temp += fre[j]; 
  
        ans += temp * (temp - 1) / 2 * mobius[i]; 
    } 
  
    // Return the number of pairs 
    return ans; 
} 
int main()
{
	
	io
	

	cin>>n;
	rep(i,0,n)
	{
		cin>>a[i];
	}
	ll zz=gcd_pairs();
	ll mx=(n*(n-1))/2;
	if(mx==zz)
	{
		cout<<"pairwise coprime";
		exit(0);
	}
	ll cgcd=a[0];
	rep(i,0,n)
	{
		cgcd=__gcd(cgcd,a[i]);
	}
	if(cgcd==1)
	{
		cout<<"setwise coprime";
		exit(0);
	}
	cout<<"not coprime";

}

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

int main(void){
  const int inf = 1 << 30;
  typedef tuple<int, int, int> t3;
  int n, Q;
  priority_queue<t3, vector<t3>, greater<t3>> q;
  cin >> n >> Q;
  vector<int> ans(Q, -1), ds(Q);
  multiset<int> ms; ms.insert(inf);
  for (int i = 0; i < n; i++){
    int s, t, x;
    scanf("%d %d %d", &s, &t, &x);
    q.push(make_tuple(s - x, x, 1));
    q.push(make_tuple(t - x, x, 0));
  }

  for (int i = 0; i < Q; i++) scanf("%d", &ds[i]);

  int cur = 0;
  while (!q.empty()){
    t3 e = q.top(); q.pop();
    int t, x, act, v;
    tie(t, x, act) = e; v = *ms.begin();
    while (cur < Q && ds[cur] < t)
      ans[cur++] = v;
    
    if (act) ms.insert(x);
    else ms.erase(ms.find(x));
  }

  for (int i = 0; i < Q; i++) printf("%d\n", ans[i] == inf ? -1 : ans[i]);
  return 0;
}


Measured memory_bytes: 18896
#!/usr/bin/env python3
from bisect import bisect_left, bisect_right

n = int(input())
a = list(map(int, input().split()))
m = sorted(i - x for i, x in enumerate(a))
p = sorted(i + x for i, x in enumerate(a))
cs = [0] * 10 ** 6
ans = 0
for i in range(n):
    if m[i] <= 0:
        continue
    ans += bisect_right(p, m[i], 0, i) - bisect_left(p, m[i], 0, i)
print(ans)


Measured memory_bytes: 105348
using System;

namespace _0130
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                char[] train = new char[53];
                int now = 26;
                string s = Console.ReadLine();
                train[now] = s[0];
                for (int j = 0; j < (s.Length - 1) / 3; j++)
                {
                    if (s[j * 3 + 1] == '-')
                    {
                        now++;
                    }
                    else
                    {
                        now--;
                    }
                    train[now] = s[j * 3 + 3];
                }
                for (int j = 0; j < 53; j++)
                {
                    if (train[j] != 0)
                    {
                        Console.Write(train[j]);
                    }
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 8984
var x = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = x.split(/\n/);
for (var i = 0; i < lines.length ; i++) {
  var arr = lines[i].split(/\s/).map(Number);
  if ((arr[0]==0)&&(arr[1]==0)) break;
  for (var j = 0; j < arr[0]; j++){
    for (var k = 0; k < arr[1]; k++) process.stdout.write("#");
    console.log();
  }
  console.log();
}




Measured memory_bytes: 31920
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}

	ans := 0
	m := as[0]
	for i := 1; i < n; i++ {
		if m > as[i] {
			ans += m - as[i]
		} else {
			m = as[i]
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 6468
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main() {
	cin.sync_with_stdio(0);

	string s, t;
	cin >> s >> t;

	ll m = oo;
	FOR(i,0,sz(s) - sz(t) + 1) {
		ll count = 0;
		FOR(j,0,sz(t)) {
			if (s[i + j] != t[j]) {
				count++;
			}
		}
		m = min(m, count);
	}

	cout << m << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

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

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

string s;

int main(){
	while(cin >> s){
		printf("%c",s[0]);
	}
	puts("");
	return 0;
}


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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pi;
typedef long double ld;
typedef pair<long double, long double> pld;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll i, j, k, l;

    ll x;
    cin >> x;
    if(x) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3580
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
    int a,b;
    cin >>a >>b;
    double x,y,z;
    x=a/b;
    y=a%b;
    z=1.00*a/b;
    
    cout << int(x)<<" "<<int(y)<<" ";
    printf("%.5lf\n", z);
    return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using P = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
    a[i] -= i + 1;
  }
  sort(a.begin(), a.end());
  ll mi = INF;

  ll total = 0;
  rep(j, n) { total += abs(a[j] - a[n / 2]); }
  cout << total << endl;
}

Measured memory_bytes: 1792
def print_frame(h,w)
  h.times do |i|
    next puts "#"*w if i == 0 || i == h-1
    puts "#"+"."*(w-2)+"#"
  end
  puts ""
end

loop do
  h,w = gets.split.map(&:to_i)
  break if h == 0 && w == 0
  print_frame(h,w)
end



Measured memory_bytes: 6956
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];//a[4]
	for(int i=0;i<=n-1;i++)//a[1]....a[4]
	{
		cin>>a[i];
	}
	sort(a,a+n);
	cout<<a[n-1]-a[0];
	return 0;
}

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


int main(){
    int N, T;
    cin>>N>>T;
    vector<pair<int, int>> AB(N);
    for(int i=0; i<N; i++){
        cin>>AB.at(i).first>>AB.at(i).second;
    }
    sort(AB.begin(), AB.end());
    int DP[N+1][T+1];
  	for(int i=0; i<N+1; i++){
      	for(int j=0; j<T+1; j++){
          	DP[i][j]=0;
        }
    }
    for(int i=1; i<=N-1; i++){
        for(int j=0; j<=T-1; j++){
            if(j-AB.at(i-1).first>=0){
                DP[i][j]=max(DP[i-1][j],DP[i-1][j-AB.at(i-1).first]+AB.at(i-1).second);
            }
            else{
                DP[i][j]=DP[i-1][j];
            }
        }
    }
    int Max=0;
    for(int i=0; i<=N-1; i++){
        int Sum=0;
        Sum+=DP[i][T-1];
        Sum+=AB.at(i).second;
        Max=max(Max, Sum);
    }
  	
  	cout<<Max;
}




Measured memory_bytes: 35456
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
 
class Program {
    static void Main(string[] args){
        var HW  = Console.ReadLine().Split().Select(a => long.Parse(a)).ToArray();
        
       var H = HW[0];
       var W = HW[1];
       var masu = new long[H][];
       for(int i = 0;i < H;i++){
           masu[i] = Console.ReadLine().Split().Select(a => long.Parse(a)).ToArray();
       }
       
       var flag = true;
       var tmp = 0;
       var count = 0L;
       var ans = new List<string>();
       for(int i = 0;i < H;i++){
           
           if(i%2 == 0){
               for(long j = 0;j < W;j++){
                   masu[i][j] += tmp;
                   if(masu[i][j]%2 ==1){
                       masu[i][j]--;
                       tmp = 1;
                       if(j < W-1){
                           var str = (i+1)+" "+(j+1)+" "+(i+1)+" "+(j+2);
                           ans.Add(str);
                           count++;
                       }else if(i < H-1){
                           var str = (i+1)+" "+(j+1)+" "+(i+2)+" "+(j+1);
                           ans.Add(str);
                           count++;
                       }
                   }else{
                       tmp = 0;
                   }
               }
           }
           
           if(i%2 != 0){
               for(long j = W-1;j>=0;j--){
                   masu[i][j] += tmp;
                   if(masu[i][j]%2 ==1){
                       masu[i][j]--;
                       tmp = 1;
                       
                       if(j > 0){
                           var str = (i+1)+" "+(j+1)+" "+(i+1)+" "+(j);
                           ans.Add(str);
                           count++;
                       }else if(i < H-1){
                           var str = (i+1)+" "+(j+1)+" "+(i+2)+" "+(j+1);
                           ans.Add(str);
                           count++;
                       }
                   }else{
                       tmp = 0;
                   }
               }
           }
       }
       
       Console.WriteLine(count);
       for(int i = 0;i < ans.Count();i++){
           Console.WriteLine(ans[i]);
       }
       
    }      
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

const int MAX = 1e5+10;

int N, K;
string S;

int solve() {
    int l = 1;
    REP (i, N-1) if (S[i+1] != S[i]) l++;
    return N - max(1, l - 2*K);
}

int main() {
    cin >> N >> K >> S;
    cout << solve() << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool solve(int n, vector<string> &words) {
	const int ALPHABET_NUM = 26;

	vector<bool> used(ALPHABET_NUM);
	vector<vector<bool>> g(ALPHABET_NUM, vector<bool>(ALPHABET_NUM));

	vector<int> indegree(ALPHABET_NUM), outdegree(ALPHABET_NUM);
	for (auto word : words) {
		// x -> y
		int x = word.front() -'a';
		int y = word.back() - 'a';

		used[x] = used[y] = g[x][y] = true;

		outdegree[x]++;
		indegree[y]++;
	}

	for (int i = 0; i < ALPHABET_NUM; i++) {
		if (indegree[i] != outdegree[i]) {
			return false;
		}
	}

	for (int k = 0; k < ALPHABET_NUM; k++) {
		for (int i = 0; i < ALPHABET_NUM; i++) {
			for (int j = 0; j < ALPHABET_NUM; j++) {
				if (g[i][k] && g[k][j]) {
					g[i][j] = true;
				}
			}
		}
	}

	for (int i = 0; i < ALPHABET_NUM; i++) {
		if (!used[i]) continue;
		for (int j = 0; j < ALPHABET_NUM; j++) {
			if (!used[j]) continue;

			if (!g[i][j]) {
				return false;
			}
		}
	}

	return true;
}

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

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

		if (n == 0) {
			break;
		}

		vector<string> words(n);
		for (int i = 0; i < n; i++) {
			cin >> words[i];
		}

		cout << (solve(n, words) ? "OK" : "NG") << endl;
	}
	return 0;
}



Measured memory_bytes: 3692
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	n=RD()
	k=II()

	dp=[[[0]*2 for _ in range(k+2)] for _ in range(len(n)+1)]
	#print(dp)

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

	for i in range(len(n)):
		now=int(n[i])
		for j in range(k+1):
			#print(i,j,now)
			dp[i+1][j+(now!=0)][0]+=dp[i][j][0]
			dp[i+1][j][1]+=dp[i][j][1]+dp[i][j][0]*(now!=0)
			dp[i+1][j+1][1]+=dp[i][j][1]*9+dp[i][j][0]*(now-1 if now>0 else 0)
		#print(dp)
	print(dp[len(n)][k][0]+dp[len(n)][k][1])

















if __name__ == "__main__":
	main()


Measured memory_bytes: 9328
n = gets.to_i

s = Array.new(3)
s[0] = gets.chomp
s[1] = gets.chomp
s[2] = gets.chomp

ans = 0
for i in 0...n
    a = s[0][i]
    b = s[1][i]
    c = s[2][i]
    
    same = 0
    same += 1 if a == b
    same += 1 if b == c
    same += 1 if c == a

    if same == 0
        ans += 2
    elsif same == 1
        ans += 1
    else

    end
end

puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9 + 7;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int x = 0;
  rep(i, n) {
    cin >> a[i];
    x ^= a[i];
  }
  vector<int> b(n);
  rep(i, n) b[i] = x^a[i];
  print_vec(b);
  return 0;
}

Measured memory_bytes: 5448
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
//int b=scan.nextInt();
//int c=scan.nextInt();
int ans=0;
if(a==7||a==5||a==3) {
 ans=1;
}
if(ans==1) {
System.out.println("YES");
}
else {
	
	System.out.println("NO");
}
}
}


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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    int N, M; cin >> N >> M;
    vector<int> x(M), y(M); rep(i, M) cin >> x[i] >> y[i];

    vector<int> B(N + 1, 1);
    vector<bool> R(N + 1, false);
    R[1] = true;
    int a, b;
    rep(i, M) {
        a = x[i]; b = y[i];
        B[a]--; B[b]++;
        if (R[a]) {
            R[b] = true;
            if (B[a] == 0) R[a] = false;
        }
    }
    int ans = 0;
    rep(i, N + 1) if (R[i]) ans++;
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 4300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve(ll n, vl a);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n;
    cin >> n;
    vl a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    solve(n, move(a));
}

void solve(ll n, vl a){
    sort(all(a));

    ll val=0;
    rep(i,n-1)chmax(val,min(a[i],a[n-1]-a[i]));

    rep(i,n-1){
        if(val==min(a[i],a[n-1]-a[i])){
            cout<<a[n-1]<<' '<<a[i]<<endl;
            return;
        }
    }
}



Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 100010
ll d[N],n;
typedef pair<ll,ll> P;
P a[N],b[N];
vector<P> v[N];
void Dijkstra(){
    lol(i,N)d[i]=1e18;
    priority_queue<P,vector<P>,greater<P> >Q;
    Q.push(make_pair(0,0));
    while(!Q.empty()){
	ll x=Q.top().second;
	ll cost=Q.top().first;
	Q.pop();
	if(d[x]<=cost)continue;
	d[x]=cost;
	for(auto y:v[x]){
	    Q.push(make_pair(cost+y.second,y.first));
	}
    }
}
void ME(ll a,ll b,ll cost){
    v[a].push_back(make_pair(b,cost));
    v[b].push_back(make_pair(a,cost));
}
int main(){
    cin>>n;
    lol(i,n){cin>>a[i].first; a[i].second=i;}
    lol(i,n){cin>>b[i].first; b[i].second=i;}
    sort(a,a+n); sort(b,b+n);
    lol(i,n-1){
	ME(a[i].second,a[i+1].second,a[i+1].first-a[i].first);
	ME(b[i].second,b[i+1].second,b[i+1].first-b[i].first);
    }
    Dijkstra();
    lol(i,n)cout<<d[i]<<endl;
    return 0;
}



Measured memory_bytes: 21840
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN = 50;

int n;
char have[MAXN + 1];
char want[] = "AKIHABARA";

void run() {
	scanf("%s", have); n = strlen(have);
	int nwant = strlen(want);
	int at = 0;
	REP(i, nwant) {
		if (at < n&&have[at] == want[i]) { ++at; continue; }
		if (want[i] == 'A') continue;
		printf("NO\n"); return;
	}
	printf("%s\n", at >= n ? "YES" : "NO");
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

fn main() {
    let x = read_i64();
    if x < 1200 {
        println!("ABC");
    }
    else if 1200 <= x && x < 2800 {
        println!("ARC");
    }
    else {
        println!("AGC");
    }
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}

#[allow(dead_code)]
fn tf<T>(cond: bool, t: T, f: T) -> T {
    if cond { t } else { f }
}


Measured memory_bytes: 4352
# Field
module Field
  def self.search_square(grid, x, y)
    dp = Array.new(1000) { Array.new(1000, 0) }
  
    for i in 0...grid.size
      for j in 0...grid[i].size
        if grid[i][j] == '*'
          dp[i][j] = 0
        else
          if i > 0 && j > 0
            dp[i][j] = [dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]].min + 1
          else
            dp[i][j] = 1
          end
        end
      end
    end

    dp.flatten.max
  end
end

while line = gets
  n = line.chomp.to_i
  break if n == 0

  grid = []
  n.times do
    grid << gets.chomp.split('')
  end

  puts Field::search_square(grid, 0, 0)
end

Measured memory_bytes: 129056
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp
 
using namespace std;
 
typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ちゃんとユニークな配列にする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
 
int main() {
  int H, W;
  cin >> H >> W;
  ll C[10][10] = {0};
  int A[200][200] = {-1};
  rep(i, 10) {
    rep(j, 10) {
      cin >> C[i][j];
    }
  }
  rep(i, H) {
    rep(j, W) {
      cin >> A[i][j];
    }
  }
 
  // 同じならコスト0
  rep(i, 10) {
    C[i][i] == 0;
  }
 
  // ワーシャルフロイドでコストを最小化
  rep(k, 10) {
    rep(i, 10) {
      rep(j, 10) {
        C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
      }
    }
  }
 
  // デバッグで表示
  // DEBUG("optimized");
  // rep(i, 10) {
  //   rep(j, 10) {
  //     cout << C[i][j] << " ";
  //   }
  //   cout << endl;
  // }
 
  ll sumCost = 0;
  rep(i, H) {
    rep(j, W) {
      int a = A[i][j];
      if (a != -1 && a != 1) {
        sumCost = sumCost + C[a][1];
      }
    }
  }
 
  cout << sumCost << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n, m;
    cin >> n >> m;
    vector<int> l(m);
    vector<int> r(m);
    for(int i = 0; i < m; i++) cin >> l[i] >> r[i];
    int maxl = 1;
    int minr = n;
    for(int i = 0; i < m; i++){
        maxl = max(maxl,l[i]);
        minr = min(minr,r[i]);
    }
    int ans = minr - maxl + 1;
    ans = max(ans, 0);
    cout << ans;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 文字列の入力
		String s = sc.next();
    
		// 出力
		System.out.println(check(s) ? "AC" : "WA");
	}
    public static boolean check(String value) {
      ArrayList<Integer> list = new ArrayList<>();
      for(int i = 0; i < value.length(); i++) {
        if (Character.isUpperCase(value.charAt(i))) {
          list.add(i);
        }
      }
      if (list.size() != 2) {
        return false;
      }
      if (list.get(0) != 0) {
        return false;
      }
      if (list.get(1) < 2 || list.get(1) > value.length() - 2) {
        return false;
      }
      if (!String.valueOf(value.charAt(0)).equals("A")) {
        return false;
      } 
      return String.valueOf(value.charAt(list.get(1))).equals("C");
   }
      
}


Measured memory_bytes: 22736
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;int t=0;
   cin >> a >> b >> c;
    t=a;
   a=b;
    b=t;
    t=c;
    c=a;
    a=t;

    cout << a << " " << b << " " << c << endl;
    return 0;

}


Measured memory_bytes: 3640
#include <iostream>
#include <deque>
#include <queue>
#include <vector>
#include <cmath>

using namespace std;

int maxnum = 0;

int N,K;

void iter(deque<int> v,priority_queue<int> neg,int score,int num,bool flag){
  int negsum = 0;
  priority_queue<int> tmp = neg;
  int numfor = neg.size();
  if(numfor > K-num){
    numfor = K - num;
  }
  for(int i=0;i<numfor;i++){
    negsum = negsum + tmp.top();
    tmp.pop();
  }
  //cout << "neg:" << num << endl;
  //cout << score << endl;
  if(score + negsum > maxnum){
    maxnum = score + negsum; 
  }
  if(v.size() <= 0 || num >= K){
    if(score > maxnum){
      maxnum = score;
    }
    return;
  }

  //左
  if(flag){
  int l = v.front();
  int score_l = score + l;
  priority_queue<int> vl = neg;
  deque<int> tmpL = v;
  tmpL.pop_front();
  if(l < 0){
    vl.push(-l);
  } 
  iter(tmpL,vl,score_l,num+1,true);
  }
    //右
  int r = v.back();
  int score_r = score + r;
  priority_queue<int> vr = neg;
  deque<int> tmpR = v;
  tmpR.pop_back();
  if(r < 0){
    vr.push(-r);
  }
  iter(tmpR,vr,score_r,num+1,false);
  
  return;
}

int main(void){
  priority_queue<int> neg;
  deque<int> v;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
  iter(v,neg,0,0,true);
  cout << maxnum << endl;
  return 0;
}


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

int main(void) {
	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> c(n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	for (int i = 0; i < n; i++) {
		if (v[i] - c[i] > 0) ans += v[i] - c[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
char op;
int a,b;
int c;
for(;;)
{
scanf("%d %c %d",&a,&op,&b);
if(op=='+')
{
c=a+b;
}
else if(op=='-')
{
c=a-b;
}
else if(op=='*')
{
c=a*b;
}
else if(op=='/')
{
c=a/b;
}
else
{
break;
}
printf("%d\n",c);
}
return 0;
}

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

int main() {
  int A, B, cnt=0;
  cin >> A >> B;
  for(int i=A; i<=B; i++) {
  	int x1 = i%10;
    int x2 = (i%100)/10;
    int x4 = (i/1000)%10;
    int x5 = i/10000;
    if (x1==x5 && x2==x4) cnt++;
  }
  cout << cnt << endl;
}

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

int n, m;
int t[8];
vector<int> ans_perm;

vector<int> getPerm(int *ar){
  vector<int> res;
  for(int i = 0; i < n; i++){
    res.push_back(i);
  }
  for(int i = 0; i < m; i++){
    int idx = ar[i] - 1;
    swap(res[idx], res[idx + 1]);
  }
  return res;
}

int getHeight(int *ar){
  int res = 1;
  vector<int> pre;

  for(int i = 0; i < m; i++){
    bool flg = true;
    for(int j = 0; j < pre.size(); j++){
      if(pre[j] == ar[i] || pre[j] + 1 == ar[i] ||
         pre[j] == ar[i] + 1 || pre[j] + 1 == ar[i] + 1){
        flg = false;
        break;
      }
    }

    if(flg){
      pre.push_back(ar[i]);
    }
    else{
      pre.clear();
      pre.push_back(ar[i]);
      res++;
    }
  }

  return res;
}

void solve(){
  ans_perm = getPerm(t);
  int ans = m;

  sort(t, t + m);

  do{
    vector<int> perm = getPerm(t);
    if(perm != ans_perm) continue;

    int h = getHeight(t);
    ans = min(ans, h);
  }while(next_permutation(t, t + m));

  cout << ans << endl;
}

int main(){
  while(cin >> n >> m){
    for(int i = 0; i < m; i++){
      cin >> t[i];
    }
    solve();
  }
}

Measured memory_bytes: 1224
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long LL;

vector<LL> v;

void dfs(int digits, LL x)
{
	v.push_back(x);
	if(digits >= 9) return;
	int r = x % 10LL;
	x = x * 10 + r;
	dfs(digits + 1, x);
	if(r > 0) dfs(digits + 1, x - 1);
	if(r < 9) dfs(digits + 1, x + 1);
}

int main(int argc, char** argv)
{
	for(int i=1; i<10; i++) dfs(0, i);
	sort(v.begin(), v.end());
	int k;
	scanf("%d", &k);
	printf("%lld", v[k - 1]);
	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define mod 1000000007
ll Pow(ll a, ll n) {
    if (n == 0) return 1;
    if (n % 2) return (a * Pow(a, n - 1)) % mod;
    else {
        ll k = Pow(a, n / 2);
        return (k * k) % mod;
    }
}
ll gyakusuu[2001];
ll nCk(ll n, ll k) {
    ll ret = 1;
    for (ll i = 1; i <= k; i++) {
        ret = ret * (n - k + i) % mod;
        ret = ret * gyakusuu[i] % mod;
    }
    return ret;
}

int main() {
    int n;
    int k;
    cin >> n >> k;
    for (int i = 1; i <= 2000; i++) {
        gyakusuu[i] = Pow(i, mod - 2);
    }
    for (int i = 1; i <= k; i++) {
        cout << nCk(k - 1, i - 1) * nCk(n - k + 1, i) % mod << endl; 
    }
    return 0;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

int main()
{
  char s[20];
  scanf("%s",s);
  string res="ABC";
  cout<<res+s;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[100005],b[100005];
int main()
{
    cin>>n;
    for(int i=0;i<n;++i)scanf("%d",a+i);
    for(int i=0;i<n;++i)scanf("%d",b+i);
    //sort(a,a+n);
    //sort(b,b+n);
    long long could=0;
    for(int i=0;i<n;++i){
        if(b[i]>a[i])could+=(b[i]-a[i])/2;
        else could-=a[i]-b[i];
    }
    //cout<<could<<endl;
    if(could>=0)puts("Yes");
    else puts("No");
}


Measured memory_bytes: 384
#include <stdio.h>

int main()
{

    int a;
    int b;

    
    int n[101];
    int deta[101];

    scanf("%d", &a);
    scanf("%d", &b);

    for (int i = 0; i <= 100; i++)
    {
        deta[i] = 0;//で初期化
    }

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

    for (int i = 0; i <= 100; i++)
    {
        if(a-i>=0){//0よりでかい
        if(deta[a-i]==0){
            printf("%d", a - i);
            break;
        }
        }
        if(a+i==101){
            printf("%d", 101);
            break;
        }
        if (a + i <= 100)
        { //100より
            if (deta[a + i] == 0)
            {
                printf("%d", a + i);
                break;
            }
        }
    }

    printf("\n");
}

Measured memory_bytes: 2168
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let m:usize = read();
    let st:Vec<(i64, i64)> = (0..n).map(|_| (read(), read())).collect();
    let cp:Vec<(i64, i64)> = (0..m).map(|_| (read(), read())).collect();
    for (x1, y1) in st {
        let mut dist = std::i64::MAX;
        let mut ans = 0;
        for i in 0..m {
            let x2 = cp[i].0;
            let y2 = cp[i].1;
            if (x1 - x2).abs() + (y1 - y2).abs() < dist {
                dist = (x1 - x2).abs() + (y1 - y2).abs();
                ans = i + 1;
            }
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 2084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC091A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            if (a + b >= c)
                Console.WriteLine("Yes");

            else
                Console.WriteLine("No");

            Console.ReadKey();
        }
    }
}



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

using namespace std;
using ll = long long;

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll a1, a2, a3;
    cin >> a1 >> a2 >> a3;

    if(a1+a2+a3>=22){
        _PR("bust");
    }else{
        _PR("win");
    }

    return 0;
}

/*



*/

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
using namespace std;

const int MaxN = 1e5 + 6;
typedef long long LL;

int main(){
	int a, b;
	cin>>a>>b;
	cout<<(a-1)*(b-1)<<endl;
	return 0;
}

Measured memory_bytes: 256