akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    string S;
    cin >> S;

    int ans = 0;

    for (auto s : S)
        ans = (ans + s - '0') % 9;

    if (ans == 0)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


Measured memory_bytes: 3764
/**
  *Fibonacci Number
  * @output: ??\???????¬¬n???????????£??????????????°(n???0???????????????)
  */

#include <stdio.h>

#define MAX 100

long long F[MAX];
long long fib(long long);
long long n, i; //n: ?¬¬n???, ????????¬??????

int main() {
  /* 0,1??????1*/
  F[0] = 1;
  F[1] = 1;

  /* input data */
  scanf("%lld", &n);

  /* initialize */
  for(i = 2; i < MAX; i++) {
    F[i] = 0;
  }

  /* calculate */
  for(i = 2; i < n+1; i++) { //?¬¬n??????n???0??????????????§???????????¨?????¨??????
    F[i] = fib(i);
  }

  printf("%lld\n", F[n]);
  
  return 0;
}

/* fibonacchi */
long long fib(long long n) {
  return F[n-1] + F[n-2];
}

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

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

  vector<int> a(N);
  rep(i,N) cin >> a.at(i);
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  int sum_a=0;
  int sum_b=0;
  rep(i,N) {
    if (i%2) { sum_b += a.at(i); }
    else     { sum_a += a.at(i); }
  }
  cout << sum_a - sum_b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main(){
  long long N,ans=1,a,b;
  cin >> N;
  int rn=sqrt(N)+1;
  for(int i=1;i<=rn;i++){
    if(N%i==0){
      a=i;
      b=N/i;
    }
  }
  if(a>b){
    while(a>=10){
      a/=10;
      ans++;
    }
  }else{
    while(b>=10){
      b/=10;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi

using namespace std;

int main() {
    int n, b, f, r, v, house[4][3][10];
    for (auto i=0; i<4; i++) {
        for (auto j=0; j<3; j++) {
            for (auto k=0; k<10; k++) {
                house[i][j][k] = 0;
            }
        }
    }
    
    cin >> n;
    for (auto i=0; i<n; i++) {
        cin >> b >> f >> r >> v;
        house[b-1][f-1][r-1] += v;
    }
    
    for (auto i=0; i<4; i++) {
        if (i != 0) cout << "####################" << endl;
        for (auto j=0; j<3; j++) {
            for (auto k=0; k<10; k++) {
                cout << " " << house[i][j][k];
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 3080
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
  double r;
  double pi = round(M_PI*1000000000000)/1000000000000;
  scanf("%lf", &r);

  printf("%lf %lf\n", (double)(r*r*pi), (double)(r*2*pi));

  return 0;
}


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

int main(){
    long long n,m;
    cin >> n >> m;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    long long sum=0;
    for(int i=0; i<n; i++){
        sum += a.at(i);
    }

    bool flag=false;
    int cnt=n;
    for(int i=0; i<n; i++){
        if(a.at(i) < (double)sum/((double)m*4)){
            cnt--;
        }
    }
    //cout << sum << endl;
    //cout << (double)sum/(4*(double)m)<< endl;
    if(cnt>=m) flag=true;
    if(flag==true) cout << "Yes";
    else cout << "No";
    return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(M+1,0);
    for(int i=0; i<N; i++){
        int K;  cin >> K;
        for(int j=0; j<K; j++){
            int a;  cin >> a;
            A[a]++;
        }
    }

    int ans = 0;
    for(int i=1; i<=M; i++){
        if(A[i]==N) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  rep(i, n - 2) rep2(j, i + 1, n - 1) rep2(k, j + 1, n) {
    if(a[i] == a[j] || a[j] == a[k] || a[k] == a[i]) continue;
    vl x(3);
    x[0] = a[i];
    x[1] = a[j];
    x[2] = a[k];
    sort(all(x));
    if(x[0] + x[1] <= x[2]) continue;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;
int main()
{
	int a;
	cin>>a;
	vector<int>v(a+1);
	for(int i=1;i<=a;++i){
		if((i % 3 == 0) && (i % 5 == 0)) v[i] = 0;
			else if((i % 3) == 0) v[i] = 0;
				else if((i % 5) == 0) v[i] = 0;
						else v[i] = i;
	}
	cout<<accumulate(v.begin(),v.end(),0LL)<<endl;
	return 0;
}
	

Measured memory_bytes: 7140
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    string o, e; cin >> o >> e;
    REP(i, o.length()){
        cout << o[i];
        if(i != e.length()) cout << e[i];
    }
    cout << "\n";
    return 0;
}

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

typedef long long ll;

int main() {
    string S;
    ll K;
    cin >> S >> K;
    rep(i, S.size()) {
        if (S[i] != '1') {
            cout << S[i] << "\n";
            return 0;
        }
        if (K == i + 1) {
            cout << "1\n";
            return 0;
        }
    }
}

Measured memory_bytes: 256
def find(x):
    while union[x] != x:
        x = union[x]
        
    return x

N, M = map(int, input().split())
p = list(map(int, input().split()))

union = [i for i in range(N+1)]

for i in range(M):
    x, y = map(int, input().split())
    x = find(x)
    while union[y] != y:
        union[y], y = x, union[y]
        
    union[y] = x
    
ans = 0
for idx, n in enumerate(p):
    if idx+1 == n:
        ans += 1
    else:
        x, y = find(idx+1), find(n)
        if x == y:
            ans += 1
        
print(ans)

Measured memory_bytes: 13812
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
        route: [usize;5],
    }

    let mut min_value = route[0];
    for i in route {
        min_value = std::cmp::min(min_value, i);
    }

    let ans = 4 + (((n as f64)/(min_value as f64)).ceil()) as usize;
    // let ans = 5 + n/min_value;
    println!("{}", ans);

}

Measured memory_bytes: 2588
import sys, os
import collections

def solve(input_stream):
  line = input_stream.readline().strip()
  start = 0
  end = 1
  ans = 0
  while end < len(line) + 1:
    target = line[end - 1]
    if target in ["A", "C", "G", "T"]:
      ans = max(ans, end - start)
      end += 1
    else:
      start = end
      end += 1
  return [str(ans)]

if __name__ == "__main__":
    outputs = solve(sys.stdin)
    for line in outputs:
      print(line)

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

using namespace std;

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

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int n, a, b, c, d;
ll dp[1001][1001];

vector<ll> fact, inv;

ll mod_pow(ll x, ll n, ll mod) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	return res;
}

void fact_inv(int n, ll mod) {
	fact.resize(n + 1);
	inv.resize(n + 1);
	
	fact[0] = 1;
	FOR(i, 1, n + 1) fact[i] = fact[i - 1] * i % mod;
	inv[n] = mod_pow(fact[n], mod - 2, mod);
	for (int i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}

ll nCr(ll n, ll r) {
	if (n < r || r < 0 || n < 0) return 0;
	return fact[n] * inv[r] % MOD * inv[n - r] % MOD;
}

ll dfs(int rem, int mi) {
	if (rem == 0) return 1;
	if (mi > b || rem < mi) return 0;
	
	if (~dp[rem][mi]) return dp[rem][mi];
	
	ll res = dfs(rem, mi + 1);
	
	ll p = 1;
	FOR(i, 1, d + 1) {
		if (rem < mi * i) break;
		
		p = p * nCr(rem - mi * (i - 1), mi) % MOD;
		
		if (i >= c) res += p * dfs(rem - mi * i, mi + 1) % MOD * inv[i] % MOD;
	}
		
	return dp[rem][mi] = res % MOD;
}

int main() {
	cin >> n >> a >> b >> c >> d;
	fact_inv(n, MOD);
	
	fill(dp[0], dp[n + 1], -1);
	cout << dfs(n, a) << endl;
	
	return 0;
}

Measured memory_bytes: 8192
#! //Users/daigofujiwara/anaconda3/bin python3

#h行で列和がyかy+1であるかどうかとサンプルを出力

input1=input()
input2=input()

N=int(input1)
S=input2

count=0
for i in range(2,N):
    if S[i-2]=="A" and S[i-1]=="B" and S[i]=="C":
        count+=1
print(count)

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
int main()
{
    unsigned long long int n, p;
    scanf("%lld %lld", &n, &p);
    unsigned long long int ans = 1;
    long long int i = 2;
    long long int k;
    k = 0;
    while (p%i == 0)
    {
        k++;
        p /= i;
    }
    if (k >= n)
        ans *= powl(i, (k / n));
    i++;
    while (sqrt(p) >= i)
    {
        while (p%i > 0 && sqrt(p) >= i)
            i += 2;
        k = 0;
        while (p%i == 0)
        {
            k++;
            p /= i;
        }
        if (k >= n)
            ans *= powl(i, (k / n));
    }
    if (p != 1 && n == 1)
        ans *= p;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_DEF(bool, scan, int &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

int main() {
	[] {
		vector<int> v{0, 0};
		for (;;) {
			vector<int> t{0};
			for (;;) {
				int d;
				char c;
				if (scanf("%d%c", &d, &c) == EOF) {
					outl(v[1]);
					return;
				}
				t.push_back(d);
				if (c == '\n')
					break;
			}
			t.push_back(0);
			int u = t.size() < v.size() ? 1 : -1;
			for (int i: range(1, t.size() - 1))
				t[i] = max(v[i] + t[i], v[i + u] + t[i]);
			v = t;
		}
	}();
}


Measured memory_bytes: 2652
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s, t;
	getline(cin, s);
	getline(cin, t);
	int m = s.size(), n = t.size();
	// vector<vector<string>> dp(m + 1, vector<string>(n + 1));
	vector<vector<int>> dp(m + 1, vector<int>(n + 1));

	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			if (s[i - 1] == t[j - 1]) {
				dp[i][j] = 1 + dp[i - 1][j - 1];
			}
			else {
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}

	int i = m, j = n;
	string result;
	while (i > 0 && j > 0) {
		if (s[i - 1] == t[j - 1]) {
			result += s[i - 1];
			i--; j--;
		}
		else {
			if (dp[i - 1][j] > dp[i][j - 1]) {
				i--;
			}
			else {
				j--;
			}
		}
	}
	reverse(result.begin(), result.end());
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 38552
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 1000 * 1000 + 47;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int x, y;
	cin >> x >> y;
	int res;
	if ((x >= 0 && y >= 0) || (x <= 0 && y <= 0))
	{
		res = abs(y - x);
		//cout << "!!" << res << endl;
		if (x > y)
		{
			res++;
			if (y != 0 && x != 0) res++;
		}

		cout << res << endl;
		return 0;
	}

	res = abs(x + y) + 1;

	cout << res << endl;
}


Measured memory_bytes: 256
n = int(input())

mod = 10 ** 9 + 7

if n == 3:
    print(61)
else:

    from collections import defaultdict
    from itertools import product
    keys = []
    for prod in product('AGCT', 'AGCT', 'AGCT', 'AGCT'):
        last = ''.join(prod)
        f = ('AGC' not in last)

        for i in range(len(last) - 1):
            last2 = list(last)
            last2[i], last2[i+1] = last2[i+1], last2[i]
            last2 = ''.join(last2)
            if 'AGC' in last2:
                f = False

        if f:
            keys.append(''.join(last))

    dp = dict()
    for key in keys:
        dp[key] = 1

    for _ in range(4, n):
        dp_new = defaultdict(int)

        for key in keys:
            for char in 'AGCT':
                last = (key + char)[1:]
                f = ('AGC' not in last)

                for i in range(len(last) - 1):
                    last2 = list(last)
                    last2[i], last2[i+1] = last2[i+1], last2[i]
                    last2 = ''.join(last2)
                    if 'AGC' in last2:
                        f = False

                if f:
                    dp_new[''.join(last)] += dp[key]

        dp = dict()
        for key in keys:
            dp[key] = dp_new[key] % mod

    print(sum(list(dp.values())) % mod)


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

int main() {
  int n,y;
  cin >> n >> y;
  int a=-1, b=-1, c=-1;
  for(int i=0; i<=n; i++) {
  	for(int j=0; j + i<=n; j++) {
      int k = n - i - j;
      int sum = 10000*i + 5000*j + 1000*k;
      if(sum == y) {
      a = i;
      b = j;
      c = k;
      }
    }
  }
  cout << a << " " << b << " " << c << endl;
}

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

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

	int digit = log10(N) + 1;

	vector<string> vvv;
	vector<string> v753;

	vector<int> c = { 3,5,7 };


	for (int n = 3; n <= digit; n++) {
		int nummax = pow(3, n);
		int i = 0;
		while (i < nummax) {
			string str = "";
			int index = i;
			for (int k = 0; k < n; k++) {
				if (index % 3 == 0) str += "3";
				else if (index % 3 == 1) str += "5";
				else str += "7";
				index = index / 3;
			}

			vvv.push_back(str);
			int y = str.find('5');
			if ((int)str.find('3') >= 0 && (int)str.find('5') >= 0 && (int)str.find('7') >= 0 && stoi(str)<=N) {
				v753.push_back(str);
			}
			i++;
		}
	}

	cout << v753.size() << endl;
	return 0;
}


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

#define For(i, x, y) for (int i = x; i <= (int)(y); ++i)
#define Rep(i, x, y) for (int i = y; i >= (int)(x); --i)
#define mem memset
#define pb push_back
#define mp make_pair
#define in inline 

const int maxn = 1e5 + 7;

int n, m;
struct node{
    int l, r;
}a[maxn];
bool cmp(const node &a, const node & b) {
    return a.r < b.r;
}
int main() {
    cin >> n >> m;
    For(i, 1, m) {
        cin >> a[i].l >> a[i].r;
    }
    sort(a + 1, a + m + 1 ,cmp);

    int ans = 0, last = 0;
    For(i, 1, m) {
        if (last >= a[i].l && last < a[i].r) continue;
        last = a[i].r - 1; ++ans;
    }
    cout << ans << endl;
}

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

#define pb push_back
#define F first
#define S second
#define y1 dasdasfasfas
#define x1 wqdadfasfasfas
#define All(c) c.begin(), c.end()
#define SZ(A) (int((A).size()))
#define umap unordered_map
#define __ fflush(stdout)
#define FILENAME ""

typedef long long ll;
typedef long double ld;    

using namespace std;

void FREOPEN() {
	#ifdef LOCAL
		freopen(".in", "r", stdin);
		freopen("1.out", "w", stdout);
	#else
		//freopen(FILENAME".in", "r", stdin);
		//freopen(FILENAME".out", "w", stdout);
	#endif
}

inline double Time() {return (clock() * 1.0) / CLOCKS_PER_SEC; }             

const int N = 200500, inf = 1e9 * 2;

const ll MOD = 1e9 + 7ll, INF = 1e18;

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

int main() {
	FREOPEN();
	int n;
	cin >> n;
	int kek = n % 2;
	kek ^= 1;
	vector<pair<int, int> > ans;
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			if ((i + j == n + kek)) continue;
			ans.pb({i, j});
		}
	}
	printf("%d\n", SZ(ans));
	for (auto i : ans) printf("%d %d\n", i.F, i.S);
	return 0;
}


Measured memory_bytes: 384
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize,
        b: usize,
        t: usize,
    }
    println!("{}", t / a * b);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(void)
{
    float a,b;
	int c1,c2,d1,d2,e1,e2,f1,f2;
	c1=0;
	c2=0;
	d1=0;
	d2=0;
	e1=0;
	e2=0;
	f1=0;
	f2=0;
	while(scanf("%f %f",&a,&b)!=EOF){
		if(a>=1.1){
			c1=c1+1;
		}
		else if(a>=0.6){
			d1=d1+1;
		}
		else if(a>=0.2){
			e1=e1+1;
		}
		else{
			f1=f1+1;
		}
		if(b>=1.1){
			c2=c2+1;
		}
		else if(b>=0.6){
			d2=d2+1;
		}
		else if(b>=0.2){
			e2=e2+1;
		}
		  else{
			f2=f2+1;
		}
	}
	printf("%d %d\n",c1,c2);
	printf("%d %d\n",d1,d2);
	printf("%d %d\n",e1,e2);
	printf("%d %d\n",f1,f2);
	return 0;
}

Measured memory_bytes: 2564
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int N;

	cin >> N;

	if (N < 1200) {
		cout << "ABC" << endl;
	}
	else if (N < 2800) {
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}

	return 0;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll a, b, h, m;
  cin >> a >> b >> h >> m;

  double hr = (360 / 12) * h;
  hr += (360/720.0) * m;
  double mr = (360 / 60) * m;

  double r = fabs(hr-mr);
  if (r > 180) {
    r = 360.0 - r;
  }
  
  double ans = sqrt(double(a*a+b*b)-(double(2*a*b)*cos(r*M_PI/180.0)));
  cout << fixed << setprecision(10);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4232
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>

using namespace std;
typedef long long int ll;

int main(){

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

    if(K == 0){
        cout << N * N << endl;
        return 0;
    }

    ll ans = 0;
    for(ll i = 1; i <= N; i++){
        ll re = i - K;
        if(re < 1) continue;
        //確実に取れるのは倍数分
        ans += (N / i) * re ;
        //あまりがあるときどれくらい取れるか
        if(N % i >= 1 && N % i >= i - re){
           //cout << i << endl;
           ans += N % i - (i - re - 1);
        }
        //cout << re << " " <<  ans << endl;
    }

    cout << ans << endl;
} 

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int S = sc.nextInt();
        int[] A = new int[N];
        int mod = 998244353;
        long[] ruiseki = new long[N+1];
        for (int i=0;i<N;i++) {
            A[i] = sc.nextInt();
            ruiseki[i+1] = ruiseki[i]+A[i];
        }

        long[][][] dp = new long[3][N+1][S+1];
        dp[0][0][0] = 1;
        for (int i=0;i<N;i++) {
            for (int j=0;j<=S;j++) {
                dp[0][i+1][j] = (dp[0][i+1][j]+dp[0][i][j])%mod;
                dp[1][i+1][j] = (dp[1][i+1][j]+dp[1][i][j])%mod;
                dp[2][i+1][j] = (dp[2][i+1][j]+dp[2][i][j])%mod;
                if (j+A[i]<=S) {
                    if (j+A[i]!=S) {
                        dp[1][i+1][j+A[i]] = (dp[1][i+1][j+A[i]]+dp[0][i][j]*(i+1)%mod)%mod;
                    } else {
                        dp[2][i+1][j+A[i]] = (dp[2][i+1][j+A[i]]+dp[0][i][j]*(i+1)*(N-i)%mod)%mod;
                    }
                    if (j+A[i]!=S) {
                        dp[1][i+1][j+A[i]] = (dp[1][i+1][j+A[i]]+dp[1][i][j])%mod;
                    } else {
                        dp[2][i+1][j+A[i]] = (dp[2][i+1][j+A[i]]+dp[1][i][j]*(N-i)%mod)%mod;
                    }
                }
            }
        }
        System.out.println(dp[2][N][S]);
    }
}

Measured memory_bytes: 325884
n, a, b = map(int,input().split(' '))
total = 0
for num in range(1,n+1):
    split_nums = [int(s) for s in list(str(num))]
    sum = 0
    for s in split_nums:
        sum += s
    if a <= sum and sum <= b:
        total += num
print(total)

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

using namespace std;
using ll = long long;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, long long K){
  ll ans = 0;
  for(ll i=1; i<=N; i++) {
    if((2*i)%K==0) {
      // std::cout << i << std::endl;
      // std::cout << ceil((double)(1+i)/(double)K) << std::endl;
      ans+=pow((ll)(max((ll)0, ((N+i)/K)-(ll)ceil((double)(1+i)/(double)K)+(ll)1)), 2);
    }
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  solve(N, K);
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys

s = sys.stdin.readline().rstrip()
if "a" <= s and s <= "z":
    print("a")
else:
    print("A")


Measured memory_bytes: 9012
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;
ll MODP = 998244353;

ll kai(ll x,ll y){
  if(y == 0)return 1;
  if(y == 1)return x;
  if(y&1){
    return (x*kai(x,y-1))%MOD;
  }else{
    ll t = kai(x,y/2);
    return (t*t)%MOD;
  }
}

ll comb(ll a,ll b,vector<ll> &p){
  if(a == 0)return 1;
  if(b == 0)return 1;
  ll ans = p[a+b];
  ans = (ans*kai(p[a],MOD-2))%MOD;
  ans = (ans*kai(p[b],MOD-2))%MOD;
  return ans;
}

ll mind(int x,vector<int> &v){
  int ok = v.size()-1,ng = -1;
  while(ok - ng > 1){
    int next = (ok+ng)/2;
    if(v[next] > x){
      ok = next;
    }else{
      ng = next;
    }
  }
  return ok;
}

ll maxd(int x,vector<int> &v){
  int ok = 0,ng = v.size();
  while(ng - ok > 1){
    int next = (ok+ng)/2;
    if(v[next] < x){
      ok = next;
    }else{
      ng = next;
    }
  }
  return ok;
}

int main(){
  string S;
  cin >> S;
  ll ans = 0;
  rep(i,S.size()){
    ans += (S.at(i) - '0');
  }
  if(ans%9){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }


  return 0;
}


Measured memory_bytes: 3732
s = input()
p = input()
s += s
ans = "No"
for i in range(len(s)//2):
      if s[i] == p[0]:
            for j in range(len(p)):
                  if s[i+j] != p[j]:
                        break
                  if j == len(p)-1:
                        ans = "Yes"
print(ans)


Measured memory_bytes: 5560
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
using namespace std;

typedef long long ll;

const int MOD = (int)(1e+9) + 7;
int N;
int max_A;
ll val_lcm;
vector<int> A;
vector<bool> prime_table;
vector<int>prime;
map<int, int> lcm;

void input_init(void) {
	cin >> N;
	A.resize(N);
	max_A = -1;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		if (A[i] > max_A)
			max_A = A[i];
	}
}

void make_prime_table(void) {
	prime_table.resize(max_A + 1, true);
	prime_table[0] = prime_table[1] = false;
	for (int i = 4; i <= max_A; i += 2) prime_table[i] = false;
	int sqrt_max = (int)sqrt((double)max_A);
	for (int i = 2; i <= sqrt_max; ++i) {
		if (prime_table[i]) {
			for (int j = i * i; j <= max_A; j += i)
				prime_table[j] = false;
		}
	}
	prime.push_back(2);
	for (int i = 3; i <= max_A; i += 2) {
		if (prime_table[i])
			prime.push_back(i);
	}
}

ll mod_pow(ll x, int n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1)
			res = res * x % MOD;
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}

void calcu_lcm(void) {
	for (int i = 0; i < N; ++i) {
		int a = A[i];
		for (int j = 0; j < (int)prime.size(); ++j) {
			if (prime[j] > A[i] / 2) break;
			int cnt = 0;
			while (a % prime[j] == 0) {
				a /= prime[j];
				++cnt;
			}
			if (cnt != 0) {
				if (lcm.count(prime[j]) == 0)
						lcm[prime[j]] = cnt;
				else {
					if (cnt > lcm[prime[j]])
						lcm[prime[j]] = cnt;
				}
			}
		}
		if (prime_table[A[i]]) {
			if (lcm.count(A[i]) == 0)
				lcm[A[i]] = 1;
		}
	}
	val_lcm = 1;
	map<int, int>::iterator itr;
	for (itr = lcm.begin(); itr != lcm.end(); ++itr)
		val_lcm = val_lcm * mod_pow(itr->first, itr->second) % MOD;
}

ll solve(void) {
	ll sum = 0;
	for (int i = 0; i < N; ++i) {
		ll div = (val_lcm * mod_pow(A[i], MOD - 2)) % MOD;
		sum = (sum + div) % MOD;
	}
	return sum;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	input_init();
	make_prime_table();
	calcu_lcm();
	ll ans = solve();
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1144
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=100+10;
int a[maxn][maxn];
int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	for(int i=0;i<h;i++){
		char s[105];
		scanf("%s",s);
		for(int j=0;j<strlen(s);j++)
		   if(s[j]=='#')a[i][j]=1;
		   else a[i][j]=0;
	}
	for(int i=0;i<h;i++){
		bool flag=true;
	    for(int j=0;j<w;j++){
	    	if(a[i][j]==1)flag=false;
		}	
		if(flag)for(int j=0;j<w;j++)
		           a[i][j]=2;
	}
	for(int i=0;i<w;i++){
		bool flag=true;
	    for(int j=0;j<h;j++){
	    	if(a[j][i]==1)flag=false;
		}	
		if(flag)for(int j=0;j<h;j++)
		           a[j][i]=2;
	}
	for(int i=0;i<h;i++){
		bool flag=false;
		 for(int j=0;j<w;j++)
		    if(a[i][j]==1)printf("#"),flag=true;
		    else if(a[i][j]==0)printf("."),flag=true;
		if(flag)printf("\n");    
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long sum = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 3 != 0 && i % 5 != 0) {
				sum += i;
			}
		}
		
		System.out.println(sum);
	}
}


