akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(int argc, char** argv){
	int a, b, c;
	cin >> a >> b >> c;
	
	if(a <= b && a <= c){
		cout << a << " ";
		if(b <= c) {
			cout << b << " " << c << endl;
		} else {
			cout << c << " " << b << endl;
		}
	} else if(b <= a && b <= c){
		cout << b << " ";
		if(a <= c) {
			cout << a << " " << c << endl;
		} else {
			cout << c << " " << a << endl;
		}
	} else if(c <= a && c <= b){
		cout << c << " ";
		if(a <= b) {
			cout << a << " " << b << endl;
		} else {
			cout << b << " " << a << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

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

Measured memory_bytes: 3608
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    string s;
    R(s);
    W(string(SZ(s),'x'));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int Q,H,S,D,N;
ll cost[2];
int main()
{
    scanf("%d%d%d%d%d",&Q,&H,&S,&D,&N);
    Q *=4;
    H *=2;
    cost[0] = (ll)min(min(Q,H),S);
    cost[1] = (ll)D;
    ll ans = 0;
    if(cost[0]*2<=cost[1]){
        ans = cost[0] * N;
    }else{
        ans = (cost[0] * (N%2)) + (cost[1]*(N/2));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define INF 1e18
int n, m;
vector<int> graph[100020];
vector<int> dp(100020, -1);
vector<bool> visited(100020, false);
int dfs(int node, int sum)
{
    if(dp[node] != -1)
        return dp[node];
    if(graph[node].empty())
        return 1;
    else{
        int temp, max = 0;
        for (auto child : graph[node]) {
            temp = dfs(child, sum+1);
            if(temp > max)
                max = temp;
        }
        return dp[node] = max+1;
    }
}
int check()
{
    int mx = 0;
    for (int i = 1; i <= n; ++i) {
        if(!visited[i])
            mx = max(mx, dfs(i, 0));
    }
    return mx-1;
}
int main() {
    fast;
    cin>>n>>m;
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin>>a>>b;
        graph[a].push_back(b);
    }
    cout<<check();
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T> T count_bit(T p){
  if(typeid(p)==typeid(int))return __builtin_popcount(p);
  else if(typeid(p)==typeid(long))return __builtin_popcountl(p);
  else return __builtin_popcountll(p);
}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  string s;
  in(s);
  if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])out("Bad");
  else out("Good");
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------


int main(){
  ll N,A,B;
  cin >> N >> A >> B;
  vector<ll> h(N);
  for(int i=0; i<N; i++){
    cin >> h[i];
  }
  ll ng=0,ok=1e9;
  while(ok-ng>1){
    ll mid = (ng+ok)/2;
    ll cnt = 0;
    for(int i=0; i<N; i++){
      if(h[i] > mid*B){
        cnt += (h[i]-mid*B+A-B-1)/(A-B);
      }
    }
    if(cnt <= mid){
      ok = mid;
    }else{
      ng = mid;
    }
  }
  cout << ok << endl;
  return 0;
}


Measured memory_bytes: 1152
use std::io;
use std::cmp::min;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let p = iter.next().unwrap().parse::<i32>().ok().unwrap();
	let q = iter.next().unwrap().parse::<i32>().ok().unwrap();
	let r = iter.next().unwrap().parse::<i32>().ok().unwrap();
	let mut ret = min(p+q, q+r);
	ret = min(ret, p+r);
	println!("{}", ret);
}

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

int main(){
    int N;
    cin >>N;
    string S;
    string T;
    cin >> S >> T;
    string outstring;
    rep(i,N){
        cout << S.at(i) << T.at(i);
    }
    cout <<  endl;
}

Measured memory_bytes: 256
import Data.List.Split

data Vec2 = Vec2 Double Double deriving Eq

(/--) :: Vec2 -> Vec2 -> Vec2
(/--) (Vec2 a1 a2) (Vec2 b1 b2) = (Vec2 (a1 - b1) (a2 - b2))

-- Cross Product
(/**) :: Vec2 -> Vec2 -> Double
(/**) (Vec2 a1 a2) (Vec2 b1 b2) = a1 * b2 - a2 * b1

isConvex :: [Double] -> String
isConvex [xa, ya, xb, yb, xc, yc, xd, yd]
    | (all (> 0) cps) || all (< 0) cps = "YES"
    | otherwise                        = "NO"
    where
        vab = (Vec2 xb yb) /-- (Vec2 xa ya)
        vbc = (Vec2 xc yc) /-- (Vec2 xb yb)
        vcd = (Vec2 xd yd) /-- (Vec2 xc yc)
        vda = (Vec2 xa ya) /-- (Vec2 xd yd)
        cps = [vab /** vbc, vbc /** vcd, vcd /** vda, vda /** vab]

main :: IO ()
main = interact $ unlines . map isConvex . map (map read) . map (splitOn ",") . lines

Measured memory_bytes: 4240
#include<iostream>
using namespace std;
int a[1000000]={0};
int main(){
    int n,c=0;
    for(int i=2;i<10000;i++)
        for(int j=i;j*i<1000000;j++)
            a[i*j]=1;
    while(cin>>n){
        c=0;
        for(int i=2;i<=n;i++)
            if(a[i]==0)
                c++;
        cout<<c<<endl;
    }
}

Measured memory_bytes: 5064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
//library begin
int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int log(int a){
    int b=a;
    int cnt=0;
    while(b%2==0){
        b/=2;
        cnt++;
    }
    return cnt;
}
//library end
int a,b;
string x="",y="";
signed main(){
    cin>>a>>b;
    rep(i,b){
        char c='0'+a;
        x=x+c;
    }
    rep(i,a){
        char c='0'+b;
        y=y+c;
    }
    string s=min(x,y);
    cout<<s<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n,a,b;
int main(){
	cin>>n>>a>>b;
	ll ans=INFl;
	//cout<<ans<<endl;
	if(a>b)swap(a,b);
	if((b-a)%2==0){
		ans=min(ans,((b-a)/2));
	}else{
		ans=min(ans,(b+a+1)/2-1);
		ans=min(ans,(2*n-b-a+1)/2);
	}
	ans=min(ans,max(a-1,b-1));
	ans=min(ans,max(n-a,n-b));
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
   for (int i = 0; i < N; i++) {
     cin >> vec.at(i);
   }
  sort(vec.begin(), vec.end());
  int a = vec.at(0);
  int b = vec.at(N-1);
  vector<int> P(b-a+1,0);
  int y = 0;
   for (int i = a; i < b+1; i++) {
     int x = 0;
      for (int j = 0; j < N; j++) {
        int t = (vec.at(j) - i) * (vec.at(j) - i);
        x += t;
      }
     P.at(y) = x;
     y ++;
   }
  sort(P.begin(), P.end());
  cout << P.at(0) << endl;
}

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

int bin(int x,int y,char e)
{
  if(e == '+')
    {
      return x | y;
    }
  else if(e == '*')
    {
      return x & y;
    }
  else
    {
      return x ^ y;
    }
}
int compute(const string &str,int a,int b,int c,int d){
  
  stack<int>s;
  stack<char>op;
  char e;
  int x,y,z;
  for(int i=0;i < str.size();i++)
    {
      if(str[i] == 'a')
	{
	  s.push(a);
	}
      else if(str[i] == 'b')
	{
	  s.push(b);
	}
      else if(str[i] == 'c')
	{
	  s.push(c);
	}
      else if(str[i] == 'd')
	{
	  s.push(d);
	}
      
      if(str[i] == '+')
	{
	  op.push('+');
	}
      else if(str[i] == '*')
	{
	  op.push('*');
	}
      else if(str[i] == '^')
	{
	  op.push('^');
	}

      if(str[i] == ']')
	{
	  e = op.top();
	  op.pop();
	  x = s.top();
	  s.pop();
	  y = s.top();
	  s.pop();
	  s.push(bin(x,y,e));
	}
    }
  return s.top();
}

int main(){
  int n;
  string str;
  int cnt=0;

  while(1){
    cnt =0;
    cin >> str;
    if(str == ".") break;
    cin >> n;

    int key = compute(str, n/1000, n/100%10, n/10%10, n%10 );
    
    for(int a=0;a < 10;a++){
      for(int b=0;b < 10;b++){
	for(int c=0;c < 10;c++){
	  for(int d=0;d < 10;d++){
	    if( compute(str,a,b,c,d) == key){
	      cnt++;
	    }
	  }//d
	}//c
      }//b
    }//a
    cout << key << " " << cnt << endl;

    
  }// while
  
  return 0;
}


Measured memory_bytes: 3104
object Main extends App {
  val read = scala.io.StdIn.readLine()
  val array =  read.split(" ").map(_.toLong).toVector
  val r = array(0)
  val D = array(1)
  val x2000 = array(2)
  var x = x2000

  for(i<-1 to 10) {
    x = r * x - D
    println(x)
  }

}


Measured memory_bytes: 25536
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>

long long int mod(long long int x, long long int m);
long long int fast_power(long long int x, long long int n, long long int m);

long long int MOD = 1e9+7;

int main(){

  // read problem
  
  long long int N, tmp;
  std::vector<long long int> C;

  scanf("%lld", &N);
  for(int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    C.push_back(tmp);
  }

  // sort C
  std::sort(C.begin(), C.end(), std::greater<long long int>());

  // solve problem
  long long int ans = 0;
  long long int pow2;

  pow2 = fast_power(2, 2*N-2, MOD);

  for(long long int i = 0; i < N; i++){
    tmp = (pow2*(i+2)+MOD)%MOD;
    tmp = (tmp*C[i] + MOD)%MOD;
    ans += tmp;
    ans = (ans+MOD)%MOD;
  }

  std::cerr << "Answer: " << std::endl;
  std::cout << ans << std::endl;

  return 0;
}

long long int mod(long long int x, long long int m){
  if(x>0){
    return x%m;
  }
  else if(x==0){
    return 0;
  }
  else if((-x)%m == 0){
    return 0;
  }
  else{
    return m - (-x)%m;
  }
}

long long int fast_power(long long int x, long long int n, long long int m){
  long long int ans = 1;
  
  while(n > 0){
    if(n&1){
      ans = ans * x;
      ans = mod(ans, m);
    }
    x = x*x;
    x = mod(x, m);
    n = n>>1;
  }
  
  return ans;
}


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

int n, a[200009], cnt, id[200009], res[200009], mod = 1000000007; vector<int>x[200009];
vector<pair<long long, long long>> lis[2000009];

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 32; i++) {
		if ((b&(1LL << i)) != 0) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}
long long Div(long long a, long long b, long long m) {
	return (a*modpow(b, m - 2, m)) % m;
}

void dfs(int pos, int depth) {
	res[depth]++;
	if (x[pos].size() == 0) {
		cnt++; id[pos] = cnt;
		lis[cnt].push_back(make_pair(1, 1));
		return;
	}
	for (int i = 0; i < x[pos].size(); i++) dfs(x[pos][i], depth + 1);
	vector<pair<long long, long long>>V;
	for (int i : x[pos]) {
		V.push_back(make_pair(lis[id[i]].size(), i));
	}
	sort(V.begin(), V.end());
	if (V.size() == 1) {
		id[pos] = id[V[V.size() - 1].second]; lis[id[pos]].push_back(make_pair(1, 1));
		return;
	}
	for (int i = 0; i < V[V.size() - 2].first; i++) {
		int pos1 = lower_bound(V.begin(), V.end(), make_pair((long long)(i + 1), 0LL)) - V.begin();

		long long product = 1, sum = 0, sum2 = 1;
		for (int j = pos1; j < V.size(); j++) {
			int ID = id[V[j].second];
			product *= lis[ID][lis[ID].size() - i - 1].second; product %= mod;
			sum2 *= (lis[ID][lis[ID].size() - i - 1].first + lis[ID][lis[ID].size() - i - 1].second); sum2 %= mod;
		}
		for (int j = pos1; j < V.size(); j++) {
			int ID = id[V[j].second];
			long long a = lis[ID][lis[ID].size() - i - 1].first;
			long long b = lis[ID][lis[ID].size() - i - 1].second;
			long long I = Div(product, b, mod)*a; I %= mod;
			sum += I;
		}
		sum %= mod;
		int ID = id[V[V.size() - 1].second];
		lis[ID][lis[ID].size() - i - 1] = make_pair(sum, (sum2 - sum + mod) % mod);
	}
	id[pos] = id[V[V.size() - 1].second]; lis[id[pos]].push_back(make_pair(1, 1));
}

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) { cin >> a[i]; x[a[i]].push_back(i); }
	dfs(0, 0);
	long long finalans = 0;
	for (int i = 0; i < lis[id[0]].size(); i++) {
		long long a1 = lis[id[0]][i].first;
		long long a2 = lis[id[0]][i].second;
		long long depth = lis[id[0]].size() - i - 1;
		while ((a1 + a2) % mod != modpow(2, res[depth], mod)) {
			a1 *= 2; a2 *= 2; a1 %= mod; a2 %= mod;
		}
		a1 *= modpow(2, n + 1 - res[depth], mod); a1 %= mod;
		a2 *= modpow(2, n + 1 - res[depth], mod); a2 %= mod;
		finalans += a1;
		finalans %= mod;
	}
	cout << finalans << endl;
	return 0;
}

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

void prime()
{
     long long n,i,j;
     int f = 1;
     cin>>n;
     if(n>2)
     {
     for(i=n;i<999999999;i++)
     {
         f=1;
         for( j=2;j<sqrt(i);j++)
         {
             if(i%j==0)
             {
                 f=0;
                 break;
             }
         }
         if(f)
         break;
         
     }
     cout<<i;
     }
     else if(n==2)
         cout<<n;
    else cout<<"wrong";     
}




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

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,K;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	N%=K;
	cout<<min(N,K-N)<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
s1 = []
mod = 1000000007
i = 0
while i < n-1:
    if s[i]==s[i+1]:
        s1.append(0)
        i += 1
    else:
        s1.append(1)
    i += 1

if s[n-2]!=s[n-1]:
    s1.append(1)

if n==1:
    s1.append(1)

ans = 1
for i in range(len(s1)):
    ans %= mod
    if i == 0:
        if s1[i]==0:
            ans*=6
        else:
            ans*=3
    elif s1[i-1]==0 and s1[i]==0:
        ans*=3
    elif s1[i-1]==1 and s1[i]==1:
        ans*=2
    elif s1[i-1]==1 and s1[i]==0:
        ans*=2

print(ans%mod)

Measured memory_bytes: 3064
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different 
Yours Faithfully
Shobhit Yadav */

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

ll N,T;
/*ll freq[200005];*/
void solve(){
	ll ans , temp;
	for(ll i = 0 ; i<5 ; i++){
      cin>>temp;
      if(temp == 0){
      	ans = i+1;
      	break;
      }

	}

	cout<<ans<<'\n';
}



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

	return 0;
}

Measured memory_bytes: 3584
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <complex>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;

int main() {
  int n;
  while (cin >> n) {
    if (n == 1) {
      cout << "1" << endl;
    } else if (n % 2 == 0) {
      cout << "0.5" << endl;
    } else {
      printf("%.10f", (double)(n / 2 + 1) / n);
      cout << endl;
    }
  }
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a, Ts... ts) {return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    if(n == 2)
    {
        cout << a[1] - a[0] << endl;
        cout << a[1] << " " << a[0] << endl;
        return 0;
    }

    sort(all(a));
    int zero = 0;
    vector<LL> ans1, ans2;
    int index = lower_bound(all(a), 0) - a.begin();

    if(index == 0)
    {
        LL cur = a[index];
        FOR(i, 2, n)
        {
            ans1.pb(cur); ans2.pb(a[i]);
            cur -= a[i];
        }
        ans1.pb(a[1]); ans2.pb(cur);
        cout << a[1] - cur << endl;
        REP(i, n-1) cout << ans1[i] << " " << ans2[i] << endl;
         
        return 0;
    }

    if(index == n)
    {
        LL cur = a[n-1];
        REP(i, n-1)
        {
            ans1.pb(cur); ans2.pb(a[i]);
            cur -= a[i];
        }
        cout << cur << endl;
        REP(i, n-1) cout << ans1[i] << " " << ans2[i] << endl;
         
        return 0;
    }

    LL cur = a[index-1];
    LL ans = a[n-1];
    
    FOR(i, index, n-1)
    {
        ans1.pb(cur); ans2.pb(a[i]);
        cur -= a[i];
    }
    REP(i, index-1)
    {
        ans1.pb(ans); ans2.pb(a[i]);
        ans -= a[i];
    }
    ans1.pb(ans); ans2.pb(cur);
    ans -= cur;
    cout << ans << endl;
    REP(i, n-1) cout << ans1[i] << " " << ans2[i] << endl;
}

Measured memory_bytes: 4076
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll mm[200010] = { 1,1 };
ll pow_mod(ll a, ll b) {
	if (b == 0) { return 1; }
	if (b == 1) { return a % mod; }
	ll r = pow_mod(a, b / 2);
	r *= r;
	r %= mod;
	if (b % 2 == 0) {
		return r;
	}
	return (r * a) % mod;
}
ll nCm(ll n, ll m) {
	ll res = mm[n];
	res *= pow_mod(mm[m], mod - 2);
	res %= mod;
	res *= pow_mod(mm[n - m], mod - 2);
	res %= mod;
	return res;
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	for (int i = 2; i <= 200000; i++) {
		mm[i] = (mm[i - 1] * i) % mod;
	}
	int H, W;
	cin >> H >> W;
	int A, B;
	cin >> A >> B;
	ll ans = 0;
	for (int a = H - A, b = B + 1; a >= 1 && b <= W; a--, b++) {
		ans += nCm((a - 1) + (b - 1), a - 1) * nCm((H - a) + (W - b), H - a);
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main () {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int x = tx-sx, y = ty-sy;
    cout << string(y, 'U') << string(x, 'R') << string(y, 'D') << string(x, 'L') << "D" << string(x+1, 'R') << string(y+1, 'U') << "LU" << string(x+1, 'L') << string(y+1, 'D') << 'R' << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include<string>
#include<vector>
#include <algorithm>
#define REP(a,b) for (int i = a; i <= (b); i++)
using namespace std;
int main() {
  double a,b,c;
  cin>>a>>b;
  c=a*a-b;
  cout<<c;
}

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


namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int[] a_b = sc.intarr;
            int a = a_b[0];
            int b = a_b[1];

            int count = 0;

            for(int i=a; i<=b; i++)
            {
                int k1 = i / 10000;
                int k2 = (i-k1*10000) / 1000;
                int k3 = (i - k1 * 10000 - k2 * 1000) / 100;
                int k4 = (i - k1*10000 - k2 * 1000 - k3 * 100)/ 10;
                int k5 = i % 10;

                if(k1 == k5 && k2 == k4)
                {
                    count++;
                }
            }

            wr.wri(count);
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13268
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: u8,
      mut s: chars,
    }
    for i in 0..s.len() {
        let index = (((s[i] as u8) + n) - 'A' as u8) % 26;
        s[i] = ('A' as u8 + index) as char;
    }

    let ans =s.into_iter().collect::<String>();
    puts!("{}\n", ans);
}


Measured memory_bytes: 4352
N = gets.chomp#.to_i
n = (N.size/2.0).ceil
a = n.times.map {|i| (100 ** i)..("9" + "99"*i).to_i}
if N.to_i < a.last.last
  a[-1] = a.last.first..N.to_i
end
puts a.map(&:size).inject(:+)


Measured memory_bytes: 1788
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

const int MAXN = 2e5+10;
int R[MAXN];

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&R[i]);
	}
	int maxv = -INF;
	int minv = R[0];
	
	for(int i=1;i<n;i++){
		maxv=max(maxv,R[i]-minv);
		minv=min(minv,R[i]);
	}
	
	printf("%d\n",maxv);
	
	return 0;
}




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


