akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<stack>
#include<string>
#include<cstring>
#include<cmath>
typedef long long ll;
using namespace std;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll sum=0;
    while(n)
    {
    	sum++;
    	n=n/k;
    	//cout<<n<<endl;
	}
	cout<<sum<<endl;
}


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

using namespace std;

typedef unsigned long long ull;

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int n;
    while(cin >> n, n){
        vector<pair<int, int>> v(n);
        rep(i, n) cin >> v[i].second >> v[i].first;
        sort(v.begin(), v.end());
        int m = 0; bool is = true;
        rep(i, n){
            m += v[i].second;
            if(v[i].first < m){is = false; break;}
        }
        cout << (is?"Yes":"No") << endl;
    }
}

Measured memory_bytes: 1192
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[100010],B[100010],C[100010];
int dp[100010];
int dp2[100010];
int dp3[100010];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i]>>B[i]>>C[i];
	}
	for(int i=0;i<N;i++){
		dp[i]=max(dp2[i-1],dp3[i-1])+A[i];
		dp2[i]=max(dp[i-1],dp3[i-1])+B[i];
		dp3[i]=max(dp[i-1],dp2[i-1])+C[i];
	}
	cout<<max(dp[N-1],max(dp2[N-1],dp3[N-1]))<<endl;
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;


template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}
 
template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}



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

    int s;
    cin >> s;

    int a = s/100;
    int b = s%100;

    //cout << a << " "<< b << endl;

    
    string ans = "NA";

    if(0 < a && a <= 12 )
        ans = "MMYY";

    if(0 < b && b <= 12){
        ans = "YYMM";
        if(0 < a && a  <= 12 )
            ans = "AMBIGUOUS";
    }


    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
from scipy.sparse.csgraph import floyd_warshall
n,*a=map(int,open(0).read().split())
a,b=a[:n],a[n:]
d=[]
M=max(a)
for k in range(M-1,-1,-1):
    s=set(a)
    e=[[0]*(M+1)for _ in range(M+1)]
    for i in range(M+1):e[i][i]=1
    for i in d+list(range(k,0,-1)):
        t=s.copy()
        for x in s:
            e[x][x%i]=1
            t|={x%i}
        s=t
    c=floyd_warshall(e)
    for x,y in zip(a,b):
        if c[x,y]==float('inf'):
            d+=k+1,
            break
print(-(len(d)==M)or sum(2**k for k in d))

Measured memory_bytes: 13852
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
ll ncd(ll n,ll d){
    ll x = 1,y=1;
    for(int i=0;i<d;i++){
        x = x*(n-i)%mod;
        y = y*(i+1)%mod;
    }
    return x*modpow(y,mod-2,mod)%mod;
}
int main() {    
    srand(time(NULL));
    for(int j=0;j<14;j++){
    for(int i=0;i<26;i++){
        cout<<i+1<<endl;
    }
    }
    for(int i=0;i<1;i++){

          cout<<rand()%26+1<<endl;  
    }
}
    



Measured memory_bytes: 3612
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let 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")
  };
}

