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

using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<ll> X(N);
  for (int i = 0; i < N; ++i) {
    cin >> X[i];
  }
  vector<ll> X_sort = X;
  sort(X_sort.begin(), X_sort.end());

  ll mid_low = X_sort[X_sort.size() / 2 - 1];
  ll mid_high = X_sort[X_sort.size() / 2];
  double mid = (mid_low + mid_high) / 2.0;
  // ...., mid_low, mid_high, ....

  for (int i = 0; i < N; ++i) {
    if (X[i] >= mid)
      cout << mid_low << endl;
    else if (X[i] < mid)
      cout << mid_high << endl;
  }
  return 0;
}


Measured memory_bytes: 5376
#include<cstdio>
using namespace std;
long long abs(long long x)
{
	if(x<0)return -x;
	return x;
}
int main()
{
	long long n,k;
	scanf("%lld%lld",&n,&k);
	if(n%k==0)
	{
		printf("0\n");
	}
	else
	{
		n=n%k;
		if(abs(n-k)>abs(n))
		{
			printf("%lld\n",abs(n));
		}
		else
		{
			printf("%lld\n",abs(n-k));
		}
	}
	return 0;
}

Measured memory_bytes: 128
# coding: utf-8


def solve(*args: str) -> str:
    abc = list(map(int, args[0].split()))

    ret = 'No'
    if abc.count(abc[0]) == 2:
        ret = 'Yes'
    if abc.count(abc[1]) == 2:
        ret = 'Yes'
    if abc.count(abc[2]) == 2:
        ret = 'Yes'

    return ret


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;