Measured memory_bytes: 27232
#include<bits/stdc++.h>
#define N 100010

using namespace std;

int n,m;
int num[N];

int main(){
	int i,x,y;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d%d",&x,&y);
		num[x]++; num[y]++;
	} 
	for(i=1;i<=n;i++)
	if(num[i]&1){puts("NO"); return 0;}
	puts("YES");
	return 0;
}

Measured memory_bytes: 640
a, b, c, x, y = map(int, input().split())
ans = a *x + b * y
m = max(x, y)
for i in range(m + 1):
    s = 2 * c * i
    s += max(x - i, 0) * a
    s += max(y - i, 0) * b
    if s < ans:
        ans = s
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
bool graph[110][110];
int main()
{
    int n, k;
    cin >> n >> k;
    if(k>n*(n-1)/2-(n-1)){
        cout << -1 << endl;
        return 0;
    }
    for (int i = 1; i < n; i++)
    {
        graph[0][i] = true;
    }
    bool flag = false;
    int l = 0;
    int s = k;
    for (int i = 1; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {  
            if((n-1)*(n-2)/2-k==0){
                flag = true;
                break;
            }
            if(graph[i][j]){
                continue;
            }
           
            graph[i][j] = true;
            k++;
            l++;
            // cerr << i << " " << j << " "<<k<<endl;
        }
        if(flag){
            break;
        }
    }
    cout << n-1+(n-1)*(n-2)/2-s << endl;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if(graph[i][j]){
                cout << i + 1 << " " << j + 1 << endl;
            }
        }
        
    }
    
    

    return 0;
}

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

