akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define IO {ios_base::sync_with_stdio(false); cin.tie(0);}
#define ll  long long
#define pi pair<ll,ll>
ll vs[2000], a[2000], b[2000], c[30000];

string s;
int main()
{
    IO;
    ll i, j, k, cnt=0, n, m, mod=1e9, t, mx=0, mn=INT_MAX, l, h, r=0, w=0, ovr=0;
    // cin>>t;
        //while(t--){
            cin>>n;
            for(i=1; i<=n; i++) cin>>a[i];

            for(i=1; i<=n-2; i++)
            for(j=i+1; j<n; j++){
                for(k=j+1; k<=n; k++){
                    if(a[i]!=a[j]&&a[j]!=a[k]&&a[k]!=a[i]){
                        mx=max(a[i],max(a[j],a[k]));
                        if(mx<a[i]+a[j]+a[k]-mx) cnt++;
                    }
                }
            }
        cout<<cnt<<endl;
        //}
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef unsigned long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	ll n;
	cin>>n;
	char s[16]={};
	int c=0;
	while(true){
		if(n%26!=0){
			s[c]='a'+(n%26)-1;
		}else{
			s[c]='z';
		}
		if(n==26){
			n=0;
		}else{
			n=(n+25)/26-1;
		}
		++c;
		if(n==0){
			for(int i=c-1;i>=0;--i){
				cout<<s[i];
			}
			return 0;
		}
	}
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int a,b;
    cin >> a >> b;
    int ans = -1;
    for(int i=0; i<=10000;i++){
        if((int)(i*0.08)==a && (int)(i*0.10)==b) {
            ans = i;
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

struct Data
{
    std::string city;
    int score, id;

    Data(std::string city = "", int score = 0, int id = 0) : city(city), score(score), id(id) {}
};

int cmp(const Data& x, const Data& y)
{
    if (x.city < y.city)
        return 1;
    else if (x.city > y.city)
        return 0;
    else
        return x.score > y.score;
}

int a, p;

int main()
{
    std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);
    std::cin >> a >> p;
    a = a * 3 + p;
    std::cout << a / 2 << std::endl;
    return 0;
}

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

#define i64 long long int
#define ran 101101

int n, q;
int cnt[ran];

int main() {
	i64 s = 0LL;
	
	scanf("%d", &n);
	for(int i=0;i<n;i++) {
		int x;
		scanf("%d", &x);
		
		s += x;
		cnt[x] ++;
	}
	scanf("%d", &q);
	for(int i=0;i<q;i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		if(a!=b) {
			cnt[b] += cnt[a];
			s += 1LL * cnt[a] * (b-a);
			cnt[a] = 0;
		}
		printf("%lld\n", s);
	}
	
	return 0;
}

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

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll d = a + b;
    ll e = n / d;
    ll f = n % d;
    if(f > a)
        cout << a * e + a << endl;
    else
        cout << a * e + f << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[][] a = new int[2][n];
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < n; j++) {
                a[i][j] = scanner.nextInt();
            }
        }
        int msxSum=0;
        for(int i=0;i<n;i++){
            int total=0;
            for(int j=0;j<=i;j++){
                total+=a[0][j];
            }
            for(int k=i;k<n;k++){
                total+=a[1][k];
            }
            if(msxSum<=total){
                msxSum=total;
            }
        }
        System.out.println(msxSum);
    }
}


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

