akhauriyash/Code-Regression huggingface dataset:
object Main extends App {

  val words = Seq("the", "this", "that")
  def caesar(ch: Char): Char = ch match {
    case 'a' => 'b'
    case 'b' => 'c'
    case 'c' => 'd'
    case 'd' => 'e'
    case 'e' => 'f'
    case 'f' => 'g'
    case 'g' => 'h'
    case 'h' => 'i'
    case 'i' => 'j'
    case 'j' => 'k'
    case 'k' => 'l'
    case 'l' => 'm'
    case 'm' => 'n'
    case 'n' => 'o'
    case 'o' => 'p'
    case 'p' => 'q'
    case 'q' => 'r'
    case 'r' => 's'
    case 's' => 't'
    case 't' => 'u'
    case 'u' => 'v'
    case 'v' => 'w'
    case 'w' => 'x'
    case 'x' => 'y'
    case 'y' => 'z'
    case 'z' => 'a'
    case x => x
  }

  def isDecoded(input: String): Boolean = {
    val arr = input.split(' ')
    arr.foreach { a =>
      if (a == words(0) || a == words(1) || a == words(2)) {
        return true
      }
    }
    return false
  }

  def loop(input: String): String = {
    if (isDecoded(input)) {
      println(input)
      input
    }
    else {
      loop(input map caesar)
    }
  }

  val sc = new java.util.Scanner(System.in)
  while(sc.hasNext()) {
    loop(sc.nextLine())
  }

}

Measured memory_bytes: 44888
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;

#define ll long long

int main(){
    ll A,B,C;
    ll r=0,b=0;
    string S;
    ll ans = 1e9;
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == '1')b++;
        else r++;
    }
    ans = 2 * min(r,b);
    cout << ans << endl;
    
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
      	if(a==1) a+=13;
      	if(b==1) b+=13;
      	String ans = "Draw";
      	if(a>b) ans = "Alice";
      	if(a<b) ans = "Bob";
      	System.out.println(ans);
	}
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n], maxi = 0;
    rep(i, n) {
        cin >> a[i];
        maxch(maxi, a[i]);
    }

    string ans = "Impossible";
    if (n == 2 && a[0] == 1 && a[1] == 1) {
        ans = "Possible";
    } else if (n > 2 && maxi > 1) {
        int exist[n] = {};
        rep(i, n) {
            exist[a[i]]++;
        }
        bool ok = true;
        if (maxi % 2 == 0) {
            repl(i, maxi / 2, maxi + 1) {
                if (i == maxi / 2 && exist[i] != 1) ok = false;
                else if (i > maxi / 2 && exist[i] < 2) ok = false;
            }
            rep(i, maxi / 2) if (exist[i] > 0) ok = false;
        } else {
            repl(i, (maxi / 2) + 1, maxi + 1) {
                if (i == (maxi / 2) + 1 && exist[i] != 2) ok = false;
                if (i > (maxi / 2) + 1 && exist[i] < 2) ok = false;
            }
            rep(i, maxi / 2) if (exist[i] > 0) ok = false;
        }
        if (ok) ans = "Possible";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 380
N = int(input())
D, X = map(int, input().split())
A = [int(input()) for i in range(N)]

sum = 0

for i in range(N):
  chocoN = 0
  for k in range(D):
    if k*A[i]+1 <= D:
      chocoN = chocoN + 1
  sum = sum + chocoN

print(sum + X)


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

using namespace std;

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

	vector<int> vi;
	int res = 0;

	for (int i = 0; i < N; i++) {
		int p;
		cin >> p;
		res ^= p;
		vi.push_back(p);
	}

	for (int i = 0; i < N; i++) {
		int ans = res ^ vi[i];
		cout << ans << " ";
	}
}


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

  cin >> n;
  if(n%2==0) cout << n/2;
  else cout << 1+(n/2);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


string s;
int n;
map<string,bool> mp;

