akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    string inp;cin >>inp;
    int j =inp.size();
    if(j==1){
        cout << "No";return 0;
    }
    int n=0,s=0,e=0,w=0;
    fo(i,j){
        if(inp[i]=='N'){
            n=1;
        }
        if(inp[i]=='E'){
            e=1;
        }
        if(inp[i]=='W'){
            w=1;
        }
        if(inp[i]=='S'){
            s=1;
        }
    }
    if(n&&w&&e&&s){
        cout << "Yes";return 0;
    }
    else if((n&&s&&e)||(n&&s&&w)||(w&&s&&e)||(w&&n&&e)){
        cout << "No";return 0;
    }
    else if((n&&s)||(e&&w)){
        cout << "Yes";return 0;
    }
    else{
        cout << "No";return 0;
    }
}




Measured memory_bytes: 3648
#include <iostream>
#include <set>
#include <map>

using namespace std;

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

string replace(string &S, string &T, int i) {
  char target = S[i], replacement = T[i];
  for (int j = i; j < S.length(); ++j) {
    if (S[j] == target)
      S[j] = replacement;
    else if (S[j] == replacement)
      S[j] = target;
  }
  return S;
}

int main() {
  string S, T;
  cin >> S >> T;

  map<char, char> s_table;
  map<char, char> t_table;
  REP(i, S.length()) {
    if (s_table.find(S[i]) != s_table.end()) {
      if (T[i] != s_table[S[i]]) {
        cout << "No" << endl;
        return 0;
      }
    }
    if (t_table.find(T[i]) != t_table.end()) {
      if (S[i] != t_table[T[i]]) {
        cout << "No" << endl;
        return 0;
      }
    }
    s_table[S[i]] = T[i];
    t_table[T[i]] = S[i];
  }
  cout << "Yes" << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

ll k,s;
ll ans;

int main(){
  cin >> k >> s;
  for(ll i = 0;i <= k;i++){
    for(ll j = 0;j <= k;j++){
      if(s-i-j <= k && s-i-j >= 0) ans++;
    }
  }
  cout << ans << endl;
}


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

using namespace std;


int INF = (1 << 30);
int gcd(int a, int b) {
  return b != 0 ? gcd(b, a % b) : a;
}




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

  int A[N];
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }

  int ans =INF;
  for (int i = 1; i < N; ++i) {
    ans = min(ans, gcd(A[0], A[i]));
//    for (int j = i+1; j < N; ++j) {
//    }
  }

  //
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#pragma region Include
#include <bits/stdc++.h>
// #include <algorithm>
// #include <bitset>
// #include <climits>
// #include <cmath>
// #include <iostream>
// #include <iterator>
// #include <map>
// #include <queue>
// #include <sstream>
// #include <stack>
// #include <string>
// #include <unordered_map>
// #include <unordered_set>
// #include <vector>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define newl "\n"
#define out(x) cout << (x) << newl
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << newl
template <class T>
using VV = vector<vector<T>>;
#define Uni(v) (v).erase(unique((v).begin(), (v).end()), (v).end());

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;

string tostring(int i, int digit) {
  auto cur = cout.flags();
  stringstream ss;
  ss << setw(4) << setfill('0') << i;
  string ret = ss.str();
  cout.flags(cur);
  return ret;
}

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;
}

#pragma endregion

bool ok(ll x, vector<ll>& A, vector<ll>& F, ll K) {
  ll cur = 0;
  int N = A.size();
  ll mult;
  rep(i, N) {
    mult = A[i] * F[i];
    if (mult <= x) continue;
    cur += max((A[i] * F[i] - x - 1) / F[i] + 1, 0LL);
  }
  if (cur <= K)
    return true;
  else
    return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  vector<ll> F(N);
  cin >> A;
  cin >> F;
  sort(all(A));
  sort(all(F));
  reverse(all(F));
  ll down, up;
  down = 0;
  up = -1;
  rep(i, N) { chmax(up, A[i] * F[i]); }

  while (up - down > 0) {
    ll mid = (down + up) / 2;
    if (ok(mid, A, F, K)) {
      up = mid;
    } else {
      down = mid + 1;
    }
  }
  out(down);
  return 0;
}

Measured memory_bytes: 3328
import bisect
 