int main() {

	int N;
	long long D;
	cin >> N >> D;

	int ans = 0;
	for (int i = 0; i < N; i++) {
		long long X, Y;
		cin >> X >> Y;
		if (X * X + Y * Y <= D * D) ans++;
	}

	cout << ans << endl;

	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

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

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

using ti3 = tuple<ll,ll,ll>;
set<ti3> s;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,n,x,y,z;
  cin >> a >> b >> c >> n;
  ll ans = a * b * 2 + b * c * 2 + c * a * 2;
  rep(i,n){
    cin >> x >> y >> z;
    ti3 t(x,y,z);
    int cnt = 0;
    if((x == 0 || x == a - 1) || (y == 0 || y == b - 1) || (z == 0 || z == c - 1)){
      bool f[6] = {};
      if(x == 0){
        ++cnt;
      }
      else{
        if(s.find(make_tuple(x-1,y,z)) != s.end())++cnt;
      }
      if (x == a - 1){
        ++cnt;
      }
      else{
        if(s.find(make_tuple(x+1,y,z))!= s.end())++cnt;
      }
      if(y == 0){
        ++cnt;
      }
      else{
        if(s.find(make_tuple(x,y-1,z))!= s.end())++cnt;
      }
      if (y == b - 1){
        ++cnt;
      }
      else
        if(s.find(make_tuple(x,y+1,z))!= s.end())++cnt;
      if(z == 0){
        ++cnt;
      }
      else
        if(s.find(make_tuple(x,y,z-1))!= s.end())++cnt;
      if (z == c - 1){
        ++cnt;
      }
      else
        if(s.find(make_tuple(x,y,z+1))!= s.end())++cnt;
    }
    else{
      if(s.find(make_tuple(x-1,y,z))!= s.end())++cnt;
      if(s.find(make_tuple(x+1,y,z))!= s.end())++cnt;
      if(s.find(make_tuple(x,y-1,z))!= s.end())++cnt;
      if(s.find(make_tuple(x,y+1,z))!= s.end())++cnt;
      if(s.find(make_tuple(x,y,z-1))!= s.end())++cnt;
      if(s.find(make_tuple(x,y,z+1))!= s.end())++cnt;
    }
    if(cnt == 0) ans += 6;
    if(cnt == 1) ans += 4;
    if(cnt == 2) ans += 2;
    if(cnt == 3) ans += 0;
    if(cnt == 4) ans += -2;
    if(cnt == 5) ans += -4;
    if(cnt == 6) ans += -6;
    s.insert(t);
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 3280
n = gets.to_i
arr = gets.split.map(&:to_i)
puts arr.join(' ')
(1...arr.length).each do |i|
  key = arr[i]
  j = i - 1
  while j >= 0 and arr[j] > key do
    arr[j+1] = arr[j]
    j -= 1
  end
  arr[j+1] = key
  puts arr.join(' ')
end

Measured memory_bytes: 6108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

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


int main(){
    ll x, y;
    cin >> x >> y;
    if(abs(x-y)<=1) cout << "Brown" << endl;
    else cout << "Alice" << endl;
}

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

const int MAXN = 100005;

struct point {
	int x, y, id;
} a[MAXN], b[MAXN];

bool vis[MAXN];
int n;

int main()
{
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i].x >> a[i].y;
		a[i].id = i;
		b[i] = a[i];
	}
	sort(a+1, a+n+1, [](const point &a, const point &b) { return a.y < b.y; });
	sort(b+1, b+n+1, [](const point &a, const point &b) { return a.x > b.x; });
	int L = 1, R = 1, cur_pos = 0;
	long long ans = 0;
	auto trans = [&ans](int &x, const point &a) {
		vis[a.id] = 1;
		if (x < a.x) ans += a.x-x, x = a.x;
		else if (x > a.y) ans += x-a.y, x = a.y;
	};
        while (L <= n && R <= n) {
		while (L <= n && vis[a[L].id]) L++;
		if (L <= n) trans(cur_pos, a[L++]);
		while (R <= n && vis[b[R].id]) R++;
		if (R <= n) trans(cur_pos, b[R++]);
	}
	ans += abs(cur_pos);
	long long tot = ans;
	ans = 0, memset(vis, 0, sizeof vis), L = R = 1;
	cur_pos = 0;
	while (L <= n && R <= n) {
		while (R <= n && vis[b[R].id]) R++;
		if (R <= n) trans(cur_pos, b[R++]);
		while (L <= n && vis[a[L].id]) L++;
		if (L <= n) trans(cur_pos, a[L++]);
	}
	ans += abs(cur_pos);
	ans = max(ans, tot);
	cout << ans << endl;
	return 0;
}


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

int main(){
    int n;
   
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    int wa=0;
    rep(i,n-1){
        wa+=a[i];

    }
    if(wa>a[n-1]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  long X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<long> A(X), B(Y), C(Z);
  rep(i, X) cin >> A[i];
  rep(i, Y) cin >> B[i];
  rep(i, Z) cin >> C[i];

  vector<long> foo;
  rep (i, X) rep (j, Z) foo.push_back(A[i] + B[j]);
  sort(foo.rbegin(), foo.rend());

  vector<long> bar;
  long tmp = K < foo.size() ? K : foo.size();
  rep (i, tmp) rep (j, Z) bar.push_back(foo[i] + C[j]);
  sort(bar.rbegin(), bar.rend());

  rep (i, K) cout << bar[i] << endl;

  return 0;
}


Measured memory_bytes: 43368
s=gets.chomp
r = 0
r |= 1<=s[0,2].to_i&&s[0,2].to_i<=12 ? 1 : 0
r |= 1<=s[2,2].to_i&&s[2,2].to_i<=12 ? 2 : 0

case r
  when 0
  puts 'NA'
  when 1
  puts 'MMYY'
  when 2
  puts 'YYMM'
  when 3
  puts 'AMBIGUOUS'
end

Measured memory_bytes: 1788
/*
  AtCoder Beginner Contest 080
  C - Shopping Street

  方針
    すべてで2^10=1024通りであるため、全探索が可能である。

  実装
    1024通りを10重ループで書くのは面倒である。
    そこでビットを使用するとコードがすっきりする。
    今回は固定長ビットなので、bitsetを使用するのも可。
*/

#include<iostream>
#include<limits>
#include<bitset>
#include<vector>
using namespace std;

int N;
int F[100] = {0};
int P[100][11] = {0};

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 10; ++j) {
      int f;
      scanf("%d", &f);
      if (f) F[i] += (1 << j);
    }
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 11; ++j) {
      scanf("%d", &P[i][j]);
    }
  }


  int maxval = numeric_limits<int>::min();
  for (int p = 1; p != (1 << 10); p += 1) { // 全探索
    int val = 0;
    for (int n = 0; n < N; ++n) {
      int f = p & F[n]; // 重複したビット
      
      // 1になっているビットの数を数える
      int cnt = 0;
      for (int b = 1; b != (1 << 10); b <<= 1) {
        if (b & f) cnt += 1;
      }
      
      val += P[n][cnt];
    }

    maxval = max(maxval, val);
  }

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

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