int main(){
  cin>>s>>n;
  int m=s.size();

  rep(i,m){
    string t={};
    for(int j=i;j<i+10&&j<m;j++){
      t =t+s[j];
      mp[t]=true;
    }
  }

  int c=0;

  for(auto itr=mp.begin();itr!=mp.end();itr++,c++){
    if(c==n-1){
      cout<<itr->first<<endl;
      break;
    }
  }

  return 0;
}



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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
void print_line(vector<ll> &line) {
    for (int i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<double> x(n);
    vector<double> y(n);

    rep(i, n) cin >> x[i];
    rep(i, n) cin >> y[i];

    {
        // p = 1
        double sum = 0;
        rep(i, n) {
            sum += abs(x[i] - y[i]);
        }
        printf("%.10f\n", sum);
    }

    {
        // p = 2
        double sum = 0;
        rep(i, n) {
            double distance = abs(x[i] - y[i]);
            distance *= distance;
            sum += distance;
        }
        double ans = sqrt(sum);
        printf("%.10f\n", ans);
    }

    {
        // p = 3
        double sum = 0;
        rep(i, n) {
            double distance = abs(x[i] - y[i]);
            distance = pow(distance, 3.0);
            sum += distance;
        }
        double ans = pow(sum, 1.0 / 3);
        printf("%.10f\n", ans);
    }

    {
        // p = ∞
        double sum = 0;
        rep(i, n) {
            double distance = abs(x[i] - y[i]);
            cmax(sum, distance);
        }
        printf("%.10f\n", sum);
    }

}


Measured memory_bytes: 3416
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		if (get<1>(a) < get<1>(b))return true;
		else if (get<1>(a) == get<1>(b))return (get<0>(a) < get<0>(b));
		else return false;
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll h, w, n;
	cin >> h >> w >> n;
	vl x(n), y(n);
	vector<tii> v(n);
	rep(i, n) {
		cin >> x[i] >> y[i];
		x[i]--;
		y[i]--;
		v[i]=(tii(y[i], x[i]));
	}
	sort(all(v), compare());
	v.push_back(tii(-1, h));
	int pos = -1;
	rep(i, v.size()) {
		//cout << get<0>(v[i]) <<" "<<get<1>(v[i]) << endl;
	}
	rep(i, v.size()) {
		int dif = get<1>(v[i]) - get<0>(v[i]);
		//cout << dif << endl;
		if (dif - pos >= 2) {
			cout << get<1>(v[i]) << endl;
			return 0;
		}
		else pos = max(pos, dif);
	}
}



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

int main() {
  int64_t N, a0, b1, c2;
  cin >> N;
  vector<vector<int64_t>> dp(N, vector<int64_t>(3, 0));

  cin >> a0 >> b1 >> c2;
  dp.at(0).at(0)=a0;
  dp.at(0).at(1)=b1;
  dp.at(0).at(2)=c2;
  
    for (int i=1; i<N; i++) {
      cin >> a0 >> b1 >> c2;
        for (int j=0; j<3; j++) {
          if (j==0) {
            dp.at(i).at(j)=a0 + max(dp.at(i-1).at(1), dp.at(i-1).at(2));
          }
          if (j==1) {
            dp.at(i).at(j)=b1 + max(dp.at(i-1).at(0), dp.at(i-1).at(2));
          }
          if (j==2) {
            dp.at(i).at(j)=c2 + max(dp.at(i-1).at(0), dp.at(i-1).at(1));
          }
        }
    }
  cout << max(dp.at(N-1).at(0), max(dp.at(N-1).at(1), dp.at(N-1).at(2))) << endl;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define ll long long 
#define OJ \
        freopen("input.txt","r",stdin); \
        freopen("output.txt","w",stdout);
using namespace std;
int main()
{
//	OJ;
int a[5],ans=0;
for(int i=0;i<5;i++)
{
 cin>>a[i];
 if(a[i]==0)
 {
ans=i+1;
 }
}
cout<<ans;
}

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

const int inf = 1e9;
const ll linf = 1e18;

int main()
{
    int n; cin >> n;
    vector<int> a(n+2, 0);
    for (int i = 1; i <= n; i++) cin >> a[i];
    
    vector<int> l(n+2, 0), r(n+2, 0);
    for (int i = 1; i <= n; i++) l[i] = l[i-1] + abs(a[i-1] - a[i]);
    for (int i = n; i >= 1; i--) r[i] = r[i+1] + abs(a[i+1] - a[i]);

    for (int i = 1; i <= n; i++) {
        cout << l[i-1] + abs(a[i-1] - a[i+1]) + r[i+1] << '\n';
    }
    return 0;
}

Measured memory_bytes: 2432
integer N,L
integer ans
read*,N,L
ans=0
do i=1,N
  ans=ans+(L+i-1)
end do
if((L+1-1)*(L+N-1)>0)then
  if(L<0)then
    ans=ans-(L+N-1)
  else
    ans=ans-L
  endif
endif

print"(i0)",ans

end

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define db double
#define ll long long
#define X first
#define Y second
#define pii pair<int, int>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define REP(i, y) rep(i, 0, y - 1)
#define pb push_back
#define mp make_pair
using namespace std;
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int a[100010];
int main()
{
	int n = read();
	rep(i, 1, n)
	{
		int x = read();
		a[x] ++;
	}
	int ans = 0;
	rep(i, 1, 100000)
		ans = max(ans, a[i - 1] + a[i] + a[i + 1]);
    cout << ans;
	return 0;
}


Measured memory_bytes: 640
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

int[][10^^5] T;

void main()
{
    auto N = readln.chomp.to!int;
    foreach (b; 1..N) {
        auto a = readln.chomp.to!int - 1;
        T[a] ~= b;
    }

    int solve(int i) {
        int[] rr;
        foreach (j; T[i]) {
            rr ~= solve(j);
        }
        sort!"a > b"(rr);
        int max_r;
        foreach (j, r; rr) {
            max_r = max(max_r, r + j.to!int + 1);
        }
        return max_r;
    }
    writeln(solve(0));
}

Measured memory_bytes: 20220
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
Scanner s = new Scanner(System.in);
		int N = Integer.valueOf(s.next());
		int[] A = new int[N];
		int trend = 0; // 0 = down, 1 = -, 2 = up
		List<int[]> list = new ArrayList<>(); // 0=buy or sell, 1=index
		A[0] = Integer.valueOf(s.next());
		for(int i = 1; i < N; i++) {
			A[i] = Integer.valueOf(s.next());
			if(A[i] > A[i-1]) {
				if(trend == 0) list.add(new int[]{0, i-1}); // 0 = buy
				trend = 2;
			} else if(A[i] < A[i-1]) {
				if(trend == 2) list.add(new int[]{1, i-1}); // 0 = buy
				trend = 0;
			}
		}

		long money = 1000;
		if(list.isEmpty()) {
			if(trend == 2) {
				int stock = 1000 / A[0];
				int amari = 1000 - stock * A[0];
				money = amari + stock * A[N-1];
			}
		}else {
			for(int i = 0; i < list.size(); i++) {
				int[] cur = list.get(i);
				// 売る場合
				if(cur[0] == 1) {
					int index = (i == 0 ? 0 : list.get(i-1)[1]);
					long stock = money / A[index];
					long amari = money - A[index] * stock;
					money = amari + stock * A[cur[1]];
				}
			}

			if(list.get(list.size()-1)[0] == 0) {
				int index = list.get(list.size()-1)[1];
				long stock = money / A[index];
				long amari = money - A[index] * stock;
				money = amari + stock * A[N-1];
			}
		}
		System.out.println(money);
	}
}

