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

int main() {
  int64_t N;
  string S;
  cin>>N>>S;
  int64_t Q=1000000007,Z=1;
  vector<int> p(26);
  for(int i=0;i<N;i++){
    p.at(S.at(i)-'a')++;
  }
  for(int i=0;i<26;i++){
    Z*=(p.at(i)+1);
    Z=Z%Q;
  }
  Z+=Q-1;
  Z=Z%Q;
  cout<<Z<<endl;
}

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

// 大きな配列はここに書く
long long dp[110][100100] = {0};

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){  
  
  long long N, W;
  cin >> N >> W;

  vector<long long> w(N);
  vector<long long> v(N);
  for(long long i=0; i<N; i++){
    cin >> w[i] >> v[i];
  }

  // dp[i][x] = 0~i-1番の品物の中から，重さがx以下になるように選んだときの最大値
  // long long dp[110][100100] = {0};
  
  // 貰うdp
  // 遷移: 品物iを1つ加えるか判定する
  // 状態(i+1,x) <- (i,x-w[i]) or (i-1,x)
  for(long long i=0; i<N; i++){
    for(long long x=0; x<W+1; x++){
      if(x-w[i] >= 0){
  	dp[i+1][x] = max(dp[i+1][x], dp[i][x-w[i]] + v[i]);
      }
      
      dp[i+1][x] = max(dp[i+1][x], dp[i][x]);

      //cout << dp[i+1][x] << endl;
    }
  }
    
  cout << dp[N][W] << endl;
  
  return 0;
}


