akhauriyash/Code-Regression huggingface dataset:
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def binary(n):
    return bin(n)[2:]

# バイナリ法
def pow_by_binary_exponentiation(a, x, n): # a^x mod n
    x = [int(b) for b in binary(x)]
    y = a
    for i in range(1, len(x)):
        y = (y**2) % n
        if x[i] == 1:
            y = (y * a) % n
    return y

# モンゴメリ冪乗法
def pow_by_montgomery_ladder(a, x, n): # a^x mod n
    x = [int(b) for b in binary(x)[::-1]]
    k = len(x)
    a1 = a
    a2 = a**2
    for i in range(k - 2, -1, -1):
        if x[i] == 0:
            a2 = (a1 * a2) % n
            a1 = (a1**2) % n
        else:
            a1 = (a1 * a2) % n
            a2 = (a2**2) % n
    return a1

def power_func(a,n,p):
  bi=str(format(n,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res
#a,b,c,d=list(map(int,input().split()))
s=input()
#s="3"*20000
su=[0 for _ in range(len(s))]
su[0]=int(s[-1])
for i in range(1,len(s)):
    ii=len(s)-i-1
    o=int(s[ii])*pow(10,i,2019)
    #su[i]=su[i-1]+(int(s[ii])*(10**i))
    #su[i]=su[i-1]+pow(int(s[ii]),10**i,2019)
    su[i]=(su[i-1]+o)

    su[i]%=2019
a_dic=Counter(su)
#print(su)
#print(a_dic)
ans=0
if 0 in a_dic.keys():
    ans+=a_dic[0]

for i in a_dic.keys():
    if a_dic[i]<2:
        continue
    ans+=combinations_count(a_dic[i],2)

print(ans)


Measured memory_bytes: 34636
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
    cin>>a>>b;
    if(b==1){cout<<0<<endl;return 0;}
    for(int i=1;;i++){
        int c=i*a-(i-1);
        if(c>=b){
            cout<<i<<endl;return 0;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int w,h;
  cin >> w >> h;
  unsigned long long int p[w+1];
  unsigned long long int q[h+1];
  for(int i=0;i<w;i++)
    cin >> p[i];
  for(int j=0;j<h;j++)
    cin >> q[j];
  p[w] = 200000001;
  q[h] = 200000001;
  sort(p,p+w);
  sort(q,q+h);
  unsigned long long int count = 0;
  int i=0;
  int j=0;
  unsigned long long int kw = w+1;
  unsigned long long int kh = h+1;
  while(i!=w||j!=h){
    if(p[i]<q[j]){
      count += p[i]*kh;
      kw--;
      i++;
    }
    else{
      count += q[j]*kw;
      kh--;
      j++;
    }
  }
  cout << count << endl;
  return 0;
}
  


Measured memory_bytes: 1792
#include <stdio.h>

int A[100][100];
int Color[100];
int d[100],f[100];
int n,time1=0;

void vist(int u){
  int v;
  Color[u]=1;
  d[u]=++time1;
  for(v=0;v<n;v++){
    if(A[u][v]==1 && Color[v]==0) vist(v);
  }
  f[u]=++time1;
}

int main() {
  int i,u,j,k;
  int v;

  for(i=0;i<100;i++) Color[i]=0;

  for(i=0;i<100;i++){
    for(j=0;j<100;j++){
      A[i][j]=0;
    }
  }

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u=u-1;
    if(k!=0){
      for(j=0;j<k;j++){
        scanf("%d",&v);
        v=v-1;
        A[u][v]=1;
      }
    }
  }

  for(i=0;i<n;i++){
    if(Color[i]==0) vist(i);
  }
  for (i=0; i<n;i++) {
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  return 0;
}

Measured memory_bytes: 640
N = int(input())
d_ls=[]
for vakawkawelkn in range(N):
	D1,D2=map(int, input().split())
	if D1==D2:
		d_ls+=[1]
	else:
		d_ls+=[0]

flag=0
for i in range(N-2):
	if d_ls[i]*d_ls[i+1]*d_ls[i+2]==1:
		flag=1


if flag==0:
	print("No")
else:
	print("Yes")


# 2darray [[0] * 4 for i in range(3)]
# import itertools

Measured memory_bytes: 9200
N = gets.to_i
mochis = []
N.times do
  mochis.push(gets.to_i)
end
mochis.sort!
count = 0
last_mochi = 0
mochis.each do |mochi|
  if mochi != last_mochi
    count += 1
  end
  last_mochi = mochi
end
puts count

Measured memory_bytes: 1916
import java.util.*;
import java.io.*;

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int k = Integer.parseInt(br.readLine());
        String s = br.readLine();
        
        out.println(s.length() > k ? s.substring(0, k) + "..." : s);
        out.close();
        
    }
}

Measured memory_bytes: 36472
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1; i<=(n); i++)
const int MX = 2005;
int n, m, q, a, b, c, d, x, y, dx[] = {1,-1,0,0}, dy[] = {0,0,1,-1}, ac[4][MX][MX], ac2[MX][MX];
char s[MX][MX];
void dfs(int x, int y){
	s[x][y] = '0';
	for(int i=0; i<4; i++){
		int nx = x + dx[i], ny = y + dy[i];
		if(s[nx][ny] != '1') continue;
		ac[i][x+!i][y+(i==2)] = 1;
		dfs(nx,ny);
	}
}
int main(){
	scanf("%d%d%d", &n, &m, &q);
	rep(i,n) scanf("\n%s", s[i]+1);
	rep(i,n) rep(j,m) if(s[i][j] == '1'){
		dfs(i,j);
		ac2[i][j] = 1;
	}
	rep(i,n) rep(j,m){
		for(int k=0; k<4; k++) ac[k][i+k/2][j+1-k/2] += ac[k][i][j];
		ac2[i][j] += ac2[i-1][j] + ac2[i][j-1] - ac2[i-1][j-1];
	}
	rep(i,q){
		scanf("%d%d%d%d", &a, &b, &c, &d);
		printf("%d\n",ac2[c][d] + ac2[a-1][b-1] - ac2[c][b-1] - ac2[a-1][d] + ac[0][a][d] - ac[0][a][b-1] + ac[1][c+1][d] - ac[1][c+1][b-1] + ac[2][c][b] - ac[2][a-1][b] + ac[3][c][d+1] - ac[3][a-1][d+1]);
	}
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 512345;
pair<char,int> p[MAX_N];

int main2() {
  string S; cin >> S;

  int ps = 0;
  char x = '?';
  int len = 0;
  REP(i, S.size()) {
    if (x != S[i]) {
      if (len > 0) {
        p[ps++] = {x, len};
      }
      x = S[i];
      len = 1;
    } else {
      len++;
    }
  }
  if (len > 0) {
    p[ps++] = {x, len};
  }

  ll ans = 0;
  int i = 0;
  if (p[i].first == '>') { ll n = p[i].second; ans += (ll)n*(n+1)/2; i++; }
  for ( ; i + 2 <= ps; i += 2) {
    ll n1 = p[i].second;
    ll n2 = p[i+1].second;
    if (n1 > n2) swap(n1, n2);
    n1--;
    ans += n1 * (n1+1) / 2;
    ans += n2 * (n2+1) / 2;
  }
  if (i < ps) {
    ll n = p[i].second;
    ans += (ll)n*(n+1)/2;
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 2820
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N,M; cin>>N>>M;
    map<int,set<int>> adj;
    rep(m,0,M){
        int a,b; cin>>a>>b;
        adj[a].insert(b);
        adj[b].insert(a);
    }

    string ans="IMPOSSIBLE";
    for(auto a:adj[1]){
        if(adj[a].count(N)) ans="POSSIBLE";
    }

    cout<<ans<<endl;
}

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

#define PI 3.14159265359
#define MODULO 1000000007

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int x, n;
  int index;
  int diff = 1000;
  cin >> x >> n; 
  vi v(102);
  for(int i =0; i<n;i++){
    int k;
    cin >> k;
    v[k] = !!k;
  }
  for(int i =0; i<102;i++){
    if(v[i] == 0){
      if( abs(i-x) <diff){
        diff = abs(i-x);
        index = i;
      }
    }
  }
  cout << index;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>

int main() {
    long long n, m, t, ret = 0;
    std::cin >> n >> m;
    std::vector<std::map<long long, long long>> x(m);
    for (auto i = 0ll; i < n; i++) {
        std::cin >> t;
        x[t % m][t]++;
    }

    auto bo = [](auto acc, auto& p) { return acc + p.second; };

    ret += std::accumulate(x[0].begin(), x[0].end(), 0ll, bo) / 2;
    if (m % 2 == 0) ret += std::accumulate(x[m / 2].begin(), x[m / 2].end(), 0ll, bo) / 2;

    for (auto i = 1; i < (m + 1) / 2; i++) {
        auto ssum = std::accumulate(x[i].begin(), x[i].end(), 0ll, bo);
        auto bsum = std::accumulate(x[m - i].begin(), x[m - i].end(), 0ll, bo);
        if (bsum > ssum) {
            x[i].swap(x[m - i]);
            std::swap(ssum, bsum);
        }
        auto multiels = std::accumulate(x[i].begin(), x[i].end(), 0ll, [](auto acc, auto& el) { return acc + el.second / 2 * 2; });
        if (ssum - multiels >= bsum) {
            ret += bsum + multiels / 2;
        } else {
            ret += bsum + (ssum - bsum) / 2;
        }
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, Npow, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
ll Npow(ll x, ll n) {
	if (n == 0) return 1;
	if (n % 2 == 0) return Npow(x * x % MOD, n / 2);
	else return x * Npow(x, n - 1) % MOD;
}
map<ll, ll> primeFactorize(ll n, map<ll, ll>& PF) {
	while (n % 2 == 0) {
		PF[2]++;
		n /= 2;
	}
	for (ll p = 3; p * p <= n; p += 2) {
		while (n % p == 0) {
			PF[p]++;
			n /= p;
		}
	}
	if (n != 1) {
		PF[n]++;
	}
	return PF;
}
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int main() {
	cin >> N;
	vector<map<ll, ll>> PF(N); vl A(N);
	for (i = 0; i < N; i++) {
		cin >> A[i]; primeFactorize(A[i], PF[i]);
	}
	map<ll, ll> Pm;
	for (i = 0; i < N; i++) for (auto itr : PF[i]) Pm[itr.first] = max(Pm[itr.first], itr.second);
	ll pre = 1;
	for (auto itr:Pm) pre = (pre * Npow(itr.first, (itr.second))) % MOD;
	for (i = 0; i < N; i++) ans = (ans + pre * modinv(A[i], MOD)) % MOD;
	cout << ans;
}

Measured memory_bytes: 3968
use std::io::{BufRead, Read};

pub struct Scanner<R>
where
    R: BufRead,
{
    reader: R,
}

impl<R> Scanner<R>
where
    R: BufRead,
{
    pub fn new(reader: R) -> Self {
        Self { reader }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: ::std::str::FromStr,
        <T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
    {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .unwrap()
    }
}

use std::iter::Iterator;

fn main() {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let mut sc = Scanner::new(stdin);

    let r: i32 = sc.next();
    let c: i32 = sc.next();
    let mut col_sum: Vec<i32> = vec![0i32; c as usize];

    for _ in 0..r {
        let mut row_sum: i32 = 0;
        for j in 0..c {
            let n: i32 = sc.next();
            row_sum += n;
            col_sum[j as usize] += n;
            print!("{} ", n);
            if j == c - 1 {
                println!("{}", row_sum);
            }
        }
    }
    let mut sum: i32 = 0;
    for i in 0..c {
        sum += col_sum[i as usize];
        print!("{} ", col_sum[i as usize]);
    }
    println!("{}", sum);
}



Measured memory_bytes: 5052
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Diverse Word
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 26;

/* typedef */

/* global variables */

int ds[MAX_N];
bool used[MAX_N];

/* subroutines */

/* main */

int main() {
  string s;
  cin >> s;
  int n = s.size();

  for (int i = 0; i < n; i++)
    used[ds[i] = s[i] - 'a'] = true;

  if (n >= MAX_N) {
    while (n > 0) {
      int &d = ds[n - 1];
      used[d++] = false;
      while (d < MAX_N && used[d]) d++;
      if (d < MAX_N) {
	used[d] = true;
	break;
      }
      n--;
    }

    if (n == 0) {
      puts("-1");
      return 0;
    }
  }
  else {
    ds[n] = 0;
    while (used[ds[n]]) ds[n]++;
    n++;
  }

  for (int i = 0; i < n; i++) putchar(ds[i] + 'a');
  putchar('\n');

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

long long f(long long n) {
	long long ret = 1;
	for(long long i = 1; i <= n; ++i) {
		ret *= i;
		ret %= 1000000007;
	}
	return ret;
}

int main(void) {
	// input
	long long n, m;
	std::cin >> n >> m;

	// cases
	long long x = 0;
	if(n == m) x = f(n) * f(m) * 2;
	else if(n == m + 1 || m == n + 1) x = f(n) * f(m);
	else x = 0;

	x %= 1000000007;

	std::cout << x << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   /// https://ideone.com/Fd5s8n
  int k;
  cin>>k;
  string s;
  cin>>s;
  if(s.length()<=k)
    cout << s << endl;
  else{
    for(int i=0;i<k;i++)
        cout << s[i];
cout << "..." << endl;
  }

    return 0;

}


Measured memory_bytes: 3632
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize,
        av: [usize; n]
    };

    let mut res = 0;
    for i in 0..n {
        let a = av[i];
        let i = i + 1;
        if i % 2 == 1 && a % 2 == 1 {
            res += 1;
        }
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

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 << ' ';
  }
  return s;
}

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];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

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

signed main() {
  int N;
  cin >> N;

  int ans = 0;
  repp(i, 1, N) {
    if (i % 3 != 0 && i % 5 != 0)
      ans += i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
namespace mp = boost::multiprecision;
// 任意長整数型
using bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;
// ついでに有理数型
using rat = boost::rational<bint>;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()

void solve(long long L, long long R, long long d){
  ll ans = 0;
  for (int i = L; i <= R; i++) {
    if(i%d == 0)ans++;
  }
  cout << ans << endl;
}

int main(){
    long long L;
  scanf("%lld",&L);
  long long R;
  scanf("%lld",&R);
  long long d;
  scanf("%lld",&d);
    solve(L, R, d);
    return 0;
}


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

int main(void){
    ll v[3];
    ll k;
    cin>>v[0]>>v[1]>>v[2]>>k;
    sort(v,v+3);
    cout<<v[0]+v[1]+(v[2]<<k)<<endl;
    return 0;
}


Measured memory_bytes: 256
#4 9
#1 3 5 6
#の時に1（正解は0）と出力されるがACになる

N, K = map(int, input().split())
a=list(map(int, input().split()))
a.sort()
ans = N
t = 0
for i in range(N-1, -1, -1) :
  if t+a[i] < K:
    t += a[i]
  else:
    ans = min(ans, i)
print(ans)


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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    H,W,K=MI()
    C=[]
    for i in range(H):
        c=input()
        C.append(c)
    
    import itertools
    ans=0
    for ite in itertools.product([0,1], repeat=H+W):
        temp=0
        for i in range(H):
            for j in range(W):
                if ite[i]==1 or ite[j+H]==1:
                    pass
                else:
                    if C[i][j]=="#":
                        temp+=1
        if temp==K:
            ans+=1
            
    print(ans)

main()


Measured memory_bytes: 68344
a = int(input())
if 400 <= a <= 599:
    print('8')
elif 600 <= a <= 799:
    print('7')
elif 800 <= a <= 999:
    print('6')
elif 1000 <= a <= 1199:
    print('5')
elif 1200 <= a <= 1399:
    print('4')
elif 1400 <= a <= 1599:
    print('3')
elif 1600 <= a <= 1799:
    print('2')
else:
    print('1')


Measured memory_bytes: 9196
#include <iostream>

using namespace std;

int main(){

int a,b,c,d;

cin >> a >> b >> c;

if(a > b){
d = b;
b = a;
a = d;
}
if(b > c){
d = c;
c = b;
b = d;
}
if(a > b){
d = b;
b = a;
a = d;
}
cout << a << " " << b << " " << c << endl;

}

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

const int N = 1e5 + 10; 

int n, m, k;
vector <int> adl1[N], adl2[N];

int par[N], sz[N];

int find(int a){
    if (par[a] == a) return a;
    return par[a] = find(par[a]);
}

void make(int a, int b){
    a = find(a);
    b = find(b);
    if (a == b) return;
    if (sz[a] < sz[b]) swap(a, b);
    par[b] = a;
    sz[a] += sz[b];
}

void dfs1(int node){
    for (auto x : adl1[node]){
        if (find(node) == find(x)) continue;
        make(node, x);
        dfs1(x);
    }
}

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

    cin >> n >> m >> k;
    for (int i=1;i<=n;i++){
        par[i] = i;
        sz[i] = 1;
    }
    for (int i=1;i<=m;i++){
        int a, b;
        cin >> a >> b;
        adl1[a].pb(b);
        adl1[b].pb(a);
    }

    for (int i=1;i<=k;i++){
        int a, b;
        cin >> a >> b;
        adl2[a].pb(b);
        adl2[b].pb(a);
    }

    for (int i=1;i<=n;i++){
        if (find(i) == i && sz[i] == 1){
            dfs1(i);
        }
    }

    for (int i=1;i<=n;i++){
        int kur = 0;
        int p = find(i);
        for (auto x : adl2[i]){
            if (find(x) == p) kur++;
        }
        cout << sz[p] - kur - (int)adl1[i].size() - 1 << " ";
    }
    cout << el;

    return 0;
}

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

int main(void){
	int N, A, B;
	cin >> N >> A >> B;
	string S;
	cin >> S;
	int Nj = 0, Nf = 0;
	rep(i,N){
		if (S[i] == 'c'){
			cout << "No" << endl;
		}
		else if (S[i] == 'a'){
			if (Nj+Nf < A+B) {
				cout << "Yes" << endl;
				Nj++;
			}
			else cout << "No" << endl;
		}
		else {
			if (Nj+Nf < A+B && Nf < B){
				cout << "Yes" << endl;
				Nf++;
			}
			else cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3716
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

typedef long long ll;
const int maxn=3e5+10,mod=998244353;
ll n,a,b,k,ans;
ll fac[maxn],inv[maxn];

inline ll fpow(ll a,ll n){
	ll res=1;
	for(;n;n>>=1,a=a*a%mod)
		if(n&1ll)
			res=res*a%mod;
	return res;
}
inline ll c(ll a,ll b){
	if(a<0||b<0||a<b)return 0;
	return fac[a]*inv[b]%mod*inv[a-b]%mod;
}

int main(){
	cin>>n>>a>>b>>k;
	fac[0]=1;
	for(int i=1;i<maxn;++i)
		fac[i]=fac[i-1]*i%mod;
	inv[maxn-1]=fpow(fac[maxn-1],mod-2);
	for(int i=maxn-1;i;--i)
		inv[i-1]=inv[i]*i%mod;
	for(int i=0;i<=n;++i)
		if(k>=i*a&&(k-i*a)%b==0){
			int x=i,y=(k-i*a)/b;
			if(y<=n)
				(ans+=c(n,x)*c(n,y))%=mod;
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
using Graph=vector<vector<int>>;
typedef long long ll;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
ll MOD=998244353;
#define INF 1000000000
#define MAX_V 100000

struct edge {
    int to;
    int cost;
};
using P = pair<int, int>;

int V=MAX_V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
    priority_queue<P,vector<P>,greater<P>> que;
    fill(d,d+V,INF);
    d[s]=0;
    que.push(P(0, s));
    while (!que.empty()){
        P p = que.top();
        que.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        for (int i=0;i<G[v].size();i++) {
            edge e=G[v][i];
            if (d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

int main(){
    int v,e,r;cin>>v>>e>>r;
    for(int i=0;i<e;i++){
        int a,b,c;cin>>a>>b>>c;
        edge e={b,c};
        G[a].push_back(e);
    }
    dijkstra(r);
    for(int i=0;i<v;i++){
        if(d[i]==INF) cout<<"INF"<<endl;
        else cout<<d[i]<<endl;
    }
}


Measured memory_bytes: 13160
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int main(){
    int s; cin>>s;
    if(s==1 || s==2 || s==4){
        cout << 4 << endl;
        return 0;
    }
    int cnt=0;
    int ans=1;
    while(1){
        if(s==4 && cnt==1){
            cout << ans << endl;
            return 0;
        }
        if(s==4 && cnt==0){
            cnt=1;
        }

        if(s%2==0){
            s/=2;
        }
        else{
            s=3*s+1;
        }
        ans++;
    }
}

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


using namespace std;

int main()
{
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	int dp[n][3];
	for(int i = 0;i < n ;i++)
		cin>>a[i]>>b[i]>>c[i]; // happiness points available on each day 
	// for(int i = 0;i<n;i++)
	// 	cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<'\n';
	for(int i = 0;i < n;i++)
	{
		for(int j = 0;j < 3;j++)
		{
          	dp[i][j] = INT_MIN;
			if(i == 0)		//base case
			{
				if(j == 0)
					dp[i][j] = a[i];
				else if(j == 1)
					dp[i][j] = b[i];
				else 
					dp[i][j] = c[i];
			}
			else
			{
				for(int k = 0;k < 3;k++)		//k means previous activity and j is present activity
				{
					if(j == k) 
						continue;
					else if(j == 0)
						dp[i][j] = max(dp[i][j] , dp[i-1][k] + a[i]);
					else if(j == 1)
						dp[i][j] = max(dp[i][j] , dp[i-1][k] + b[i]);
					else if(j == 2) 
						dp[i][j] = max(dp[i][j] , dp[i-1][k] + c[i]);
				}
			}
		}
	}
	cout<<max(dp[n-1][0] , max(dp[n-1][1] , dp[n-1][2]))<<'\n';
	return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int tyukan,kimatu,saisi;
		int ten;
		Scanner scan = new Scanner(System.in);
		
		while(true)
		{
			
			tyukan=scan.nextInt();
			kimatu=scan.nextInt();
			saisi=scan.nextInt();
			if(tyukan==-1&&kimatu==-1&&saisi==-1)
				break;
			if(tyukan==-1||kimatu==-1){
				System.out.println("F");
			}else{
				if(tyukan+kimatu>=80) {
					System.out.println("A");
				}else {
					if(tyukan+kimatu>=65) {
						System.out.println("B");
					}else{
						if(tyukan+kimatu>=50) {
							System.out.println("C");
						}else {
							if(tyukan+kimatu>=30) {
								if(saisi>=50) {
								System.out.println("C");
								}else {
									System.out.println("D");
								}
							}else {
								System.out.println("F");
							}
						}
					}
				}
					
			}
				
		}
		
	}
}

Measured memory_bytes: 25976
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

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

    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(Q, K);
    rep (i, Q) cin >> A[i];

    vector<int> P(N, K);
    vector<int> C(N);
    for (int i : A) {
        C[i-1]++;
    }

    rep(i, N) {
        P[i] -= Q - C[i];
        if (P[i] > 0) cout << "Yes" << "\n";
        else cout << "No" << "\n";
    }
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
int n,m;
int ax[55],ay[55],bx[55],by[55];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1; i<=n; i++)
		scanf("%d%d",&ax[i],&ay[i]);
	for(int j=1; j<=m; j++)
		scanf("%d%d",&bx[j],&by[j]);
	for(int i=1; i<=n; i++){
		int bes = 1000000000, id = -1;
		for(int j=1; j<=m; j++){
			int now = labs(bx[j]-ax[i]) + labs(by[j]-ay[i]);
			if(now < bes){
				bes = now;
				id = j;
			}
		}
		printf("%d\n",id);
	}
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		long h = long.Parse(input[0]);
		long w = long.Parse(input[1]);
    long n = long.Parse(input[2]);
    string[] inputa = Console.ReadLine().Split(' ');
    long sr = long.Parse(inputa[0]);
		long sc = long.Parse(inputa[1]);
		string s = Console.ReadLine();
    string t = Console.ReadLine();
		bool answer = false;
    long up = sr;
    long down = sr;
    long left = sc;
    long right = sc;

    for(int i = 0; i < n; i++)
    {
      //Console.WriteLine(right);
      if(s[i] == 'L')
      {
        left--;
        if(left == 0) answer = true;
      }
      if(s[i] == 'R')
      {
        right++;
        if(right == w+1) answer = true;
      }
      if(s[i] == 'U')
      {
        up--;
        if(up == 0) answer = true;
      }
      if(s[i] == 'D')
      {
        down++;
        if(down == h+1) answer = true;
      }

      if(t[i] == 'L')
      {
        right = Math.Max(right-1, 1);
      }
      if(t[i] == 'R')
      {
        left = Math.Min(left+1, w);
      }
      if(t[i] == 'U')
      {
        down = Math.Max(down-1, 1);
      }
      if(t[i] == 'D')
      {
        up = Math.Min(up+1, h);
      }
    }

		Console.WriteLine((answer) ? "NO" : "YES");
	}
}

Measured memory_bytes: 13268
import collections
N,K = map(int,input().split(' '))
A = list(map(int,input().split(' ')))
B = collections.Counter(A)
ball_count = B.most_common()
ball_count.sort(key=lambda x:x[1])
M = len(ball_count)
num = 0
for i in range(0,M-K):
  x,y = ball_count[i]
  num += y
print(num)

Measured memory_bytes: 39348
getter = -> {
   require 'stringio'
  _in = StringIO.new
  while l = gets
    _in << l
  end
  _in.string
}

x,y = getter.call.split(' ').map(&:to_i)

check = ->{
    rtn = false
    x.times{|i|
        rtn = true if (i*2 + (x-i)*4) == y
    }
    rtn
}

jdg = ->{
    break false if y > x*4
    break false if y < x*2
    break true if y == x*4
    break true if y == x*2
    break check.call
}
if jdg.call
    puts 'Yes'
else
    puts 'No'
end

Measured memory_bytes: 14380
#include <bits/stdc++.h>
using namespace std;
int main() {
	int H;
	int W;
	int K;
	string S;
	int p;
	int q;
  	int i2;
  	int j2;
	int b[8];
	int count;

	cin >> H >> W >> K;

 	vector<vector<int>> a(6, vector<int>(6));
	for (int i = 0; i < 6; i++) {
    	for (int j = 0; j < 6; j++) a.at(i).at(j)=0;
	}
	for (int i = 0; i < H; i++) {
		cin >> S;
    	for (int j = 0; j < W; j++) {
			if(S.at(j)=='#') a.at(i).at(j)=1;
		}
	}
	b[0]=1;
	b[1]=2;
	b[2]=4;
	b[3]=8;
	b[4]=16;
	b[5]=32;
	b[6]=64;
	b[7]=128;
  
	p=0;
	for (int i = 0; i < b[H]; i++) {
    	for (int j = 0; j < b[W]; j++) {
			count=0;
          	i2=1;
			for (int i1 = 0; i1 < H; i1++,i2*=2) {
				if((i & i2)==0) continue;
              	j2=1;
    			for (int j1 = 0; j1 < W; j1++,j2*=2) {
					if((j & j2)==0) continue;
					count+=a.at(i1).at(j1);
				}
				if(count>K) break;
			}
			if(count==K) p++;
		}
	}
	cout << p << endl;
	return 0;
}

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

int gcd(int a, int b) {
	return !b ? a : gcd(b, a % b);
}

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	int g = 0, maxx = 0;
	fori(i, 0, n) {
		int cur;
		scanf("%d", &cur);
		maxx = max(maxx, cur);
		g = gcd(g, cur);
	}
	puts(k % g == 0 && k <= maxx ? "POSSIBLE" : "IMPOSSIBLE");

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVETSE(c) reverse((c).begin(),(c).end())
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define ALL(a)  (a).begin(),(a).end()
// int gcd(int a,int b){return b?gcd(b,a%b):a;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> T maxt(T x,T y) {
    if (x>y) return x;
    else return y;
}
template<class T> T mint(T x,T y) {
    if (x>y) return y;
    else return x;
}
//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

/* //約数列挙
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}*/

int main() {
  int N,a,ans=0,n=1;
  cin >> N;
  REP(i,N) {
    cin >> a;
    n==a?n++:ans++;
  }
  ans = ans==N?-1:ans;
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<ll> vi;

const ll inf = 1e16;

vi knap(vector<pii> wb, int N){
	vi res(N+1, -inf);
	res[0] = 0;
	for(const auto &p:wb){
		rep(i,0,N-p.first+1){
			gmax(res[i+p.first], res[i] + p.second);
		}
	}
	return res;
}

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	vi a(3), b(3);
	rep(i,0,3)cin >> a[i];
	rep(i,0,3)cin >> b[i];
	vector<pii> v1,v2;
	rep(i,0,3){
		v1.emplace_back(a[i],b[i]);
		v2.emplace_back(b[i],a[i]);
	}
	auto res = knap(v1, n);
	ll nlim = 0;
	rep(i,0,res.size())gmax(nlim, res[i]-i);
	//cout << nlim << endl;
	nlim += n;

	auto res2 = knap(v2, nlim);
	ll nlim2 = 0;
	rep(i,0,res2.size())gmax(nlim2, res2[i]-i);
	//cout << nlim2 << endl;
	nlim2 += nlim;

	cout << nlim2 << '\n';
}


Measured memory_bytes: 198452
N = int(input())
a = list(map(int,input().split()))

color = [0]*9

for rate in a:
    if rate >= 3200:
        color[8] += 1
    else:
        color[rate//400] += 1
    
ans = 0

for i in range(8):
        if color[i] > 0:
            ans += 1
print(max(ans,1),ans + color[8])

Measured memory_bytes: 38256
n = gets.to_i
r = 0
if 400 <= n && n <= 599
  r = 8
elsif 600 <= n && n <= 799
  r = 7
elsif 800 <= n && n <= 999
  r = 6
elsif 1000 <= n && n <= 1199
  r = 5
elsif 1200 <= n && n <= 1399
  r = 4
elsif 1400 <= n && n <= 1599
  r = 3
elsif 1600 <= n && n <= 1799
  r = 2
elsif 1800 <= n && n <= 1999
  r = 1
end

puts r.to_s

Measured memory_bytes: 14292
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,a[100005],i,j,x,y;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(i=1;i<n;i++)
	{
		if(a[i]>a[i-1])
		{
			a[i]--;
		}
		if(a[i]<a[i-1])
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

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

using namespace std;

#define int long long
#define PB push_back
#define ALL(V) V.begin(), V.end()
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;

constexpr int INF = 1LL<<60;
constexpr int MOD = 1000000007;
constexpr int MAX_N = 100005;
constexpr int MAX_M = 200005;
constexpr int dx[] = {-1, 0, 1, 0};
constexpr int dy[] = {0, -1, 0, 1};

int n, m, q, d[MAX_N], sq[MAX_M], query[MAX_M], imos[MAX_M];
vector<int> G[MAX_N], S[MAX_N];
bool al[MAX_N];
pii edges[MAX_M];

void Bfs() {
    fill(d, d + MAX_N, INF);
    queue<pii> q;
    d[1] = 0;
    q.push({0, 1});

    while (q.size()) {
        pii p = q.front();
        q.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); ++i) {
            int to = G[v][i];
            if (d[to] <= p.first + 1) continue;
            d[to] = p.first + 1;
            q.push({d[to], to});
        }
    }
}

int Fill(int k) {
    if (al[k]) return 0;
    int res = 1;
    al[k] = true;
    for (int i = 0; i < S[k].size(); ++i) {
        res += Fill(S[k][i]);
    }
    return res;
}

void Enum() {
    for (int i = 1; i <= m; ++i) {
        pii te = edges[i], ue;
        if (d[te.first] == d[te.second]) continue;
        if (d[te.first] == d[te.second] + 1) {
            ue = {te.first, te.second};
        } else {
            ue = {te.second, te.first};
        }

        auto it = lower_bound(sq, sq + q, i) - sq;
        if (it != q && sq[it] == i) continue;
        S[ue.second].PB(ue.first);
    }

    Fill(1);
}

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

    cin >> n >> m >> q;
    for (int i = 1; i <= m; ++i) {
        int u, v;
        cin >> u >> v;
        G[u].PB(v);
        G[v].PB(u);
        edges[i] = {u, v};
    }

    for (int i = 0; i < q; ++i) {
        cin >> query[i];
        sq[i] = query[i];
    }
    sort(sq, sq + q);

    Bfs();
    Enum();

    for (int i = q - 1; 0 <= i; --i) {
        int r = query[i];
        pii te = edges[r], ue;
        if (d[te.first] == d[te.second]) continue;
        if (d[te.first] == d[te.second] + 1) {
            ue = {te.first, te.second};
        } else {
            ue = {te.second, te.first};
        }
        S[ue.second].PB(ue.first);
        if (!al[ue.second]) continue;
        imos[i] = Fill(ue.first);
    }

    int sum = 0;
    for (int i = 0; i < q; ++i) {
        sum += imos[i];
        cout << sum << endl;
    } 
}

Measured memory_bytes: 25052
N=int(input())
K=int(input())
X=int(input())
Y=int(input())
amount = 0
amount1=0
if K <= N:
    for i in range(1, K + 1):
        amount = amount + X
if K>N:
    for d in range(1, N+1):
        amount=amount+X
for j in range(K+1,N+1):
    amount1=amount1+Y
total=amount+amount1
print(total)

Measured memory_bytes: 2948
#include<bits/extc++.h>
#ifdef _debug 
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#include<bits/stdc++.h>
#define dout(i) 0&&0
#endif
#pragma GCC optimize("unroll-loops,no-stack-protector,O3")
#define eout(i) {cout << (i) << '\n';exit(0);}
#define rout(i) {return cout << (i) << '\n', 0;}
#define priority_queue __gnu_pbds::priority_queue
#define unordered_map __gnu_pbds::gp_hash_table
#define rep(a, b) {for(int _i = a;_i > 0;--_i){b;}}
#define multe int _T;for(cin >> _T;_T--;)
using namespace std;
using ll = long long;using ull = unsigned long long;using ul = unsigned;using db = double;
using __gnu_pbds::null_type;
template<typename T> void read(int n, T s){while(n--)cin >> *s, ++s;}
template<typename T> void write(int n, T s){while(n--)cout << *s << " \n"[n==0], ++s;}
template<typename T> using rbtree = __gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T> inline ostream& operator << (ostream &ou, const vector<T> &a){for(auto it = a.begin();it != a.end();++it)ou << (it != a.begin() ? " " : "") << *it;return ou;}
template<typename T1, typename T2>inline istream& operator >> (istream &in, pair<T1, T2> &a){return in >> a.first >> a.second;}
template<typename T1, typename T2>inline ostream& operator << (ostream &ou, const pair<T1, T2> &b){return ou << b.first << ' ' << b.second;}
template<typename T> inline long long pow(long long v, long long t, const T &p){long long res = 1;for(;t;t >>= 1, v = v * v % p)if(t & 1)res = res * v % p;return res;}
const int maxn = 1001;
//  q : if there is a group with X people, there must be ql ~ qr of these groups
//  g : from gl ~ gr people per group
int ql, qr, gl, gr, n;
const int p = 1e9+7;
ll dp[2][maxn];
ll fa[maxn]{1,1}, fainv[maxn]{1,1}, inv[maxn]{1,1};
#define C(a, b) (fa[a] * fainv[b] % p * fainv[a-b] % p)
#define pick(from, quan, team) (fa[from] * fainv[from-quan] % p * pow(fainv[quan/team], team, p) % p * fainv[team] % p)
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	for(int i = 2;i < maxn;++i){
		fa[i] = fa[i-1] * i % p;
		inv[i] = (p-p/i) * inv[p%i] % p;
		fainv[i] = fainv[i-1] * inv[i] % p;
	}
	cin >> n >> gl >> gr >> ql >> qr;
	dp[0][0] = 1;
	int cur = 1;
	for(int per = gl;per <= gr;++per, cur ^= 1){
		memcpy(dp[cur], dp[!cur], sizeof dp[0]);
		for(int gc = ql, quan = ql * per;gc <= qr and quan <= n;++gc, quan += per){
			for(int sor = 0;sor + quan <= n;++sor){
				if(dp[!cur][sor]){
					dp[cur][sor + quan] = (dp[cur][sor+quan] + (dp[!cur][sor] * pick(n-sor, quan, gc) % p)) % p;
				}
			}
		}
	}
	cout << dp[!cur][n] << '\n';
}

Measured memory_bytes: 256
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <utility>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iterator>
#include <sstream>

using namespace std;

int N;
bool p[100][100];

int main()
{
	while(cin>>N,N){
		memset(p,0,sizeof(p));
		for (int i = 0; i < N; i++){
			int m; cin>>m;
			for (int j = 0; j < m; j++){
				int x; cin>>x;
				x--;
				p[i][x] = true;
			}
			//p[i][i] = true;
		}
		int k; cin>>k;
		vector<int> l(k);
		for (int i = 0; i < k; i++){ cin>>l[i]; l[i]--;}

		int ans = -1;
		for (int i = 0; i < N; i++){
			int j;
			for (j= 0; j< k; j++){
				if(!p[i][l[j]]) break;
			}
			if(j == k){
				if(ans == -1){
					ans = i + 1;
				} else {
					ans = -1; break;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 916
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int >
#define F first
#define S second
#define mod 1000000007
///cout <<"Case #"<<it<<": ";
using namespace std;

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

    ll x; cin >> x;
    for(int i=-1000;i<=1000;i++){
        for(int j=-1000;j<=1000;j++){
            ll curr=(ll)pow(i,5)-pow(j,5);
            if(curr==x){
                cout <<i <<" "<< j << endl;
                return 0;
            }
        }
    }


    return 0;
}


Measured memory_bytes: 4044
#include<stdio.h>

int main(){
    int N,A[210000],C[210000],i;
    scanf("%d",&N);
    for(i=0;i<N-1;i++)scanf("%d",&A[i]);
    for(i=0;i<N;i++)C[i]=0;
    for(i=0;i<N-1;i++)C[A[i]-1]+=1;
    for(i=0;i<N;i++)printf("%d\n",C[i]);
}

Measured memory_bytes: 3288
from itertools import combinations
s = list(input())
len_s = len(s)
sum_ = 0

for i in range(len(s)):
    for t in combinations(range(1, len_s), i):
        copy_s = s[:]
        for cnt, idx in enumerate(t):
            copy_s.insert(cnt + idx, '+')
        sum_ += eval("".join(copy_s))

print(sum_)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"
#define INF (int)10000000000000000
#define PI (double)3.14159265358979
// #define M 421412341324321
#define MOD 1000000007


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

	
	string t, s;
	cin>>t>>s;
	string r = s+t;
	cout<<r;



	



	return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& v) {
    return is >> v.first >> v.second;
}

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& v) {
    for (T& i: v) is >> i;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& v) {
    return os << v.first << " " << v.second;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
    int n = (int) v.size();
    for (int i = 0; i < n; ++i) os << v[i] << (i == n - 1 ? "" : " ");
    return os;
}

template <typename T>
void in(T& x) {
    std::cin >> x;
}

template <typename T>
void out(const T H) {
    std::cout << (H);
}

template <typename T1, typename... T2>
void out(const T1 H, const T2... T) {
    std::cout << (H) << " "; out(T...);
}

template <typename T>
void eout(const char *s, const T H) {
    std::cerr << s << "=" << H << "\n";
}

template <typename T1, typename... T2>
void eout(const char *s, const T1 H, const T2... T) {
    while (*s != ',') std::cerr << *s++;
    std::cerr << "=" << H << " | "; eout(++s, T...);
}

#define nl                std::cout << "\n"
#define err(args...)      eout(#args, args)

#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define sz(v)             ((int) v.size())
#define all(v)            (v).begin(), (v).end()
#define lla(v)            (v).rbegin(), (v).rend()

#define no                std::cout << "NO\n"
#define yes               std::cout << "YES\n"

const int INF           = 2147483647;
const long long int LNF = 9223372036854775807LL;

using ll  = long long int;
using vi  = std::vector<int>;
using vb  = std::vector<bool>;
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N  = 505050;
const int MD = 1000*1000*1000 + 7;

int solve();
int main() {
    std::ios_base::sync_with_stdio(0); std::cin.tie(0);
    //std::cout.tie(0);

    //int t; in(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}

int solve() {
    int a, b; in(a); in(b);
    int t = 1, i = 0;
    while (1) {
        if (t >= b) return out(i), 0;
        --t; t += a; ++i;
    }
    return 0;
}


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

int main (){
	long long a, b, v, w, t;
	scanf("%lld%lld%lld%lld%lld", &a, &v, &b, &w, &t);
	if(v * t >= ((a - b) > 0 ? (a - b) : (b - a)) + w * t){
		puts("YES");
		return 0;
	}
	puts("NO");
	return 0;
}


Measured memory_bytes: 3672
/*
	ex3_2
	ruuu0048
*/
#include <stdio.h>
#include <math.h>
#define PI 3.14159265359 //πを定義

double radian_distance_cos(int hour,int minute); //時針と分針の間の角度の予言を返す関数

int main(void){


    int hour_length,minute_length; //時針と分針の変数を宣言
    int hour,minute; //時間Hと分Mの変数を宣言
    double distance; //求める距離の変数を宣言

    scanf("%d %d %d %d",&hour_length,&minute_length,&hour,&minute); //それぞれ入力
    
    distance = sqrt(pow(hour_length,2) + pow(minute_length,2) - 2 * hour_length * minute_length * radian_distance_cos(hour,minute)); //余弦定理を使う

    printf("%.16f\n",distance); //答えを出力

    return 0; 
}

double radian_distance_cos(int hour,int minute){

    double hour_radian,minute_radian; //時針と分針の0時からの角度の変数を宣言

    hour_radian = ((double)hour + (double)minute / 60) / 12 * (2 * PI); //ラジアンに変換

    minute_radian = (double)minute / 60 * (2 * PI); //ラジアンに変換

    return cos(hour_radian - minute_radian); //差の予言を返す

};

Measured memory_bytes: 2496