fn main() {
  input! {
    n: usize,
    p: [usize1; n],
  }
  let mut ans = 0;
  let mut i = 0;
  while i < n {
    if p[i] == i {
      ans += 1;
      i += 1;
    }
    i += 1;
  }

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


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;
const ll inf = 1001001001;
const ll mod = 1000000007;

int main() {
   int n;
   cin >> n;
   vector<int>c(n-1);
   vector<int>s(n-1);
   vector<int>f(n-1);
   vector<int>ans(n);
   rep(i, 0, n-1){
       cin >> c[i] >> s[i] >> f[i];
   }
   rep(i, 0, n-1){
       //iからN番目の時間をans[i]に格納
       ans[i] += c[i]+s[i];
       rep(j, i+1, n-1){
           if(ans[i] >= s[j]){
               int a;
               if((ans[i]-s[j])%f[j] == 0)a=0;
               else a=1;
               ans[i] = s[j]+((ans[i]-s[j])/f[j]+a)*f[j];
            }
            else{
               ans[i] = s[j];
            }
            ans[i] += c[j];
       }
   }
   rep(i, 0, n){
       cout << ans[i] << endl;
   }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define w(x) int x; cin>>x; while(x--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
using namespace std;
int main(){
#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	cin>>n;
	ll z=0;
	for(ll i=1; i<10; i++){
		for(ll j=1; j<10; j++){
			if(i*j==n){
				z=1;
				break;
			}
		}
	}
	if(z==0)
		cout<<"No";
	else
		cout<<"Yes";
	

}

Measured memory_bytes: 3600
n,k = map(int,input().split())
p = list(map(int, input().split()))
kt = [0]*n
ans = sum(p[0:k])
prev = sum(p[0:k])

for i in range(k,n):
    prev = prev - p[i-k] + p[i]
    ans = max(ans , prev)
      
print((ans+k)/2)

Measured memory_bytes: 71792
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string S, T = "AIZUNYAN", U = "AADINNUY";
int main() {
	cin >> S;
	int W = S.size() - 7;
	for (int i = 0; i < W; i++) {
		string V = S.substr(i, 8);
		sort(V.begin(), V.end());
		if (V == U) {
			for (int j = 0; j < 8; j++) {
				S[i + j] = T[j];
			}
			i += 7;
		}
	}
	cout << S << endl;
	return 0;
}

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

#define B begin()
#define E end()
#define I iterator
using pii = pair < int , int >;
using vi = vector < int >;
using llu = unsigned long long int;
using ll = long long int;
/*

//ofstream cout ("op.txt");
//ifstream fin("inp.in");
int main ()
{
    ll n;
    fin >> n;
    vector <ll> vec(n);
    ll val;
    for ( int i = 0 ; i < n ; i ++ ){
        fin >> val;
        vec[i] = val;
    }
    sort ( vec.B , vec.E , greater<ll>() );
    ll ansa = 0 , ansb = 0 ;
    ansa = vec[0];
    for ( int i = 1; i < n ; i++ ){
        if ( ansb < ansa )
            ansb += vec[i];
        else
            ansa += vec[i];
    }
    cout << max( ansa , ansb ) - min( ansa , ansb );
    return 0;
}
*/
int main()
{
    int n;
    cin >> n;
    vi vec(n - 1);
    for ( int i = 0; i < n - 1; i++ )
        cin >> vec[i];
    int sum = 0;
    sum += vec[0];
    for ( int i = 0; i < n - 2; i++ ){
        if ( vec[i] <= vec[i+1] ) sum += vec[i];
        else sum += vec[i+1];
    }
    sum += vec[n-2];
    cout << sum;
    return 0;
}




Measured memory_bytes: 256
n = int(input())
m, a, r, c, h = 0, 0, 0, 0, 0
for _ in range(n):
    i = input()
    i = i[0]
    if i == 'M':
        m += 1
    elif i == 'A':
        a += 1
    elif i == 'R':
        r += 1
    elif i == 'C':
        c += 1
    elif i == 'H':
        h += 1
 
ans = 0
from itertools import combinations
for i in combinations([m, a, r, c, h], 3):
    i, j, k = i
    ans += i * j * k
print(ans)

Measured memory_bytes: 9184
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int main(){
    int n;
    cin>>n;
    rep(i,n){
        char x;
        cin>>x;
        if(x=='Y'){
            cout<<"Four"<<endl;
            return 0;
        }
    }
    cout<<"Three"<<endl;
   
return 0;
}


Measured memory_bytes: 256
c, b, a, k = map(int, input().split())
s = min(c, k)
k -= s
if k == 0:
	print(s)
else:
	d = min(k, b)
	k -= d
	if k == 0:
		print(s)
	else:
		f = min(k, a)
		s -= f
		print(s)



Measured memory_bytes: 9184
def main():
    n = int(input())
    k = int(input())
    x = int(input())
    y = int(input())

    r = 0

    for i in range(n):
        if i < k:
            r += x
        else:
            r += y

    print(r)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.io.BufferedReader
import java.io.InputStreamReader

fun main(args: Array<String>) {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val n = br.readLine()
    val a = n[0].toString().toInt()
    val b = n[1].toString().toInt()
    val c = n[2].toString().toInt()
    val d = n[3].toString().toInt()
    val sum = a + b + c + d
    val plus = "+"
    val minus = "-"
    val op = arrayOf(plus, plus, plus)
    if (sum == 7) {
        println("$a+$b+$c+$d=7")
    } else {
        val diff = (sum - 7) / 2
        when (diff) {
            b -> op[0] = minus
            c -> op[1] = minus
            d -> op[2] = minus
            b + c -> {
                op[0] = minus
                op[1] = minus
            }
            b + d -> {
                op[0] = minus
                op[2] = minus
            }
            c + d -> {
                op[1] = minus
                op[2] = minus
            }
        }
        println("$a${op[0]}$b${op[1]}$c${op[2]}$d=7")
    }
}


Measured memory_bytes: 31384
"use strict";

function Main(input) {
  var input_arr = input.split(" ");
  var num1 = parseInt(input_arr[0], 10);
  var num2 = parseInt(input_arr[1], 10);

  if (num1 % 2 == 0 || num2 % 2 == 0) {
    console.log('Even');
  } else {
    console.log('Odd');
  }
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RI register int
#define int LL
typedef long long LL;

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc();
  while (ch < '0' || ch > '9') ch = gc();
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
}

struct Edges {
  int to, next, dis;
} e[15005];
struct Edge {
  int from, to, dis;
} tmp[15005];
int head[12505], tot, vis[12505], dis[12505], flag = 0, cnt[12505], n, ok[12505];
queue <int> q;

inline void addedge(int from, int to, int dis) {
  e[++tot] = (Edges){to, head[from], dis};
  head[from] = tot;
}

void Dfs(int now) {
  vis[now] = 1;
  for (RI i = head[now]; i; i = e[i].next)
    if (!vis[e[i].to]) Dfs(e[i].to);
}

void SPFA(int now) {
  memset(dis, -0x7f, sizeof(dis));
  q.push(now);
  dis[now] = 0;
  while (!q.empty()) {
    int t = q.front(); q.pop();
    ok[t] = 0;
    for (RI i = head[t]; i; i = e[i].next)
      if (dis[t] + e[i].dis > dis[e[i].to] && vis[e[i].to]) {
      	dis[e[i].to] = dis[t] + e[i].dis;
      	if (!ok[e[i].to]) ok[e[i].to] = 1, q.push(e[i].to), ++cnt[e[i].to];
      	if (cnt[e[i].to] >= n) return flag = 1, void();
      } 
  }
}

signed main() {
 // freopen("e.in", "r", stdin);
  int m, p; read(n), read(m), read(p);
  for (RI i = 1; i <= m; ++i)
    read(tmp[i].from), read(tmp[i].to), read(tmp[i].dis), tmp[i].dis -= p;
  for (RI i = 1; i <= m; ++i)
    addedge(tmp[i].to, tmp[i].from, tmp[i].dis);
  Dfs(n);
  memset(head, 0, sizeof(head));
  tot = 0;
  for (RI i = 1; i <= m; ++i)
    addedge(tmp[i].from, tmp[i].to, tmp[i].dis);
  SPFA(1);
  if (flag) puts("-1");
  else printf("%lld\n", max(0ll, dis[n]));
  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, t[100], sum, m, p, x;

int main() {
	cin >> n;
	rep(i,n) {
		cin >> t[i];
		sum += t[i];
	}
	cin >> m;
	rep(i,m) {
		cin >> p >> x;
		p--;
		cout << sum + (x-t[p]) << ln;
	}
}

Measured memory_bytes: 256
A,B,C,X,Y = (input().split())

A = int(A)
B = int(B)
C = int(C)
X = int(X)
Y = int(Y)



value = 0

na = 0
nb = 0
nc = 0


if A+B <= 2*C:
  value = X * A + Y * B
else:
  if X > Y:
    if 2*C <= A:
      nc = 2*X
    else:
      na = X - Y
      nc = 2*Y
  else:
    if 2*C <= B:
      nc = 2*Y
    else:
      nb = Y - X
      nc = 2*X
  value = A * na + B * nb + C * nc

print(value)
  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
ll d[3005][3005][4];
ll v[3005][3005];
int vis[3005][3005];
int main() {
  IOS;
  int r, c, k;
  cin >> r >> c >> k;
  for (int i = 0; i < k; i++) {
    int rr, cc, vv;
    cin >> rr >> cc >> vv;
    v[rr][cc] = vv;
  }
  for (int i = 1; i <= r; i++) {
    for (int j = 1; j <= c; j++) {
      for (int k = 0; k <= 3; k++) {
        d[i][j][0] = max(d[i - 1][j][k], d[i][j][0]);
        if (v[i][j])
          d[i][j][1] = max(d[i - 1][j][k] + v[i][j], d[i][j][1]);
        d[i][j][k] = max(d[i][j - 1][k], d[i][j][k]);
        if (k != 0 && v[i][j])
          d[i][j][k] = max(d[i][j - 1][k - 1] + v[i][j], d[i][j][k]);
      }
    }
  }
  ll ans = 0;
  for (int i = 0; i <= 3; i++) {
    // for (int j = 1; j <= r; j++) {
    //   for (int k = 1; k <= c; k++) {
    //     cout << d[j][k][i] << ' ';
    //   }
    //   cout << endl;
    // }
    ans = max(ans, d[r][c][i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 355668
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int ANS = 0;
	int N ;//
	int BSUM=0, CSUM=0,tmp;//
	int A[21];//各桁の数を格納
  	int B[21];//各桁の数を格納
  	int C[21];//各桁の数を格納
 
	//Nをスキャン
	scanf("%d", &N);
	//N個の数字をスキャン 0からN-1まで
 	for (int i = 0; i < N; i++) { 
		scanf("%d", &A[i]);
	}
	for (int i = 0; i < N; i++) { 
		scanf("%d", &B[i]);
      BSUM=BSUM+B[i];
	}
   	for (int i = 0; i < N-1; i++) { 
		scanf("%d", &C[i]);
	}
   	for (int i = 0; i < N-1; i++) { 
		if(A[i]==A[i+1]-1){
          tmp=A[i];
          CSUM=CSUM+C[tmp-1];
        }
	}
  
 
	ANS = BSUM + CSUM;
 
	printf("%d", ANS);
 
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define ll long long int
using namespace std;
int main()
{
    ll tc;

    ll a=0,b=0,c=0,n,x,y,z,cnt=0,sum=0;
    string str;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        string s;
        cin>>s;
        if(s=="AC")
            a++;
        else if(s=="WA")
            b++;
        else if(s=="TLE")
            c++;
        else if(s=="RE")
            cnt++;
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<cnt<<endl;



}




Measured memory_bytes: 3608
#include<bits/stdc++.h>
 using namespace std;
 #define int long long
 #define endl "\n"
 const int mod=1e9+7;
 #define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 #define clr(a,x) memset(a,x,sizeof(a))
 #define T int t;cin>>t; while(t--)
 #define vll vector<int> 
 #define v22 vactor<vector<int>>
#define pb push_back
 #define sz size
 #define str to_string
 #define um unordered_map<int,int>
 #define intt stoll
 #define sv() sort(a.begin(),a.end())
 #define vp vector<pair<int, int>> b(n) 
 vector<int> adj[1000001];    
 int v[1000001]={0};
int32_t main()
{
 int n,d=0,x=1000001,k;
 cin>>n>>k;
 vll a(n);
 for(int i=0;i<n;i++)
 cin>>a[i];
 int dp[n]={0};
 if(n<=k)
 cout<<a[n-1]-a[0]<<endl;
 else
 {
 dp[0]=0;
 
 for(int i=1;i<=k;i++)
 {
     dp[i]=abs(a[i]-a[0]);
 }
 for(int i=k+1;i<n;i++)
 {
   d=1000000000000;
  for(int j=1;j<=k;j++)
d=min(d,dp[i-j]+abs(a[i]-a[i-j]));
  dp[i]=d;
 }
 
 cout<<dp[n-1];
}
}

Measured memory_bytes: 28252
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}


//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var map = {
		AC : 0,
		WA : 0,
		TLE : 0,
		RE : 0
	};
	var keys = ["AC", "WA", "TLE", "RE"];
	for(var i = 0; i < N; i++){
		var s = next();
		map[s]++;
	}
	for(var i = 0; i < keys.length; i++){
		myout(keys[i] + " x " + map[keys[i]]);
	}
}


Measured memory_bytes: 41072
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
n = int(input())
l = make_divisors(n - 1)
l2 = make_divisors(n)
del l2[0]
ans = len(l) - 1
for i in l2:
    k2 = n
    while True:
        if k2 % i == 1:
            ans += 1
        k2 /= i
        if k2 % 1 != 0:
            break
print(ans)

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

using PP = pair<int, int>;
const int inf = 1e9;

int n;
vector<PP> P[4];
int ext[4][4];

int dir(char c) {
  if (c == 'R') return 0;
  if (c == 'U') return 1;
  if (c == 'L') return 2;
  if (c == 'D') return 3;
}

double cat(double t) {
  const double dx[] = { 1, 0, -1, 0 };
  const double dy[] = { 0, 1, 0, -1 };
  double lx = inf;
  double rx = -inf;
  double ly = inf;
  double ry = -inf;
  for (int k = 0; k < 4; ++k) {
    lx = min(lx, ext[k][2] + dx[k] * t);
    rx = max(rx, ext[k][0] + dx[k] * t);
    ly = min(ly, ext[k][3] + dy[k] * t);
    ry = max(ry, ext[k][1] + dy[k] * t);
  }
  return (rx - lx) * (ry - ly);
}

double sub(double a, double b) {
  double lo = a;
  double hi = b;
  for (int z = 0; z < 500; ++z) {
    double mlo = (lo + lo + hi) / 3;
    double mhi = (lo + hi + hi) / 3;
    double vlo = cat(mlo);
    double vhi = cat(mhi);
    if (vlo < vhi) {
      hi = mhi;
    } else {
      lo = mlo;
    }
  }
  return cat(lo);
}

// p ->    <- q   c
vector<double> events(PP p, PP q, PP c) {
  vector<double> ts;
  ts.push_back(c.first - p.first);
  ts.push_back(c.second - p.second);
  ts.push_back(q.first - c.first);
  ts.push_back(q.second - c.second);
  return ts;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x, y;
    char c;
    cin >> x >> y >> c;
    P[dir(c)].push_back(PP(x, y));
  }
  
  for (int k = 0; k < 4; ++k) {
    int xl = 1e9;
    int xr = -1e9;
    int yl = 1e9;
    int yr = -1e9;
    for (PP p : P[k]) {
      xl = min(xl, p.first);
      xr = max(xr, p.first);
      yl = min(yl, p.second);
      yr = max(yr, p.second);
    }
    ext[k][0] = xr;
    ext[k][1] = yr;
    ext[k][2] = xl;
    ext[k][3] = yl;
  }
  
  auto va = events(
    PP(ext[0][2], ext[0][0]),
    PP(ext[2][2], ext[0][0]),
    PP(
      min(ext[1][2], ext[3][2]),
      max(ext[1][0], ext[3][0])
      )
  );
  
  auto vb = events(
    PP(ext[1][3], ext[1][1]),
    PP(ext[3][3], ext[3][1]),
    PP(
      min(ext[0][3], ext[0][3]),
      max(ext[2][1], ext[2][1])
      )
  );
  
  vector<double> ts;
  for (double t : vb) if (t >= 0) ts.push_back(t);
  for (double t : va) if (t >= 0) ts.push_back(t);
  ts.push_back(0);
  ts.push_back(inf);
  sort(ts.begin(), ts.end());
  
  double mn = 1e50;
  for (int i = 1; i < ts.size(); ++i) {
    mn = min(mn, sub(ts[i - 1], ts[i]));
  }
  cout << fixed << setprecision(16) << mn << endl;
}


Measured memory_bytes: 1276
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    t1,t2=MI()
    a1,a2=MI()
    b1,b2=MI()
    if a1<b1:a1,a2,b1,b2=b1,b2,a1,a2
    if a1*t1+a2*t2==b1*t1+b2*t2:
        print("infinity")
        exit()
    if a1*t1+a2*t2>b1*t1+b2*t2:
        print(0)
        exit()
    x=a1*t1-b1*t1
    y=b1*t1+b2*t2-(a1*t1+a2*t2)
    ans=(x//y)*2
    if x%y:
        ans+=1
    print(ans)


main()

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

using namespace std;

int main()
{
    map<int,int>m;
    int n;
    cin>>n;
    int a[n];
    int maks=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        m[a[i]]++;
        if(m[a[i]]>maks)
        {
            maks=m[a[i]];
        }
    }
    if(maks==1)
    {
        cout<<"YES"<<endl;
    }else
    {
        cout<<"NO"<<endl;
    }

}


Measured memory_bytes: 10368
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

#define PB push_back
#define MP make_pair
#define SZ(a) a.size()
#define DEBUG(x) cout << #x << " = " << x << endl;

#define PR(A,n)  { cout << #A << " = "; for (int i = 1, _n = (n); i <= _n; i++) \
                    cout << A[i] << ' '; cout << endl; }
#define PR0(A,n) { cout << #A << " = "; for (int i = 0, _n = (n); i < _n; i++) \
                    cout << A[i] << ' '; cout << endl; }

using namespace std;

const int MAXN = (int) 1e5 + 5;

int a[MAXN];
int n;

int main() {
//    freopen("C.txt", "r", stdin);
    
    scanf("%d", &n);

    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    
    sort(a + 1, a + 1 + n);

    int first = 1;
    int last = 1;
    int res = 1;

    while (true) {
        last++;
        if (last == n + 1) break;

        while (a[last] - a[first] > 2)
            first++;

        if (last - first + 1 > res) 
            res = last - first + 1;
    }

    cout << res;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    vector<vector<int>> h(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        h[b].push_back(a);
    }

    int MIN = INF, s;
    rep(i, n) {
        vector<int> d(n, INF);
        d[i] = 0;
        queue<int> q;
        q.push(i);
        while (sz(q)) {
            int now = q.front();
            q.pop();
            for (int nxt : g[now]) {
                if (nxt == i) {
                    if (d[i] == 0)
                        d[i] = d[now] + 1;
                    else
                        chmin(d[i], d[now] + 1);
                } else {
                    if (d[nxt] == INF) {
                        q.push(nxt);
                        d[nxt] = d[now] + 1;
                    }
                }
            }
        }
        if (d[i] > 0) {
            if (chmin(MIN, d[i])) {
                s = i;
            }
        }
    }

    if (MIN == INF) {
        cout << -1 << endl;
        return 0;
    }
    cout << MIN << endl;

    vector<int> d(n, INF);
    d[s] = 0;
    queue<int> q;
    q.push(s);
    while (sz(q)) {
        int now = q.front();
        q.pop();
        for (int nxt : g[now]) {
            if (nxt == s) {
                if (d[nxt] == 0)
                    d[nxt] = d[now] + 1;
                else
                    chmin(d[nxt], d[now] + 1);
            } else {
                if (d[nxt] == INF) {
                    q.push(nxt);
                    d[nxt] = d[now] + 1;
                }
            }
        }
    }

    vector<int> ans;
    ans.push_back(s);
    int now = s;
    rep(i, MIN - 1) {
        for (int pre : h[now]) {
            if (d[pre] + 1 == d[now]) {
                ans.push_back(pre);
                now = pre;
                break;
            }
        }
    }
    rep(i, MIN) cout << ans[i] + 1 << endl;
}


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

int main(){
  int n,m,c,co,i,j,sum;
  cin >> n >> m >> c;
  vector<int> b(m);
  vector<vector<int>> a(n,vector<int>(m));
  for(i=0;i<m;++i){
    cin >> b[i];
  }
  for(i=0;i<n;++i){
    for(j=0;j<m;++j){
      cin >> a[i][j];
    }
  }
  sum=0;
  co=0;
  for(i=0;i<n;++i){
    for(j=0;j<m;++j){
      sum=sum+a[i][j]*b[j];
    }
    sum=sum+c;
    if(sum>0){
      co=co+1;
    }
    sum=0;
  }
  cout << co << endl;
  return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
int M;
int ans = 0;
int digi[4] = {-1, -1, -1, -1};
bool flag = true;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int s, c;
        cin >> s >> c;
        if(digi[s] == c) continue;
        else if(digi[s] != -1) flag = false;
        if(s == 1 && c == 0 && N != 1) flag = false;
        
        digi[s] = c;
        for(; s < N; s++){
            c *= 10;
        }
        ans += c;
    }
    if(digi[1] == -1 && N != 1){
        int add = 1;
        for(int i = 1; i < N; i++){
            add *= 10;
        }
        ans += add;
    }
    cout << (flag ? ans : -1) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        for(int i = 1; i <= 5; i++){
            if(i != sc.nextInt()){
                System.out.println(i);
                return;
            }
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

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

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

	string s;
	cin >> s;

	int q;
	cin >> q;

	vector<int> v(q);
	rep(i, q) cin >> v[i];

	vector<int> dsum(n+1, 0);
	rep(i, n) dsum[i+1] += dsum[i] + (s[i] == 'D' ? 1 : 0);

	for(int k : v){
		ll ans = 0;
		deque<int> q;

		ll t = 0;
		for(int i = 0; i < n; i++){
			if(i-k >= 0 && s[i-k] == 'D'){
				t -= q.size();
			}
			
			if(q.size() > 0 && q.back() < i - (k - 2)){
				q.pop_back();
			}

			if(s[i] == 'M'){
				q.push_front(i);
				t += dsum[i] - dsum[max(i-(k-1), 0)];
			}

			if(s[i] == 'C') ans += t;
		}

		cout << ans << endl;
	}
}


Measured memory_bytes: 6556
#include <stdio.h>

int main(void) {

  long long n, h, i, max = -1000000, min = 1000000 ,sum = 0;
  scanf("%lld", &n);
  for(i = 1; i <= n; i++) {
    scanf("%lld", &h);
    if(min > h)
      min = h;
    if(max < h)
      max = h;
    sum = sum + h;
  }
  printf("%lld %lld %lld\n", min, max, sum);

  return 0;
 
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int w, h, n;
	cin >> w >> h >> n;
	
	int ans = h * w;
	int maxx = w, maxy = h, minx = 0, miny = 0;
	
	for(int i = 0; i < n; ++i) {
		int x, y, a;
		cin >> x >> y >> a;
		
		if( a == 1 ) {
			ans -= max(0, x - minx) * max(0, maxy - miny);
			minx = max(minx, x);
		}
		
		if( a == 2 ) {
			ans -= max(0, maxx - x) * max(0, maxy - miny);
			maxx = min(maxx, x);
		}
		
		if( a == 3 ) {
			ans -= max(0, maxx - minx) * max(0, y - miny);
			miny = max(miny, y);
		}
		
		if( a == 4 ) {
			ans -= max(0, maxx - minx) * max(0, maxy - y);
			maxy = min(maxy, y);
		}
	}
	
	cout << max(0, ans) << endl;
	
	return 0;
}


Measured memory_bytes: 3592
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
int main() {
	//入力
	int r,D,x;
	cin >> r >> D >> x;
	//処理
	//出力
	for (int i = 0; i < 10; i++) {
		x = r * x - D;
		cout << x << endl;
	}
}

Measured memory_bytes: 256
nn, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]


def check(n):  # 満たすかどうかを判定
    ss = str(n)
    if len(ss) != nn:  # 全探索する中で桁数が違っていたらfalseを返す
        return False
    for s, c in sc:
        if ss[s - 1] != str(c):  # その桁で数字が合っているかどうかをみる
            return False
    return True


for i in range(1000):
    if check(i):
        print(i)
        exit()
print(-1)

Measured memory_bytes: 3060
def resolve():
    '''
    code here
    '''
    N = input()
    res = N[-1]

    if int(res) in [2,4,5,7,9]:
        print('hon')
    elif int(res) in [0,1,6,8]:
        print('pon')
    else:
        print('bon')

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9176
from math import sqrt
N,D = map(int,input().split())
xy = [list(map(int,input().split())) for x in range(N)]
c = 0
for n in range(N):
  xyx = xy[n]
  tmp = sqrt(xyx[0]**2 + xyx[1]**2)
  if tmp <= D:
    c += 1
print(c)

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

int main(){
  int AB, BC, CA;
  cin >> AB >> BC >> CA;

  cout << AB * BC / 2 << endl;
}

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

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int s, w;
    cin >> s >> w;
    if (s <= w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
} 

Measured memory_bytes: 3648
#include <stdio.h>
int main(){
	int A,B,a,b,c,d,p;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&p);
	A=a*p;
	if(p<=c){
		B=b;
	}
	else {
		B=b+(p-c)*d;
	}
	if(A>B){
		printf("%d\n",B);
	}
	else{
		printf("%d\n",A);
	}
	return 0;
}

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