int main(){
    int N,K;
    cin >> N >> K;
    
    for(int i = 0;i < N;i++){
        int a;
        cin >> a;
    }
    
    int ans;
    if((N - 1)%(K - 1) == 0)ans = (N - 1)/(K - 1);
    else ans = (N - 1)/(K - 1) + 1;
    
    cout << ans << endl;
}


Measured memory_bytes: 256
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let q = read::<usize>();
    let s = read::<String>().chars().collect::<Vec<_>>();

    let mut table = vec![0; n];
    table[0] = 0;
    for i in 1..s.len() {
        if s[i - 1] == 'A' && s[i] == 'C' {
            table[i] = table[i - 1] + 1
        } else {
            table[i] = table[i - 1]
        }
    }

    for _ in 0..q {
        let l = read::<usize>() - 1;
        let r = read::<usize>() - 1;
        println!("{}", table[r] - table[l])
    }
}


Measured memory_bytes: 4860
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int Mod = 1e9 + 7;
const int MaxN = 105;
const int MaxClicks = 3500;

int dp_sum[MaxN][MaxClicks];
int dp_count[MaxN][MaxClicks];

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);

  for (int rgt = 0; rgt < MaxClicks; ++rgt) {
    dp_count[0][rgt] = 1;
    dp_sum[0][rgt] = 0;
  }

  int N, K;
  cin >> N >> K;

  for (int len = 1; len <= N; ++len) {
    for (int rgt = 0; rgt < MaxClicks; ++rgt) {
      for (int val = 0; val <= K; ++val) {
        const int num_clicks = val <= len ? (val + rgt) / len : 0;
        if (rgt + num_clicks >= MaxClicks) { break; }

        const int final_val = val + rgt - num_clicks * len;
        dp_count[len][rgt] = (dp_count[len][rgt] + dp_count[len - 1][rgt + num_clicks]) % Mod;
        dp_sum[len][rgt] = (dp_sum[len][rgt] +
            (LL)final_val * dp_count[len - 1][rgt + num_clicks] +
            dp_sum[len - 1][rgt + num_clicks]) % Mod;

      }
      if (rgt < 4)
        debug(len, rgt, dp_count[len][rgt], dp_sum[len][rgt]);
    }
  }

  debug(dp_count[N][0]);
  cout << dp_sum[N][0] << "\n";

  /* int N;
  cin >> N;
  vector<int> data(N);
  iota(ALL(data), 1);
  int steps = 0;

  while (true) {
    bool found = false;
    for (int k = 0; k < N; ++k) {
      if (data[k] == k + 1) {
        data[k] = 0;
        for (int j = 0; j < k; ++j)
          ++data[j];
        ++steps;
        found = true;
        break;
      }
    }

    if (!found) { break; }
  }

  cout << steps << "\n"; */

}


Measured memory_bytes: 5888
// inputに入力データ全体が入る
function Main(input) {
	var input = input.split('\n');
	var answer;

	var boxCount = parseInt( input[0].split(' ')[0] );
	var maxCandies = parseInt( input[0].split(' ')[1] );
	var candies = input[1].split(' ');
	var eatCount = 0;

	candies = candies.map((x) => parseInt(x));

	function eat(indexPair, difference) {
		if (difference <= candies[indexPair[1]]) {
			eatCount += difference;
			candies[indexPair[1]] = candies[indexPair[1]] - difference;
		} else {
			eatCount += difference;
			difference -= candies[indexPair[1]];
			candies[indexPair[1]] = 0;
			candies[indexPair[0]] = candies[indexPair[0]] - difference;
		}
	}

	function getPairSum(indexPair) {
		return candies[indexPair[0]] + candies[indexPair[1]];
	}

	function checkBoxes(candies) {
		var indexPair;

		for (var i = 0; i < (candies.length - 1); i++) {
			var difference;
			indexPair = [i, i+1];
			difference = getPairSum(indexPair) - maxCandies;

			if (difference > 0) {
				eat(indexPair, difference);
			}
		}
	}

	checkBoxes(candies);


	// 出力
	console.log(eatCount);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29708
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	long n,s=0,min=0,max=0,a;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		if(i==0){min=a;max=a;}
		s+=a;
		if(min>a)min=a;
		if(max<a)max=a;
	}
	cout<<min<<" "<<max<<" "<<s<<endl;
    return 0;
}

Measured memory_bytes: 1164
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll N;
ll x[112345];
ll mod = 1000000007;

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