Measured memory_bytes: 35664
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit
#include <cstdio>	// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define DEBUG 1

using namespace std;

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

const int mod = 100000;
int t[210][105][2];	// 偶数行は、横の辺、奇数行は縦の辺 
						// 第３引数は 	0 は次で曲がれない 
						//				1 で次で曲がれる状態
int main()
{
//	freopen ("testcase.cr", "r", stdin );

	int w, h;
	while (scanf ("%d %d", &w, &h ), w, h ){

		if (w == 1 || h == 1 ){
			printf ("1\n" );
			continue;
		} // end i

		memset (t, -1, sizeof (t ) );
		// 西端の南北の道路の状態
		for (int i = 1; i < 2*h-1; i += 2 ){
			t[i][0][0] = 0; t[i][0][1] = 1;
		} // end for
		// 南端の陶材の道路の状態
		for (int j = 0; j < w-1; j++ ){
			t[0][j][0] = 0; t[0][j][1] = 1;
		} // end for
		for (int j = 1; j <= w; j++ ){
			t[1][j][0] = 1; t[1][j][1] = 0;
		} // end for
		for (int i = 2; i < 2*h-1; i += 2 ){
			t[i][0][0] = 1; t[i][0][1] = 0;
		} // end for
		for (int i = 2; i < 2*h-1; i++ ){
			// 横辺の場合
			if (i % 2 == 0 ){
				for (int j = 1; j < w-1; j++ ){
					t[i][j][0] = t[i-1][j][1];
					t[i][j][1] = (t[i][j-1][0] + t[i][j-1][1] ) % mod;
				} // end for
			}else{ // 縦辺の場合
				for (int j = 1; j < w; j++ ){
					t[i][j][0] = t[i-1][j-1][1];
					t[i][j][1] = (t[i-2][j][0] + t[i-2][j][1] ) % mod;
				} // end for
			} // end if
		} // end for
		int res = 0;
		rep (k, 2 ){
			res = (res + t[2*h-2][w-2][k] ) % mod;
			res = (res + t[2*h-3][w-1][k] ) % mod;
		} // end rep
		printf ("%d\n", res );
	} // end loop

	return 0;
}

Measured memory_bytes: 1368
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;


