akhauriyash/Code-Regression huggingface dataset:
def main():
    A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())
    
    count = 0

    for yen500 in range(A+1):
        for yen100 in range(B+1):
            for yen50 in range(C+1):
                total = 500 * yen500 + 100 * yen100 + 50 * yen50
                if X == total:
                    count += 1
                total = 0

    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 39024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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 MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

vector<int> a[11];

int main(){
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int k;
        cin >> k;
        for(int j = 0; j < k; j++) {
            int t;
            cin >> t, t--;
            a[i].push_back(t);
        }
    }
    vector<int> p(n);
    for(int i = 0; i < m; i++) {
        cin >> p[i];
    }
    int ans = 0;
    for(int bit = 0; bit < 1 << n; bit++) {
        vector<bool> l(m, false);
        vector<bool> r(n, false);
        for(int i = 0; i < n; i++) {
            if(1 & bit >> i) r[i] = true;
        }
        for(int i = 0; i < m; i++) {
            int cnt = 0;
            for(int j = 0; j < (int)a[i].size(); j++) {
                if(r[a[i][j]]) cnt++;
            }
            if((cnt%2) == p[i]) l[i] = true;
        }
        bool ok = true;
        for(int i = 0; i < m; i++) {
            if(!l[i]) ok = false;
        }
        if(ok) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int S,h,m,s;
	scanf("%d",&S);
	h=S/3600;
	m=S-(h*3600);
	s=S%60;
	printf("%d:",h);
	printf("%d:",m/60);
	printf("%d\n",s);
	return 0;
}



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

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[][] c= new int[4][4];
		for(int i =1;i<=3;i++){
			for(int j =1;j<=3;j++){
				c[i][j] = sc.nextInt();
			}
		}
		if(c[1][1]-c[2][1]==c[1][2]-c[2][2]
		 &&c[1][1]-c[2][1]==c[1][3]-c[2][3]
		 &&c[3][1]-c[2][1]==c[3][2]-c[2][2]
		 &&c[3][1]-c[2][1]==c[3][3]-c[2][3]
		 &&c[1][2]-c[1][1]==c[2][2]-c[2][1]
		 &&c[1][2]-c[1][1]==c[3][2]-c[3][1]
		 &&c[1][3]-c[1][2]==c[2][3]-c[2][2]
		 &&c[1][3]-c[1][2]==c[3][3]-c[3][2]){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

		sc.close();
	}
}


Measured memory_bytes: 23764
#!/usr/bin/env python
# coding: utf-8

import sys


def main():
    params = [line.split(",")[1].replace("\n", "") for line in sys.stdin.readlines()]
    print params.count("A")
    print params.count("B")
    print params.count("AB")
    print params.count("O")

if __name__ == '__main__':
    main()

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

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var K = input[0];
            var N = input[1];
            var A = ReadArrayInt();
            var ans = A[N - 1] - A[0];
            for (int i = 1; i < N; i++)
            {
                var len = K - A[i] + A[i - 1];
                if (len < ans) ans = len;
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static string[] ReadArrayString() { return Read().Split(' '); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}


Measured memory_bytes: 34780
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main()
{
	int h,n;
	cin>>h>>n;
	int a[n],sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum=sum+a[i];
	}
	if(sum>=h)
	cout<<"Yes";
	else
	cout<<"No";

	
	return 0;
}

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

int dem[2][2];

string S;

int main()
{
    //freopen("a.inp","r",stdin);
    cin >> S;
    for(int i=0;i<S.length();i++)
    {
        ++dem[S[i]-'0'][i%2];
    }
    cout << min(dem[0][1]+dem[1][0],dem[0][0]+dem[1][1]);
}


Measured memory_bytes: 512
fn solve() {
    let n: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    let d: Vec<(u32, u32)> = {
        let mut v = vec![(0, 0); n];
        for i in 0..n {
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).unwrap();
            let mut ws = buf.split_whitespace();
            let a = ws.next().unwrap().parse().unwrap();
            let b = ws.next().unwrap().parse().unwrap();
            v[i] = (a, b);
        }
        v
    };

    let same = |(a, b)| a == b;
    for i in 0..(n - 2) {
        if same(d[i]) && same(d[i + 1]) && same(d[i + 2]) {
            println!("Yes");
            return;
        }
    }

    println!("No");
}

fn main() {
    solve();
}


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

const int N = 2e6 + 10, mod = 1e9 + 7;
typedef long long ll;
typedef pair <ll, ll> pii;

vector <int> adj[N];
int h[N];
vector <int> tour;

void dfs_2 (int v, int p) {
	tour.push_back(v);
	for (auto u : adj[v]) {
		if (u == p)	continue;
		if (h[u] == 1e7) {
			h[u] = h[v] + 1, dfs_2(u, v);
			break;
		}
	}
	return;
}