Measured memory_bytes: 79360
/*=======================
Author    : Shounak Dey
Filename  : c.cpp
=======================	*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define PB push_back
#define MK make_pair 
#define SZ(a) (int)(sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define read(n) scanf("%d",&n)
#define readl(n) scanf("%lld",&n)
#define readul(n) scanf("%llu",&n);


#define SORTV(a) sort(a.begin(),a.end())
#define TEST int Test;cin >> Test;while(Test--)
#define gcd(a,b) __gcd(a,b)
#define ffs(a) __builtin_ffs(a) // find first set
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)


#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

int main()
{
	fast_io;
	ll n;
	cin >> n;
	priority_queue<double,vector<double>,greater<double>> q;
	REP(i,n){
		double x;
		cin >> x;
		q.push(x);
	}
	ll c=n;
	while(c>1){
		double x,y;
		x = q.top();
		q.pop();
		y = q.top();
		q.pop();
		x = (x+y)/2;
		q.push(x);
		c--;
	}
	cout << setprecision(10) << fixed;
	cout << q.top() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> N >> M >> X;
  ll count=0;
  ll a[N];
  rep(i, M){
    cin >> a[i];
    if (a[i] > X) break;
    count++;
  }
  //cout << count << endl;
  cout << min(count, M-count) << endl;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	int ca = 0;
	int cb = 0;
	REP(i, n) {
		if (s[i] == 'a') {
			if (ca + cb < a + b) {
				put("Yes");
				ca++;
			}
			else {
				put("No");
			}
		}
		else if (s[i] == 'b') {
			if (ca + cb < a + b && cb < b) {
				put("Yes");
				cb++;
			}
			else {
				put("No");
			}
		}
		else {
			put("No");
		}
	}
	return 0;
}



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

using namespace std;

bool check(int n){
  int cc = 0;
  while(n){
    n = n/10;
    cc++;
  }
  return cc%2 == 1;
}

int main(){
  int n;
  cin >> n;
  int cnt = 0;
  for(int i = 1; i <= n; i++)
    if( check(i) )
      cnt ++;
  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
'use strict';
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim();
  var expressions = inputs.split('\n');

  for (var i = 0; i < expressions.length; i++) {
    if (expressions[i] === '0 ? 0') {
      break;
    }
    var expression = expressions[i].split(' ');
    var left = parseFloat(expression[0]);
    var right = parseFloat(expression[2]);
    var op = expression[1];

    if (op === '+') {
      console.log(left + right);
    } else if (op === '-') {
      console.log(left - right);
    } else if (op === '*') {
      console.log(left * right);
    } else if (op === '/') {
      console.log(Math.floor(left / right));
    }
  }

});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15916
#include<stdio.h>
int main(void)
{
    int n,a;
    double ans;

    scanf("%d",&n);
    if(n==1){
        ans=1.0;
        printf("%lf\n",ans);
        return 0;
    }
    if(n%2==0){
        a=n/2;
    }
    else{
        a=n/2;
        a++;
    }
    ans=(double)a/(double)n;
    printf("%lf\n",ans);
    return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>){
    var N = readLine()!!.toList().map{it.toString()}

    var a = mutableMapOf<String, Int>()

    for(i in N){
        if(a.keys.contains(i)){
            a[i] = a[i]?.plus(1) ?: 1
        }else{
            a[i] = 1
        }
    }
    if(a.values.all { it % 2 == 0 }){
        println("Yes")
    }else{
        println("No")
    }
}


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

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

int n,m;
short int dat[5005][5005]={};

int main(void){
	scanf("%d%d",&n,&m);
	rep(i,m){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		dat[a][b] = max(dat[a][b],((short int)(c+1)));
	}
	
	int ans=0;
	reg(p,1,n){
		reg(q,1,p){
			dat[p][q] = max(dat[p][q],((short int)(max(dat[p-1][q],dat[p-1][q-1])-1)));
			if(dat[p][q]>0)ans++;
		}
	}
	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 48772
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

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

void Main(){
    int n; cin >> n;
    vector<P> r(n);
    vll pl(n), mi(n);
    rep(i, n){
        int x, y; cin >> x >> y;
        r[i] = {x, y};
        pl[i] = x + y;
        mi[i] = x - y;
    }
    sort(all(r));
    sort(rall(pl));
    sort(rall(mi));
    ll ans = 0;
    rep(i, n){
        ll a = r[i].fi;
        ll b = r[i].se;
        ans = max(ans, pl[0] - (a+b));
        ans = max(ans, mi[0] - (a-b));
    }
    cout << ans << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  if (N * A > B) {
    cout << B << endl;
  }
  else if (N * A < B) {
    cout << N * A << endl;
  }
  else cout << B << endl;
}

Measured memory_bytes: 256
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/input.txt"
exit $?
'''
import sys


def _i(): return int(sys.stdin.readline().strip())
def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    k = _i()
    a, b = _ia()
    for i in range(a, b+1):
        if i % k ==0:
            return "OK"
    return "NG"

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 61732
#include <iostream>

using namespace std;

int main()
{
  string a;
  cin >> a;
    if(a=="SUN") cout << "7";
    else if(a=="SAT") cout << "1";
    else if(a=="FRI") cout << "2";
    else if(a=="THU") cout << "3";
    else if(a=="WED") cout << "4";
    else if(a=="TUE") cout << "5";
    else if(a=="MON") cout << "6";
  cout << endl;
  return 0;
}


Measured memory_bytes: 3504
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line = reader.readLine();
		String[] str = line.split(" ");
		int r = Integer.parseInt(str[0]);
		int D = Integer.parseInt(str[1]);
		int x = Integer.parseInt(str[2]);
		long ans = x;
		for (int i = 0; i < 10; i++) {
			ans = r * ans - D;
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 20692
# coding: utf-8
# Your code here!
N,K=map(int,input().split())
H=list(map(int,input().split()))

dp=[10**9]*N
dp[0]=0

for i in range(N):
    for k in range(1,K+1):
        if i+k<N:
            dp[i+k]=min(dp[i+k],dp[i]+abs(H[i+k]-H[i]))
    
    
print(dp[-1])


Measured memory_bytes: 52448
import sys
sys.setrecursionlimit(2000)
n = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i,cnt])
    # 上のループを通した後にtempが1じゃなかったら、だけど、nが素数以外にそんなケースある？
    if temp!=1:
        arr.append([temp, 1])
    
    # 素数だったときの処理
    if arr == []:
        arr.append([n,1])

    return arr

factor_dict = {}
for i in range(2,n+1):
    factor_ls = factorization(i)
    for factor in factor_ls:
        if not factor[0] in factor_dict.keys():
            factor_dict[factor[0]] = 0
        factor_dict[factor[0]] += factor[1]
       
num_factor = 1
for num in factor_dict.values():
    num_factor *= num + 1
print(num_factor % (10**9 + 7))

Measured memory_bytes: 3188
r,c = list(map(int,input().split()))
ans = [[0] * (c + 1) for i in range (r + 1)]
for i in range (r):
    s = list(map(int,input().split()))
    for k in range (c):
        ans[i][k] = s[k]
    ans[i][c] = sum(s)
for j in range (c + 1):
    for k in range (r):
        ans[r][j] = ans[r][j] + ans[k][j]
for i in ans:
    k = 0
    for j in i:
        if k == 0:
            k = 1
            print(j,end = "")
        else:
            print(" " + str(j),end = "")
    print()


Measured memory_bytes: 6204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  while(n > 0) {
    n /= k;
    ans++;
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll, int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 100005;

void solve(){
	char c;
	cin >> c;
	if(isupper(c))cout << 'A' << endl;
	else cout << 'a' << endl;
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 3512
#include <bits/stdc++.h>
#define int long long int
#define gif(a,b) (a/b +(a%b?1:0))
#define pi 3.14159265358
#define watch(x) cout<<(#x)<<" is "<<(x)<<"\n";
#define float long double
using namespace std;

int32_t main()
{   
    cin.tie(NULL);
    std::ios::sync_with_stdio(false);
  	int a , b;
  	cin >> a >>b;
  	cout << gif(a,b);
    return 0;
}


Measured memory_bytes: 256
use std::cmp::{max};
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!(
    k: usize,
    n: usize,
    a: [usize; n],
    );
    let len = a.len();
    let mut ans = k - max(a[1] - a[0], k - a[len - 1] + a[0]);
    for i in 1..len {
        let mut tmp = 0;
        if i == len -1 {
            tmp = k - max(k - a[i] + a[0], a[i] - a[i - 1]);
        } else {
            tmp = k - max(a[i + 1] - a[i], a[i] - a[i - 1]);
        }
        if tmp < ans {
            ans = tmp;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
int main()
{
	int s;
	cin>>s;
	ll dp[2010];
	dp[3]=1;
	for(int i=4;i<2010;i++)
	{
		dp[i]=(dp[i-1]+dp[i-3])%mod;
	}
	cout<<dp[s]<<endl;
	return 0;
}

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

int main() {
  int N,L;
  cin>>N>>L;
  string S[N];
  for (int i=0; i<N; i++) {
    cin>>S[i];
  }
  for (int i=0; i<N; i++) {
    for (int j=i+1; j<N; j++) {
      if (S[i]>S[j]) {
        swap(S[i],S[j]);
      }
    }
  }
  for (int i=0; i<N; i++) {
    cout<<S[i]<<flush;
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
n = gets.to_i

m = a = r = c = h = 0
for i in 1..n
  s = gets
  case s[0]
    when "M"
    	m = m + 1
		when "A"
		  a = a + 1
		when "R"
			r = r + 1
		when "C"
			c = c + 1
		when "H"
			h = h + 1
	end
end

sum = m*a*(r+c+h)+(m+a)*r*(c+h)+(m+a+r)*c*h

puts sum


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

ll inv_mod(ll a, ll MOD)
{
    ll b = MOD, u = 1, v = 0;
    while(b){
        ll t = a/b;
        a -= t*b;   swap(a,b);
        u -= t*v;   swap(u,v);
    }
    u %= MOD;
    if(u < 0) u+= MOD;
    return u;
}

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    const ll MOD = 1e9+7;
    vector<ll> a(n);
    ll sum = 0;
    rep(i,n){
        cin >> a.at(i);
        sum += a.at(i);
        sum %= MOD;
    }
    ll ans = 0;
    rep(i,n){
        ans += a.at(i)*sum;
        ans %= MOD;
        ans += MOD - a.at(i)*a.at(i)%MOD;
        ans %= MOD;
    }
    ans *= inv_mod(2ll, MOD);
    cout << ans%MOD << endl;


    return 0;
}

Measured memory_bytes: 4844
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int N;
    cin >> N;
    std::map<string, map<int, int>> city2ScoresMap;
    for (int i = 0; i < N; ++i)
    {
        string Si;
        int Pi;
        cin >> Si >> Pi;
        if (city2ScoresMap.find(Si) != city2ScoresMap.end())
        {
            city2ScoresMap[Si].insert({ Pi, i + 1 });
        }
        else
        {
            city2ScoresMap[Si] = map<int, int>{{ Pi, i + 1 }};
        }
    }
    for (auto &city2Scores : city2ScoresMap)
    {
        const auto scores = city2Scores.second;
        for (auto itr = scores.rbegin(); itr != scores.rend(); ++itr)
        {
            cout << itr->second << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
a = [(i+1) * 2*10**4 for i in range(n)]
b = [(n-i) * 2*10**4 for i in range(n)]
for i in range(n):
    a[p[i]-1] += i
print(" ".join(list(map(str, a))))
print(" ".join(list(map(str, b))))

Measured memory_bytes: 7228
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,x,n) for(int i=x;i<n;++i)
#define ar array
int mod= 998244353;
int32_t main()
{
  int n; cin>>n;
   ar<int,2> a[n];
   f(i,0,n)
   cin>>a[i][0]>>a[i][1];
   sort(a,a+n);
   int dp[n+1];
   f(i,0,n+1)
   dp[i]=-1;dp[n]=1;
   vector<ar<int,2>> v{{n,(int)2e9}};
   for(int i=n-1;i>=0;--i){
      while(v.back()[1]<a[i][0]+a[i][1])
        v.pop_back();
      int p=v.back()[0];
      dp[i]=dp[p];
      int pp=a[i][0];
      v.push_back({i, pp});
      dp[i]+=dp[i+1];
      dp[i]%=mod;
   }   
   cout<<dp[0];
  return 0;
}


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


//ll dp[100001][2];

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

    #ifdef FUNSOCIETY
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif // FUNSOCIETY
    int n;
    cin>>n;
    ll sum = 0, v, c;
    c = 0ll;
    for( int i = 0; i < n; i++)
    {
        cin>>v;
        if ( c != 0 )
        {
            v++;
            sum += v/2ll;
            if ( v == 1ll ) c = 0ll;
            else c = v%2ll;
        }
        else{
            sum += v/2ll;
            c = v%2ll;
        }
        //cout<<sum<<" "<<c<<endl;
    }
    cout<<sum<<"\n";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
using namespace std;

const int MAXN = 100055;

struct DJF {
	DJF() { init(); }
	int ud[MAXN*2];

	void init() { iota(ud, ud+MAXN*2, 0); }
	int uf(int i) { return i == ud[i] ? i : (ud[i] = uf(ud[i])); }
	void uf(int a, int b) { ud[uf(b)] = uf(a); }
} djf;

vector<int> XV, UV;

int A[MAXN], B[MAXN];

int N, Ans;

int getI(int x) { return int(lower_bound(allv(XV), x) - XV.begin()); }

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

	cin >> N;
	for(int i = 1; i <= N; i++) {
		cin >> A[i];
		A[0] ^= A[i];
	}
	for(int i = 1; i <= N; i++) {
		cin >> B[i];
		B[0] ^= B[i];
	}
	{
		vector<int> AV, BV;
		for(int i = 0; i <= N; i++) AV.eb(A[i]);
		for(int i = 0; i <= N; i++) BV.eb(B[i]);
		sorv(AV); sorv(BV);
		if(AV != BV) {
			puts("-1");
			exit(0);
		}
	}
	XV.eb(A[0]); XV.eb(B[0]);
	for(int i = 1; i <= N; i++) if(A[i] != B[i]) {
		XV.eb(A[i]);
		XV.eb(B[i]);
		Ans++;
	}
	sorv(XV); univ(XV);
	for(int i = 1; i <= N; i++) if(A[i] != B[i])
		djf.uf(getI(A[i]), getI(B[i]));
	for(int i = sz(XV); i--;) UV.eb(djf.uf(i));
	sorv(UV); univ(UV);

	cout << Ans + sz(UV) - 1 << endl;
	return 0;
}

Measured memory_bytes: 3568
# B Foods Loved by Everyone

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

likeList = []
for i in range(N):
    myList = list(map(int, input().split()))
    likeList += myList[1:]
    
ans = 0
for i in range(M):
    if likeList.count(i + 1) == N:
        ans += 1
        
print(ans)

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

int main()
{
    _LL n, k;
    cin >> n >> k;
    _LL *a = new _LL[n];
    rep(i, n) cin >> a[i];
    rep(i, n - k)
    {
        if( a[i + k] > a[i] )
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}

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

int main(){
    int n,q;
    string s;
    cin>>n>>q;
    cin>>s;
    vector<int> save;
    for(int i=0;i<n-1;i++){
        if(s[i]=='A' && s[i+1]=='C'){
            save.push_back(i);
        }
    }
    for(int i=0;i<q;i++){
        int l,r;
        cin>>l>>r;
        l--;
        r--;
        int bottom = lower_bound(save.begin(),save.end(),l) - save.begin();
        int top = upper_bound(save.begin(),save.end(), r-1) - save.begin();
        cout<<top-bottom<<endl;

    }
    return 0;
}

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

int main() {
  int k,x;
  cin >> k >> x;
  for(int i = x - k + 1 ;i < k + x;i++){
    cout << i;
    if(i == k + x - 1)cout << endl;
    else cout << " ";
  }
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
#include<cmath>
double a,b,x;
int main()
{
	scanf("%lf%lf%lf",&a,&b,&x);
	double S=x/a;
	if (2*S<=a*b)
	{
		double now=2*S/(b*b);
		double k=atan(now);
		printf("%.10lf",90-k*180/M_PI); 
	}
	else
	{
		double SS=a*b-S;
		b=SS*2/a;
		double now=a/b;
		double k=atan(now);
		printf("%.10lf",90-k*180/M_PI); 
	}
	return 0;
}

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

int main() {
    string s, t;
    cin >> s;
    cin >> t;

    int ans = 0;
    rep(i, 3) {
        if (s.at(i) == t.at(i))
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define INF INT_MAX/3
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define PCC pair<char,char>
#define PIC pair<int,char>
#define Pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define PI 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE() freopen("out0.txt","w",stdout)
#define IN scanf
#define OUT(x) cout<<x<<endl
#define LL long long
#define ll long long
#define ULL unsigned long long
#define EPS 1e-14
#define FST first
#define SEC second

#include<iostream>

using namespace std;
int main()
{
  // 入力
  string a;
  cin >> a;
  
  if (a[0] == a[1]) {
    OUT("1 2");
    return 0;
  }
  FOR(i,2,a.size()) {
    if (a[i-2] == a[i-1] || a[i-2] == a[i] || a[i-1] == a[i]) {
      printf("%d %d\n", i-1 , i+1);
      return 0;
    }
  }
  OUT("-1 -1");
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#define MAX 100000

int parent(int a){
  return a/2;
}

int left(int a){
  return 2*a;
}

int right(int a){
  return 2*a+1;
}

int main(){
  int i,n;
  int heap[MAX];
  scanf("%d",&n);
  for(i=1;i<=n;i++)scanf("%d",&heap[i]);
  
  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,heap[i]);
    if(parent(i)>=1)printf("parent key = %d, ",heap[parent(i)]);
    if(left(i)<=n)printf("left key = %d, ",heap[left(i)]);
    if(right(i)<=n)printf("right key = %d, ",heap[right(i)]);
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2108
x = int(input())
dp = [0] * 100010
dp[100] = 1
dp[101] = 1
dp[102] = 1
dp[103] = 1
dp[104] = 1
dp[105] = 1

for i in range(106, 100010):
    if (
        dp[i - 100]
        or dp[i - 101]
        or dp[i - 102]
        or dp[i - 103]
        or dp[i - 104]
        or dp[i - 105]
    ):
        dp[i] = 1

print(1 if dp[x] else 0)


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

const int maxn = 500010;
int n, a[maxn];
char s[maxn];

int main() {
    scanf("%s", s + 1);
    n = strlen(s + 1);
    for (int i = 1; i <= n; i++) {
        a[i] = s[n - i + 1] - '0';
    }
    int sum = 0;
    auto mul = [&]() {
        int t = 0;
        for (int i = 1; i <= n; i++) {
            t += a[i] * 9;
            a[i] = t % 10, sum += a[i], t /= 10;
        }
        if (t) a[++n] = t, sum += t;
    };
    mul();
    auto inc = [&]() {
        int t = 9;
        for (int i = 1; i <= n; i++) {
            t += a[i], sum -= a[i];
            a[i] = t % 10, sum += a[i], t /= 10;
            if (!t) break;
        }
        if (t) a[++n] = t, sum += t;
    };
    for (int i = 1; ; i++) {
        inc();
        if (!(sum % 9) && i * 9 >= sum) printf("%d\n", i), exit(0);
    }
    return 0;
}

Measured memory_bytes: 6200
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

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

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

template<typename T> void sort(vector<T>& v) {sort(v.begin(), v.end());}

vector<int64_t> dp1, dp2;

int64_t solve(int n, int64_t x) {
  if (x == dp1[n]) return dp2[n];
  if (x == 1) return 0;
  if (x < dp1[n - 1] + 2) return solve(n - 1, x - 1);
  if (x == dp1[n - 1] + 2) return dp2[n - 1] + 1;
  return dp2[n - 1] + solve(n - 1, x - dp1[n - 1] - 2) + 1;
}

int main() {
  int64_t n, x;
  cin >> n >> x;
  dp1.resize(n + 1, 1);
  dp2.resize(n + 1, 1);
  for (int i = 1; i <= n; ++i) dp1[i] = 2 * dp1[i - 1] + 3;
  for (int i = 1; i <= n; ++i) dp2[i] = 2 * dp2[i - 1] + 1;
  cout << solve(n, x) << endl;
}



Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

typedef long long ll;

ll n, m;
vector<ll> ve[100005];
bool v[100005];
bool vv[100005];
bool vvv[100005];

void f(ll p, ll q)
{
    v[p] = true;
    for(ll i = 0; i < ve[p].size(); i++)
    {
        if(ve[p][i] == q) continue;
        if(vvv[ve[p][i]]) continue;
        if(v[ve[p][i]])
        {
            cout<<p<<' '<<ve[p][i]<<endl;
            vv[p] ^= 1;
        }
        else
        {
            f(ve[p][i], p);
            if(vv[ve[p][i]]) cout<<ve[p][i]<<' '<<p<<endl;
            else cout<<p<<' '<<ve[p][i]<<endl;
            vv[p] ^= !vv[ve[p][i]];
            vv[ve[p][i]] = false;
        }
    }
    vvv[p] = true;
}

int main()
{
    scanf("%lld%lld", &n, &m);
    if(m % 2 == 1)
    {
        cout<<-1<<endl;
        return 0;
    }
    for(ll i = 0; i < m; i++)
    {
        ll t1, t2;
        scanf("%lld%lld", &t1, &t2);
        ve[t1].push_back(t2), ve[t2].push_back(t1);
    }
    f(1, 0);
    return 0;
}


Measured memory_bytes: 16512
import java.awt.geom.*;
import java.util.*;
public class Main {
	//1442 start
	
	double EPS = 1.0e-08;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int x1 = sc.nextInt();
			int y1 = sc.nextInt();
			int x2 = sc.nextInt();
			int y2 = sc.nextInt();
			if((x1|y1|x2|y2) == 0) break;
			Line2D [] list = new Line2D[3];
			list[0] = new Line2D.Double(x1, y1, x2, y2);
			for(int i= 1; i < 3; i++){
				int xx1 = sc.nextInt();
				int yy1 = sc.nextInt();
				int xx2 = sc.nextInt();
				int yy2 = sc.nextInt();
				list[i] = new Line2D.Double(xx1, yy1, xx2, yy2);
			}
			
			boolean isOK = true;
			Point2D [] plist = new Point2D[3];
			for(int i = 0; i < 3; i++){
				if(list[i].intersectsLine(list[(i+1) % 3])){
					Point2D v1 = sub(list[i]);
					Point2D v2 = sub(list[(i+1) % 3]);
					if(Math.abs(cross(v1, v2)) < EPS){
						isOK = false;
						break;
					}
					else{
						plist[i] = intersectPtSS(list[i], list[(i+1) % 3]);
					}
				}
				else{
					isOK = false;
					break;
				}
			}
			if(isOK && plist[0].distance(plist[1]) < EPS && plist[0].distance(plist[2]) < EPS) isOK = false;
			if(isOK){
				double res = area(plist);
				if(res < 100000){
					System.out.println("syo-kichi");
				}
				else if(res < 1000000){
					System.out.println("kichi");
				}
				else if(res < 1900000){
					System.out.println("chu-kichi");
				}
				else{
					System.out.println("dai-kichi");
				}
			}
			else{
				System.out.println("kyo");
			}
		}
	}

	private double area(Point2D[] plist) {
		double res = 0;
		for(int i = 0; i < plist.length; i++){
			res += cross(plist[i], plist[(i + 1) % plist.length]);
		}
		return Math.abs(res / 2);
	}

	private Point2D intersectPtSS(Line2D l, Line2D m) {
		Point2D lv = sub(l.getP2(), l.getP1());
		Point2D mv = sub(m.getP2(), m.getP1());
		Point2D mlv = sub(m.getP1(), l.getP1());
		double a = cross(mlv, lv);
		double b = cross(lv, mv);
		if(Math.abs(a) < EPS && Math.abs(b) < EPS){
			if(l.getP1().distance(m.getP1()) < EPS) return l.getP1();
			if(l.getP1().distance(m.getP2()) < EPS) return l.getP1();
			return l.getP2();
		}
		double t = a / b;
		double x = m.getX1() + t * mv.getX();
		double y = m.getY1() + t * mv.getY();
		
		return new Point2D.Double(x, y);
	}

	private Point2D sub(Point2D p1, Point2D p2) {
		double x = p1.getX() - p2.getX();
		double y = p1.getY() - p2.getY(); 
		return new Point2D.Double(x, y);
	}

	private double cross(Point2D p1, Point2D p2) {
		double res = p1.getX() * p2.getY() - p1.getY() * p2.getX();
		return res;
	}

	private Point2D sub(Line2D l) {
		double x = l.getX1() - l.getX2();
		double y = l.getY1() - l.getY2();
		return new Point2D.Double(x,y);
	}

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

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
int aa[10000];
string s;
double a,b,c;
signed main()
{
	cin>>a>>b;
	printf("%.4f",a/b);
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int t,a;
int h[2000];
double clo=10000000;
int ind=0;
void init()
{
    cin>>n>>t>>a;
    for (int i=1; i<=n; ++i)
    {
        cin>>h[i];
        if (abs(a-(t-h[i]*0.006))<clo)
        {
            clo=abs(a-(t-h[i]*0.006));
            ind=i;
        }
    }
    cout<<ind<<endl;
}
void work()
{


}

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




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int h[N];
int main()
{
	int n,k;
	long long ans=0;
	cin>>n>>k;
	for(int i=0;i<n;++i)
		cin>>h[i];
	sort(h,h+n);
	for(int i=0;i<n-k;++i)
		ans+=h[i];
	cout<<ans<<"\n";
	return 0;
} 

Measured memory_bytes: 4412
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        WriteLine(New String() {"No", "Yes"}(B2I(N Mod S(N) = 0)))
    End Sub

    Function S(n As Integer) As Integer
        Dim result As Integer
        Do While n <> 0
            result += n Mod 10
            n \= 10
        Loop
        Return result
    End Function

    Function B2I(ok As Boolean) As Integer
        If ok Then Return 1
        Return 0
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


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

using namespace std;
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; }

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 30;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)

int x, a;

int main(void){
	cin>>x>>a;

	if (x < a) cout<< 0 <<endl;
	else cout<< 10 <<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const int INF = INT_MAX / 2;

class Edge
{
public:
    int to, cost, risk;
    Edge(int to0, int cost0, int risk0){
        to = to0;
        cost = cost0;
        risk = risk0;
    }
};

int main()
{
    for(;;){
        int n, m, l;
        cin >> n >> m >> l;
        if(n == 0)
            return 0;

        vector<vector<Edge> > edges(n+1);
        for(int i=0; i<m; ++i){
            int a, b, d, e;
            cin >> a >> b >> d >> e;
            edges[a].push_back(Edge(b, d, e));
            edges[b].push_back(Edge(a, d, e));
        }

        vector<vector<int> > dp(n+1, vector<int>(l+1, INF));
        dp[1][l] = 0;
        multimap<int, pair<int, int> > mm;
        mm.insert(make_pair(0, make_pair(1, l)));

        for(;;){
            int curr = mm.begin()->second.first;
            int money = mm.begin()->second.second;
            int risk = mm.begin()->first;
            mm.erase(mm.begin());
            if(dp[curr][money] < risk)
                continue;
            if(curr == n){
                cout << risk << endl;
                break;
            }

            for(unsigned i=0; i<edges[curr].size(); ++i){
                int next = edges[curr][i].to;

                int risk2 = risk + edges[curr][i].risk;
                if(risk2 < dp[next][money]){
                    dp[next][money] = risk2;
                    mm.insert(make_pair(risk2, make_pair(next, money)));
                }

                int money2 = money - edges[curr][i].cost;
                if(money2 >= 0 && risk < dp[next][money2]){
                    dp[next][money2] = risk;
                    mm.insert(make_pair(risk, make_pair(next, money2)));
                }
            }
        }
    }
}

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

using namespace std;

int main()
{
    int n;
    long long int a[200010];
    long long int ans = 1LL << 60;

    cin >> n;

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

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

    for (int i = 0; i < n-1; i++) {
        if (ans > abs((a[n-1]-a[i])-a[i])) {
            ans = abs((a[n-1]-a[i])-a[i]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let s: String = read();
  if s.contains('9') {
    println!("Yes");
  } else {
    println!("No");
  }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <vector>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

int main(){
  int A, B;
  cin >> A >> B;
  
  if((A+B)%2==0) cout << (A+B)/2 << endl;
  else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);

    double total = 0;
    for (int i = 0; i < N; i++)
    {
        /* code */
        cin >> A[i];

        total += (double)1 / (double)A[i];
    }
    double ans = (double)1 / total;
    cout << ans << endl;
    


}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,s;