int main() {
  int n, C;
  cin >> n >> C;
  vector<vector<int>> d(C, vector<int>(C));
  vector<vector<int>> c(n, vector<int>(n));
  rep(i, C) rep(j, C) {
    cin >> d[i][j];
  }
  vector<vector<int>> cnt(3, vector<int>(C));
  rep(i, n) rep(j, n) {
    int t;
    cin >> t;
    --t;
    c[i][j] = t;
    int s = (i + j) % 3;
    cnt[s][t]++;
  }

  int ans = INF;
  rep(i, C)rep(j, C)if(i != j)rep(k, C) {
    if(j == k || k == i) continue;
    int t = 0;
    rep(x, 3) rep(y, C) {
      int next;
      if(x == 0) next = i;
      else if (x == 1) next = j;
      else next = k;
      t += cnt[x][y] * d[y][next];
    }
    ans = min(ans, t);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod (ll)1000000007
#define fast std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define input int t;cin>>t;while(t--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define f(i, a, b) for (int i = (a); i < (b); i++)
#define fr(i, a, b) for (int i = (a); i >= (b); i--)
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define all(x) x.begin(), x.end()
#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define PI 3.1415926535897932384626433
int i,j,k;
int main()
{
	cini(k);
	cins(s);
	if(s.size()<=k)
		cout<<s;
	else
	{
		for(i=0; i<k; i++)
			cout<<s[i];
		cout<<"...";
	}

}


Measured memory_bytes: 3624
#include <stdio.h>
  int main(){
     int i, n;
     int arr[100];
     scanf("%d", &n);
     for(i=0;i<n;i++){
         scanf(" %d", &arr[i]);
     }
     for(i=0;i<n;i++){
         if(i)printf(" ");
         printf("%d", arr[n-i-1]);
     }
     printf("\n");
     return 0;
 }


Measured memory_bytes: 2088
n,m = map(int,input().split())
INF = 10**10

B = [INF]*(1<<n)
B[0] = 0

for _ in range(m):
  a,b = map(int,input().split())
  C = list(map(int,input().split()))
  opens = 0
  for c in C:
    opens |= (1<<(c-1))
  
  for i in range(2**n):
    if B[i|opens] > B[i]+a:
      B[i|opens] = B[i]+a

if B[(1<<n)-1]==INF:
  print(-1)
else:
  print(B[(1<<n)-1])

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


using LL = long long int;
using uLL = unsigned long long int;
using uint = unsigned int;
using ld = long double;

//const int MAXN = (1<<14);
const int N = 100007;
const int INF = 10000007;


int h[N], dp[N];
/*int tree[2][2*MAXN+7], h[N], dp[N];

void fill_tree(){
    for(int i = 0; i <= 2*MAXN; i++){
        tree[0][i] = INF;
    }
    for(int i = 0; i <= 2*MAXN; i++){
        tree[1][i] = INF;
    }
}

void add(int a, int val, int pam){
    a += MAXN;
    tree[pam][a] = val;
    a >>= 1;
    while(a > 0){
        tree[pam][a] = min(tree[pam][(a<<1)], tree[pam][(a<<1)+1]);
        a >>= 1;
    }
}
int query(int a, int b, int pam){
    a += MAXN;
    b += MAXN;
    int res = INF;
    while(a <= b){
        if((a&1) == 1) res = min(res, tree[pam][a]);
        if((b&1) == 0) res = min(res, tree[pam][b]);
        a = ((a+1)>>1);
        b = ((b-1)>>1);
    }
    return res;
}*/

int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    //fill_tree();
    for(int i = 1; i <= n; i++){
        cin >> h[i];
    }
    /*add(h[n], -h[n], 0);
    add(h[n], h[n], 1);
    for(int i = n-1; i > 0; i--){
        int x = query(1, h[i], 0);
        int y = query(h[i], MAXN-1, 1);
        cout << x << " " << y << " ";
        dp[i] = min(h[i]+x, y-h[i]);
        cout << -h[i]+dp[i] << " " << h[i]+dp[i] << " ";
        add(h[i], -h[i]+dp[i], 0);
        add(h[i], h[i]+dp[i], 1);
        cout << dp[i] << '\n';
    }*/
    dp[n+1] = INF;
    for(int i = n-1; i > 0; i--){
        dp[i] = min(abs(h[i+1]-h[i])+dp[i+1], abs(h[i+2]-h[i])+dp[i+2]);
    }
    cout << dp[1] << '\n';
    
    
    return 0;
}

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

int main(void){
  int n;
  vector<int> a(100);
  cin >> n;
  for(int i = 0; i < n; i++)cin >> a[i];
  for(int i = n - 1; i >= 0; i--){
    cout << a[i];
    if(i != 0)cout << ' ';
  }
  cout << endl;
  return 0;
}


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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pii pair<int, int>
#define sz size()

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>void __f(const char* name, Arg1&& arg1){cout<<name<<" : "<<arg1<<"\n";}
template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args)
{const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" , ";__f(comma+1, args...);} 
#define traceloop(x,a) { cerr<<#a<<": "; for(ll ix=0;ix<x;ix++) cerr<<a[ix]<<" "; cerr<<endl; }

vector<int> st, a;

void update(int node, int l, int r, int i, int val)
{
	if(l>r or l>i or r<i)
		return;

	if(l==r and l==i)
	{
		st[node] = val;
		return;
	}

	int mid = (l+r)/2;
	update(2*node+1, l, mid, i, val);
	update(2*node+2, mid+1, r, i, val);

	if(a[st[2*node+1]] > a[st[2*node+2]])
		st[node] = st[2*node+1];
	else
		st[node] = st[2*node+2];
}

int query(int node, int l, int r, int i, int j)
{
	if(l>r or l>j or r<i)
		return 0;

	if(i<=l and r<=j)
		return st[node];

	int mid = (l+r)/2;

	int q1 = query(2*node+1, l, mid, i, j);
	int q2 = query(2*node+2, mid+1, r, i, j);

	return (a[q1] > a[q2]) ? q1 : q2 ;
}

