akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main {

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);

        int w = scan.nextInt();
        
        while(w != -1){
            int total = 0; 
            
        if (w <= 10 )  {
            System.out.println(4280 -1150);
        
        } else if (10 < w && w <= 20){
            System.out.println(4280 - (1150 + (w-10) * 125));
        
        } else if (20 < w && w <= 30){
            System.out.println(4280 - (1150 + 125 * 10 + (w-20) * 140));
            
        } else if (30 < w){
            System.out.println (4280 - (1150 + 125 * 10 + 140 * 10 + ((w-30) * 160)));
        }
       w = scan.nextInt();
    }  
}
}


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

int main(){
  int n;
  cin >> n;
  int i=1;
  int x=n;
  int k;
  
  while(x>=10){
    x/=10;
    i++;
  }
  
  if(i==1){
    k=n;
  }
  
  else if(i==2){
    k=9;
  }
  
  else if(i==3){
    k=n-90;
  }
  
  else if(i==4){
    k=909;
  }
  
  else if(i==5){
    k=n-9090;
  }
  
  else{
    k=90909;
  }
  
  cout << k << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
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 long long INF = 1LL <<60;
typedef long long ll;
using namespace std;
 
ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
 
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
 
ll choose2(ll n){
    return n*(n-1)/2;
}
 
int main(){
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}

Measured memory_bytes: 3632
/*input
souuundhound
2
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define MAX 
#define INF 0x3f3f3f3f

string s;
int32_t main(){
    IOS;
    int pos = 0 , res;
    cin >> s;
    cin >> res;
    while(pos < s.size()) cout << s[pos] , pos += res;
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import           Control.Applicative
import           Control.Monad
import           Data.List

main :: IO ()
main = do
  text <- getLine
  num <- getLine
  cmds <- replicateM (read num) (words <$> getLine)
  putStr $ unlines $ snd $ foldl exec (text,[]) cmds
  where
    exec::(String, [String])->[String]->(String, [String])
    exec(cur, out) (cmd:a:b:s1)
      | cmd=="reverse" = (left ++ reverse mid  ++ right, out)
      | cmd=="replace" = (left ++ head s1 ++ right, out)
      | cmd=="print" = (cur, out ++ [mid])
      where
        start = read a
        end = read b
        left = take start cur
        mid = take (end - start + 1) (drop start cur)
        right = drop (end + 1) cur



Measured memory_bytes: 5836
//ABC140 B - Buffet
//20190907

using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] B = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] C = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int satisfaction = 0;

            for (int i = 0; i < N; i++)
            {
                A[i] -= 1;
            }

            satisfaction += B[A[0]];


            for (int i = 1; i < N; i++)
            {
                satisfaction += B[A[i]];

                if (A[i] - A[i - 1] == 1)
                {
                    satisfaction += C[A[i-1]];
                }
            }

            Console.WriteLine(satisfaction);
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
        #define ll long long
        #define f   first
        #define s   second
        #define pb          push_back
        #define mod        1000000007
        #define mod1       1000000009
        #define hell        998244353
        #define inf         1000000000000000000LL
        #define pi          3.14159265358979323
        #define N           1000005 
        using namespace std;
        ll n,k,sum,q,res,m,val,ans;
        ll x,y;
        ll xx[]={1,0,-1,0};
        ll yy[]={0,1,0,-1};
        void solve()    
        {   ll a,b;
            cin>>n;
            ll ans=0;
            for(int i=0;i<n;i++)
                ans+=(i+1)*(n-i);
            for(int i=0;i<n-1;i++)
            {
                cin>>x>>y;
                if(x>y) swap(x,y);
                ans-=(x*(n-y+1));
            }
            cout<<ans;
            


        }
        int main()
        {   ios_base::sync_with_stdio(false);
            cin.tie(0);cout.tie(0);
            ll t=1;
            //cin>>t;
            while(t--)
                solve();
            

        }            

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

namespace TOPSIC
{
    partial class Program
    {
        static void Main(string[] args)
        {
          string[] ABM = Console.ReadLine().Split(' ');

            int A = int.Parse(ABM[0]);
            int B = int.Parse(ABM[1]);
            int M = int.Parse(ABM[2]);

            string[] stra = Console.ReadLine().Split(' ');
            int[] a = stra.Select(s => int.Parse(s)).ToArray();

            string[] strb = Console.ReadLine().Split(' ');
            int[] b = strb.Select(s => int.Parse(s)).ToArray();

            int[] x = new int[M];
            int[] y = new int[M];
            int[] c = new int[M];
            for (int i = 0; i < M; i++)
            {
                string[] xyc = Console.ReadLine().Split(' ');
                x[i] = int.Parse(xyc[0]);
                y[i] = int.Parse(xyc[1]);
                c[i] = int.Parse(xyc[2]);
            }

            List<int> sumab = new List<int>();

            sumab.Add(a.Min() + b.Min());

            for (int i = 0; i < M; i++)
            {
                sumab.Add(a[x[i] - 1] + b[y[i] - 1] - c[i]);
            }

            int ans = 1000000;
            for (int i = 0; i < sumab.Count; i++)
            {
                if (ans > sumab[i])
                {
                    ans = sumab[i];
                }
            }

            Console.WriteLine(ans);

        }
    }
}


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

typedef long long int ll;
#define pb push_back
#define mp make_pair
#define N 300005

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	int n,i;
	cin>>n;
	int a[N],count[N]={0};
	for(i=2;i<=n;i++){
		cin>>a[i];
		count[a[i]]++;
	}

	for(i=1;i<=n;i++)
		cout<<count[i]<<" ";
	cout<<endl;
	return 0;
}


Measured memory_bytes: 5516
n,d= map(int,input().split())
l = []
a = 0
def dis(l1,l2):
    c = 0
    for i in range(0,len(l1)):
        c = c+(l1[i]-l2[i])**2
    return c**0.5

for _ in range(n):
    l.append(list(map(int,input().split())))
for i in range(0,n-1):
    for j in range(i+1,n):
        if float(dis(l[i],l[j])).is_integer() == True:
            a = a + 1
print(a)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int d=n%10;
    n/=10;
    int c=n%10;
    n/=10;
    int b=n%10;
    n/=10;
    int a=n;
    //0が+で1が-にしようでな
    int sum,ans;
    for(int i=0;i<8;i++)
    {
        sum=a;
        if(i&1)
        {
            sum-=b;
        }
        else
        {
            sum+=b;
        }
        if(i&2)
        {
            sum-=c;
        }
        else
        {
            sum+=c;
        }
        if(i&4)
        {
            sum-=d;
        }
        else
        {
            sum+=d;
        }
        if(sum==7){
            ans=i;break;
        }
    }
    char op1='+',op2='+',op3='+';
    if(ans%2)
    op1='-';
    ans/=2;
    if(ans%2)
    op2='-';
    ans/=2;
    if(ans%2)
    op3='-';
    cout<<a<<op1<<b<<op2<<c<<op3<<d<<"=7"<<endl;
    return 0;
    
}

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

//-----------------------------------------------

//------------------------------------------------
int main(){
  int n;
  int a[110];
  int b[110];
  int c[110];
  int ans;
  ans=0;
  cin>>n;
  rep(i,0,n) cin>>a[i];
  rep(i,0,n) cin>>b[i];
  rep(i,0,n-1) cin>>c[i];

  rep(i,0,n) {
    ans+=b[a[i]-1];
    if(i>0 && a[i]-a[i-1]==1) ans+=c[a[i]-2];
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;

public class B {
    public static void Main(){
        string[] line = Console.ReadLine().Split(' ');
        long N = long.Parse(line[0]);
        long A = long.Parse(line[1]);
        long B = long.Parse(line[2]);
        long div = N/(A+B);
        long amari = N%(A+B);
        long ans = A*div;
        if (amari > 0)
        {
            ans += Math.Min(A, amari);
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
/* Warshall-Floyd Algorithm */

#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	int wf[10][10];
	for(int n_road;cin>>n_road,n_road;){
		for(int i=0;i<10;i++)for(int j=0;j<10;j++)wf[i][j]=10000;

		int n_city=0;
		for(int i=0;i<n_road;i++){
			int a,b,c;	cin>>a>>b>>c;
			n_city=max(n_city,max(a+1,b+1));
			wf[a][b]=wf[b][a]=c;
		}

		for(int k=0;k<n_city;k++){
			for(int i=0;i<n_city;i++){
				for(int j=0;j<n_city;j++){
					if(i==j)	wf[i][j]=0;
					wf[i][j]=min(wf[i][j],wf[i][k]+wf[k][j]);
				}
			}
		}

		int opt=10000,iopt;
		for(int i=0;i<n_city;i++){
			int sum=0;
			for(int j=0;j<n_city;j++)	sum+=wf[i][j];
			if(opt>sum)	opt=sum,iopt=i;
		}
		cout<<iopt<<' '<<opt<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <numeric>
#include <algorithm>

typedef long long ll;

using namespace std;

ll gcd(ll a, ll b) {
    if (a < b) return gcd(b, a);
    if (a % b) return gcd(b, a % b);
    return b;
}

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

int main() {
    ll n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    if (n < m) {
        swap(n, m);
        swap(s, t);
    }
    if (s.at(0) != t.at(0)) {
        cout << "-1" << endl;
        return 0;
    }
    ll p = lcm(n, m), q = gcd(n, m);
    bool flag = true;
    for (ll i = 0; i < p; i += p / q) flag &= (s.at(i * q / m) == t.at(i * q / n));
    if (flag) cout << p << endl;
    else cout << "-1" << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#define ll long long
#include<cstring>
#define rep(i,n) for(int i=0;i<n;i++)
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>QUE;//きゅー

int length(char* str) {
	int len = strlen(str);
	return len;
}

ll LCM(ll a,ll b)
{

    ll r, x, tmp;
    ll i, j;
    ll lcm;
    i = a;
    j = b;

    /* 自然数 a > b を確認・入替 */
    if (a < b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    /* ユークリッドの互除法 */
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    lcm = (i / b) * j;

    return lcm;
}

int main()
{
    int ans;
    
    int N, L;
    int sum = 0;
    cin >> N >> L;
    ans = abs(L);
    for (int i = 0; i < N; i++) {
        sum += L;
        ans = min(abs(ans), abs(L));
        L++;
    }
    if (L <= 0)cout << sum + abs(ans) << endl;
    else cout << sum - abs(ans) << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

const ll mod = 1e9 + 7;
// const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

template<class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
	return os << "{" << p.first << "," << p.second << "}";
}

template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
	os << "{";
	for (auto e : v)os << e << ",";
	return os << "}";
}

int main() {
	ll N;
	cin >> N;
	double ans = (N % 2 == 0) ? 0.5 : (N + 1.0) / 2.0 / (double)N;

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

Measured memory_bytes: 256
def solve():

    n, a, b = map(int, input().split())
    mod = 10**9 + 7

    # 繰り返し二乗法
    def modPow(a, n, mod):
        if n == 1:
            return a
        elif n%2 == 1:
            return a * modPow(a, n-1, mod) % mod
        else:
            t = modPow(a, n/2, mod)
            return (t * t) % mod

    def combination(n, a, mod):
        x = 1
        y = 1
        for i in range(a):
            x = x * (n-i)%mod
            y = y * (a-i)%mod

            #x *= (n-i)
            #x %=mod
            #y *= (a-i)
            #y %=mod
        return x * pow(y, mod-2, mod)%mod

    #全ての選び方
    sigma_nCi = pow(2, n, mod)
    # nCa, nCb
    nCa = combination(n, a, mod)
    nCb = combination(n, b, mod)

    ans = sigma_nCi - 1 - nCa - nCb

    #print(Sigma_nCi, nCa, nCb)
    print(ans%mod)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:String,
    }
    let mut a=a.chars().collect_vec();
    let mut a=a.iter().map(|a|a.to_digit(10).unwrap() as usize).collect_vec();
    let mut b:usize=a.iter().sum();
    println!("{}",max(b,(a[0]+a.len()*9-10)))
}

Measured memory_bytes: 2124
n = int(raw_input())
a = map(int,raw_input().split())
b = map(int,raw_input().split())
c = map(int,raw_input().split())
res = 0
prev = -1
for x in a:
	res += b[x-1]
	if x-1 == prev:
		res += c[x-2]
	prev = x
print res

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

#ifdef LOCAL_BOOKNU
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// ........................macro.......................... //
#define FOR(i, f, n) for(int (i) = (f); (i) < (int)(n); ++(i))
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (int)(n); --(i))
#define pb push_back
#define emb emplace_back
#define fi first
#define se second
#define ENDL '\n'
#define sz(A) (int)(A).size()
#define ALL(A) A.begin(), A.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define next next9876
#define prev prev1234
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef long long i64;
typedef unsigned long long ui64;
// inline i64 GCD(i64 a, i64 b) { if(b == 0) return a; return GCD(b, a % b); }
inline int getidx(const vi& ar, int x) { return lower_bound(ALL(ar), x) - ar.begin(); } // 좌표 압축에 사용: 정렬된 ar에서 x의 idx를 찾음
inline i64 GCD(i64 a, i64 b) { i64 n; if(a < b) swap(a, b); while(b != 0) { n = a % b; a = b; b = n; } return a; }
inline i64 LCM(i64 a, i64 b) { if(a == 0 || b == 0) return GCD(a, b); return a / GCD(a, b) * b; }
inline i64 CEIL(i64 n, i64 d) { return n / d + (i64)(n % d != 0); } // 음수일 때 이상하게 작동할 수 있음.
inline i64 ROUND(i64 n, i64 d) { return n / d + (i64)((n % d) * 2 >= d); }
const i64 MOD = 1e9+7;
inline i64 POW(i64 a, i64 n) {
	assert(0 <= n);
	i64 ret;
	for(ret = 1; n; a = a*a%MOD, n /= 2) { if(n%2) ret = ret*a%MOD; }
	return ret;
}
template <class T> ostream& operator<<(ostream& os, vector<T> v) {
	os << "[";
	int cnt = 0;
	for(auto vv : v) { os << vv; if(++cnt < v.size()) os << ","; }
	return os << "]";
}
template <class T> ostream& operator<<(ostream& os, set<T> v) {
	os << "[";
	int cnt = 0;
	for(auto vv : v) { os << vv; if(++cnt < v.size()) os << ","; }
	return os << "]";
}
template <class L, class R> ostream& operator<<(ostream& os, pair<L, R> p) { return os << "(" << p.fi << "," << p.se << ")"; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H, debug_out(T...); }
// ....................................................... //

const int MAXN = 2e5+10;
int n, ar[MAXN], pr[MAXN], head[MAXN], dp[MAXN];
void input() {
	memset(pr, -1, sizeof(pr));
	memset(head, -1, sizeof(head));
	cin >> n;
	FOR(i, 0, n) cin >> ar[i];
}

i64 getdp(int i) {
	if(i < 0) return 1;
	return dp[i];
}

int solve() {
	FOR(i, 0, n) {
		if(head[ar[i]] == -1) head[ar[i]] = i;
		else pr[i] = head[ar[i]], head[ar[i]] = i;
	}
	FOR(i, 0, n) {
		dp[i] = getdp(i-1);
		if(pr[i] != -1 && pr[i] != i-1) {
			dp[i] += getdp(pr[i]);
			dp[i] %= MOD;
		}
	}
	cout << dp[n-1] << ENDL;
	return 0;
}

// ................. main .................. //
void execute() {
	input(), solve();
}

int main(void) {
#ifdef LOCAL_BOOKNU
	freopen("input.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	cin.tie(0), ios_base::sync_with_stdio(false);
	execute();
	return 0;
}
// ......................................... //

Measured memory_bytes: 3328
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	s := sc.NextLine()
	t := sc.NextLine()
	a := [26]int{}
	b := [26]int{}
	mp1 := map[int]int{}
	mp2 := map[int]int{}
	if len(s) != len(t) {
		fmt.Printf("No\n") // output for debug
		return
	}
	for i := 0; i < len(s); i++ {
		a[int(s[i]-'a')]++
		b[int(t[i]-'a')]++
	}
	for i := 0; i < len(a); i++ {
		mp1[a[i]]++
		mp2[b[i]]++
	}
	for k, _ := range mp1 {
		if mp1[k] != mp2[k] {
			fmt.Printf("No\n") // output for debug
			return
		}
	}
	fmt.Printf("Yes\n") // output for debug

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int d = a - b;
    if (c <= d) cout << 0 << endl;
    else cout << (c-d) << endl;
    return 0;
}

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

signed main(){
int a[3];
scanf("%d%d%d",&a[0],&a[1],&a[2]);
sort(a,a+3);
if(a[0]==5 && a[1]==5 && a[2] ==7) puts("YES\n");
else puts("NO\n");

return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque

h,w=map(int,input().split())
ch,cw=map(int,input().split())
ch,cw=ch-1,cw-1
dh,dw=map(int,input().split())
dh,dw=dh-1,dw-1
s=[[*next(sys.stdin)] for _ in range(h)]

c=-1
for i in range(h):
    for j in range(w):
        if s[i][j]!='.':
            continue
        c+=1
        stk=[(i,j)]
        while stk:
            ii,jj=stk.pop()
            s[ii][jj]=c
            for di,dj in (-1,0),(0,1),(1,0),(0,-1):
                ni,nj=ii+di,jj+dj
                if not (0<=ni<h and 0<=nj<w):
                    continue
                if s[ni][nj]!='.':
                    continue
                stk.append((ni,nj))

n=c+1
cc=dc=-1
dirs=[-2,-1,0,1,2]
adj=[{*()} for _ in range(n)]
for i in range(h):
    for j in range(w):
        u=s[i][j]
        if u=='#':
            continue
        if i==ch and j==cw:
            cc=u
        elif i==dh and j==dw:
            dc=u
        for di in dirs:
            for dj in dirs:
                if di==dj==0:
                    continue
                ni,nj=i+di,j+dj
                if not (0<=ni<h and 0<=nj<w):
                    continue
                v=s[ni][nj]
                if v=='#':
                    continue
                if u!=v:
                    adj[u].add(v)
                    adj[v].add(u)

que=deque()                
que.append(cc)
vis={cc}
m=-1
while que:
    m+=1
    for _ in range(len(que)):
        u=que.popleft()
        if u==dc:
            print(m)
            exit()
        for v in adj[u]:
            if v in vis:
                continue
            vis.add(v)
            que.append(v)

print(-1)


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

int main(){
  int n;
  std::cin >> n;
  vector<int> a(n);
  vector<int> color(8, 0);
  int sum = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
    color[0] += (   1 <= a[i] and a[i] <=  399);
    color[1] += ( 400 <= a[i] and a[i] <=  799);
    color[2] += ( 800 <= a[i] and a[i] <= 1199);
    color[3] += (1200 <= a[i] and a[i] <= 1599);
    color[4] += (1600 <= a[i] and a[i] <= 1999);
    color[5] += (2000 <= a[i] and a[i] <= 2399);
    color[6] += (2400 <= a[i] and a[i] <= 2799);
    color[7] += (2800 <= a[i] and a[i] <= 3199);
    sum += (3200 <= a[i]);
  }
  for (int i = 0; i < 8; i++) {
    ans += (color[i] > 0);
  }
  std::cout << max(ans, 1) << " " << ans + sum << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());
		int z = Integer.parseInt(sc.next());
		int ans = 0;
		x -= (2 * z);
		while(x - y >= 0) {
			x -= (y + z);
			ans++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23252
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<cstdlib>
#define lson l,mid,o<<1
#define rson mid + 1,r,o<<1|1
#define sc(x) scanf("%d",&x);
#define For(i,a,b)  for(i = a; i <= b; i++)
typedef long long LL;
typedef unsigned long long uLL;
const int INF = 0x3f3f3f3f;
const LL MAX_N = 1e3 + 5;
const LL mod = 1e9 + 7;
const double PI = acos(-1);
using namespace std;


int main()
{
    char a,b;
    cin>>a>>b;
    if(a=='H'){
        if(b=='H'){
            cout<<"H"<<endl;
        }
        else{
            cout<<"D"<<endl;
        }
    }
    else{
        if(b=='D'){
            cout<<"H"<<endl;
        }
        else{
            cout<<"D"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String input = br.readLine();
        int notes = Integer.parseInt(input.substring(0,input.indexOf(" ")));
        input = input.substring(input.indexOf(" ") + 1);
        int money_l = Integer.parseInt(input);
        int money = money_l/1000;
        String result = "-1 -1 -1";


        if(notes<=money && money<=notes*10){//too much notes or too much mooney
            OUTSIDE:for(int x = 0; x<=notes; x++){
                if(x*10>money){break;}
                else if(money <= x*10 + (notes-x)*5){
                    for(int y = 0; y<=notes-x; y++){
                        if(x*10 + y*5 > money){break;}
                        else if(x*10 + y*5 + (notes-x-y) == money){
                            result = String.valueOf(x) + " " + String.valueOf(y) + " " + String.valueOf(notes-x-y);
                            break OUTSIDE;
                        }
                    }
                }
            }
        }
    System.out.println(result);
    }
}

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

int dou(int a, int b){
  return (a-b)*(a-b);
}

int main(){
  int N;
  cin>>N;
  int X[N+1];
  for(int i=0; i<N; i++) cin>>X[i];
  int sum=0;
  for(int i=0; i<N; i++) sum += X[i];
  int ave = sum/N;
  // printf("ave = %d\n", ave);

  int p = ave;
  int ans = 10000000;
  for(int i=0; i<10; i++){
    if(p+i<=100){
      int S = 0;
      for(int j =0; j<N; j++) S+= dou(p+i, X[j]);
      // printf("%d\n", S);
      if(ans>S) ans = S;
    }
  }
  for(int i=0; i<10; i++){
    if(p-i>=0){
      int S = 0;
      for(int j =0; j<N; j++) S+= dou(p-i, X[j]);
      // printf("%d\n", S);
      if(ans>S) ans = S;
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s, t;
    cin>>s>>t;
    if(t.length()<=s.length() || t.length()>s.length()+1) {
        cout<<"No\n";
        return 0;
    }
    for(int i=0;i<s.length();i++) {
        if(s[i]!=t[i]) {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;

    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(void){
    
    int n,m,X,Y;
    scanf("%d %d %d %d",&n,&m,&X,&Y);
    int i,x[n],y[m];
    
    for(i=0; i<n; ++i)scanf("%d",&x[i]);
    for(i=0; i<m; ++i)scanf("%d",&y[i]);
    
    int Xmin=X,Xmax=X,Ymin=Y,Ymax=Y;
    
    for(i=0; i<n; ++i){
        if( x[i] < Xmin ) Xmin=x[i];
        if( x[i] > Xmax ) Xmax=x[i];
    }
    for(i=0; i<m; ++i){
        if( y[i] < Ymin ) Ymin = y[i];
        if( y[i] > Ymax ) Ymax = y[i];
    }
    
    if( Xmax < Ymin ){
        printf("No War");
        return 0;
    }
    
    printf("War");
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int Hlength=sc.nextInt();
        int Mlength=sc.nextInt();
        int H=sc.nextInt();
        int M=sc.nextInt();
        double Hdiff=(double)M/60;
        double Hdeg=90-(360*(H+Hdiff)/12);
        double Mdeg=90-(360*M/60);
 
        double Hth=Math.toRadians(Hdeg);
        double Mth=Math.toRadians(Mdeg);
 
        double Hx=Hlength*Math.cos(Hth);
        double Hy=Hlength*Math.sin(Hth);
        double Mx=Mlength*Math.cos(Mth);
        double My=Mlength*Math.sin(Mth);
 
        double dis=Math.sqrt(Math.pow((Hx-Mx),2)+Math.pow((Hy-My),2));
        System.out.println(dis);
        sc.close();
    }
}

Measured memory_bytes: 35964
n, m, x = map(int,input().split())
array = [[int(x) for x in input().split()] for y in range(n)]

ans = float("inf")
for i in range(2**n):
    tmp = [0 for x in range(m)]
    tmp_cost = 0
    bits = format(i, "b").zfill(n)
    for j in range(n):
        bit = bits[j]
        if bit == "1":
            tmp_cost += array[j][0]
            for k in range(m):
                tmp[k] += array[j][1+k]
    for l in tmp:
        if l < x:
            break
    else:
        ans = min(ans, tmp_cost)
print(ans if ans != float("inf") else -1)





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

int main() {
        while(true){
        int n,m;
        string s;
        cin>>n>>m>>s;

        if(n==0){
                break;
        }

        int ni,start=0,ans=0;
        for(int i=0;i<m;i++){
                if(s[i]==s[i+1] && i>0){
                        if(s[i]!=s[i-1] && s[i-1]!=s[i-2]){
                                int longs=i-start;
                                if(s[start+1]=='I'){
                                        ni=longs-longs/2;
                                }
                                else{
                                        ni=longs/2;
                                }
                                if(ni>n){
                                        ans+=ni-n;
                                }
                                start=i;
                        } else start=i;
                }
        }

        cout<<ans<<endl;

        }

        return 0;
}

Measured memory_bytes: 2112
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if ( (b-a) == (c-b) ) System.out.println("YES");
		else System.out.println("NO");
	}
}


Measured memory_bytes: 23252
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
    
n,m = map(int, input().split(" "))

if (n+m)%3 != 0 or max(n,m) // min(n,m) > 2:
  print(0)
else:
  sa = max(n,m)-min(n,m)
  times = [((n+m)//3), ((n+m)//3-sa)//2]
  #print(times)
  print(cmb(times[0], times[1], p))

Measured memory_bytes: 167996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int x1,y1,x2,y2,x,y,x3,y3,x4,y4;
    cin>>x1>>y1>>x2>>y2;
    x=y1-y2;
    y=x2-x1;
    x4=x1+x;
    y4=y1+y;
    x3=x2+x4-x1;
    y3=y2+y4-y1;
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;

    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> A(9);
  for (int i = 0; i < 9; i++) {
    cin >> A.at(i);
  }
  int N;
  cin >> N;
  vector<int> b(N);
  for (int i = 0; i < N; i++) {
    cin >> b.at(i);
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 9; j++) {
      if (b.at(i) == A.at(j)) {
        A.at(j) = 0;
      }
    }
  }
  if (
    ((A.at(0) == 0) && (A.at(1) == 0) && (A.at(2) == 0)) ||
    ((A.at(3) == 0) && (A.at(4) == 0) && (A.at(5) == 0)) ||
    ((A.at(6) == 0) && (A.at(7) == 0) && (A.at(8) == 0)) ||
    ((A.at(0) == 0) && (A.at(3) == 0) && (A.at(6) == 0)) ||
    ((A.at(1) == 0) && (A.at(4) == 0) && (A.at(7) == 0)) ||
    ((A.at(2) == 0) && (A.at(5) == 0) && (A.at(8) == 0)) ||
    ((A.at(0) == 0) && (A.at(4) == 0) && (A.at(8) == 0)) ||
    ((A.at(2) == 0) && (A.at(4) == 0) && (A.at(6) == 0))
    ) { cout << "Yes" << endl; }
  else { cout << "No" << endl; }
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int>v(110);
    for (int i = 0; i < N; i++){
        cin >> v.at(i);
    }
    int nagai = 0;
    for (int i = 0; i < N; i++){
        nagai = max(nagai,v.at(i));
    }
    int ans = 0;
    for (int ish = 0; ish <= nagai; ish++){
        for (int i = 0; i < N; i++){
            if (v.at(i) == 0){
                continue;
            }
            if (v.at(i+1) == 0){
                v.at(i)--;
                ans++;
                continue;
            }
            v.at(i)--;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
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; }
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n;
  cin >>n;
  map<string,int>mp;
  string t;
  bool ok=true;
  rep(i,n){
    string s;
    cin >> s;
    if(i==0){
      string t=s;
    }
    else{
      if(t[t.size()-1]!=s[0] ||mp[s]>0){
        ok=false;
      }
    }
    t=s;
    mp[s]++;
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
typedef long long ll;
#define pri(n) printf("%d\n",n)
#define lpri(n) printf("%lld\n",n);
#define rep(i,st,ed) for(int i=st;i<ed;i++)
#define F first
#define S second 
#define pb(n) push_back(n)
const int N=1e5+6;
const ll M=1e9+7;

int main()
{
	int n,w;
	scn(n);scn(w);
	ll dp[n+1][w+1];
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++)
	{
		int wt,val;
		scn(wt);scn(val);
		for(int j=1;j<=w;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(j>=wt)
				dp[i][j]=max(dp[i][j],dp[i-1][j-wt]+val);
		}
	}
	lpri(dp[n][w]);
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;
const long double PI=3.14159265358979;

int main() {
  int S,W;
  cin>>S>>W;
  if(S<=W){
    cout<<"unsafe";
  }
  else{
    cout<<"safe";
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    int x;
    cin >> x;
    int ans;
    ans = x / 500;
    ans *= 1000;
    x %= 500;
    ans += (x / 5) * 5;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int h,w;
char a[10][10];
bool ans;
int d;


int main(){
  cin>>h>>w;
  rep(i,h){
    cin>>a[i];
    rep(j,w){
      if(a[i][j]=='#') d++;
    }
  }

  int b[10][10];
  rep(i,h)rep(j,w) b[i][j]=inf;

  b[0][0] = 1;
  queue<P> q;
  q.push(P(0,0));

  while(!q.empty()){
    P p = q.front(); q.pop();
    int x = p.first,y = p.second;
    if(a[y+1][x]=='#'&&b[y+1][x]>b[y][x]){
      b[y+1][x] = b[y][x]+1;
      q.push(P(x,y+1));
    }
    if(a[y][x+1]=='#'&&b[y][x+1]>b[y][x]){
      b[y][x+1] = b[y][x]+1;
      q.push(P(x+1,y));
    }
  }

  if(b[h-1][w-1]==d)
    cout<<"Possible"<<endl;
  else
    cout<<"Impossible"<<endl;

  return 0;
}

  


Measured memory_bytes: 892
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
q = int(input())
info = []
for i in range(q):
    info.append(list(map(int, input().split())))

a_dict = dict()
for num in a:
    if num in a_dict.keys():
        a_dict[num] += 1
    else:
        a_dict[num] = 1

a_key = list(a_dict.keys())
a_value = list(a_dict.values())
ans = 0
for k in range(len(a_dict)):
    ans += a_key[k] * a_value[k]

for j in range(q):
    if info[j][0] in a_dict.keys():
        if info[j][1] in a_dict.keys():
            ans -= info[j][0] * a_dict[info[j][0]]
            ans += info[j][1] * a_dict[info[j][0]]
            a_dict[info[j][1]] += a_dict[info[j][0]]
            del a_dict[info[j][0]]
        else:
            ans -= info[j][0] * a_dict[info[j][0]]
            a_dict[info[j][1]] = a_dict[info[j][0]]
            ans += info[j][1] * a_dict[info[j][1]]
            del a_dict[info[j][0]]


    print(ans)

Measured memory_bytes: 97484
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <ctime>
#include <cstring>
using namespace std;

int n;


int main(void){

	cin >> n;
	int suji[n];
	int	num[n];
	int adj[n][n];
	int ans[n][n];

	

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

		
		for(int j = 0; j < num[i]; j++){
			cin >> adj[i][j];
			adj[i][j] -= 1;
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			ans[i][j] = 0;
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < num[i]; j++){
			ans[i][adj[i][j]] = 1;
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(j == n - 1){
				cout << ans[i][j] << endl;
			}else{
				cout << ans[i][j] << " ";
			}
		}
	}



	
    return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)
#define all(a) a.begin(), a.end()
#define gr greater<LL>()

using namespace std;

long long gcd(long long a, long long b) {
  long long _max = a > b ? a : b;
  long long _min = a > b ? b : a;
  if (!(_max%_min)) return _min;
  else return gcd(_min, _max%_min);
}
 
long long lcm(long long a, long long b) {
  return a/gcd(a,b)*b;
}

const string NO = "IMPOSSIBLE";

void solve(long long A, long long B){
    if((A+B)%2==1)cout << NO << endl;
    else cout << (A+B)/2 << endl;
}

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


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

using namespace std;

const int MAX_N = 100000;
int n;
pair<int, int> l[MAX_N], r[MAX_N];
bool used[MAX_N];

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++) {
    l[i].second = r[i].second = i;
    cin >> l[i].first >> r[i].first;
  }

  sort(l, l+n);
  reverse(l, l+n);
  sort(r, r+n);

  fill_n(used, n, false);
  int64_t d = 0;
  int ri = 0, li = 0, flag = 0;
  int pos = 0;
  for (int i = 0; i < n; i++) {
    if (flag == 0) {
      while (li < n && used[l[li].second]) li++;
      if (li >= n || l[li].first <= pos) break;
      d += l[li].first - pos;
      pos = l[li].first;
      used[l[li].second] = true;
    } else {
      while (ri < n && used[r[ri].second]) ri++;
      if (ri >= n || r[ri].first >= pos) break;
      d += pos - r[ri].first;
      pos = r[ri].first;
      used[r[ri].second] = true;
    }
    flag ^= 1;
  }
  d += abs(pos);

  fill_n(used, n, false);
  int64_t temp = 0;
  ri = 0, li = 0, flag = 1;
  pos = 0;
  for (int i = 0; i < n; i++) {
    if (flag == 0) {
      while (li < n && used[l[li].second]) li++;
      if (li >= n || l[li].first <= pos) break;
      temp += l[li].first - pos;
      pos = l[li].first;
      used[l[li].second] = true;
    } else {
      while (ri < n && used[r[ri].second]) ri++;
      if (ri >= n || r[ri].first >= pos) break;
      temp += pos - r[ri].first;
      pos = r[ri].first;
      used[r[ri].second] = true;
    }
    flag ^= 1;
  }

  d = max(d, temp+abs(pos));

  cout << d << endl;

  return 0;
}


Measured memory_bytes: 1920
MOD = 10**9+7


def main():
    N = int(input())
    A = list(map(int, input().split()))
    prodasc = [1] * (N+1)
    prodesc = [1] * (N+1)
    for i in range(N):
        prodasc[i+1] = (prodasc[i] * (i+1)) % MOD
        prodesc[i+1] = (prodesc[i] * (N-i)) % MOD
    inv = [1] * (N+1)
    for i in range(1, N+1):
        inv[i] = (prodasc[i-1] * prodesc[N-i]) % MOD
    cumsum = [0] * N
    for i in range(1, N):
        cumsum[i] = (cumsum[i-1] + inv[i+1]) % MOD

    ans = 0
    for i in range(N):
        ans = (ans + A[i] * (prodasc[N] + cumsum[i] + cumsum[N-1-i])) % MOD
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 62576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 1024
#define M 4096
int a[N];
int d[N] = {};
int dp[N][M] = {};

vi v;
 
int main(){
	int n, m; scanf("%d%d", &n, &m);
	REP(i, m){
		int b; scanf("%d%d", a+i, &b);
		REP(j, b){
			int c; scanf("%d", &c); c--;
			d[i] |= 1<<c;
		}
		// DEBUG("d[%d] = %d\n", i, d[i]);
	}

	REP(i, M) v.EB(i);
	sort(ALL(v), [](auto &x, auto &y){
			return __builtin_popcount(x) > __builtin_popcount(y);
			});
	// for(int &i : v) DEBUG("%d ", i);

#define INF 1<<30
	fill(dp[0]+1, dp[0]+M, INF);
	REP(i, m){
		REP(j, 1<<n){
			dp[i+1][j] = dp[i][j];
			if( (j & d[i]) == d[i]){
				SML(dp[i+1][j], dp[i][j ^ d[i]] + a[i]);
			}
			DEBUG("dp(%d, %d) = %d\n", i+1, j, dp[i+1][j]);
		}
		for(int &j : v){
			if(j >= (1<<n)) continue;
			REP(k, n){
				SML(dp[i+1][j], dp[i+1][j|(1<<k)]);
			}
		}
		REP(j, 1<<n){
			DEBUG("dp(%d, %d) = %d\n", i+1, j, dp[i+1][j]);
		}
	}
	int ans = dp[m][(1<<n) - 1];
	if(ans >= INF) ans = -1;
	printf("%d\n", ans);
}


Measured memory_bytes: 16640
n = int(input())
Dup = []

for i in range(n):
    a = int(input())
    Dup.append([])
    for j in range(a):
        x,y = map(int, input().split())
        Dup[-1].append((x-1,y))

def is_honest (i,j):
    return (i >> j)%2 == 1

def honest_cnt(i):
    ans = 0
    for j in range(n):
        ans += is_honest(i,j)
    return ans

ans = 0

for i in range(1 << n):
    ok = True
    for j in range(n):
        if not is_honest(i,j):continue

        for x,y in Dup[j]:
            if y == 0 and is_honest(i,x): ok = False
            if y == 1 and not is_honest(i,x): ok = False

    if ok:
        ans = max(ans,honest_cnt(i))

print(ans)

Measured memory_bytes: 9136
x1, y1, x2, y2 = gets.split.map(&:to_i)
dx = x2 - x1
dy = y2 - y1

x3 = x2 - dy
y3 = y2 + dx
x4 = x3 - dx
y4 = y3 - dy

puts "#{x3} #{y3} #{x4} #{y4}"

Measured memory_bytes: 1788
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  string S; cin >> S;
  int L = S.size();
  int vmin = 1e9;
  for (int i = 0; i + 2 < L; ++i) {
    int v = stoi(S.substr(i, 3));
    vmin = min(vmin, abs(753 - v));
  }
  cout << vmin << endl;
}


Measured memory_bytes: 3556
import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def debug_print(maze):
    for xx in maze:
        for yy in xx:
            print(yy,end="")
        print("\n",end="")

def clear_maze(sx, sy, gx, gy, maze):
#    debug_print(maze)
    INF = 100000000
    field_x_length = len(maze)
    field_y_length = len(maze[0])
    distance = [[INF for i in range(field_y_length)] for j in range(field_x_length)]
    def bfs():
        queue = []
        queue.insert(0, (sx, sy))
        distance[sx][sy] = 0
        while len(queue):
            x, y = queue.pop()
            if x == gx and y == gy:
                break
            for i in range(0, 4):
                nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]
                if (0 <= nx and nx < field_x_length and 0 <= ny and ny < field_y_length and maze[nx][ny] != '#' and distance[nx][ny] == INF):
                    queue.insert(0, (nx, ny))
                    distance[nx][ny] = distance[x][y] + 1
        if distance[H-1][W-1] == INF:
            print(-1)
            exit()
        return distance[gx][gy] 
    return bfs()

H,W = Is()
maze = []
for _ in range(H):
    maze.append(list(S()))
sx, sy = 0, 0 # スタート地点の座標
gx, gy = H-1, W-1 # ゴール地点の座標
a = clear_maze(sx, sy, gx, gy, maze)
for i in range(H):
    a += maze[i].count("#")
print(H*W-a-1)


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

int main() {
    int n;
    cin>>n;
    int a[n];
    int dp[n] = {0};
    for(int i = 0 ; i < n ; i++){
        cin>>a[i];
    }
    for(int i = n - 2; i >= 0 ; i--){
        int mini = INT_MAX;
        for(int j = i + 1; j <= i +2 && j < n;j++){
            mini = min(mini, max(a[j] - a[i], a[i] - a[j]) + dp[j]);
        }
        dp[i] = mini;
    }
    cout<<dp[0];
	// your code goes here
	return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
using namespace std;
//
const int inf=1e9+7;//0x3f
//
int N;
long long H[5000],P[5000];
long long DP[5001][5001];
int main(){
	cin>>N;
	vector<pair<long long,int>> V;
	for(int i=0;i<N;i++){
		cin>>H[i]>>P[i];
		V.push_back(make_pair(H[i]+P[i],i));
	}
	sort(V.begin(),V.end());
	for(int i=0;i<=N;i++){
		for(int j=0;j<=N;j++){
			DP[i][j]=1e18+7;
		}
	}
	DP[0][0]=0;
	for(int i=0;i<N;i++){
		for(int j=0;j<=i;j++){
			DP[i+1][j]=min(DP[i][j],DP[i+1][j]);
			if(DP[i][j]<=H[V[i].second]){
				DP[i+1][j+1]=min(DP[i+1][j+1],DP[i][j]+P[V[i].second]);
			}
		}
	}
	int ans=0;
	for(int i=0;i<=N;i++){
		if(DP[N][i]!=1e18+7){
			ans=i;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 195968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
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; }

int main(void) {
    int n,m;
    cin>>n>>m;
    vector<vector<int>> jobs(m);
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(a>m) continue;
        jobs[m-a].push_back(b);
    }
    priority_queue<int> q;
    ll ans=0;
    for(int i=m-1;i>=0;i--){
        for(int b : jobs[i]){
            q.push(b);
        }
        if(!q.empty()){
            ans+=q.top();
            q.pop();
        }
    }
    cout<<ans<<endl;
}

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

int main(){
    
    string S;
    cin >> S;
    
    int i, l, count, max;
    l = S.length();
    count = 0;
    max = 0;
    
    for (i = 0; i < l; i++){
        
        if (S.at(i) == 'S'){
            count = 0;
        } else {
            count += 1;
            if (count > max) max = count;
        }
    }
    
    cout << max << "\n";
    
    return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    int D, T, S;
    cin >> D >> T >> S;
    puts(T * S >= D ? "Yes" : "No");
}

Measured memory_bytes: 3644