akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long ll;
int main(){
    ll a, b, c, d, e;
    ll na, nb, nc;
    while(cin >> a >> b >> c >> d >> e >> na >> nb >> nc) {
        ll ans = c * nc + b * nb + a * na;
        if(nc >= d) {
            ans = min(ans, e * nc + b * nb + a * na);
        } else if(nc + nb >= d) {
            ans = min(ans, e * d + b * (nb - (d - nc)) + a * na);
        } else if(nc + nb + na >= d) {
            ans = min(ans, e * d + a * (na - (d - nc - nb)));
        } else {
            ans = min(ans, e * d);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
struct custom_hash 
{
    static unsigned long long splitmix64(unsigned long long x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(unsigned long long x) const 
    {
        static const unsigned long long FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
mt19937 random_generator(chrono::steady_clock::now().time_since_epoch().count());

int n; 
void read()
{
	cin >> n; 
}

void solve()
{
    set <string> s; 
	for (int i = 1; i <= n; i++)
	{
		string str;
		cin >> str;
		
		s.insert(str);
	}
	
	cout << (int)s.size() << endl; 
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	
	read();
	solve();
}


Measured memory_bytes: 19244
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <cmath>

#define INF (int)1e8
#define EPS 1e-10
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define RFOR(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define debug(x) cerr << #x << ": " << x << endl
#define all(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> PII;

// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << "\t";
    }
    return s;
}

// 2 dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) {
        s << vv[i] << endl;
    }
    return s;
}

ll N;


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

    cin >> N;
    ll a, b;

    FOR(i, 1, sqrt(N)+1) {
        if (N % i == 0) {
            a = i;
            b = N / i;
        }
    }

    cout << a - 1 + b - 1 << endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()
	_, max := max([]int{a, b})
	_, min := min([]int{a, b})
	var ans string
	for i := 0; i < max; i++ {
		ans = ans + strconv.Itoa(min)
	}
	fmt.Println(ans)
}


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

int main() {

  int A[5][4][11];
  int N;
  int b, f, r, v;

  for(int i = 0; i < 5; ++i) {
    for(int j = 0; j < 4; ++j) {
      for(int k = 0; k < 11; ++k) {
	A[i][j][k] = 0;
      }
    }
  }

  std::cin >> N;
  for(int i = 0; i < N; ++i) {
    std::cin >> b >> f >> r >> v;
    A[b][f][r] += v;
  }

  for(int i = 1; i < 5; ++i) {
    for(int j = 1; j < 4; ++j) {
      for(int k = 1; k < 11; ++k) {
	std::cout << " " << A[i][j][k];
      }
      std::cout << std::endl;
    }
    if( i != 4 ) {
      std::cout << "####################" << std::endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		boolean cards[][] = new boolean[4][13];
		
		for(int i = 0; i < n; i++){
			String s = sc.next();
			
			switch(s.charAt(0)){
			case 'S' : cards[0][sc.nextInt()-1] = true; break;
			case 'H' : cards[1][sc.nextInt()-1] = true; break;
			case 'C' : cards[2][sc.nextInt()-1] = true; break;
			case 'D' : cards[3][sc.nextInt()-1] = true; break;
			}
		}
		char[] c = {'S', 'H', 'C', 'D'};
		for (int i = 0; i < 4; i++){
			for(int j = 0; j < 13; j++){
				if(! cards[i][j]){
					System.out.println(c[i]+" "+(j+1));
				}
			}
		}
	}
}


Measured memory_bytes: 26268
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
int main()
{
    IOS
    int n,q; cin>>n>>q;
    string S; cin>>S;
    string str;
    str.pb('a');
    str = str + S;
    int ACarr[n+1];
    ACarr[0] = 0,ACarr[1] = 0;
    for(int i=2;i<=n;i++)
    {
        if(str[i-1] == 'A' && str[i] == 'C')
        {
            ACarr[i] = ACarr[i-1] + 1;
        }
        else{
            ACarr[i] = ACarr[i-1];
        }
    }
 //   for(int i=1;i<=n;i++) cout<<ACarr[i]<<" "; cout<<endl;
    while(q--)
    {
        int l,r; cin>>l>>r;
        cout<<ACarr[r]-ACarr[l]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1488
// inputに入力データ全体が入る
function Main(input) {
	ans = 'No'
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.trim().split("\n");
	rotate = input[0]
	// s = input[0].split(' ').map((n) => (parseInt(n)))
	for (i = 0; i <= input[0].length; i++) {
		head = rotate.substr(0,1)
		str = rotate.slice(1) + head

		if (input[1] === str) {
			ans = 'Yes'
			break
		}
		rotate = str
	}

	// sort
	// s.sort()
	// s.sort((a, b) => { return b - a})



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

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
int n,m,k;
int r[300005],c[300005];
vector< pair<int,int> >v;
int pos;
vector<int>lot1,lot2;
int mx1,mx2;
signed main()
{
	cin>>n>>m>>k;
	for (int i=0;i<k;i++){
		int a,b;
		cin>>a>>b;
		a--; b--;
		r[a]++; c[b]++;
		v.pb(mp(a,b));
	}
	sort(all(v));
	for (int i=0;i<max(n,m);i++){
		if (mx1==r[i]){
			lot1.pb(i);
		}
		if (mx1<r[i]){
			lot1.resize(0);
			lot1.pb(i);
			mx1=r[i];
		}
		if (mx2==c[i]){
			lot2.pb(i);
		}
		if (mx2<c[i]){
			lot2.resize(0);
			lot2.pb(i);
			mx2=c[i];
		}
	}
	if (sz(lot1)*sz(lot2)>k){
		cout<<mx1+mx2;
		re 0;
	}
	for (int i=0;i<sz(lot1);i++){
		for (int j=0;j<sz(lot2);j++){
			while (mp(lot1[i],lot2[j])>v[pos] && pos<sz(v))
				pos++;
			if (pos==sz(v) || v[pos]!=mp(lot1[i],lot2[j])){
				cout<<mx1+mx2;
				re 0;
			}
		}
	}
	cout<<mx1+mx2-1;
	re 0;
}


Measured memory_bytes: 22784
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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



#[allow(dead_code)]
fn solve(s: Vec<char>) -> &'static str{
    let s: Vec<char> = s.into_iter().rev().collect();
    let len = s.len();
    let mut i = 0;
    let s1 = ['e', 's', 'a', 'r' ,'e'];
    let s2 = ['m', 'a', 'e', 'r', 'd'];
    let s3 = ['r', 'e', 's', 'a', 'r', 'e'];
    let s4 = ['r', 'e', 'm', 'a', 'e', 'r', 'd'];
    loop {
        if i + 5 <= len {
            let ss = &s[i..i+5];
            if ss == s1 || ss == s2 {
                i += 5;
                continue;
            };
        }
        if i + 6 <= len {
            let ss = &s[i..i+6];
            if ss == s3 {
                i += 6;
                continue;
            }
        }
        if i + 7 <= len {
            let ss = &s[i..i+7];
            if ss == s4 {
                i += 7;
                continue;
            }
        }
        if i == len {
            break;
        }
        return "NO";
    }
    "YES"
}

fn main() {
    input!{
        s: chars
    }
    println!("{}", solve(s));
}


Measured memory_bytes: 4352
package main

import (
	"fmt"
)

func main() {
	var (
		n     int
		count int
	)
	fmt.Scan(&n)
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}

	flag := true
	for flag {
		for i := 0; i < n; i++ {
			if nums[i]%2 == 0 {
				nums[i] /= 2
			} else {
				flag = false
			}
		}
		if flag {
			count++
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 1768
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int min = -1;
		for(int n=1;n<N/2+1;n++){
			int t = N-n;

			String st1 = String.valueOf(n);
			String st2 = String.valueOf(t);
			int val = 0;
			for(int m=0;m<st1.length();m++){
				val += st1.charAt(m)-'0';
			}
			for(int m=0;m<st2.length();m++){
				val += st2.charAt(m)-'0';
			}
			if(min==-1) min = val;
			if(min>val) min = val;
		}

		System.out.println(min);
		

	}
}

Measured memory_bytes: 26136
import sys

readline = sys.stdin.readline

def culc(A, B, C):
    ans = 0
    for i in range(len(B)):
        ans += A[i]*B[i]
    ans += C
    return ans

def main():
    N, M, C = map(int, readline().split())
    B = list(map(int, readline().split()))
    ans = 0
    for _ in range(N):
        A = list(map(int, readline().split()))
        ans += culc(A, B, C)>0
    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
  string s;
  cin >> s;
  bool a = false, b = false;
  int x = (s[0] - '0') * 10 + (s[1] - '0');
  int y = (s[2] - '0') * 10 + (s[3] - '0');
  if (x > 0 && x <= 12) a = true;
  if (y > 0 && y <= 12) b = true;
  if (a && b) cout << "AMBIGUOUS" << endl;
  else if (a) cout << "MMYY" << endl;
  else if (b) cout << "YYMM" << endl;
  else        cout << "NA" << endl;
  
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
typedef long double ld;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
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 dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

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

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
  int N;  cin>>N;
  string s; cin>>s;
  ll r=0,g=0,b=0;
  rep(i,0,N){
    if(s[i]=='R') r++;
    else if(s[i]=='G') g++;
    else b++;
  }
  ll all = r*g*b;
  ll cnt = 0;
  rep(i,0,N){
    rep(j,i+1,N){
      
      int k = 2*j-i;
      if(s[i]!=s[j] && s[j]!=s[k] && s[k]!=s[i] && k<N) cnt++;
    }
  }
  cout << all-cnt << endl;
  return 0;
}


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

namespace ABC
{
    class ABC171D3
    {
        const string FILE = "/tmp/data.txt";

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            string line;
            string[] sa;
            line = Console.ReadLine();
            int N = int.Parse(line);

            line = Console.ReadLine();
            sa = line.Split(' ');
            Dictionary<long, long> dic = new Dictionary<long, long>();
            long sum = 0;
            for (int i = 0; i < N; ++i)
            {
                long a = long.Parse(sa[i]);

                if (dic.ContainsKey(a))
                {
                    dic[a] += 1;
                }
                else
                {
                    dic[a] = 1;
                }
                sum += a;
            }


            line = Console.ReadLine();
            int Q = int.Parse(line);

//            int[,] BC = new int[Q, 2];
//            Dictionary<int, int> cnvDic = new Dictionary<int, int>();
//            Dictionary<int, int> cnvDicReverse = new Dictionary<int, int>();
            for (int i = 0; i < Q; ++i)
            {
                line = Console.ReadLine();
                sa = line.Split(' ');
                long b = long.Parse(sa[0]);
                long c = long.Parse(sa[1]);

                if (dic.ContainsKey(b))
                {
                    long count = dic[b];
                    dic.Remove(b);
                    if (dic.ContainsKey(c))
                    {
                        dic[c] += count;
                    }
                    else
                    {
                        dic[c] = count;
                    }
                    sum += count * (c - b);
                }
                Console.WriteLine(sum);
            }


#if DEBUG
            Console.WriteLine("*** end ***");
            Console.SetIn(Console.In);
            Console.ReadKey();
#endif
        }

        public static string    sum(Dictionary<long, long> dic)
        {
            long result = 0;
            foreach(var d in dic)
            {
                result += d.Key * d.Value;
            }
            return result.ToString();
        }
    }
}


Measured memory_bytes: 52440
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

using R = double;

int main(void){
	for(int D, E; cin >> D >> E, D;){
		R res = 1e9;
		rep(xx, D + 1){
			R x = xx, y = D - x;
			R diff = fabs(sqrt(x * x + y * y) - E);
			chmin(res, diff);
		}

		cout.precision(20);
		cout << fixed << res << endl;
	}

    return 0;
}

Measured memory_bytes: 3184
#coding:utf-8
n,k  = map(int,input().split())
ls_a  = list(map(int,input().split()))
target = int(k*(k+1)/2)
ls_target = []
i = 1
while(1):
    for j in range(i):
        temp = ls_a[j:(len(ls_a)-i+j+1)]
        ls_target.append(sum(temp))
    if i==n:
        break
    i+=1

def check(num):
    for i in range(50):
        if (num < 2**i):
            return i-1, 2**(i-1)
mx = ls_target[0]
digit, mx_bin = check(mx)
ans = 0
for d in range(digit+1):
#    print (mx_bin)
#    print (ls_target)
    new_idx = []
    cnt = 0
    for idx,ls in enumerate(ls_target):
        if ls & mx_bin > 0:
            cnt += 1
            new_idx.append(idx)
    if cnt >= k:
        ls_target = [ls_target[i] for i in new_idx]
        ans += mx_bin
    mx_bin = int(mx_bin/2)
print (ans)

Measured memory_bytes: 90588
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

typedef struct fare_tbl
{
	int v;
	int w;
	int price;
} fare_t;

int
main(int argc, char **argv)
{
	const fare_t fare[7] = {{60, 2, 600}, {80, 5, 800}, {100, 10, 1000}, {120, 15, 1200}, {140, 20, 1400}, {160, 25, 1600}, {0, 0, 0}};

	while (true)
	{
		int n;
		scanf("%d", &n);
		if (n == 0)
			break;

		int total = 0;
		for (int i = 0; i < n; ++i)
		{
			int x, y, z, w;
			scanf("%d%d%d%d", &x, &y, &z, &w);
			int v = x + y + z;

			int j;
			for (j = 0; j < 6; ++j)
			{
				if (fare[j].v >= v && fare[j].w >= w)
					break;
			}

			total += fare[j].price;
		}

		printf("%d\n", total);
	}

	return 0;
}


Measured memory_bytes: 1848
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define Maxn 10005
using namespace std;
int ans;
int h,w;
int mp[15][Maxn];
void dfs(int x)
{
   if(x==h)
   {
       int sum=0;
       for(int i=0;i<w;i++)
       {
           int tmpsum=0;
           for(int j=0;j<h;j++)
           {
               if(mp[j][i]==1)
                    tmpsum++;
           }
           sum+=max(tmpsum,h-tmpsum);
       }
       ans=max(ans,sum);
       return;
   }
   dfs(x+1);
   for(int i=0;i<w;i++)
        mp[x][i]=!mp[x][i];
   dfs(x+1);
}
int main()
{
    while(cin>>h>>w,h+w)
    {
        for(int i=0;i<h;i++)
            for(int j=0;j<w;j++)
                cin>>mp[i][j];
        ans=0;
        dfs(0);
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3392
#include<bits/stdc++.h>
using namespace std;
int main(){
	int E;
	int Y;
	cin >> E >> Y;
	if (E==0){
		if( Y<=1911){
			cout << "M" << Y-1867 << endl;
		}else if (Y<=1925){
			cout << "T" << Y-1911 << endl;
		}else if (Y<=1988){
			cout << "S" << Y-1925 << endl;
		}else if (Y<=2016){
			cout << "H" << Y-1988 << endl;
		}
	}
	else if (E==1){
		cout << 1867+Y << endl;
	}else if (E==2){
		cout << 1911+Y << endl;
	}else if (E==3){
		cout << 1925+Y << endl;
	}else if (E==4){
		cout << 1988+Y << endl;
	}
}


Measured memory_bytes: 3108
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a[100010];
int main(){
	ll n;
	
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	sortup(a,n);
	//+側と-側に分ける。どっちも空はダメ
	
	ll s=a[n-1]-a[0];
	rep(i,1,n-1)s+=llabs(a[i]);
	printf("%lld\n",s);

	if(a[n-2]<0){
		//+側が1つのとき
		ll temp=a[n-1];
		rep(i,0,n-1){
			printf("%lld %lld\n",temp,a[i]);
			temp-=a[i];
		}
	}else{
		//+側が2つ以上のとき
		printf("%lld %lld\n",a[0],a[n-1]);
		if(n>2){
			ll temp=a[0]-a[n-1];
			int i=n-2;
			while(i>=2&&a[i-1]>0){
				printf("%lld %lld\n",temp,a[i]);
				temp-=a[i];
				i--;
			}
			printf("%lld %lld\n",a[i],temp);
			temp=a[i]-temp;
			i--;
			while(i>=1){
				printf("%lld %lld\n",temp,a[i]);
				temp-=a[i];
				i--;
			}
		}
	}
}

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


void solve(std::string T){
    for(auto t: T){
        if(t == '?'){
            cout << 'D';
        }else{
            cout << t;
        }
    }
    cout << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string T;
    std::cin >> T;
    solve(T);
    return 0;
}


Measured memory_bytes: 3924
import math
MOD=10**9+7
N,K=map(int,input().split())

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)

  divisors.sort()
  return divisors
  
def powmod(a,p):
  if p==0:
    return 1
  elif p==1:
    return a
  else:
    pow2=powmod(a,p//2)
    if p%2==0:
      return (pow2**2)%MOD
    else:
      return (a*pow2**2)%MOD

div_table=[0,1]
for i in range(2,K+1):
  divlist=make_divisors(i)
  dv=i
  for d in divlist:
    if d<i:
      dv-=div_table[d]
  div_table.append(dv)
#print(div_table)
    
answer=0
for i in range(1,K+1):
  k=div_table[i]
  pm=powmod(K//i,N)
  answer+=k*pm
  answer%=MOD
  
print(answer)

Measured memory_bytes: 75972
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<cctype>
#include<string.h>
#include <stdlib.h>

#define PI 3.1415926
void swap(int* x, int* y) {
	int a = *x;
	int b = *y;
	*x = b;
	*y = a;
}
int factorial(int n);
int sum(int n, int*);
int ave(int n, int*);
int min(int n, int*), min(int n, int m);
int max(int n, int*), max(int n, int m);

int main() {
	int N, M;
	int ans=0, cou=0;
	int cou2;
	char C[10],c[100][100];
	C[1] = 'W';
	C[2] = 'B';
	C[3] = 'R';
	int p[10][100] = { 0 };
	scanf("%d %d", &N, &M);
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= M; j++) {
			scanf("%c", &c[i][j]);
		}
	}
	for (int i = 1; i <= 3; i++) {
		for (int j = 1; j <= N; j++) {
			for (int k = 0; k <= M ; k++) {
				if (C[i] == c[j][k]) {
					p[i][j]++;
				}
			}
		}
	}
	for (int i = 1; i <= N - 2;i++) {
		for (int j = 1; j <= i; j++) {
			cou += p[1][j];
		}
		for (int j = i + 1; j <= N - 1; j++) {
			cou2 = cou;
			for (int k = i + 1; k <= j; k++) {
				cou2 += p[2][k];
			}
			for (int k = j + 1; k <= N; k++) {
				cou2 += p[3][k];
			}
			if ((i == 1 && j == 2) | (ans<cou2)) {
				ans = cou2;
			}
			cou2 = 0;
		}
		cou = 0;
	}
	printf("%d\n",M*N-ans);
	return 0;
}

int factorial(int n) {
	if (n > 0) {
		return n * factorial(n - 1);
	}
	else {
		return 1;
	}
}
int sum(int n, int *all) {
	int total = 0;
	for (int i = 0; i < n; ++i) {
		total += all[i];
	}
	return total;
}
int ave(int n, int *all) {
	int total = 0;
	for (int i = 0; i<n; ++i) {
		total += all[i];
	}
	return total / n;
}
int min(int n, int *all) {
	int min = all[0];
	for (int i = 1; i < n; ++i) {
		if (min > all[i]) {
			min = all[i];
		}
	}
	return min;
}
int max(int n, int *all) {
	int max = all[0];
	for (int i = 1; i<n; ++i) {
		if (max<all[i]) {
			max = all[i];
		}
	}
	return max;
}
int max(int n, int m) {
	if (n >= m) {
		return n;
	}
	else {
		return m;
	}
}
int min(int n, int m) {
	if (n >= m) {
		return m;
	}
	else {
		return n;
	}
}

Measured memory_bytes: 2720
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int N = 4;
		int[] town = {0, 0, 0, 0, 0};
		for(int i = 0; i < 3 * 2; i++) {
			town[sc.nextInt()]++;
		}
		int[] count = {0, 0, 0, 0, 0};
		for(int i = 1; i <= N; i++) {
			count[town[i]]++;
		}
		if(count[1] == 2 && count[2] == 2) System.out.println("YES");
		else System.out.println("NO");
	}
}


Measured memory_bytes: 23764
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main() {

    int N; cin >> N;
    ll a[N]; rep(i,N) cin >> a[i];
    int Q; cin >> Q;
    ll b[Q], c[Q]; rep(i,Q) cin >> b[i] >> c[i];

    ll cnt[110000]; rep(i,11000) cnt[i] = 0;
    rep(i,N) ++cnt[a[i]];

    ll sum = 0;
    rep(i,N) sum += a[i];
    rep(i,Q) {
        sum = sum - b[i]*cnt[b[i]] + c[i]*cnt[b[i]];
        out(sum);
        cnt[c[i]] += cnt[b[i]];
        cnt[b[i]] = 0;
    }



    return 0;
}









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

int main(){
    int N;
    cin >> N;
    vector<pair<int,int>> a;
    vector<vector<int>> G(N);
    rep(i, N-1){
        int x,y;
        cin >> x >> y;
        x--;y--;
        G[x].push_back(y);
        G[y].push_back(x);
        a.push_back(make_pair(x,y));
    }
    //int ansm = *max_element(h.begin(),h.end());
    //cout <<ansm<< endl;
    queue<int> que;
    vector<int> used(N,0);
    vector<int> cs(N,0);
    map<pair<int,int>, int> I;
    que.emplace(0);
    int K = 0;
    used[0] = 1;

    while(!que.empty()){
        int v = que.front();
        que.pop();
        if(K < G[v].size()) K = G[v].size();
        int cur = 1;
        for(int u:G[v]){
            if(used[u])continue;
            if(cur == cs[v]) cur++;
            cs[u] = I[make_pair(u, v)] = I[make_pair(v, u)] = cur++;
            used[u]=1;
            que.emplace(u);
        }
    }
    cout << K << endl;
    for(auto ai : a){
        //c[a[i].first]++;
        //c[a[i].second]++;
        int color = I[ai];
        cout << color << endl;
    }
}


Measured memory_bytes: 20084
#include <bits/stdc++.h>
	using namespace std;
	typedef long long ll;
	#define endl "\n"
	#define space " "
	#define ll long long int
	#define vl vector<ll>
	#define vvl vector < vll >
	#define pii pair<int,int>
	#define pll pair<ll,ll>
	#define vpl vector < pll >
	#define mod 1000000007
	#define pi 3.1415926535897932384626433
	#define inf 1000000000000000001;
	#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y) 
	#define mem(a,val) memset(a,val,sizeof(a))
	#define pb push_back
	#define f first
	#define s second
	
	void solve()
	{
		ll a,b,c;
		cin>>a>>b>>c;
		ll k;
		cin>>k;
		while(b<=a){
			k--;
			b*=2;
		}
		while(c<=b){
			k--;
			c*=2;
		}
		if(k<0) cout<<"No";
		else cout<<"Yes";
	}

	signed main()
	{

	fast;
	#ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
     #endif

	ll T=1;
	// cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
	}


Measured memory_bytes: 3664
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n string
	fmt.Scan(&n)
	f := 0
	for _, r := range n {
		i, _ := strconv.Atoi(string(r))
		f += i
	}
	if x, _ := strconv.Atoi(n); x%f == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,q,z=0,zz=0,nn=0,mm,qqq=0;
	cin>>n>>m>>q;
	int a[q+5],b[q+5],c[q+5],d[q+5],e[15];
	
	for(int i=0;i<q;i++)
	{
		cin>>a[i]>>b[i]>>c[i]>>d[i];
	}
	
	
	for(int i1=1;i1<=m;i1++)
	{
		e[1]=i1;
		for(int i2=i1;i2<=m;i2++)
		{
			e[2]=i2;
			for(int i3=i2;i3<=m;i3++)
			{
				e[3]=i3;
				for(int i4=i3;i4<=m;i4++)
				{
					e[4]=i4;
					for(int i5=i4;i5<=m;i5++)
					{
						e[5]=i5;
						for(int i6=i5;i6<=m;i6++)
						{
							e[6]=i6;
							for(int i7=i6;i7<=m;i7++)
							{
								e[7]=i7;
								for(int i8=i7;i8<=m;i8++)
								{
									e[8]=i8;
									for(int i9=i8;i9<=m;i9++)
									{
										e[9]=i9;
										for(int i10=i9;i10<=m;i10++)
										{
											e[10]=i10;
											z=0;
											for(int i=0;i<q;i++)
											{
												if(e[b[i]]-e[a[i]]==c[i])
												z+=d[i];
												//if(i1==1&&i2==3&&i3==4)
												//cout<<z<<endl;
											}
											if(z>zz)
											zz=z;
											
										}		
									}
								}
							}
							
						}
					}
				}
					
			}
		}
	}
	cout<<zz;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
	int N;
	int sum = 0;

	scanf("%d", &N);
	int tmp = N;
	while (tmp > 0) {
		sum += tmp % 10;
		tmp /= 10;
	}
	if (N % sum == 0) {
		puts("Yes");
	} else {
		puts("No");
	}
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

LL const INF = 100000000;
LL c[12] = {0};
LL a[12][12] = {{0}};
LL n,m,x;
LL ans = INF;

void f(LL bit, LL dep){
    if(dep == n){
        LL p[12] = {0};
        LL cost = 0;
        REP(i,n){
            if((bit & (1<<i)) != 0){
                cost += c[i];
                REP(j,m){
                    p[j] += a[i][j];
                }
            }
        }
        bool ok = true;
        REP(i,m){
            if(p[i] < x){
                ok = false;
                break;
            }
        }
        if(ok){
            ans = min(ans, cost);
        }
        return;
    }
    f(bit, dep + 1);
    f(bit + (1<<dep), dep + 1);
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m>>x;
    REP(i,n){
        cin>>c[i];
        REP(j,m)cin>>a[i][j];
    }
    f(0,0);
    PUTS(ans == INF ? -1 : ans);
}

Measured memory_bytes: 3612
#include <iostream>
#include <set>
#include <vector>

using namespace std;

bool bingo_check(std::vector<std::vector<bool> > &holl){
  for(int row_idx = 0; row_idx < 3; row_idx++){
    if(holl[row_idx][0] && holl[row_idx][1] && holl[row_idx][2]){
      return true;
    }
  }
  for(int col_idx = 0; col_idx < 3; col_idx++){
    if(holl[0][col_idx] && holl[1][col_idx] && holl[2][col_idx]){
      return true;
    }
  }
  if(holl[0][0] && holl[1][1] && holl[2][2]){
    return true;
  }
  if(holl[0][2] && holl[1][1] && holl[2][0]){
    return true;
  }
  return false;
}

int main(){
  vector<vector<int> > a(3, vector<int>(3, 0));
  for(int row_idx = 0; row_idx < a.size(); row_idx++){
    for(int col_idx = 0; col_idx < a[0].size(); col_idx++){
      std::cin >> a[row_idx][col_idx];
    }
  }

  int n;
  std::cin >> n;
  set<int> b;
  for(int idx = 0; idx < n; idx++){
    int input_temp;
    std::cin >> input_temp;
    b.insert(input_temp);
  }

  std::vector<std::vector<bool> > holl(3, std::vector<bool> (3, false));
  for(int row_idx = 0; row_idx < 3; row_idx++){
    for(int col_idx = 0; col_idx < 3; col_idx++){
      if(b.find(a[row_idx][col_idx]) != b.end()){
        holl[row_idx][col_idx] = true;
      }
    }
  }

  if(bingo_check(holl)){
    std::cout << "Yes" << '\n';
  }else{
    std::cout << "No" << '\n';
  }
  return 0;
}


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

using namespace std;

const int MAXK = 1E5;
int a[MAXK];

int main()
{
    int k;
    cin >> k;
    for (int i = 0; i < k; i++)
    {
        cin >> a[i];
    }
    if (a[k - 1] != 2)
        cout << -1 << endl;
    else
    {
        bool poss = true;
        long long bigGroups = 1;
        long long smallGroups = 1;
        for (int i = k - 2; i >= 0; i--)
        {
            long long A = a[i + 1];
            long long B = a[i];
            long long temp1 = 0;
            for (long long jump = A * (bigGroups + 1) / B; jump > 0; jump /= 2)
            {
                while ((temp1 + jump) * B / A <= bigGroups)
                    temp1 += jump;
            }
            if (temp1 * B / A < smallGroups || temp1 * B / A > bigGroups)
                poss = false;
            long long temp2 = 0;
            for (long long jump = A * (bigGroups + 1) / B; jump > 0; jump /= 2)
            {
                while ((temp2 + jump) * B / A < smallGroups)
                    temp2 += jump;
            }
            bigGroups = temp1;
            smallGroups = temp2 + 1;
        }
        if (poss)
            cout << smallGroups * a[0] << " " << bigGroups * a[0] + (a[0] - 1) << endl;
        else
            cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 640
# by the authority of GOD   author: manhar singh sachdev #

import os,sys
from io import BytesIO, IOBase

def main():
    d,t,s = map(int,input().split())
    if s*t >= d:
        print('Yes')
    else:
        print('No')

#Fast IO Region
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == '__main__':
    main()

Measured memory_bytes: 62544
// I look at my watch
// it say nine twenty-five
// And I think oh God
// I'm still alive
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(int i = int(a); i < int(b); ++i)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
typedef long double ld;

const int N=1e5;
vector<string>ans;


void compute(){
	vector<vector<string>>G(10);
	For(i,0,10){
		char c='0'+i;
		string s;s.pb(c);
		G[i].pb(s);
		if(i)ans.pb(s);
	}
	For(tam,2,10000){
		vector<vector<string>>T(10);
		For(i,0,10){
			char c='0'+i;
			for(int d=-1;d<=1;d++){
				int j=i+d;
				if(j<0)continue;
				if(j>9)continue;
				for(string s:G[j]){
					string ss;ss.pb(c);
					ss+=s;
					T[i].pb(ss);
					if(i){
						ans.pb(ss);
						if(sz(ans)>N)return;
					}
				}
			}
		}
		G=T;
	}
	//cout<<"lel"<<endl;
}


int main(){
	compute();
	//trace(sz(ans));
	int k;cin>>k;
	k--;
	cout<<ans[k]<<endl;
	return 0;
}


Measured memory_bytes: 6772
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}



signed main(){
	ll a,b,n; cin>>a>>b>>n;
	cout<<(a*min(b-1,n))/b<<endl;


	return 0;
}


Measured memory_bytes: 3652
/**
 *    This code has been written by YueGuang, feel free to ask me question. Blog: http://www.yx.telstudy.xyz
 *    created:
 */
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define REP_(i, a, b) for(int i = a; i <= b; i++)
#define sl(n) scanf("%lld", &n);
#define si(n) scanf("%d", &n);
#define RepAll(a) for(auto x: a)
#define cout(ans) cout << ans << endl;
typedef long long ll;

using namespace std;
const int maxn = 1e5 + 10;


int main(){
    int n, m;scanf("%d%d",&n, &m);
    if (n == 1 && m == 1) printf("1");
    else  if (n == 1) printf("%d", m - 2);
    else if (m == 1) printf("%d", n - 2);
    else{
        printf("%lld", 1ll * (m - 2) * (n - 2));
    }}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    int a, b; cin >> a >> b;
    string s; cin >> s;

    int cnt1 = 0, cnt2=0;
    int h_cnt=0;

    rep(i, s.size()){
       if(s[i]=='-'){
           h_cnt++;
           if(h_cnt==1)swap(cnt1, cnt2);
           continue;

       }
       else{
           cnt1++;
       }
    }
    if(h_cnt==0||h_cnt>1){
        out("No");
        return 0;
    }

    if(a==cnt2&&b==cnt1){
        out("Yes");
    }
    else out("No");
}

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

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> L(N);
    
    for(int i =0;i<N;i++){
        cin >> L[i];
    }
    sort(L.begin(),L.end());
    int ans=0;
    for(int j=0;j<K;j++){
        ans += L[N-1-j];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*Always success does not build on success,success build on failure*/
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vec         vector<int>
#define map         map<int,int>
#define scn(t)      scanf("%d",&t)
#define lscn(t)      scanf("%lld",&t)
#define mod         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define endl        "\n"
using namespace std;
const int N=1e5+5;
int main()
{
   ll n;
   lscn(n);
   ll k=2;
   lscn(k);
   ll arr[n];
   
   for(ll i=0;i<n;i++)
   lscn(arr[i]);
   
   ll ans[n];
   
   memset(ans,-1,sizeof(ans));
   ans[0]=0;
   for(ll i=0;i<n-1;i++)
   {
       for(ll j=1;j<=k;j++)
       {
           if(i+j<n)
          {
           if(ans[i+j]==-1)
           ans[i+j]=ans[i]+abs(arr[i]-arr[i+j]);
           else
           ans[i+j]=min(ans[i+j],ans[i]+abs(arr[i]-arr[i+j]));
          }
          else
          {
             break;
          }
       }
   }
//   for(auto it:ans)
//   cout<<it<<" ";
//   cout<<endl;
   cout<<ans[n-1]<<endl;
   return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int n;
  cin >> n;

  set<char> st;
  rep(i, n) {
    char s;
    cin >> s;
    st.insert(s);
  }

  cout << (st.size() == 3 ? "Three" : "Four") << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
const double EPS = 1e-8;
double D(P a, P b) {
  return sqrt((a.real()-b.real())*(a.real()-b.real())+(a.imag()-b.imag())*(a.imag()-b.imag()));
}
double dot(P a, P b){return real(conj(a)*b);}
double cross(P a, P b){return imag(conj(a)*b);}
bool intersectLP(const L &l, const P &p){return abs(cross(l.second-p,l.first-p))<EPS;}
bool intersectSP(L s, P p){return abs(s.first-p)+abs(s.second-p)-abs(s.second-s.first)<EPS;}
int main() {
  double d,px,py,vx,vy;
  while(cin >> d && d) {
    cin >> px >> py >> vx >> vy;
    P p=P(px,py),q=P(px+vx,py+vy);
    L l=L(p,q);
    bool f=0;
    if(intersectLP(l,P(0,0))) f=1;
    double c=D(p,P(0,0));
    if(D(p,P(0,0))<D(q,P(0,0))&&!intersectSP(l,P(0,0))) c=2-c;
    if(f&&c<=d) printf("%.10f\n",c);
    else printf("impossible\n");
  }
  return 0;
}


Measured memory_bytes: 1264
import sys
# gcd
from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
# fin = open('in_1.txt', 'r')
# sys.stdin = fin
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    S = list(next(tokens))  # type: str

    # write code
    S[K-1] = S[K-1].lower()
    print(''.join(S))


Measured memory_bytes: 5588
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #n = int(stdin.readline()[:-1])   
    #r = stdin.readline()[:-1]
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #n = int(r)
    #a = r.split()
    #a,b,c = r.split()
    #a = list(map(int, r.split()))
    #a,b,c,d = map(int, r.split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    #res = 0
    r = [int(stdin.readline()) for i in range(3)]

    print((r[0]+r[1])*r[2]//2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256