int main()
{
	ios::sync_with_stdio(0);

	int n, i, j, m;
	cin>>n>>m;
	vector<pii> v;
	for(i=0;i<n;++i)
	{
		int u, v1;
		cin>>u>>v1;
		v.pb({u, -v1});
	}

	vector<int> b;
	a.resize(n+2, 0);
	b.resize(n+2, 0);
	sort(v.begin(), v.end());


	for(i=1;i<=n;++i)
	{
		a[i] = -v[i-1].second;
		b[i] = v[i-1].first;
		//trace(i, a[i], b[i]);
	}

	st.resize(4 * int(a.sz));
	for(i=0;i<n;++i)
		update(0, 0, n, i+1, i+1);


	i = j = 0;
	ll ans = 0;
	for(i=1;i<=m;++i)
	{
		while(j <= n and b[j] <= i){
			j++;
		}
		j--;

		int q = query(0, 0, n, 1, j);
		//trace(i, j, q, a[q], b[q]);
		ans += a[q];
		update(0, 0, n, q, 0);
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3444
/*author : Yashvardhan
Sunday, April 26, 2020
5:30 PM
*/
 
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
 
#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))
 
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
 
#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif
 
template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}
 
const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;
 
int takemod(int a){return ((a%mod)+mod)%mod;}
 
int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}
 
int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}
 
 
signed main()
{
 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
 
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif
 
	time_t t1, t2;
	t1 = clock();
	
	int s,w;
	cin >> s >> w;
 
	if(w >= s) cout << "unsafe" << endl;
	else cout << "safe" << endl;
	
 
	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}

Measured memory_bytes: 3652
N,M = map(int,input().split())
d = {}
for _ in range(N):
    a,b = map(int,input().split())
    if not a in d.keys():
        d[a] = b
    else:
        d[a] += b
#print(d)
cost = 0
for c in sorted(d.keys()):
    #print(c,d[c])
    if M < d[c]:
        cost += c * M
        break
    else:
        cost += c * d[c]
        M -= d[c] 
print(cost)