int main(){
  ll ans=0;
  cin >> n >> k>>s;


  if ((n-k+1)<=s){
    vi a(n-k+1,1);
    a[0]=s-(n-k);
    REP(i,n){
      cout<<a[i%(n-k+1)]<<" ";
      cout<<endl;
    }
    return 0;
  }else{
    REP(i,k){
      cout<<s<<" ";
    }
    if (s!=1000000000){
      REP(i,n-k){
        cout<<1000000000<<" ";
      }
    }else{
      REP(i,n-k){
        cout<<1<<" ";
      }
    }
    return 0;
  }


  return 0;
}

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

int main(){
   int a,b,c;
   string s;
   cin >> a >> b >> c;
   if (a+b == 2*a) cout << c<< endl;
   else if (a+c == a*2) cout << b << endl;
   else if (b+c == c*2) cout << a << endl;
   
   
   return 0;
   
}



Measured memory_bytes: 256
//Heaplax
#include<bits/stdc++.h>
#define bit(x) __builtin_popcount((x))
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
const int mod=1000000007;
bool gg[1<<15];
int n,m,ans,f[1<<15],edge[15];
int main()
{
	re(n),re(m);
	ans=1;
	for(int i=1;i<=m;++i)
		ans=ans*2%mod;
	for(int i=1,u,v;i<=m;++i)
	{
		re(u),re(v);
		--u,--v;
		edge[u]|=1<<v;
	}
	for(int i=0;i<(1<<n);++i)
		if((i&1)^(i>>1&1))
			gg[i]=1;
	for(int i=0;i<(1<<n);++i)if(!gg[i])
	{
		f[i]=1;
		for(int j=(i-1)&i;j;j=(j-1)&i)if(!gg[j])
		{
			int k=i^j;
			int base=f[j];
			for(int x=0;x<n;++x)if(j>>x&1)
				base=1ll*base*((1<<bit(edge[x]&k))-1)%mod;
			for(int x=0;x<n;++x)if(k>>x&1)
				base=1ll*base*(1<<bit(edge[x]&j))%mod;
			f[i]=(f[i]+base)%mod;
		}
	}
	ans=(ans-f[(1<<n)-1]+mod)%mod;
	printf("%d\n",ans);
}


