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

#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
#define input freopen("input.txt","r",stdin);
#define output freopen("output.txt","w",stdout);
#define fast_io ios::sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
#define fix cout << fixed << setprecision(15);
//#define left left228
//#define right right228
//#define next next228
#define rank rank228
//#define prev prev228
#define y1 y1228
#define dout if(debug) cout
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int> ;
using pll = pair<ll, ll>;
using pci = pair<char, int>;
using vi = vector<int> ;
using vll = vector<ll> ;
using vpii = vector<pii> ;
const ll infll = 1e18 + 3;
const int maxn = 1e6 + 77;
const int nmax = 1e6 + 577;
const ll basell = 1e18 + 3;
const int mod = 1e9 + 7;
const ld eps = 1e-7;
const int inf = 1009000999;
const int nv = 100505;
const int baseint = 1000200013;
const ld PI = acos(-1.0);
inline bool EQ(ld a, ld b) { return fabs(a-b) < 1e-9; }
inline bool IF(int a, int b, int c) { return (a >= b && a <= c); }
inline bool IFS(int a, int b, int c) { return (a > b && a < c); }
template<typename T> inline istream &operator>> (istream &_in, vector<T> &_v) { for (auto &_i : _v) { _in >> _i; } return _in; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
//typedef pair<int, int> pt;
//#define x first
//#define y second
//ifstream cin("input.txt");
//ofstream cout("output.txt");
/*
sort(a, a + n, [&](pair<pt, int> a, pair<pt, int> b){if (a.x.x != b.x.x)
        return a.x.x < b.x.x; return a.x.y > b.x.y;});
for(int c : s)
for(int &i : a) cin >> i;
for(int c = 'a'; c <= 'z'; ++c)
vector<vector<ll>> dp(n, vector<ll>(n+2));
__int128;
char 0 = int 48;
char c = cin;
int h = (int)c - 48;
*/

/*char memory[(int)1e8];

char memorypos;

inline void * operator new(size_t n){
    char * ret = memory + memorypos;
    memorypos += n;
    return (void *)ret;
}

inline void operator delete(void *){}
*/

ll dp[200][nv];

ll w[nv], val[nv];

int inline solve() {
    //input;//,output;
    //fix;
    fast_io;
    int n, W;
    cin >> n >> W;
    for (int i = 1; i <= n; ++i) {
        cin >> w[i] >> val[i];
    }
    for (int j = 1; j <= n; ++j) {
        for (int i = 0; i <= W; ++i) {
            if(w[j] > i) {
                dp[j][i] = dp[j - 1][i];
            } else {
                dp[j][i] = max(dp[j - 1][i - w[j]] + val[j], dp[j - 1][i]);
            }
        }
    }
    cout << dp[n][W];
    return 0;
}

int32_t main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
    return 0;
}
/*
6
2 1 6 3 4 5
2 1 3 4 5 6
6 0
1 7 8 2 4 6
 * */

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

int main()
{
   double x,y,z;
   cin>>x;
   for(int i=1;i<=x;i++)
    if(i%2!=0)
        y++;
    
   z=y/x;
   cout<<fixed<<setprecision(12)<<z<<endl;
    return 0;
}



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

int main(){
  int N,Q; cin >> N >> Q;
  vector<vector<int>> e(N,vector<int>());
  for(int i=0; i<N-1; i++){
    int a,b; cin >> a >> b;
    e[a-1].push_back(b-1);
    e[b-1].push_back(a-1);
  }
  vector<int> px(N,0);
  for(int i=0; i<Q; i++){
    int p,x; cin >> p >> x;
    px[p-1]+=x;
  }
  
  vector<int> result(N,-1);
  queue<int> q;
  result[0]=px[0];
  q.push(0);
  while(!q.empty()){
    int c=q.front();
    for(auto d:e[c]){
      if(result[d]<0){
        result[d]=result[c]+px[d];
        q.push(d);
      }
    }
    q.pop();
  }
  
  for(int i=0; i<N; i++){
    cout << result[i] << (i==N-1?"\n":" ");
  }
}

Measured memory_bytes: 16372
#include <bits/stdc++.h>
#define int int64_t
using namespace std;

signed main() {
	int r;
	cin >> r;
	double pi = 3.1415926 , ans;
	ans = 2*pi*r;
	cout << fixed << setprecision(2) << ans << "\n";

	return 0;
}


Measured memory_bytes: 3784
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