int main()
{
    int N;
    cin >> N;
    vector<int> h(N);
    int mx = -1;
    rep(i, N)
    {
        int tmp;
        cin >> tmp;
        h.at(i) = tmp;
        mx = max(mx, tmp);
    }
    int cnt = 0;
    while(mx != 0)
    {
        rep(i, N)
        {
            if(h.at(i) == mx)
            {
                h.at(i)--;
                rep2(j, i+1, N)
                {
                    if(h.at(j) == mx)
                    {
                        h.at(j)--;
                    }
                    else
                    {
                        break;
                    }
                }
            cnt++;
            }
        }
        mx--;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>

using namespace std;

int n;

int team[101];

int main(){
	scanf("%d",&n);
	for(int g=0;g<n*(n-1)/2;g++){
		int at,bt,as,bs;
		scanf("%d %d %d %d",&at,&bt,&as,&bs);
		if(as == bs){
			team[at] += 1;
			team[bt] += 1;
		}else{
			team[as > bs ? at : bt] += 3;
		}
	}
	for(int t=1;t<=n;t++){
		int ans = 1;
		for(int i=1;i<=n;i++){
			if(t == i){continue;}
			if(team[i] > team[t]){
				ans++;
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 0
import java.util.*;
class Main {
    static long cnt;
    static int N,M;
    static int[] k,p;
    static int[][] s;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();
        k = new int[M];
        s = new int[M][N];
        p = new int[M];
        sc.nextLine();
        for(int i = 0; i<M; i++) {
            String[] str = sc.nextLine().split(" ",0);
            //System.out.println(str[0]);
            k[i] = Integer.parseInt(str[0]);
            for(int j = 1; j<str.length; j++) {
                s[i][j-1] = Integer.parseInt(str[j]);
            }
        }
        for(int i = 0; i<M; i++) {
            p[i] = sc.nextInt();
        }
        cnt = 0;
        dfs(0, new boolean[N]);
        System.out.println(cnt);
    }
    public static void dfs(int depth, boolean[] env) {

        if(depth == N) {
            if(isAllOn(env)) cnt++;
            return;
        }
        //System.out.println(N+" "+depth +" "+env[Math.max(0,depth-1)]);
        boolean[] cenv = new boolean[N];
        for(int i = 0; i<cenv.length; i++) cenv[i] = env[i];
        cenv[depth] = true;
        dfs(depth+1, cenv);
        cenv[depth] = false;
        dfs(depth+1, cenv);
    }
    public static boolean isAllOn(boolean[] env) {
        //System.out.println("in");
        int[] a = new int[M];
        for(int i = 0; i<M; i++) {
            for(int j = 0; j<N; j++) {
                if(s[i][j]==0) continue;
                //System.out.println(s[i][j]);
                int index = s[i][j]-1;
                if(env[index]) a[i]++;
            }
//            for(int ai: a)System.out.print(ai+" ");
//            System.out.println();
        }

        for(int i = 0; i<M; i++) {
            if(a[i]%2 != p[i]) return false;
        }
        return true;
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define es cout<<" "
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;
template<class T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<class T, class... Ts> 
auto make_vec(size_t a, Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));}

int main(void) {
    int n;
    cin >> n;
    int a = n / 100;
    int b = n % 100;
    
    auto ismonth = [](int n) -> bool {
        if (n <= 0) return false;
        if (n >= 13) return false;
        return true;
    };
    
    if (ismonth(a) and ismonth(b)) cout << "AMBIGUOUS" << endl;
    else if (ismonth(a) and !ismonth(b)) cout << "MMYY" << endl;
    else if (!ismonth(a) and ismonth(b)) cout << "YYMM" << endl;
    else cout << "NA" << endl;
}


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

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    int A,B;
    cin >> A >> B;
    if(A+B<10)cout << A+B << endl;
    else cout << "error" << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	final int INF = Integer.MAX_VALUE;
	void solve(){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int W = scan.nextInt();
		int[] w = new int[n];
		int[] v = new int[n];
		for(int i = 0; i < n; i++) {
			w[i] = scan.nextInt();
			v[i] = scan.nextInt();
		}
		long[][] dp = new long[n + 1][100001];
		for(int i = 0; i < n + 1; i++) {
			for(int j = 0; j < 100001; j++) {
				dp[i][j] = INF;
			}
		}
		dp[0][0] = 0;
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < 100001; j++) {
				if(j < v[i]) dp[i + 1][j] = dp[i][j];
				else dp[i + 1][j] = Math.min(dp[i][j], dp[i][j - v[i]] + w[i]);
			}
		}
		for(int i = 100000; i >= 0; i--) {
			if(dp[n][i] <= W) {
				System.out.println(i);
				return;
			}
		}
		scan.close();
	}

	public static void main(String[] args){
		new Main().solve();
	}
}
 

Measured memory_bytes: 138116
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 102000;
int n,m,a[N];
struct SPJ{
	int f[N];
	int find(int x){return f[x]==x?x:f[x]=find(f[x]);}
	void merge(int x, int y){x=find(x);y=find(y);f[x]=y;}
	void add(int *a, int m){
		for(int i=1,j=0;i<=m;j+=a[i],i++){
			rep(k,1,a[i]/2)merge(j+k,j+a[i]-k+1);
		}
	}
	void ck(){
		int cnt=0;rep(i,1,n)cnt+=find(i)==i;
		assert(cnt==1);
	}
}spj;
int main() {
	read(n);read(m);rep(i,1,n)spj.f[i]=i;
	rep(i,1,m)read(a[i]);
	int cnt=0;rep(i,1,m)cnt+=a[i]%2;
	if(cnt>2){puts("Impossible");return 0;}
	rep(i,1,m)if(a[i]%2){swap(a[1],a[i]);break;}
	rep(i,2,m)if(a[i]%2){swap(a[m],a[i]);break;}
	rep(i,1,m)printf("%d ",a[i]);puts("");
	spj.add(a,m);
	if(m==1){a[1]=1;a[2]=n-1;m=2;if(!a[m])m--;}
	else{a[1]++;a[m]--;if(!a[m])m--;}
	printf("%d\n",m);
	rep(i,1,m)printf("%d ",a[i]);puts("");
	spj.add(a,m);
	spj.ck();
	return 0;
}


Measured memory_bytes: 640
#define DEBUG
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
 
#define F first
#define S second
#define fi first
#define sc second
#define pb push_back
#define endl "\n"

#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }

#ifdef DEBUG
    #define dbg(s) {s;}
#endif

#ifndef DEBUG
    #define dbg(s)
#endif

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int grand(int x) { // from [0, x-1]
    return uniform_int_distribution<int>(0, x - 1)(rng);
}

#define int ll
#define i32 int32_t

#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 

#define all(v) (v).begin(),(v).end()

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

int getInt () {
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}


ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 

const ll mod = 1e9 + 7;

ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}

const int maxn = 1e6 + 7;
const int N = 1e5 + 7;

const ll inf = 1e9 + 7;

int arr[N];
int par[N];

int _find(int x){
    if(x == par[x]) return x;
    return par[x] = _find(par[x]);
}

void _union(int x, int y){
    par[x] = y;
}

vector < pll > v;

i32 main() {
    //freopen("<file>.in", "r", stdin);
    //freopen("<file>.out", "w", stdout);

    IOS;

    int n, m ,q;
    cin >> n >> m >> q;
   
    for(int i = 0; i < n; i++){
        par[i] = i;
    }
    
    int x, y, z;
    for(int i = 0; i < q; i++){
        cin >> x >> y >> z;
        if(z == 0){
            _union(_find(x), _find(y));
        }else{
            v.pb({x, y});
        }
    }

    z = 0;
    for(auto i : v){
        if(_find(i.fi) == _find(i.sc)){
            cout << "No" << endl;
            return 0;
        }
        z = 1;
    }

    int ct = 0;
    for(int i = 0; i < n; i++) ct += int(par[i] == i);

    if(z == 0){
        if(m <= n - ct + (ct*(ct-1))/2){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        if(ct == 2 || m == n - 1){
            cout << "No" << endl;
            return 0;
        }
        if(m <= n - ct + (ct*(ct-1))/2){
          cout << "Yes" << endl;
        }else{
          cout << "No" << endl;
        }
    }  


}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

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

    int e;
    while (cin >> e, e) {
        int m = 99999999;
        for (int z = 0; z * z * z <= e; z++) {
            for (int y = 0; y * y + z * z * z <= e; y++) {
                int x = e - (y * y + z * z * z);
                m = min(m, x + y + z);
            }
        }
        cout << m << endl;
    }

}

Measured memory_bytes: 3112
N,M = map(int,(input().split()))
A = list(map(int,(input().split())))
c = 0
p = sum(A)
for i in range(N):
    if A[i] >= p/4/M:
        c += 1

def yn(p):
    if p:
        return "Yes"
    else:
        return "No"
print(yn(c>=M))

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define PRINT(a)   cout << (a) << endl
#define RALL(v) rbegin(v), rend(v)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main(){
  int N;
  cin >> N;
  vi x(N),y(N);
  REP(i,N)cin >> x[i] >> y[i];

  double sum=0;
  REP(i,N)FOR(j,i,N){
    sum += sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
  }

  printf("%.10f\n", sum * 2 / N);
}



