akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 1e9+7
#define N 2001
#define MAX_V 400010
#define vec vector<int>
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<ll,int,custom_hash>
struct pair_hash
{
    template<class T1,class T2>
    size_t operator() (const pair<T1,T2> &p)const{
        return hash<T1>()(p.first)^hash<T2>()(p.second);
    }
};

int ans;
vec a;
void pr(int n){
    a.pb(n);
    ans++;
    return;
}
main(){
    ll n=lin();
    vector<ll> v;
    v.pb(0);
    v.pb(1);
    rep2(i,2,40){
        v.pb((v[i-1]+1)*2-1);
    }
    sort(ALL(v),greater<ll>());
    int pos=0;
    while(n<v[pos]){
        pos++;
    }
    int mem=40-pos;
    n-=v[pos];
    rep(i,41)v[i]++;
    vec s;
    while(n){
        while(n>=v[pos]){
            s.pb(40-pos);
            n-=v[pos];
        }
        pos++;
    }
    sort(ALL(s));
    cout<<mem*2+s.size()*2<<endl;
    int now=0;
    int temp=1;
    while(temp<=mem){
        while(now<s.size()&&s[now]<temp){
            cout<<mem+1+now<<" ";
            now++;
        }
        cout<<temp<<" ";
        temp++;
    }
    rep2(i,1,mem)cout<<i<<" ";
    rep3(i,mem+s.size(),mem+1)cout<<i<<" ";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define FF first
#define SS second
#define f(a,b,c) for(int a=b;a<=c;a++)
#define fd(a,b,c) for(int a=b;a>=c;a--)
#define fspr(X) fixed<<setprecision(X)

const ll MOD=1e9+7;

//bool visited[1001][1001];
//char graph[1000][1000];
//int ans=0;
//bool path=false;
ll power(ll x, ll y , ll z)       // returns (x^y)%z
{
	ll res=1,num=x;
	while(y>0)
	{
		if(y&1)res=(res*num)%z;
		num=(num*num)%z;
		y=y>>1;
	}
	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll H;cin>>H;
    ll ans=0,ref=1;
    while(H)
    {
    	ans+=ref;
    	ref<<=1;
    	H/=2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N, X, T;
	cin >> N >> X >> T;

	int k = (N + X - 1) / X * T;

	co(k);

	Would you please return 0;
}

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

bool bs(long long int, long long int*, int);
int main(){
  int n; cin >> n;
  long long int s[n];
  for(int i=0; i<n; i++) cin >> s[i];
  int q; cin >> q;
  long long int t[q];
  for(int i=0; i<q; i++) cin >> t[i];

  int count=0;
  for(int i=0; i<q; i++){
    if(bs(t[i], s, n)) count++;
  }

  cout << count << endl;

  return 0;
}

bool bs(long long int s, long long int* array, int size){
  bool ans=false;
  int start=0, end=size-1, min;
  if(s==array[start] || s==array[end]){
    ans = true;
    return ans;
  }
  while(end>start+1){
    min = (start+end)/2; //中央値を持ってくる
    if(array[min]==s){ //中央値が探しているものなら終了
      ans = true;
      break;
    }
    else if(array[min]<s){
      start = min;
    }
    else if(array[min]>s){
      end = min;
    }
  }
  return ans;
}



Measured memory_bytes: 4144
#include<stdio.h>

void swape(int *a,int *b) {
	int temp;
	temp = *a;
	*a = *b;
	*b = temp;
}

int main() {
	int w, n;
	int a, b;
	scanf("%d",&w);
	scanf("%d", &n);
	int vertical[31];
	for (int i = 0;i <= w;i++) {
		vertical[i] = i;
	}

	while (n--) {
		scanf("%d,%d", &a, &b);
		swape(&vertical[a], &vertical[b]);
	}

	for (int j = 1;j <= w;j++) {
		printf("%d\n",vertical[j]);
	}
}

Measured memory_bytes: 1808
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;
            int sum;
            string[] data = Console.ReadLine().Split(' ');
            int n = int.Parse(data[0]);
            int m = int.Parse(data[1]);
            int c = int.Parse(data[2]);
            string[] data2 = Console.ReadLine().Split(' ');
            int[] B = data2.Select(int.Parse).ToArray();
            for (int i = 0; i < n; i++) {
                sum = 0;
                int[] A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                for (int j = 0; j < m; j++)
                {
                    sum += A[j] * B[j];
                }
                sum += c;
                if (sum > 0) {
                    ans++;
                }
            }
            Console.WriteLine(ans);


        }
    }
}

Measured memory_bytes: 28240
#include "bits/stdc++.h"
using namespace std;
int main(){
  int n,h,w,x,y;
  cin >> n >> h >> w;
  x = n-w;
  y = n-h;
  if(x == 0){
    cout << y+1;
  }else{
    cout << (x+1)*(y+1);
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	long x=sc.nextLong();
	long y=sc.nextLong();
	long now=x;
	long fla=0;
	for(long i=1;i<=y;i++){
		fla=i;
		if(y<now){
			System.out.println(i-1);
			break;
		}
		now=now*2;
	}
if(fla==y){
System.out.println(1);
}
	}}

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


using namespace std;