fn dfs(g: &[Vec<(usize, i64)>], v: usize, par: usize, col: &mut [i64], dist: i64) {
    col[v] = dist % 2;
    for &(w, c) in &g[v] {
        if par == w { continue; }
        dfs(g, w, v, col, dist + c);
    }
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        uvw: [(usize1, usize1, i64); n - 1],
    }
    let mut g = vec![vec![]; n];
    for &(u, v, w) in &uvw {
        g[u].push((v, w));
        g[v].push((u, w));
    }
    let mut col = vec![0; n];
    dfs(&g, 0, n, &mut col, 0);
    for c in col { puts!("{}\n", c); }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 25084
n=int(input())
a=input()
b=input()
c=input()
ans=0
for i in range(n):
    if a[i]==b[i]==c[i]:
        ans+=0
    elif a[i]==b[i]:
        ans+=1
    elif b[i]==c[i]:
        ans+=1
    elif a[i]==c[i]:
        ans+=1
    else:
        ans+=2
print(ans)

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

n_100 = n // 100
# print(n_100)
n_10 = (n - (n_100 * 100)) // 10
# print(n_10)
n_1 = (n - (n_100 * 100) - (n_10 * 10)) // 1
# print(n_1)

if n_100 == 7 or n_10 == 7 or n_1 == 7:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9112
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()

	s := readString()
	t := make([]rune, 0)

	push := func(r rune) {
		t = append(t, r)
	}
	peek := func() rune {
		return t[len(t)-1]
	}
	pop := func() {
		t = t[:len(t)-1]
	}
	empty := func() bool {
		return len(t) == 0
	}

	var count int
	for _, r := range s {
		if !empty() {
			if peek() != r {
				count += 2
				pop()
				continue
			}
		}
		push(r)
	}
	println(count)
}

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


Measured memory_bytes: 3328
import math
a, b, C = map(float, input().split())
C *= math.pi / 180
c = (a**2 + b**2 - 2*a*b*math.cos(C))**0.5
h = b * math.sin(C)
S = a * h * 0.5
L = a + b + c

print("{:.8f}".format(S))
print("{:.8f}".format(L))
print("{:.8f}".format(h))



Measured memory_bytes: 5704
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long
#define lfl long double

int n;
int o[100001];
int e[100001];
vector<int> oo[200001];
vector<int> ee[200001];

int main(void)
{
    cin >> n;
    rep(i,n)
    {
        int v;
        cin >> v;
        if(i % 2 == 0)
            e[v]++;
        else
            o[v]++;
    }

    rep(i, 100001)
    {
        oo[o[i]].push_back(i);
        ee[e[i]].push_back(i);
    }

    int o1 = -1;
    int o2 = -1;
    int e1 = -1;
    int e2 = -1;

    for(int i = 200000; i >= 0; i--)
    {
        if(oo[i].size() > 0)
        {
            if(o1 < 0)
                o1 = i;
            else if(o2 < 0)
                o2 = i;
        }
        
        if(ee[i].size() > 0)
        {
            if(e1 < 0)
                e1 = i;
            else if(o2 < 0)
                e2 = i;
        }
    }

    if(oo[o1].size() == 1 && ee[e1].size() == 1 && oo[o1][0] == ee[e1][0])
    {
        int res1 = n - o1 - e2;
        int res2 = n - o2 - e1;
        int res = min(res1, res2);
        cout << res << endl;
    }
    else
    {
        int res = n - o1 - e1;
        cout << res << endl;
    }

    return 0;
}


Measured memory_bytes: 11480
#include <cstdio>
#include <algorithm>
#include <map>
#include <string>
#include <iostream>
#include <cstring>
typedef long long ll;
int dx[] = { 0,1,0,-1 }, dy[] = {-1, 0, 1, 0};

using namespace std;
int main() {
    ll H, W, L;
    while (cin >> H >> W >> L, H) {
        string field[100];
        for (int i = 0; i < H; i++) {
            cin >> field[i];
        }

        int x, y, dir;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (field[i][j] == 'N') x = j, y = i, dir = 0;
                if (field[i][j] == 'E') x = j, y = i, dir = 1;
                if (field[i][j] == 'S') x = j, y = i, dir = 2;
                if (field[i][j] == 'W') x = j, y = i, dir = 3;
            }
        }

        ll memo[100][100][4];
        memset(memo, -1, sizeof memo);
        memo[y][x][dir] = 0;

        ll c = 0, rem = L;
        while (rem > 0) {
            int nx = x + dx[dir], ny = y + dy[dir];
            while (nx < 0 || W <= nx || ny < 0 || H <= ny || field[ny][nx] == '#') {
                dir = (dir + 1) % 4;
                nx = x + dx[dir], ny = y + dy[dir];
            }

            c++;
            rem--;
            x = nx;
            y = ny;

            if (memo[y][x][dir] == -1){
                memo[y][x][dir] = c;
            }
            else {
                ll loop = c - memo[y][x][dir];
                if (rem >= loop) rem %= loop;
            }
        }

        string s = "NESW";
        cout << y + 1 << " " << x + 1 << " " << s[dir] << endl;
    }

}