int main(){
  int X,ans=0;
  cin >> X;
  rep(i,100){
    int num = 0;
    for(int j=2;j<=100;++j){
      num = pow(i,j);
      if(num<=X){
        ans = max(num,ans);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    int n, k; cin >> n >> k;
    vi p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    int sum = 0;
    rep(i, k) sum += p[i];
    cout << sum << endl;


    return 0;
}

Measured memory_bytes: 3632
n,c,k = map(int,input().split())
l = sorted(list(int(input()) for _ in range(n)))
bus = 1
now = 1
time = l[0]+k
for i in range(1,n):
  b = l[i]
  if b<=time and time<=b+k and now<c:
    now += 1
  else:
    bus += 1
    now = 1
    time = l[i]+k
print(bus)

Measured memory_bytes: 8264
#include <iostream>
#include <stdio.h>
#include <string>
#include <map>
#include <stack>
#include <vector>
#include <string.h>
#include <set>
#include <queue>
#include <time.h>
#include <cmath>
#include <algorithm>

using namespace std;

int input[20][10010];
bool flipRow[20];

int main()
{
	int i , j , n , m;
	while (scanf("%d%d" , &n , &m) != EOF)
	{
		if (n == 0 && m == 0)
			break;

		int maxNum = - 1;

		for (i = 0;i < n;i ++)
			for (j = 0;j < m;j ++)
				scanf("%d" , &input[i][j]);

		for (int mask = 0;mask < (1 << n);mask ++)
		{
			int temp = 0;
			memset(flipRow , 0 , sizeof(flipRow));
			for (i = 0;i < n;i ++)
			{
				if (mask & (1 << i))
					flipRow[i] = true;
			}
			// ?????¬?????????
			for (j = 0;j < m;j ++)
			{
				int count1 = 0 , count0 = 0;
				for (i = 0;i < n;i ++)
				{
					if (input[i][j] == 1)
					{
						if (flipRow[i])
							count0 ++;
						else
							count1 ++;
					}
					else
					{
						if (flipRow[i])
							count1 ++;
						else
							count0 ++;
					}
				}
				temp = temp + max(count0 , count1);
			}
			if (temp > maxNum)
				maxNum = temp;
		}
		printf("%d\n" , maxNum);
	}
	return 0;
}

Measured memory_bytes: 1576
n = gets.to_i
nums = []
n.times {
	nums.push( gets.to_i )
}
nums.sort!

start = 0
for i in ( 2 .. nums[-1] )
	break if nums[-1] < i*i
	(nums.length-1).downto( start ) { |j|
		if nums[j] == i
			start = j + 1
			break
		end
		if 0 == nums[j]%i
			nums.delete_at( j )
		end
	}
end
puts( nums.length )

Measured memory_bytes: 6192
def i1str():
    return input()


def istrs(n=None):
    if n is None:
        return input().split()
    a = []
    for _ in range(n):
        a.append(istrs())
    return a


def i1num():
    return int(input())


def inums(n=None):
    if n is None:
        return list(map(int, input().split()))
    a = []
    for _ in range(n):
        a.append(inums())
    return a


def ostrs(l, sp=" "):
    print(sp.join(l))


def onums(l, sp=" "):
    print(sp.join(map(str, l)))


def solve(a, b, c, d):
    is_a_turn = True
    while True:
        if a <= 0:
            return "No"
        if c <= 0:
            return "Yes"
        if is_a_turn:
            c -= b
        else:
            a -= d
        is_a_turn = not is_a_turn


if __name__ == "__main__":
    a, b, c, d = inums()
    print(solve(a, b, c, d))


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = a; i <= min(a + k - 1, b); i++) cout << i << endl;
    for (int i = max(b - k + 1, a + k); i <= b; i++) cout << i << endl;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};


#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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


ll dp[110][100010] = {INF};



void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c; cin >> a >> b >> c;
    string ans = (a+b+c>21)?"bust":"win";
    cout << ans << endl;
    
}