Measured memory_bytes: 17884
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;

    ll n,a[200010];
    ll ans=0;
    cin>>n;
    rep(i,n){
        cin>>a[i];
        a[i]-=(i+1);
        ans+=abs(a[i]);
    }
    sort(a,a+n);
    ll s;
    if(n%2==0){
        s=(a[n/2]+a[n/2-1])/2;
        ll cnt=0;
        rep(i,n){
            cnt+=abs(a[i]-s);
        }
        // cout<<s<<" "<<cnt<<endl;
        ans=min(ans,cnt);
        // cout<<ans<<endl;
        if((a[n/2]+a[n/2-1])%2!=0){
            s++;cnt=0;
            rep(i,n){
                cnt+=abs(a[i]-s);
            }
            ans=min(ans,cnt);
        }
    }
    else{
        s=a[n/2];
        ll cnt=0;
        rep(i,n){
            cnt+=abs(a[i]-s);
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;
const ll mod = 998244353;

int main()
{
  ll n; cin>>n;
  vector<ll> a(n);
  rep(i, n) cin>>a[i];
  sort(a.begin(),a.end());

  ll ans = n;
  ll sum = 0;
  rep(i, n-1) {
    sum += a[i];
    if (2*sum < a[i+1]) {
      ans = n-i-1;
    }
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, Q;
    cin >> N >> Q;

    string S;
    cin >> S;

    vector<int> ans(N+1, 0);
    for (int i = 1; i <= N; i++) {
        ans[i] = ans[i-1];
        if (S[i-1] == 'A' && S[i] == 'C') {
            ++ans[i];
        }
    }

    int l, r;
    for (int i = 0; i < Q; i++) {
        cin >> l >> r;
        cout << ans[r-1] - ans[l-1] << endl;
    }

    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
  int N; cin >> N;
  vector<int> x(N), y(N); REP(i, N) cin >> x[i] >> y[i];
  vector<int> array(N); REP(i, N) array[i] = i + 1;

  int math = 0;
  double tmp = 0;
  do{
    math++;
    for(int i = 0; i < array.size() - 1; i++){
      tmp += sqrt(pow(x[array[i] - 1] - x[array[i + 1] - 1] ,2) + pow(y[array[i] - 1] - y[array[i + 1] - 1] ,2));
    }
  } while(next_permutation(all(array)));

  double ans = tmp / math;
  cout << std::fixed << std::setprecision(15) << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;
 
const int maxN = 1 << 13;
 
int pref[maxN][400];
char T[maxN];
 
void solve()
{
	int n;
	scanf ("%d %s", &n, T+1);
	FOR(i, 1, n+1)
	{
		for (char c : {'R', 'G', 'B'})
			pref[i][c] = pref[i-1][c];
		pref[i][T[i]]++;
	}
	
	long long res = 0;
	FOR(i, 1, n+1) FOR(j, i+2, n+1) if (T[i] != T[j])
	{
		char x = T[i] ^ T[j] ^ 'R' ^ 'G' ^ 'B';
		int k = (i + j) / 2;
		res += pref[j][x] - pref[i][x];
		if ((i-j) % 2 == 0 and T[k] == x)
			res--;
	}
	
	printf("%lld\n", res);
}
 
int main()
{
	int t;
	t=1;//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 9884
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define int long long  
signed main(){
    int N;
    int A[114514],B[114514];
    int maxa=0,maxb=0;
    cin >> N;
    REP(i,N){cin >> A[i] >> B[i];}
    REP(i,N){
        if(maxa<A[i]){
            maxa=A[i];
            maxb=B[i];
        }
    }
    cout << maxb +maxa << endl;
	return 0;
}


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

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

  long long N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  if(N <= min({A, B, C, D, D, E})){
    cout << 5 <<endl;
  } else{
    cout << (N + min({A, B, C, D, D, E}) - 1)/ min({A, B, C, D, D, E}) + 4 <<endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))

const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 200005;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	string a,b;
	cin >> a >> b;
	int c = 0;
	FOR(i,0,SZ(a)) {
		c+=a[i]!=b[i];
	}
	cout << c << "\n";

}


Measured memory_bytes: 3884
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll A = 0,B = 0,C = 0,K = 0,x = 0;
  cin >> A >> B >> C >> K;
  if(A >= K){
    cout << K;
    return 0;
  }
  if(A + B >= K){
    cout << A;
    return 0;
  }
  else{
    x = K - A - B;
    cout << A - x;
  }
}
    
    
    

Measured memory_bytes: 3632
import math
# import bisect
import sys
# from collections import Counter
input = sys.stdin.readline
def inp():
	return(int(input()))
def inlt():
	return(list(map(int,input().split())))
def insr():
	s = input()
	return(s[:len(s)-1])
def invr():
	return(map(int,input().split()))
def print_fract(p,q):
	g = math.gcd(p,q)
	p//=g
	q//=g
	print(str(p)+"/"+str(q))
# list1, list2 = zip(*sorted(zip(list1, list2)))
N, D = invr()
out  = 0
for n in range(N):
	X, Y = invr()
	if ((X**2)+(Y**2))**0.5 <= D:
		out += 1
print(out)

Measured memory_bytes: 9680
from copy import deepcopy
import bisect
n = int(input())
dat = list(map(int, input().split()))
odat = deepcopy(dat)
dat.sort()
x1 = dat[len(dat) // 2 - 1]
x2 = dat[len(dat) // 2]
for i in range(n):
    c = odat[i]
    j = bisect.bisect_left(dat, c)
    if j < len(dat) // 2:
        print(x2)
    else:
        print(x1)

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

using namespace std;
const int MAXN = 100010;
int _w;

int n, ans;
char s[MAXN];

void solve( int l, int r ) {
	if( l >= r ) return;
	if( s[l] == s[r] )
		solve(l+1, r-1);
	else if( s[l] == 'x' )
		++ans, solve(l+1, r);
	else if( s[r] == 'x' )
		++ans, solve(l, r-1);
	else
		ans = -1;
}

int main() {
	_w = scanf( "%s", s );
	n = (int)strlen(s);
	solve(0, n-1);
	printf( "%d\n", ans );
	return 0;
}


Measured memory_bytes: 384
NandX=list(map(int,input().split()))
N=NandX[0]
x=NandX[1]
A=list(map(int,input().split()))

ans = 0
for i in range(1,N):
    s = A[i]+A[i-1]
    if x<s:
        dif = s-x
        #オーバーしてる分がA[i]より小さい
        if dif<=A[i]:
            A[i]-=dif
            ans+=dif
        #オーバーしてる分がA[i]より大きい
        #(A[i]を減らすだけでは対処できない)
        else:
            A[i-1]=dif-A[i]
            A[i]=0
            ans+=dif

print(ans)


Measured memory_bytes: 14252
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long K = sc.nextLong();
            if(N%K < K - N%K){
                System.out.println(N%K);
            }else{
                System.out.println(K-N%K);
            }
    }
} 

Measured memory_bytes: 21588
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#define ll long long
using namespace std;

int main(){
    long k,a,b;
    cin>>k>>a>>b;
    int p=1;
    bool ans =false;
    while (true){
        if (k*p>=a && k*p<=b){
            ans=true;
            break;
        }
        if (k*p>b) break;
        p++;
    }
    if (ans) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
}

Measured memory_bytes: 3572
N, M = map(int, input().split())
ans = 0

V = [[] for i in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  V[a - 1] += [b - 1]
  V[b - 1] += [a - 1]
  
visited = [0] * N
for i in range(N):
  if visited[i] == 0:
    visited[i] = 1
    x = 1
    que = [i]
    while que:
      q = que.pop()
      for v in V[q]:
        if visited[v] == 0:
          que += [v]
          x += 1
          visited[v] = 1
    ans = max(x, ans)
    
print(ans)

Measured memory_bytes: 101960
def combi2(a):
    if a == 0: return 0
    return a * (a-1) // 2

n = int(input())

datas = []

for _ in range(n):
    datas.append(sorted(input()))

datas.sort()

total = 0
count = 0
for i in range(n-1):
    if datas[i] == datas[i+1]:
        if count == 0: count = 2
        else: count += 1
    else:
        total += combi2(count)
        count = 0
total += combi2(count)
count = 0
print(total)


Measured memory_bytes: 24652
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int ans[100005] = {0};
    
    int fro = 0;
    int back;
    int r = 0;
    for (int i = 0;i < s.size();i++){
    
        if (s[i] == 'R' && s[i+1] == 'L'){
            r = i;
        }
        else if ((s[i] == 'L' && s[i+1] == 'R') || i == s.size()-1){
            back = i;
            int k = (back-r)/2;
            int j = (r-fro+1)/2;
            ans[r] += r-fro+1-j+k;
            ans[r+1] += back-r-k+j;
            fro = i+1;
        }
    }
    for (int i = 0;i < s.size();i++){
        cout << ans[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int i,x,N[100001];
  scanf("%d",&x);
  for(i=1; i<=x; i++)scanf("%d",&N[i]);
  for(i=1; i<=x; i++){
    printf("node %d: key = %d, ",i,N[i]);
    if(i/2>=1)printf("parent key = %d, ",N[i/2]);
    if(2*i<=x)printf("left key = %d, ",N[2*i]);
    if(2*i+1<=x)printf("right key = %d, ",N[2*i+1]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#define For(i,l,r) for (register int i=l; i<=r; i++)
using namespace std;
typedef unsigned long long LL;
typedef signed long long ll;
template <typename T>
inline void read(T &x) {
	char c = getchar(); int w = 1; x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}

int a, b, c;
int main() {
    read(a); read(b); read(c);
    if (a == b && a != c) return puts("Yes"), 0;
    if (a == c && b != c) return puts("Yes"), 0;
    if (b == c && a != b) return puts("Yes"), 0;
    puts("No");
	getchar();
	return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
Y //= 1000
flag = False
for x in reversed(range(N + 1)):
    for y in reversed(range(N + 1 - x)):
        z = N - x - y
        if 10 * x + 5 * y + 1 * z == Y:
            print(x, y, z)
            flag = True
            break
    else:
        continue
    break

if not flag:
    print(-1, -1, -1)

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

#define ll long long
#define fast_io ios::sync_with_stdio(0); cin.tie(0)
#define infl 1e18+9
#define sz(a) ((int)a.size())

void solve(){
  int n; cin>>n; 
  int k; cin>>k; 
  vector<int> h(n),dp(n,1e9+5); 
  for(int i=0;i<n;i++){
    cin>>h[i]; 
  }
  dp[n-1]=0; 
  for(int i=n-2;i>=0;i--){
    for(int j=1;j<=k;j++){
      if(i+j<n)
      dp[i]=min(dp[i],dp[i+j]+abs(h[i+j]-h[i])); 
    }
  }
  cout<<dp[0]<<endl; 
}

int main(){
	fast_io;
	clock_t beg=clock();
  int t; 
  t=1; 
  //cin>>t; 
  while(t--){
	  solve();
  }
	clock_t end=clock();
	fprintf(stderr,"%.2lf sec\n",(double)(end-beg)/CLOCKS_PER_SEC);
	return 0;
}

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

int main()
{
  int A, B;
  cin >> A >> B;

  int temp =  A + B;
  if (temp % 2 != 0) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << temp / 2 << endl;
  }
}

Measured memory_bytes: 256
import Control.Arrow
import Data.Char
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as B
import qualified Data.IntSet as IS
main=mapM_ print.solve.unfoldr(B.readInt.B.dropWhile isSpace)=<<B.getContents
solve(a:b:q:stxs)=map f xs where
  (ss,(ts,xs))=(IS.fromList***first IS.fromList.splitAt b).splitAt a$stxs
  f x=minimum[g x ts ss,g x ss ts]
g x as bs=minimum.map(minimum.map fst.h as)$h bs(0,x)
h as(d,x)=map(\y->(d+abs(x-y),y))$mapMaybe(\f->f x as)[IS.lookupLE,IS.lookupGE]

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

const ll ansmod = 1000000007;

ll dp[100010] = {0};
ll ruizyou(ll a, ll b)
{
	ll res = a;
  	ll place = 1;
  	while(b > 1)
    {
  		if(b % 2 == 0)
    	{
    		res *= res;
      		b /= 2;
    	}
      	else
        {
        	place *= res;
          	b--;
        }
      	res %= ansmod;
      	place %= ansmod;
    }
  	return (res * place) % ansmod;
}

int main ()
{
	int n, k;
  	cin >> n >> k;
  	ll kosu[100010];
  	for(int i = 1; i <= k; i++)
    {
    	kosu[i] = ruizyou(k / i, n);
    }
  	for(int i = k; i > 0; i--)
    {
    	dp[i] = kosu[i];
      	for(int j = 2; j * i <= k; j++)
        {
        	dp[i] -= dp[j * i];
          	dp[i] %= ansmod;
        }
    }
  	ll ans = 0;
  	for(int i = 1; i <= k; i++)
    {
    	ans += i * dp[i];
      	ans %= ansmod;
    }
  	cout << ans % ansmod << endl;
  	}


Measured memory_bytes: 5180
n = int(input())
score_set = [0, 0]

for i in range(n):
  taro, hanako = input().split()
  if taro < hanako:
    score_set[1] += 3
  elif taro == hanako:
    score_set[0] += 1
    score_set[1] += 1
  elif hanako < taro:
    score_set[0] += 3

print(" ".join(map(str, score_set)))



Measured memory_bytes: 5600
h,w=map(int,input().split())
for x in range(h):
    a=input()
    for i in range(w):
        if a[i]=="#":
            l=i
            break
    for j in range(w):
        if a[w-1-j]=="#":
            r=w-1-j
            break
    if x>0:
        if br>l:
            print("Impossible")
            exit()
    bl=l
    br=r
print("Possible")


Measured memory_bytes: 3064
(defun split (string &key (delimiterp #'delimiterp))
  (loop :for beg = (position-if-not delimiterp string)
    :then (position-if-not delimiterp string :start (1+ end))
    :for end = (and beg (position-if delimiterp string :start beg))
    :when beg :collect (subseq string beg end)
    :while end))
(defun delimiterp (c) (position c " ,.;/"))

(defun make-array-from-list (l)
  (make-array (list (length l)) :initial-contents l)
  )

(defun bisect-left (n arr)
  (bisect-left_ n 0 (length arr) arr))
(defun bisect-left_ (n lo hi arr)
  (cond ((>= lo hi) (return-from bisect-left_ lo))
        (t
          (let ((mid (floor (/ (+ lo hi) 2))))
            (cond ((<= n (aref arr mid)) (return-from bisect-left_
                                                      (bisect-left_ n lo mid arr)))
                  (t (return-from bisect-left_ (bisect-left_ n (1+ mid) hi arr))))))
        ))

(defun bisect-right (n arr)
  (bisect-right_ n 0 (length arr) arr))
(defun bisect-right_ (n lo hi arr)
  (cond ((>= lo hi) (return-from bisect-right_ hi))
        (t
          (let ((mid (floor (/ (+ lo hi) 2))))
            (cond ((< n (aref arr mid)) (return-from bisect-right_
                                                      (bisect-right_ n lo mid arr)))
                  (t (return-from bisect-right_ (bisect-right_ n (1+ mid) hi arr))))))
        ))

(defun main()
  (let ((n (read))
        (as (sort (make-array-from-list (map 'list #'parse-integer (split (read-line)))) #'<))
        (bs (map 'list #'parse-integer (split (read-line))))
        (cs (sort (make-array-from-list (map 'list #'parse-integer (split (read-line)))) #'<))
        )

    (princ (reduce #'+ (loop :for b :in bs :collect
                       (* (bisect-left b as) (- n (bisect-right b cs))))))
    (princ #\newline)
    )
)
(main)

Measured memory_bytes: 93028
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<typeinfo>
#include<functional>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

typedef complex<double> C;



void dfs(ll n,C s,C t){
    cout<<fixed<<setprecision(12);
    C d=(t-s)/(C)3;
    C m1=s+d;
    C m2=m1+d;
    d/=(C)2;
    C u=m1+d;
    d*=C(0,sqrt(3.0));
    u+=d;
    if(n==1){
        cout<<m1.real()<<" "<<m1.imag()<<endl;
        cout<<u.real()<<" "<<u.imag()<<endl;
        cout<<m2.real()<<" "<<m2.imag()<<endl;
        cout<<t.real()<<" "<<t.imag()<<endl;
        return;
    }
    dfs(n-1,s,m1);
    dfs(n-1,m1,u);
    dfs(n-1,u,m2);
    dfs(n-1,m2,t);
}


int main(){
    cout<<fixed<<setprecision(12);
    ll n;
    cin>>n;
    C s(0,0);
    cout<<s.real()<<" "<<s.imag()<<endl;
    C t(100,0);
    if(n==0){
        cout<<t.real()<<" "<<t.imag()<<endl;
        return 0;
    }
    dfs(n,s,t);
    
    
    
    return 0;
}



Measured memory_bytes: 3288
def readinput():
    n,k=list(map(int,input().split()))
    a=list(map(int,input().split()))
    return n,k,a

def main(n,k,a):
    MOD=10**9+7

    t=0
    for i in range(n-1):
        for j in range(i+1,n):
            if a[i]>a[j]:
                t+=1
    
    s=0
    for i in range(n):
        for j in range(n):
            if a[j]<a[i]:
                s+=1
    
    x= ( (k*t)%MOD + ((k*(k-1)//2)%MOD)*s%MOD  )%MOD

    return x

if __name__=='__main__':
    n,k,a=readinput()
    ans=main(n,k,a)
    print(ans)



Measured memory_bytes: 9244