vector<ll> f(ll n) {
	vector<ll> ret(n);
	ll fact = 1;
	rep(i, n) {
		fact *= (i + 1);
		fact %= mod;
	}
	rep(i, n) ret[i] = (fact * modinv(i + 1, mod)) % mod;
	return ret;
}

int main() {

	cin >> N;
	rep(i, N) cin >> x[i];

	auto v = f(N - 1);

	ll ans = 0;
	rep(i, N - 1) {
		ans += (x[N - 1] - x[i]) * v[i] % mod;
		ans %= mod;
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
#mod = 10**9+7 #998244353
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main():
    p = int(ipt())
    a = [int(i) for i in ipt().split()]
    mod = p
    #nCrをmodで割った余りを求める。Nに最大値を入れて使用。
    N = 3000
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル
    def cmb(n,r,mod=p):
        if r<0 or r>n :
            return 0
        r = min(r,n-r)
        return g1[n]*g2[r]*g2[n-r]%mod
    for i in range(2,N+1):
        g1.append((g1[-1]*i)%mod)
        inverse.append((-inverse[mod % i]*(mod//i))%mod)
        g2.append((g2[-1]*inverse[-1])%mod)

    ans = [0]*p
    for i in range(p):
        if a[i]:
            ans[0] += 1
            sgn = -1
            ji = 1
            for j in range(p-1,-1,-1):
                ans[j] += sgn*ji*cmb(p-1,j,p)
                ji *= i
                ji %= p
                ans[j] %= p
                sgn *= -1

    print(" ".join(map(str,ans)))
    return None

if __name__ == '__main__':
    main()


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

int main() {
  string S;
  cin >> S;
  
  for (int i = 1; i < S.size(); i++) {
    if (S[i - 1] == S[i]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  
  cout << "Good" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  char s[10];
  scanf("%s", s);
  if (s[2] == s[3] && s[4] == s[5])
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 128
//To leave a good impact on people I meet and places I go
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FIO  ios_base::sync_with_stdio(0);cin.tie(0)
#define f(i, n) for(int i = 0; i < n; i++)

signed main()
{
	FIO;
	int T;
	T=1;
	while(T--)
	{
		string s;
		cin>>s;
		if(s.compare("RRR")==0) cout<<3<<endl;
		else if(s.compare("SRR") == 0 || s.compare("RRS") == 0) cout<<2<<endl;
		else if(s.compare("SSS")==0) cout<<0<<endl;
		else cout<<1<<endl;
	}
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin());  // 先頭文字削除
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000000;

int main() {
    ll N;
    cin >> N;
    ll c[N];
    rep(i, N) { c[i] = 0; }
    rep(i, N - 1) {
        ll a;
        cin >> a;
        c[a - 1]++;
    }
    rep(i, N) { COUT(c[i]); }
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int N;
    cin >> N;
    int a[N];
    REP(i, N) cin >> a[i];
    ll hash[100005] = {};
    REP(i, N){
        hash[a[i]]++;
        hash[a[i]+1]++;
        hash[a[i]+2]++;
    }
    ll res = 0;
    REP(i, 100005){
        res = max(res, hash[i]);
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
#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 INF (ll)2e9
#define MOD ((ll)1e9+7)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define bit(n) (1LL<<(n))

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

template<class InputIterator>
InputIterator adv(InputIterator x, typename std::iterator_traits<InputIterator>::difference_type n) {
    advance(x, n);
    return x;
}

class mod {
    static ll fact[];
public:

    template<class... A>
    static ll mul(A... args) {
        ll res = 1;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = (res * i) % MOD;
        }
        return res;
    }

    static ll power(ll base, ll exp) {
        if (exp == 0) return 1;
        if (exp & 1) {
            return mul(base, power(base, exp - 1));
        } else {
            ll p = power(base, exp / 2);
            return mul(p, p);
        }
    }

    static ll factorial(int n) {
        if (fact[n] != 0) return fact[n];
        if (n == 0) return 1;
        return fact[n] = mul(n, factorial(n - 1));
    }

    static ll inverse(int n) {
        return power(n, MOD - 2);
    }

    static ll comb(int n, int r) {
        if (r < 0 || r > n) return 0;
        return mul(factorial(n), inverse(factorial(n - r)), inverse(factorial(r)));
    }

    template<class... A>
    static ll div(ll dividend, A... args) {
        ll res = dividend;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = mul(res, inverse(i));
        }
        return res;
    }

    template<class... A>
    static ll add(A... args) {
        ll res = 0;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = (res * i) % MOD;
        }
        return res;
    }

    template<class... A>
    static ll sub(ll l, A... args) {
        ll res = l;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = (res - i + MOD) % MOD;
        }
        return res;
    }
};

ll mod::fact[(int) 1e6 + 1];

int ni() {
    int i;
    cin >> i;
    return i;
}

int main() {
    int N = ni();

    int count[9] = {};
    REP(i, N) {
        int d = ni() / 400;
        if (d > 8) d = 8;
        count[d]++;
    }

    int zero = 0;
    REP(i, 8) {
        if (count[i] == 0) zero++;
    }

    int m = max(1, 8 - zero);
    int M = 8 - zero + count[8];

    cout  << m << " " << M << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n, m = list(map(int, input().split(' ')))

    mid1 = [False]*(n+1)
    mid2 = [False]*(n+1)

    for _ in range(m):
        a, b = list(map(int, input().split(' ')))
        if a == 1:
            mid1[b] = True
        if b == n:
            mid2[a] = True

    for i in range(n+1):
        if mid1[i] and mid2[i]:
            print('POSSIBLE')
            return

    print('IMPOSSIBLE')

if __name__ == '__main__':
    main()


Measured memory_bytes: 6260
list=[]
for i in range(50):
    a=map(int,raw_input().split())
    b="grade"
    if a==[-1,-1,-1]:
        break
    elif a[0]==-1 or a[1]==-1:
        b="F"
    elif a[0]+a[1]>=80:
        b="A"
    elif a[0]+a[1]>=65:
        b="B"
    elif a[0]+a[1]>=50:
        b="C"
    elif a[0]+a[1]>=30:
        b="D"
        if a[2]>=50:
            b="C"
    else:
        b="F"
    list.append(b)
for i in range(len(list)):
    print list[i]


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)

#define DBGP 1
 
#define idp if (DBGP)
#define p2(a, b) idp cout << a << "\t" << b << endl
#define p3(a, b, c) idp cout << a << "\t" << b << "\t" << c << endl

int main(void) {
    li n, y;
    cin >> n >> y;

    rep(m, n + 1) {
        rep(g, n + 1) {
            li amari = y - m * 10000 - g * 5000;
            if (amari % 1000 == 0) {
                li s = amari / 1000;
                if (s == n - m - g && s >= 0) {
                    p3(m, g, s);
                    return 0;
                }
            }
        }
    }
    p3(-1, -1, -1);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int x;
	int a;
	while(~scanf("%d %d",&x,&a)){
		if(x<a){
			printf("0\n");
		}
		if(x>=a){
			printf("10\n");
		}
	}
	
	return 0;
 } 

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

int main() {
    char c;
    cin >> c;
    c++;
   cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, K; string S;
    cin >> N >> K >> S;
  	K--;
    
    if(S.at(K) == 'A') S.at(K) = 'a';
    if(S.at(K) == 'B') S.at(K) = 'b';
    if(S.at(K) == 'C') S.at(K) = 'c';
    
    cout << S << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
using ll = long long;
using plong = pair<ll,ll>;
const long MOD = 1000000007;

int main(){
    ll N;
    cin>>N;
    ll a = N%10;
    if(a==3){
        cout<<"bon"<<endl;
    }else if(a == 0 ||a == 1||a == 6||a == 8){
        cout<<"pon"<<endl;
    }else{
        cout<<"hon"<<endl;
    }



}


Measured memory_bytes: 3624
n = int(input())
a = sorted(list(map(int,input().split())))
cum = [a[0]]
for i in range(1,n):
    cum.append(cum[-1]+a[i])

for i in range(n-2,-1,-1):
    if a[i+1] > cum[i]*2:
        print(n-i-1)
        exit()
print(n)

Measured memory_bytes: 20504
H, W = map(int,input().split())
HW = [input() for _ in range(H)]
#print(HW)
#黒がない行は削除して転置,*で文字列を一文字ずつに分解、joinで再結合
HW = ["".join(hw) for hw in zip(*HW) if hw.count("#") > 0]
#転置した後の黒がない行（元の行列の列に対応する）は削除して転置（元の行列に戻る）
HW = ["".join(hw) for hw in zip(*HW) if hw.count("#") > 0]
print("\n".join(HW))#改行を伴って結合

Measured memory_bytes: 3060
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<list>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;
typedef pair<pll,pll> P;
const ll C=1000;

vector<vector<bool>> e;
ll n,m;
ll ret=0;
vector<ll> color;
vector<ll> count1;



bool dfs(ll w){
    for(int i=0;i<n;i++){
        if(e[w][i]){
            if(color[i]==0){color[i]=color[w]*-1; count1[color[w]*-1+C]++; if(!dfs(i)){return false;}}
            else if(color[i]!=color[w]*-1){
                return false;
            }
        }
    }
    return true;
}

int main(){
    cin>>n>>m;
    e.resize(n,vector<bool>(n,true));
    for(int i=0;i<n;i++){
        e[i][i]=false;
    }
    for(int i=0;i<m;i++){
        ll s,t;
        cin>>s>>t;
        s--; t--;
        e[s][t]=false;
        e[t][s]=false;
    }
    bool j=true;
    color.resize(n,0);
    count1.resize(C+n+100,0);
    for(int i=0;i<n;i++){
        if(color[i]==0){
            ret++;
            color[i]=ret;
            count1[ret+C]++;
            if(!dfs(i)){j=false; break;}
        }
    }
    if(!j){cout<<-1<<endl; return 0;}
    vector<vector<bool>> dp(ret+100,vector<bool>(n+100,false));
    dp[0][0]=true;
    for(int i=1;i<=ret;i++){
        ll a=count1[C-i];
        ll b=count1[C+i];
        for(int t=0;t<=n;t++){
            if(dp[i-1][t]){
                dp[i][t+a]=true;
                dp[i][t+b]=true;
            }
        }
    }
    ll ans=E;
    for(int i=0;i<=n;i++){
        if(dp[ret][i]){
            ll k=i*(i-1)/2;
            ll c=n-i;
            k+=c*(c-1)/2;
            ans=min(ans,k);
        }
    }
    cout<<ans<<endl;
    
    
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int n;
  cin>>n;
  vector<int> p(2*n);
  rep(i,2*n) cin>>p[i];
  sort(all(p));

  double ans = 0;
  rep(i,2*n){
    ans += (2*n-i-1.0)/(2*n-1.0) * p[2*n-1-i];
  }

  printf("%.10f\n", ans);

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<stack>
#include<string>
#include<cstdlib>
using namespace std;

stack <int> st;

int caluclation( string s ){
 int b = st.top();
 st.pop();
 int a = st.top();
 st.pop();

 int c;
 if( s == "+" ){
   c = a+b;
 }
 if( s == "-" ){
   c = a-b;
 }
 if( s == "*" ){
   c = a*b;
 }

 return c;
}

int main(){
 string s;
 while( cin >> s ){
  if( s == "+" || s == "-" || s == "*" ){
    st.push(caluclation(s));
  }else{
    st.push(atoi(s.c_str()));
  }
 }

 cout << st.top() << endl;

 return 0;
}


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

void solve() {
	int n; scanf("%d", &n);
	printf("%d", n*(n+1)/2);
}

int main() {
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())
aaa = list(map(int, input().split()))
M = 0
bbb = [0] * (N + 1)
for i in range(N, 0, -1):
    if (aaa[i-1] + sum(bbb[i::i])) % 2 == 1:
        M += 1
        bbb[i] = 1
print(M)
if M > 0:
    ans = [i for i, b in enumerate(bbb) if b]
    print(*ans)


Measured memory_bytes: 18492
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	string S; cin >> S;
	map<char, int> mp;
	REP(i, S.length()) {
		mp[S[i]] += 1;
	}
	if (
		(mp['S'] > 0 && mp['N'] == 0) ||
		(mp['N'] > 0 && mp['S'] == 0) ||
		(mp['E'] > 0 && mp['W'] == 0) ||
		(mp['W'] > 0 && mp['E'] == 0)
	) {
		cout << "No" << endl;
		return;
	}
	cout << "Yes" << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005
#define MAX 3005

int dp[MAX][MAX];
int G[MAX][MAX]; // 1 is wall.

int getLargestSquare(int H, int W){
    int maxWidth = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            dp[i][j] = (G[i][j] + 1) % 2;
            maxWidth |= dp[i][j];
        }
    }

    for(int i = 1; i < H; i++){
        for(int j = 1; j < W; j++){
            if(G[i][j]){
                dp[i][j] = 0;
            }else{
                dp[i][j] = min(dp[i-1][j-1], min(dp[i-1][j], dp[i][j-1])) + 1;
                maxWidth = max(maxWidth, dp[i][j]);
            }
        }
    }

    return maxWidth * maxWidth; // 面積を返す.
}

int main() {
    int h, w;
    cin >> h >> w;
    rep(i,h)rep(j,w)cin >> G[i][j];

    int ans = getLargestSquare(h, w);
    cout << ans << endl;
    return 0;
}
 
 



Measured memory_bytes: 29568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[100010],b[100010],A[100010],B[100010];
int main() {
	for(int i=0;i<100010;i++){
		a[i]=b[i]=A[i]=B[i]=INF;
	}
	ll l,r,q;
	cin>>l>>r>>q;
	for(int i=0;i<l;i++){
		cin>>a[i];
	}
	for(int i=0;i<r;i++){
		cin>>b[i];
	}
	ll k=0;
	for(int i=0;i<l;i++){
		ll now=a[i];
		while(abs(now-b[k])>abs(now-b[k+1])){
			k++;
		}
		A[i]=abs(now-b[k]);
	}
	k=0;
	for(int i=0;i<r;i++){
		ll now=b[i];
		while(abs(now-a[k])>abs(now-a[k+1])){
			k++;
		}
		B[i]=abs(now-a[k]);
	}
	for(int i=0;i<q;i++){
		ll ans=INF,now;
		cin>>now;
		auto posi = lower_bound(a, a+l, now);
		unsigned int idx = distance(a, posi);		
		ans=min(ans,abs(a[idx]-now)+A[idx]);
		if(idx!=0){
			ans=min(ans,abs(a[idx-1]-now)+A[idx-1]);
		}
		posi = lower_bound(b, b+r, now);
		idx = distance(b, posi);		
		ans=min(ans,abs(b[idx]-now)+B[idx]);
		if(idx!=0){
			ans=min(ans,abs(b[idx-1]-now)+B[idx-1]);
		}		
		cout <<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 4480
#include <iostream>
using namespace std;
int main(){
	int N;
	int k[10000];
	while (true){
		cin >> N;
		if (N == 0){
			break;
		}
		int cnt = 0;
		int cnt0 = 0;
		int total = 0;
		bool flag = 0;
		for (int i = 0; i < N; i++){
			cin >> k[i];
			if (k[i]>=1) cnt++;
			if (k[i]>1) flag = 1;
			if (k[i] == 0) cnt0++;
			total += k[i];
		}
		if (flag) cout << N + 1 - cnt0 << endl;
		else if (total < N + 1-cnt0){
			cout << "NA\n";
		}
		else cout << N + 1-cnt0 << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
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:isize
    }
    
    println!("{}", a(n));
}

fn a(n:isize) -> f32 {
match n {
1 => 1.0,
2 => 0.5,
3 => 0.66666666666666666,
_ => if n%2==1 { ((n as f32)+1.0)/2.0/(n as f32) } else { 0.5 }
}}

Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict

S=sys.stdin.readline().strip()
S=S[::-1]
#Lの先頭の0を入れるのは、何も数を選択しない状態はmod2019がゼロになるの意味
#19行目でx=0の際に、ans+=C[x]で1足されることになるので都合が良い
L=[0] 
val=0
for i,x in enumerate(S):
    val+=pow(10,i,2019)*int(x)
    L.append(val%2019)

C=defaultdict(lambda: 0)    #mod2019の値の出現個数を記録
ans=0
for x in L:
    ans+=C[x]   #自分とmod2019の結果が同じ値となる出現個数をansに足す
    C[x]+=1     #自分のmod2019の値を出現個数に+1カウント
print ans


Measured memory_bytes: 85632
N = int(input())
rate = list(map(int,input().split()))
rate.append(100)
position = 0
flag = 'motanai'
money = 1000
for i in range(N):
  if flag == 'motanai' and rate[i]<rate[i+1]:
    position = money//rate[i]
    money = money%rate[i]
    flag = 'motu'
  elif flag == 'motu' and rate[i]>rate[i+1]:
    money += position*rate[i]
    position = 0
    flag = 'motanai'
  else:
    continue
print(money)

Measured memory_bytes: 9208
#include<stdio.h>
int main()
{
  int A,B,C;
  scanf("%d %d %d",&A,&B,&C);
  if(A==B){
    if(C==B){
      printf("No");
    }
    else{
      printf("Yes");
    }
  }
  else if(C==B){
    if(A==B){
      printf("No");
    }
    else{
      printf("Yes");
    }
  }
  else if(C==A){
    if(A==B){
      printf("No");
    }
    else{
      printf("Yes");
    }
  }
  else{
    printf("No");
  }
  return 0;
}
  
  
  

Measured memory_bytes: 128
#include <cstdio>
const int mo=1000000007;
int f[15][1<<15],dp[1<<15],n,m;
int calc(int x,int y){
	if (!x) return 1;
	long long cnt=1;
	for (int i=0;i<n && cnt;i++)
		if ((x>>i)&1) cnt=cnt*(f[i][y]-1)%mo;
			else if ((y>>i)&1) cnt=cnt*f[i][x]%mo;
	return cnt;
}
int main(){
	scanf("%d%d\n",&n,&m);
	int L=1<<n,ans=1;
	for (int i=0;i<n;i++)
		for (int j=0;j<L;j++) f[i][j]=1;
	for (int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d\n",&x,&y);
		x--;y--;(ans<<=1)%=mo;
		for (int j=0;j<L;j++)
			if ((j>>y)&1) f[x][j]<<=1;
	}
	dp[0]=1;
	for (int i=1;i<L;i++)
		for (int j=i;j;j=(j-1)&i)
			if (!((j>>1^j)&1))
				dp[i]=(dp[i]+1ll*calc(i^j,j)*dp[i^j])%mo;
	printf("%d\n",(ans-dp[L-1]+mo)%mo);
}

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

int main(int argc, char const *argv[]) {
  int n, r;
  vector<int> rs;

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

  int max_diff = -1000000000;
  int min_r = rs[0];
  int prev_r = rs[0];
  for (int i = 1; i < n; i++) {
    max_diff = max(max_diff, rs[i] - min_r);
    min_r = min(min_r, rs[i]);
  }
  cout << max_diff << endl;

  return 0;
}



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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector <int> v(8);
    int noColor = 0;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        if(a < 400){
            v[0]++;
        }
        else if(a < 800){
            v[1]++;
        }
        else if(a < 1200){
            v[2]++;
        }
        else if(a < 1600){
            v[3]++;
        }
        else if(a < 2000){
            v[4]++;
        }
        else if(a < 2400){
            v[5]++;
        }
        else if(a < 2800){
            v[6]++;
        }
        else if(a < 3200){
            v[7]++;
        }
        else{
            noColor++;
        }
    }
    int sum = 0;
    for(int i = 0; i < 8; i++){
        if(v[i] > 0){
            sum++;
        }
    }
    if(sum > 0){
        cout << sum << " ";
    }
    else{
        cout << sum+1 << " ";
    }
    cout << sum + noColor << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
n = len(s)
m = len(t)
start = -1
for i in range(n-m+1):
  success=True
  #print(i)
  for j in range(m):
    #print(s[j+i],t[j])
    if s[j+i] != t[j] and s[j+i] != '?':
      success=False
      break

  if success:
    start=i
res = ''
if start < 0:
  print("UNRESTORABLE")
  exit(0)
for i in range(start):
  if s[i]=='?':
    res += 'a'
  else:
    res += s[i]
for i in range(start,start+m):
  res += t[i-start]
for i in range(start+m,n):
  if s[i]=='?':
    res += 'a'
  else:
    res += s[i]
print(res)

Measured memory_bytes: 3064
n=int(input())
l=list(map(int,input().split()))
m=sorted([a-i for i,a in enumerate(l, start=1)])
b1,b2=m[n//2],m[n//2-1]
print(min(sum([abs(a-b1) for a in m]),sum([abs(a-b2) for a in m])))


Measured memory_bytes: 33480
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int mdist(int x1, int y1, int x2, int y2) {
	return abs(x1 - x2) + abs(y1 - y2);
}
int main() {
	int h, w, d;
	cin >> h >> w >> d;
	VV a(h, V(w));
	vector<P<int>> nums(h * w + 1);
	rep(i, h) rep(j, w) {
		cin >> a[i][j];
		nums[a[i][j]] = make_pair(i, j);
	}
	VL dist(h * w + 1, 0);  // 次元を圧縮できるなら圧縮しよう！
	for (int i = d + 1; i <= h * w; i++) {
		dist[i] = dist[i - d] + mdist(nums[i - d].first, nums[i - d].second, nums[i].first, nums[i].second);
		// dの倍数であるという制約をうまく使うと1次元に圧縮できる
		// 複雑にしてもいいけどバグらせるな
	}
	int q;
	cin >> q;
	rep(qqqqq, q) {
		ll a, b;
		cin >> a >> b;
		cout << dist[b] - dist[a] << endl;
	}
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;
struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1) { }

    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if(x==y)return false;
        if(par[y]<par[x])swap(x,y);
        par[x]+=par[y];par[y]=x;
        return true;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return -par[root(x)];
    }
    int root(int x) {
        return par[x] < 0 ? x : par[x] = root(par[x]);
    }
};

signed main(){
  int n,k,l;
  cin>>n>>k>>l;

  UnionFind car(n);
  UnionFind train(n);

  rep(i,k){
    int p,q;
    cin>>p>>q;
    p--;q--;
    car.unite(p,q);
  }
  rep(i,l){
    int r,s;
    cin>>r>>s;
    r--;s--;
    train.unite(r,s);
  }
  map<pair<int,int>,int> m;
  rep(i,n){
      m[make_pair(car.root(i),train.root(i))]++;
  }
  rep(i,n){
    if(0<i)cout<<' ';
    cout<<m[make_pair(car.root(i),train.root(i))];
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 15104
#include<stdio.h>
int main(void)
{
  int n,i;
  int money=100000;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    money*=1.05;
    if(money%1000!=0)
      money+=1000-money%1000;
  }

  printf("%d\n",money);

  return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int main() {

while(true){
     int n;
     cin >> n;
     vector<int> A(n);
  
  if(n>0){
  for(int i=0;i<n;i++){
  
     cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  int sum=0;
  for(int i=1;i<n-1;i++){
  sum+=A.at(i);
  }
  cout << sum/(n-2) << endl;
  }
 if(n==0){
    break;
   }
}
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

vector<int> primes(int n)
{
	vector<int> p(n, 1);

	iota(p.begin(), p.end(), 0);

	p[0] = p[1] = 0;
	for (int i = 2; i * i < n; ++i) {
		for (int j = i * i; j < n; j += i) {
			p[j] = 0;
		}
	}
	return p;
}

int main()
{
	int X;
	cin >> X;
	
	for (int p : primes(200000)) {
		if (p >= X) {
			cout << p << endl;
			break;
		}
	}
}


Measured memory_bytes: 1024
def run():
  N, M = map(int, input().split())
  land_li = [list(map(int, input().split())) for m in range(M)]
  sorted_li = sorted(land_li, key=lambda x:(x[1], x[0]))
  #print(sorted_li)
  end = sorted_li[0][1]
  num = 1
  for batle_li in sorted_li[1:]:
    if end <= batle_li[0]:
      end = batle_li[1]
      num += 1
  print(num)
  
if __name__ == '__main__':
  run()

Measured memory_bytes: 36272
from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

n, k = inpl()
p = inpl()
p = sorted(p)
ans = 0
for i in range(n):
    ans += p[i]
    if i+1 == k:
        break
print(ans)

Measured memory_bytes: 10024