Measured memory_bytes: 3776
#include<iostream>
#include<vector>
#include<queue>
#include<unordered_map>
#include<map>
#include<set>
#include<unordered_set>
#include<algorithm>
#include<cmath>
#include<cassert>
#include<thread>
#include<future>
using namespace std;

#define INF 1e15+7
typedef long long ll;



int main(){
    int n;
    cin>>n;
    vector<ll>a(n);
    ll mi=1e9+10,ma=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        ma=max(ma,a[i]);
    }
    sort(a.begin(),a.end());
    ll best_n,best_dif=1e9+2;
    for(int i=0;i<n-1;i++){
        if(abs(a[i]*2-ma)<best_dif){
            best_n=a[i];
            best_dif=abs(a[i]*2-ma);
        }
    }
    cout<<ma<<" "<<best_n<<endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

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

	cout << 50 << endl;
	vector<ll> a(50);
	REP(i, 50) a[i] = 49 + (K/50);
	ll ama = K%50;
	REP(i, 50) a[i] -= ama;
	REP(i, ama) a[i] += 51;
	REP(i, 50) cout << a[i] << " ";
	cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
//public class abc163_c{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];

		for(int i=0; i<(n-1); i++ ){
			int x = scan.nextInt();
			a[x] += 1; 
		}

		for(int i=0; i<n; i++ ){
			if(i!=0)System.out.println(a[i]);
		}
      	System.out.println(0);

	}
}

Measured memory_bytes: 59100
using System;
class Program
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int a, b;
        a = int.Parse(str[0]);
        b = int.Parse(str[1]);
        Console.WriteLine((a + b + (a + b) % 2) / 2);
    }
}

Measured memory_bytes: 11092
H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]

result = []
y = 0
while y < H:
    x = 0
    while x < W:
        if a[y][x] % 2 == 1:
            if x == W - 1:
                if y == H - 1:
                    break
                else:
                    result.append('%d %d %d %d' % (y + 1, x + 1, y + 2, x + 1))
                    a[y + 1][x] += 1
            else:
                result.append('%d %d %d %d' % (y + 1, x + 1, y + 1, x + 2))
                a[y][x + 1] += 1
        x += 1
    if y == H - 1:
        break
    y += 1
    x = W - 1
    while x >= 0:
        if a[y][x] % 2 == 1:
            if x == 0:
                if y == H - 1:
                    break
                else:
                    result.append('%d %d %d %d' % (y + 1, x + 1, y + 2, x + 1))
                    a[y + 1][x] += 1
            else:
                result.append('%d %d %d %d' % (y + 1, x + 1, y + 1, x))
                a[y][x - 1] += 1
        x -= 1
    y += 1

print(len(result))
print('\n'.join(result))