int main() {
	int n, W;
	while ( cin >> n >> W ) {
		long long max_V[ W+5 ]; memset( max_V, 0, sizeof (max_V) );
		
		for (int i = 0; i < n; ++i) {
			int wi, vi; cin >> wi >> vi;
			
			for (int j = W; j >= wi; --j) {
				max_V[j] = max( max_V[j], max_V[ j-wi ] + vi );
			}
		}
		
		cout << max_V[W] << '\n';
	}
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline void myassert(bool a,string s){ if(!a)cerr<<s<<endl,exit(0);}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=1e5+20;

int n,m;
vector<int>ed[maxn];
int a[maxn],b[maxn];
int fa[maxn],vis[maxn],id[maxn];
ll sum[maxn],mn[maxn];

inline void init()
{
	n=read();m=read();
	REP(i,1,n)
	{
		a[i]=read();b[i]=read();
		a[i]=max(a[i]-b[i],0);
		fa[i]=id[i]=i;
		sum[i]=b[i]; mn[i]=a[i];
	}
	REP(i,1,m)
	{
		int x=read(),y=read();
		ed[x].push_back(y);
		ed[y].push_back(x);
	}
	sort(id+1,id+n+1,[](int x,int y){ return a[x]<a[y];});
}

int fin(int x){ return x==fa[x]?x:fa[x]=fin(fa[x]);}

inline void doing()
{
	REP(i,1,n)
	{
		int x=id[i]; vis[x]=1;
		for(int y:ed[x])
			if(vis[y])
			{
				int u=fin(x),v=fin(y);
				if(u==v)continue;
				fa[v]=u;
				mn[u]=min(max(mn[v]-sum[u],mn[u]),max(a[u]-sum[v],mn[v]));
				sum[u]+=sum[v];
			}
	}
	printf("%lld\n",sum[id[n]]+mn[id[n]]);
}

int main()
{
	init();
	doing();
	return 0;
}


Measured memory_bytes: 9468
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<queue>
#include<climits>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
//#define INF LLONG_MAX / 2;
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;

const ll INF = LLONG_MAX;

#define ARRAY_MAX 100005
#define INF 1e9+7


int main(){

    int h,w;
    cin >> h >> w;
    int cost[10][10];
    vector<int> num(10);
    int mini[10];

    REP(i,10){
        mini[i] = INF;
    }
    mini[1] = 0;/*1は変える必要がない*/
    REP(i,10){
        num[i] = i;
    }
    REP(i,10){
        REP(j,10){
            cin >> cost[i][j];
        }
    }

    do{
        int magic_power = 0;
        if(num[0] == 1){
            continue;
        }

        for(int i = 0;i < 9;i++){
            magic_power += cost[num[i]][num[i+1]];
            if(num[i+1] == 1){
                /*1になったのでもう変える必要がない*/
                break;
            }
        }
        mini[num[0]] = min(mini[num[0]],magic_power);/*num[0]から1に変えるのに必要な最小コストの更新*/

    }while(next_permutation(num.begin(),num.end()));

    int ans = 0,tmp;
    REP(i,h){
        REP(j,w){
            cin >> tmp;
            if(tmp != -1){
                ans += mini[tmp];
            }
        }
    }
    cout << ans << endl;




    return 0;
}

Measured memory_bytes: 384
import java.util.*;
 
class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if ((a * b) % 2 == 0){
      System.out.println("Even");
    }else{
      System.out.println("Odd");
    }
  }
}