Measured memory_bytes: 3480
/*
       Hi there <3 
──────▄▀▄─────▄▀▄
─────▄█░░▀▀▀▀▀░░█▄
─▄▄──█░░░░░░░░░░░█──▄▄
█▄▄█─█░░▀░░┬░░▀░░█─█▄▄█

*/
#include <bits/stdc++.h>
#define MOD 1000000007
#define re return
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define y0 y32479
#define y1 y95874
#define next next239
#define prev prev239
#define fill(x, y) memset(x, y, sizeof(x))
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define ba back()
#define popcount __builtin_popcountll
#define fastIO()                 \
    {                            \
        ios::sync_with_stdio(0); \
        cin.tie(0);              \
        cout.tie(0);             \
    }
#define in(x) \
    int x;    \
    cin >> x;
#define in1(x) \
    int x;     \
    cin >> x;  \
    x--;
#define inll(x) \
    ll x;       \
    cin >> x;
#define ins(x) \
    string x;  \
    cin >> x;

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef pair<double, double> pdd;
typedef long double LD;
typedef double D;

void Solve()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> v(n, 0);
    for (int i = 0; i < n; i++)
        cin >> v[i];

    bool vis[n];
    for (int i = 0; i < n; i++)
        vis[i] = false;

    int i = 0;
    int count = 0;
    int withoutloop = 0;
    int loopcount = 0;
    bool flag = false;
    while (count < n * n || flag)
    {
        if (vis[i])
        {
            if (flag)
            {
                break;
            }
            for (int j = 0; j < n; j++)
                vis[j] = false;
            flag = true;
            withoutloop = count;
        }
        else
        {
            vis[i] = true;
            i = v[i] - 1;
            if (flag)
                loopcount++;
            count++;
        }
    }

    //cout << loopcount << " " << withoutloop << endl;
    if (k - withoutloop > 0)
    {
        k = k - withoutloop;
        i = 0;
        for (int j = 0; j < withoutloop; j++)
        {
            i = v[i] - 1;
        }
        k = k % loopcount;
        for (int j = 0; j < k; j++)
        {
            i = v[i] - 1;
        }
        cout << i + 1 << endl;
    }
    else
    {
        i = 0;
        for (int j = 0; j < k; j++)
        {
            i = v[i] - 1;
        }
        cout << i + 1 << endl;
    }
}

int main()
{
    fastIO();
    int t;
    t = 1;
    while (t--)
    {
        Solve();
    }
    return 0;
}

Measured memory_bytes: 5048
import java.util.*;
public class Main {
	
	static int mod = (int)1e9+7;
	
	public static void main(String[] args) {		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long A[] = new long[N];
		for(int i=0;i<N;i++)A[i]=sc.nextLong();
		sc.close();

		long ans = 0;
		for(int i=0;i<60;i++) {
			int cnt = 0;
			for(int j=0;j<N;j++) {
				if(((A[j]>>i)&1)==1) cnt++;
			}
			long tmp = (long)cnt*(N-cnt) %mod;
			long mul = ((long)1<<i)%mod;
			//long mul = (long)Math.pow(2, i) % mod;
			ans += (tmp * mul % mod);
			ans %= mod;	
		}
		System.out.println(ans);
	}
	
}

Measured memory_bytes: 97276
import sys
from itertools import combinations
input = sys.stdin.readline

N = int(input())
leng = len(str(N))
if leng <= 2:
    print(0)
    exit()

def f(N, l, stri):
    if l == 0:
        if int(stri) <= N and '7' in stri and '5' in stri and '3' in stri:
            return 1
        else:
            return 0
    ans = 0
    for i in ['7', '5', '3']:
        ans += f(N, l-1, stri + i)
    return ans

ans = 0
for l in range(3, leng+1):
    ans += f(N, l, '')

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll INF = LLONG_MAX/3;