Measured memory_bytes: 20120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  vector<int> a(n + 1);
  int ans = 0;

  for (int i = 1; i <= n; i++) {
    cin >> a.at(i);
    if((i % 2) != 0) {
      //forループ中に奇数のマスがあった場合の処理
      if((a.at(i) % 2) != 0) {
        //奇数のマスのAiが奇数であった場合に加算
        ans = ans + 1;
      }
    } 
    //cout << a.at(i) << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll a,b;
    cin >> a >> b ;
    if(a*b <= 0)cout << "Zero" << endl;
    else if(a > 0)cout << "Positive" << endl;
    else{
        if(b > 0){
            if(a%2){
                cout << "Negative" << endl;
            }
            else{
                cout << "Positive" << endl;
            }
        }
        else{
            if((b-a)%2){
                cout << "Positive" << endl;
            }
            else{
                cout << "Negative" << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int t;
	while(cin >> t && t)
	{
		vector<int> v;
		v.push_back(t);

		rep(i,4)
		{
			cin >> t;
			v.push_back(t);
		}
		
		map<int,int> m;
		rep(i,5)
		{
			m[v[i]]++;
		}

		if(m.size() >= 3 || m.size() == 1)
		{
			rep(i,5) cout << 3 << endl;
		}
		else
		{
			if(m[1] > 0 && m[2] > 0)
			{
				rep(i,5)
				{
					if(v[i] == 1) cout << 1 << endl;
					else cout << 2 << endl;
				}
			}
			else if(m[2] > 0 && m[3] > 0)
			{
				rep(i,5)
				{
					if(v[i] == 2) cout << 1 << endl;
					else cout << 2 << endl;
				}
			}
			else if(m[1] > 0 && m[3] > 0)
			{
				rep(i,5)
				{
					if(v[i] == 3) cout << 1 << endl;
					else cout << 2 << endl;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
int main(){
    int a;
    int b;
    int c;
    int k;
    int l;
    int m=0;
    scanf("%d %d %d",&a,&b,&c);
    k=a;

    while(k<=b){
        l=c%k;
        if(l==0){
            m=m+1;
            k=k+1;
            }
        else{
            k=k+1;
        }
    }
    printf("%d\n",m);
}






Measured memory_bytes: 2108
#include <bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;
#define MAX 1000000

int  main(){
  int H,W;
  cin>>H>>W;
  int a[1000][1000];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>a[i][j];
    }
  }

  int y1[MAX],x1[MAX],y2[MAX],x2[MAX];

  int next=0,count=0;
  
  for(int i=0;i<H;i++){
    if(i%2==0){
      for(int j=0;j<W;j++){
        if(next){
          a[i][j]++;
          y2[count]=i+1;
          x2[count]=j+1;
          count++;
          next--;
        }
        if(a[i][j]%2==0) continue;
        y1[count]=i+1;
        x1[count]=j+1;
        next++;
      }
    }
    if(i%2!=0){
      for(int j=W-1;j>=0;j--){
        if(next){
          a[i][j]++;
          y2[count]=i+1;
          x2[count]=j+1;
          count++;
          next--;
        }
        if(a[i][j]%2==0) continue;
        y1[count]=i+1;
        x1[count]=j+1;
        next++;
      }
    
     }
  }
  cout<<count<<endl;
  for(int i=0;i<count;i++){
    cout<<y1[i]<<" "<<x1[i]<<" "<<y2[i]<<" "<<x2[i]<<endl;
  }
}


Measured memory_bytes: 18304
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  rep(i,n)
  {
    if(a[i]==i+1)a[i]=1;
    else a[i]=0;
    //cout<<a[i]<<endl;
  }
  int id=0;
  int res=0;
  while(1)
  {
    int cnt=0;
    while(a[id]==1)
    {
      cnt++;
      id++;
      if(id==n)break;
    }
    if(cnt==1)res+=cnt;
    else if(cnt>1)res+=(cnt+1)/2;
    if(id==n)break;

    while(a[id]==0)
    {
      id++;
      if(id==n)break;
    }
    if(id==n)break;

  }
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 640
import java.util.*;
import java.util.Scanner;


public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int a[] = new int[n];
        int res = 0;
        
        for(int i = 0;i < n;i++){
            a[i] = sc.nextInt();
        }
        
        for(int i = 1;i < (n-1);i++){
            if(a[i-1]<a[i] && a[i]<a[i+1]){
                res++;
            }else if(a[i+1]<a[i] && a[i]<a[i-1]){
                res++;
            }
        }
        System.out.println(res);
    }
}


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

int w, h;
bool p[90][90];
int po = -1;

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

int dfs(int y, int x, int d)
{
  po = max(po, d);

  int ret = d;
  p[y][x] = false;
  for (int i = 0; i < 4; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (0 <= ny && ny < h && 0 <= nx && nx < w && p[ny][nx]){
      ret = max(dfs(ny, nx, d + 1), d);
    }
  }
  p[y][x] = true;
  return ret;
}

int main()
{
  while (cin >> w >> h, w) {
    po = -1;
    for (int i = 0; i < h; i++){
      for (int j = 0; j < w; j++){
        int a;
        cin >> a;
        p[i][j] = (a ? true : false);
      }
    }

    int m = -1;
    for (int i = 0; i < h; i++){
      for (int j = 0; j < w; j++){
        if (!p[i][j]) continue;
        m = max(m, dfs(i, j, 1));
      }
    }

    cout << po << endl;
  }
}

Measured memory_bytes: 3004
N = int(input())
a = [int(x) for x in input().split()]

a_sum=0
b_sum=0

for i in range((N+1)//2):
    max_value=max(a)
    max_index=a.index(max_value)
    a_sum+=max_value
    a[max_index]=0

    max_value=max(a)
    max_index=a.index(max_value)
    b_sum+=max_value
    a[max_index]=0

print(a_sum-b_sum)


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

int main() {
  string S;
  cin >> S;
  int red = 0;
  int blue = 0;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == '0') red += 1;
    else blue += 1;
  }
  cout << min(red, blue) * 2 << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<math.h>


int main(){

  long long int N,M,L;

  scanf("%lld %lld %lld",&N,&M,&L);

  /*
  int A[N];
  int i;
  for(i=0;i<N;i++){
   scanf("%d",&A[i]);
   }
  */
  long long int A,B;
  A = N%(M+L);
  B = N/(M+L);

  if (A >= M){
    printf("%lld",B*M+M);
  }
  else if(A == 0){
    printf("%lld",B*M);
  }
  else{
    printf("%lld",B*M+A);
  }






 return(0);
 }


Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#define Rint register int
#define mem(a,b) memset(a,(b),sizeof(a))
#define Temp template<typename T>
using namespace std;
typedef long long LL;
Temp inline void read(T &x){
    x=0;T w=1,ch=getchar();
    while(!isdigit(ch)&&ch!='-')ch=getchar();
    if(ch=='-')w=-1,ch=getchar();
    while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^'0'),ch=getchar();
    x=x*w;
}

int n,m;

int main(){
	read(n);read(m);
	for(Rint i=0;i<=n;i++){
		for(Rint j=0;j<=n;j++){
			int k=n-(i+j);
			if(k<0)continue;
			if(i*10000+j*5000+k*1000==m){
				printf("%d %d %d\n",i,j,k);
				return 0;
			}
		}
	}
	printf("-1 -1 -1\n");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void PDF(long long n,long long m,long long A[])
{
    int i,s=0,t;
    for (i=0;i<m;i++)
    {
        s = s+A[i];
    }
    t = n-s;
    if(t<0)
    {
        cout << "-1" <<endl;
    }
    else
    {
        cout << t <<endl;
    }
}
int main()
{
    long long n,m,i,A[100000];
    cin >> n >> m;
    for (i=0;i<m;i++)
    {
       cin >> A[i] ;
    }
    PDF(n,m,A);
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<iomanip>
using namespace std;

typedef pair<int, int> p;

int main(){
    int a,b,X,Y,i=0,j=0;
    vector<p> v1,v2,v3;
    cin>>X;
    while(X--){
        cin>>a>>b;
        v1.push_back(make_pair(a, b));
    }
    cin>>Y;
    while(Y--){
        cin>>a>>b;
        v2.push_back(make_pair(a, b));
    }
    while(true){
        if(i==v1.size()&&j==v2.size())
            break;
        else if(i==v1.size())
            v3.push_back(v2[j++]);
        else if(j==v2.size())
            v3.push_back(v1[i++]);
        else
            v3.push_back(v1[i]>v2[j]?v2[j++]:v1[i++]);
    }
    p t;
    cout<<v3[0].first<<":"<< setw(2) << setfill('0')<<v3[0].second;
    t=v3[0];
    for(int i=1;i<v3.size();i++){
        if(v3[i]==t)continue;
        t=v3[i];
        cout<<" "<<v3[i].first<<":"<< setw(2) << setfill('0')<<v3[i].second;
    }
    cout<<endl;
}

Measured memory_bytes: 1220
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    vector< vector<int> > sw(M, vector<int>(0) );

    int k[M];
    int temp;
    for(int i=0;i<M;i++){
        cin >>k[i];
        for(int j=0;j<k[i];j++){
            cin >> temp;
            sw[i].emplace_back(temp);
        }
    }
    int p[M];
    for(int i=0;i<M;i++) cin >> p[i];
    int c=0;
    int ok =1;
    vector<int> on(N);
    int dec;
    int ans =0;
    for(int i=0;i<pow(2,N);i++){
        ok = 1;
        dec = i;
        for(int j=0;j<N;j++){
            if(dec%2==1) on[j] = j + 1;
            else on[j] = -1;
            dec/=2;
        }
        for(int j=0;j<M;j++){
            c = 0;
            for(auto itr = sw[j].begin(); itr != sw[j].end(); ++itr){  // j番目のライトに必要なスイッチを探索
                if(find(on.begin(), on.end(), *itr) != on.end()) c++;  // 見つかったら　cをインクリメント
            }
            if(c%2 != p[j]){ //一個でもつかなかったらアウト
                ok = 0;
                break;
            }
        }
        if(ok == 1) ans ++; 

    }
    cout << ans << endl;
    
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
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;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



struct UF {vector<int> par;
	UF(int NV) { par.clear(); rep(i,NV) par.push_back(i); }
	void reset() { rep(i,par.size()) par[i] = i; }
	int operator[](int x) { return par[x] == x ? x : par[x] = operator[](par[x]); }
	void operator()(int x, int y) {x = operator[](x); y = operator[](y);if (x != y) par[x] = y;}
};

int h, w, g[404][404], bl, wh, res;
string s[404];

void rec(int x, int y) {
	g[x][y] = 1;
	(s[x][y]=='.' ? wh : bl)++;
	rep(i,4) {
		int xx = x+dx[i], yy = y+dy[i];
		if (ool(xx,yy,h,w) || g[xx][yy]) continue;
		if (s[x][y]!=s[xx][yy]) rec(xx,yy);
	}
}

signed main() {
	cin >> h >> w;
	rep(i,h) cin >> s[i];
	rep(i,h) rep(j,w) if (!g[i][j]) {
		bl = wh = 0;
		rec(i,j);
		res += bl*wh;
	}
	cout << res << endl;
}


Measured memory_bytes: 14208
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        a: [[usize1; n]; 2],
    }
    let inf = std::u16::MAX;
    let mut dp = vec![vec![inf; 1 << n]; 50];
    dp[0][0] = 0;
    for s in 0..50 {
        for i in 0..(1usize << n) {
            if dp[s][i] == inf {
                continue;
            }
            let v = dp[s][i];
            let c = i.count_ones() as usize & 1;
            let mut bit = c ^ 1;
            let mut cost = 0;
            for j in 0..n {
                bit ^= 1;
                if (i >> j) & 1 == 1 {
                    continue;
                }
                cost += 1;
                let x = a[bit][j];
                if x < s {
                    continue;
                }
                let k = i | (1 << j);
                dp[x][k] = std::cmp::min(dp[x][k], v + cost - 1);
            }
        }
    }
    let mut ans = inf;
    for i in 0..50 {
        ans = std::cmp::min(ans, dp[i][(1 << n) - 1]);
    }
    if ans == inf {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 37116
s = gets.chomp

ans = 10 ** 20
s.chars.each do |a|
  t = s.dup
  tmp = 0
  while t.chars.uniq.count != 1 do
    (0..t.size-2).each do |i|
      if t[i] == a || t[i+1] == a
        t[i] = a
      end
    end
    t.chop!
    tmp += 1
  end
  ans = [ans, tmp].min
end
puts ans

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	int N,R;
	cin>>N>>R;
	
	cout<<max(R,R+100*(10-N))<<endl;
	
	return 0;
}


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

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

int main(){
  string s, t = "";
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') { t = t + "0"; }
    if (s[i] == '1') { t = t + "1"; }
    if (s[i] == 'B') {
      int l = t.size();
      if (l > 0) { t = t.substr(0, l-1); }
    }
  }
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  string s;
  while (cin >> s) {
    string t = "";
    rep(i, s.size()) {
      if (s[i] == '@') {
        t += string(s[i + 1] - '0', s[i + 2]);
        i += 2;
      } else {
        t += s[i];
      }
    }
    cout << t << endl;
  }
}

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

int main(){
    int N,W; cin>>N>>W;
    int value[N],weight[N];
    for(int i=0;i<N;i++){
        cin>>value[i]>>weight[i];
    }
    int dp[110][10010];
    for(int w=0;w<=W;w++) dp[0][w]=0;

    for(int i=0;i<N;i++){
        for(int w=0;w<=W;w++){
            if(w >= weight[i]) dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w]);
            else dp[i+1][w] = dp[i][w];
        }
    }

    
    cout<<dp[N][W]<<endl;
    return 0;
}


Measured memory_bytes: 7032
// Problem : C - Ubiquity
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <fstream>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <list>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef map<int, int> mii;
typedef map<int, string> mis;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sl;
typedef map<ll, ll> mll;
typedef queue<int> qi;
typedef queue<ii> qii;
typedef vector<string> vs;
typedef pair<ll, ll> iil;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<ll> pqil;
typedef priority_queue<iil> pqiil;
typedef vector<iil> viil;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int, ii> iii;
typedef pair<iil, ll> iiil;
typedef vector<pair<pair<int,int>,int> > viii;
typedef vector<pair<pair<ll,ll>,ll> > viiil;
typedef vector<vl> vvl;

#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0 ; i < n ; i++)
#define INF 2000000000

ll MOD = 1000000007;

void solve() {
    
    ll n;
    cin >> n;
    
    ll dp[n+1][4];
    dp[0][0] = 1LL;
    dp[0][1] = 0LL;
    dp[0][2] = 0LL;
    dp[0][3] = 0LL;
    
    rep(i, n) {
    	dp[i + 1][0] = (dp[i][0] * 8)%MOD;
    	dp[i + 1][1] = ((dp[i][1] * 9)%MOD + dp[i][0])%MOD;
    	dp[i + 1][2] = ((dp[i][2] * 9)%MOD + dp[i][0])%MOD;
    	dp[i + 1][3] = (dp[i][2] + dp[i][1] + (dp[i][3] * 10)%MOD)%MOD;
    }
    
    cout << dp[n][3] << endl;
    
}

void querySolve() {
    int t;
    cin >> t;
    for (int i = 0 ; i < t ; i++) {
        solve();
    }
}

int main() {
    solve();
    //querySolve();
}


Measured memory_bytes: 34808
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n;
    int length[3];
    cin >> n;
    for (int i=0; i<n; i++) {
        bool is_yes = true;
        for (int j=0; j<3; j++) {
            cin >> length[j];
        }
        sort(length, length+3);
        if (length[0]*length[0]+length[1]*length[1] != length[2]*length[2]) {
            is_yes = false;
        }
        if (length[0]+length[1] <= length[2]) {
            is_yes = false;
        }
        if (is_yes) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1168
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int x[11];
	int N,i,j,cnt,p,ba;
	char c[101];
	
	scanf("%d",&N);
	while(!(N==0)){
		cnt=100;
		ba=0;
		for(i=0;i<N;i++){
			x[i]=0;
		}
		scanf("%s",c);
		i=0;
		j=0;
		while(!(cnt==0)){
			cnt--;
			if(c[i]=='M'){
				x[j]+=1;
			}
			else if(c[i]=='S'){
				ba+=x[j]+1;
				x[j]=0;
			}
			else if(c[i]=='L'){
				x[j]+=ba+1;
				ba=0;
			}
			i++;
			j++;
			if(j==N){
				j=0;
			}
		}
		sort(x,x+N);
		for(i=0;i<N;i++){
			printf("%d ",x[i]);
		}
		printf("%d\n",ba);
		scanf("%d",&N);
	}
	return 0;
}
			
			
				
			
			
			

Measured memory_bytes: 1048
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

monster = sum(a)
for i in range(n):
    a[i + 1] -= min(b[i] - min(b[i], a[i]), a[i + 1])
    a[i] -= min(b[i], a[i])

print(monster - sum(a))

Measured memory_bytes: 24120
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,Q;
int main(){
    cin>>N>>Q;
    set<P> st1,st2;
    st1.insert(P(N,N-2));
    st2.insert(P(N,N-2));
    ll top=N,left=N;
    ll ans=(N-2)*(N-2);
    vector<ll> v;
    for(ll i=0;i<Q;i++){
        ll a,x;
        cin>>a>>x;
        set<P>& st=(a==1)?st1:st2;
        ll otherleast=(a==1)?top:left;
        ll val;
        if(st.empty() || x < st.begin()->first){
            val=(otherleast-2);
            ans-=val;
            if(a==1){
                left=x;
            }else{
                top=x;
            }
        }else{
            auto it=st.lower_bound(P(x,0));
            it--;
            val=it->second;
            ans-=val;
        }
        st.insert(P(x,val));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 16104
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1234567;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
int main(){
	int a,b;cin>>a>>b;
	if(a==b){
		cout<<"Draw"<<endl;
	}else if(a==1){
		cout<<"Alice"<<endl;
	}else if(b==1){
		cout<<"Bob"<<endl;
	}else if(a<b){
		cout<<"Bob"<<endl;
	}else{
		cout<<"Alice"<<endl;
	}
    return 0;
}


Measured memory_bytes: 256
def show(nums):
    for i in range(len(nums)):
        if i!=len(nums)-1:
            print(nums[i],end=' ')
        else:
            print(nums[i])


def intersetion_sort(A, N):
    for i in range(N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        show(A)
    return A


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split(' ')))
    intersetion_sort(A, N)



Measured memory_bytes: 5976
fn main() {
    proconio::input! {
        n: usize,
        positions: [(i64, i64); n]
    }

    let ps = positions.iter().map(|(x, y)| x + y).collect::<Vec<i64>>();
    let ms = positions.iter().map(|(x, y)| x - y).collect::<Vec<i64>>();

    let pmax = ps.iter().max().unwrap();
    let pmin = ps.iter().min().unwrap();
    let mmax = ms.iter().max().unwrap();
    let mmin = ms.iter().min().unwrap();

    let ans = (pmax - pmin).max(mmax - mmin);
    println!("{:?}", ans);
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define ac(x, i) get<i>(x)
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll ,ll>
#define ff first
#define ss second
#define MOD 1000000007

const int infi = 1e9;
const ll infl = 1e18;

const int N = 1e5 + 100;
ll dp[N][2];

int main() {
  #ifndef ONLINE_JUDGE
  //freopen("input.txt", "r", stdin);
  #endif
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int n; cin >> n;
  for (int i = 2; i <= n; i++) {
    dp[i][0] = infl;
    dp[i][1] = infl;
  }
  int a[n+1];
  for (int i = 1; i <= n; i++) cin >> a[i];
  dp[1][0] = dp[1][1] = 0LL;
  for (int i = 1; i < n; i++) {
    dp[i+1][0] = min(dp[i][0], dp[i][1]) + abs(a[i+1] - a[i]);
    dp[i+2][1] = min(dp[i][0], dp[i][1]) + abs(a[i+2] - a[i]);
  }
  cout << min(dp[n][0], dp[n][1]) << "\n";
  return 0;
}

Measured memory_bytes: 2176
#include<cstdint>
#include<cstring>
#include<iostream>
#include<vector>
#include<memory>
#include<algorithm>
#include<functional>
#include<utility>

using namespace std;


int64_t A[200001];
int64_t N, K;

int main()
{
	cin >> N >> K;
	for (int i = 0; i < N; ++i) {
		int64_t temp;
		cin >> temp;
		A[temp] += 1;
	}

	std::sort(A, std::end(A), std::greater<>());

	auto it = std::begin(A);
	for (int i = 0; i < K; ++i) {
		++it;
	}

	int64_t ans = 0;
	while (*it) {
		ans += *it;
		++it;
	}

	cout << ans << endl;

    return 0; 
}



Measured memory_bytes: 1792
n = int(input())
dp = [[0] * 3 for _ in range(n)]

dp[0] = list(map(int, input().split()))
for i in range(1, n):
    a, b, c = map(int, input().split())
    dp[i][0] = a + max(dp[i - 1][1], dp[i - 1][2])
    dp[i][1] = b + max(dp[i - 1][0], dp[i - 1][2])
    dp[i][2] = c + max(dp[i - 1][0], dp[i - 1][1])
    
print(max(dp[-1]))

Measured memory_bytes: 22772
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin >> s;
    
    long long k;
    cin >> k;
    
    for (int i = 0; i < k; i++){
        if (s[i] != '1'){
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
}

Measured memory_bytes: 256
s = gets
if s[0] == "R" && s[1] == "R"
  if s[2] == "R"
    puts 3
  else
    puts 2
  end
else
  if s[1] == "R" && s[2] == "R"
    puts 2
  else
    if s.count("R") == 0
      puts 0
    else
      puts 1
    end
  end
end
  

Measured memory_bytes: 14296
import math
t = []
for i in range(5):
  t.append(int(input()))
ct = [math.ceil(x/10)*10 for x in t]
fraction = [x%10 for x in t]
fraction = list(filter(lambda x: x > 0, fraction))
if len(fraction) > 0:
  min_fraction = min(fraction)
else:
  min_fraction = 10
print(sum(ct) - 10 + min_fraction)


Measured memory_bytes: 38384
io = STDIN
N=io.gets.to_i
a=io.gets.split.map(&:to_i)
b=io.gets.split.map(&:to_i)
cnt=0
b.each_with_index do |bb,i|
  if a[i]+a[i+1]<bb
    cnt +=a[i]+a[i+1]
    a[i+1]=0
  else     #a[i]+a[i+1]>bb
    if  a[i]<bb
      cnt+=bb
      a[i+1]-=bb-a[i]
    else
      cnt+=bb
    end
  end
end
puts cnt


Measured memory_bytes: 15396
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	int v,n=12;
	cin>>v;
	int num[n]={1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
	int b[v+1];
	memset(b,0x3F,sizeof(b));
	b[0]=true;
	for(int i=0;i<n;i++){
		int temp=num[i];
		for(int j=0;j<=v-temp;j++)
			if(b[j])
				b[j+temp]=min(b[j+temp],b[j]+1);
	}
	cout<<b[v]-1;
	return 0;
}

Measured memory_bytes: 640