void dfs (int v, int p = -1) {
	tour.push_back(v);
	for (auto u : adj[v]) {
		if (u == p)	continue;
		if (h[u] == 1e7) {
			h[u] = h[v] + 1, dfs(u, v);
			break;
		}
	}
	if (v == 0) {
		for (auto u : adj[v]) {
			if(h[u] == 1e7) {
				reverse(tour.begin(), tour.end());
				h[u] = 1;
				dfs_2(u, v);
				return;
			}
		} 
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int v, u;
		cin >> v >> u;
		v--, u--;
		adj[v].push_back(u), adj[u].push_back(v);
	}
	fill(h, h + n, 1e7);
	h[0] = 0;
	dfs(0);
	cout << tour.size() << "\n";
	while (!tour.empty()) {
		cout << tour.back() + 1 << " ";
		tour.pop_back();
	}
	cout << "\n";
}

Measured memory_bytes: 56312
#include <bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int X, Y; cin >> X >> Y;
    if (X % Y == 0) {
        cout << -1 << '\n';
    } else {
        cout << X << '\n';
    }
    return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N, M;
  cin >> N >> M;
  int l, m, left, right;
  left = 1 << 31;
  right = 1 << 29;
  REP(i, M) {
    cin >> l >> m;
    left = max(left, l);
    right = min(right, m);
  }

  if (right < left) {
    cout << 0 << endl;
  } else {
    cout << right - left + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
#define ll long long
typedef unsigned long long ull;
typedef long double ld;

#define pii         pair<ll ,ll >
#define vi          vector<ll >
#define vii         vector<pii>
#define mi          map<ll ,ll >
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define pb          push_back
#define hell        1000000007
#define rep(i,a,b)  for(ll int i=a;i<b;i++)
#define take        rep(i,0,n) cin>>v[i];
#define MAXN        1000005


#define allr(c) (c).rbegin(),(c).rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}



void solve()
{
	ll n;
	cin>>n;
	ll k=0;
	for(ll i=1;i<n;i++)
	{
		for(ll j=1;j<n;j++)
		{
			if(i*j<n)
			{
				k++;
			}
			else
			{
				break;
			}
		}
		
	}
	cout<<k<<endl;
}
int main()
    {
    	ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
      
        ll t;
        
        t=1;
        
    
//    cin>>t;
        while(t--)
        solve();
    }

Measured memory_bytes: 3648
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

const ll inf = 1e17;
const ll N = 1e4+10;
const ll bits = 30;
const ll mod = 1e9+7;



int main(){
    FASTIO;

    ll t,n,temp;
    cin>>t;
    cout<<t*t<<"\n";








}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define rep(i, n) for (int i = 0; i < (n); 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 repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue<int>
#define PQR priority_queue<int,VE,greater<int>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e9;
// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int n;
vector<int>to[1005];

vector<int>bfs(int sv) {
	VE dist(n, INF), pre(n, -1);
	queue<int>q;
	dist[sv] = 0;
	q.push(sv);
	while (!q.empty()) {
		int v = q.front(); q.pop();
		for (int u : to[v]) {
			if (dist[u] != INF)continue;
			pre[u] = v;
			dist[u] = dist[v] + 1;
			q.push(u);
		}
	}
	P best(INF, -1);
	rep(v, n) {
		if (v == sv)continue;
		for (int u : to[v]) {
			if (u == sv) {
				chmin(best, make_pair(dist[v], v));
			}
		}
	}
	if (best.first == INF)return vector<int>(n + 1);
	int v = best.second;
	vector<int> res;
	while (v != -1) {
		res.push_back(v); v = pre[v];
	}
	return res;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int m;
	cin >> n >> m;
	rep(i, m) {
		int a, b; cin >> a >> b; a--; b--;
		to[a].push_back(b);
	}
	vector<int>ans(n + 1);
	rep(s, n) {
		auto now = bfs(s);
		if (now.size() < ans.size())ans = now;
	}
	if (ans.size() == n + 1) {
		cout << -1 << endl; return 0;
	}
	cout << ans.size() << endl;
	for (int v : ans) {
		cout << v + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> fs, rs, casher;
    for (int i = 0; i < A; i++) {
        int f_i;
        cin >> f_i;
        fs.push_back(f_i);
    }
    for (int i = 0; i < B; i++) {
        int r_i;
        cin >> r_i;
        rs.push_back(r_i);
    }
    for (int i = 0; i < M; i++) {
        int x_i, y_i, c_i;
        cin >> x_i >> y_i >> c_i;
        int cash = fs[x_i - 1] + rs[y_i - 1] - c_i;
        casher.push_back(cash);
    }

    sort(casher.begin(), casher.end());
    sort(fs.begin(), fs.end());
    sort(rs.begin(), rs.end());
    int ans;
    int minimum = fs[0] + rs[0];
    if (minimum < casher[0]) {
        ans = minimum;
    } else {
        ans = casher[0];
    }

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

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

using namespace std;

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    if(a+b<=2*c) {
        cout << a*x+b*y << endl;
    } else {
        int r = a*x+b*y;
        int lim = max(x, y);
        for(int i=min(x, y); i<=lim; i++) {
            r = min(r, a*max(x-i, 0) + b*max(y-i, 0) + c * 2 * i);
        }
        cout << r << endl;
    }
}


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

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

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int main(){
    int A, B;
    cin >> A >> B;
    if (A % 3 == 0) {
        cout << "Possible" << endl;
        return 0;
    }
    if (B % 3 == 0) {
        cout << "Possible" << endl;
        return 0;
    }
    if ((A + B) % 3 == 0) {
        cout << "Possible" << endl;
        return 0;
    }
    cout << "Impossible" << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
from collections import defaultdict

n = int(input())
graph = defaultdict(list)

for i in range(n - 1):
    a, b = map(int, input().split())
    graph[a].append([b, i])
    graph[b].append([a, i])

ans = [0] * (n - 1)

q = deque([[1, 0, 0]])
while q:
    v, pcol, root = q.popleft()
    cnt = 1
    for node in graph[v]:
        if node[0] == root:
            continue
        if cnt == pcol:
            cnt += 1
        ans[node[1]] = cnt
        q.append([node[0], cnt, v])
        cnt += 1

print(max(ans))
print(*ans, sep="\n")


Measured memory_bytes: 53084
def parse():
  N = int(input())
  A = list(map(int, input().split(" ")))
  return N, A

def power(base, exp):
    """ Fast power calculation using repeated squaring """
    if exp < 0:
        return 1 / power(base, -exp)
    ans = 1
    while exp:
        if exp & 1:
            ans *= base
        exp >>= 1
        base *= base
    return ans

def main():
  N, A = parse()
  A = sorted(A)
  if A[0] == 0:
    print(0)
    exit(0)

  ans = 1
  for n in range(N):
    ans *= A[n]
    # print(ans)
    if ans > power(10, 18):
      print(-1)
      exit(0)
  print(ans)

if __name__ == "__main__":
  main()

Measured memory_bytes: 21644
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;

int main(){
  int X,Y; cin>>X>>Y;
  
  if((2*Y-X)%3||(2*X-Y)%3||X*2<Y||Y*2<X){
    cout<<0<<endl;
  }else{
    int a=(2*Y-X)/3;
    int b=(2*X-Y)/3;
    if(a<b) swap(a,b);
    
    ll nx=a+1,dx=1,n=1,d=1;
    while(b>0){
      n=n*nx%mod;
      d=d*dx%mod;
      nx++,dx++,b--;
    }
    ll e=mod-2;
    dx=d,d=1;
    while(e>0){
      if(e&1){
        d=d*dx%mod;
      }
      dx=dx*dx%mod;
      e>>=1;
    }
    cout<<n*d%mod<<endl;
  }
}

Measured memory_bytes: 3652
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);


    double n, a, b,sum=0;
    cin >> n >> a >> b;
    for(double i = 1; i <= n; ++i) {
        int val = 0,cou=0;
        val = i;
        cou += val / 10000;
        val %= 10000;
        cou += val / 1000;
        val %= 1000;
        cou += val / 100;
        val %= 100;
        cou += val / 10;
        val %= 10;
        cou += val %= 10;
        //cout << cou << ' ';
        if(a <= cou && cou <= b) {
            sum += i;
            //cout  << sum ;
        }
        //cout << endl;
    }
    //cout << endl;
    cout <<setprecision(15)<< sum << endl;
}

Measured memory_bytes: 3712
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


ll check[26];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  string s; cin >> s ;
  
  if(s.size() < 26){
    rep(i,s.size())
      check[s[i]-'a'] = true;
    rep(i,26){
      if(check[i] == false){
	cout << s << (char)(i+'a') << endl;
	return 0;
      }
    }
  }
  

  vector<ll> str;
  rep(i,s.size())
    str.pb(s[i] - 'a');

  if(next_permutation(all(str))){
    string ans = "";
    rep(i,str.size()){
      ans += (str[i]+'a');
    }
    rep(i,str.size()){
      cout << ans[i];
      if(ans[i] != s[i]) break;
    }
    cout << endl;
    return 0;
  }
  else cout << -1 << endl;
  
  
    
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from itertools import permutations

def solve():
    N = int(input())
    P = [[int(i) for i in input().split()] for _ in range(N)]
    tmp = 0
    c = 0
    for p in permutations(P):
        t = 0
        c += 1
        for i in range(N - 1):
            t += ((p[i][0] - p[i + 1][0]) ** 2 + (p[i][1] - p[i + 1][1]) ** 2) ** 0.5
        tmp += t
    print(tmp / c)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 68316
n = int(input())
restaulant = []
for i in range(n): restaulant.append(input().split())
for i in range(n): restaulant[i][1] = -1 * int(restaulant[i][1])

sorted_rest = sorted(restaulant)
for i in sorted_rest:
    for j in range(n):
        if i == restaulant[j]: print(j+1)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <array>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define all(c) begin(c), end(c)
#define dump(c) cerr << "> " << #c << " = " << (c) << endl
#define tr(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef pair<int,int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;


int main() {
  for (int E; cin >> E, E != 0; ) {
    int m = INF;
    for (int z = 0; z * z * z <= E; z++)
      for (int y = 0; y * y <= E; y++) {
        int x = E - y * y - z * z * z;
        if (x < 0) break;
        m = min(m, x + y + z);
    }

    cout << m << endl;

  }
  
  
  return 0;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll H1, M1, H2, M2, K; cin >> H1 >> M1 >> H2 >> M2 >> K;
  ll x1 = H1 * 60 + M1;
  ll x2 = H2 * 60 + M2;
  ll ans = x2 - x1 - K;
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3640
#include<stdio.h>
#include<stdlib.h>

int compUp(const void* a, const void*b){
    return *(int*)a - *(int*)b;
}
/*int compDown(const void* a, const void*b){
    return *(int*)b - *(int*)a;
}*/

int main(void){
    int N, M;
    scanf("%d%d", &N, &M);
    int X[M];
    int i;
    for(i = 0; i < M; i++){scanf("%d", &X[i]);}
    qsort(X, M, sizeof(int), compUp);
    int D[M-1];
    for(i = 0; i < M-1; i++){D[i] = X[i+1] - X[i];}
    qsort(D, M-1, sizeof(int), compUp);

    int ans = 0;
    if(N >= M){ans = 0;}
    else{
        for(i = 0; i < M-N; i++){ans += D[i];}
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long double,int> P;
int n,k;
int p[1005];
int ans;
int main(void){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    sort(p,p+n);
    for(int i=0;i<k;i++){
        ans+=p[i];
    }
    cout<<ans<<endl;

}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); i++)

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);


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


int main() {

string s;
cin>>s;
for(int i=0;i<s.length();i++){
  cout<<"x";
}




  
  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll INF=1e18;
    
int main(){
  int n,k;
  cin>>n>>k;
  bool judge=true;
  int l=1;
  int keta=1;
  while(judge){
    if(n/l==0){
      cout<<keta-1<<endl;
      judge=false;
      return 0;
    }else{
      l*=k;
      keta++;
      
    }
      
   
  }
  

}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair< int, int > Pi;
typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const double DINF = 5e14, eps = 1e-10;
const long long MOD = 1e9 + 7, INF = 5e18;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()

int h, w, k;
ll dp[110][10], cul[10], cul2[10];

int main() {
	cin >> h >> w >> k;
	if (w == 1) {
		cout << 1 << endl;
		return 0;
	}
	for (int i = 0;i < (1 << (w - 1));i++) {
		bool fl = false;
		for (int j = 0;j < w - 2;j++) {
			if ((i&(1 << j)) && (i&(1 << (j + 1)))) {
				fl = true;
				break;
			}
		}
		if (!fl) {
			for (int j = 0;j < w - 1;j++) {
				if (i&(1 << j))cul[j + 1]++;
			}
			if (!(i & 1))cul2[1]++;
			for (int j = 0;j < w - 2;j++) {
				if (!(i&(1 << j)) && !(i&(1 << (j + 1))))cul2[j + 2]++;
			}
			if (!(i&(1 << (w - 2))))cul2[w]++;
		}
	}
	dp[1][1] = 1;
	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			if (j != 1) {
				dp[i + 1][j - 1] += dp[i][j] * cul[j - 1] % MOD;
				dp[i + 1][j - 1] %= MOD;
			}
			dp[i + 1][j] += dp[i][j] * cul2[j] % MOD;
			dp[i + 1][j] %= MOD;
			if (j != w) {
				dp[i + 1][j + 1] += dp[i][j] * cul[j] % MOD;
				dp[i + 1][j + 1] %= MOD;
			}
		}
	}
	cout << dp[h + 1][k] << endl;
	return 0;
}


Measured memory_bytes: 256
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 1e5+5 ;
const long double eps = 1e-11;

int n ,x[N] ,y[N] ,addx[N] ,addy[N] ;
char ch ;
int xx[128] ,yy[128] ;
long double f(long double add){
    long double minX = 1e18 ,maxX = -1e18 ,minY = 1e18 ,maxY = -1e18 ;
    for(int i=0;i<n;++i){
        minX = min(minX ,(long double)x[i] + add*addx[i]);
        maxX = max(maxX ,(long double)x[i] + add*addx[i]);
        minY = min(minY ,(long double)y[i] + add*addy[i]);
        maxY = max(maxY ,(long double)y[i] + add*addy[i]);
    }
    return (maxX - minX) * (maxY - minY) ;
}
long double ternarySearch(long double left,long double right){
    for(int i=0;i<=1000;++i){
        long double g = left + (right - left) / 3, h = left + 2 * (right - left) / 3;
        if(f(g) < f(h))    right = h;
        else    left = g; // change < to > if the fn inc then dec
    }
    return f((left + right) / 2);
}
int main(){
    xx['R'] = 1 ;
    xx['L'] = -1 ;
    yy['U'] = 1 ;
    yy['D'] = -1 ;
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        scanf("%d%d %c",x+i,y+i,&ch);
        addx[i] = xx[ch] ;
        addy[i] = yy[ch] ;
    }
    cout << fixed << setprecision(15) << ternarySearch(0,1e9+5);
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int x = sc.nextInt();
    int min = x - k + 1;
    int max = x + k - 1;
    for(int i=min;i<=max;i++){
      System.out.print(i+" ");
    }
  }
}

Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int main(){
    string N;
    char c;
    cin >> N;
    c=N.at(0);
    for(int i=1;i<N.length();i++){
        if(c>N.at(i)){
            cout << (c-'0')*111 << endl;
            return 0;
        }
        else if(c<N.at(i)){
            cout << (c-'0'+1)*111 << endl;
            return 0;
        }
    }
    cout << N << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
 
const int inf = int(1e9);
const int mod = 1e9 + 7;
const int N = 1e6 + 555;
const long double PI = acos(-1.0);

int pos[N], took[N];
void solve()
{
	string s;
	cin >> s;
	int x = 0, res = 1;
	for(int i = 1; i < sz(s); ++i){
		if(s[i] == 'L') {
			for(int j = x; j < i; ++j){
				int nw = 1e6;
				nw -= (i - j);
				if(nw % 2){
					took[i - 1]++;;
				}
				else took[i]++;
			}
			x = i + 1;
		}
	}
	x = sz(s) - 1;
	for(int i = sz(s) - 2; i >= 0; --i){
		if(s[i] == 'R') {
			for(int j = x; j > i; --j) {
				int nw = 1e6;
				nw -= (j - i);
				if(nw % 2) took[i + 1]++;
				else took[i]++;
			}
			x = i - 1;
		}
	}
	for(int i = 0; i < sz(s); ++i){
      cout << took[i] << " ";
	}






}

int main()
{
	Red;
	solve();
	return 0;
}


Measured memory_bytes: 1104
#include <stdio.h>

int main() {
	int n, a, pos, left, right, mid, ans[100010], size = 1;
	scanf("%d %d", &n, &a);
	ans[0] = a;
	for (int i = 1; i < n; i++) {
		scanf("%d", &a);
		if (ans[size - 1] >= a)
			ans[size++] = a;
		else {
			left = 0;
			right = size - 1;
			while (left <= right) {
				mid = (left + right) / 2;
				if (ans[mid] < a) {
					pos = mid;
					right = mid - 1;
				}
				else
					left = mid + 1;
			}
			ans[pos] = a;
		}
	}
	printf("%d\n", size);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 100005
using namespace std;
int n,m,in[M],dp[M];
int main()
{
    while (~scanf("%d %d",&n,&m)) {
        REP(i,1,n) scanf("%d",&in[i]);
        dp[1] = 0;
        REP(i,2,n) {
            dp[i] = 1000000000;
            REP(j,1,m) if(i-j>=1) dp[i] = min(dp[i], dp[i-j] + abs(in[i]-in[i-j]));
        }
        printf("%d\n", dp[n]);
    }
    
    return 0;
}



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

int main() {
  string S, T;
  cin >> S >> T;
  
  int ans = 0;
  if (S[0] == T[0]) ans++;
  if (S[1] == T[1]) ans++;
  if (S[2] == T[2]) ans++;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int i, j, k, n, m, l, A[105][105], B[105][105];
	long  int C[105][105];

	scanf("%d %d %d", &n, &m, &l);
	for (i = 0; i<n; i++)
	{
		scanf("%d", &A[i][0]);
		for (j = 1; j<m; j++)
		{
			scanf(" %d", &A[i][j]);
		}
	}
	for (i = 0; i<m; i++)
	{
		scanf("%d", &B[i][0]);
		for (j = 1; j<l; j++)
		{
			scanf(" %d", &B[i][j]);
		}
	}

	for (i = 0; i<n; i++)
	{
		for (j = 0; j<l; j++)
		{
			for (k = 0; k<m; k++)
			{
				C[i][j] = C[i][j] + A[i][k] * B[k][j];
			}
		}
	}
	for (i = 0; i<n; i++)
	{
		printf("%ld", C[i][0]);
		for (j = 1; j<l; j++)
		{
			printf(" %ld", C[i][j]);
		}printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2112
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>	tree_set;
typedef long long ll;
typedef long double ld;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

ll mod=1e9 + 7;

int main()
{
    fast();
    int n,ans=0;
    cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++)
        cin>>arr[i];

    sort(arr,arr+n);

    ll mid_1 = arr[n/2];
    ll mid_2 = arr[n/2 - 1];

    cout<<mid_1-mid_2;
}



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


void solve(long long N, long long K){
    long n = 1;
    long cnt = 0;
    while(n <= N){
        n *= K;
        cnt++;
    }
    cout << cnt << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
 
using namespace std;
 
#define int long long
 
signed main(){

	int n;
	int tmp;

	cin>>n;

	vector<int> v;
	v.push_back(0);

	int ans[n+2];


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

	int sum=0;

	for(int i=0;i<n+1;i++){

		sum+=abs(v[i+1]-v[i]);

		// cout<<sum<<endl;

	}

	// cout<<sum<<endl;

	ans[0]=sum-abs(v[1]);
	ans[n-1]=sum-abs(v[n]);


	// for(int i=1;i<n;i++){
	// 	// a[i]=sum-v[i-1]
	// }

	// for(int i=0;i<n+2;i++){
	// 	cout<<v[i]<<" ";
	// }

	// cout<<endl;
	// cout<<endl;

	for(int i=1;i<n+1;i++){
		ans[i]=sum-(abs(v[i+1]-v[i])+abs(v[i]-v[i-1]))+abs(v[i+1]-v[i-1]);
		// cout<<abs(v[i+1]-v[i])+abs(v[i]-v[i-1])<<" "<<abs(v[i+1]-v[i-1])<<endl;
	}

	for(int i=1;i<n+1;i++){
		cout<<ans[i]<<endl;
	}
}

Measured memory_bytes: 2932
#include<bits/stdc++.h>
using namespace std;
struct Cake {
    long long x, y, z;
    Cake() {
        x = y = z = 0;
    }
};
long long ans, temp;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<Cake> C(N);
    for (auto &c : C) cin >> c.x >> c.y >> c.z;
    for (int t = 0; t < 8; t++) {
        sort(C.begin(), C.end(), [&t](const Cake &a, const Cake &b) {
            return (t%2 ? a.x : -a.x)+((t>>1)%2 ? a.y : -a.y)+((t>>2)%2 ? a.z : -a.z) > (t%2 ? b.x : -b.x)+((t>>1)%2 ? b.y : -b.y)+((t>>2)%2 ? b.z : -b.z);
        });
        temp = 0;
        for (int i = 0; i < M; i++) temp += (t%2 ? 1 : -1)*C[i].x+((t>>1)%2 ? 1 : -1)*C[i].y+((t>>2)%2 ? 1 : -1)*C[i].z;
        ans = max(ans, temp);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    val H = readLine()!!.split(" ").map { it.toInt() }.toIntArray()


    H[0]--
    (1 until N).forEach {i ->
        val previous = H[i-1]
        val current = H[i]
        if (previous > current) {
            println("No")
            return
        }

        // If possible, decrement it
        if (previous < current) {
            H[i]--
        }

    }

    println("Yes")
}

Measured memory_bytes: 57840
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=1e5+5;
int a[N];
int32_t main(){
    int n;
    cin>>n;
    forn(i,n)cin>>a[i];
    int ans=0;
    for(int d=1;d<n;++d){
        int l=0,r=n-1,c=0,k=0;
        while(1){
            upx(ans,c);
            l+=d;
            if(l==r)break;
            r-=d;
            if(l==r)break;
            c+=a[l]+a[r];
            k++;
            if(n-(k+1)*d<=1)break;
        }
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 4432
import itertools
H,W,K=map(int,input().split())

cmat=[[x=="." for x in input()] for _ in range(H)]
#print(cmat)

answer=0
for perm in itertools.product([True,False],repeat=H+W):
  #print(perm)
  row_set=set()
  for i in range(H):
    if perm[i]:
      row_set.add(i)
  
  col_set=set()
  for i in range(H,H+W):
    if perm[i]:
      col_set.add(i-H)      
  
  #print(perm,row_set,col_set)
  cnt=0
  for i in range(H):
    for j in range(W):
      if not cmat[i][j] and not i in row_set and not j in col_set:
        cnt+=1
        
  if cnt==K:
    answer+=1
    
print(answer) 

Measured memory_bytes: 68452
while True:
  lst = input().split()
  a,b,op = int(lst[0]),int(lst[2]),lst[1]
  if op == "+":
      print(a+b)
  if op == "-":
      print(a-b)
  if op == "*":
      print(a*b)
  if op == "/":
      print(int(a/b))
  if op == "?":
      break


Measured memory_bytes: 5596
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int rangeStart = B * 10;
		int ans = -1;

		for(int i = rangeStart; i < rangeStart + 10; i++) {
			if(A == (int)Math.floor(i*0.08)) {
				ans = i;
				break;
			}
		}
		System.out.println(ans);


	}
}




Measured memory_bytes: 23380
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  vector<int> a(n), b(n);
  REP(i, n) cin >> a[i];
  REP(i, n) cin >> b[i];
  vector<vector<int> > dp(1 << n, vector<int>(51, INF));
  dp[0][0] = 0;
  REP(i, 1 << n) {
    REP(k, n) if (!(i >> k & 1)) {
      int cnt = 0, ope = 0;
      REP(l, k) cnt += !(i >> l & 1);
      FOR(l, k + 1, n) {
        cnt += (i >> l & 1);
        ope += (i >> l & 1);
      }
      int val = (cnt % 2 == 0 ? a[k] : b[k]);
      REP(j, val + 1) chmin(dp[i | (1 << k)][val], dp[i][j] + ope);
    }
  }
  int ans = INF;
  REP(j, 51) chmin(ans, dp[(1 << n) - 1][j]);
  cout << (ans == INF ? -1 : ans) << '\n';
  return 0;
}


Measured memory_bytes: 63744
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int c = scanner.nextInt();

			if (c <= (a + b)) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}


Measured memory_bytes: 21972
#include <stdio.h>

int main(void){
    int x1, y1, x2, y2, x3, y3, x4, y4;
    int change_x, change_y;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    
    x3 = x2 + (y2 - y1) * (-1);
    y3 = y2 + (x2 - x1);
    
    x4 = x3 + (x2 - x1) * (-1);
    y4 = y3 + (y2 - y1) * (-1);
    
    printf("%d %d %d %d", x3, y3, x4, y4);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

void failure () {
  cout << "Impossible" << endl;
  exit(0);
}

const int MAX_N = 20;

char grid [MAX_N][MAX_N];

int ni [4] = {1, 0, -1, 0};
int nj [4] = {0, 1, 0, -1};

int main () {
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> grid[i][j];
    }
  }

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (!(i == 1 && j == 1) && !(i == n && j == m)) {
        if (grid[i][j] == '#') {
          int pc = 0;
          for (int k = 0; k < 2; k++) {
            if (grid[i + ni[k]][j + nj[k]] == '#') pc++;
          }

          int nc = 0;
          for (int k = 2; k < 4; k++) {
            if (grid[i + ni[k]][j + nj[k]] == '#') nc++;            
          }

          if (pc != 1 || nc != 1) failure();
        }
      }

      if (i == 1 && j == 1) {
        int pc = 0;
        for (int k = 0; k < 2; k++) {
          if (grid[i + ni[k]][j + nj[k]] == '#') pc++;
        }

        if (pc != 1) failure();
      }

      if (i == n && j == m) {
        int nc = 0;
        for (int k = 2; k < 4; k++) {
          if (grid[i + ni[k]][j + nj[k]] == '#') nc++;            
        }

        if (nc != 1) failure();
      }
    }
  }

  cout << "Possible" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 int a[100],b[100];