static long long M = 1e9 + 7;

inline long long MOD(long long x, long long m) {
    return (x%m + m)%m;
}


int main() {
    string S;
    
    getline(cin, S);

    int d=1, e=0;
    long long x[13] = {};
    x[0] = 1;

    for(int k=S.length()-1; k>=0; --k) {
	int s = S[k];

        if (s == '?') {
            long long y[13] = {};
	    
	    for(int i=0; i<10; ++i) {
                int d2 = MOD(d*i, 13);

		for(int j=0; j<13; ++j) {
		    int j2 = MOD((j+d2),13);
                    y[j2] = MOD(y[j2] + x[j], M);
		}
	    }

	    for(int j=0; j<13; ++j) {
		x[j] = y[j];
	    }

	}else {
            e = MOD(e + d*(s - '0'), 13);
	}

	d = MOD(d*10, 13);
    }

        
    cout << x[MOD((5-e),13)] << endl;
}







Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
	ll k;
	cin>>k;
	ll rem=0;
	ll pow_of_ten=1;
	map<ll, ll> mp1;
	for(ll i=1; ;i++)
	{
		rem=(7*pow_of_ten)%k+rem;
		rem%=k;
		pow_of_ten=pow_of_ten*10;
		pow_of_ten%=k;
		if(rem&&mp1.find(rem)!=mp1.end())
		{
		    cout<<-1<<endl;
		    return;
		}
		mp1[rem]++;
		if(rem==0)
		{
			cout<<i<<endl;
			return;
		}
	}
}
int main()
{
    ll test=1;
    while(test--)
    {
        solve();
    }
}