int main() {

	int n;
	cin >> n;
	int co=0,ce=0;
	for (int i = 0; i < n; ++i)
	{
		int a;
		cin >> a;
		if(a%2)
			co++;
		else
			ce++;
	}
	int count = pow(3,n);
	int no=1;
	while(ce--){
		no*=2;
	}
	cout << count-no;
}

Measured memory_bytes: 256
include Math
define_method :max, -> (a,b) { a > b ? a : b }
define_method :min, -> (a,b) { a < b ?  a : b }
define_method :swap, -> (a,b) { a, b = b, a }
define_method :rep, -> (num, &block) { num.times do |i| block.call(i) end }
define_method :repl, -> (st,en, &block) { st.upto en-1 do |i| block.call(i) end }
define_method :array, -> (size,init = nil) { Array.new(size){init} }
define_method :darray, -> (size1, size2, init = nil) { Array.new(size1){Array.new(size2){init}} }
define_method :gi, -> () { gets.split.map(&:to_i) }
define_method :gs, -> () { gets.chomp }
define_method :putall, -> (obj) { obj.each do |o| puts o end }




n = gi[0]
count = 1
sum = 0
ans = n
rep n do |num|
sum += num+1
break if sum >= n
count += 1
end

puts count

Measured memory_bytes: 1788
#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() {
  int x, n;
  cin >> x >> n;

  vector<bool> list(101, false);

  rep(i, n) {
    int p;
    cin >> p;
    list[p] = true;
  }

  int diff = INT_MAX;
  int closest;

  for (int i = 0; i <= 101; i++) {
    if (abs(x - i) < diff && list[i] == false) {
      diff = abs(x - i);
      closest = i;
    }
  }

  cout << closest << endl;

  return 0;
}


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

typedef long long lli;
typedef vector<int> Vi;
typedef vector<lli> Vl;
typedef pair<int, int> Pii;
typedef pair<lli, lli> Pll;


//===


int main()
{
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;

	S[K - 1] = S[K - 1] + 32;
	cout << S << endl;
}

Measured memory_bytes: 256
/** 
 *  Author : Parth Prajapati
 *  Institute : Pandit Deendayal Petroleum University
 *  Problem : Assembly Line Scheduling
 *  Time complexity : O(n)
 *  Space complexity : O(n)
**/
#include<bits/stdc++.h>

