akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace ABC042A{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var input = sr.Next<int>(3);
            var res = input.Count(x => x == 5) == 2 && input.Count(x => x == 7) == 1;
            Console.WriteLine(res ? "YES" : "NO");
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = Console.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define err(A) cout << #A << " = " << (A) << endl
using namespace std;
const int N=2e5+100;
ll a[N],b[N];
int32_t main(){
    ll n,m,k;
    cin >> n >> m >> k;
    vector <int> c,d;
    for (int i=1;i<=n;i++){
        cin >> a[i];
        c.pb(a[i]);
    }
    sort(c.begin(),c.end());
    for (int i=1;i<=m;i++){
        cin >> b[i];
        d.pb(b[i]);
    }
    sort(d.begin(),d.end());
    ll ans=c[0]+d[0];
    for (int i=0;i<k;i++){
        ll x,y,e;
        cin >> x >> y >> e;
        ans=min(ans,a[x]+b[y]-e);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3828
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<vector<ll>>> vvvll;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================





int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================
	

	ll N, M, K;
	cin >> N >> M >> K;

	for (int n = 0; n <= N; n++)
	{
		if (n == 2)
		{
			int df = 0;
		}

		int sum = n * M;
		int nokori = K - sum;

		int up = (N - n) - n;

		if (up == 0 && nokori != 0)
		{
			continue;
		}

		if (up != 0 && nokori % (abs(up)) != 0)
		{
			continue;
		}

		if (nokori * up < 0)
		{
			continue;
		}

		if (nokori / (up) <= M)
		{

			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;




}





Measured memory_bytes: 256
import java.util.*

fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val a = LongArray(n)
    var ans = 0L
    for(i in 0 until n){
        val b = readLine()!!.toLong()
        a[i] = b
    }
    for(i in 0 until n - 1){
        if(a[i] % 2 == 1L && a[i + 1] > 0){
            ans += a[i] / 2 + 1
            a[i + 1]--
        }
        else{
            ans += a[i] / 2
        }
    }
    ans += a[n - 1] / 2
    println(ans)
}


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

using namespace std;
typedef long long ll;
ll n,res=0;
int dgt[15],cnt;

void dfs(int dep,ll sum)
{
	if(dep==cnt){res+=sum;return;}
	for(int i=dep+1;i<=cnt;i++)
	{
		ll t=0;
		for(int j=dep+1;j<=i;j++) 
			t=t*10+dgt[j];
		dfs(i,sum+t);
	}
}

int main()
{
	scanf("%lld",&n);
	for(;n;n/=10) dgt[++cnt]=n%10;
	reverse(dgt+1,dgt+cnt+1);dfs(0,0);
	printf("%lld",res);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SpeeD ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
#define endl '\n'
//pair<int, int> *p=new pair<int, int>[n];
//std::vector<pair<int,int>> vp;
//v.push_back(make_pair(x,y))
//pair<int, int> p[1000001];
//string *s=new string [n];
//int freq[e];
//freq[a[i]-'a']++; freq[a[i]]++;
 using namespace std;
ll n,t,m,c1,c2,c,x,y,sum,mn=999999999,avg,pos,dif,j,dis,mx,xi,yi,q;
vector<ll>v;
set<string>s;
map<string , ll >mp;
bool PE(int x)
{
for (int i=2;i*i<=x;i++)
if (x%i==0)
return false;
return true;
}
bool PR(string s)
{
int n=s.length();
for(int i=0;i<n/2;i++)
if(s[i]!=s[n-i-1])
return false;
return true;
}

int main(void)
{ SpeeD;
ll a,b,c,d,e;
cin>>a>>b>>c>>d>>e;

n= (c-a)*60;
if (b > d)
n-=abs(b-d);
else  if (d > b)n+=abs(b-d);

if (e >= n)cout<<0;
else cout<<n-e;



}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n, mc = 0, mn = 1e9;
  ll absum = 0;
  cin >> n;
  vector<int> a(n);
  rep(i, n){
    int in;
    cin >> in;
    a.at(i) = in;
    mn = min(mn, abs(in));
    absum += abs(in);
    if(in <= 0){
      mc++;
    }
  }
  if(mc % 2 == 1){
    absum -= (ll)2 * mn;
  }
  cout << absum << endl;

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define pb(x) push_back(x)
using namespace std;

int main()
{
    ll n,m;
    string s,t;
    cin>>s>>t;

    n = s.length();
    m = t.length();

    vector<ll>adj[26];

    for(ll i=0;i<n;i++)
    {
        adj[s[i]-'a'].pb(i);
    }

    ll iter = 0;
    ll ind = 0;

    for(ll i=0;i<m;i++)
    {
        ll val = t[i]-'a';
        auto tmp_ind = lower_bound(adj[val].begin(),adj[val].end(),ind);

        if(tmp_ind == adj[val].end())
        {
            iter++;
            ind = 0;
            tmp_ind = lower_bound(adj[val].begin(),adj[val].end(),ind);
            if(tmp_ind == adj[val].end())
            {
                cout<<-1;
                return 0;
            }
        }
        ind = *tmp_ind+1;
        //cout<<"it : "<<i<<" "<<iter<<" "<<ind<<"\n";
    }

    ll ans = iter*n + ind;
    cout<<ans;

    return 0;
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF 1e9

//dp[i][j] - answer for that state(min or max)
int main(){
	int n;cin>>n;
	// if(n==0) cout<<0
	vector<ll> v(n);
	vector<ll> pref(n+1,0);
	for(int i=0;i<n;i++){
		cin>>v[i];
		pref[i+1] = pref[i]+v[i];
	}
	// bool state = n%2==0; //when even T moves else K moves
	vector<vector<ll> > dp(n,vector<ll>(n,0));
	ll ans2=0;
	for(int d=0;d<n;d++){
		for(int i=0;i<n-d;i++){
			int j = i+d;
			if(j==i) {dp[i][j] = v[i];continue;}
			ll tot_sum = pref[j+1] - pref[i];
			assert(i+1<n&&j-1>=0);
			dp[i][j] = tot_sum - min(dp[i+1][j],dp[i][j-1]);
			if(d==n-1) ans2 = min(dp[i+1][j],dp[i][j-1]);
		}
	}
	cout<< (dp[0][n-1]-ans2) << endl;
	return 0;
}

Measured memory_bytes: 73648
def FOA(a, count):
	b = [a.count(a[i]) for i in range(len(a))]
	if  b == a:
		print(count)
		print(" ".join(map(str, b)))
	else:
		return FOA(b, count+1)

while True:
	n = int(input())
	if n == 0:
		break
	a = list(map(int, input().split()))
	FOA(a, 0)

Measured memory_bytes: 7668
import sys
from collections import Counter
from collections import deque
import math
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

from itertools import combinations_with_replacement as cwr
n,m,q=mp()
l=[lmp() for i in range(q)]
ans=0


for i in cwr(range(1,m+1),n):
    s=0
    for a,b,c,d in l:
        if i[b-1]-i[a-1]==c:
            s+=d
    ans=max(ans,s)
print(ans)

Measured memory_bytes: 68308
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const ll INF = 1001001001;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    mcf_graph<ll, ll> g(2*n+2);
    int s = 2*n;
    int t = 2*n+1;
    rep(i, n) {
        g.add_edge(s, i, k, 0);
        g.add_edge(n+i, t, k, 0);
    }
    g.add_edge(s, t, n*k, INF);
    rep(i, n) rep(j, n) {
        ll a;
        cin >> a;
        g.add_edge(i, n+j, 1, INF-a);
    }
    auto result = g.flow(s, t, n*k);
    
    ll ans = INF*n*k-result.second;
    pr(ans);
    auto edges = g.edges();
    vector<string> grid(n, string(n, '.'));
    
    for (auto e: edges) {
        if (e.from==s || e.to==t || e.flow==0) continue;
        int i = e.from;
        int j = e.to - n;
        grid[i][j] = 'X';
    }
    
    rep(i, n) pr(grid[i]);
    return 0;
}


Measured memory_bytes: 3932
$n=gets.chomp.split("").map!{|x| x.to_i}
$ans=nil

def df(num, i, s)
  $ans=s if num==7
  return if i>=4
  df(num+$n[i], i+1, s+"+"+$n[i].to_s)
  df(num-$n[i], i+1, s+"-"+$n[i].to_s)
end

df($n[0],1,$n[0].to_s)
puts "#{$ans}=7"

Measured memory_bytes: 1788
N, K = map(int, raw_input().split())
A = map(int, raw_input().split())
A.sort()

memo = [A[0], 1]
newA = []
for i in range(1, N):
	if A[i] != A[i-1]:
		newA.append(memo)
		memo = [A[i], 1]
	else:
		memo[1] = memo[1] + 1
newA.append(memo)
newA.sort(key=lambda x:x[1])

sum = 0
for i in range(0, len(newA)-K):
	sum = sum + newA[i][1]

print sum

Measured memory_bytes: 43924
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] A = new int[N];
		int sum = 0;
		for(int i=0;i<N;i++) {
			A[i] = sc.nextInt();
			sum += A[i];
		}
		sc.close();
		int anscnt = 0;
		for(int i=0;i<N;i++) {
			double p = A[i];
			double q = (double)sum/(double)(4*M);
			if(p>=q) {
				anscnt++;
			}
		}
		if(anscnt>=M) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<char> D(K);
  for (int i=0; i<K; i++) cin >> D[i];
  string num = to_string(N);
  while (true){
    for (int i=0; i<K; i++){
      auto result = find(num.begin(), num.end(), D[i]);
      if (result != num.end()) break;
      if (i == K-1){
        cout << num << endl;
        return 0;
      }
    }
    int tmp = stoi(num);
    tmp++;
    num = to_string(tmp);
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  int n,w;
  cin>>n>>w;
  vector<long> dp(w+1,0);
  for(int i=0;i<n;i++)
  {
    long we,va;
    cin>>we>>va;
    for(int j=w;j>=we;j--)
    {
      dp[j]=max(dp[j],dp[j-we]+va);
    }

  }
  cout<<dp[w];
  return 0;

}

Measured memory_bytes: 1024
package main

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

var (
	reader io.Reader = os.Stdin
	writer io.Writer = os.Stdout
)

func main() {
	reader = os.Stdin
	writer = os.Stdout
	run()
}

func run() {
	scanner := bufio.NewScanner(reader)

	for i := 1; scanner.Scan(); i++ {
		num, _ := strconv.Atoi(scanner.Text())

		if num == 0 {
			return
		}

		fmt.Fprintf(writer, "Case %d: %d\n", i, num)
	}
}

// readIntsFromStdin parses lines of inputs into 2D int array.
func readIntsFromStdin() [][]int {
	out := [][]int{}
	scanner := bufio.NewScanner(reader)

	for scanner.Scan() {
		var ints []int

		for _, s := range strings.Split(scanner.Text(), " ") {
			i, err := strconv.Atoi(s)

			if err != nil {
				fmt.Fprintln(os.Stderr, "Failed to parse string into int.", err)
				os.Exit(1)
			}

			ints = append(ints, i)
		}

		out = append(out, ints)
	}

	return out
}



Measured memory_bytes: 1304
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef complex<double> xy_t;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

const lint mod = 1e9+7;
const lint INF = mod*mod;
const int MAX =100010;

int main(){
    lint n, a, b;
    scanf("%lld%lld%lld", &n, &a, &b);
    if(a+b-1>n || a*b<n){
        printf("-1\n");
        return 0;
    }
    if(b==1){
        rep(i, n) printf("%d ", i+1);
        return 0;
    }
    lint t=a*b-n;
    lint q=t/(b-1), r=t%(b-1), s=q+b-r;
    int p[n], cur=1;
    rep(i, q) p[i]=cur++;
    rFor(i, s, q) p[i]=cur++;
    rep(i, (n-s)/b)rFor(j, s+(i+1)*b, s+i*b) p[j]=cur++;
    rep(i, n) printf("%d ", p[i]);
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
#define NINF -1e9

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    int N, M;
    cin >> N >> M;
    vector<pii> as;
    vector<int> costs = {2, 5, 5, 4, 5, 6, 3, 7, 6};
    rep(i, M){
        pii a;
        cin >> a.first;
        a.second = costs[a.first - 1];
        as.push_back(a);
    }
    sort(as.begin(), as.end(), greater<pii>());

    vector<int> dp(5e4 + 1, NINF);
    dp[0] = 0;

    for (int i=0;i<N;i++){
        for(auto a : as){
            dp[i + a.second] = max(dp[i] + 1, dp[i + a.second]);
        }
    }
    // dp[cost] = max(ketasuu)
    int keta = dp[N];

    int cost = N;
    string ans;
    for(int i = keta; i > 0; i --){
        for(auto a : as){
            if(cost - a.second >= 0 && dp[cost - a.second] == i - 1){
                ans += to_string(a.first);
                cost -= a.second;
                break;
            }
        }
    }
    if(ans.size() == 0){
        ans = "0";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end()
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;

int main() {
	int a, b, c; CI a >> b >> c;
	CO min(c, b / a) EN;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

//=============Segment_Tree_with_Lazy_Propagation====
const int MAX_N = 1 << 17;
int n;
ll initial = pow(2, 31) - 1;
vector<ll> dat(2 * MAX_N - 1, initial);
vector<ll> lazy(2 * MAX_N - 1, initial);

void init(ll n_) {
  n = 1;
  while (n < n_) {
    n *= 2;
  }
}

void eval(ll k, ll l, ll r) {
  if (lazy.at(k) != initial) {
    dat.at(k) = lazy.at(k);
    if (r - l > 1) {
      lazy.at(k * 2 + 1) = lazy.at(k);
      lazy.at(k * 2 + 2) = lazy.at(k);
    }
    lazy.at(k) = initial;
  }
}

void update(ll a, ll b, ll plus, ll k = 0, ll l = 0, ll r = n) {
  if (r <= a || b <= l) {
    eval(k, l, r);//子供のlazyを更新する必要がある
    return;
  }
  if (a <= l && r <= b) {
    lazy.at(k) = plus;
    eval(k, l, r);//子供のlazyを更新する必要がある
  }
  else {
    eval(k, l, r);//updateで使う子供のlazeとdat.at(k)の更新
    update(a, b, plus, k * 2 + 1, l, (l + r) / 2);
    update(a, b, plus, k * 2 + 2, (l + r) / 2, r);
    dat.at(k) = min(dat.at(2 * k + 1), dat.at(2 * k + 2));
  }
}

ll query(ll a, ll b, ll k = 0, ll l = 0, ll r = n) {
  if (r <= a || b <= l) {
    return INF;
  }
  eval(k, l, r);//dat.at(k)と子供のlazy更新のためreturn datとqueryに必要
  if (a <= l && r <= b) {
    return dat.at(k);
  }
  else {
    ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return min(vl, vr);
  }
}
//=================================================

main() {
  ll q;
  cin >> n >> q;
  init(n);
  for (ll i = 0; i < q; ++i) {
    ll com;
    cin >> com;
    if (com == 0) {
      ll s, t, x;
      cin >> s >> t >> x;
      update(s, t + 1, x);
    }
    else {
      ll s, t;
      cin >> s >> t;
      cout << query(s, t + 1) << "\n";
    }
  }
}



Measured memory_bytes: 7016
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Reflection.Metadata;

namespace AtCoder
{
    class Program
    {

        const int BiggestMod = 1000000007;

        public static void Main()
        {

            var args = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var res = (args[0] % args[2] != 0 ? 0 : 1);
            res += (args[1] / args[2] - args[0] / args[2]);
            Console.WriteLine(res);

        }
    }

}

Measured memory_bytes: 28244
#include <cstdio>
// A - Poor

using namespace std;

int main() {
    int A,B,C;

    scanf("%d%d%d",&A,&B,&C);

    if (A == B && A != C)
        printf("Yes\n");
    else if (A == C && A != B)
        printf("Yes\n");
    else if (B == C && A != B)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;
	while(cin>>s>>t) {
		sort(ALL(s));
		sort(ALLR(t));
		ll ans=s<t;
		cout<<YN(ans)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
n=int(input())
l=[]
for i in range(n):
    s,p=input().split()
    p=int(p)
    l.append([s,p,i+1])
l=sorted(l,key=lambda x:x[1],reverse=True)
l=sorted(l,key=lambda x:x[0])
for j in range(len(l)):
  print(l[j][2])

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

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;

  int cnt = 0;
  rep(i, n - 1) {
    if (s[i] != s[i + 1]) {
      cnt++;
    }
  }

  int ans = n - 1 - cnt + 2 * k;
  cout << min(ans, n - 1) << endl;

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define REP(i,a,b) for(int i =a; i <=b ; i++) 
int main()
{
  	speed;
    int n;
    cin >> n;
    int i , a[n];
    REP(i,0,n-1)
    {
        cin >> a[i];
    }
    int dp[n];
    dp[0]=0;
    dp[1] = abs(a[1]-a[0]);
    for(int i =2; i <=n-1 ; i++)
    {
        dp[i]  = min(dp[i-1] + abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout << dp[n-1];
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

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

	int count = n;
	while (n--)
	{
		int x;
		cin >> x;

		for (int i = 2; i <= sqrt(x); ++i)
			if (x % i == 0)
			{
				count--;
				break;
			}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1160
n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
A = [0] * (n+1)
B = [0] * (m+1)
for i in range(1, n+1):
    A[i] = A[i-1] + a[i]
for i in range(1, m+1):
    B[i] = B[i-1] + b[i]
ans = 0
j = m
for i in range(n+1):
    while j >= 0:
        if A[i] + B[j] <= k:
            ans = max(ans, i + j)
            break
        else:
            j -= 1
print(ans)

Measured memory_bytes: 119572
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



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

  vector<ll> a(100);
  a[0] = 2; a[1] = 1;
  for(int i=2; i<100; i++) {
    a[i] = a[i-1] + a[i-2];
  }

  cout << a[n] << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


public class Main {

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

        int n = sc.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) nums[i] = sc.nextInt();

        trace(nums);
        insertionSort(n, nums);
    }

    private static void insertionSort(int n, int[] nums) {
    	int j, v;
    	for (int i = 1; i < n; i++) {
    		v = nums[i];
    		j = i - 1;
    		while (j >= 0 && nums[j] > v) {
    			nums[j + 1] = nums[j];
    			j--;
    		}
    		nums[j + 1] = v;
    		trace(nums);
    	}
    }

    private static void trace(int[] nums) {
    	System.out.println(Arrays.toString(nums).replaceAll("[\\[\\],]", ""));
    }

}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(long long int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
#define pb push_back
#define mp make_pair
const unsigned int mod = 1e9+7;
const int mx=1000005;
int dx[]={0,0,-1,1};
int dy[]={-1,1,0,0};
int main(){
	/*freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);*/  
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n,m;cin >> n >> m;
	vector < vector <int > > d(n,vector <int > (m,-1));
	vector < pair <int ,int > > e;
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			char c;cin >> c;
			if(c=='#')e.push_back(mp(i,j));
		}
	}
	for(auto c : e)d[c.first][c.second]=0;
	int ans=0;
	for(int i=0;i<(int)e.size();++i){
		int x=e[i].first,y=e[i].second;
		ans=max(ans,d[x][y]);
		for(int t=0;t<4;++t){
			int gx=x+dx[t],gy=y+dy[t];
			if(0<=gx and gx<n and 0<=gy and gy<m and d[gx][gy]==-1){
				d[gx][gy]=d[x][y]+1;
				e.push_back(mp(gx,gy));
			}
		}
	}
	cout << ans << endl;
}
	

Measured memory_bytes: 14444
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll n;
    cin >> n;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    
    deque<ll> d;
    rep(i, n) {
        ll p = lower_bound(all(d), a[i]) - d.begin();
        if(p == 0) {
            d.push_front(a[i]);
        }
        else {
            d[p-1] = a[i];
        }
    }

    out(d.size());
    re0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    int n,ans=0;
    scanf("%d",&n);
    while (n>0){
        ans+=n%10;
        n/=10;
    }    
    if (ans==1){
        ans=10;
    }
    printf("%d\n",ans);
	return 0 ;
}

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

int main() {
    int N, X, T;
    cin >> N >> X >> T;
    int flag, cnt=0;
    flag = N;
    while(true) {
        flag -= X;
        ++cnt;
        if (flag <= 0) break;
    }
    cout << cnt*T << endl;
    return 0;
}

Measured memory_bytes: 3552
N = int(input())
lista = list(map(int, input().split()))
a = 0
b = sum(lista)
ans = abs(lista[0]- (b- lista[0]))

for i in range(N- 1):
  a+= lista[i]
  b-= lista[i]
  if(abs(a- b)< ans):
    ans = abs(a- b)
    
print(ans)

Measured memory_bytes: 24832
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
        char s[202];
        scanf("%s",s);
        int len=strlen(s)-1;
        //printf("%d\n",len);
        int n=len;
        for(int i=0;i<=len;i++)
        {
                int num=0;
                int flag=0;
                if(n%2==0)
                {
                        for(int j=0;j<n/2;j++)
                        {
                                if(s[j]==s[n/2+j])
                                        num++;
                                if(num==n/2)
                                {
                                        flag=1;
                                        printf("%d\n",n);
                                }
                        }
                }
                n--;
                if(flag)
                        break;
        }
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    vector<ll> dp(N, 1e12);
    dp[0] = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = 1; j <= K; j++) {
            if (i + j < N) {
                dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
            }
        }
    }
    cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1792
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n: usize = read();
    let k: isize = read();
    let q: isize = read();

    let mut point = [k - q; 100001];
    for _ in 0..q {
        let a: usize = read();
        point[a - 1] += 1;
    }

    for i in 0..n {
        if point[i] > 0 {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}

Measured memory_bytes: 5500
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>

typedef long long int64;

int main(void) {
  std::string s;
  std::cin >> s;
  int a = 0;
  if (s == "SUN") a = 7;
  else if (s == "MON") a = 6;
  else if (s == "TUE") a = 5;
  else if (s == "WED") a = 4;
  else if (s == "THU") a = 3;
  else if (s == "FRI") a = 2;
  else if (s == "SAT") a = 1;
  std::cout << a << std::endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
S = []
for _ in range(M):
    S.append(list(map(int, input().split()))[1:])
p = list(map(int, input().split()))
ans = 0
for bit in range(1 << N):
    for m in range(M):
        if p[m] != ([bin(bit)[2:].zfill(N)[s-1] for s in S[m]].count('1') % 2):
            break
    else:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.1415926535

ll dp[100004];

int main() 
{
    FAST;
    ll n,k;
    cin>>n>>k;
    ll h[n];
    for(int i=0;i<n;i++)
        cin>>h[i];
    for(ll i=1;i<n;i++)
    {
        ll mi=10000000000000ll;
        for(ll j=1;j<=min(k,i);j++)
            mi=min(mi,dp[i-j]+abs(h[i]-h[i-j]));
        dp[i]=mi;
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1792
N, P = gets.split.map(&:to_i)
as = gets.split.map(&:to_i).map{|i|i%2}
if P == 0
    puts as.all?{|a| a == 0} ? 2**N : 2**(N-1)
else
    puts as.all?{|a| a == 0} ? 0 : 2**(N-1)
end


Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;

int main() {

	int N;
	cin >> N;
	vector<int>num;

	for (int i = 0; i < N; i++) {
		int d;
		cin >> d;
		num.push_back(d);
	}

	sort(num.begin(), num.end());


	cout << num[N / 2] - num[N / 2-1] << endl;

	return 0;

}

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

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

const int INF = 1e9;
const int MAXN = 3e5 + 5;
const int MOD = 1e9 + 7;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
a = []
for i in range(5):
    a.append(int(input()))
b = []
for i in range(5):
    b.append(a[i]-a[i]//10*10)
mini = 10
index = 0
for i in range(5):
    if mini > b[i] and b[i] > 0:
        index = i
        mini = b[i]

ans = 0
for i in range(5):
    if i == index:
        ans += a[i]
    else:
        ans += ((a[i]-1)//10+1)*10
print(ans)


Measured memory_bytes: 3064
#include<cstdio>
using namespace std;

int n,h[100];
int dfs(int l,int r,int x){
    if(l>r){
        return 0;
    }
    int p=0,a=10000;
    for(int i=l;i<=r;i++){
        if(a>h[i]){
            a=h[i];
            p=i;
        }
    }
    return a-x+dfs(l,p-1,a)+dfs(p+1,r,a);
}

int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    printf("%d\n",dfs(0,n-1,0));
}

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void pout(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void pout(const T &value, const Args&... args){std::cout << value << " ";pout(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int A, B, C, D;

  while(cin >> A >> B >> C >> D){
    bool ans;

    bool t = 1;
    while(1){
      if(t){
        C -= B;
        if(C <= 0){
          ans = true;
          break;
        }
      }else{
        A -= D;
        if(A <= 0){
          ans = false;
          break;
        }
      }
      

      t = !t;
    }
    
    pout(ans ? "Yes" : "No");
  }

  return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main(){
    int d,g,ans=1e9;
    cin >> d >> g;
    int p[d],c[d];
    for(int i=0;i<d;i++){
        cin >> p[i] >> c[i];
    }
    for(int i=0;i<(1<<10);i++){
        int cnt = 0,anw = 0,c1 = 0;
        bitset<10> a(i);
        for(int j=0;j<d;j++){
            if(a.test(j)){
                cnt += ((j+1)*100*p[j]+c[j]);
                anw += p[j];
            } 
            else c1 = max(c1,j+1);
        }
        if(g>cnt){
            if(((g-cnt)+c1*100-1)/(c1*100)<=p[c1-1]) anw += ((g-cnt)+c1*100-1)/(c1*100);
            else continue;
        }
        ans = min(ans,anw);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <set>
#include <list>

using namespace std;
int cnt{0};

vector<int> insertion_sort(vector<int> A, int n, int g) {
    int j, v;
    for (int i = g; i < n; i++) {
        v = A[i];
        j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j + g] = v;
    }
    return A;
}

int main() {
    int n, flag{1}, count{0}, min_i, m = 1;
    int e = 1;
    cin >> n;
    vector<int> A, G;

    for (int i = 0; i < n; i++) {
        cin >> e;
        A.push_back(e);
    }

//    e = (n / 2 != 0) ? n / 2 : 1;
    e = 1;
    while (e <= n) {
        G.push_back(e);
        e = ceil(2.25*e+1);
    }
    m = G.size();

    for (int i = m-1; i >= 0; i--) {
        A = insertion_sort(A, n, G[i]);
    }


//    while (m >= 0) {
//        count = 0;
//        int G[m];
//        for (int i = m-1; i >= 0; i--) {
//            G[i] = i;
//        }
//        if (count <= ceil(pow(n, 1.5)))break;
//        m++;
//    }

    cout << m << endl;
    for (int i = m-1; i >= 0; i--) {
        cout << G[i];
        if (i == m - 1) cout << endl;
        else cout << " ";
    }
    cout << cnt << endl;
    for (int i = 0; i < n; i++) {
        cout << A[i] << endl;
    }
}


Measured memory_bytes: 10860
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    vector<P>ans;
    for(int i = 1; i < N-1; i++) {
        if(A[i] < 0) {
            ans.push_back({A[N-1],A[i]});
            A[N-1]-=A[i];
        }
        else {
            ans.push_back({A[0],A[i]});
            A[0]-=A[i];
        }
    }
    cout << A[N-1]-A[0] << endl;
    ans.push_back({A[N-1],A[0]});
    for(int i = 0; i < N-1; i++) {
        cout << ans[i].first << " " << ans[i].second << endl;
    }
}


Measured memory_bytes: 6156
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <limits.h>
using namespace std;
typedef long long ll;
const int MAX_N = 200000 + 2;
ll sum[MAX_N] = { 0, }, A[MAX_N];

int main()
{
	ll N, ans = 0;
	cin >> N;
	for (int i = 1; i <= N; i++)
	{
		cin >> A[i];
		if (i - A[i] >= 1)sum[i - A[i]]++;
	}
	for (int i = 1; i <= N; i++)
	{
		if (i + A[i] < MAX_N)
		{
			//cout << "i=" << i << "," << sum[i+A[i]] << endl;
			ans += sum[i+A[i]];
		}
		
	}
	cout << ans;
}

Measured memory_bytes: 6724
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    ll n, m;
    cin >> n >> m;
    if(m <= 2*n) {
        cout << m/2 << endl;
        return 0;
    }
    else {
        cout << n + (m - 2*n)/4 << endl;
        return 0; 
    }
}

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

int main() {
  long long  h, n;
  cin >> h >> n;
  
  long long count = 0;
  for (int i = 0; i < n; i++) {
    int _a;
    cin >> _a;
    count += _a;
  }
  
  if (count >= h) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
char getChar(string& s, int index){
    while(true){
        if(s[index]!='0')
            return s[index];
        ++index;
    }
}
int main(){//D問題
    string s;
    cin >> s;
    bool flag;
    int num=0;
    do{
        flag=false;
        char c=s[0];
        for(int i=1;i<s.length()-1;++i){
            if(s[i]=='0')
                continue;
            if(c==getChar(s, i+1)){
                c=s[i];
            }else{
                ++num;
                s[i]='0';
                flag=true;
            }
        }
    }while(flag);
    cout << ((num&1)==1 ? "First" : "Second");
    return 0;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline

mod = 10**9+7
def cmb(n, r, mod=mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NN = 5*10**5 # 使うデータによって変える
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, NN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N, K = map(int, input().split())
A = list(map(int, input().split()))

A.sort()
ans = 0
for i, a in enumerate(A):
    ans += (cmb(i, K-1) - cmb(N-(i+1), K-1)) % mod * a % mod
    ans %= mod

print(ans)

Measured memory_bytes: 73452
import sys

n = int(sys.stdin.readline())
a_list = [int(x) for x in sys.stdin.readline().split()]

color_list = [0] * 8
rainbow = 0
for i in a_list:
    if int(i / 400) < 8:
        color_list[int(i / 400)] += 1
    else:
        rainbow += 1
color_list = [i for i in color_list if i != 0]
confirm = len(color_list)
if confirm == 0:
    print(1, min(8, rainbow))
else:
    print(confirm, confirm + rainbow)


Measured memory_bytes: 3064
n = int(input())
s = ["".join(sorted(input())) for _ in range(n)]

d = {}
for i in s:
  if i in d:
    d[i] += 1
  else:
    d[i] = 1

ans = 0
for i in d:
  t = d[i]
  ans += t*(t-1)//2
print(ans)

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

using namespace std;

/**
* Binary_Indexed_Tree(BIT)
* Fenwick Tree
* 1-indexed!!!
*/
template<typename T = int>
class BIT {
private:
    std::vector<T> bit;
    const int N;
    const int MOD;
public:
    BIT() : N(-1), MOD(-1) {}
    BIT(int n, int mod) : N(n), bit(n + 1, 0), MOD(mod) {}
    //bit[point]にnum追加
    void add(int point, T num) {
        assert(N != -1 && 0 <= point && point <= N);
        while (point <= N) {
            (bit[point] += num) %= MOD;
            point += point & -point;
        }
    }
    //pointまでの値の和を返す
    T sum(int point) {
        assert(N != -1 && 0 <= point && point <= N);
        T res = 0;
        while (point > 0) {
            (res += bit[point]) %= MOD;
            point -= point & -point;
        }
        return res;
    }
    //left から right の区間和
    T sum(int left, int right) {
        return (this->sum(right) - this->sum(left - 1) + MOD) % MOD;
    }
};

const int MAX = 1e5 + 10;
long long A[MAX];
long long N, M;

void naive() {
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        long long sum = 0;
        for (int j = i; j < N; j++) {
            sum += A[j];
            if (sum % M == 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

int main() {
    cin >> N >> M;
    BIT<long long> ft(N, M);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i] %= M;
        ft.add(i + 1, A[i]);
    }
    long long ans = 0;
    map<long long, int> mp;
    {
        long long sum = 0;
        for (int i = 0; i < N; i++) {
            sum += A[i];
            sum %= M;
            mp[sum]++;
        }
    }
    long long sum = 0;
    for (int i = 0; i < N; i++) {
        ans += mp[sum];
        (sum += A[i]) %= M;
        mp[sum]--;
        cerr << ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5760
#include<stdio.h>
#include<math.h>
int main(){
int a[110000],b=0,i=3,c=0,d=2,x;
while(d<100050){
if(d==2){
a[b]=d;
b++,d++;
}
else{
while(i<=sqrt(d)){
if(d%i==0){
c++;
break;
}
i=i+2;
}
if(c!=1){
a[b]=d;
b++;
}
c=0,i=3;
d=d+2;
}
}
  scanf("%d\n",&x);
  for(i=0;i<=x;i++){
    if(a[i]>=x){
      break;
    }
  }
  printf("%d\n",a[i]);
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
    int A,B;
    cin>>A>>B;
    if(A>=13)cout<<B<<endl;
    else if(A>5)cout<<B/2<<endl;
    else cout<<0<<endl; 
}



Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <algorithm>
#include <string>
//#include <functional>
//#include <cmath>


int main(){
    int32_t N;
    std::cin >> N;
    std::string S;
    std::cin >> S;

    char prev = '0';
    char tmp = '0';
    int32_t res = 0;
    for(int32_t i = 0; i < N; i++){
        tmp = S.at(i);
        if(tmp != prev){
            res++;
        }
        prev = tmp;
        //std::cout << tmp <<"," << prev << std::endl;
    }

    
    std::cout << res;

    return 0;
}


Measured memory_bytes: 512