akhauriyash/Code-Regression huggingface dataset:
use std::io;

pub trait ExRead {
    fn read_line(&mut self) -> io::Result<String>;
    fn read_to_string(&mut self) -> io::Result<String>;
}

impl<'a> ExRead for io::StdinLock<'a> {
    fn read_line(&mut self) -> io::Result<String> {
        let mut buf = String::new();
        io::BufRead::read_line(self, &mut buf).map(|_| buf)
    }

    fn read_to_string(&mut self) -> io::Result<String> {
        self.read_line().map(|s| s.trim().to_string())
    }
}

pub trait SplitAndParse<T: std::str::FromStr> {
    type Result;
    fn split_and_parse(self) -> Self::Result;
}

impl<'a, T: std::str::FromStr> SplitAndParse<T> for &'a str {
    type Result = Result<Vec<T>, <T as std::str::FromStr>::Err>;
    fn split_and_parse(self) -> Self::Result {
        self.split_whitespace()
            .map(|e| e.parse())
            .fold(Ok(Vec::new()),
                |acc, e| acc.and_then(|mut v| e.map(|parsed| {v.push(parsed); v})))
    }
}

fn main() {
    let n: usize;
    let mut ans = [1, 1];

    {
        let stdin = std::io::stdin();
        let mut lkin = stdin.lock();
        let mut input = lkin.read_line().unwrap().split_and_parse().unwrap().into_iter();
        n = input.next().unwrap();
        for _ in 0..n {
            let input = lkin.read_line().unwrap().split_and_parse().unwrap();
            let (t, a): (usize, usize) = (input[0], input[1]);
            let ratio = std::cmp::max((ans[0] + t - 1) / t, (ans[1] + a - 1) / a);
            ans = [t * ratio, a * ratio];
        }
    }

    println!("{}", ans[0] + ans[1]);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int N;
  cin >> N;
  vector<int> data(N+10,1e10);
  for(int i = 0; i < N; i++){
    cin >> data.at(i);
  }
  int count = 0;
  int c = 0;
  for(int i = 0; i < N; i++){
    if(data.at(i) >= data.at(i+1)){
      count++;
     c = max(count,c);
    } else if(data.at(i) < data.at(i+1)){
      count = 0;
    }
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Program
{
    public class DIVERTA2019B
    {
        static public void Main(string[] args)
        {
            var R = NextInt;
            var G = NextInt;
            var B = NextInt;
            var N = NextInt;

            var rmax = N;
            var ans = 0;
            for (int r = 0; r <= rmax; r += R)
            {
                var gmax = rmax - r;
                for (int g = 0; g <= gmax; g += G)
                {
                    var bmax = gmax - g;
                    if(bmax % B == 0) ++ans;
                }
            }

            Console.WriteLine(ans);
        }

        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static int NextInt() => int.Parse(NextString());
            public static long NextLong() => long.Parse(NextString());
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static int NextInt => Console_.NextInt();
        static long NextLong => Console_.NextLong();
        static string NextString => Console_.NextString();

        static IEnumerable<int> Prime(int x)
        {
            if (x < 2) yield break;
            yield return 2;
            var halfx = x / 2;
            var table = new bool[halfx + 1];
            var max = (int)(Math.Sqrt(x) / 2);
            for (int i = 1; i <= max; ++i)
            {
                if (!table[i])
                {
                    var add = 2 * i + 1;
                    yield return add;
                    for (int j = 2 * i * (i + 1); j <= halfx; j += add)
                    {
                        table[j] = true;
                    }
                }
            }
            for (int i = max + 1; i <= halfx; ++i)
            {
                if (!table[i]) yield return 2 * i + 1;
            }
        }
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
  	cin >> p[i];
  }
  int ans = 0;
  for (int i = 1; i < n - 1; i++) {
  	if ((p[i-1] < p[i])&&(p[i] < p[i+1])) {
    	ans++;
    }
    else if ((p[i-1] > p[i])&&(p[i] > p[i+1])) {
    	ans++;
    }	
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

long long modpow(ll x, ll n) {
	if (n == 0) return 1LL;
	else if (n % 2 == 0) return modpow((x*x) % MOD, n / 2) % MOD;
	else return (modpow((x*x) % MOD, n / 2) * x) % MOD;
}

ll modComb(ll n, ll k) {
	ll res = 1;
	for (int i = 1; i <= n; i++) {
		res *= i;
		res %= MOD;
	}
	for (int i = 1; i <= k; i++) {
		res *= modpow(i, MOD - 2);
		res %= MOD;
	}
	for (int i = 1; i <= n - k; i++) {
		res *= modpow(i, MOD - 2);
		res %= MOD;
	}
	return res;
}

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

	/*
	ll n, m; cin >> n >> m;
	cout << "test" << endl;
	cout << "nCm = " << modComb(n, m) << endl;
	*/

	
	ll N, M, K; cin >> N >> M >> K;
	ll ans = 0;

	ll com;
	com= modComb(N * M - 2, K - 2);
	//cout << com << endl;
	
	ll res1 = N * N*(N - 1) / 2 - (N - 1)*N*(2 * N - 1) / 6;
	res1 %= MOD;
	res1 *= M * M; res1 %= MOD;
	ll res2 = M * M*(M - 1) / 2 - (M - 1)*M * (2 * M - 1) / 6;
	res2 %= MOD;
	res2 *= N * N; res2 %= MOD;

	cout << ((res1 + res2)*com) % MOD << endl;
	
	

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B,N;
  int p_a;
  cin >> N >> A >> B;
  p_a=N*A;
  if(p_a>B)
    cout << B << endl;
  else
    cout << p_a << endl;
}

  

Measured memory_bytes: 256
#include <cmath>
#include <cassert>
#include <iostream>

using namespace std;

string S;
size_t cur = 0;

int digit() {
	int n;
	assert(isdigit(S[cur]));
	n = S[cur] -'0';
	++cur;
	return n;
}

int number() {
	int n = digit();
	while (cur < S.size() && isdigit(S[cur])) {
		n = n*10 + digit();
	}
	return n;
}

int expression();
int factor() {
	int n;
	if (S[cur] != '(') n = number();
	else {
		++cur;
		n = expression();
		assert(S[cur] == ')');
		++cur;
	}
	return n;
}

int term() {
	int t = factor();
	while (cur < S.size() && (S[cur] == '*' || S[cur] == '/')) {
		char op = S[cur++];
		int b = factor();
		if(op == '*') t *= b; else t = (int)trunc(1.0*t/b);
		//cout << t << endl;
	}
	return t;
}


/*int expression() {
	int sum = number();
	while (S[cur] == '+' || S[cur] == '-') {
		char op = S[cur++];
		int b = number();
		if(op == +) sum += b;	else return sum -= b;
	}
	return sum;
}*/

int expression() {
	int sum = term();
	while (cur < S.size() && (S[cur] == '+' || S[cur] == '-')) {
		char op = S[cur++];
		int b = term();
		if(op == '+') sum += b; else sum -= b;
	}
	return sum;
}


int main() {
	int N;
	cin >> N;
	for (int i=0; i<N; ++i) {
		cur = 0;
		cin >> S;
		S.resize(S.size()-1);
		cout << expression() << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100000;

vector<int> G[MAX_N];
vector<int> art;
int ord[MAX_N];	//?¨??????????
int low[MAX_N]; //low[u]???u????????????1???????????????????????£?????????????????????????????????ord???????°????
bool visit[MAX_N]; //?¨?????????????????????????????????°

void dfs(int v,int p,int &k) //&??????????????¨??§k???????????§?????? p???v??????
{
	visit[v] = true;
	ord[v] = k++;
	low[v] = ord[v];
	bool flag = false;	//??¢??????????????????
	int ct = 0;	//?????????v????¬???°
	for(int i=0;i<G[v].size();i++){
		if(!visit[G[v][i]]){
			ct++;
			dfs(G[v][i],v,k);
			low[v] = min(low[v],low[G[v][i]]);	//??????????????????low??¨????????????
			if(p >= 0 && ord[v] <= low[G[v][i]]){
				flag = true;
			}
		}else if(G[v][i] != p){
			low[v] = min(low[v],ord[G[v][i]]); //???????????§????????£??????????¨????????????¨????????????
		}
	}
	if(p == -1 && ct > 1){
		flag = true;	//???????¬???°???2??\?????????????????¢??????
	}
	if(flag){
		art.push_back(v);
	}
}

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	int k = 0;
	fill(visit,visit+n,false);
	for(int i=0;i<n;i++){
		if(!visit[i]){
			dfs(i, -1, k);
		}
	}
	sort(art.begin(),art.end());
	for (int i=0;i<art.size();i++){
		printf("%d\n",art[i]);
	}
}

Measured memory_bytes: 7120
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

ll n, s, w, q;
ll seq[100010];

void generate() {
  int g = s;
  for(int i=0; i<n; i++) {
    seq[i] = (g/7) % 10;
    if( g%2 == 0 ) { g = (g/2); }
    else
    { g = (g/2) ^ w; }
  }
}

int main() {
  while (scanf("%lld %lld %lld %lld", &n, &s, &w, &q), n|s|w|q) {
    MEMSET(seq, 0);
    generate();
    //REP(i, n) { cout << seq[i]; }
    //cout << endl;
    reverse(seq, seq + n);
    ll ans = 0;
    if (q != 2 && q != 5) {
      map<ll, ll> cnt;
      ll value = 0;
      ll base = 1;
      REP(i, n) {
        value = (value + base * seq[i]) % q;
        base = (base * 10) % q;
        if (seq[i] != 0) {
          if (!cnt.count(value)) { cnt[value] = 0; }
          cnt[value]++;
        }
      }
      value = 0;
      base = 1;
      ll sum = 0;
      REP(i, n) {
        if (cnt.count(sum)) { ans += cnt[sum]; }
        sum = (sum + base * seq[i]) % q;

        value = (value + base * seq[i]) % q;
        base = (base * 10) % q;
        if (seq[i] != 0) {
          if (!cnt.count(value)) { cnt[value] = 0; }
          cnt[value]--;
        }
      }
    } else {
      ll numq = 0;
      REP(i, n) {
        if (seq[i] % q == 0) { numq++; }
        if (seq[i] != 0) { ans += numq; }
      }
    }
    printf("%lld\n", ans);
  }
}

Measured memory_bytes: 5228
N = int(input())
T,A = map(int, input().split())
H=list(map(int,input().split()))
Temp=[]
ans=0
for i in range(N):
    Temp.append(T-H[i]*0.006)
    if abs(Temp[i]-A) < abs(Temp[ans]-A):
        ans = i
print(ans+1)

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

int MOD=1000000007;

int main() {
  int N;
  cin >> N;
  vector<vector<long long>> dp(N+1,vector<long long>(4));
  vector<long long> ans(N+1);
  for (int i=0;i<4;i++){
    dp[0][i]=0;
    dp[1][i]=1;
    dp[2][i]=4;
  }
  ans[0]=0;
  ans[1]=4;
  ans[2]=16;
  for (int i=3;i<N+1;i++){
    dp[i][0]=ans[i-1];
    dp[i][1]=ans[i-1];
    dp[i][2]=ans[i-1]-dp[i-2][0]+dp[i-3][2];
    dp[i][3]=ans[i-1]-dp[i-2][0]-dp[i-2][2]-dp[i-3][0]*3;
    ans[i]=(dp[i][0]+dp[i][1]+dp[i][2]+dp[i][3])%MOD;
  }
  cout << ans[N] << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    string s;
    cin >> s;
    string key = "keyence";

    if (s == key) {
        std::cout << "YES" << std::endl;
        return 0;
    }

    REP(i, s.size()) {
        FOR(j, i, s.size()) {
            string a;
            REP(k, s.size()) {
                if (k < i || j < k)
                    a += s[k];
            }
            if (a == key) {
                std::cout << "YES" << std::endl;
                return 0;
            }
        }
    }

    std::cout << "NO" << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a, b, c;
  int chk[101];
  int i;
  for(i=0;i<=100;i++) chk[i] = 0;
  scanf("%d%d%d", &a, &b, &c);
  chk[a]++; chk[b]++; chk[c]++;
  int cnt = 0;
  for(i=0;i<=100;i++) cnt += chk[i] > 0 ? 1 : 0;
  printf("%d\n", cnt);
  return 0;
}

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

int main(){

	int l,j,i;
	char str[10];
	int memo[22];

	while(cin>>str>>l, l){
		memo[i=0]=atoi(str);
		while(++i){
			while(strlen(str)!=l) strcat(str, "0");
			sort(str,str+l);
			memo[i]=atoi(str);
			sort(str,str+l,greater<char>());
			memo[i] = atoi(str) - memo[i];

			sprintf(str, "%d", memo[i]);
	
			for(j=0;j<i;j++) if(memo[j]==memo[i])break;
			if(j<i) break;
		}
		cout << j << ' ' << memo[i] << ' ' << i-j << endl;
	}
	
	return 0;
}

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

int main() {
    
	const int p = 3;
	vector<vector<int>> c(p, vector<int>(p));
	for (int i = 0; i < p; i++) {
		for (int  j = 0; j < p; j++) {
			cin >> c[i][j];
		}
	}
	int b0 = c[0][0];
	int b1 = c[0][1];
	int b2 = c[0][2];
	bool can = true;
	if (!(c[1][0] - b0 == c[1][1] - b1 && c[1][1] - b1 == c[1][2] - b2)) can = false;
	if (!(c[2][0] - b0 == c[2][1] - b1 && c[2][1] - b1 == c[2][2] - b2)) can = false;
	if (can) cout << "Yes" << endl;
	else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>

using namespace std;

int main(){
    int n;
    cin >> n;
    long long int nums[n];
    for(int i = 0; i < n; i++){
        long long int x;
        cin >> x;
        nums[i] = x - (i + 1);
    }
    sort(nums, nums+n);
    int p;
    if(n % 2 == 0){
        p = n / 2;
    }else{
        p = n / 2 + 1;
    }
    long long int b = nums[p - 1];
    long long int ans = 0;
    for(int i = 0; i < n; i++){
        ans += abs(nums[i] - b);
    }
    cout << ans;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        String n = sc.next();
//        String str = "";
//	    // splitで分割して格納
//	    String[] strArray = str.split("");
//	    for (int i = 0; i < strArray.length; i++) {
//	    // 1文字ずつ表示
        if ((n .equals("AAA")) || (n.equals("BBB"))) {
	     System.out.println("No");
	    } else {
	    	System.out.println("Yes");
	    }
     }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
using namespace std;
using int64 = int_fast64_t;

int N;
char opt[3] = {'7', '5', '3'};

bool check(string str) {
	// t:three, f:five, s:seven
	bool t = false, f = false, s = false;
	for (int i=0; i<str.size(); ++i) {
		t |= (str[i] == '3');
		f |= (str[i] == '5');
		s |= (str[i] == '7');
	}
	return t && f && s;
}

int solve(string sum) {
	// 範囲外の時は0, 空の時はスルー
	if (sum.size() == 0);
  else if (sum.size() > 9) return 0;
	else if (stoi(sum) > N) return 0;
	
	int ret = 0;
	for (int i=0; i<3; ++i) {
		string tmp = sum + opt[i];

		// 範囲内で753全てを利用している時に1を加算
		if (tmp.size() <= 9 && stoi(tmp) <= N && check(tmp)) {
			ret++;
		}
		ret += solve(tmp);
	}

	return ret;
}

int main() {
	cin >> N;

	int ans = solve("");
	cout << ans << endl;
	
	return 0;
}


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

using namespace std;

int main()
{

string S ;
int N ;
int x=0;
cin >> N>>S;
int a[N]={1};

for(int i =0 ; i<N; i++)
 {
     if (S[i]=='I')
    x++;
    if (S[i]=='D')
   x--;
a[i]=x;
 }
sort(a,a+N);
if (a[N-1]>0)
    cout << a[N-1];
else
    cout <<0;






    return 0;
}


Measured memory_bytes: 256
# 与えられた数値の桁数と桁値の総和を計算する.
def calc_digit_sum(num):
    digits = sums = 0
    while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
    return digits, sums


n = int(input())

cnt = 0
for index in range(1, n+1):
    digit, _ = calc_digit_sum(index)
    if digit % 2 != 0:
        cnt += 1

print(cnt)

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int A=in(),B=in();
	int num = ceil(((double)B-1.0)/((double)A-1.0));
	
	out(num);
	return 0;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<long double> a(n);

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

  long double sum = 0;

  for (int i=0; i<n; i++) sum += 1/a[i];

  printf("%.14Lf\n",(1/sum));
}

Measured memory_bytes: 888
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int mod = 1e9 + 7;

int main() {
    long long n, k;
    long long ans = 0;
    scanf("%lld%lld", &n, &k);
    for(int i = k; i <= n; i++) {
        long long a1, b1, a2, b2;
        a1 = 1LL * (i - 1) * (i) / 2;
        b1 = 1LL * (i - 1) * (n - i + 2 + n) / 2;
        a2 = 1LL * i * (i + 1) / 2;
        b2 = 1LL * i * (n - i + 1 + n) / 2;
       // printf("%lld %lld %lld %lld\n", a1, b1, a2, b2);
        if(b1 >= a2)
            ans += (b2 - a1 + 1);
        else
            ans += (b1 - a1 + 1) + (b2 - a2 + 1);
        ans %= mod;
    }
    ans++;
    ans %= mod;
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;

ll n;
ll ans = 0;
vector<string> vec;
vector<vector<ll>> container(200000,vector<ll>(26,0));


void dfs(ll x,ll y,ll depth){
  //cout << depth << endl;
  if(x >= y){
    return;
  }
  REP(i,x,y){
    ull len = vec[i].size();
    if(len >= depth+1){
      container[i][vec[i][depth] - 'a']--;
    }
    if(len == depth+1){
      char c = vec[i][depth];
      REP(j,x,y){
        if(i != j && container[j][c-'a']){
          //cout << vec[i] << " " << vec[j] << endl;
          //cout << c << " " << endl;
          ans++;
        }
      }
    }
  }

  ll piv = x;

  while(piv < y-1){
    //cout << piv << endl;
    ull len = vec[piv].size();
    char c = vec[piv][depth] - 'a';
    REP(i,piv+1,y){
      if(vec[piv][depth] == vec[i][depth]){

      }else{
        dfs(piv,i,depth+1);
        piv = i;
        break;
      }
      if(i == y-1){
        dfs(piv,y,depth+1);
        piv = INFLONG;
      }
    }
  }
}
int main(){
  cin >> n;
  vec.resize(n);
  rep(i,n){
    cin >> vec[i];
    reverse(all(vec[i]));
  }
  sort(all(vec));
  rep(i,n){
    ull len = vec[i].size();
    rep(j,len){
      container[i][vec[i][j] - 'a']++;
    }
  }
//  rep(i,n){
//    rep(j,26){
//      cout << container[i][j] << " ";
//    }
//    cout << endl;
//  }
//  rep(i,n){
//    cout << vec[i] << endl;
//  }

  dfs(0,n,0);
//  rep(i,n){
//    rep(j,26){
//      cout << container[i][j] << " ";
//    }
//    cout << endl;
//  }
  cout << ans << endl;
}

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

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

	map<char, int> mp;
	for( int i = 0; i < S.size(); i++ ) {
		mp[ S[i] ]++;
	}
	string ans = "Yes";
	if( mp['N'] && mp['S'] == 0 || mp['S'] && mp['N'] == 0 || mp['W'] && mp['E'] == 0 || mp['E'] && mp['W'] == 0 ) ans = "No";

	cout << ans << endl;
}


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

#define ll long long
#define MOD 1000000007


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

    vector<ll> a(n);
    vector<ll> ap(n);
    ll va;
    for(int i=0;i<n;i++){
        cin>>va;
        a.at(i) = va;
        ap.at(i) = va;
    }

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

    ll ma,se;

    ma = ap.at(n-1);
    se = ap.at(n-2);

    for(int i=0;i<n;i++){
        if(a.at(i)==ma){
            cout<<se<<endl;
        }else{
            cout<<ma<<endl;
        }
    }




}



Measured memory_bytes: 4736
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	// 入力
	int N;
	cin >> N;
	vector<int> A(N);
	
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	
	float answer = 0.0f;
	float denominator = 0.0f;
	for (int i = 0; i < N; i++)
	{
		denominator += 1 / (float)A[i];
	}
	answer = 1 / denominator;
	
	// 出力
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
ans=0
for i in range(1,N+1):
    if i>=K:
        ans+=1/N
    else:
        c=0
        s=i
        while s<=K-1:
            s=s*2
            c+=1
        ans+=(1/N)*((1/2)**c)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <bitset>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
int main(){
    map<string,ll> blue,red;
    ll n; cin >> n;
    rep(i,n){
        string s; cin >> s;
        blue[s]++;
    }
    ll m; cin >> m;
    rep(i,m){
        string t; cin >> t;
        red[t]++;
    }
    ll ans = 0;
    for(auto i : blue){
        ans = max(ans, i.second - red[i.first]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<string>
#define swap(a,b) ((a != b) && (a += b,b = a - b,a -= b))
using namespace std;


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

int main()
{
    int a,b,k;
    cin >> a >> b >> k;
    int g=gcd(a,b);

    int c=0;
    int d=1;
    while(true){
        if(g%d==0)k--;
        if(k==0){
            cout << g/d <<endl;
            break;
        }
        d++;

    }


    return 0;
}






Measured memory_bytes: 256
fun main(arg: Array<String>) {
    val INF = 1L.shl(29)
    val (N, M, R) = listOfInt()
    val Ra = listOfInt(-1).toIntArray()
    val G = Array(N) { LongArray(N) { INF } }
    for (n in 0 until N) G[n][n] = 0
    repeat(M) {
        val (a, b, c) = listOfInt(-1, -1, 0)
        val C = c.toLong()
        if (G[a][b] > C) { G[a][b] = C; G[b][a] = C }
    }
//G.print("bofore")
    for (k in 0 until N) for (h in 0 until N) for (w in 0 until N) {
        G[h][w] = Math.min(G[h][w], G[h][k] + G[k][w])
    }
//G.print("after")
    var ans = INF
    val used = BooleanArray(R)
    fun dfs(c: Int, las: Int, dist: Long) {
        if (c == R) {
            if (ans > dist) ans = dist
            return
        }
        for (r in 0 until R) if(!used[r]) {
            used[r] = true
            if (las == -1) dfs(c + 1, r ,0)
            else dfs(c + 1, r, dist + G[Ra[las]][Ra[r]])
            used[r] = false
        }
    }
    dfs(0, -1, 0)
    println(ans)
}
fun Array<IntArray>.print(title: String = "") {
    System.err.println(if (title.length > 0) title else this)
    for ((index, array) in this.withIndex()) {
        System.err.print("[${index}] ")
        System.err.println(array.joinToString(", "))
    }
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt(D: Int = 0) = listOfString().map { Integer.parseInt(it) + D }
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }


Measured memory_bytes: 44196
n, y = map(int, input().split())
for i in range(0, n+1):
  for j in range(0, n+1-i):
    k = n - i - j
    if 10000 * i + 5000 * j + 1000 * k == y:
      print(i, j, k)
      exit()
print(-1, -1, -1)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if (A * B == 2) {
			System.out.print(3);
		} else if (A * B == 3) {
			System.out.print(2);
		} else if (A * B == 6) {
			System.out.print(1);
		}
	}
}

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

typedef long long ll;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define REPM(i,n) for(ll i=(n-1); 0=<i; i--)
#define VI vector<int>
#define VL vector<ll>
#define VD vector<double>
#define VS vector<string>
#define V_SORT_U(x) sort(x.begin(), x.end());
#define V_SORT_D(x) sort(x.begin(), x.end(),greater<int>());
#define V_SUM(x) accumulate(x.begin(), x.end(), 0)
#define STR_TRANS_UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define STR_TRANS_LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
bool chk_temp_rikaido(ll v_M, ll v_X, VL in_tmp_rikaido){
    
    REP(i,v_M)
    {
        if( in_tmp_rikaido.at(i) < v_X ) return false;
    }

    return true;
}
int main(void){
    ll N,M,X;
    cin >> N >> M >> X;
    
    vector<vector<ll>> C_i(N, vector<ll>(M+1));
    
    REP(i,N)
    {
        REP(j,M+1)
        {
            cin >> C_i.at(i).at(j); 
        }
    }
    
    ll cost = -1;

    //理解度Xを満たすような買い方シミュレーション
    //N,Mが共にMAX12なので全探索でいける？(2^12で4096通り)
    //最大で12冊全部購入のパターン、最小で1冊でALL OKのパターン

    VL tmp_rikaido (M);
    ll tmp_cost = 0;

    
    REP(i,pow(2,N))
    {
        if(i==0) continue;

        //init
        REP(init_i,M)
        {
            tmp_rikaido.at(init_i) = 0;
        }
        tmp_cost = 0;

        REP(j,N)
        {
            //採用不採用判定（ビット計算）
            if( i & (1<<j) )
            {
                REP(k,M)
                {
                    tmp_rikaido.at(k) += C_i.at(j).at(k+1); 
                }
                tmp_cost += C_i.at(j).at(0);
                //cout << "bit:" << j << endl;
            }
        }
        //cout << "tmp_cost:" << tmp_cost << endl;

        //チェック＆コスト更新
        if(chk_temp_rikaido(M,X,tmp_rikaido))
        {
            //cout << "OK" << endl;
            if( cost == -1) cost = tmp_cost;
            if( tmp_cost < cost ) cost = tmp_cost;
        }
    }
    
    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 4056
#include <cmath>
#include <iostream>
#include <vector>

int main()
{
    std::ios_base::sync_with_stdio(false);
    int N, K;
    std::cin >> N >> K;
    std::vector<int> vec;
    vec.reserve(N);
    for (int i = 0; i < N; ++i) {
        int n;
        std::cin >> n;
        vec.push_back(n);
    }
    int ans = std::ceil(static_cast<double>(N - 1) / (K - 1));
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	int N;
	cin >> N;
	vector<ll> A(N);
	rep(i, N) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	if (N == 1) {
		cout << 1 << endl;
		return 0;
	}
	int tmp_count = 1, count = 0;
	rep1(i, N) {
		if (A[i] != A[i - 1]) {
			count += tmp_count % 2;
			tmp_count = 1;
			if (i == N - 1) {
				count++;
			}
		}
		else {
			tmp_count++;
			if (i == N - 1) {
				count += tmp_count % 2;
			}
		}

	}

	cout << count << endl;
	return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s, t;

int main() {
	cin >> s >> t;
	
	bool ans = false;
	inc(i, s.size()) {
		if(s == t) { ans = true; }
		s = s.back() + s;
		s.pop_back();
	}
	
	
	cout << (ans ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string a;
    cin>>a;
    int han=(a.length()-1)/2;
    
    if((han)%2==0){
        for(int i=0;i<han/2;i++){
            if(a[i]==a[han-1-i]&&a[i]==a[han+1+i]&&a[i]==a[han+han-i]){
                if(i==han/2-1){
                    cout<<"Yes";
                }
                continue;
            }
            else{
                cout<<"No";
                break;
            }
        }
    }
    else{
        for(int i=0;i<han/2+1;i++){
            if(i==han/2){
                if(a[i]==a[han+han/2+1]){
                    cout<<"Yes";
                }
                else{
                    cout<<"No";
                }
            }
            else if(a[i]==a[han-1-i]&&a[i]==a[han+1+i]&&a[i]==a[han+han-i]){
                continue;
            }
            else{
                cout<<"No";
                break;
            }
        }
    }
    
}


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

int main(){
    ll n, k;
    cin >> n >> k;
    
    ll zero = 0, half = 0;
    rep(i, 1, n+1){
        if(i%k == 0) zero++;
        if(k%2 == 0 && i%k == (ll)(k/2)) half++;
    }

    ll ans = pow(zero, 3) + pow(half, 3);
    cout << ans << endl;
    return 0;
}

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


int main() {
  int N, L;
  string result;
  cin >> N >> L;
  string a[N];
for (int i=0; i<N; i++) cin >> a[i];
sort(a, a+N);

for(int i=0; i<N; i++){
  result += a[i];
}
  cout << result << endl;
}



Measured memory_bytes: 256
import sys

p=[0 for i in range (101)]
m=[[0 for i in range(100)]for i in range(100)]

def MatrixChain(n) : 
	for i in range(1,n+1) : m[i][i] = 0;
	for l in range(2,n+1) :
		for i in range(1,n-l+2) : 
			j = i + l - 1
			m[i][j] = float('Infinity')
			for k in range(i,j) :
				q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]
				m[i][j] = m[i][j] if m[i][j] <= q else q

n = int(input())
for i in range(n) :
	p[i], p[i+1] = map(int, input().split())

MatrixChain(n)
print(m[1][n])

Measured memory_bytes: 6848
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def solve(input: String): String = {
    val sc: Scanner = new Scanner(input)
    val s = sc.next.toCharArray
    s(0) + (s.length - 2).toString + s(s.length - 1)
  }

  val tests = List(
    """internationalization""".stripMargin -> """i18n""",
    """smiles""".stripMargin -> """s4s""",
    """xyz""" -> "x1z"
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}

Measured memory_bytes: 27312
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

//prototype declaration
int iin();
long long llin();
double din();
char cin();
void stin(char *s);
void iout(int i);
void llout(long long i);
void dout(double i);
void cout(char c);
void stout(char *s);
int dfs(int v, int n, int *visited, int table[n][n]);
int gcd(int a, int b);
int lcm(int a, int b);
long long llgcd(long long a, long long b);
long long lllcm(long long a, long long b);
int asc(const void *a, const void *b);
int desc(const void *a, const void *b);

//main function
int main() {
    char s[15];
    stin(s);
    int i, count = 0;
    REP(i,strlen(s)) {
        if (s[i] == 'o') count++;
    }
    if (count + (15 - strlen(s)) >= 8) stout("YES");
    else stout("NO");
    return 0;
}

//body function
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

int dfs(int v, int n, int *visited, int table[n][n]) {
    int all_visited = 1, i;

    REP(i,n) {
        if (!visited[i]) {
            all_visited = 0;
            break;
        }
    }

    if (all_visited) {
        return 1;
    }

    int count = 0;

    REP(i,n) {
        if (!table[v][i]) continue;
        if (visited[i]) continue;

        visited[i] = 1;
        count += dfs(i, n, visited, table);
        visited[i] = 0;
    }

    return count;
}

int gcd(int a, int b) {
    int r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

int lcm(int a, int b) {
    int r = llgcd(a, b);
    a /= r;
    return a * b;
}

long long llgcd(long long a, long long b) {
    long long r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

long long lllcm(long long a, long long b) {
    long long r = llgcd(a, b);
    a /= r;
    return a * b;
}

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int a[3][3], b[10];
bool d[3][3];

int main(){
    rep(i, 3) rep(j, 3) cin >> a[i][j];
    int n;
    cin >> n;
    rep(k, n) cin >> b[k];
    rep(i, 3) rep(j, 3) {
        d[i][j] = false;
        rep(k, n) if (a[i][j] == b[k]) d[i][j] = true;
    }
    string ans = "No";
    rep(i, 3) {
        if (d[i][0] and d[i][1] and d[i][2]) ans = "Yes";
    }
    rep(j, 3) {
        if (d[0][j] and d[1][j] and d[2][j]) ans = "Yes";
    }
    {
        if (d[0][0] and d[1][1] and d[2][2]) ans = "Yes";
    }
    {
        if (d[0][2] and d[1][1] and d[2][0]) ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <string>
using namespace std;
int main(){
    string s; cin >> s;
    set<char> st;
    for(char c:s){
        if(st.count(c) == 1){
            puts("no");
            return 0;
        }
        else{
            st.insert(c);
        }
    }
    puts("yes");
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
#include<cstdlib>
using namespace std;
#define ll long long
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll n;
    cin>>n;
    string ans="";
    while(n)
    {
        if(n%26)
        {
            ans+=('a'+n%26-1);
            n=n/26;
        }
        else
        {
            ans+='z';
            n=n/26-1;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n); for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
typedef pair<int, int> P;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
  int N,M,X;cin>>N>>M>>X;
  vi C(N);vvi A(N,vi(M));
  rep(i,N){
    cin>>C[i];
    rep(j,M){
      cin>>A[i][j];
    }
  }
  vi B(M);
  int ans=10000000;
  bool res =false;
  for(int tmp =0;tmp<(1<<N);tmp++){
    bitset<12> s(tmp);
    int cnt=0;
    bool ok=true;
    rep(i,M){
      B[i]=0;
    }
    rep(i,N){
      if(s.test(i)){
        cnt += C[i];
        rep(j,M){
          B[j] +=A[i][j];
        }
      }
    }
    rep(j,M){
      if(B[j]<X){
        ok=false;
      }
    }
    if(ok){
      ans =min(ans,cnt);
      res=true;
    }
  }  
  if(!res)cout<<-1<<endl;
  else cout<<ans<<endl;
}


Measured memory_bytes: 3732
#include "bits/stdc++.h"
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<stack>
#include<complex>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
	
#define WHATS(var)cout<<__LINE__<<' '<<#var<<"="<<var<<endl;
	
template<class S, class T> ostream& operator <<(ostream &os, const pair<S, T> v){
	os << "( " << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<T> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<vector<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<set<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const set<T> &v){
	int i=0;
	for(auto it:v){
		if(i > 0){os << ' ';}
		os << it;
		i++;
	} 
	return os;
}
using ll=long long ;

int main() {
	ios::sync_with_stdio(false);
	// int a,b,c,d;cin>>a>>b>>c>>d;
	// cout<<(int(b>d))<<endl;

	// int N;cin>>N;
	// int answer=-1;
	// for(int i=1;i<5000;++i){
	// 	int j=i*108;
	// 	j/=100;
	// 	if(j==N){
	// 		answer=i;
	// 		break;
	// 	}
	// }
	// if(answer==-1)cout<<":("<<endl;
	// else cout<<answer<<endl;
	int X;cin>>X;
	int k=X/100;
	int l=X%100;
	if(l<=5*k)cout<<1<<endl;
	else cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int max = Math.max(Math.max(a, b), c);
            int cnt = 0;
            while (1 < Math.abs(max - a)) {
                a += 2;
                cnt++;
            }
            while (1 < Math.abs(max - b)) {
                b += 2;
                cnt++;
            }
            while (1 < Math.abs(max - c)) {
                c += 2;
                cnt++;
            }

            if ((max - c + max - b + max - a) == 0) {
                out.print(cnt);
            } else if ((max - c + max - b + max - a) == 1) {
                out.print(cnt + 2);
            } else if ((max - c + max - b + max - a) == 2) {
                out.print(cnt + 1);
            }
        }

    }
}



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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        System.out.println(Arrays.stream(arr).sum() - Arrays.stream(arr).max().getAsInt()/2);
    }
}

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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

struct UnionFind {
    int size_;
    vector<int> par;
    vector<int> rank;
    vector<int> sz;

    UnionFind(int size_) : size_(size_) {
        par.resize(size_);
        rank.resize(size_);
        sz.resize(size_);

        for (int i = 0; i < size_; i++) {
            par[i] = i;
            rank[i] = 0;
            sz[i] = 1;
        }
    }

    int find(int x) { return par[x] == x ? x : par[x] = find(par[x]); }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

        if (rank[y] < rank[x]) swap(x, y);
        if (rank[x] == rank[y]) rank[x]++;

        par[x] = y;
        sz[y] += sz[x];
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return sz[find(x)]; }
};

struct Node {
    int v;
    long long cost;
    bool operator<(const Node &rhs) const {
        return make_pair(cost, v) < make_pair(rhs.cost, rhs.v);
    }
};

int N, M;
vector<long long> a;
vector<int> x, y;

int main() {
    cin >> N >> M;
    a.resize(N), x.resize(M), y.resize(M);
    rep(i, N) cin >> a[i];
    rep(i, M) cin >> x[i] >> y[i];
    UnionFind uf(N);

    rep(i, M) uf.unite(x[i], y[i]);
    map<int, int> id;
    vector<vector<Node>> trees;
    rep(i, N) {
        int p = uf.find(i);
        // printf("uf: %d -> %d\n", p, i);
        if (!id.count(p)) {
            int t = id.size();
            id[p] = t;
            trees.push_back(vector<Node>());
        }
        trees[id[p]].push_back({i, a[i]});
    }
    for (auto &tree : trees) {
        sort(all(tree));
    }
    int cnt = 2 * (N - M - 1);
    if (N < cnt) {
        cout << "Impossible" << endl;
        return 0;
    }
    if (N == M + 1) {
        cout << "0" << endl;
        return 0;
    }
    long long ans = 0;
    vector<Node> nodes;
    for (auto &tree : trees) {
        ans += tree[0].cost;
        tree.erase(tree.begin());
        for (auto node : tree) nodes.push_back(node);
        cnt--;
    }
    sort(all(nodes));
    for (auto node : nodes) {
        if (cnt == 0) break;
        ans += node.cost;
        cnt--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12976