Measured memory_bytes: 384
function Main(input) {
    input = input.split(" ");
    var a = Number(input[0]);
    var b = Number(input[1]);
    var k = Number(input[2]);
    
    a -= k;
    if(a < 0){
        b += a;
        a = 0;
    }
    if(b < 0){
        b = 0;
    }
    
    console.log("%d %d",a,b);
}

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

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
int aa[1000];
int main()
{
	long long a,b,c;
	cin>>a>>b>>c;
	if(a%2==0||b%2==0||c%2==0){
		cout<<0;
	}else{
		cout<<min({a*b,b*c,c*a});
	}
}

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

int main(){
    string s;
    cin >> s;
    s[5] = ' ';
    s[13] = ' ';
    cout << s << endl;
    return 0;
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main(){
    string a, b;
    cin >> a >> b;
    char ans[200];
    rep(i,a.length()) ans[i*2]   = a[i];
    rep(i,b.length()) ans[i*2+1] = b[i];
    ans[a.length()+b.length()] = '\0';
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  double ans = 0;
  double temp;
  for(int i = 0; i < n; ++i){
    cin >> temp;
    ans += 1 / temp;
  }
  ans = 1 / ans;
  printf("%f\n", ans);
}

Measured memory_bytes: 256
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define allof(a) (a).begin(), (a).end()
using lint = long long;
template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }
template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }
int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//
int main() {
	int N;
	cin >> N;
	Vec< string > S(N);
	Vec< int > P(N);
	for_(i,0,N) cin >> S[i] >> P[i];
	Vec< int > id(N);
	iota(allof(id), 0);
	sort(allof(id), [&](int i, int j) {
		if (S[i] < S[j]) return true;
		return S[i] > S[j] ? false : P[i] > P[j];
	});
	for_(i,0,N) cout << id[i] + 1 << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 256
K,A,B = map(int,input().split())
bisc = 1
money = 0

if B-A < 3:
  print(bisc + K)
else:
  bisc += A-1
  K -= A-1
  if K >= 2:
    change_n = int(K/2)
    bisc += change_n*(B-A)
    K -= change_n*2
  bisc += K
  print(bisc)
    
    

Measured memory_bytes: 3060