int main(void){
    int n;
    cin>>n;
   
    for(int i=0;i<n;i++)cin>>a[i],b[i]=a[i];
    sort(a,a+n);
    int c=0;
    for(int i=0;i<n;i++)if(b[i]!=a[i])c++;
    if(c<=2)cout<<"YES";
    else cout<<"NO";
   
    
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

string S;
ll DP[int(1e5+5)][13];
int main(){
  cin >> S;
  DP[0][0] = 1;

  for (int i = 1; i <= S.length(); i++){
    if (S[i-1] != '?'){
      int num = S[i-1] - '0';
      for (int j = 0; j < 13; j++){
        DP[i][(j*10+num)%13] += DP[i-1][j];
        DP[i][(j*10+num)%13] %= MOD;
      }
    }else{
      for (int num = 0; num <= 9; num++){
        for (int j = 0; j < 13; j++){
          DP[i][(j*10+num)%13] += DP[i-1][j];
          DP[i][(j*10+num)%13] %= MOD;
        }
      }
    }
  }
  cout << DP[S.length()][5] << endl;

  return 0;
}


Measured memory_bytes: 13928
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

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

    vector<int64_t> a(3 * n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    sort(a.rbegin(), a.rend());

    int64_t ans = 0;
    for (auto i : irange(0, n)) {
        ans += a[2 * i + 1];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
///******* In the name of Allah *******///

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

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

void Ok()
{
    long long int a,b,c,d,e,f,g,h,t,s,i,j = 0,k,l1,l2,m,n,r,sum = 0,ans_1,ans_2,ans_3,cnt = 0,Max,Min,flag,div,rcv,temp;
    double aa,bb,cc,dd,ee,tot;
    char aaa[1013],bbb[1013],ccc[1013];
    
    cin>>n>>r;
    if(n<10)
    {
        ans_1 = r + (100 * (10 - n));
        cout<<ans_1<<endl;
    }
    else
        cout<<r<<endl;

    return;
}

int main()
{
    Ok();

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long n;
	while(1){
	scanf("%ld",&n);
	if(n==0)
	break;
	
		int count=0;
		while(n!=1){
		if(n%2==0)
			n=n/2;
		//if(n%2==1)
	    else
			n=n*3+1;
			count++;
		}
		printf("%d\n",count);
	}
		
}


Measured memory_bytes: 2040
#include "atcoder/all"

#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>


using namespace std;
using namespace atcoder;


using ll = long long;
using ull = unsigned long long;


template <class ...Args>
void Input(Args &...args)
{
	(cin >> ... >> args);
}

template <class T>
void InputArray(std::size_t size, T &t)
{
	t.resize(size);
	for (auto &e : t) {
		cin >> e;
	}
}

template <class ...Args>
void InputArray(std::size_t size, Args &...args)
{
	(InputArray(size, args), ...);
}

template <class ...Args>
void InputVerticalArray(std::size_t size, Args &...args)
{
	(args.resize(size), ...);
	for (int i = 0; i < size; i++) {
		((cin >> args[i]), ...);
	}
}

template <class ...Args>
void Output(const Args &...args)
{
	((cout << args << ' '), ...) << endl;
}

template <class ...Args>
void OutputVertical(const Args &...args)
{
	((cout << args << endl), ...);
}

template <class T>
void OutputArray(const T &t)
{
	for (const auto &e : t) {
		cout << e << ' ';
	}
	cout << endl;
}

template <class ...Args>
void OutputArray(const Args &...args)
{
	(OutputArray(args), ...);
}

template <class ...Args>
void OutputVerticalArray(const Args &...args)
{
	for (int i = 0; i < min({ args.size()... }); i++) {
		((cout << args[i] << ' '), ...) << endl;
	}
}


#define inp(type, ...) \
	type __VA_ARGS__; \
	Input(__VA_ARGS__)

#define inpa(type, size, ...) \
	type __VA_ARGS__; \
	InputArray((size), __VA_ARGS__)

#define inpva(type, size, ...) \
	type __VA_ARGS__; \
	InputVerticalArray((size), __VA_ARGS__)

#define otp(...) \
	Output(__VA_ARGS__)

#define otpv(...) \
	OutputVertical(__VA_ARGS__)

#define otpa(...) \
	OutputArray(__VA_ARGS__)

#define otpva(...) \
	OutputVerticalArray(__VA_ARGS__)

#define rep(counter, range) \
	for (int (counter) = 0; (counter) < (range); (counter)++)

#define repi(range) \
	rep(i, range)

#define rrep(counter, range) \
	for (int (counter) = (range) - 1; (counter) >= 0; (counter)--)

#define rrepi(range) \
	rrep(i, range)

#define repc(element, container) \
	for (auto &(element) : (container))

#define repe(container) \
	repc(e, container)

#define all(container) \
	(container).begin(), (container).end()

#ifdef __CCR__
#	define dlog(x) clog << #x " = " << x << endl
#else
#	define dlog(x)
#endif



int main()
{
	inp(int, k);
	
	string s;
	s.reserve(3 * k);
	repi(k) s += "ACL";
	
	otp(s);
	
	return 0;
}


Measured memory_bytes: 3664
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

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

int main() {
    int N, X;
    cin >> N >> X;
    int L[N];
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }

    int count = 1;
    int D = 0;

    for (int i = 0; i < N; i++) {
        D += L[i];
        if (D <= X) count++;
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256