using namespace std; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, w, i, j;
    cin>>n>>w;
    vector<int> weight(n), value(n);
    long long total = 0;
    for(i=0;i<n;++i)
    {
        cin>>weight[i]>>value[i];
        total += value[i];
    }
    vector<long long> dp(total+1,INT_MAX);
    dp[0] = 0;
    for(i=0;i<n;++i)
    {
        for(j=total-value[i];j>=0;--j)
        {
            dp[j+value[i]] = min(dp[j+value[i]], dp[j]+weight[i]);
        }
    }
    long long ans = 0;
    for(i=0;i<total+1;++i)
    {
        if(dp[i] <= w)
            ans = max(ans,(long long)i);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+7;
typedef long long ll;
typedef pair<ll,int> pii;
ll a[maxn],b[maxn];
priority_queue<pii> q;
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&b[i]);
		if(a[i]!=b[i]) q.push({b[i],i});
	}
	ll ans=0;
	while(!q.empty())
	{
		pii t=q.top();q.pop();
		ll ib=t.first;int id=t.second;
		//if(ib==a[id]) continue;
		int pre = (id + n - 2) % n + 1, suf = id % n + 1;
		int stp=(ib-a[id])/(b[pre]+b[suf]);
		if(!stp)
		{
			puts("-1");return 0;
		}
		ans+=stp;
		ib-=1ll*stp*(b[pre]+b[suf]);
		b[id]=ib;
		if(a[id]!=ib) q.push({ib,id});
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 8944
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

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

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
 
VI memo;

int f(int n){
	if(n<0)
		return 0;
	if(n==0)
		return 1;
	if ( memo[n]!= -1 )
		return memo[n];
	return f(n-1)+f(n-2)+f(n-3);
}

int main(){
	int n;
	memo.resize(31,-1);
	while(1){
		cin >> n;
		if(n==0)
			break;
		int num=f(n);
		cout <<num/10/365+1<< endl;
	}
	return 0;  
}  

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

int main() {
    string S;
    cin >> S;
    vector<string> week{"SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};

    int ans = 0;
    rep(i, 7) {
        ans++;
        if (S == week[i]) {
            break;
        }
    }

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


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

      int N,M,B,C;
      long long check[1000000];
      pair<long long,int>check2[1000000];
      long long int ans=0;
int main(){
      cin >> N >> M;
      for(int i=0;i<N;i++){
            cin >>check[i];
            ans+=check[i];
      }
      sort(check,check+N);

      for(int j=0;j<M;j++){
            int A,A_N;
            cin >> A >> A_N;
            check2[j]=make_pair(A_N,A);
      }
      sort(check2,check2+M);
      reverse(check2,check2+M);
      for(int k=0;k<N;k++){
            if(B >= M ||check2[B].first <= check[k])break;
            ans+=check2[B].first-check[k];
            C++;
            if(C==check2[B].second){
                  C=0;
                  B++;
            }
      }
      cout << ans;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define P pair<int,int>
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
double ABS(double a, double b) {
	if (a - b < 0) {
		return (double)(- 1) * (a - b);
	} else {
		return a - b;
	}
}
int main() {
	int n;
	cin >> n;
	int a[n];
	int Max = -1;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		Max = max(Max, a[i]);
	}
	double ans = (double)INF;
	double cmp = (double)Max / 2;
	// cout << "cmp:" << cmp << endl;
	cout << Max << " ";
	int ANS;
	for (int i = 0; i < n; i++) {
		ans = min(ans, ABS(cmp, (double)a[i]));
		if (ans == ABS(cmp, (double)a[i])) {
			ANS = a[i];
			//cout << "i:" << i << " ANS:" << ANS  << " ans:" << ans << endl;
		}
	}
	cout << ANS << endl;
	return 0;
}

Measured memory_bytes: 640
import sys,collections as cl,bisect as bs,random
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

d = onem()

c = l()

s = []
sel = [0 for i in range(365)]

day = [[0 for i in range(26)] for j in range(365)]
ans = 0
for i in range(d):
	s.append(l())
	ss = [[s[-1][i],i+1] for i in range(26)]

	ak = 0

	for j in range(26):
		if i != 0:
			ak -= c[j] * (i-day[i-1][j]+1)
		else:
			ak -= c[j]

	ma = [-1,-1]
	for j in range(26):
		if i != 0:
			if ma[0] <= c[j] * (i-day[i-1][j]+1) + s[-1][j]:
				ma[0] = c[j] + (i-day[i-1][j]+1) + s[-1][j]
				ma[1] = j
		else:
			if ma[0] <= c[j] + s[-1][j]:
				ma[0] = c[j] + s[-1][j]
				ma[1] = j
	ans += ma[0] + ak
	sel[i] = ma[1]+1

	for j in range(26):
		if j == ma[1]:
			day[i][j] = i
		else:
			day[i][j] = day[i-1][j] if i - 1 >= 0 else 0



for _ in range(140000):
	ima = random.randrange(365)
	po = [[s[ima][i],i+1] for i in range(26)]
	po.sort(reverse = True)
	while True:
		data = po[random.randrange(12)][1]
		if sel[ima] != data:
			break
	data = data-1
	ppp = 0
	now = sel[ima]-1
	for i in range(ima+1,365):
		if day[i][data] == i:
			ppp += (i - ima) * c[data]
			break
	else:
		ppp += (364-ima) * c[data]
	ppp += s[ima][data]

	for i in range(ima+1,365):
		if day[i][now] == i:
			ppp -= (i - ima) * c[now]
			break
	else:
		ppp -= (364-ima) * c[now]
	ppp -= s[ima][now]
	if ppp > 0:
		for i in range(ima,365):
			if day[i][data] != i:
				day[i][data] = ima
			else:
				break
		po = ima - 1 if ima != 0 else 0
		for i in range(ima,365):
			if i == ima:
				day[i][now] = po
			elif day[i][now] != i:
				day[i][now] = po
			else:
				break
		sel[ima] = data+1
		ans += ppp

for i in sel:
	print(i)


Measured memory_bytes: 83464
#include<bits/stdc++.h>
using namespace std;
const int SZ = 100005;
typedef long long ll;
pair<ll,ll> arr[SZ];
int main(void){
	ll n,m; scanf("%lld %lld",&n,&m);
	for(int i=0;i<(int)n;i++){
		ll x,y; scanf("%lld %lld",&x,&y);
		arr[i]=make_pair(x,y);
	}
	sort(arr,arr+n);
	long long ans = 0LL;
	int p = 0;
	while(m){
		ll buy = min(m,arr[p].second);
		ans += buy*arr[p].first;
		p++;
		m-=buy;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pii pair <int,int>
#define vpii vector< pair<int,int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const ll inf64 = 1e18 + 5;
bool check(ll arr[], ll n, ll m, ll v, ll p, ll mid)
{
	ll cnt = 0, val = arr[mid], i;
	fo(i, 0, n){
		if(arr[i] > val) break;
		cnt++;
	}
	if(n - p <= cnt - 1)
		return true;
	val += m;
	ll g = max(0ll, v - cnt);
	if(g < p && arr[n - p] <= val)
		return true;
	if(arr[n - p] > val)
		return false;
			
	g -= (p - 1);
	ll fin = 0, tot = m * g;
	foe(i, cnt, n - p){
		if(arr[i] < val)
		fin += (val - arr[i]);
	}
	return(fin >= tot);
}
int main()
{
	boost;
	ll n, m, p, v, i;
	cin >> n >> m >> v >> p;
	ll arr[n];
	fo(i, 0, n)
	cin >> arr[i];
	sort(arr, arr + n);
	ll f = 0, l = n - 1, mid;
	ll ans = inf64;
	while(f <= l){
		mid = (f + l) / 2;
		if(check(arr, n, m, v, p, mid)){
			ans = min(ans, arr[mid]);
			l = mid - 1;
		}
		else
		f = mid + 1;
	}
	fo(i, 0, n){
		if(arr[i] == ans){
			cout << n - i;
			return 0;
		}
	}
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

template< typename T >
class CumulativeSum
{
public:
    CumulativeSum() : m_Mod(1000000007) {}
    CumulativeSum(int sz) : m_Data(sz, T(0)), m_Mod(1000000007) {};
    CumulativeSum(int sz, int mod) : m_Data(sz, T(0)), m_Mod(mod) {};

    // k に x を加える O(1)
    void Add(int k, T x) {
        assert(m_Data.size() >= k);
        if(m_Data.size() <= k) { m_Data.push_back(x % MOD); }
        else { m_Data[k] = (m_Data[k] + x + m_Mod) % m_Mod; }
    }

    // 累積和の構築 O(m_Data.size())
    void Build() {
        for(int i = 1; i < m_Data.size(); i++) {
            m_Data[i] = (m_Data[i] + m_Data[i - 1] + m_Mod) % m_Mod;
        }
    }

    // 区間 [0, k] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int k) {
        if(k < 0) { return T(0); }
        return (m_Data[min(k, static_cast<int>(m_Data.size()) - 1)]);
    }

    // 区間 [l, h] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int l, int h) {
        return (this->Query(h) - this->Query(l-1) + m_Mod) % m_Mod;
    }
private:
    vector< T > m_Data;
    int m_Mod;
};

ll N;
ll A[MAX_N];
// ブロック i を取り除くとき、 i と j が連結である確率 P'ij を考える。
// このときの各 j について、 P'11 + P'21 + ... + P'N1 = P[i]
// A[1] が P'11 の確率で 1 回、 P'21 の確率で 1 回 ... P'N1 の確率で 1 回でるので、
// 1 回 N 個のブロックを取り切ったときに、コストとして加算すべき A[i] は期待値的に P[i] 回出ることになる。
ll P[MAX_N];

// 1~nの逆元を求める(mod m)
vector<ll> ListModInverse(ll n, ll m)
{
    vector<ll> inv(n + 1);
    inv[1] = 1;
    for (int i = 2; i <= n; ++i)
        inv[i] = inv[m % i] * (m - m / i) % m;
    return inv;
}

signed main()
{
    cin >> N;
    REP(i, N) { cin >> A[i]; }

    // 逆元の作成
    vector<ll> inv = ListModInverse(N, MOD);

    // 累積和の構築
    CumulativeSum<ll> cs(N+1);
    for(int i = 1; i <= N; ++i) {
        cs.Add(i, inv[i]);
    }
    cs.Build();

    // P の構築
    REP(i, N) {
        int low = i;        // 自分より小さいものの数
        int high = N - low; // 自分以上のものの数
        P[i] = cs.Query(high);
        P[i] %= MOD;
        if(low > 0) {
            P[i] += cs.Query(2, 2 + (low - 1));
            P[i] %= MOD;
        }
    }

    // 1 回 N 個のブロックを取り切ったときのコストの期待値
    ll X = 0;
    REP(i, N) {
        X += ((A[i] * P[i]) % MOD);
        X %= MOD;
    }

    // N! の計算
    ll N_f = 1;
    for(int i = 2; i <= N; ++i) {
        N_f *= i;
        N_f %= MOD;
    }

    ll ans = (X * N_f) % MOD;
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.AtCoder_Begginer_Contest_162
{
    class B
    {
        static void Main(string[] args)
        {
            string input1 = Console.ReadLine();
            long n = long.Parse(input1);

            long n3 = n / 3;
            long n5 = n / 5;
            long n15 = n / 15;
            long sum = (n * (2 * 1 + (n - 1)) / 2) - (n3 * (6 + (n3 - 1) * 3) / 2) - (n5 * (10 + (n5 - 1) * 5) / 2) + (n15 * (30 + (n15 - 1) * 15) / 2);

            Console.WriteLine(sum);
        }
    }
}


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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine();
			int n = s.Length;
			int pc = 0;
			int gc = 0;
			int win = 0;
			int lose = 0;
			for (int i = 0; i < n; i++) {
				if (s[i] == 'p') {
					if (pc < gc) {
						++pc;
					} else {
						++gc;
						++lose;
					}
				} else {
					if (pc < gc) {
						++pc;
						++win;
					} else {
						++gc;
					}
				}
			}

			Console.WriteLine(win - lose);
		}
	}
}


Measured memory_bytes: 11232
// B.

#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n, m, d[200000], t[200000];
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> d[i];
	}
	sort(d, d + n);
	cin >> m;
	for (int i = 0; i < m; ++i) {
		cin >> t[i];
	}
	sort(t, t + m);
	bool ans = true;
	int pos = 0;
	for (int i = 0; i < m; ++i) {
		for (; pos < n && d[pos] < t[i]; ++pos) {
			;
		}
		if (pos >= n || d[pos] > t[i]) {
			ans = false;
			break;
		}
		++pos;
	}
	cout << (ans ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <time.h>

typedef int32_t i32;
typedef int64_t i64;
typedef double f64;

void *const null=(void *)0;
i64 const llinf=4611686018427387903LL;
i64 const mod=1000000009LL;
f64 const pi=3.141592653589793;
f64 const rad=57.295779513082323;

#define CODE_

i32 main(void){
    i64 n,m;
    scanf("%lli%*c%lli%*c",&n,&m);
    i64 *a=(i64 *)calloc(n,sizeof(i64));
    for(i64 i=0LL;i<n;++i) scanf("%lli%*c",&a[i]);
    i64 b;
    i64 *c=(i64 *)calloc(n,sizeof(i64));
    for(i64 i=0LL;i<m;++i){
        scanf("%lli%*c",&b);
        for(i64 j=0LL;j<n;++j){
            if(a[j]<=b){
                ++c[j];
                break;
            }
        }
    }
    i64 maxidx=0LL;
    for(i64 i=1LL;i<n;++i){
        if(c[i]>c[maxidx]) maxidx=i;
    }
    printf("%lli\n",maxidx+1LL);
    return 0;
}



Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <array>
#include <queue>

using namespace std;

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

    const array<int, 4> wasd_y{-1, 0, 1, 0};
    const array<int, 4> wasd_x{0, -1, 0, 1};

    int h, w;

    queue<int> srch_y;
    queue<int> srch_x;

    cin >> h >> w;

    vector<string> map(h);

    for (int i = 0; i < h; i++)
        cin >> map[i];

    vector<vector<int>> dis(h, vector<int>(w, -1));

    // 最初のマスをキューに追加
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            if (map[i][j] == '#')
            {
                dis[i][j] = 0;
                srch_y.push(i);
                srch_x.push(j);
        }

    // 追加したマスの上下左右探索してキューに追加
    int max_way = 0;
    while (!srch_y.empty())
    {
        for (int i = 0; i < 4; i++)
        {
            const int y = srch_y.front() + wasd_y[i];
            const int x = srch_x.front() + wasd_x[i];
            if (y >= 0 && y < h && x >= 0 && x < w)
                if (dis[y][x] < 0)
                {
                    dis[y][x] = dis[srch_y.front()][srch_x.front()] + 1;
                    max_way = max(dis[y][x], max_way);
                    srch_y.push(y);
                    srch_x.push(x);
                }
        }
        srch_y.pop();
        srch_x.pop();
    }

    cout << max_way << endl;

    return 0;
}


Measured memory_bytes: 13440
#include <iostream>
#include <set>

int main(){
  std::string s;
  std::cin >> s;
  
  
  auto validate = [](const char* begin,const char* end){
  std::set<char> m = 
  {
    'A','T','C','G'
  };
    while(begin != end){
      if(m.count(*begin) == 0){
        return false;
      }
      begin++;
    }
    return true;
  };
  int max = 0;
  for(int st = 0;st<s.size();++st){
    for(int e = s.size();e >= 0;--e){
  		if(validate(s.c_str() + st,s.c_str() + e)){
          max = std::max(max,e-st);
        }
    }
  }
  
    std::cout << max << std::endl;
}

Measured memory_bytes: 888
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))  # リスト入力（数値）  map関数はリストの各要素に対して関数を適用してくれる
y = list(map(int, input().split()))  # リスト入力（数値）  map関数はリストの各要素に対して関数を適用してくれる