Measured memory_bytes: 66096
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値

int main() {
    // 入力
    int N, K;
    while (cin >> N >> K) {
        if (N == 0) break;
        vector<long long> a(N);
        for (int i = 0; i < N; ++i) cin >> a[i];

        // 累積和を前計算
        vector<int> s(N+1, 0);
        for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

        // 答えを求める
        long long res = -INF; // 最初は無限小の値に初期化しておく
        for (int i = 0; i <= N-K; ++i) {
            long long val = s[K+i] - s[i];
            if (res < val) res = val;
        }
        cout << res << endl;
    }
}



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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    string s; cin >> s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3624
n = int(input())
input_list = list(map(int,input().split()))
d = sorted(input_list)

n = len(d)
h = n//2
l = n//2 - 1

if d[l] == d[h]:
    print(0)
else:
    s = d[h] - d[l]
    print(s)

Measured memory_bytes: 52780
public class Main {

  private static void solve() {
    int n = ni();
    int[] h = na(n);

    for (int i = n - 2; i >= 0; i--) {
      int d = h[i] - h[i + 1];
      if (d >= 2) {
        System.out.println("No");
        return;
      } else if (d == 1) {
        h[i]--;
      }
    }
    System.out.println("Yes");

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 40496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

const int INF = 1e9;

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

    int N;
    cin >> N;
    vector<int> V(N+1), W(N+1);
    for (int i = 1; i <= N; i++) cin >> V[i] >> W[i];
    int MAX_L = 1e5;
    vector<vector<int>> dp(min(1 << 10, N+1), vector<int>(MAX_L+1));
    for (int i = 1; i < min(1 << 10, N + 1); i++) {
        dp[i] = dp[i / 2];
        for (int j = W[i]; j <= MAX_L; j++) {
            dp[i][j] = max(dp[i][j], dp[i / 2][j - W[i]] + V[i]);
        }
    }
    int Q;
    cin >> Q;
    REP(q, Q) {
        int v, L;
        cin >> v >> L;
        int ans = 0;
        if (v < (1 << 10)) {
            ans = dp[v][L];
        } else {
            vector<pair<int, int>> vals;
            vals.push_back({0, 0});
            while (v >= (1 << 10)) {
                vector<pair<int, int>> tmp;
                for (auto& p : vals) {
                    tmp.push_back({p.first + W[v], p.second + V[v]});
                }
                vals.insert(vals.end(), ALL(tmp));
                v /= 2;
            }
            for (auto& p : vals) {
                if (p.first > L) continue;
                ans = max(ans, dp[v][L - p.first] + p.second);
            }
        }
        cout << ans << '\n';
    }
}

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

string str;

int main( void ) {
    
    int k;
    cin >> str >> k;
    
    for( char &ch : str ) {
        if( ch == 'a' )
            continue;
        
        if( 'z' - ch < k ) {
            k -= 'z' - ch + 1;
            ch = 'a';
        }
    }
    
    str.back() = ( str.back() - 'a' + k ) % 26 + 'a';
    cout << str << endl;
    
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A[3],K;
  cin>>A[0]>>A[1]>>A[2]>>K;
  sort(A,A+3);
  int ans=A[2];
  while(K>0){
    ans*=2;
    K--;
  }
  cout<<ans+A[0]+A[1]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>

using namespace std;

long long A[200000];

bool is_valid(int N){
    if(A[0] != 0){
        return false;
    }
    for(int i = 0; i < N - 1; i++){
        if(A[i] > i){
            return false;
        }
        if(A[i] < A[i + 1]){
            if(A[i] + 1 != A[i + 1]){
                return false;
            }
        }
    }
    return true;
}
int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    if(!is_valid(N)){
        cout << - 1 << endl;
        return 0;
    }
    long long ans = 0;
    for(int i = 0; i < N - 1; i++){
        if(A[i] >= A[i + 1]){
            ans += A[i];
        }
    }
    ans += A[N - 1];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- スペース区切り整数の入力
    [a, b, c] <- words <$> getLine
    -- 出力
    putStrLn $ map (toUpper . head) [a, b, c]


Measured memory_bytes: 380
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main() {
	int N;
	cin >> N;

	vector<int> A(N);
	for (int a = 0; a < N; a++) {
		cin >> A[a];
	}
	sort(A.begin(), A.end());
	int alice = 0;
	int bob = 0;
	for (int a = 0; a < N;a++) {
		if (a%2==0) {
			alice += A[a];
		}
		else {
			bob += A[a];
		}
	}
	cout<< max(alice,bob)-min(alice,bob)<<endl;


}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

void solve()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 0;

    REP0 (d1, 10)
    {
        REP0 (d2, 10)
        {
            REP0 (d3, 10)
            {
                bool d1ok = false, d2ok = false;
                REP0 (i, N)
                {
                    int d = S[i] - '0';

                    if (d == d1 and !d1ok)
                    {
                        d1ok = true;
                        continue;
                    }
                    if (d == d2 and d1ok and !d2ok)
                    {
                        d2ok = true;
                        continue;
                    }
                    if (d == d3 and d2ok)
                    {
                        ans++;
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

bool check(vector<int> a, vector<int> b) {
    sort(all(a));
    sort(all(b));
    return a == b;
}

map<int, int> p;

int get(int u) {
    auto it = p.find(u);
    if (it == p.end()) {
        p[u] = u;
        return u;
    } 
    if (it->sn == u) return u;
    return it->sn = get(it->sn);
}

void unite(int u, int v) {
    u = get(u);
    v = get(v);
    if (u != v) p[u] = v;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    forn(i, 0, n) cin >> a[i];
    forn(i, 0, n) cin >> b[i];
    int A = 0;
    forn(i, 0, n) A ^= a[i];
    a.eb(A);
    int B = 0;
    forn(i, 0, n) B ^= b[i];
    b.eb(B);
    if (!check(a, b)) {
        cout << "-1\n";
        return 0;
    }
    ++n;
    forn(i, 0, n) if (a[i] != b[i] || i == n - 1) unite(a[i], b[i]);
    map<int, vector<int>> x;
    forn(i, 0, n) if (a[i] != b[i] || i == n - 1) x[get(a[i])].eb(a[i]);
    int ans = 0;
    for (auto q : x) {
        int sz = q.sn.size();
        if (sz == 1) continue;
        if (q.fs == get(a.back())) ans += sz - 1;
        else ans += sz + 1;
    }
    cout << ans << '\n';
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int n,a,b;
    cin>>n>>a>>b;

    cout<<min(n*a,b)<<"\n";

    return 0;

}

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

//ライブラリ始まり

//定数

//円周率
const double PI = 3.1415926535897932384;

//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15

//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";

//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//関数

//ctoi
int ctoi(char c){
  if (c == '0') {
    return 0;
  }
  if (c == '1') {
    return 1;
  } 
  if (c == '2') {
    return 2;
  } 
  if (c == '3') {
    return 3;
  }
  if (c == '4') {
    return 4;
  } 
  if (c == '5') {
    return 5;
  } 
  if (c == '6') {
    return 6;
  }
  if (c == '7') {
    return 7;
  } 
  if (c == '8') {
    return 8;
  } 
  if (c == '9') {
    return 9;
  }
  return -1;  
}

//素数判定
bool PN(int x) {
  if (x <= 1) {
    return false;
  }
  if (x == 2) {
    return true;
  }
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

//ライブラリ終わり

int main() {
  int N;
  cin >> N;
  if (N < 1000) {
    cout << "ABC" << endl;
  }
  else {
    cout << "ABD" << endl;
  }
}

Measured memory_bytes: 3680
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cassert>
#define ll long long
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n,first[100010],cnte,mindep[100010],tmp[100010],cnt;
struct edge{
	int to,next;
}a[100010];
inline void add(int u,int v){
	a[++cnte]=(edge){v,first[u]};first[u]=cnte;
}
void dfs(int u){
	int i;
//	cout<<"dfs "<<u<<'\n';
	for(i=first[u];~i;i=a[i].next) dfs(a[i].to);
	cnt=0;
	for(i=first[u];~i;i=a[i].next) tmp[++cnt]=mindep[a[i].to];
	if(!cnt){mindep[u]=0;return;}
	sort(tmp+1,tmp+cnt+1);
	for(i=2;i<=cnt;i++) if(tmp[i]<=tmp[i-1]) tmp[i]=tmp[i-1]+1;
	mindep[u]=tmp[cnt]+1;
//	cout<<"return "<<u<<' '<<cnt<<' '<<mindep[u]<<'\n';
}
int main(){
	memset(first,-1,sizeof(first));
	n=read();int i,t1;
	for(i=2;i<=n;i++) t1=read(),add(t1,i);
	dfs(1);
	printf("%d\n",mindep[1]);
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18

priority_queue<int,vector<int>,greater<int>> que;


llint k,s;


void solve(){
	cin >> k >> s;
	int ans=0;
	for(int x=0;x<=k;x++){
		for(int y=0;y<=k;y++){
			int z=s-x-y;
			if(z>=0 && z<=k)ans++;
		}
	}
	cout << ans << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
n = int(input())
num = 0
count = 0
a_list = []

for i in range(n):
    a = int(input())
    a -= 1
    a_list.append(a)

OK = False

for i in range(n):
    num = a_list[num]
    count += 1
    if num == 1:
        OK = True
        break
if OK:    
    print(count)
else:
    print(-1)

Measured memory_bytes: 7084