Measured memory_bytes: 23764
n = int(input())
a = [int(num) for num in input().split()]
ans = 0.0
a.sort()
for i in range(n - 2):
    ans = max(ans, (a[n - 1] + a[n - 2]) / (a[i + 1] - a[i] + 0.0))
ans = max(ans, (a[n - 1] + a[n - 4]) / (a[n - 2] - a[n - 3] + 0.0))
ans = max(ans, (a[n - 3] + a[n - 4]) / (a[n - 1] - a[n - 2] + 0.0))
print('%.8f' % (ans))

Measured memory_bytes: 7780
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int N;
cin >> N;
vector<int> hei(N);
for (int i = 0;i < N;i++) cin >> hei.at(i);

int maxi = hei.at(0),cnt = 1;
for (int i = 1;i < N;i++) {
    if (hei.at(i) >= maxi) {
        cnt++;
        maxi = hei.at(i);
    }

}
cout << cnt << endl;

return 0;
}


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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> T;
	for (int i = 0; i < 4; i++) {
		if (T[i] == '+') {
			ans++;
		}
		else {
			ans--;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
import sys
from io import StringIO
import unittest

sys.setrecursionlimit(10 ** 7)


def memoize(f):
    cache={}
    def helper(*args):
        if args not in cache:
            cache[args] = f(*args)
        return cache[args]
    return helper


def resolve():
    n = int(input())
    h = list(map(int, input().split()))
    inf = n * 10 ** 7

    """
    ボトムアップ型: for loopを使う
    ans = [inf for _ in range(n)]
    ans[0] = 0
    ans[1] = abs(h[1] - h[0])

    for i in range(2, n):
        ans[i] = min(ans[i], ans[i - 1] + abs(h[i] - h[i - 1]), ans[i - 2] + abs(h[i] - h[i - 2]))

    print(ans[-1])
    """

    # トップダウン(メモ再帰型)
    memo = [inf for _ in range(n)]

    @memoize
    def dp(n: int) -> int:
        if n == 0:
            return 0
        elif n == 1:
            return abs(h[1] - h[0])
        else:
            return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]))

    print(dp(n - 1))

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4
10 30 40 20"""
        output = """30"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """2