signed main() {
    
    
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> c(n),s(n),f(n);
  for (int i = 0; i < n-1; i++)
  {
    cin >> c[i] >> s[i] >> f[i]; 
  }

  for (int i = 0; i < n-1; i++)
  {
    int t=0;
    for (int j = i; j < n-1; j++)
    {
      if(t<=s[j]) t=s[j]+c[j];
      else if(t%f[j]==0) t+=c[j];
      else t+=c[j]+f[j]-t%f[j];
    }
    cout << t << endl;
  }
  cout << 0 << endl;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

        // 入力(a)
        int a = sc.nextInt();
        // 入力(b)
        int b = sc.nextInt();
        // 入力(c)
        int c = sc.nextInt();

        Map<Integer, Integer> color = new HashMap<>();
        color.put(a, a);
        color.put(b, b);
        color.put(c, c);
        System.out.println(color.size());
        sc.close();
    }
}

Measured memory_bytes: 20820
//AtCoder1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream> 
#include <algorithm>
#include <math.h> 
#include <vector>
using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;
    cout << max({ 2 * A -1,A + B,2 * B - 1 }) << endl;
}


Measured memory_bytes: 256
#define a(x,y) a[x][y]++
a[99][99],x,y,z,i;
main()
{
  for(;~scanf("%d,%d,%d",&x,&y,&z);)
    {
      x+=10;y+=10;
      a(x,y);
      a(x-1,y);
      a(x,y-1);
      a(x+1,y);
      a(x,y+1);
      if(z>1)
	a(x+1,y+1),a(x+1,y-1),a(x-1,y+1),a(x-1,y-1);
      if(z>2)
	a(x-2,y),a(x+2,y),a(x,y-2),a(x,y+2);
      
    }
  for(z=0,x=9;x++<19;)
    for(y=9;y++<19;)
      {
	
	!a[x][y]&&z++;
	if(a[x][y]>i)i=a[x][y];
      }
  printf("%d\n%d\n",z,i);
  exit(0);
}

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

constexpr int MAXN = 1e5;
int weight[101];
int value[101];
long long dp[101][MAXN + 1];

int main()
{
    int n, w;
    cin >> n >> w;
    for (int i = 1; i <= n; i++)
        cin >> weight[i] >> value[i];

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            if (weight[i] <= j)
                dp[i][j] = max(dp[i - 1][j], value[i] + dp[i - 1][j - weight[i]]);
            else
                dp[i][j] = dp[i - 1][j];
            //cout << j << " " << weight[i] << "\n";
        }
        
    }
    cout << dp[n][w] << "\n"; 
}

Measured memory_bytes: 78464