minX = max(x) + 1
maxY = min(y)

if X < minX and maxY <= Y and minX <= maxY:
    print("No War")
else:
    print("War")


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const ll INF = 1e+13;

ll sum[100005];     // 累積和テーブル

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

    int n, m;
    cin >> n >> m;
    map<ll, ll> cnt;
    for(int i = 0; i < n; ++i){
        ll a;
        cin >> a;
        sum[i + 1] = sum[i] + a;
        ++cnt[sum[i + 1] % m];
    }
    ll res = 0;
    for(auto it = cnt.begin(); it != cnt.end(); ++it){
        res += it->second * (it->second - 1) / 2;
        if(it->first == 0){
            res += it->second;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 4992
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
inline int read()
{
	int num=0, w=0;
	char ch=0;
	while (!isdigit(ch))
	{
		w|=ch=='-';
		ch = getchar();
	}
	while (isdigit(ch))
	{
		num = (num<<3) + (num<<1) + (ch^48);
		ch = getchar();
	}
	return w? -num: num;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=2e6+10;
int a[N];
int n,k;
bool check(int mid)
{
	int ans=0;
	for(int i=1;i<=n;i++)
		ans+=a[i]/mid+(a[i]%mid>0)-1;
	return ans<=k;
}
void solve()
{
	cin>>n>>k;
	for(int i=1; i<=n; i++)
		cin>>a[i];
	int l=1,r=1e9;
	while(l<r)
	{
		int mid=l+r>>1;
		if(check(mid))
			r=mid;
		else
			l=mid+1;
	}
	cout<<l<<endl;
}
signed main()
{
	int t=1;
	while(t--)
		solve();
	return 0;
}



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

int main(){
	int n,m,a;
	map<int,int> d;
	cin>>n;
	for (int i = 0; i < n; i++){
		cin>>a;
		d[a]++;
	}
	cin>>m;
	for (int i = 0; i < m; i++){
		cin>>a;
		d[a]--;
		if(d[a]<0){
			cout<<"NO"<<endl;
			return 0;
		}
	}

	cout<<"YES"<<endl;
	return 0;

}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define sz(x)  x.size()
#define cl(x)  x.clear()
#define all(x)  x.begin() , x.end()
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++)
#define per(i , n , x)  for(int i = n ; i >= x ; i --)
#define mem0(x)  memset(x , 0 , sizeof(x))
#define mem_1(x)  memset(x , -1 , sizeof(x))
#define debug(x)  cout << '*' << x << '\n'
#define ddebug(x , y)  cout << '*' << x << ' ' << y << '\n'
#define ios std::ios::sync_with_stdio(false) , cin.tie(0)
using namespace std ;
typedef long long ll ;
typedef pair<int , int> pii ;
const ll mod = 1e9 + 7 ;
const int maxn = 2e5 + 5 ;
int n ;
int a[maxn] ;
int num[maxn] ;
int main()
{
	ios ;
	cin >> n ;
	rep(i , 1 , n)  cin >> a[i] , num[a[i]] ++ ;
	ll sum = 0 ;
	rep(i , 1 , n)  sum += 1ll * num[i] * (num[i] - 1) / 2 ;
	rep(i , 1 , n)
	{
		ll temp = sum - 1ll * num[a[i]] * (num[a[i]] - 1) / 2 ;
		if(num[a[i]] >= 1)  temp += 1ll * (num[a[i]] - 1) * (num[a[i]] - 2) / 2 ;
		cout << temp << '\n' ;	
	} 
	return 0 ;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
int a[maxn + 5];
int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}
int main() {
	int n, x;
	cin >> n >> x; 
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	} 
	a[n + 1] = x;
	sort(a + 1, a + n + 2);
	int ans = 0;
	for(int i = 2; i <= n + 1; i++) {
		
		ans = gcd(ans, a[i] - a[i - 1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
sum_a=sum(a)
sum_b=sum(b)
a_cnt,b_cnt=0,0
for aa,bb in zip(a,b):
    if aa>bb:
        a_cnt+=aa-bb
    elif aa<bb:
        b_cnt+=(bb-aa)//2
if a_cnt<=b_cnt:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 4596
n = int(input())
info = [list(map(int, input().split())) for i in range(n - 1)]
m = int(input())
path = [list(map(int, input().split())) for i in range(m)]

tree = [[] for i in range(n)]
memo = {}
for i in range(n - 1):
    a, b = info[i]
    a -= 1
    b -= 1
    tree[a].append(b)
    tree[b].append(a)
    memo[(min(a, b), max(a, b))] = i


def dfs(par, pos, goal):
    if pos == goal:
        return True
    for child in tree[pos]:
        if child == par:
            continue
        if dfs(pos, child, goal):
            res.append((min(pos, child), max(pos, child)))
            return True
    return False
  

li_path = [0] * m
for i in range(m):
    res = []
    s, g = path[i]
    s -= 1
    g -= 1
    dfs(-1, s, g)
    tmp = 0
    for j in res:
        tmp += (1 << memo[j])
    li_path[i] = tmp
  
ans = 0
for bit_state in range(1 << m):
    mask = 0
    cnt = 0
    for i in range(m):
        if bit_state & (1 << i):
            cnt += 1
            mask |= li_path[i]
    num_n = bin(mask).count("1")
    if cnt % 2 == 0:
        ans += 2 ** (n - 1 - num_n)
    else:
        ans -= 2 ** (n - 1 - num_n)
print(ans)

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

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

Measured memory_bytes: 256
def get_int(): return int(input())
def get_float(): return float(input())
def get_line(): return input().split()
def get_lines(v): return [get_line() for _ in range(v)]
def get_int_line(): return list(map(int, get_line()))
def get_int_lines(v): return [get_int_line() for _ in range(v)]
def get_float_line(): return list(map(float, get_line()))
def get_float_lines(v): return [get_float_line() for _ in range(v)]

cost = [0,2,5,5,4,5,6,3,7,6]
N, M = get_int_line()
A = get_int_line()

dp = [-1 for _ in range(N + 1)]
dp[0] = 0
for i in range(N):
  if (dp[i] == -1): continue
  for v in A:
    if (i + cost[v] <= N and dp[i + cost[v]] < dp[i] * 10 + v):
      dp[i + cost[v]] = dp[i] * 10 + v

print(dp[N])

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

int arr[100005];
int n;
bool nxt = true; ///true - first, false - second

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

bool winstate(){
int numeven = 0;
for (int x = 0; x<n; x++){
    if (arr[x]%2==0) numeven++;
}
return numeven%2==1;
}

bool losestate(){
int numeven = 0;
int numodd = 0;
for (int x = 0; x<n; x++){
    if (arr[x]%2==0) numeven++;
    else numodd++;
}
return (numeven%2==0) && (numodd!=1);
}

int main(){
scanf("%d",&n);
for (int x = 0; x<n; x++){
    scanf("%d",&arr[x]);
}
while (true){
    if (winstate()){
        printf(nxt?"First":"Second");
        return 0;
    }
    if (losestate()){
        printf(nxt?"Second":"First");
        return 0;
    }
    int d = 0;
    for (int x = 0; x<n; x++){
        if (arr[x]%2==1) arr[x]--;
        if (arr[x]==0){
            printf(nxt?"Second":"First");
            return 0;
        }
        d = gcd(d,arr[x]);
    }
    for (int x = 0; x<n; x++){
        arr[x] /= d;
    }
    nxt = (!nxt);
}
}


Measured memory_bytes: 640
rooms = [[[0 for x in range(10)] for y in range(3)] for z in range(4)]
n = int(input())
for i in range(n):
    b,f,r,v = [int(x) for x in input().split()]
    rooms[b-1][f-1][r-1] += v
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(f" {rooms[i][j][k]}",end='')
        print("")
    if i < 3:
        print("####################")



Measured memory_bytes: 5640
A,B,Q = map(int,input().split())
S = [-10**11]
S.extend(int(input()) for _ in [0]*A)
S.extend([10**11])
T = [-10**11]
T.extend(int(input()) for _ in [0]*B)
T.extend([10**11])
X = [int(input()) for _ in [0]*Q]

def binary_search(A,func):
    l = 0
    r = len(A)-1
    if func(0,A):return -1
    if not func(r,A):return r
    while l+1<r:
        i = (l+r)//2
        if func(i,A):
            r = i
        else:
            l = i
    return l

for x in X:
    a = binary_search(S,lambda i,A:A[i]>=x)
    s = S[a:a+2]
    b = binary_search(T,lambda i,A:A[i]>=x)
    t = T[b:b+2]
    print(min(x-min(s[0],t[0]),
              max(s[1],t[1])-x,
              x-s[0]+t[1]-x+min(x-s[0],t[1]-x),
              x-t[0]+s[1]-x+min(x-t[0],s[1]-x) ))

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, M;
    cin >> N >> M;

    scc_graph G(N);

    REP(i, M){
        ll a, b;
        cin >> a >> b;
        G.add_edge(a, b);
    }
    
    auto ans = G.scc();

    cout << ans.size() << endl;
    for(auto v: ans){
        cout << v.size() << " ";
        for(auto i: v){
            cout << i << " ";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 40572
#include <stdio.h>
int main()
{
    int a, b, temp;
    scanf("%d %d", &a, &b);
    while (a != 0 || b != 0) {
        if (b < a) {
            temp = b;
            b = a;
            a = temp;
        }
        printf("%d %d\n", a, b);
        scanf("%d %d", &a, &b);
    }
    return 0;
}

Measured memory_bytes: 1028
/*ex4_3
series2*/

# include <stdio.h>
# include <math.h>
int main(void){
    //各文字の箱を作って読み取り
    int east,west;
    scanf("%d %d", &east,&west);
    //diffは西側の塔の図っている部分の西からの位置を示す
    int diff=west-east-1;
    //西側の本来の塔の高さは1からdiffを足したもの
    int height = diff*(diff+1)/2;
    printf("%d\n",height-east);
    return 0;
}

Measured memory_bytes: 128
use proconio::input;

fn main() {
    input! {
        a:f64,
        b:f64,
        h:f64,
        m:f64   
    };


    let rate_a = h/12.+m/(60.*12.);
    let rate_b = m/60.;

    fn f (r:f64,rate:f64) -> num::complex::Complex<f64>{
        let theta = 2.*std::f64::consts::PI*rate;
        r*(num::complex::Complex::<f64>::new(0.,theta)).exp()
    };

    let pos_a = f(a,rate_a);
    let pos_b = f(b,rate_b);
    let ans = (pos_a-pos_b).norm();

    println!("{}",ans);


}


Measured memory_bytes: 2932
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define nl cout << endl
#define pb push_back
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
//debugger
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

int main() {
	fast;
	int n;
	cin >> n;
	int a[n];
	for (int i=0; i<n; i++) {
		cin >> a[i];
	}
	sort(a,a+n);
	ll ans=0;
	for (int i=0; i<n; i++) {
		for (int j=i+1; j<n; j++) {
			int sum=a[i]+a[j];
			for (int k=j+1; k<n; k++) {
				if (sum>a[k]) {
					ans++;
				} else {
					break;
				}
			}
		}
	}
	cout << ans;nl;
	return 0;
}

//notes
/*
 use these format of input when number of inputs not provided
 *while(scanf("%lld",&n)!=EOF)
 *while using getline(cin,s) for taking input of a string which is 
 having white space characters just write cin>>ws; before geline(cin,s)
 to make it work properly
*/

/*
 use 2-D vector for representing the pair<int,pair<int,int> > kind of things
*/

Measured memory_bytes: 256
for _ in range(10000):
	n,x = map(int,input().split())
	
	if (n+x == 0):
		break
	
	input_list = list(range(1,n+1))
	
	res = 0
	
	for i in range(len(input_list)):
		for j in range(i+1,len(input_list)):
			for k in range(j+1,len(input_list)):
				if input_list[i]+input_list[j]+input_list[k] == x:
					res += 1
				
			if j + 2 == len(input_list):
				break
		
		if i + 3 == len(input_list):
			break
		
	print(str(res))


Measured memory_bytes: 5592
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b;
	cin >> a >> b;

	if(a>b) swap(a, b);

	pair<int,int> x = make_pair(a, b);

	for(int i = 1; i <= 5000; i++) {
		pair<int,int> p = make_pair((i*8)/100, (i*10)/100);
		if(p == x) {
			cout << i;
			exit(0);
		}
	}

	cout << -1;
	

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll A[310][310];
ll B[310][310];

void solve() {
	cin >> N;
	rep(i, 0, N) {
		rep(j, 0, N) {
			cin >> A[i][j];
			B[i][j] = A[i][j];
		}
	}
	rep(i, 0, N) {
		rep(j, 0, N) {
			rep(k, 0, N) {
				MIN(B[i][j], B[i][k] + B[k][j]);
			}
		}
	}
	rep(i, 0, N) {
		rep(j, 0, N) {
			if(A[i][j] != B[i][j]) {
				cout << "-1\n";
				return;
			}
		}
	}
	ll ans = 0;
	rep(i, 0, N) {
		rep(j, 0, N) {
			if(i == j) continue;
			bool found = false;
			rep(k, 0, N) {
				if(i == k || j == k) continue;
				if(A[i][j] == B[i][k] + B[k][j]) {
					found = true; break;
				}
			}
			if(!found) ans += A[i][j];
		}
	}
	cout << ans / 2 << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

long long A, B;

int main(){
	cin >> A >> B;
	set<long long> ans;
	ans.insert(1);
	ans.insert(2);
	ans.insert(3);
	ans.erase(A);
	ans.erase(B);
	cout << *ans.begin() << endl;

}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  string s,t;
  cin>>s>>t;
  bool ans=true;
  string alpha="abcdefghijklmnopqrstuvwxyz";
  string al="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  rep(i,26){
      rep(j,sz(s)){
          if(s[j]==alpha[i]){
              al[i]=t[j];
              break;
          }
      }
  }
  rep(i,25){
      for(ll j=i+1;j<26;j++){
          if(al[i]==al[j]){
              ans=false;
          }
      }
  }
  rep(i,26){
      rep(j,sz(s)){
          if(s[j]==alpha[i]&&t[j]!=al[i]){
              ans=false;
              i=30;
              break;
          }
      }
  }
  cout<<(ans?"Yes":"No")<<endl;
}


Measured memory_bytes: 3912
#![allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   rand::Rng,
   std::collections::BTreeSet,
};

#[fastout]
fn main() {
   let start = std::time::Instant::now();
   let time_limit = std::time::Duration::from_millis(1950);

   let n = 26;
   input! {
      dn: usize,
      c: [i64; n],
      s: [[i64; n]; dn],
   }

   let mut score = 0i64;
   let mut set = vec![BTreeSet::new(); n];
   for i in 0..n {
      set[i].insert(0);
      set[i].insert(dn + 1);
   }

   let mut t = vec![0; dn];
   for i in 0..dn {
      let mut diff = vec![];
      let mut mx = 0;
      for j in 0..n {
         diff.push(c[j] * (i + 1 - set[j].range(..=i + 1).rev().next().unwrap()) as i64);
         if s[i][j] + diff[j] >= s[i][mx] + diff[mx] {
            mx = j;
         }
      }
      t[i] = mx;
      for j in 0..n {
         if j == mx {
            score += s[i][j];
         }
         score -= diff[j];
      }
   }

   let calc = |d: usize, q: usize, set: &BTreeSet<usize>| {
      c[q]
         * (d + 1 - set.range(..=d).rev().next().unwrap()) as i64
         * (set.range(d + 2..).next().unwrap() - (d + 1)) as i64
         + s[d][q]
   };

   let mut ans = t.clone();
   let mut mn = score;
   let mut rng = rand::thread_rng();
   loop {
      let elapsed = start.elapsed();
      if elapsed > time_limit {
         break;
      }
      let dt = elapsed.as_micros() as f64 / time_limit.as_micros() as f64;
      let d = rng.gen_range(0, dn);
      let q = rng.gen_range(0, n);
      let diff = calc(d, q, &set[q]) - calc(d, t[d], &set[t[d]]);

      if diff > 0 || rng.gen_range(0f64, 1f64) <= (-diff as f64 / 20.0 / dt).exp() {
         set[t[d]].remove(&(d + 1));
         set[q].insert(d + 1);
         t[d] = q;
         score += diff;
      } else if mn > score {
         ans = t.clone();
         mn = score;
      }
   }
   for t in ans.iter() {
      println!("{}", t + 1);
   }
}


Measured memory_bytes: 3332
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


string s;

void solve()
{
    cin >> s;
    if (s=="Sunny") nout("Cloudy");
    if (s=="Cloudy") nout("Rainy");
    if (s=="Rainy") nout("Sunny");
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

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

using namespace std;
using ll = long long;

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> ac(N), wa(N);
  ac.assign(0, N);
  wa.assign(0, N);
  int p;
  string s;
  int ac_cnt =0, wa_cnt=0;
  for(int i=0; i<M; i++){
    cin >> p >> s;
    p--;
    if(s=="AC" && ac[p]==0){
      wa_cnt += wa[p];
      ac[p] = 1;
      ac_cnt++; 
    }
    
    wa[p]++;
    
  }
  
  
  cout << ac_cnt << " " << wa_cnt << endl;
  
  
 
  return 0;
}

Measured memory_bytes: 4032
#include<stdio.h>
char c;
int main(){
	c=getchar();
	switch (c){
		case 'A':putchar('T');break;
		case 'T':putchar('A');break;
		case 'C':putchar('G');break;
		case 'G':putchar('C');break;
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
inline int dis(int x, int K) {
	int a = x * 2;
	int b = 2 * abs(K - x);

	return min(a, b);
}

int main() {
	int N, K;
	int x[101];
	int ans = 0;

	cin >> N >> K;
	for (int i = 1; i <= N; i++)
	{
		cin >> x[i];
	}

	for (int i = 1; i <= N; i++)
	{
		ans += dis(x[i], K);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

antenas = [a, b, c, d, e, k]
ans_str = 'Yay!'
for i in range(len(antenas)-1):
    ans = 0
    for j in range(len(antenas)-i-1):
        ans = antenas[i]-antenas[i+j+1]
        if ans < -1:
            ans *= -1
        if ans > k:
            ans_str = ':('
            break
    if ans > k:
        ans_str = ':('
        break

            
    
# 出力
print(ans_str)

Measured memory_bytes: 3064