10 10"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """6
30 10 60 10 60 50"""
        output = """40"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

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

int main(){
  ll n;
  cin>>n;
  vector<double> v(n);
  rep(i,n){
    cin>>v.at(i);
  }
  sort(v.begin(),v.end());
  int sum=0;
  rep(i,n-1){
    v.at(i+1)=(v.at(i) + v.at(i+1))/2;
  }
  cout << v.at(n-1) << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
	int a,b;
	while(1){
		cin>>a>>b;
		if(a==0 && b==0) break;
		if(a<b) cout<<a<<" "<<b<<endl;
		else cout<<b<<" "<<a<<endl;
	}
	return 0;
}


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

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int n, m;
struct UF {
    vi e;
    UF(int n) : e(n, -1) {}
    bool same_set(int a, int b) { return find(a) == find(b); }
    int size(int x) { return -e[find(x)]; }
    int find(int x) { return e[x] < 0 ? x : e[x] = find(e[x]); }

    void join(int a, int b) {
        a = find(a), b = find(b);
        if(a == b) return;
        if(e[a] > e[b]) swap(a, b);
        e[a] += e[b]; e[b] = a;
    }
};


int main() {
    //cout << fixed << setprecision(15);
    int n = readInt(), m = readInt();

    UF uf(n);
    REP(i, m){
        int X = readInt(), Y = readInt(), Z = readInt();
        X--; Y--;
        uf.join(X, Y);
    }

    map<int, int> mp;
    REP(i, n){
        mp[uf.find(i)]++;
    }

    cout << mp.size() << endl;
    return 0;
}

Measured memory_bytes: 5376
k,t = map(int,input().split())
a_input = list(map(int,input().split()))

#最も多いケーキをAtとする,a=4,b=1,c=1の場合を考えると
#a,b,a,c,a,aのようになる。よってa-(b+c)-1
max_a = max(a_input)
print(max(0,max_a-(k-max_a)-1))

Measured memory_bytes: 2940
#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>
using namespace std;

int main(){
    int n,a,b;
    cin >> n;

    if(n==1){
        cout << "Hello World" << endl;
    }
    else if(n==2){
        cin >> a >> b;
        cout << a+b << endl;
    }

}

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

int main() {
  string s;
  cin >> s;
  int count1=0;
  int count0=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='1'){
      count1++;
    }
    else{
      count0++;
    }
  }
  cout << 2*min(count1,count0);
}

Measured memory_bytes: 512