x = int(input())
six_list = [6 ** i for i in range(7)]
nine_list = [9 ** i for i in range(6)]
 
 
def six_nine(n):
    if n == 0:
        return 0
    else:
        six = six_list[bisect.bisect_right(six_list, n) - 1]
        nine = nine_list[bisect.bisect_right(nine_list, n) - 1]
        return min(n // six + six_nine(n % six), 1 + six_nine(n - nine))
 
 
print(six_nine(x))

Measured memory_bytes: 3060
#include <iostream>
#include <cassert>
//#define NDEBUG
void output(int h, int w){
	using namespace std;
	for (int i = 0; i < h; i++){		/* 縦 */
		for (int j = 0; j < w; j++){	/* 横 */
			cout << "#";
		}
		cout << "\n";
	}
	cout << "\n";							/* データセット間の空行 */
}
int main(void){
	using namespace std;
	static const int INPUT_H_MIN = 0;	/* 前提は1以上だが、入力終了時は0 */
	static const int INPUT_H_MAX = 300;
	static const int INPUT_W_MIN = 0;	/* 前提は1以上だが、入力終了時は0 */
	static const int INPUT_W_MAX = 300;
	int input_h = 0;
	int input_w = 0;
	
	while(1){
		/* 縦Hと横Wを入力 */
		cin >> input_h >> input_w;
		
		/* 入力値が、  両方0(入力終了時) or 前提条件 最大・最小の制限内の入力 */
		assert ((input_h == 0 && input_w == 0 ) || (INPUT_H_MIN <= input_h && input_h <= INPUT_H_MAX));
		assert ((input_h == 0 && input_w == 0 ) || (INPUT_W_MIN <= input_w && input_w <= INPUT_W_MAX));
		
		/* 出力 */
		if(input_h == 0 && input_w == 0){
			break;
		}
		else{
			output(input_h, input_w);
		}
	}
	
	return 0;
}



Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main() {
    int n, k;
    while (cin >> n >> k) {
        vector<int> gs(n+1);
        for (int i = 0; i < k; i++) {
            int m;
            cin >> m;
            for (int j = 0; j < m; j++) {
                int id;
                cin >> id;
                gs[id] = i;
            }
        }
        int r;
        cin >> r;
        set<int> bads;
        for (int i = 0; i < r; i++) {
            int p, q;
            cin >> p >> q;
            if (gs[p] == gs[q]) {
                bads.insert(p);
                bads.insert(q);
            }
        }
        cout << bads.size() << endl;
    }
}

Measured memory_bytes: 1196
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

const int maxn = 105;

int A[2][maxn];

int main(void)
{
	int n;
	scanf("%d", &n);
	for(int i = 0;i < n;i++)
	{
		scanf("%d", &A[0][i]);
		if(i) A[0][i] += max(0, A[0][i-1]);
	}

	for(int i = 0;i < n;i++)
	{
		scanf("%d", &A[1][i]);
		if(i) A[1][i] += max(A[1][i-1], A[0][i]);
		else A[1][i] += max(A[0][i], 0);
	}
	printf("%d\n", A[1][n-1]);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;

using namespace std;

int main() {
    ll N,M;
    cin >> N >>M;
    ll A[N];
    for(int i = 0; i < N; i++){
        A[i] = 0;
    }
    for(int i = 0; i < M; i++){
        ll a,b;
        cin >> a >>b;
        b--;a--;
        A[a]++;
        A[b]++;
    }
    bool judge = true;
    for(int i = 0; i < N; i++){
        if(A[i] % 2 != 0){
            judge = false;
        }
    }
    if(judge){
        cout << "YES" << endl;
    } else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 1024
"use strict";

function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    let a = parseInt(input[0], 10);

    //出力
    console.log(a + Math.pow(a, 2) + Math.pow(a, 3));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29696
#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)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



int main(){
    int MAX = 100005;
    int primes[MAX+10];
    repi(i,2,MAX) primes[i] = 1;
    repi(i,2,sqrt(MAX)) if(primes[i]) for(int j = 2; i*j < MAX; j++) primes[i*j] = 0;
    vector<int> pms, res;
    rep1(i,MAX) if(primes[i]) pms.pb(i);
    sort(ALL(pms));

    rep1(i,MAX) if(binary_search(ALL(pms),i) && binary_search(ALL(pms),(i+1)/2)) res.pb(i);
    int Q;
    cin >> Q;
    rep(i,Q){
        int l,r;
        cin >> l >> r;
        pr(upper_bound(ALL(res),r) - lower_bound(ALL(res),l));
    }
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
using namespace std;
int N,M;
int H[100001];
vector<int> G[100001];
int c=0;
int main(){
	cin >> N >> M;
	for(int i=0;i<N;i++)cin >> H[i];
	for(int i=0;i<M;i++){
		int a,b;
		cin >> a >> b;
		G[a-1].push_back(b-1);
		G[b-1].push_back(a-1);
	}
	for(int i=0;i<N;i++){
		bool f =true;
		for(int j=0;j<G[i].size();j++){
			if( H[i] <= H[ G[i][j] ] ) f=false;
		}
		if(f)c++;
	}
	cout << c << endl;
	return 0;
}

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

typedef long long ll;
static const int MAX=1000;

int main(){
    int n;
    cin >> n;
    ll res[MAX+1]={};
    ll div=1000000007;
    for(int i=2;i<=n;i++){
        int k=i;
        for(int j=2;j<=i;j++){
            while(k%j==0){
                res[j]++;
                k/=j;
            }
        }
    }
    ll ans=1;
    for(int i=2;i<=n;i++){
        if(res[i]==0) continue;
        ans*=(res[i]+1);
        if(ans>div) ans=ans%div;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * A - Not
 * 0 以上 1 以下の整数 x が与えられます。
 * x が 0 なら 1 を、1 なら 0 を出力してください。
 */
public class Main {

    public static void main( String[] args ) {

        // 入力値
        Scanner sc = new Scanner( System.in );

        System.out.println( sc.nextInt() == 0 ? 1 : 0 );

        sc.close();
    }
}


Measured memory_bytes: 35680
import functools
n = int(input())
arr = [int(a) for a in input().split()]
m = 10 ** 18

ans = 1
if 0 in arr:
    print(0)
else:
    for a in arr:
        ans *= a
        if ans > m:
            print(-1)
            break
    else:
        print(ans)


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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)

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


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}

void print(vector<vector<int> >& b, string s, int i, int j)
{
	if(i==0 or j==0)
	{
		return;
	}
	if(b[i][j]==1)
	{
		print(b, s, i-1, j-1);
		cout<<s[i-1];
	}
	else if(b[i][j]==3)
		print(b, s, i, j-1);
	else print(b, s, i-1, j);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s, t, ans="";
	cin>>s>>t;

	int m = s.size(), n = t.size();

	vector<vector<int> > a(m+1, vector<int> (n+1)), b(m+1, vector<int> (n+1));
	for(int i = 0; i <= m; i++)
	{
		a[i][0]=0;
	} 
	for(int i = 0; i <= n; i++)
	{
		a[0][i]=0;
	}
	for(int i = 1; i <= m; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			if(s[i-1]==t[j-1])
			{
				a[i][j]=1+a[i-1][j-1];
				b[i][j]=1;
			}
			else
			{
				if(a[i-1][j]>=a[i][j-1])
				{
					a[i][j]=a[i-1][j];
					b[i][j]=2;
				}
				else
				{
					a[i][j]=a[i][j-1];
					b[i][j]=3;
				}
				// a[i][j]=max(a[i-1][j], a[i][j-1]);
			}
		}
	}
	// int i = m, j = n;
	// while(i > 0 and j > 0)
	// {
	// 	if(a[i][j]==a[i-1][j-1]+1)
	// 	{
	// 		ans+=s[i-1];
	// 		i--;
	// 		j--;
	// 	}
	// 	else
	// 	{
	// 		if(a[i][j]==a[i-1][j])
	// 		{
	// 			i--;
	// 		}
	// 		else if(a[i][j]==a[i][j-1]) j--;
	// 	}
	// }
	// cout<<i<<" "<<j<<endl;
	// reverse(ans.begin(), ans.end());
	// cout<<ans<<endl;
	print(b, s, m, n);
}

Measured memory_bytes: 88624
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	ans := 0
	for i := 0; i < n; i++ {
		a := scanInt()
		if i%2 == 0 && a%2 == 1 {
			ans++
		}
	}
	fmt.Println(ans)
}


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

using namespace std;

const int P = 998244353;

long long power(long long x, long long t) {
	long long ret = 1;
	for(; t; t >>= 1, x = x * x % P) {
		if(t & 1) {
			ret = ret * x % P;
		}
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, s;
	cin >> n >> s;

	vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	vector<long long> pw(n + 1);
	pw[0] = 1;
	for(int i = 0; i + 1 <= n; ++i) {
		pw[i + 1] = pw[i] * 2 % P;
	}

	long long inv2 = power(2, P - 2);

	vector<vector<long long> > dp(n + 1, vector<long long> (s + 1));
	dp[0][0] = pw[n];

	for(int i = 0; i < n; ++i) {
		for(int j = 0; j <= s; ++j) {
			dp[i + 1][j] = dp[i][j];
		}
		for(int j = 0; j + a[i] <= s; ++j) {
			dp[i + 1][j + a[i]] = (dp[i + 1][j + a[i]] + dp[i][j] * inv2) % P;
		}
	}

	cout << dp[n][s] << '\n';

	return 0;
}


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

void fnInput(vector<int>& rvnSeqB)
{
  int nSeqBSiz;
  cin >> nSeqBSiz;
  rvnSeqB.resize(nSeqBSiz - 1);

  for (int& rnSeqB : rvnSeqB)
    cin >> rnSeqB;
}
  
int fnMaxValueGet(const vector<int>& cnrvnSeqB)
{
  vector<int> vnSeqA(cnrvnSeqB.size() + 1, INT_MAX);

  for (int n = 0; n < cnrvnSeqB.size(); n++)
    if (cnrvnSeqB[n] < vnSeqA[n])
      vnSeqA[n + 1] = vnSeqA[n] = cnrvnSeqB[n];
    else
      vnSeqA[n + 1] = cnrvnSeqB[n];

  int nSumSeqA = 0;
  for (int nSeqA : vnSeqA)
    nSumSeqA += nSeqA;

  return nSumSeqA;
}
  
int main()
{
  vector<int> vnSeqB;

  fnInput(vnSeqB);
  cout << fnMaxValueGet(vnSeqB) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ls (o << 1)
#define rs (o << 1 | 1)
#define mid ((L + R) >> 1)
using namespace std;
typedef long long LL;
const int N = 25;
int dp[N][N];
int dfs(int a, int b) {
	if (~dp[a][b]) return dp[a][b];
	vector<int> nxt;
	for (int i = 1; i + i <= a; ++i) {
		nxt.push_back(dfs(a - i - i, b + i));
	}
	for (int i = 1; i + i <= b; ++i) {
		nxt.push_back(dfs(a + i, b - i - i));
	}
	sort(nxt.begin(), nxt.end());
	nxt.resize(unique(nxt.begin(), nxt.end()) - nxt.begin());
	dp[a][b] = 0;
	for (auto &i : nxt) {
		if (i == dp[a][b]) {
			dp[a][b]++;
		}
	}
	return dp[a][b];
}
int main() {
#ifdef TEST
	freopen("input.txt", "r", stdin);
#endif
	// memset(dp, -1, sizeof(dp));
	// for (int i = 0; i < 11; ++i) {
	// 	for (int j = 0; j < 11; ++j) {
	// 		printf("%3d", dfs(i, j));
	// 	}
	// 	printf("\n");
	// }
	LL a, b;
	cin >> a >> b;
	if (abs(a - b) <= 1) {
		puts("Brown");
	} else {
		puts("Alice");
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static final FS sc = new FS();  // 封装输入类
    static final PrintWriter pw = new PrintWriter(System.out);
    public static void main(String[] args) {
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0;i < n;i++) {
            a[i] = sc.nextLong();
        }
        long money = 1000, k = 0;
        for (int i = 1; i < n; i++) {
            if (a[i - 1] < a[i]) {
                k = money / a[i - 1];
                money -= a[i - 1] * k;
            }
            money += k * a[i];
            k = 0;
        }
        pw.println(money);
        pw.flush();
    }

    static class FS {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        String next() {
            while(!st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch(Exception ignored) {}
            }
            return st.nextToken();
        }
        int[] nextArray(int n) {
            int[] a = new int[n];
            for(int i = 0;i < n;i++) {
                a[i] = nextInt();
            }
            return a;
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32744
N,M,X = map(int,input().split())
data = [list(map(int,input().split())) for i in range(N)]

A = []
for i in range(2**N):
    B = [0]*M
    price = 0
    for j in range(N):
        if i >> j & 1:
            price += data[j][0]
            for k in range(M):
                B[k] += data[j][k+1]
    for j in range(M):
        if B[j] < X:
            break
    else:
        A.append(price)
if len(A) == 0:
    print(-1)
else:
    print(min(A))

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

long long cycletown=1;
long long cyclelen=0;
long long totallen=0;
long long n;
long long k;

void dfs(long long t, vector<long long> &arr, vector<bool> &vis)
{
  if (vis[t])
  {
    cycletown=t;
    return;
  }
  
  vis[t]=true;
  
  dfs (arr[t],arr,vis);
  
  totallen++;
  
  if (vis[cycletown])
    cyclelen++;
  
  vis[t]=false;
}

long long town (vector<long long> &arr, vector<bool> &vis)
{
  if (k<=n)
  {
  	long long anstown = 1;
    for (long long i=0;i<k;i++)
    anstown = arr[anstown];
    
    return anstown;
  }
  
  dfs (1,arr,vis);
  
  k-= (totallen-cyclelen);

  k%=cyclelen;
  
  long long anstown = cycletown;
  
  for (long long i=0;i<k;i++)
    anstown = arr[anstown];
  
  return anstown;
}

int main()
{
  cin>>n;
  cin>>k;
  
  vector<long long> arr (n+1,0);
  for (long long i=1;i<=n;i++)
    cin>>arr[i];
  
  vector<bool> vis (n+1,false);
  
  cout<<town(arr,vis);
}


Measured memory_bytes: 12168
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
As = list(map(int, input().split()))

s1 = 0
s2 = sum(As)

ans = s2
for a in As:
    s1 += a
    s2 -= a
    # print(s1, s2)
    ans = min(ans, abs(s1 - s2))
print(ans)




Measured memory_bytes: 28276
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int sum = 0, A;
  for (int i = 0; i < 3; i++) cin >> A, sum += A;
  cout << (sum >= 22 ? "bust" : "win") << '\n';
  return 0;
}


Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[] h=new int[s[0]+1];
		string ans="YES";
		for(int i=0;i<s[1];i++){
			int[] q=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			h[q[0]]++;
			h[q[1]]++;
		}
		for(int i=0;i<s[0];i++){
			if(h[i]%2==1){ans="NO";break;}
		}
		Console.WriteLine(ans);
	}
}

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

using namespace std;

void solve()
{
	int n;
	cin >> n;
	int xs[n];
	for (int i = 0; i < n; i++)
	{
		cin >> xs[i];
		xs[i]--;
	}
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (xs[i] == i)
		{
			if (i != n-1)
			{
				swap(xs[i], xs[i+1]);
			}
			ans++;
		}
	}
	cout << ans << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
	int n, a, b;
	cin >> n;
	int con = 0;
	for(int i = 0; i < n; i++){
		cin >> a >> b;
		con += (b - a + 1);
	}
	cout << con << endl;
	return 0;
}


Measured memory_bytes: 384
#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
      
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

n,m = [int(i) for i in input().split()]
par = [-1]*n
for i in range(m):
  x,y,z = [int(i)-1 for i in input().split()]
  unite(x,y)
  
chk = []
for i in range(n):
  chk_append = chk.append
  chk_append(find(i))
  
chk = set(chk)
print(len(chk))

Measured memory_bytes: 13992
from math import gcd

def gcd2(p, q):  # p > qのこと！
    if p % q == 0:
        # print('result: ' + str(q))
        return q
    else:
        return gcd(q, p % q)


K = int(input())

ans = 0

for i in range(1, K+1):
    for j in range(1, K+1):
        # gcd_ij = gcd2(max(i, j), min(i, j))
        gcd_ij = gcd(i, j)
        for k in range(1, K+1):
            # gcd_ijk = gcd2(max(gcd_ij, k), min(gcd_ij, k))
            gcd_ijk = gcd(gcd_ij, k)
            # print(i, j, k, gcd_ij, gcd_ijk)
            ans += gcd_ijk

print(ans)

# print(max(2, 3))
# print(min(2, 3))
#
# print(gcd(max(2, 3), min(2, 3)))


Measured memory_bytes: 9172
A,B,C,D,E,F = map(int, input().split())
u,v,w,x,y,z = map(int, input().split())
s = 0
for _ in range(3):
    for _ in range(4):
        if A == u and B == v and C == w and D == x and E == y and F == z:
            s = 1
            break
        A,B,C,D,E,F = A,C,E,B,D,F #R
    A,B,C,D,E,F = D,B,A,F,E,C #E
    for _ in range(4):
        if A == u and B == v and C == w and D == x and E == y and F == z:
            s = 1
            break
        A,B,C,D,E,F = A,C,E,B,D,F #R
    A,B,C,D,E,F = B,F,C,D,A,E #N

if s == 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 7736
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    a--;
    string s;
    cin>>s;
    
    int len=s.size();
    
    for(int i=0;i<len;i++)
    {
        if(i==a+1&&s[i]!='-')
        {
           cout<<"No"<<endl;
            return 0; 
        }
        
        else if(i!=a+1&&s[i]=='-')
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
def ssort(a,n):
    count = 0
    for i in range(n):
        mini = i
        for j in range(i, n):
            if a[mini]>a[j]:
                mini = j
        if i!=mini:
            a[i], a[mini] = a[mini], a[i]
            count+=1
    print(*a)
    print(count)
n= int(input())
a = [int(x) for x in input().split()]
ssort(a,n)



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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 2*(int)1e5+1000;
int n, a[maxn], lis[maxn], len = 1, ans[maxn];
vvi G(maxn);

void dfs(int u, int par) {
    for (int v : G[u]) {
        if (v == par) continue;
        int p = lower_bound(lis+1, lis+1+len, a[v])-lis;
        bool flag = false;
        if (p > len) {
            len = p;
            flag = true;
        }
        int pre;
        if (!flag) pre = lis[p];
        lis[p] = a[v];
        ans[v] = len;
        dfs(v, u);
        if (flag) --len;
        if (!flag) lis[p] = pre;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> n;
    for1(i, n) cin >> a[i];
    forn(i, n-1) {
        int u, v;
        cin >> u >> v;
        G[u].eb(v);
        G[v].eb(u);
    }
    ans[1] = 1;
    lis[1] = a[1];
    dfs(1, 0);
    for1(i, n) cout << ans[i] << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

int main() {
    int  n;
    cin>>n;
    long long arr[n];
    set<long long>s;
    map<long long,long long>mp;
    long long x=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        x^=arr[i];
    }
    for(int i=0;i<n;i++){
        long long y=x^arr[i];
        cout<<y<<" ";
    }
}



Measured memory_bytes: 5180
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
int main(void){
	int c[100000][2];
	for (int i = 0; i < 100000; i++){
		c[i][0] = 0;
		c[i][1] = 0;
	}
	vector<int> e[100000];
	queue<pair<int, int> >q;
	int d;
	int k;
	long long n,m;
	int s, t;
	long long x, y, z,ans;

	scanf("%lld %lld", &n,&m);

	for (int i = 0; i < m; i++){
		scanf("%d %d", &s,&t);
		s--;
		t--;
		e[s].push_back(t);
		e[t].push_back(s);
	}
	c[0][0] = 1;
	q.push(make_pair(0, 0) );
	for (; q.empty() == 0;){
		for (int i = 0; i < e[q.front().first].size(); i++){
			s = (q.front().second+1) % 2;
			if (c[e[q.front().first][i]][s] == 0){
				c[e[q.front().first][i]][s] = 1;
				q.push(make_pair(e[q.front().first][i], s));
			}
		}
		q.pop();
	}
	x = 0;
	y = 0;
	z = 0;
	c[0][1] = 0;
	for (int i = 0; i < n; i++){
		if (c[i][0] == 1 && c[i][1] == 1)z++;
		else if (c[i][0] == 1)x++;
		else y++;
	}
	ans = (z*(z - 1)) / 2;
	ans += x*y;
	ans += x*z;
	ans += y*z;
	ans = ans - m;
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(decltype(N+k) i=k; i<N;i++)
#define rep(i,N) for(decltype(N) i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return 約数unordered_set 1 <= x <= n
auto divv = [](auto n) {
  unordered_set<decltype(n)> v;
  for(decltype(n) i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.insert(i);
      if(i*i != n) v.insert(n/i);
    }
  }
  return v;
};

// check prime (and n>=2) or not
auto isPrime = [](auto n){
  if(n <= 1) return false;
  for(decltype(n) i = 2; i <= sqrt(n); ++i) {
      if(n % i == 0) {
          return false;
      }
  }
  return true;
};

int main() {
    ll a;
    cin>>a;
    vector<pair<double,double>> v;
    rep(i,a){
        double c,b;
        cin>>c>>b;
        v.emplace_back(c,b);
    }
    double sum = 0;
    rep(i,a){
        rep(j,a){
            auto tmp = (v[i].first - v[j].first)* (v[i].first - v[j].first)+ (v[i].second - v[j].second)*(v[i].second - v[j].second);
            sum+=sqrt(tmp);
        }
    }
    printf("%f\n",sum/a);
    
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n;
	cin>>n;
	multiset<int> ms;
	vector<int> v;
	for(int i=0;i<(1<<n);i++){
		int x;
		cin>>x;
		ms.insert(x);
	}
	multiset<int>::iterator it = ms.end();
	--it;
	v.pb(*it);
	ms.erase(it);
	//it = ms.begin(); while( it != ms.end() ){ cout<<*it<<" "; it++; } cout<<endl;
	for(int k=1;k<=n;k++){
		int times = 1 << (k-1);
		for(int i=0; i<times;i++){
			int cur = v[i];
			it = ms.lower_bound(cur);
			if( it == ms.begin() && *it >= cur ){
				cout<<"No"<<endl;
				return 0;
			}
			else if( it == ms.end() || *it >= cur){
				--it;
				v.pb(*it);
				//cout<<*it<<endl;
				ms.erase(it);
			}
			else{
				v.pb(*it);
				//cout<<*it<<endl;
				ms.erase(it);
			}
		}
		sort( v.begin(), v.end(), greater<int>() );
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 14712
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define INF 10000000
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int N;
    cin>>N;
    vector<int> A(N),B(N),C(N);
    rep(i,N) cin>>A.at(i);
    rep(i,N) cin>>B.at(i);
    rep(i,N) cin>>C.at(i);
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    
    //Acnt.at(n)=Bnについて上部に使えるAの個数
    vector<ll> Acnt(N);
    int max_ai=0;
    rep(i,N){
        Acnt.at(i)=max_ai;
        for(int j=max_ai; j<N; j++){
            if(A.at(j)>=B.at(i)) break;
            Acnt.at(i)++;
            max_ai=j;
        }
    }
    
    //Bcnt.at(n)=Cnについて中部に使えるBの個数
    vector<ll> Bcnt(N);
    int max_bi=0;
    rep(i,N){
        Bcnt.at(i)=max_bi;
        for(int j=max_bi; j<N; j++){
            if(B.at(j)>=C.at(i)) break;
            Bcnt.at(i)++;
            max_bi=j;
        }
    }
    
    //累積和をとる
    vector<ll> sum(N+1);
    rep(i,N){
        sum.at(i+1) = sum.at(i)+Acnt.at(i);
    }

    ll ans=0;
    rep(i,N){
        ans+=sum.at(Bcnt.at(i));
    }
    cout<<ans<<endl;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

    string S; std::cin >> S;
    bool n, w, s, e;
    n = w = s = e = false;
    for (auto &c : S) {
        if (c == 'N') n = true;
        else if (c == 'W') w = true;
        else if (c == 'S') s = true;
        else if (c == 'E') e = true;
    }
    if (n^s || w^e) std::cout << "No" << "\n";
    else std::cout << "Yes" << "\n";
}


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

int main(void) {
    int n;
    cin >> n;
    long a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    long x = 0;
    for (int i = 0; i < n; i++) {
        x += a[i] * ((i & 1) ? -1 : 1);
    }
    cout << x;
    for (int i = 1; i < n; i++) {
        x = 2 * a[i - 1] - x;
        cout << ' ' << x;
    }
    cout << endl;
    return 0;
}


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

namespace {
	const long long MOD = 1000000007;
}

long long fact(long long n) {
	long long ans = 1;
	for (long long i = 1; i <= n; i++) {
		ans = (ans * i) % MOD;
	}
	return ans;
}

int main() {
	
	int N, M;
	std::cin >> N >> M;

	if (std::abs(N - M) >= 2) {
		std::cout << 0 << std::endl;
		return 0;
	}

	long long fact_N = fact(N);
	long long fact_M = fact(M);

	if (N == M) {
		std::cout << (2 * fact_N * fact_M) % MOD << std::endl;
	} else {
		std::cout << (fact_N * fact_M) % MOD << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using std::min;
#define mod 998244353
#define int long long
int fac[20001000],inv[20001000],n,a,b,ans;
int quickpow(int x,int y){
	if(y==0)return 1;
	if(y%2==0)return quickpow(x*x%mod,y/2);
	if(y%2==1)return quickpow(x*x%mod,y/2)*x%mod;
}
int C(int x,int y){
	if(y<0||x<y)return 0;
	if(y==0||x==y)return 1;
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int Catalan(int x,int y){
	return((C(x+y,y)-C(x+y,y-1))+mod)%mod;
}
signed main(){
	scanf("%lld%lld%lld",&n,&a,&b);
	if(b==0)return puts("1"),0;
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=fac[i-1]*i%mod;
	inv[n]=quickpow(fac[n],mod-2);
	for(int i=n-1;i>=0;i--)
		inv[i]=inv[i+1]*(i+1)%mod;
	for(int i=0;i<=min(min(a,n-b),b-1);i++){
		int tot=Catalan(b-1,i);
		if(i==n-b){
			if(a==i)(ans+=tot)%=mod;
		}
		else{
            int x=n-b-i-1;
            int y=a-i+1;
            (ans+=tot*C(x+y-1,x)%mod)%=mod;
        }
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 159872
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;

int main(){
  ll N, M;
  cin >> N >> M;
  map<ll, P> m;
  for(ll i = 1; i <= M; i++){
    ll p, y;
    cin >> p >> y;
    m[y] = P(i, p);
  }
  ll cp[N+1];
  fill(cp, cp + N + 1, 1);
  ll id[M+1];
  for(auto x : m){
    ll a = x.second.first;
    ll b = x.second.second;
    id[a] = b*pow(10,6) + cp[b];
    cp[b]++;
  }
  for(ll i = 1; i <= M; i++){
    printf("%012lld\n", id[i]);
  }
  return 0;
}


Measured memory_bytes: 9344
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve(int N) {
    using eltype = pair<double, string>;
    VT<eltype> vec;
    REP(i, N) {
        string name;
        int p, a, b, c, d, e, f, s, m;
        cin >>name>>p>>a>>b>>c>>d>>e>>f>>s>>m;
        double syunyu = f * s * m - p;
        double tim = 0;
        if (m == 1) tim = a + b + c + d + e;
        else {
            tim = a + b + c + d + e;
            tim += (d + e) * (m - 1);
        }
        vec.EB(MP(syunyu / tim, name));
    }
    sort(ALL(vec), [](const eltype& l, const eltype& r) {
        if (l.first == r.first) return l.second < r.second;
        return l.first > r.first;
    });
    FORE(el, vec) {
        printf("%s\n", el.second.c_str());
    }
    printf("#\n");
    return;
}

signed main(void) {
    int n, m, p, a, b, c, x, y, z, q;
    string s;
    bool f = false;
    while (cin >> n, n) {
        solve(n);
        //return 0;
    }
}

Measured memory_bytes: 2988
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    s = input()
    n = len(s)
    sr = s.replace('x', '')
    if sr == '':
        print(0)
        return
    elif sr != sr[::-1]:
        print(-1)
        return
    cur_l = 0
    cur_r = n-1
    ans = 0
    cnt = 0
    while cur_l < cur_r:
        while s[cur_l] == 'x':
            cnt += 1
            cur_l += 1
        while s[cur_r] != s[cur_l]:
            cur_r-=1
            cnt -= 1
        ans += abs(cnt)
        cur_l += 1
        cur_r -= 1
        cnt = 0
        
    print(ans)   
    
        

if __name__ == '__main__':
    main()

Measured memory_bytes: 9108
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int A[100000];

int gcd(int a, int b) {
  if (a > b) swap(a, b);
  if (a == 0) return b;
  return gcd(b%a, a);
}
bool f() {
  int ones = 0, sum = 0;
  rep(i, N) {
    if (A[i] % 2 == 1) {
      ones++;
    }
    sum += (A[i]%2);
    sum %= 2;
  }
  if (sum != N%2) return true;
  if (ones != 1) return false;

  rep(i, N) {
    if (A[i] % 2 == 1) {
      A[i]--;
      if (A[i] == 0) return false;
    }
  }
  int g = A[0];
  rep(i, N) {
    g = gcd(g, A[i]);
  }
  rep(i, N) A[i] /= g;
  return !f();
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> A[i];

  if (f()) cout << "First\n";
  else cout << "Second\n";
  return 0;
}


Measured memory_bytes: 768
# coding: utf-8

from itertools import combinations, chain

N = int(input())
values = map(int, input().split())
costs = map(int, input().split())

sales = [v - c for v, c in zip(values, costs)]

print(max(chain.from_iterable(map(sum, combinations(sales, i)) for i in range(0, N+1))))


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    r,D,X = map(int, lines.pop(0).split(' '))
    for i in range(10):
        X = r * X - D
        print(X)
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

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

int main() {
    int N;
    string S;
    cin >> N >> S;
    const int mod = 1e9 + 7;
    int x[26];
    rep(i, 26) {
        x[i] = 1;
    }

    for(char c = 'a'; c <= 'z'; c++) {
        rep(i, N) {
            if(S[i] == c) {
                x[c - 'a']++;
            }
        }
    }

    int ans = 1;

    rep(i, 26) {
        ans = (ll)ans*x[i] % mod;
    }
    
    ans -= 1;

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

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

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

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

	int n;

	cin >> n;

	cout << (n*2)/gcd(2,n) << '\n';
	
	return 0;	
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int i,N;
	scanf("%d",&N);
	int a[N];
	int ans = 0;
	for(i=0;i<N;i++){
		scanf("%d",&a[i]);
		ans += a[i]-1;
	}
	
	
	printf("%d",ans);
	
	
	return 0;
}

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

"""
input:
3 5
0 0 1
0 1 2
0 2 3
1 0 2
1 1 2

output:
1
2
"""

import sys
from math import ceil, log2, isinf


class SegmentTree(object):
    __slots__ = ('dat', 'tree_range')

    def __init__(self):
        """
        Init a SegmentTree with update and find for RMQ.
        """
        self.tree_range = end
        self.dat = [float('inf')] * (2 * self.tree_range - 1)

    # let A[k]=a
    def update(self, k, a):
        k += self.tree_range - 1
        self.dat[k] = a
        while k > 0:
            k = (k - 1) // 2
            self.dat[k] = min(self.dat[k * 2 + 1], self.dat[k * 2 + 2])

    # get min(A[s] A[s+1] ... A[t])
    def find(self, s, t, k=0, l=0, r=0):
        if r <= s or t <= l:
            return float('inf')

        if s <= l <= r <= t:
            return self.dat[k]
        else:
            vl = self.find(s, t, k * 2 + 1, l, (l + r) // 2)
            vr = self.find(s, t, k * 2 + 2, (l + r) // 2, r)
            return min(vl, vr)


def action(cmd_list):
    for query in cmd_list:
        cmd, ele_1, ele_2 = map(int, query)
        if cmd == 0:
            case.update(ele_1, ele_2)
        elif cmd == 1:
            assert ele_1 <= ele_2
            res = case.find(s=ele_1, t=ele_2 + 1, r=end)
            if isinf(res):
                print(INIT_MAX)
            else:
                print(res)

    return case


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    n_num, q_num = map(int, _input[0].split())
    q_list = map(lambda x: x.split(), _input[1:])

    end = pow(2, ceil(log2(n_num)))
    INIT_MAX = pow(2, 31) - 1

    case = SegmentTree()

    ans = action(q_list)

Measured memory_bytes: 19716
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    cout << max({10 * a + b + c, a + 10 * b + c, a + b + c * 10}) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define F first
#define S second
using namespace std;

int main(void){
	int n,m;
	while(cin >> n,n){
		bool field[21][21]={false};
		pair<int,int> P[20];
		REP(i,n){
			int x,y;
			cin >> x >> y;
			P[i].F=x,P[i].S=y;
		}
		int x=10,y=10;
		cin >> m;
		REP(i,m){
			char dir;
			int num;
			cin >> dir;
			if(dir=='N'){
				cin >> num;
				REP(j,num)
					y++,field[x][y]=true;
			}else if(dir=='W'){
				cin >> num;
				REP(j,num)
					x--,field[x][y]=true;
			}else if(dir=='S'){
				cin >> num;
				REP(j,num)
					y--,field[x][y]=true;
			}else if(dir=='E'){
				cin >> num;
				REP(j,num)
					x++,field[x][y]=true;
			}
		}
		bool ok=true;
		REP(i,n){
			if(!field[P[i].F][P[i].S])
				ok=false;
		}
		if(ok)
			cout << "Yes" << endl;
		else 
			cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1152