int main(){
    int n,m;
    cin >>n >>m;

    vector<int> L(m),R(m),C(m);
    rep(i,m){
        cin >>L[i] >>R[i] >>C[i];
        --L[i];
        --R[i];
    }

    vector<vector<int>> B(n);
    rep(i,m){
        B[L[i]].pb(i);
    }

    vector<ll> dp(n,INF);
    dp[0] = 0;

    vector<vector<ll>> drop(n);
    multiset<ll> s;
    for(int i=1; i<n; ++i){
        for(int idx:B[i-1]){
            ll val = dp[i-1]+C[idx];
            s.insert(val);
            drop[R[idx]].pb(val);
        }
        // dbg((vector<ll>(all(s))));

        if(!s.empty()) dp[i] = min(dp[i], *s.begin());

        for(ll v:drop[i]) s.erase(s.find(v));
    }

    ll ans = dp[n-1];
    if(ans == INF) ans = -1;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 12928
#include<iostream>
#include<stdio.h>

using namespace std;

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

  int n, k;
  string s;

  cin >> n;
  cin >> k;
  cin >> s;

  if(s[k-1] == 'A'){
    s[k-1] = 'a';
  }else if(s[k-1] == 'B'){
    s[k-1] = 'b';
  }else{
    s[k-1] = 'c';
  }

  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 256
import math
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    j = math.ceil((N+1)**0.5)

    ans = [0] * (N+1)
    for x in range(1,j+1):
        for y in range(1,j+1):
            for z in range(1,j+1):
                n = x**2+y**2+z**2+x*y+y*z+z*x
                if 1<=n<=N:
                    ans[n] += 1
            
        
    print(*ans[1:],sep="\n")

                


if __name__ == "__main__":
    main()


Measured memory_bytes: 9768
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

var S = readLine()!.toArray()
var output = "yes"
for _ in 0..<S.count {
    let c = S.last!
    S.removeLast()
    if S.contains(c) {
        output = "no"
        break
    }
}
print(output)


Measured memory_bytes: 2524
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			solveA();
			//			 solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		String res = next().substring(0, 1) + next().substring(0, 1) + next().substring(0, 1);

		out.println(res);
	}

	private void solveB() {
		int numN = nextInt();

		out.println("");
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 21076
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    C = S()
    print(str(chr(ord(C)+1)))

main()



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

using namespace std;

const int mod=1000000007;

int main(){
  int n;
  cin >> n;
  
  string s;
  cin >> s;
  
  vector<long> cnt(26,0);
  for(int i=0;i<n;i++) cnt[s[i]-'a']++;
  
  long res=1;
  for(int i=0;i<26;i++) {res*=(cnt[i]+1);
                         res%=mod;
                        }

  cout << res-1 << endl;
}

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

int main()
{
    int number;
    int a,b,c,d;
    cin >> number;
    d = number % 10;
    c = number / 10 % 10;
    b = number /100 % 10;
    a = number /1000;
    //cout << "a=" << a << "b=" << b << "c=" << c << "d= "<< d;
    if (a + b + c + d == 7)
    {
        cout << a << "+" << b << "+" << c << "+" << d << "=7";
    }
    else if (a + b + c - d == 7)
    {
        cout << a << "+" << b << "+" << c << "-" << d << "=7";
    }
    else if (a + b - c + d == 7)
    {
        cout << a << "+" << b << "-" << c << "+" << d << "=7";
    }
    else if (a + b - c - d == 7)
    {
        cout << a << "+" << b << "-" << c << "-" << d << "=7";
    }
    else if (a - b + c + d == 7)
    {
        cout << a << "-" << b << "+" << c << "+" << d << "=7";
    }
    else if (a - b + c - d == 7)
    {
        cout << a << "-" << b << "+" << c << "-" << d << "=7";
    }
    else if (a - b - c + d == 7)
    {
        cout << a << "-" << b << "-" << c << "+" << d << "=7";
    }
    else if (a - b - c - d == 7)
    {
        cout << a << "-" << b << "-" << c << "-" << d << "=7";
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	lint a;
	string b;
	cin>>a>>b;
	b.erase(1,1);
	int B=stoi(b);
	cout<<(a*B)/100<<endl;
}

Measured memory_bytes: 3656
n = int(input())
m,a,r,c,h = 0,0,0,0,0
for _ in range(n):
  s = input()
  if s[0]=='M':m+=1
  elif s[0]=='A':a+=1
  elif s[0]=='R':r+=1
  elif s[0]=='C':c+=1
  elif s[0]=='H':h+=1

cnt = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h
print(cnt)

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

int main() {
    ll a,b,c,x,y,ans=0;
    cin>>a>>b>>c>>x>>y;

    if(a+b<c*2){
        ans=a*x+b*y;
    }

    else if((x>y&&a>2*c)||(x<y&&b>2*c)){
        ans=max(x,y)*2*c;
    }

    else if(x==y){
        ans=x*2*c;
    }

    else if(x>y){
        ans=y*2*c+(x-y)*a;
    }

    else if(x<y){
        ans=x*2*c+(y-x)*b;
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
  ll L,R;
  cin>>L>>R;
  if(R-L>=2019) cout<<0;
  else{
    ll m=2018;
    for(ll i=L;i<=R;i++)for(ll j=i+1;j<=R;j++) m=min(m,i*j%2019);
    cout<<m;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MD=998244353;
const int N=5e5+5;
int fac[N],inv[N],n,m;
void add(int &x,int y) {
	x+=y;
	if(x>=MD) x-=MD;
	if(x<0) x+=MD;
}
int quick_pow(int x,int y) {
	int ans=1;
	while(y) {
		if(y&1) ans=1LL*ans*x%MD;
		y>>=1;
		x=1LL*x*x%MD;
	}
	return ans;
}
void init() {
	fac[0]=1;
	for(int i=1;i<N;i++) fac[i]=1LL*fac[i-1]*i%MD;
	inv[N-1]=quick_pow(fac[N-1],MD-2);
	for(int i=N-2;i>=0;i--) inv[i]=1LL*inv[i+1]*(i+1)%MD;
}
int C(int n,int m) {
	return 1LL*fac[n]*inv[m]%MD*inv[n-m]%MD;
}
int main() {
	init();
	scanf("%d%d",&n,&m);
	if(n>m) swap(n,m);
	int ans=0;
	for(int i=0;i<=n;i++) {
		add(ans,1LL*C(n,i)*C(m,i)%MD*fac[i]%MD*quick_pow(m+1,n-i)%MD*quick_pow(n+1,m-i)%MD*(i&1?-1:1));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;

const int MAX = 1000010;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

  COMinit();

  int N;
  cin >> N;
  int A[N];
  map<int, int> mp;
  int gcd = 1;
  rep(i,N){
    cin >> A[i];
    int M = A[i];
    for(int j=2;j*j<=A[i];j++){
      int count = 0;
      while(true){
        if(M % j == 0){
          M /= j;
          count++;
        }
        else break;
      }
      if(count > mp[j]){
        rep(k,count-mp[j]){
          gcd *= j;
        }
        mp[j] = count;
      }
      if(M == 1) break; 
    }
    if(M != 1){
      if(!mp[M]){
        gcd *= M;
        mp[M]++;
      }
    }
    gcd %= MOD;
  }
  int ans = 0;
  rep(i,N){
    ans += gcd * inv[A[i]];
    ans %= MOD;
  }
  cout << ans << endl;
}

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

namespace ConsoleApp86 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = st[0];
            int M = st[1];
            int mod = 1000000007;

            var a = new int[M + 3];
            a[0] = -1;
            a[1] = 0;
            a[2] = 0;
            for (int i = 1; i <= M; i++) {
                a[i] = int.Parse(Console.ReadLine());
            }
            a[M + 1] = N + 1;

            var X = new int[N + 1];
            X[0] = 1;
            X[1] = 1;
            for (int i = 2; i <= N; i++) {
                X[i] = (X[i - 2] % mod + X[i - 1] % mod) % mod;
            }

            //Console.WriteLine("Xの配列は" + string.Join(" ", X));
            //Console.WriteLine("aの配列は" + string.Join(" ", a));

            long ans = 1;

            if (M == 0) {
                Console.WriteLine(X[N]);
                return;
            }

            if (N == 1) {
                Console.WriteLine(1);
                return;
            }
            if (N == 2) {
                if (M == 0) {
                    Console.WriteLine(2);
                    return;
                } else if (M == 1) {
                    Console.WriteLine(1);
                    return;
                } else {

                }
            }

            for (int i = 1; i <= M + 1; i++) {
                //Console.WriteLine("X[" + (a[i] - a[i - 1] - 1) + "] = " + X[a[i] - a[i - 1] - 1] + "を掛けました");

                if (a[i] - a[i - 1] >= 2) {
                    ans *= X[a[i] - a[i - 1] - 2];
                    ans %= mod;
                }

                if (a[i] - a[i - 1] == 1) {
                    ans *= 0;
                    Console.WriteLine(0);
                    return;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13920
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
ll a,b,c;

int main(){
	cin >> a >> b >> c;
	
	ll mi=min(a*c*(b/2+b%2)-a*c*(b/2),a*b*(c/2+c%2)-a*b*(c/2));
	mi=min(mi, min(b*c*(a/2+a%2)-b*c*(a/2), a*b*(c/2+c%2)-a*b*(c/2)));
	mi=min(mi, min(c*b*(a/2+a%2)-c*b*(a/2), a*c*(b/2+b%2)-a*c*(b/2)));
	cout << mi << endl; 
	return 0;
}



Measured memory_bytes: 256
L=[0 for i in range(4)]
for i in range(3):
    a,b=map(int,input().split())
    L[a-1]+=1
    L[b-1]+=1
X=sorted(L)
Y=[1,1,2,2]
for i in range(4):
    if X[i]!=Y[i]:
        print("NO")
        exit()
print("YES")


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

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
  cin >> s;
   if(s == "SUN" ) cout << "7" ;
  else if (s == "MON") cout << "6" ;
    else if (s == "TUE") cout << "5" ;
  else if (s == "WED") cout << "4" ;
  else if (s == "THU") cout << "3" ;
  else if (s == "FRI") cout << "2" ;
  else cout << "1" ;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    string S; cin >> S;
    S += '@';
    int ans = 0;
    for (int i = 1; i < S.size(); i++) {
        if (S[i - 1] != S[i]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<double> vd;

int main() {
    int i, n;
    double d, x;
    scanf("%d%lf%lf", &n, &d, &x);
    vd f(n+1), s(n+1);
    for(i=1; i<=n; i++) {
        f[i]=(i+1)/2.0+2*s[i-1]/i;
        s[i]=s[i-1]+f[i];
    }
    printf("%.12lf\n", f[n]*(d+(n-0.5)*x));
    return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Idx{
public:
    int ptr=0;
    map<pair<int,int>,int>idx;
    int getIdx(int u,int v){
        if(u>v)swap(u,v);
        if(idx.find({u,v})==idx.end())idx[{u,v}]=ptr++;
        return idx[{u,v}];
    }
};
class Solver{
public:
    static const int MAXN=5e5+10;;
    static const int INF=0x3f3f3f3f;
    int N;
    vector<int>G[MAXN];
    int dgr[MAXN];
    int level[MAXN];
    Idx *idx;
    int maxCnt=-1;
    void toplo(){
        queue<int>q;
        for(int u=0;u<idx->ptr;u++){
            if(dgr[u]==0){
                level[u]=1;
                q.push(u);
            }
        }
        while(!q.empty()){
            int t=q.front();
            q.pop();
            for(auto nxt:G[t]){
                dgr[nxt]--;
                if(dgr[nxt]==0){
                    q.push(nxt);
                    level[nxt]=level[t]+1;
                }
            }
        }
    }
    void solve(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        idx=new Idx();
        cin>>N;
        for(int u=1;u<=N;u++){
            int head;
            for(int v=1;v<N;v++){
                int x;
                cin>>x;
                if(v==1)head=x;
                else {
                    G[idx->getIdx(u,head)].push_back(idx->getIdx(u,x));
                    dgr[idx->getIdx(u,x)]++;
                    head=x;
                }
            }
        }
        toplo();
        int ans=-1;
        for(int u=0;u<idx->ptr;u++){
            if(dgr[u]){
                cout<<-1;
                return;
            }
            ans=max(ans,level[u]);
        }
        cout<<ans;
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
} 

Measured memory_bytes: 64384
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {
	int n, k, batas, sum = 0;
	char s[100010];
	scanf("%d %d %s", &n, &k, s);
	for (int i = 0; i < n; i++) {
		batas = i;
		while (batas + 1 < n) {
			if (s[batas + 1] != s[batas])
				break;
			batas++;
		}
		sum += (batas - i);
		i = batas;
	}
	sum = min(n - 1, sum + k + k);
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
const int INF = 0x3f3f3f3f;

int n, pos;
vector<int > pre, in, post;

void rec(int l, int r){
	if(l >= r)	return ;
	int root = pre[pos++];
	int m = distance(in.begin(), find(in.begin(), in.end(), root));
	rec(l, m);
	rec(m + 1, r);
	post.push_back(root);
}

void solve(){
	pos = 0;
	rec(0, pre.size());
	for(int i = 0; i < n; i++){
		if(i)	printf(" ");
		cout << post[i];
	}
	printf("\n");
}

int main(){
	int temp;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> temp;
		pre.push_back(temp);
	}
	for(int i = 0; i < n; i++){
		cin >> temp;
		in.push_back(temp);
	}
	solve();
	return 0;
}

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

using namespace std;
int n,m;


int a[100110];
int main()
{
    cin>> n>> m;
for(int i =0;i<m;i++){
    cin>>a[i];
   }
   int s =0;
   for(int i =0;i<m;i++){
 s+=a[i];
   }
if(s>n){
    cout<<-1<<endl;
}
else{
    cout<< n-s<<endl;
}


    return 0;
}


Measured memory_bytes: 3640
#1_7_B
import itertools
while True:
    n , x = map(int,input().split())
    if n == x == 0:
        break
    l =[]
    for j in range(1 , n+1):
        l.append(j)

    li =  [i for i in itertools.combinations(l, 3)]
    y = len(li)
    s = 0
    for j in range(y):
        if sum(li[j]) == x:
            s += 1
    print(s)


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

using namespace std;

int main(void){
  int A,B;
  cin >> A >> B;
  if(A==1){
    A=14;
  }
  if(B==1){
    B=14;
  }
  if(A>B){
    cout << "Alice" << endl;
  }
  else if(B>A){
    cout << "Bob" << endl;
  }
  else{
    cout << "Draw" << endl;
  }
}

Measured memory_bytes: 256
local n = io.read("*n")
local h = {}
for i = 1, n do
  h[i] = io.read("*n")
end
h[1] = h[1] - 1
local ret = true
for i = 2, n do
  if h[i] < h[i - 1] then
    ret = false
    break
  elseif h[i - 1] < h[i] then
    h[i] = h[i] - 1
  end
end
print(ret and "Yes" or "No")


Measured memory_bytes: 2424
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, K, L): (usize, usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let (p, q): (Vec<usize>, Vec<usize>) = {
        let (mut p, mut q) = (vec![], vec![]);
        for _ in 0..K {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            p.push(iter.next().unwrap().parse().unwrap());
            q.push(iter.next().unwrap().parse().unwrap());
        }
        (p, q)
    };
    let (r, s): (Vec<usize>, Vec<usize>) = {
        let (mut r, mut s) = (vec![], vec![]);
        for _ in 0..L {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            r.push(iter.next().unwrap().parse().unwrap());
            s.push(iter.next().unwrap().parse().unwrap());
        }
        (r, s)
    };

    struct UnionFindTree {
        parent: Vec<usize>,
        size: Vec<i64>
    }

    impl UnionFindTree {
        fn new(n: usize) -> UnionFindTree {
            UnionFindTree {
                parent: (0..(n + 1)).collect(),
                size: vec![1; n + 1]
            }
        }
        fn find(&mut self, x: usize) -> usize {
            if self.parent[x] != x {
                let parent_x = self.parent[x];
                self.parent[x] = self.find(parent_x);
            }
            self.parent[x]
        }
        fn same(&mut self, x: usize, y: usize) -> bool {
            self.find(x) == self.find(y)
        }
        fn size(&mut self, x: usize) -> i64 {
            let i = self.find(x);
            self.size[i]
        }
        fn union(&mut self, x: usize, y: usize) {
            let parent_x = self.find(x);
            let parent_y = self.find(y);
            if !self.same(x, y) {
                if self.size[parent_x] < self.size[parent_y] {
                    self.size[parent_y] += self.size[parent_x];
                    self.parent[parent_x] = parent_y;
                } else {
                    self.size[parent_x] += self.size[parent_y];
                    self.parent[parent_y] = parent_x;
                }
            }
        }
    }

    let mut uft_road = UnionFindTree::new(N);
    for i in 0..K {
        uft_road.union(p[i], q[i]);
    }
    let mut uft_rail = UnionFindTree::new(N);
    for i in 0..L {
        uft_rail.union(r[i], s[i]);
    }
    let mut c = std::collections::HashMap::new();
    for (i, j) in (1..(N + 1)).map(|i| (uft_road.find(i), uft_rail.find(i))) {
        *(c.entry((i, j)).or_insert(0)) += 1;
    }
    let ans = (1..(N + 1)).map(|i| c[&(uft_road.find(i), uft_rail.find(i))].to_string()).collect::<Vec<_>>().join(" ");

    println!("{}", ans);
}

Measured memory_bytes: 33040
n,m=gets.split.map &:to_i
a=gets.split.map &:to_i
b=gets.split.map &:to_i
a.sort!
b.sort!
if n==1 || m==1
  p 0
else
  x=0
  (n-1).times do |i|
    x+=(a[i+1]-a[i])*(i+1)*(n-1-i)
  end
  y=0
  (m-1).times do |i|
    y+=(b[i+1]-b[i])*(i+1)*(m-i-1)
  end
  p x*y%(10**9+7)
end

Measured memory_bytes: 16264
#include <stdio.h>
#include <math.h>

int main(){
    long int a,b,n;
    long int x;

    scanf("%ld %ld %ld", &a, &b, &n);
    x = fmin(b-1, n);
    printf("%ld", a*x/b - a*(x/b));

}

Measured memory_bytes: 2148
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := readint()
	d := map[int]int{}
	for i := 0; i < n; i++ {
		in := readint()
		d[in]++
	}
	m := readint()
	for i := 0; i < m; i++ {
		t := readint()
		if d[t] > 0 {
			d[t]--
		} else {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

// ttps://qiita.com/tnoda_/items/b503a72eac82862d30c6
func readint() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

Measured memory_bytes: 12800
def solve():
    from itertools import chain
    H, W = map(int, input().split())
    flag = [tuple(input()) for _ in [0]*H]
    crest = list(input()) + list(input())
    a = [[0]*W for _ in [0]*H]
    a2 = [[[] for _ in [0]*W] for _ in [0]*H]
    result = 0

    for y in range(H-1):
        for x, fl in enumerate(zip(flag[y], flag[y][1:], flag[y+1], flag[y+1][1:])):
            correct = 0
            correct_char = ""
            _y = _x = 0
            for i, (f, c) in enumerate(zip(fl, crest)):
                if f == c:
                    correct += 1
                else:
                    if i == 1:
                        _x = 1
                    elif i == 2:
                        _y = 1
                        _x = 0
                    elif i == 3:
                        _y = _x = 1
                    correct_char = c
            if correct == 4:
                for dy, dx in ((0, 0), (0, 1), (1, 0), (1, 1)):
                    a[y+dy][x+dx] -= 1
                result += 1
            elif correct == 3:
                if not a2[y+_y][x+_x] or correct_char in a2[y+_y][x+_x]:
                    a[y+_y][x+_x] += 1
                a2[y+_y][x+_x].append(correct_char)

    result += max(max(chain.from_iterable(a)), 0)
    print(result)


if __name__ == "__main__":
    solve()

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

using namespace std;

int main() {
    long int n, m;
    vector<long int> l, r;

    cin >> n >> m;
    long int lmax = 0;
    long int rmin = 100000;
    
    long int li, ri;
    for (long int i = 0; i < m; i++) {
        cin >> li >> ri;
        lmax = max(lmax, li);
        rmin = min(rmin, ri);
    }
    
    long int ans = rmin - lmax + 1;
    if (ans >= 0) {
        cout << ans << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
		input = input.split(" ");
		
		var tem = input;
 
  
	
	//文字列から10進数に変換するときはparseIntを使います
	 //   var tem = parseInt(input[0], 10);
  
  // 分割する数値
var beforeText = tem;
// 数値を文字列に変換して、一文字ずつ分割
var arr = String(tem).split('');

var a = parseInt(arr[0], 10);
var b = parseInt(arr[1], 10);
var c = parseInt(arr[2], 10);
var d = parseInt(arr[3], 10);

//console.log(arr); 
//console.log(a,b,c,d); 

if (a == b){console.log('Bad');}
      else if (b == c){console.log('Bad');}
             else if (c == d){console.log('Bad');}
                             else {console.log('Good');}
                             
                      
                             
        


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

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

ll h,w;
ll n;
ll a[10005];
ll b[10005];
ll res[111][111];

int main(){
    cin >> h >> w;
    cin >> n;
    b[0]=0;
    for(ll i=0;i<n;i++){
        cin >> a[i];
        b[i+1]=b[i]+a[i];
    }
    ll count=0;
    ll k=1;
    for(ll i=0;i<h;i++){
        if(i%2==0){
            for(ll j=0;j<w;j++){
                count++;
                if(count<=b[k]) res[i][j]=k;
                else if(count>b[k]){
                    k++;
                    res[i][j]=k;
                }
            }
        }
        else if(i%2==1){
            for(ll j=w-1;j>=0;j--){
                count++;
                if(count<=b[k]) res[i][j]=k;
                else if(count>b[k]){
                    k++;
                    res[i][j]=k;
                }
            }
        }
    }
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
            if(j!=w-1) cout << res[i][j] << " ";
            else cout << res[i][j] << endl;
        }
    }
    return 0;
}  


Measured memory_bytes: 3760
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<cmath>

using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;


int main() {
	string str;
	cin >> str;
	int a = 0;

	for (int i = 0; i < 4; ++i) {
		if (str[i] == '+') a++;
		else a--;
	}

	cout << a << endl;

	return 0;
}

Measured memory_bytes: 256
def getN():
    return int(input())

def getMN():
    return list(map(int, input().split()))

def getlist():
    return list(map(int, input().split()))

n = getN()

res = []
for i in range(n):
    a, b = input().split()
    b = int(b)
    res.append([a,b,i+1])

res = sorted(res, key=lambda x: (x[0], -x[1]))

for r in res:
    print(r[2])



Measured memory_bytes: 3060